Prototyped Exported Procedure: Retrieve and Send a Record Back as a Data Structure Parameter

0 pts.
Tags:
RPG
I want to define a prototyped procedure that chains out to and returns data back from a record in a file. I don't want the calling program to reference the file in any manner (thereby encapsulating it from the file). Essentially, I wan't a standard Java "get". I've got two source elements. One, I "/Copy" into my calling program and my separate procedure. It holds the following lines of code: d ircdfmt e ds extname(fileabc) d rtvpgm pr d keyfld 10a d parrcdfmt likeds(ircdfmt) In my calling program, I "/Copy" the above code and it then brings in a data structure that holds all of the fields to my file, "fileabc". OK so far. I haven't had to put an "f" specification into my calling program. Now, I also "/Copy" the above code into my procedure, "getRecord". This code looks like this. p getRecord b export d getRecord PI d keyfld 10a d parrcdfmt likeds(ircdfmt) c keyfld chain file c if not %found c clear rcdfmt c endif eval parrcdfmt = rcdfmt I essentially want to chain to the file, load the record via the record format into my data structure and then return the data structure (populated with data) back to my calling program. Unfortunately, this won't compile. The compiler tells me that parrcdfmt and rcdfmt are not the same type so it won't let the "eval" statement work. Is there a way to make this work or a better/simpler way of retrieving a record without making reference to it in the calling program?
ASKED: March 18, 2005  6:42 PM
UPDATED: March 23, 2005  12:54 PM

Answer Wiki

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

hi,
you can just use an external ds (from the file) and export it in the *SRVPGM and import it in the calling PGM.
here is a little piece of code i use to do tha same :

Global parm :
FBRO010P1 uf a e k disk
D/Copy Qio_Proto,BRO010P1
d Io_BRO010P1 e ds extname(BRO010P1 )
d export
i have a few procedure (get_BRO010P1 <=> chain, .. and so on)

in the calling pgm :
d Io_Bro010p1 e ds extname(Bro010p1) import

My procedures get keys and some keywords like ‘*NEXT’, ‘*LOCK’ ….
and return always an indicator *off if operation fail, *on in other case.

hope this help

Discuss This Question: 1  Reply

 
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
  • JonP
    It would seem that the reason it won't compile is that the Eval should reference ircdfmt not rcdfmt. However there is a better way that avoids the eval completely. You don't mention what release you are on, but I'm assuming V5R2. The way to do this is to do the Chain directly into the parm. Instead of using LikeDS use LikeRec on the parm and specify the name of the record format. You will also need to specify the format name on the Chain. i.e. key Chain format parrcdfmt.
    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