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
hi to all abap interview guys please notify this .. first if u have any doubts please go through google search or else please do debugging with some sample programs . but don't post even silly questions too. thanking you.
What are the different window types in sapscript?
How move-corresponding works
What abap statement will trigger list generation?
Explain what is the significance of hide?
What is evaluation path, where do we do it and why? : sap abap hr
What are the advantages/ dis-advantages of logical databases?
What is buffering in abap?
What does the extract statement do in extract datasets?
Can you assign a matchcode object to a parameter? If so how?
Write the bdc table structure? : abap bdc
What is the logo in sap script?
what next in SAP-ABAP/4 is it going to be change?
What is the difference between field-group header and other field groups? : abap modularization
What is the use of enqueue function module? : sap abap data dictionary