Looking at returning a data structure from a sub procedure in a service program and I read a few articles and it seems to be working properly but wanted a second opinion on a couple of things.
First is it the best way? I am returning a data structure with address info in it. I don't like that I have to have the data structure definition in my copy book as it will get copied into every program regardless if it needs it or not. If I move it to my service program then my program won't compile as it sees the procedure definition referencing it.
Secondly, should I be using a different technique for returning a lot of like information. I don't really want to write a procedure for each piece. I read quite a few articles on this also but most were older.
Lastly if I need to add something to this data structure I am kind of SOL correct. I would either have to add it an optional parameter and populate it there or change the data structure and recompile every program that uses it.
First is it the best way? I am returning a data structure with address info in it. I don't like that I have to have the data structure definition in my copy book as it will get copied into every program regardless if it needs it or not. If I move it to my service program then my program won't compile as it sees the procedure definition referencing it.
Code:
// in copy book
Dcl-Ds addressDs qualified;
prefixName char(3);
firstName char(15);
middleIntial char(1);
lastName char(25);
suffix char(3);
streetAddress char(32);
apartment char(10);
address2 char(32);
address3 char(32);
address4 char(32);
city char(25);
zip char(10);
deliveryCode char(1);
poBox char(1);
companyName char(30);
scanZip char(10);
End-Ds;
dcl-pr OrderP_GetSoldToAddress likeDs(addressDs);
company packed(3) const;
order packed(8) const;
end-pr;
Lastly if I need to add something to this data structure I am kind of SOL correct. I would either have to add it an optional parameter and populate it there or change the data structure and recompile every program that uses it.





Comment