How I can reread the physical file in CL program once the
end of file reached in same CL program.

Answers were Sorted based on User's Feedback



How I can reread the physical file in CL program once the end of file reached in same CL program...

Answer / jim

Specify two DCLF for the same file with 2 different
openID's sayID1 and ID2
Tjen do RCVF on the file with open ID ID1 do the
processing, upon EOF then issue a 2nd RCVF for open ID2

the 1st record will be available.
Here's an example

DCLF FILE(FILE1) OPNID(ID1)
DCLF FILE(FILE2) OPNID(ID2)

RCVF: RCVF RCDFMT(FILE1) OPNID(ID1)
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(XYZ))



GOTO RCVF

XYZ:
RCVF RCDFMT(FILE2) OPNID(ID2)
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END))

GOTO XYZ

END:
ENDPGM

Is This Answer Correct ?    25 Yes 8 No

How I can reread the physical file in CL program once the end of file reached in same CL program...

Answer / abhishek bajpai

hi Shobhit,

POSDBF and OVRDBF can only position the file at the desired
location if the file hasn't reached EOF yet. If the file is
already at EOF, then thesekeywords won't help you in
positioning the cursor.
However, there is one keyword recently added to the CL
commands and that is 'CLOSE'. After the file is at EOF
mark, you can close it by using this keyword and the next
RCVF keyword will retrieve the first record again, or u can
position the cursor anywhere using POSDBF or OVRDBF.

Thanks

Is This Answer Correct ?    15 Yes 5 No

How I can reread the physical file in CL program once the end of file reached in same CL program...

Answer / sri

Hi Jim can we declare two files in a CL program?

Is This Answer Correct ?    12 Yes 3 No

How I can reread the physical file in CL program once the end of file reached in same CL program...

Answer / shobhit

Have you tried this option..
This option will not work as once the end of file reached
in CL program can not be reseted at beginning.

The Only way is come out of the cl program and call it
again.

Is This Answer Correct ?    14 Yes 6 No

How I can reread the physical file in CL program once the end of file reached in same CL program...

Answer / sekhar

Answer 11 is correct when the version of your iSeries is V6 and above. For V5R* , I guess CLOSE key word is not there.
For V5R4 systems... you can approach below solution.

Declare the same file two times with different OPENIDs

Before first RCVF , do OPNDBF and read the file. After reaching EOF do CLOF

Then do OPNDBF for second OPNID and do the same again.

Is This Answer Correct ?    2 Yes 1 No

How I can reread the physical file in CL program once the end of file reached in same CL program...

Answer / parkpark

NOTHING WORKS~!

Is This Answer Correct ?    2 Yes 2 No

How I can reread the physical file in CL program once the end of file reached in same CL program...

Answer / naga srinivas

WE can't read the file again once you reached end of file.
If you want to use the POSDBF command before reaching the
end of file you make to position to starting.Use RTVMBRD, we
get the number of records in the file.Count the number of
records retrieved.When the count becomes equal to number of
records in PF..use POSDBF and make the cursor position to
intial record

Is This Answer Correct ?    0 Yes 0 No

How I can reread the physical file in CL program once the end of file reached in same CL program...

Answer / sravs

simply call that progrm by using IF condition based on
increment value of one varibale it will again read from
first

Is This Answer Correct ?    1 Yes 1 No

How I can reread the physical file in CL program once the end of file reached in same CL program...

Answer / arvind

Read file thru a pgm and then call d same program and u can read d file.
i try it refine me if m wrong

Is This Answer Correct ?    0 Yes 0 No

How I can reread the physical file in CL program once the end of file reached in same CL program...

Answer / naga srinivas.kattula

Ovrdbf file name with share

rtvmbrd to get the number of recoeds of file

Pos: Posdbf with positon *first

RCVf file name

count the loops

If no of records of file is equal to no of loops

goto POS

enddo

count+

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More RPG400 Interview Questions

what is the equivalent keyword for CHAIN opcode ??

7 Answers   TCS,


what are the parameters of jobd?give in detail.&what are the parameters of subsystem...????

1 Answers   CTS,


what do you mean by an input subfile, what are the keywords required?

0 Answers   IBM,


Setps to create .csv file on IFS folder in AS/400( V4R3)....?

3 Answers   TCS,


Given the following code, what is the value of RESULT? DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++ D RESULT S 5 0 C EVAL RESULT = (2 + 3 * 2) ** 2 / 2

2 Answers  






I want to add 10 days in current date. how it is possible in CL program...?

11 Answers   CSC,


Is it possible to call a subfile using CL. IF yes.. kindly help me out with explanation...?

3 Answers  


steps for debugging two rpg programs????

4 Answers  


How to sort an array in descending in RPG

3 Answers   Google, TCS,


I know whole thing ab't Arrays related to declaration..can anyone tell me what exactly use of array or anyone faced a situation where he found use of array must....

1 Answers  


i have a file with the values 10, 20, 30, 40, if am setll with the value 25 then readp, so what it will return?

6 Answers   Mind Tree,


How to code Page up and Page down in RPG for Single page subfile without using ROLLUP/ROLLDOWN in DSPF ?

3 Answers   HCL,


Categories