Primary file

2505 pts.
Tags:
AS/400
RPG Logic Cycle
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Check out the image at IBM infocenter

Discuss This Question: 8  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • philpl1jb
    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
    51,235 pointsBadges:
    report
  • MDratwa
    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.)
    785 pointsBadges:
    report
  • nuccio
    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 pointsBadges:
    report
  • ToddN2000
    Just curious as to how many people still use the "P" file spec for input primary?? I have not seen or used that in about 15 years. Mainly because of controlling level breaks. Those L1, L2, L3.... break could be a nightmare to work with at times.
    15,605 pointsBadges:
    report
  • Splat
    Haven't used the cycle for reports in ages, but for going through an entire file it's a good method.
    7,625 pointsBadges:
    report
  • TomLiotta
    I might still do it once a year; probably less. It's rare that I'm doing anything simple enough that using a 'P'rimary file makes sense. For such basic uses, SQL almost always is simpler to use. And for complex processes, I no longer use anything but 'F'ull-function specs if I use native I/O. . Tom
    125,585 pointsBadges:
    report
  • gfprogrammer
    I am in a shop that still has some old RPGII code (S36 mode), using (P)primary, (S)secondary, (L)level breaks, and the dreaded (M)matching records. I am getting rid of them as fast as I can.
    250 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following