Help in Decimal Data Error

0 pts.
Tags:
RPG
RPGLE
hi , we have tow RPG code, where in 1 RPG say PGM A calls the other RPG PGMB. while calling PGM A passes a parameter to PGM B. the attributes of the parameters is supposed to be 2,0(Zoned), when we called the PGM B we faced a DECIMAL DATA ERROR. now the issue we found out is that in PGM A, the parameter (STAND ALONE) is defined as *LIKE of a database field which is again 2,0 (ZONED) but the compiler while compiling changes the attributes of the parameter to 2,0(PACKED) and hence the error. we are not able to find under what circumstances does this happen or does it happen all the time.??? Please help. Thanks Rama
ASKED: March 26, 2007  6:03 AM
UPDATED: January 4, 2010  7:03 AM

Answer Wiki

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

The quickest way around this is to move the 2S0 (Zoned) number to a character of the same length (2). Use the character variable as the parameter.
E.G. in Program A
MOVE NUM PARM1 2
CALL PGMB
PARM PARM1
————-
In Program B
*ENTRY PLIST
PARM PARM1 2
MOVE PARM1 NUM 2 0

Parameters, I have found, are best passed as charater, especially in RPG/V. In ILE you have more choices. However, when calling an RPG from a CLP or CLLE, you are bound to have problems using *DEC instead of *CHAR for the actual parameters.

Another way around this is to use the *LDA for parameter passing instead of using the PARM op code with a call. However, if you don’t have an estabilished protocol for using the *LDA, I would be careful about starting this now.

===============================================================

The RPG compiler prefers working with packed-decimal numeric fields. Regardless of the definition in a database record, RPG will try to use a packed field in program memory.

If you want to force RPG to use a particular data type, then define a DS like the record format of the database file. The subfield will bring the field attributes into the program.

Note that this can have an additional slight advantage of avoiding data-type conversions as fields are moved into and out of memory.

Tom

Discuss This Question:  

 
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

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