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

sub routines

Former Member
0 Likes
486

hi ...

can any one help me in understanding subroutines using all ( tables, raising, using , changing ) parameters in both call by refrence and call by value method... with sample code....

thank u

Ginni

hi ...

can any one help me in understanding subroutines using all ( tables, raising, using , changing ) parameters in both call by refrence and call by value method... with sample code....

thank u

Ginni

2 REPLIES 2
Read only

Former Member
0 Likes
454

Hi,

To help you understand better, just check this simple subroutine which uses using and changing parameters.

REPORT z_aris_test_12.

DATA: gv_export1(20) TYPE c VALUE 'Apple',

gv_export2(20) TYPE c VALUE 'Banana',

gv_flag TYPE flag VALUE 'X'.

START-OF-SELECTION.

PERFORM check_values USING gv_export1 gv_export2

CHANGING gv_flag.

&----


*& Form check_values

&----


  • text

----


  • -->%IMPORT1 text

  • -->%IMPORT2 text

  • -->%FLAG text

----


FORM check_values USING %import1 %import2

CHANGING %flag.

IF %import1 <> 'Apple'.

MOVE space TO %flag.

ENDIF.

IF %import2 <> 'Banana'.

MOVE space TO %flag.

ENDIF.

ENDFORM. "check_values

END-OF-SELECTION.

IF gv_flag = 'X'.

WRITE: 'Success!'.

ELSE.

WRITE: 'Fail!'.

ENDIF.

Hope it helps...

P.S. Please award points if it helps...

Read only

Former Member
0 Likes
454

Hi

Subroutines are mainly used for reusability of code.

PERFORM <name> USING < fields>

Tables it_VBAK

Changing v_kunnr.

form <name> USING < fields>

Tables t_VBAK type VBAK

Changing p_kunnr.

......code...

endform...

Fields are passed by Value and Internal Tables are always passed by reference.

Three ways of calling subroutines:

call by value ..

call by reference

call by value and reference.

See the SAP documentation.

Reward points if useful

Regards

Anji