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 sort an array in descending in RPG

3 Answers   Google, TCS,


can anybody help me to solve this problem. the program that i m checking display error message saying "Record format for file AJDSPFFD does not match model file and decimal error. how to solve this problem. The AJDSPFFD is snapshot the AJTLOG that is the audit trail list.

0 Answers  


How do you do indexing in a physical file?

2 Answers  


how can I tell when to replace the array?

0 Answers   IBM,


1.How to load Records of a Physical file(PF) in the reverse order, in CL program?

2 Answers   Cap Gemini,






what are the array operations?

1 Answers   IBM,


What is use of IMPORT and EXPORT in RPGLE ? What is activation Group ? What is Service Program ???? How to call another program in RPGLE ?

1 Answers  


Suppose we have 10 records with same name and we are reading using READE,after 4 record i have to use CHAIN what is the output

3 Answers  


A pgm subroutine calling child subroutine, that child subroutine again calling parent subroutine, u have 1000 lines of code, with out debugging , how can u find that error??? Is there any command to find errors in pgm???

3 Answers   HSBC,


How to create a login screen using a command instead of display file.... intention is to get a password field on a command..... how do you achieve this...

0 Answers  


1. I have2 records in a PF. READ PF DO DSPLY EMPNO RETRN DSPLY EMPNO ENDDO What was the output 2. SETON LR vs RETURN 3. Primary File 4. How to delete a deleted spaces 5. How to read a PF in reverse order in CL 6. I have a object in Lib A, B and C. But it shows in D Lib..Why? 7.

4 Answers   HCL,


explain sflclr, sflend, sfldlt, and sflcsrrrn?

0 Answers   IBM,


Categories