‎2007 Jun 30 11:47 AM
‎2007 Jun 30 11:50 AM
Hi,
Calling ABAP subroutines
You can call an ABAP subroutine from SapScript using the PERFORM statment. You can use this to get data
without havning to cnahge the print program. In the examole below NAME is retreived from table SCUSTOM.
SapScript
/:DEFINE &CUST& = '00000021'.
/:PERFORM GET_NAME IN PROGRAM Z_BC460_EX4_HF
/: USING &CUST&
/: CHANGING &NAME&
/:ENDPERFORM.
Dear &NAME&
The ABAP routine
The ABAP routine could be defined as follows:
IMPORTANT: The structure itcsy must be used for the parameters.
REPORT Z_HENRIKF_SCRIPT_FORM .
TABLES scustom.
FORM get_name tables in_tab structure itcsy out_tab structure itcsy.
read table in_tab index 1.
select single * from scustom
where id = in_tab-value.
if sy-subrc = 0.
read table out_tab index 1.
move scustom-name to out_tab-value.
modify out_tab index sy-tabix.
else.
read table out_tab index 1.
move 'No name' to out_tab-value.
modify out_tab index sy-tabix.
endif.
You could also fill the ouput parameter table this way
READ TABLE out_par WITH KEY 'NAME1'.
out_par-value = l_name1.
MODIFY out_par INDEX sy-tabix.
ENDFORM.
Note that if you use more than one parameter you must use Using or Changing before every parameter !
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
......
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
......
/: ENDPERFORM
Reward if helpful
Regards
Raghavendra.D.S
‎2007 Jun 30 11:50 AM
Hi,
Calling ABAP subroutines
You can call an ABAP subroutine from SapScript using the PERFORM statment. You can use this to get data
without havning to cnahge the print program. In the examole below NAME is retreived from table SCUSTOM.
SapScript
/:DEFINE &CUST& = '00000021'.
/:PERFORM GET_NAME IN PROGRAM Z_BC460_EX4_HF
/: USING &CUST&
/: CHANGING &NAME&
/:ENDPERFORM.
Dear &NAME&
The ABAP routine
The ABAP routine could be defined as follows:
IMPORTANT: The structure itcsy must be used for the parameters.
REPORT Z_HENRIKF_SCRIPT_FORM .
TABLES scustom.
FORM get_name tables in_tab structure itcsy out_tab structure itcsy.
read table in_tab index 1.
select single * from scustom
where id = in_tab-value.
if sy-subrc = 0.
read table out_tab index 1.
move scustom-name to out_tab-value.
modify out_tab index sy-tabix.
else.
read table out_tab index 1.
move 'No name' to out_tab-value.
modify out_tab index sy-tabix.
endif.
You could also fill the ouput parameter table this way
READ TABLE out_par WITH KEY 'NAME1'.
out_par-value = l_name1.
MODIFY out_par INDEX sy-tabix.
ENDFORM.
Note that if you use more than one parameter you must use Using or Changing before every parameter !
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
......
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
......
/: ENDPERFORM
Reward if helpful
Regards
Raghavendra.D.S
‎2007 Jun 30 11:55 AM
‎2007 Jun 30 12:04 PM
Hi Narayana
to call a subroutine from scripts we use perform in scrits text elements.
Syntax :
/: Perform <form-name> in program <program name>
/: using &in_var1&
/: changing &out_var1&
/: endperform
in se38
Form <form_name> tables itab itscy otab itcsy
Structure of itcsy
it has two fields name of the program symbol and value (text symbol value)
u can check it in se11 by typing itcsy
or
this simple example can help you out i hope.
in the script,
/: PERFORM WAREHOUSE IN PROGRAM ZWAREHOUSE
/: USING &WERKS&
/: USING &LGORT&
/: CHANGING &FLAG&
/: ENDPERFORM
/: IF &FLAG& NE 'X'
<print the data>
/: ENDIF
in the program zwarehouse,
FORM warehouse TABLES fp_in STRUCTURE itcsy
fp_out STRUCTURE itcsy.
TABLES t320.
DATA : l_werks LIKE resbd-werks,
l_lgort LIKE resbd-lgort,
l_flag(1) type c.
clear : l_werks, l_lgort, l_FLAG.
READ TABLE fp_in INDEX 1.
l_werks = fp_in-value.
READ TABLE fp_in INDEX 2.
l_lgort = fp_in-value.
SELECT SINGLE *
FROM t320
WHERE werks EQ l_werks AND
lgort EQ l_lgort.
IF SY-SUBRC EQ 0.
l_flag = 'X'.
ENDIF.
READ TABLE fp_out INDEX 1.
fp_out-value = l_flag.
MODIFY fp_out INDEX sy-tabix.
ENDFORM. "WAREHOUSE
reward all helpfull answers
Regards
Pavan
‎2007 Jun 30 2:06 PM