10-03-2006 3:17 PM
Hi All,
I am calling a sub-routine in a INCLUDE PROGRAM <b>'ZTEST'</b> form a sap-script using a PERFORM STATEMENT.
The data which i retrive inside this sub-routine in my include<b>'ZTEST'</b> is coming in an internal table and I have to display all the entries of the internal table.
I am trying to define a element <b>'DISPLAY_ITEM'</b> inside the sap-script and trying to call that in a loop inside my INCLUDE program using WRITE_FORM. But nothing getting printed after the new element<b>'DISPLAY_ITEM'</b> which i have defined and was calling from the INCLUDE PROGRAM.
Message was edited by: Kaushal Bhavsar
10-03-2006 3:21 PM
Hi kaushal,
1. while calling subroutines from sapscripts,
there is a special technique,
which has got its own limitations.
(It should be program of type 1, and not an include)
2.
FORM abc
TABLES
in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
ENDFORM.
3. The perform in se38 program should be of the
above format only.
4. We cannot pass internal tables.
5. Rather we need to pass
VARIABLE NAME
VARIABLE VALUE
(see the structure of itcsy in se11)
6. In this form, we have to read
the internal table in_tab
to capture the variable name and its value.
7. Similary, to return the values,
we have to put one record (for each variable)
in out_tab.
regards,
amit m.
10-03-2006 3:22 PM
Hi Kaushal,
You cannot pass/ get values in the form of internal tables using performs in sap scripts.
Instead you can keep this perform in a text element which is being called in the loop of an internal table.
Regards,
Ravi
10-03-2006 3:24 PM
Hi,
Have a look at the example for calling subroutines from script.
http://www.sap-basis-abap.com/abap/how-to-call-a-subroutine-form-sapscripts.htm
Hope this helps.
10-03-2006 3:26 PM
hi,
A sample code of how to use performs in sap scripts.
In script program,
/:PERFORM GET_SBGRP_STEXT IN PROGRAM ZSDSCRIPT
/:USING &GV_MATNR&
/:CHANGING &GV_STEXT&
/:TABLES INPUT_TABLE
/: OUTPUT_TABLE
/:ENDPERFORM
In program ZSDSCRIPT,
form get_sbgrp_stext tables intab structure itcsy
outab structure itcsy.
DATA: LV_MATNR LIKE MARA-MATNR,
LV_TEXT(3) TYPE C VALUE 'ABC'.
clear intab.
read table intab with key name = 'GV_MATNR'.
if sy-subrc = 0.
lv_MATNR = intab-value.
ENDIF.
CLEAR OUTTAB.
READ TABLE OUTAB WITH KEY NAME = 'GV_STEXT'.
IF SY-SUBRC = 0.
OUTAB-VALUE = LV_TEXT.
modify outab index sy-tabix.
ENDIF.
endform.
Regards,
Sailaja.
10-03-2006 3:31 PM
Hi Kaushal,
when you create Perform and Endperform, you can transfer the fields one by one, you can not transfer entire Internal table in one shot,
When you write the perform statment in Script, use CHANGING variables
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
/: CHANGING &OUTVAR3&
/: CHANGING &OUTVAR4&
......
/: ENDPERFORM
in your Program <b>ZTEST</b>, while calling
FORM <FORM> TABLES IN_PAR STRUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY
Read the IN_PAR table to get the values ..
while putting the values to outtab, loop that internal table and pass to the Output table to the CHANGING parameters in SCRIPT,
ENDFORM
hope you understand
Regards
Sudheer