Can we call a subroutine in a script? If so, how?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / chittidi
YES , WE CAN CALL SUBROUTINES IN SCRIPTS WITH OUT
CHANGING THE STANDARD DRIVER PROGRAM TO FETCH ADDITONAL
DATA TO PRINT IT ON LAYOUT.
WRITE SUBROUTINES IN MAIN PROGRAM AND CALL THE SUBROUTINE
ie PERFORM in page WINDOW OF THE LAYOT.
SYNTAX :
/: PERFORM <FORM>IN PROGRAM <PROG> USING &INVAR1& &INVAR2&
........
........
/: CHANGING &OUTPUT1& &OUTPUT2&.
........
ENDFORM.
FORM <FORM> TABLES IN_TAB STRUCTURE ITCSY OUT_TAB STRUCTURE
ITCSY.
........
ENDFORM.
HERE INVAR1 , INVAR2 ARE VARIABLE SYMBOLS WHICH MAY BE ONE
OF THE FOUR SCRIPT SYMBOL TYPES.
OUTPUT1 , 2 ARE LOCAL TEXT SYMBOLS AND MUST BE CHAR STRINGS.
THE INTERNAL TABLE OUT_TAB CONTAINS 2 FIELDS THAT IS
NAMES AND VALUES OF THE CHANGING PARAMETERS IN THE PERFORM
STATEMENT.
Is This Answer Correct ? | 1 Yes | 1 No |
How do you populate data into a multiple line field?
It is not possible to create an abap/4 program, which contains only subroutines. State true or false. : abap modularization
what is the process of dialog program from first to last?
Have you used SAP supplied programs to load master data?
What does an extract statement do in the ABAP program?
what is a text table ?
how many main windows you can maintain in a smartform? wt is the types of window in smartform?
Between select .........endselect write one statement executes the cursor goes to dump analysis?what is the statement ?
what is protect and endprotect?
What are the differences between the table and the structure in the data dictionary in the sap abap?
what is basic diff b/w 4.7e and ecc 5.0. or 6.0?any one knows please give me exact answer?
How to transport from one client data to another in realtime, what is the transaction code for transport, where the maintain table maintenance generator in realtime,