Can we call a subroutine in a script? If so, how?

Answer Posted / kiran kumar v

Yes. Subroutine can be called using ITCSY structure.

Sample Code:
/: PERFORM SUM IN PROGRAM ZPROGRAM
/: USING &VAR1&
/: USING &VAR2&
/: CHANGING &RESULT&
/: ENDPERFORM

In the program(ZPROGRAM), we need to write the form ....

FORM SUM TABLES INTAB STRUCTURE ITCSY
OUTTAB STRUCTURE ITCSY.
data: field1 type i,
field2 type i,
result type i.

TO read the values from the ITAB you have to use this logic.
READ TABLE INTAB WITH KEY NAME = 'VAR1'.
IF SY-SUBRC = 0.
FIELD1 = INTAB-VALUE.
ENDIF.

READ TABLE INTAB WITH KEY NAME = 'VAR2'.
IF SY-SUBRC = 0.
FIELD2 = ITAB-VALUE.
ENDIF.


RESULT = V_FIELD1 + V_FIELD2.
READ TABLE OUTTAB INDEX 1.
IF SY-SUBRC = 0.
OTAB-VALUE = RESULT.
MODIFY OUTTAB INDEX 1 .
ENDIF.
ENDFORM.

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between a structure and an append structure?

751


Can you delete data element, which is being used by table fields?

1039


What is difference between check table and value table ?

818


Explain the call transaction method? : abap bdc

782


What is the use of info groups? : sap abap hr

754






what precautions or prerequisites do you follow to update a record into database table and how

5586


hi my name is amit i have passed BE(CSE) with honours(72%) in 2006 yr. i have completed SAP/ABAP training with good exposer. i need a staffing company which can provide me real time exposer in SAP R/3. so plz help me out and send any information regarding on my mail id or tele. no. 9999784331 thanks

1628


did u done enhancement framework?how u implemented?

5271


I have 3 transactions,where the output of one transaction is input of another and output of 2nd transaction is input of 3rd transaction.i have one flat file with all data for the 3 transaction.if the 3rd transaction failed can we rollback the remaining 2 transactions or not.Is this possible in BDC,How/

2014


How would you set the formatting options statically and dynamically within a report?

849


What is the syntax for ‘call transaction’?

799


Difference between function group and function module?

822


What is the difference between tables and structures?

796


Are you familiar with all steps for setting up a workflow?

1849


What is the difference between semi-monthly and Bi-weekly payroll area

3219