wirte a pgm in using files in which we hav 10 ,20,30 40...100
records in inputfile and i want them to be send to outputfile
in reverse order.
PLZ HELP ME OUT .........THIS IS A RECENT QUESTION IN IGATE..

Answers were Sorted based on User's Feedback



wirte a pgm in using files in which we hav 10 ,20,30 40...100 records in inputfile and i want them ..

Answer / quasar chunawala

However, if there are a fixed no. of records, as you have
mentioned in the question - which may not always be the
case with Production Files(They may contain millions of
records), you may follow this approach.

1. Read all the records into a COBOL array(table) A
(1,2,...10).
PERFORM VARYING I FROM 1 BY 1 UNTIL I>10
READ INPUT-FILE
MOVE INPUT-RECORD TO WS-RECORD(I)
END-PERFORM.

2. Print the data from the COBOL Array into Output-file.
PERFORM VARYING I FROM 10 BY -1 UNTIL I<1
WRITE WS-RECORD(I)
END-PERFORM.

Is This Answer Correct ?    5 Yes 1 No

wirte a pgm in using files in which we hav 10 ,20,30 40...100 records in inputfile and i want them ..

Answer / binary logics

*hival setgt pfrec
90 doueq *on 90 is a indicator for End of file
readp pfrec
write newpfrec
enddo

Is This Answer Correct ?    1 Yes 0 No

wirte a pgm in using files in which we hav 10 ,20,30 40...100 records in inputfile and i want them ..

Answer / siris

//SYSIN DD *
SORT FIELDS = COPY
OUTREC=(10,100,SEQNUM,4,ZD)
/*
0R
//SYSIN DD *
SORT FIELDS=(100,4,ZD,DESC)
OUT REC=(10,100)
/*

Is This Answer Correct ?    0 Yes 0 No

wirte a pgm in using files in which we hav 10 ,20,30 40...100 records in inputfile and i want them ..

Answer / quasar chunawala

There is no such facility on Mainframe COBOL to read a
Sequential File(PS), backwards. PS(Physical Sequential)
files are meant to be read in a straight-sequential fashion
record-by-record one at a time, till you reach the Desired
record.

Is This Answer Correct ?    1 Yes 3 No

wirte a pgm in using files in which we hav 10 ,20,30 40...100 records in inputfile and i want them ..

Answer / adarsh

just sort the input file in descending order..

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More COBOL Interview Questions

if you code move high-values to variable,can you move it into numeric variable or alphanumeric variable?

1 Answers   Patni,


How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2 1?please clear my doubt any one

10 Answers   IBM,


How many maximum number of procedures can we write in one COBOL program?

5 Answers  


Consider the following code: 77 A PIC 99V99 VALUE 55.35 77 B PIC 99V999 VALUE 32.754 ADD B TO A ON SIZE ERROR DISPLAY "ERROR!!!" What will be the result ? (a) A=88.10, B=32.754 (b) A=87.00 B=32.754 (c) A=87.10 B=32.754 (d) ERROR!!! will be DISPLAYed on the screen.

3 Answers   TCS,


What are literals?

0 Answers  






Scenario: I have 3 Input Files.Read the first i/p file and depending on certain business logic, I want to read wither i/p file-2 or i/p file-3.Now, depending on certain business logic applied to the record read from either file-2 or file-3, I decide to write them to either output file-2 or output file-2. Question: How many job steps are necessary to implement a solution for the above.

2 Answers   TCS,


Explain how you can characterize tables in cobol?

0 Answers  


Hi................... I have records like this aaaa cccc bbbb And i want output like this bbbb cccc aaaa How can it possible ?. Note:Please make sure records are in unsorted order. somebody plzzz help me.

1 Answers  


2 input fles: 2 flat files, with different number of records. both are having unique key for each record and already sorted in ascending order . match these files using unique key and in output only matching key value has to be written. please procide cobol logic

0 Answers  


) What is the use of IGNORE?

1 Answers   IBM,


Hi , I am posting some questons which are asked at interview. These may help u for ur interview... what is static and dynamic call?

2 Answers   TCS,


What is mean by maxcc

7 Answers   Syntel,


Categories