

It is a modularization unit within the program where a function is encapsulated in the form of source code. SAP-ABAP Core ABAP Interview Questions.Ī subroutine is a reusable section of code.

Is it possible to call a subroutine of one program from another program? Add a Question Tags. Perform statement in ABAP is used to call an ABAP subroutine from any program. * Form Sub_Display * -> p1 text *.External Subroutines in SAP Script - Community Profiles.

Let’s take a look at the code − REPORT ZSUBTEST. We need to include PERFORM statement to call the subroutine. The subroutine has been created successfully.

Step 3 − Write the code in FORM and ENDFORM statement block. The subroutine name is 'Sub_Display' as shown in the following screenshot. Write the subroutine name in the field and then click the continue button. Step 2 − Select Create and then select Subroutine. Open the existing program and then right-click on program. When ENDFORM is encountered, control jumps back to the statement following the PERFORM statement. The control jumps to the first executable statement in the subroutine. We can call a subroutine by using PERFORM statement. Security Note If the name of a program unit is specified dynamically when it is called, and this name is passed to a program from outside, the result is a serious security risk.įollowing is the general syntax of a subroutine definition. CALL CUSTOMER-FUNCTION is another variant for calling obsolete function module exits. A subroutine can be defined using Form and EndForm statements.Įxternal in the sense if you create a sub routine in one program and you're calling this subroutine in another program.then this is external. We can call this subroutine in our programs as many times as we wish. To make this code easier to maintain, we can encapsulate the code into a subroutine. Basically, they are the same code blocks. We have program X with 3 different source code blocks.Įach block has the same ABAP statements. You page out a part of a program to a subroutine to get a better overview of the main program, and to use the corresponding sequence of statements many times as depicted in the following diagram. A subroutine is a reusable section of code.
