RNF7591 on func’s result

25 pts.
Tags:
AS/400
RPG
Dear all! I am trying to work with DS fields returning from procedure call. Here are definitions:
d fileds E ds EXTNAME(file1:rfmt1) qualified

d rsltds ds likeds(fields)

d getDS pr likeds(fields)

d inID const like(ID)

d inDATA const like(DATA) options(*nopass)
If I write:
rsltds=getDS(id1:D'1901-01-01');

out=%char(rsltds.id_op);
it is compiled, but if I write:
out=%char(getDS(id1:D'1901-01-01').id_op);
I receive *RNF7591. What is wrong in the last case?
1

Answer Wiki

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

Good question .. this looks like it would work but …

rsltds=getDS(id1:D’1901-01-01′);

This step maps the return into the data structure rsltds

out=%char(rsltds.id_op);

This step uses id id_OP part of that data structure

out=%char(getDS(id1:D’1901-01-01′).id_op);

The attempts to grab the subfield id_OP from the return set but the return set is just an address, not a structure.

Discuss This Question: 4  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.
  • tempally

    Address? I did not define getDS's prototype as returning a pointer.

    Anyway, your answer means that we always need a 'recipient' to make copying of the result's body possible . But how then work things like "If func(arg)='text';" - in this case we have no place to "store" the result of func's call, but it works!

    25 pointsBadges:
    report
  • philpl1jb

    All calls pass pointer locations.

    Why does this If func(arg)='text';  work?

    if func returns the pointer to some text, it can be compared with some text.

    Why doesn't this work? out=%char(getDS(id1:D'1901-01-01').id_op);

    you say use the .ip_op field of the return but the program doesn't know what the .ip_op part of the return is.  It only gets an .ip_op part when it's mapped into a data structure.




    54,090 pointsBadges:
    report
  • tempally

    And that is completely strange!

    "if func returns the pointer to some text..." - how can program know that pointer points to text? It have function's prototype which describes return data type

    "...program doesn't know what the .ip_op part of the return is." - the same way, program has function's prototype, so, it know that result is a DS, and RPG works with pointer-based DS very well...

    25 pointsBadges:
    report
  • philpl1jb

    The prototype is used during compile to make certain the call passes the required parameters but your prototype could have any field names or no field names and you could compile.


    54,090 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: