have in 100 records in a file i want to read first 3 records
and skip next 3 records and agan i want to read 3 records and
again i want to skip 3 records...

Answers were Sorted based on User's Feedback



have in 100 records in a file i want to read first 3 records and skip next 3 records and agan i w..

Answer / kairoon

In working storage declare
01 ws-count1 pic s9(4) comp value zeroes.
01 ws-count2 pic s9(4) comp value zeroes.

In procedure division

PERFORM 200000-PROCESS THRU 200000-EXIT
UNTIL WS-EOF-IN = 'Y'.
200000-PROCESS.

READ IN-FILE AT END MOVE 'Y' TO WS-EOF-IN
GO TO 200000-EXIT.
ADD 1 TO WS-COUNT1
IF WS-COUNT1 <= 3
MOVE IN-REC TO OUT-REC
WRITE OUT-REC
ELSE
ADD 1 TO WS-COUNT2
IF WS-COUNT2 = 3
MOVE ZEROES TO WS-COUNT1
WS-COUNT2
END-IF
END-IF.
200000-EXIT.
EXIT.

Is This Answer Correct ?    26 Yes 2 No

have in 100 records in a file i want to read first 3 records and skip next 3 records and agan i w..

Answer / santhosh

We can do it through JCL by using sort utility ..Through splitby=3 in outfil statement giving two different outputs..It will store two alternative records into two datasets alternatively

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More COBOL Interview Questions

How do you submit JCL via a Cobol program?

5 Answers   IBM,


how do you reference the fixed unblock file formats from cobol programs

0 Answers  


1.Can we define condition-name conditions in FD entry.

11 Answers  


what is the maximum error code in mainframe

2 Answers  


What happens when we move a comp-3 field to an edited (say z (9). Zz-)?

0 Answers  






what is the difference between Normal vaiable and comp variable.

5 Answers   DELL,


01 a pic s9(5) value -12345, if we disply a , the sign will overpunched with last digit but i need to get the miuns sign in the result?

7 Answers  


Can JUSTIFIED be used for all the data types?

3 Answers  


When the working storage variables get allocated? a.At Compile time b.At starting of the run time c.At end of the run time. d.None of these

6 Answers   Wipro,


Explain what you understand by passing by value.

0 Answers  


What is the significance of the PROGRAM-ID paragraph? If this name doesnt match with the name of the COBOL program, does it make a difference? Is the name specified in the PROGRAM-ID paragraph used as a name for the load module or any such thing?

4 Answers   IBM,


what are the isolation levels and where we use it in the db2 program

3 Answers   TCS,


Categories