SETGT READPE RPG FREE

230 pts.
Tags:
AS 400
RPGLE
I am using a SETGT followed by READPE and not getting the right results.

When this piece of code runs in figure 1  I end up retrieving LINE 7 instead of

 LINE 8.

   
Begsr Sub1;                           
 SetGT ('-':wareh:appt#) I3APPTP1;    
 ReadPE ('-':wareh:appt#) I3APPTP1;   
  if %eof (I3APPTP1);                 
  SetGT (' ':wareh:appt#) I3APPTP1;   
  ReadPE (' ':wareh:appt#) I3APPTP1;  
  endif;                              
  if %eof(I3APPTP1);                  
    SetGT ('Y':wareh:appt#) I3APPTP1; 
    ReadPE ('Y':wareh:appt#) I3APPTP1;
 endif;                               
 
       Uploaded  Whse   Appt Schedule
                             Status
000001    Y       BI    2159
000002    Y       BI    2159
000003    Y       BI    2159    P
000004    Y       BI    2159    P
000005    Y       BI    2159    A
000006    Y       BI    2159    P
000007    Y       BI    2159    P
000008    Y       BI    2159    F


Software/Hardware used:
rpgle as/400
1

Answer Wiki

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

Actually the If not %equal is not there. The third piece of code

is where the program falls :

 If not %eof(I3APPTP1);                   
   SetGT (‘Y’:wareh:appt#) I3APPTP1;      
   ReadPE (‘Y’:wareh:appt#) I3APPTP1;     
endif;

Discuss This Question: 5  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.
  • azohawk

    I would examine what UARTJ suggested first.

    There have been times when I have had issues with using keys for SETLL/SETGT and have had to do one of the following (as appropriate--since doing /free exclusively, I tend more towards the first two options).

    setll *start myfile;

    setll *end myfile;

    setgt *hival myfile;

    setll *loval myfile;   

    4,015 pointsBadges:
    report
  • Splat
    Those Ps, As, & Fs in the rightmost column - are those by chance included in the key fields for the file?
    12,855 pointsBadges:
    report
  • TheRealRaven
    What is the key field(s)?
    33,730 pointsBadges:
    report
  • GregManzo
    I think Splat has guessed the problem correctly. If the right-most column is part of the key then the records are ordered like this:
    000001    Y       BI    2159
    000002    Y       BI    2159
    000005    Y       BI    2159    A
    000008    Y       BI    2159    F
    000003    Y       BI    2159    P
    000004    Y       BI    2159    P
    000006    Y       BI    2159    P
    000007    Y       BI    2159    P

    in which case the 'last' record is 7.
    2,950 pointsBadges:
    report
  • ToddN2000
    Not knowing what the file key is it tough to determine. Is the status par of the file key/index? If so you need to add that to your SETGT and READPE. Also by looking at your example, you do have multiple records with the same key.
    129,900 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: