Data fetching from file

1420 pts.
Tags:
AS/400
RPG
Hi all, I have a scenario where I need to read from a File F1 based on Product name only (F1 Key is Product name+ XXX+YYY+ZZZZ) write to file F2. Both F1 and F2 having same fields except F1 have 1 Additional field(ZZZZ) which we are not populating to F2(F2 Key is Product name+ XXX+YYY). So for each Product name I need to compare with all the records in file F1. If same Product name is found, then I need to do calculations for the other fields like Balance, No.of accounts, ....etc. Then I need to write a single entry for that Product name in the File F2. For this I did written some code, but it is populating data for only first product, even if I used a loop. I want to know how to change it so that it fetch all the data. code: PNAME SETLL RECFMTF1 READ RECFMTF1 90 /* Reads First record, PNAME-roductname *IN90 DOWEQ *OFF EXSR S1 /* to move all fields to temp fields*/ READ RECFMTF1 90 /* Reads Second record Product name*/ *IN90 IFEQ *OFF TPNAME IFEQ PNAME /*TPNAME is containg value of initial PNAME, /* Compares with other records on Sequencial-read EXSR S2 /* Add the values for other fields on PNAME match ELSE EXSR S3 /* to write to the file F2*/ ENDIF ENDIF ENDDO As of now it is reading first record at the first READ operation, and comparing with other records (from second to till end of file) on second READ operation. But it is not reading second record again at the First READ operation. Please help me find the way. Thanks a lot.

Software/Hardware used:
AS400, RPG,CLLE,

Answer Wiki

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

Discuss This Question: 6  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 it is not reading second record again at the First READ operation.

    I can not make sense out of that. Why would you expect the "First READ" to read the "second record" again?

    Why don't you use a READE loop instead of READ? Write to F2 after each READE loop completes. I'd probably even use CHAIN instead of SETLL to start my loop.

    Tom

    125,585 pointsBadges:
    report
  • philpl1jb
    You owe us responses on a number of recent requests.
    51,355 pointsBadges:
    report
  • Sai4AS400
    Tom, you mean to say.."use READE instead of READ" ?
    1,420 pointsBadges:
    report
  • TomLiotta
    No, I meant a READE loop. But that could need some explanation. A READE loop would be one that was coded to process a READE command. Depending on exactly what the program is really supposed to do, it would likely need to be a little different from a simple READ loop. -- Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Where do you get the value for PNAME?
    51,355 pointsBadges:
    report
  • philpl1jb

    .. if this is all of your code, then when you reach this statement

    PNAME SETLL RECFMTF1

     PNAME is blank so you move before the first row of the file.

    ..

    Note: since this file is keyed on PNAME you do not need to scan the entire file for each PNAME you will get all the first Pname values then all the second Pname value .. etc. in keyed order,

    What you need is control break processing logic.  As Tom mentioned there are some interesting options with Reade, however, you need to understand control break processing.

    Here is a sample of the logic ..  

    https://scs.senecac.on.ca/~timothy.mckenna/RPG544/controlbreak.htm

     

     

    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