|
Hi Jean, On Tue, 28 Oct 2003, Jean Reksodiputro wrote: [SNIP] > I have a wrapper CLP, where I declared this vars: > Dcl &ArrWhs *Char 1 > Dcl &NbrWhs *Dec (3 0) 0 > Dcl &OkFlag *Char 1 [SNIP] > Divspwhchkr PI > > D p1_AuthWhs 2 0 dim(99) > D p1_NbrWhs 3 It's very important to understand that when you pass a parameter by reference (which is what you're doing here -- and is the default method of passing parms) the parameter utilizes the same space in memory as the calling program's variable. It is, therefore, very important that whichever program originally declares the variable declares as much memory, or more, as will be needed by each program that receives these parameters. If I understand correctly, your CL program is the "originator" of that variable. It allocates space for a TYPE(*CHAR) LEN(1) variable (1 byte) and then passes it as a parameter to each RPGLE in turn. Now consider what happens... Your first RPG program reads that parm as a 198 byte long array! There's only 1 byte allocated by the CL program, but the RPG is trying to access 198 bytes! Whatever data happened to be in the next 197 bytes of memory after &ArrWhs will be overwritten by your array. This could be harmless, but more likely, you're going to overwrite something important! Instead, you need to make sure you allocate space for the entire array. The easiest way to do this would be to declare &ArrWhs as TYPE(*CHAR) LEN(198) That way, you've declared the entire 198 bytes that you need. The only time that you could get away with declaring only 1 byte would be if the array was an input parameter to the CL, and you were just passing it through to another program. In this case (unless I misundersand you) you're not just passing it through, it's originating from the CL program. Good Luck
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.