1,900 pts.
 Primary file
While declaring a file, In file designation If I give 'P' for primary file, I read it will use RPG logic cycle to read file instead of file opcodes read/chain etc. But can anyone let me know how these primary file is read? I couldnt get a clear explanation in google search. If anybody elaborate the primary file read process it will be helpful.

Software/Hardware used:
As400
ASKED: May 2, 2012  8:36 AM
UPDATED: May 3, 2012  5:31 PM

Answer Wiki:
Essentially, the RPG Cycle does a do while not end of file loop and reads in the file one record at a time. You only code the logic within the loop (that is the processing that is to be done for each record) It is possible to specify some initialization, finalization (LR) and "level break" (total) logic. But at its simplest, the primary file program is simply program that processes every record in a driving file. <img src="http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/topic/com.ibm.etools.iseries.langref.doc/rpglcyc.gif" alt="RPG Cycle" /> image from the <a href="http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp">IBM infocenter </a>
Last Wiki Answer Submitted:  May 2, 2012  1:54 pm  by  BigKat   7,185 pts.
All Answer Wiki Contributors:  BigKat   7,185 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

But can anyone let me know how these primary file is read?

Can you explain what you mean by the word “how”?

One answer is that the compiler inserts instructions to call the DB2 routines that read records into the compiled program. The DB2 routines perform the reads just like they would if you coded READ instructions into your program source.

Another answer might show an example from SQL:

INSERT INTO TSTINSERT                                     
with t1 (num, nam) as (SELECT CUSNUM, LSTNAM from QIWS/QCUSTCDT)
 SELECT num, nam from t1

That will insert rows into a table named TSTINSERT by retrieving rows from IBM’s example file in QIWS named QCUSTCDT.

But “how” does it read records in order to get the values?

In some sense, the answer is simply “It just does it. It doesn’t matter how.”

Tom

 107,995 pts.

 

This is a supported but mature subset of RPG.
It allows the creation of reports with no statements (C specs), although it can be used in conjunction with C specs.
It’s a powerful tool, almost a seperate language.

Some programmers swear by and others swear at it.
Phil

 44,150 pts.

 

Sorry – I am a COBOL programmer. Many, many years ago – back on old RPG, if you did not enter a “K” for keyed, the file is read by arrival sequence. Not sure what the latest version of RPG handle the file, but I would think that is would be read by arrival sequence or by key. (Why not dup the file (in test lib) and copy a few dozen records and run the program and see how the file is read.)

 645 pts.

 

Post your “F” and “I” and first “C” spec, then we can explain method

Work with the “primary” files is very efficient, but it is of difficulty understanding, it depends how the primary key is defined, what breakups of level is desired to manage……

You must search RPGII cicle.

Bye

 290 pts.