have in 100 records in a flat file i want to move records
like 1,3,5,7,9,11,.. to Output file1 and
2,4,6,8,10,12,14 .. records moved to Output file2..Pls
Provide real time answer..
Answer Posted / xxx
Since I assume this is a COBOL question (and not JCL), I have tried below code.
-------------------------------------------------------
OPEN INPUT DASA
OPEN OUTPUT DASB DASC
INITIALIZE WS-NUM.
MOVE 'N' TO WS-EOF-SW.
READ DASA INTO WS-NUM
AT END MOVE 'Y' TO WS-EOF-SW
END-READ
PERFORM UNTIL WS-EOF-SW = 'Y'
DIVIDE WS-NUM BY 2 GIVING WS-Q REMAINDER WS-R
IF WS-R = 1
WRITE DASB-RCD FROM WS-NUM
ELSE
WRITE DASC-RCD FROM WS-NUM
END-IF
READ DASA INTO WS-NUM
AT END MOVE 'Y' TO WS-EOF-SW
END-READ
END-PERFORM
CLOSE DASA DASB DASC
STOP RUN
.
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
How do you code cobol to access a parameter that has been defined in jcl? And do you code the parm parameter on the exec line in jcl?
How do you get the data to code the BMS macro?
What is the difference between Global and External Variables?
Write the code implementing the perform … varying.
What are the cobol coding sheets?
write a cobol logic. i have file that has 10 records .1 record go to first output file and second record goes to 2 output and etc
What is the difference between external and global variables in COBOL?
I have File 1 occurs 5 times with Employee-ID,Employee-Name,Employee-Dept (EEE and MECH). I have File 2 occurs 10 times with Employee-ID,Employee-Name,Employee-Dept (EEE,CIVIL,CHEMICAL and MECH). In FIle 1 and FIle 2 , for matching Employee-DEPT (Only MECH) , we need to move entire records from file1 to file 2. We should not use 2D array. Your help is needed here.
What is Pic 9v99 Indicates in COBOL?
can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there
Why occurs cannot be used in 01 level in COBOL?
Explain how will you differentiate between an internal and an external sort, the pros and cons, internal sort syntax etc
A table has two indexes defined. Which one will be used by the SEARCH?
How to print 10 to 1 if the input have only 10 digit number?
how do you reference the fixed unblock file formats from cobol programs