|
Hi Rick - I'm on my lunch hour so I don't have time to go in depth ...
where do you specify files in a service program? just under the H specs like an OPM program?
Yes.
What if this file is only needed in one of the service program procedures? is there a way to make the file local to that procedure only?
No. Neither files nor their fields can be local.
can service program procedures have subroutines?
Yes.
or do you have to create sub-procedures? if both, recommendations?
It depends. If the code does not need any of the special capabilities of procedures (like recursion) and it is used only within this procedure, I would probably make it a subroutine. Subroutines are local to the procedure that they are in, so if it needs to be available to multiple procedures, it will need to be a procedure itself. You can have procedures in a service program which cannot be called from the outside. Only procedures that are exported can be called from outside of the module in which they reside.
if just sub-procedures, are variables defined at the main procedure level global to the sub-procedure (like a subroutine) or do I have to define them up with the files to make them global?
If by "main procedure" you are talking about mainline (detail) calcs, this is not applicable to service programs. If by "main procedure" you are talking about what I have been calling the "first procedure", then the following applies. Local variables are local to the procedure that they are in. If a procedure calls another procedure, the local variables in the first procedure are not visible to the second procedure. You would need to either: 1. make them global (define them in d-specs right under the files), 2. export/import, or 3. pass them on the call to the second procedure. I would stay away from #2 as exporting them will make them visible to the outside world unless you use binder language to prevent it. Ken Opinions expressed are my own and do not necessarily represent the views of my employer or anyone in their right mind.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.