# How to decide out of Subprogram and Subroutine?

**URL:** <https://techcommunity.softwareag.com/t/how-to-decide-out-of-subprogram-and-subroutine/177301>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [July 8, 2014, 1:00pm UTC](https://techcommunity.softwareag.com/t/how-to-decide-out-of-subprogram-and-subroutine/177301 "2014-07-08T13:00:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shashank\_Gite1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/shashank_gite1/32/351_2.png) [@Shashank\_Gite1](https://techcommunity.softwareag.com/u/Shashank_Gite1)\
**Post date:** [July 8, 2014, 1:00pm UTC](https://techcommunity.softwareag.com/t/how-to-decide-out-of-subprogram-and-subroutine/177301/1 "2014-07-08T13:00:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [July 8, 2014, 5:54pm UTC](https://techcommunity.softwareag.com/t/how-to-decide-out-of-subprogram-and-subroutine/177301/2 "2014-07-08T17:54:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Shashank\_Gite1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/shashank_gite1/32/351_2.png) [@Shashank\_Gite1](https://techcommunity.softwareag.com/u/Shashank_Gite1)\
**Post date:** [July 8, 2014, 8:07pm UTC](https://techcommunity.softwareag.com/t/how-to-decide-out-of-subprogram-and-subroutine/177301/3 "2014-07-08T20:07:15Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Jerome\_LeBlanc](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/jerome_leblanc/32/111_2.png) [@Jerome\_LeBlanc](https://techcommunity.softwareag.com/u/Jerome_LeBlanc)\
**Post date:** [July 8, 2014, 8:14pm UTC](https://techcommunity.softwareag.com/t/how-to-decide-out-of-subprogram-and-subroutine/177301/4 "2014-07-08T20:14:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [July 8, 2014, 10:02pm UTC](https://techcommunity.softwareag.com/t/how-to-decide-out-of-subprogram-and-subroutine/177301/5 "2014-07-08T22:02:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Shashank\_Gite1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/shashank_gite1/32/351_2.png) [@Shashank\_Gite1](https://techcommunity.softwareag.com/u/Shashank_Gite1)\
**Post date:** [July 10, 2014, 8:13am UTC](https://techcommunity.softwareag.com/t/how-to-decide-out-of-subprogram-and-subroutine/177301/6 "2014-07-10T08:13:21Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:31pm UTC](https://techcommunity.softwareag.com/t/how-to-decide-out-of-subprogram-and-subroutine/177301/7 "2021-04-02T15:31:29Z")

</div>


