× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



"How come the IBM i System appears to place as adjacent positions the four
parameters (within the same space of the first), making the first one
garbage-loaded? "

Simple answer - it doesn't.

The parameters passed to PgmB are pointers to the original storage in PgmA. So it is likely that you are either looking at it incorrectly in debug or else it is defined incorrectly in PgmA.

To better suggest an answer we need to see definitions and code - including your prototype.

Plus how are you using debug to see beyond the 860 bytes?


On Aug 14, 2019, at 12:01 AM, Javier Sánchez <javiersanchezbarquero@xxxxxxxxx> wrote:

In several web fora have I seen this topic posted, most of them do have an
explanation for some other issues which have been valuable, but I still
can't have the once-for-all answer.

I have learned that when passing parameters to CL programs, there are a few
very simple rules, like a default 32-byte minimum length for character
parameters, and also the very well known 15,5 packed decimal type for
numeric if sent in the command line.

I have an ILE RPG program pgmA which calls say another program pgmB with
four parameters:

One 32000 byte string which will hold an XML document.
A second which is a 24-byte message Id generated by MQ
A third which is another 24-byte correlation Id,
And finally a fourth which a 10-byte object name.

The four variables are created within pgmA with those lengths. They are
loaded with their respective values, and then I issue a prototyped
(dynamic) call to pgmB with those four parameters.

When I debug pgmB, and press F11 on the first parameter, I see that, for
example, my XML message is only 860 bytes long. When I inspect further
beyond that boundary, I find that the other three parameters appear within
the (supposedly) 32000-byte area of the first parameter just after the 860
bytes of my XML message. A validation in pgmB for the consistency of the
XML message, I get a parsing error, as the 860-byte message is actually NOT
followed by another 32000-860 bytes of blank spaces.

When I press F11 on the other parameters, they display their correct values
and their respective lengths.

I had to %SCAN the last tag of my XML document in order to obtain the
860-byte boundary of the message, and reassign it to another 32000-byte
automatic variable within pgmB, %TRIMming the former to load the latter
with no more garbage to the end of it. Another option was to %TRIM the XML
and append to it a X'00' as though it were a "C" string, and then %SCAN the
NULL value to get the length and then %SUBST to the local pgmB's variable.
To me this is really surprising.

How come the IBM i System appears to place as adjacent positions the four
parameters (within the same space of the first), making the first one
garbage-loaded? Very surprisingly too, I see as though it actually goes
through the first parameter from the back up to the first non-blank
character and then append the other three just to the right of the XML
message.

Thanks in advance for any clues on how to circumvent this.

Stay well everyone.
Javier.
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.