Basically the method is pretty 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.
Do you have an external definition for the data structure? I would recommend that, so that you won’t have to define it twice (once from the calling procedure and once to the receiving procedure or program). Also, you would be able to use in other programs or modules as well.
Below is a quick example. 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 Procedure1 PR
D ParmDS LIKEDS(SomeDataStruct)
Here is that data structure internally defined (however, the column positions aren’t necessarily lined up correctly).
D SomeDataStruct DS
D Field1 10A
D Field2 2S 0
If you have an external definition, such as based on an externally described file, you could use the EXTNAME keyword to refer to that file, and then you wouldn’t need the individual field definitions because they’d be brought in from your external file.
In your incoming procedure, it would look similar.
P Procedure1 B
D ParmDS LIKE(SomeDataStruct)
//To call procedure (or if using fixed format, you’ll need the CALLP operation code).
Procedure1 ( SomeDataStructure) ;