|
On May 17, 2017, at 1:19 AM, Birgitta Hauser <Hauser@xxxxxxxxxxxxxxx> wrote:
If you use OPTIONS(*VARSIZE), you either need to pass the lengths as
additional parameters or add operational descriptors (keyword OPDESC)
and determine the length of the passed parameters with the CEEDOD API.
In either way make sure, that you access exactly the passed number of bytes.
Exaple:
DCL-PI DW_RtvRowOpnListAPI OpDesc;
POutRow Char(20) Options(*VarSize);
End-PI;
DCL-S DataLen Int(10);
DCL-S LocVar Char(20);
CEEDOD(1: *Zeros: *Zeros: *Zeros: *Zeros: DataLen: *Omit);
If DataLen = *Zeros; //Without data length
//What ever you want
EndIf;
LocVar = %Substr(POutRow: 1: DataLen);
%Subst(POutRow: 1: DataLen) = *Blanks;
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars."
(Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training
them and keeping them!"
„Train people well enough so they can leave, treat them well enough so
they don't want to.“ (Richard Branson)
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Dan
Sent: Mittwoch, 17. Mai 2017 01:41
To: RPG400-L@xxxxxxxxxxxx
Subject: 2 calls to same program using different parameter lengths
I am at my wit's end. I thought I knew this stuff, but maybe I've
just been lucky before with scenarios that didn't cause problems.
I created a utility program that masks account numbers, changing all
but the last 4 digits to asterisks. It has two parameters, both 20
byte characters, the first is input, the second is output. The
program that will call this utility program has a choice of passing
either two 20-character fields or two 17-character fields. The call
using the 20-character fields as parameters works fine. The call
using the 17-character fields as parameters does not. I've tried
several D-spec keywords, VARYING, OPTIONS(*VARSIZE), maybe others, to
no avail. VARYING doesn't work, I think, because the fields in the
calling program that I want to pass as parameters are not also
VARYING; the compile issued RNF7535 (The type and attributes of
parameter 1 do not match those of the prototype). I've created a
short calling program that mimics what is happening in the larger
program that I want to use the new utility program
in:
d CA9802R pr ExtPgm( 'CA9802R' )
d 20 Options( *VarSize )
d 20 Options( *VarSize )
d AC_ACCT s 20 Inz
d zz_ACCT s 20 Inz
d XX_OACHACT s 17 Inz
d zz_OACHACT s 17 Inz
ac_Acct = '12345678901234567890';
Callp CA9802R( ac_Acct : zz_Acct );
returns '****************7890'
XX_OACHACT = 'Just11Chars';
Callp CA9802R( xx_OACHACT : zz_OACHACT );
returns '**************** '
*inLR = *on;
DUMP(A);
Program CA9802R:
h DftActGrp( *No )
d CA9802R pi
d p_Account# 20a Options( *VarSize )
d p_MaskedAcct# 20a Options( *VarSize )
d MaskAccount# pr 20a
d AccountNbr 20a Const Options( *Trim )
p_MaskedAcct# = MaskAccount#( p_Account# );
*inLR = *on;
Return;
p MaskAccount# b
d MaskAccount# pi 20a
d AccountNbr 20a Const Options( *Trim )
d wAccountNbr s 20a
d Length s 3 0
d #ofAsterisks s 3 0
d i s 3 0
wAccountNbr = AccountNbr;
Length = %len( %trimr( wAccountNbr ));
If Length > 1;
If Length >= 8;
#ofAsterisks = Length - 4; // Mask all but last 4 digits
Else;
#ofAsterisks = Length / 2; // Mask half of the digits
Endif;
For i = 1 to #ofAsterisks;
%subst( wAccountNbr : i : 1 ) = '*';
Endfor;
Endif;
Return wAccountNbr;
p MaskAccount# e
When I debugged CA9802R, the p_Account# field for the second call had
a junk character in position 18. I understand it's because the
parameter passed from the calling program is 17 bytes, but I thought one of the "vary*"
keywords would allow me to do this without having to pass a length
parameter.
What am I missing here?
- Dan
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://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:
http://amzn.to/2dEadiD
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://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: http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.
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.