I have file with data as follows
data
1
2
3
4
5
I need to read 1 and 5 ,then 2 and 4 then like..
upto end of file, can any one help on this

Answers were Sorted based on User's Feedback



I have file with data as follows data 1 2 3 4 5 I need to read 1 and 5 ,then 2 and 4 then li..

Answer / vj

1. Find the greatest RRN of the file
2. Have 2 numeric counters.
3. Initialize counter1 to 1
4. Initialize counter2 to the max RRN
5. Chain with counter1 and read the record
6. Chain with Counter2 and read the record
7. Increment counter1
8. Decrement Counter2
9. Repeat Steps 5 to 8 in loop unitl counter 1 = Counter 2
(when counter 1=counter 2) we would have reached the middle of the file

Is This Answer Correct ?    6 Yes 0 No

I have file with data as follows data 1 2 3 4 5 I need to read 1 and 5 ,then 2 and 4 then li..

Answer / raghav

You can try using pre runtime array and perform lookup operation for the desired result

Is This Answer Correct ?    3 Yes 0 No

I have file with data as follows data 1 2 3 4 5 I need to read 1 and 5 ,then 2 and 4 then li..

Answer / piyush aingad

We can also use setll reade and setgt readp operation in a loop.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More RPG400 Interview Questions

How to define data area in RPG program? In which scenario multi occurrence DS is use in AS400?

0 Answers  


how to convert date format from one format to another i think in CL/400 its CVTDAT,Please tell in RPG/400 sir not in RPGILE

3 Answers   iGate,


I have some doubts on subfile----------- -----I wrote a prog on subfile to display the records. Every thing is clear but i defined a field called "opt" as input field in subfile record format from that input field i wish to enter into new screen called "EDIT" which i created it as a separate RCD in display file. i gave opt as 2 for edit just like in WRKMBRPDM screen please telll me the code and how can i code for it in RPG.

3 Answers  


what is program status data structure?

1 Answers   IBM,


Suppose my file has 10 fields and I want to make the 2nd field zeros in all records. And assume I have millions of records and I dont want to read each record and update the desired field with 0. Any other way to do this in one step operation?

1 Answers  






How can i keyed a flat file in RPGLE

5 Answers   IBM, Wipro,


what is the difference between do while and do until?

0 Answers   IBM,


When PGMA calls PGMB for the first time PGMB executes the *INZSR. PGMB uses the RETRN operation to return to PGMA. When PGMA call PGMB the second time is the *INZSR executed?

5 Answers   Mphasis,


How to read alternative records in a pf by using rpg?

8 Answers   IBM,


What will be your approach in going either for OPNQRYF or Logical files. Which one to go for?

2 Answers  


1.Are there any errors in the following statement?If so then list them.DTAARA is a data area having a field EMP # and EMPNO is a field in the file EMPPF.Which has one record. READ EMPPF IF %FOUND(EMPPF) IN DTAARA EVAL EMP#=EMPNO OUT DTAARA ENDIF

5 Answers  


What is ment by record level identifier?

0 Answers  


Categories