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 many fields(max) can be there in a transparent table?
2 Answers iGate, Unilogic Software,
What is pakey structure, pshd1 structure and what type of fields it contains? : abap hr
How to transfer the objects? Have you transferred any objects?
In a script, i want to print something at end of last page only.How can i print it?
MY DOMAIN IS SAP-ABAP COMPARE TO WEBDYNPRO AND CRM-TECHNICAL WHICH IS BEST?
Hi, If anyone is interested in SAP ABAP from basics to Expert. Email me your contact details to sap.abap9@gmail.com
What are the disadvantages of abap query tool?
in ECC6.0 version which package u r working means what? if errors occurs during database updation using bapi how vl v know??bcoz it directly updates db?? how vl v pass tables in smartformd?
what are the two methods of modifying sap standard tables ?
What is lock objects? : sap abap data dictionary
in an interactive report i want to trigger both 'at line selection' and 'user command'....if possible then how?
What is the use of update Function Module ? Where it is used and purpose ?