Subroutine has access to all LDA PDA and GDA while Subprogram can only use LDA and PDA then why should I use Subprogram? Why shouldn’t I use Subroutine always?
Is there any specific feature subprogram has?
Subroutine has access to all LDA PDA and GDA while Subprogram can only use LDA and PDA then why should I use Subprogram? Why shouldn’t I use Subroutine always?
Is there any specific feature subprogram has?
Please read up on the differences between internal and external subroutines, an external subroutine, for example, does not have access to the calling object’s LDA.
No doubt LDA is only existing for using element. I am eager to know about external subroutine and subprogram? Why should I use subprogram type ?
The main (only?) advantage an external subroutine has over a subprogram is access to the global data area. If you are not using GDAs, I would use subprogram.
Subroutines have access to the GDA. This could eliminate the need for a parameter list, which would be a performance advantage.
It is rare to create a subprogram which does not need data from the caller, so invariably a parameter list is needed. Processing a parameter list incurs overhead.
A disadvantage of subroutines is that they must exist and be executed within the same environment as the caller. (Hence the access to the GDA.) Subprograms can be invoked from anywhere on the planet via Remote Procedure Call, and they can be easily transformed into a webservice.
Thanks Wolfgang, Jerome and Ralph for your response.
I came to conclusion that -
If we just need to pass few parameters to be used across the environments use subprogram. But 99% we should prefer External Subroutine as it can have access to both “Passed parameters using PDA” and “Global data using GDA”.