i have a file which contains records like
10,30,90,50,20,40,80,60,70
i want to display these records in reverse order like
70,60,80,40,20,50,90,30,10
please give me the cobol code (do not sort the records)
Answer Posted / ch.ranveer singh gurjar
you can try its give you 100% exact output...
above solution for file its for no
NOTE:USE RIGHT JCL AND RIGHT FORMAT INPUT AND OUTPUT FILE
by
CH. RANVEER SINGH GURJAR(ACS A XEROX)
IDENTIFICATION DIVISION.
PROGRAM-ID. 'OCCURS'.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INFILE ASSIGN TO DD1.
SELECT OUTFILE ASSIGN TO DD2.
DATA DIVISION.
FILE SECTION.
FD INFILE.
01 INREC.
05 IN-NUM PIC X(2).
05 FILLER PIC X(78).
FD OUTFILE.
01 OUTREC.
05 OUT-NUM PIC X(2).
05 FILLER PIC X(78).
WORKING-STORAGE SECTION.
01 WS-COUNT PIC 9(4).
01 EOF PIC X(1) VALUE 'N'.
01 ARRAY1.
05 ARREC OCCURS 1 TO 50 TIMES DEPENDING ON WS-COUNT.
10 AR-NUM PIC X(5).
PROCEDURE DIVISION.
MOVE 1 TO WS-COUNT.
OPEN INPUT INFILE.
OPEN OUTPUT OUTFILE.
PERFORM MOVE-RECORD UNTIL EOF = 'Y'.
PERFORM PARA1 UNTIL WS-COUNT = ZEROS
CLOSE INFILE.
CLOSE OUTFILE.
STOP RUN.
MOVE-RECORD.
READ INFILE AT END MOVE 'Y' TO EOF
NOT AT END
MOVE INREC TO ARREC(WS-COUNT)
DISPLAY WS-COUNT
ADD 1 TO WS-COUNT.
PARA1.
MOVE ARREC(WS-COUNT) TO OUTREC
WRITE OUTREC
SUBTRACT 1 FROM WS-COUNT.
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
Write a program to explain size error.
i made it to stage 3 of an interview process wednessday they will quiz my knowledge again face to face for an analyst role recruiter said it will be based on Business requirements system is cobol and good ideas what they might ask etc
Are you comfortable in cobol or jcl?
What is report-item in COBOL?
Define static linking and dynamic linking.
How to change size of Initial number of records to *NOMAX for ALL PF files from perticular library, how can I do that
There are 5 fields and 1000 records in a file. Unload it into an array. Write the syntax for declaration and how will you unload it.
What is inspect in cobol ?
Can you please let me know the centre name of INS certification in Kolkata.
How can we find that module can be called – whether DYNAMICALLY or STATICALLY?
What is length is cobol?
how do you reference the variable block file formats from cobol programs
How you can characterize tables in cobol?
INREC AND OUTREC? HOW TO SPLIT 5K RECORDS TO DIFFERENT FILES IN A FILE IN COBOL? RESTART IN COBOL-DB2? ISOLATION LEVELS?
How can you get the ksds file records into your cobol program?