Reading the Physical file Using RRN

320 pts.
Tags:
AS/400
Physical File
Hi All, I have a physical file file1, have the field Status, which holds the value of:
Status

Y      rrn1

Y      rrn2

N      rrn3

Y      rrn4

Y      rrn5
My question is: How can I read the Physical file to fetch the record as rrn3,rrn1,rrn2,rrn4,rrn5? Which means I want to display the value as:
N

Y

Y

Y

Y
Please help me to achieve in best way?
1

Answer Wiki

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

If you cannot use a logical or OPNQRYF or embedded SQL then your best bet would be to create two tables/arrays, one for YES the other for NO. Then read a record, add to appropriate table/array. On the last record go back and read all record from one table/array then the other. You could even sort them. 

If that is the result, and you can use other methods then the OPNQRYF or embedded SQL would be your best solution. 

Discuss This Question: 14  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.
  • srivijay1
    Hi, I done by using OPNQRY by creating temporary logical file. Please share is there any method to achieve better way.
    320 pointsBadges:
    report
  • pdraebel
    As a starting point in configuring or setting up new printers I usually start at this IBM page : http://www-01.ibm.com/support/docview.wss?uid=nas8N1019605
    7,545 pointsBadges:
    report
  • pdraebel
    Sorry, answer was for another post..
    7,545 pointsBadges:
    report
  • Florenjm

    We are assuming you know the RRNs you what to read and in what order.
    If they are in another table (in the order you want to read them), then
     
      Select  Status_from_FileB, RRN-from-FileA, etc.
        From FileA, FileB
       Where RRN-from-Filea = RRN(FileB) etc.

    240 pointsBadges:
    report
  • srivijay1
    Thanks for the answer. but, I want to use only the Read Operation, which means i want to use Setll or read or reade anything..With this File opcodes i want to achieve the answer...

    This was the Recruitment given to me...
    320 pointsBadges:
    report
  • pdraebel
    In case you cannot or are restricted to using only SETLL and READ or READE I think the simplest way is to READ 2 times, first selecting only the "N" 's seconfd time selecting only the "Y" 's.
    7,545 pointsBadges:
    report
  • srivijay1
    Thanks pdraebel..its simple but that even not came to my mind logic...It working..

    But this logic will read the same file twice one for the value 'N' and another for 'Y'. is there any method to make more effective..

    Sorry for asking many logic. but it will really help me a lot..

    Thanks
    320 pointsBadges:
    report
  • bvining
    If you are restricted to only using reads to the physical file (no logical file, no OPNQRYF, etc) then I only see three options:

    1. As mentioned by others, read the file once loading two arrays representing the N and Y entries and then process/display all the N array entries followed by the Y array entries

    2. As mentioned by others, read the file twice processing/displaying the Ns on the first pass, the Ys on the second pass

    3. Have Status be defined as the key of the physical file. Indexes concatenate the RRN of the record to the stored index entry. So, as N collates prior to Y by default, simple reads to the indexed physical file will get you RRN3, RRN1, RRN2, RRN4, and finally RRN5. I suspect however that your physical file isn't keyed on Status.

    Bruce Vining
    7,070 pointsBadges:
    report
  • srivijay1
    Thanks bvining...

     i did not understand the 3 point which u said..If you not Mistaken can you please give in some details in that.

    Pls..
    320 pointsBadges:
    report
  • bvining
    First off, my point 3 was made for the most part in jest as I sincerely doubt your file is defined in the following way. But, if your file is defined with Status as the key like:

                    R RECORD                     
                      STATUS         1A          
                      OTHER          4A          
                    K STATUS                     

    With as many "OTHER" fields as you like but only Status as a key field, then 

    h dftactgrp(*no)                                 
                                                     
    fstatusrrn if   e           k disk               
                                                     
     /free                                           
                                                     
      read record;                                   
      dow (not %eof(statusrrn));                     
          read record;                               
      enddo;                                         
                                                     
      *inlr = *on;                                   
      return;                                        
                                                     
     /end-free                     

    would return first all the 'N' rows (by RRN when more than one 'N' row exists) and then all the 'Y' rows (by RRN when more than one 'Y' row exists).

    But assuming your physical file isn't defined as above (one key and that key is Status) then you're really looking at some variant of solutions 1 and 2 (again because you indicate that you can't use other tools like a logical file, SQL, OPNQRYF, etc).

    Bruce Vining
    7,070 pointsBadges:
    report
  • srivijay1
    Yes..Your answer is very understandable..

    But in my case, i should not have any key in my file.
    320 pointsBadges:
    report
  • srivijay1
    The First two point which u said i tried and got an exact output of which i needed..
    320 pointsBadges:
    report
  • ToddN2000
    This sound like it was another interview recruiter question.
    135,525 pointsBadges:
    report
  • srivijay1
    Yes ToddN its was an interview question.
    320 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: