Midrange News for the IBM i Community


Posted by: Chris Proctor
Programmer Analyst
Columbia Sports Company
Portland, OR
Parms running together
has no ratings.
Published: 27 Feb 2014
Revised: 28 Feb 2014 - 3703 days ago
Last viewed on: 17 Apr 2024 (4681 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Parms running together Published by: Chris Proctor on 27 Feb 2014 view comments(6)

Can someone tell me why this happens? I have a program that receives 4 parms. If I call it from a command line, if it's a character parm, I'm not worrying about specifying the entire length of the parm. However, when I look at it in debug, I could have two or more parm values showing in a single parm field. For example, I'm calling this program from the command line:

call altseqtst ('411' 'test@austin.rr.com' 'Bob' 'Cozzi')

My input parms are defined with the following in the program:

d test            pr                  extpgm('ALTSEQTST')  
d pstore                         3a                        
d pemail                        50a                        
d pfname                        50a                        
d plname                        50a                        
                                                           
d test            pi                                       
d pstore                         3a                        
d pemail                        50a                        
d pfname                        50a                        
d plname                        50a                        

Because the email address I entered is shorter than the 50a specified, it appears the first name is being appended to the email parm. I should also say that the field below is what the pemail parm is being copied into for the key list. This is what the field looks like:

> EVAL ademl1                                                            
  ADEML1 =                                                               
            ....5...10...15...20...25...30...35...40...45...50...55...60 
       1   'test@austin.rr.com             Nancy                      '
      61   '                                                            '
     121   '                                                            '
     181   '                                                            '
     241   '              '                                              

I'm sure someone can explain this. I'm sure if I accounted for all 50 characters when I called the program I would have had this issue, but is there a way of getting around it?

Thanks!

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Parms running together
Posted: 10 years 1 months 20 days 18 hours 48 minutes ago

If you're not using a command, you have to pad the Command Line call parameters to 32 characters or you end up with crap in your programs.

Posted by: Ringer
Premium member *
Comment on: Parms running together
Posted: 10 years 1 months 20 days 8 hours ago

Any parm length over 32 needs to be manually padded from a command line. It's a known quirk. Pass 50 blanks and then an X in position 51 to get around it. 

'12345678901234567890123456789012345678901234567890x' 

RPG handles this just fine if the parm value is defined as 50a long. OS400 just passes a memory address, not the value. So you pass in 51a and RPG only uses 50a of it. 

Chris Ringer

Posted by: Ringer
Premium member *
Comment on: Parms running together
Posted: 10 years 1 months 20 days 5 hours 27 minutes ago

http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.pgmgd.doc/evfclmst80.htm

"Character string constants of 32 bytes or less are always passed with a length of 32 bytes (padded on the right with blanks). If a character constant is longer than 32 bytes, the entire length of the constant is passed. If the parameter is defined to contain more than 32 bytes, the CALL command must pass a constant containing exactly that number of bytes. Constants longer than 32 characters are not padded to the length expected by the receiving program."

Chris Ringer

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Parms running together
Posted: 10 years 1 months 20 days 4 hours 16 minutes ago

I've written small CLPs for testing that do nothing but call another program, with the correct *CHAR lengths. But better yet (Bob already gave you the hint), define a *CMD. When your PARM has TYPE(*CHAR) LEN(50), the command processor ensures that your program receives exactly 50 characters, regardless of the length that is parsed from the command line.

Note that command parsing also applies to SBMJOB CMD(CALL ...). Let's say you're in a CLP or CLLE, and do SBMJOB CMD(CALL PGM(x) PARM(&A)). Even when &A is declared as *CHAR 50, the CLP will truncate trailing blanks from &A when putting it in the parm, and the effective SBMJOB will be CMD(CALL PGM(x) PARM('test@austin_rr.com')). Called program X is still subject to the length and padding rules of the parser.  Even if it's just for testing, a *CMD can be a real help.

Posted by: chrisp
Premium member *
Portland, OR
Comment on: Parms running together
Posted: 10 years 1 months 20 days 4 hours 4 minutes ago

I kinda' thought that was the case. Chris, I didn't realize that anything 32 or less will be padded with blanks. That's some good info to know. Being as this is just a small test pgm I didn't want to go thru the hassle of having to create a cmd for it so I just put it in debug and padded the parm manually.

Thanks for the input, guys!

Chris

Posted by: Ringer
Premium member *
Comment on: Parms running together
Posted: 10 years 1 months 20 days 3 hours 53 minutes ago

Good point Dale about SBMJOB. Same rules. I know that but failed to mention it. 

Chris Ringer