on 01-30-2007 4:20 PM
When we are calling a subroutine from Script is it possible to retrieve an internal table from the program and use it in the script for printing data?
for eg:PERFORM <subroutine name> IN PROGRAM <program name> using<var1>
chnging<var2>.Can Var1 or var 2 be an internal table?
hi Savitha,
Var1 and Var2 are defintely tables, but does not serve the purpose of passing internal table values from print program. They are tables of structure ITCSY which has only two fields, NAME (field name) and VALUE (field value). Meaning for one field, there can be only one entry.
Please see the code attached below:
PERFORM get_attn IN PROGRAM zprogname USING var1 CHANGING var2.
FORM get_attn TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
DATA: v_name2 TYPE kna1-name2,
v_attn TYPE string,
v_kunnr TYPE knvk-kunnr,
v_offset TYPE i,
err_str TYPE string,
w_tab TYPE itcsy.
* Get Customer Number
READ TABLE in_tab INTO w_tab WITH KEY name = 'DKADR-KONTO'.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'W' NUMBER sy-msgno
INTO err_str .
ENDIF.
* Get Assistant name
MOVE w_tab-value TO v_kunnr.
v_offset = 10 - STRLEN( v_kunnr ).
SHIFT v_kunnr RIGHT BY v_offset PLACES.
OVERLAY v_kunnr WITH '0000000000'.
SELECT SINGLE name2 FROM kna1 INTO v_name2
WHERE kunnr = v_kunnr.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'W' NUMBER sy-msgno
INTO err_str .
ENDIF.
CLEAR w_tab.
READ TABLE out_tab WITH KEY name = 'ATT_NAME' INTO w_tab.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'W' NUMBER sy-msgno
INTO err_str .
ENDIF.
MOVE v_name2 TO w_tab-value.
MODIFY out_tab INDEX sy-tabix FROM w_tab.
ENDFORM. "get_attn
Hope this helps,
Sajan Joseph.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Savitha,
I believe it cant be a internal table.
Those r variables and in routine program has structured as ITCSY.
Use of Routine: It allows us to modify the values which r not able to do it in internal table in print program.
Best when u need to modify the fields in ZSAPSCRIPT and the values r coming from standard program. So in ZPROGRAM u can modify according to ur requirement.
Pls close the thread if the problem is solved. Reward to all helpful answers.
Regards
SAB
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.