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


Please Help Members By Posting Answers For Below Questions

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?

806


What is the difference between perform … with test after and perform … with test before?

1002


How you can read the file from bottom?

749


How arrays can be defined in COBOL?

742


What is the difference between a binary search and a sequential search what are the pertinent cobol?

823






How to print 10 to 1 if the input have only 10 digit number?

919


i have 10 names in an array and my name is one of them also array is not in sorted order i need to display my name using index how will i do this

1086


State the various causes of s0c1, s0c5 and s0c7.

747


What are declaratives and what are their uses in cobol?

797


Define static linking and dynamic linking.

766


What is the difference between structured cobol programming and object alternativelyiented cobol?

855


I have a File that has duplicate records. I need only those records that occur more than thrice.?

8962


How to use the same COBOL program in Batch and CICS on lines? explain with an example

2007


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

512


What is the default value(s) for an initialize? What keyword will allow for an override of the default?

752