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

1.What is the default print format in cobol?

5 Answers   HSBC,


what is scope terminator

2 Answers   IBM,


What is SDSF?

13 Answers   IBM,


what are the limitations of Inline Perform?

3 Answers   Zensar,


Name the divisions in a COBOL program ?

7 Answers  






I want to declare a field with data type Double in my COBOL program. how shall i do that ?

5 Answers  


How many times the loop runs here 01 a pic 9(2) value 10. perform para1 a times stop run. para1: move 20 to a.

3 Answers  


INREC AND OUTREC? HOW TO SPLIT 5K RECORDS TO DIFFERENT FILES IN A FILE IN COBOL? RESTART IN COBOL-DB2? ISOLATION LEVELS?

0 Answers  


Consider the following COBOL entries: 05 X PIC 99 VALUE 10. SUBTRACT 20 FROM X. The resultant value of X wil be

7 Answers   TCS,


What is an in-line perform ?

4 Answers   Accenture,


if a dataset is already created with fixed length but after that i want to change fixed length to variable length then how is it possible

3 Answers   IBM,


What are the situations u have used in ur project for Subcript and Index ? 1.if u use Subscript why not Index,why u choose Subscript only? 2.if u use Index why not Subscript,what abt Displacement?

2 Answers   Cap Gemini,


Categories