Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SUBROUTINES

Former Member
0 Likes
1,141

Hii,

Can anyone give me the complete information about subroutines. How, PERFORM (Using and changing), FORM are used.

thanks,

raj

Hii,

Can anyone give me the complete information about subroutines. How, PERFORM (Using and changing), FORM are used.

thanks,

raj

7 REPLIES 7
Read only

Former Member
0 Likes
1,078

Hi,

Check the following link

[http://help.sap.com/saphelp_46c/helpdata/en/9f/db976935c111d1829f0000e829fbfe/content.htm]

regards,

Anirban Bhattacharjee

Read only

Former Member
0 Likes
1,078

All are modularization techniques but typically the INCLUDE is for data structures, the PERFORM is for ABAP/4 subroutines and function modules are for non-ABAP/4 subroutines.

By Value:When the subroutine is called ,the formal parameters are copies of the actual parameters(with their own storage location)

By Value and Result : the formal parameters have a separate storage location .At the end of subroutine the value of the formal parameter is passed to the storage location of the actual parameter

Assigned

By Reference: when called the formal parameters are not allocated separate storage locations. Instead the address of the actual parameter is passed. Changes to the values of the formal parameters therefore have a direct effect on the assigned main program fields.

PERFORM <name> USING <a1> <a2> <a3> <a4>

FORM <name > [TABLES <table name>] USING VALUE (<f1>) CHANGING VALUE (<f2>)

Include:

INCLUDE <name>

Function modules:

CALL FUNCTION u2018function nameu2019

EXPORTING u2026

IMPORTING u2026

The EXCEPTIONS parameter is a section in the CALL FUNCTION statement where exceptional situations can be processed.

CALL FUNCTION u2018function nameu2019

EXPORTINGu2026

IMPORTINGu2026

EXCEPTIONS NOT_FOUND = 3D1

NOT_VALID = 3D2

OTHERS = 3D3

CASE SY-SUBRC

WHEN 1

WHEN 2

Regards,

Rajasekhar Reddy

Read only

Former Member
0 Likes
1,078

SAP Help for performs in:

[ABAP|http://help.sap.com/saphelp_nwpi71/helpdata/en/9f/db976935c111d1829f0000e829fbfe/frameset.htm]

[Sapscript|http://help.sap.com/saphelp_nwpi71/helpdata/en/d1/803279454211d189710000e8322d00/frameset.htm]

Read only

Former Member
0 Likes
1,078

Hello,

In abap, there is a concept of modularization to increase the reusability of the code/function.So along with subroutines,i would suggest you to even have a little idea of all these techniques.Just check these links in the sequence.

Modularization

http://help.sap.com/saphelp_nw70/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/content.htm

Now u can go through :-

http://help.sap.com/saphelp_nw70/helpdata/en/9f/db974f35c111d1829f0000e829fbfe/content.htm

Go through the topis,i.e, Function modules & subroutines

Regards,

Bhumika

Read only

Former Member
0 Likes
1,078

Hi,

Yeah.Generally To avoid code redundancy we go for Subroutines. To complete a single complete process subroutines can be used.

an example will make u understand better.


DATA: itab TYPE STANDARD TABLE OF vbak,
      field1 TYPE vbak-vbeln,
      field2 TYPE vbap-posnr.



PERFORM get_data TABLES itab
                 USING field1
                 CHANGING field2


                .

*&---------------------------------------------------------------------*
*&      Form  get_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->IT_TAB1    text
*      -->IV_FIELD1  text
*      -->OV_FIELD2  text
*----------------------------------------------------------------------*
FORM get_data TABLES it_tab1
              USING iv_field1
              CHANGING ov_field2


              .

ENDFORM.                    "get_data

Here note that the *order of TABLES, USING, CHANGING should not be changed as USING, TABLES, CHANGING which will not work*

the values you pass throuhg USING cannot be changed inside the subroutine ( so its READ ONLY )

the tables should be passed in TABLES which can be changed

Cheers

Kothand