Midrange News for the IBM i Community


Posted by: Chris Proctor
Programmer Analyst
Columbia Sports Company
Portland, OR
Passing a data structure as a parm
has no ratings.
Published: 29 Sep 2015
Revised: 30 Sep 2015 - 573 days ago
Last viewed on: 24 Apr 2017 (1167 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.

Passing a data structure as a parm Published by: Chris Proctor on 29 Sep 2015 view comments(2)

Hello all. I'm having a problem coding with the new "DCL-"  when it comes to passing a data structure to a program that is being called within a program. I'm sure I just have the syntax wrong. Can someone please give me the correct way to code it? The error is telling me that the attributes of PARM4 don't match the prototype. It appears that maybe the program sees PARM4 as a data structure, but the prototype sees it as a CHAR(256) field, right? If so, how should I adress this? I don't think I can define the parm in the prototype as a data structure.  Thanks in advance!! Here's an example of one:

 

 

dcl-pr prcTypCurrSearch extpgm('TBL170');

  parm4 char(256);

end-pr;

 

dcl-ds parm4 extname('TBL170ED') inz end-ds;

 

 

 

dsevnt = sevent;

dsmod = 'PRC';

dsact = '1';

dstrn = '1';

dsnact = '0';

dshom = '0';

prcTypCurrSearch(parm4);

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

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Passing a data structure as a parm
Posted: 1 years 6 months 26 days 16 hours 14 minutes ago
Edited: Wed, 30 Sep, 2015 at 09:25:34 (573 days ago)

Um... LIKEDS can be used on Parameters since V5R3 (or was it V5R4).

So yes, you can define it as a DS, and probably should.

If your example is how your code is, then your issue could be that you have the prototyped parameter name as PARM4 and a data structure name of PARM4. So LIKEDS(PARM4) (which is also your data structure name) is not permitted. Since parameter names on Prototypes are just comments except for their definition, then change the parm name to something else on the prototype.

Posted by: chrisp
Premium member *
Portland, OR
Comment on: Passing a data structure as a parm
Posted: 1 years 6 months 26 days 14 hours 41 minutes ago

 Thanks, Bob. That worked like a champ!