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

1.I have a Batch job, Running for 4 hours, i want to reduce the executing time to 2 hours what should you do?

5 Answers   Cap Gemini,


To check the locks , we use cmd WRKOBJLCK , but how we confirm whether it's objeck lock / member lock. I confused with the Lock type and Status values...Can any body please tell me ...

5 Answers  


RPG/400 faqs?

1 Answers   HSBC,


can any one help in hawkeye and turnover or any change management system plzzzzz or send the documents to my mail id :gvsp.as4@gmail.com

0 Answers  


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

3 Answers   TCS,






Can we have a Physical file without any member ? Please let me know

12 Answers  


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  


I have one cl program which calls two rpg programs named a & b. I am loading a run time array in Pgm A and the control comes back to cl pgm. i call pgmb and I want to read the runtime array in pgmb which was loaded in pgma. How it can be acheived. I should not use any intermediate file or dataarea to store the loaded values.

2 Answers  


Need a sql query: retrieve all duplicate records in table?

1 Answers  


Hi friends, Can you give the solution for the below mention simple code.and explain.what is output D CHR1 S 4A INZ('PEN') D CHR2 S 10A INZ('MYGET') D CHR3 S 8A INZ('GOOD') D CHR4 S 22A INZ C MOVEL CHR1 CHR4 C MOVE CHR2 CHR4 C EVAL CHR4=CHR3 C MOVE CHR1 CHR4

4 Answers  


I have learnt through Net that Debugging a Batch job involves 1. Submit the job with the HOLD (*YES) parameter: SBMJOB HOLD(*YES) or Hold the job queue that before submitting the job by using the HLDJOBQ command. 2. Determine the job name, user, and number of the submitted job by using the WRKSBMJOB command. 3. Type the Start Service Job command on your screen: STRSRVJOB JOB(job name/user/number) 4. Type the Start Debug command on your screen: STRDBG 5. Release the job in the jobq. Type WRKSBMJOB and then put a 6 beside the job to be released and press enter, or, if the job queue was put on hold, release the job queue with the RLSJOBQ command. 6. A display appears when the job is ready to start, saying that you can now begin debugging the job. Press F10 to show the Command Entry display. 7. Now you can start debugging by entering an Add Break Point command: ADDBKP 8.ENDDBG 9.ENDSRVJOB I tried this for RPG/400 Program and up to six steps of the above it's ok,but for me no source is displayed and i typed DSPMODSRC in Command line but still i can't see the sourceif i press F.10 and enter command ADDBKP i don't know how to add break points through it,usually i add break points using F.6 for Interactive job debugs,but since this is batch i don't know sir,Please help me out. I was asked this question in a interview,i know only RPG/400 and i’m asking for debugging of RPG/400 program only sir. or is it only possible to debug BATCH RPG ILE JOB and it is not possible to debug BATCH RPG/400 JOB kindly help me out sir

4 Answers   HSBC,


The PGMA calls PGMB.PGMB generates a report.The report should contain the called program name(PGMA).How do i get the called program name in PGMB to print it on the spool file?(calling program name should NOT be hard coded or passed as parameter to called program?

6 Answers  


Categories