ILE sub-procedure does not return data from a ReadE operation

0 pts.
Tags:
Development
RPG
Sub-procedure is directly bound to pgm and has f-spec to read a file based on incoming keys. Handles the keys correctly and sets conditions based on found/not found in the file but the input buffer never loads into the field names for the file. Object is to return entire found record as a data-structure (externally defined) to caller through Procedure Interface, eliminating need for file in application pgm. The only DS fields that ever get loaded are fields expressly loaded in calcs from input parameters. I set a break-point immediately after the READE, pgm reads a record but the fields do not contain any data. Does this issue ring any bells with anyone?
ASKED: March 16, 2005  6:29 PM
UPDATED: April 1, 2005  8:10 AM

Answer Wiki

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

I suggest you define the data structure in both the program AND the subprocedure. Define the structure in the subprocedure as “based” on a pointer and pass the pointer instead of the datastructure into the procedure. When you define the structure in the program, define a separate pointer field and initialize it to the %addr of the data structure. This is the pointer that you would pass.

Discuss This Question: 9  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
  • AskDave
    The contents of the datastructure pass back ok. I'm not getting any of the fields loaded from READE within the sub-procedure. The sub-proc is in its own nomain module and bound at compile-time. After the Read operation (in the proc) the fields coming from the file are all initialized as either blanks or zeros. Anything I load into the DS fields directly stays & gets passed back to the caller of the proc. I'm thinking this may have something to do with activation group and scope, the file/field data has to go somewhere... The Chain or ReadE finds the correct record but everything but the key fields remains initialized (in the sub-proc, immediately after the operation).
    0 pointsBadges:
    report
  • mygoodname
    If you are not specifying INFSR on the F-spec, try placing it, along with the data structure, after the PI so that all of the variables are local to the subprocedure.
    0 pointsBadges:
    report
  • Chandana
    After the Reade operation, try this in the procedure. Move the Ds loaded to the Ds to be Returned. eg. F Customer D CustomerDs E ds P pCustomerDs like(CustomerDs) SetLL.... Reade E... pCustomerDs = CustomerDs;
    0 pointsBadges:
    report
  • Dorjaw
    Have you tried to read a record into data structure? d PI likeds(datastructure) c key chain fileformat datastructurname return datastructurename The data structure could be defined as: d datastructurename ds LIKEREC fileformat:*INPUT)
    0 pointsBadges:
    report
  • PG1998
    Try not to use %found, use the old indicator way of read and chain. I know it is starnge but I have found a few situations that %found doesn't work properly.
    0 pointsBadges:
    report
  • Rchevalier
    If you could post some code it would help a great deal. While the previous suggestions have been good, without seeing what your procedure is doing we are shooting in the dark. Using %FOUND isn't related to your issue so don't worry about that. One thing not yet mentioned is that depending on how you defined your data structure in the subprocedure it my be a qualified data structure even though you don't use the QUALIFIED keyword. If so, you will need to explicitly move each field from the file into the corresponding data structure field. Alternatively, you can read directly into the data structure as mentioned in a previous post. If I understand your situation correctly that is how I would do it. Even if the DS isn't qualified.
    0 pointsBadges:
    report
  • Joepbeckeringh
    You probably defined the externally defined data structure within the procedure, thereby inadvertently creating two sets of fields: the global ones that are automatically created by the RPG compiler and the local ones you defined within your procedure. When you read a record, the global fields are filled with the input data; the local fields stay empty. Remember: - all file data is global - local fields effectively hide global fields with the same names.
    0 pointsBadges:
    report
  • AskDave
    Thanks to all. Number 8 wins the prize though. The external DS was defined inside the proc instead of above it with the file spec. Dave
    0 pointsBadges:
    report
  • TomCarpenter
    Even though %Found is not part of the problem remember that with READE it is not a Found or not found condition that gets set. Instead you will get an %EOF rather than Not %Found. Just as with obsolute indicators you had a Error or End of File, Now you have a %Error or %EOF. Do not use %Found with READE the %Found will never get set. Remember: Chain = %Found
    0 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