635 pts.
I have tried using SETLL and SETGT command to read a record which is not present in file FILEA eg: A B D E Suppose in my program I have given the value C to read the file FILEA using command: C SETGT FILEA C READE FILEA and C SETLL FILEA C READE FILEA But the values retrieved are NULL. Can any1 explain me why this is happening. i m using RPGLE.

Answer Wiki

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

The values are null as there is nothing to read.

If you did a SETLL on C and then a READ, you would read the D record.

The READE will set on the %EOF flag

I hope this helps

Discuss This Question: 7  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.
  • Vids
    If you are using READE with SETLL / SETGT that means, first you are setting pointer to a particular record and then you are trying to read equal record with the same key value which is not there in example given by you in queston. Thats the reason its giving you null values as it reached end of file. So as suggested above you should use READ to see the effect of SETLL and SETGT.
    295 pointsBadges:
  • joederoche
    I would suggest that you either use the %Found() BIF or an indicator on the SETLL or the SETGT. If you get a %Found() you can read the file. Remember that normally SETGT is used inconjuction with a READP or READPE. If you are doing a READE, you will need to make sure that you are using the key to the file that you expect to see data for.
    55 pointsBadges:
  • TomLiotta
    I would suggest that you either use the %Found() BIF or an indicator on the SETLL or the SETGT. With SETLL, the circumstances in the question would be far better served with %EQUAL() than %FOUND(). The %FOUND() indication would be on whether record "C". existed or not. But %EQUAL() would come on only if "C" existed. %FOUND() comes on because SETLL checks for a "Lower Limit" which is 'found' just in front of record "D". But %EQUAL() requires an exact match with "C". Tom
    125,585 pointsBadges:
  • Splat
    Read equal is just that. If you're reading with a key that has no match, you won't retrieve anything. If you're trying to position the file to read from a particular key, the following will work:
    SetLl (C) FileA;
    Dou %eof(FileA);
     Read(E) FileA;
     If %eof(FileA) or
     ~ process ~
    12,915 pointsBadges:
  • nasrunisar

    I have a file where in filed1, field2 and field3 are key fields. Now these key fields are not unique, I need to update field 4, 5 and 6 based on the selection by user via subfile. Please help.


    55 pointsBadges:
  • anandx
    Q1: setll
    setll first, if %found then read further down or 
    setgt and readp if setgt was %found.
    %found in setll confirms a record exists whose key value is greater than or equal to the key value given in setll and hence a further read is required for validation (an exact match).
    a chain followed by %found would also serve the purpose in this instance.
    setll followed by %equal check will give the desired result of an exact match - usually, but result is not guaranteed always.
    Q2: subfile
    1. get values of field1, field2 and field3 from the user prior to building the subfile, store them in an array; use likeRec with dim()
    2. extract from the db file all the records that match user given values to those 3 keys, either using setll and reade combination or using sql select
    3. load those records into the subfile with fields 1 to 3 as output and 4,5 and 6 as both input and output type.
    5. allow the user to change values fields 4 to 6 in any record(s)
    5. readc subfile and fetch only the changed records.
    6. compare fields 4,5,6 of subfile records that have been changed the user by with the array and pick the ones whose current values don't match with previously displayedvalues.
    7. go back to db file, select only those records (this time lock the records) obtained from readc
    8. check whether the a record is already been changed by someone else
    9. update records which are unchanged in db file
    10. skip updating records which are already changed and don't forget to unlock those records
    11. display to user which are changed and which could not be changed and possibly redisplay unchanged records with newer values
    765 pointsBadges:
  • anandx
    Correction in subfile steps: Store the read db file records in an array not user inputs on fields 1 through 3, sorry.
    765 pointsBadges:

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.


Share this item with your network: