How to check if the record exists in a file without reading it using file information data structure and SETLL

2920 pts.
Tags:
#AS400 #RPGLE #as400
Hi, 

 
Below piece of code is trying to use file information data structure without reading the file but it's not showing correctly records do exists in the declared file but program shows blanks only please advise. 
     *************** Beginning of data ************************************* 
01.00 FPFBOOKS   IF   E             DISK    INFDS(PFDS)                       
02.00 DPFDS             DS                                                    
03.00 DFILE               *FILE                                               
04.00 DOPEN_IND                 9      9N                                     
05.00 DEOF_IND                 10     10N                                     
06.00 DRECORD             *RECORD                                             
07.00 C     *RECORD       DSPLY                                               
08.00 C                   SETON                                            LR 


Thanks.






















Software/Hardware used:
AS400
1

Answer Wiki

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

OK I played with your code a bit.

Changed the file to an Input Primary, and removed the File definition.
Run the job and it returns the record name.
FPFBOOKS   IP   E             DISK    INFDS(PFDS)                      
DPFDS             DS                                                   
DOPEN_IND                 9      9N                                    
DEOF_IND                 10     10N                                    
DRECORD             *RECORD                                            
C     RECORD        DSPLY                                              
C                   SETON                                            LR
This won’t tell you if there is any data, just that there is a valid record format.

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.
  • TheRealRaven
    I can't tell what you expect the program to do. From what I see, all it will do is display the blank RECORD area and then end. Since there's no file I/O, you shouldn't find anything in the feedback area.

    This line should throw an error at compile-time:
    07.00 C     *RECORD       DSPLY
    *RECORD should be invalid, resulting in being effectively with the equivalent to *BLANK if the compile is forced.
    36,145 pointsBadges:
    report
  • 6r
    even instead of * record i put record dsply then also it displays blanks despite file is having records the key idea is that how to know if the file is empty or having some records with the help of either file information data structure or using * loval but 
    C       *loval         setll     rec                                10     
    C     *IN10         IFEQ      *ON                                       
    C     'RECORD'      DSPLY                                               

    This logic is also not working and each time it displays records not found. i have tried putting 10 indicator at hi,eq,lo all three positions but each time it failed to tell record found whereas records do exists in the declared file here.

    2,920 pointsBadges:
    report
  • 6r
    any updates please?
    2,920 pointsBadges:
    report
  • ToddN2000
    Shouldn't that be NFDS(PSDS) ?  Can't find much info on you problem. Is there a specific reason to need to check for data in the file this way?

    134,970 pointsBadges:
    report
  • ToddN2000
    You could do it this way 
    
    FO5P       IF   E             DISK    RECNO(RRN2)
    DRRN2             S              9  0 
                                    
    Then you can chain by rrn 1 to see if any data 
    
    C     1             CHAIN     O5P
    
    or check with a simple read
    
    C                   READ      O5P            
    C                   DOW       NOT %EOF       
    C                   if        rrn2 = 0 
    134,970 pointsBadges:
    report
  • TheRealRaven
    Once again, in the original code, there is no file I/O, so the feedback RECORD area will be blank. If there's no I/O, there won't be any feedback data.

    You might try changing the file to have the USROPN attribute and add an OPEN statement to the code. I've never tried it, so I don't know how much would be available in the full feedback area. At the least, the 'Open' indicator should show up. There won't be any indication of whether or not any records exist though.
    36,145 pointsBadges:
    report
  • 6r
    specific need is to understand the use of file information data structure which has the property to tell whether records exists ina file or not and i believe it's for * records with read everyone can tell that records exits or not but main thing to check the use of file information data structure and the use of * loval which by default positions the pointer to the lowest matching key field and evenif the record not found with the matching key then it will position the pointer to the least available field and in this way when we will use any variant of read opcode then we will be able to know whether records exists in a file or not.
    2,920 pointsBadges:
    report
  • TheRealRaven
    See the example code at INFDS Open Feedback Example for how to specify the NUM_RCDS value (number of records in the member at open time).

    But a fundamental requirement is that you can only test the value after the file is opened. If you have no I/O, you should issue an explicit OPEN statement. Otherwise the file may be ignored by RPG.
    36,145 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.

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

Following

Share this item with your network: