RPG/400 number of Records present in a physical file using file information data structure

470 pts.
Tags:
Coding
RPG/400
V5R3
FPF001   IP  E                    DISK                       
F                                              KINFDS INFDS1 
IINFDS1      DS                                              
I                                     *RECORD  RECORD        
Is this coding correct sir,i have given I P E that is I-input,P-primary file,E-externally described.
Primary to use RPG logic cycle,is this the correct method because we have to find number of records present using file information data structure in RPG/400 without doing any input/output operations on the file and also without using DSPFD,SQL.
If the above coding is correct means,when i compile the program it gets compiled,but if i call the program it does not return anything,i need number of records,please complete the coding sir.


Software/Hardware used:
V5R3

Answer Wiki

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

Although the coding appears to be “correct”, it doesn’t seem to be right. The *RECORD value doesn’t have anything to do with the number of records in a file — it would hold the <i>name</i> of the record format.

If you want the number of records that existed at the time the file was opened, I believe it should look this way:<pre>
I B 156 1590RCDCNT</pre>
Use that line of code instead of your *RECORD line. Or leave the *RECORD line in place if you want it for some reason. The number of records should then be in variable RCDCNT after the file is opened for input.

Tom

Discuss This Question: 16  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
  • Kaly
    pf001 is my physical file name infds1 is my file information data structure name i have declared my data file as a primary file so as to use rpg logic cycle
    470 pointsBadges:
    report
  • philpl1jb
    Tom's got it. Same positions in RPGLE and RPG/IV. That's binary 4 or if you need to move it use a 9 0 field. The *RECORD keyword is especially useful when working with multi-format logical files. Sticking with RPG/400. I would do all new development in RPG/IV so many great tools. Phil
    51,355 pointsBadges:
    report
  • Kaly
    thanks tom sir i have now used the below given coding FPF001 IP E DISK F KINFDS INFDS1 IINFDS1 DS I B 156 1590RCDCNT C RCDCNT DSPLY
    470 pointsBadges:
    report
  • Kaly
    number of records in my physical file is 7 and when i display rcdcnt it displays 7 but it displays it 7 times i don't no why. what does this mean sir I B 156 1590RCDCNT I specs B from 156 to 159 decimal position 0 RCDCNT what does it imply why we are using 156 and 159
    470 pointsBadges:
    report
  • philpl1jb
    IINFDS1 DS I B 156 1590RCDCNT within the file data structure are a lot of data fields. In the positions 156 to 159 is the data you want. It is a binary number, the B, and has zero decimal positions. Other file information daa fields have the name of the file, library, status, current record number. Some parts of the structure are specific to the file type -- pf, printer, display. Check out this site http://publib.boulder.ibm.com/iseries/v5r1/ic2924/books/c092508378.htm#HDROPFEED Since you put the command C RCDCNT DSPLY in the "mainline" of the program it is processed during each loop of the RPG cycle. With the file set as type IP, the cycle reads a record, performs all the code in the main and then loops back, reading the next record. With 7 records in the file, the mainline will be executed 7 times and the command RCDCNT DSPLY is executed 7 times. Good thing this file didn't have 50,000 records. Phil
    51,355 pointsBadges:
    report
  • Kaly
    thanks philp sir that link will be useful but its in RPGLE,is there any equivalent in RPG400 most of the links are available only for ILE only. i understand how the number of records are displayed 7 times,then where can i give that to see the number of records displayed only once sir.
    470 pointsBadges:
    report
  • Kaly
    FPF001 IP E DISK F KINFDS INFDS1 I INFDS1 DS I B 156 1590RCDCNT I 83 92 FILNAM I 93 102 LIBRAR I 129 138 MEMBER C RCDCNT DSPLY C FILNAM DSPLY C LIBRAR DSPLY C MEMBER DSPLY C SETON LR
    470 pointsBadges:
    report
  • Kaly
    if i use this code results are coming correctly sir,but can i declare a file as I P E (Primary for RPG logic cycle) and issue seton LR is it allowed.if i give this,result is displayed only once.
    470 pointsBadges:
    report
  • Kaly
    also on I specifications if i give IPDS in starting over the numbers in left side end and prompt i get Data Struct S/U External Name Number Option DS File Name Occurs Length DS but i don't know what to give in Left side end (like IPDS) to get Decimal Field Control Matching P/B/L/R From To Positions Name Level Fields 83 92 FILNAM Field Record Positive Negative Zero / Relation Field Field Blank i simply get this by typing something in positions 44 to 58 in I specs and take F4(prompt) and then only i get it. is there any other actual word to get this like IPDS
    470 pointsBadges:
    report
  • philpl1jb
    Wow, so many questions Don't know if I can answer them all. I haven't written in RPG/400 in 10 years and never used IP files..I find that the complexity of the problem requires control that I don't feel I would have with IP. Anyway. Put things that you want done once before the cycle starts up in the subroutine *INZSR. Don't code an *INLR if you want the program to automatically access all the records in the file, after it's done it will turn on the *INLR for you. Input prompts for I specs, maybe IPJ and IPJX, when you move up to RPG/IV or LE you will rarely use I specs. The D spec is so much more. Finally, Google RPG/400 Programmer's Manual. You will want to have that available at all times. Phil
    51,355 pointsBadges:
    report
  • philpl1jb
    Actually, I think it's the RPG/400 Reference Manual. Phil
    51,355 pointsBadges:
    report
  • TomLiotta
    ...is there any equivalent in RPG400... The ILE reference manuals are available as web pages. The old compiler manuals are only available as .PDF downloads. You can find all RPG manuals from the Programming: RPG page for your version of the operating system. The RPG/400 manuals aren't available as web pages because you shouldn't be using it. Convert the programs to RPG IV. Everyone is forgetting how RPG III works. IBM has not been enhancing it for years. It cannot process many features that have been added to the system in the past ten years. Tom
    125,585 pointsBadges:
    report
  • pdraebel
    If you only need to know the number of records use a file Input Full Procedural and UC (user controlled) FINPUT IF F 128 DISK UC F KINFDS INFINP IINPUT NS 01 * * File information data structure * IINFINP DS I 1 256 IO0001 I 257 400 IO0002 I 83 92 FILE I 93 102 LIBR I 129 138 MEMBER I *RECORD RECFMT I B 156 1590RECORD Include a "Dummy" Open and Read (to get Compiled) *INLR IFNE *INLR OPEN INPUT READ INPUT 99 END With the INFDS coded you can display the number of records easily. Do an OVERRIDE of INPUT to the file name whose recordnumber needs to be displayed.
    3,230 pointsBadges:
    report
  • Kaly
    everyone thanks for your answers. Pdraebel sir i should not use READ because its an input operation no i need to display the number of records without using any input operations
    470 pointsBadges:
    report
  • Kaly
    philp sir i excluded *inlr and gave the things i want to display within *inzsr it gives correct output i have given the coding below please kindly tell if it is correct or we can code like this sir.i have declared as primary file only but not given *inlr FPF001 IP E DISK F KINFDS INFDS1 IINFDS1 DS I B 156 1590RCDCNT I 83 92 FILNAM I 93 102 LIBRAR I 129 138 MEMBER C *INZSR BEGSR C RCDCNT DSPLY C FILNAM DSPLY C LIBRAR DSPLY C MEMBER DSPLY C ENDSR
    470 pointsBadges:
    report
  • philpl1jb
    Not done yet. If your only purpose was to determine how many records were in the file, then the CL command RTVMBRD would be better. If you aren't using the file then the IP requires the program to read all the records, as you discovered. You could reduce the work with an *INLR in the mainline or by opening the file as IF which in RPG/400 requires a read, although it doesn't have to be in the code that's processed.
    51,355 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