RPGIV @ Work

A unique site for RPG and System i Lovers

Welcome!

Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Passing parameters via a datastructure to and from a procedure Print E-mail
User Rating: / 0
PoorBest 
Written by Chamara Withanachchi   

You may need to pass parameters in to Procedures using Data Structures, bellow is how to do it.


Basically the method is very similar to passing a "regular" parameter, only you define as a data structure and refer to that data structure on the prototype and procedure interface. Are you wanting pass by reference or by value. Passing by reference is implicit, but if you want to pass by value, just add the VALUE keyword to your parameter definitions.


Note that the parameter names don't have to match between the calling code and the receiving procedure; just as long as the signatures match. Ideally, you'll want to define your data structure elsewhere in the Definition specifications, whether internal or external, so that you can just refer to it in your prototope. Use the EXTPGM keyword (on the PR line) if you were prototyping a call to another program and wanting to pass that same data structure.


     D soFlds        E DS                  ExtName(SODS8001)

     D callTmPost      PR                  ExtProc('PD0900M')                                            
     D   parmDS                            LikeDs(soFlds)


            callTmPost(soFlds);

<Previous   Next>