2007 Aug 27 4:25 PM
Hi experts,
I have a requirement.
i want to print the 'kunnr' 'name1' 'ort01' 'land1' in the address window of a script.
i am taking 'kunnr' as the input from the selection screen as select-options.
Now, i want to call a subroutine in the address window of the Form, for extracting the data.
Please tell me what to right in the address window editor.
and also please show the subroutine code to extract the data to be written in the print program.
thankyou.
Hi experts,
I have a requirement.
i want to print the 'kunnr' 'name1' 'ort01' 'land1' in the address window of a script.
i am taking 'kunnr' as the input from the selection screen as select-options.
Now, i want to call a subroutine in the address window of the Form, for extracting the data.
Please tell me what to right in the address window editor.
and also please show the subroutine code to extract the data to be written in the print program.
thankyou.
2007 Aug 27 4:36 PM
Syntax goes like this
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
......
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
......
/: ENDPERFORM
INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.
OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.
Example:
In script form
/: PERFORM READ_TEXTS IN PROGRAM 'Z08M1_FORM_EKFORM1'
/: USING &EKKO-EKORG&
/: USING &EKPO-WERKS&
/: USING &EKKO-EKGRP&
/: USING &EKKO-BSTYP&
/: CHANGING &COMPNAME&
/: CHANGING &SENDADR&
/: CHANGING &INVCADR&
/: CHANGING &COMPADR&
/: CHANGING &COVERLTR&
/: CHANGING &SHIPADR&
/: CHANGING &REMINDER&
/: CHANGING &REJECTION&
/: CHANGING &POSTADR&
/: CHANGING &LOGO&
/: ENDPERFORM
In program
----
FORM Read_texts - To extract the standard texts from the table *
----
FORM READ_TEXTS TABLES IN_PAR STRUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA : L_EKORG TYPE EKORG,
L_WERKS TYPE WERKS_D,
L_BSTYP TYPE BSTYP,
L_EKGRP TYPE BKGRP.
READ TABLE IN_PAR WITH KEY 'EKKO-EKORG' .
CHECK SY-SUBRC = 0.
L_EKORG = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY 'EKPO-WERKS' .
CHECK SY-SUBRC = 0.
L_WERKS = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY 'EKKO-EKGRP' .
CHECK SY-SUBRC = 0.
L_EKGRP = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY 'EKKO-BSTYP' .
CHECK SY-SUBRC = 0.
L_BSTYP = IN_PAR-VALUE.
CLEAR Z08M1_ORG_TEXTS.
SELECT SINGLE * FROM Z08M1_ORG_TEXTS WHERE EKORG = L_EKORG
AND WERKS = L_WERKS
AND EKGRP = L_EKGRP
AND BSTYP = L_BSTYP.
IF SY-SUBRC NE 0.
SELECT SINGLE * FROM Z08M1_ORG_TEXTS WHERE EKORG = L_EKORG
AND WERKS = L_WERKS
AND EKGRP = L_EKGRP
AND BSTYP = SPACE.
ENDIF.
READ TABLE OUT_PAR WITH KEY 'COMPNAME'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_COMP.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'SENDADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_ADRS.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'INVCADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_INVC.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'COMPADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_CPAD.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'COVERLTR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_COVR.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'SHIPADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_SHIP.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'REMINDER'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_RMDR.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'REJECTION'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_RJCT.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'POSTADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_POST.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'LOGO'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_LOGO.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
2007 Aug 27 4:43 PM
/:PERFORM GET_DATa IN PROGRAM ztest
/:USING &kna1-kunnr&
/:CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
/:CHANGING &OUTVAR3&
/: ENDPERFORM.
in ztest program write the fallowing code in se38 editor.
form get_data tables in_par structure itcsy
out_par structure itcsy.
data:w_kunnr type kna1-kunnr,
v_var1 type kna1-name1,
v_var2 type kna1-ort01,
v_var3 type kna1-land1,
lv_index type sy-tabix.
read table in_par with key 'KNA1-KUNNR'.
if sy-subrc eq 0.
w_kunnr = in_par-value.
endif.
select single name1
ort01
land1
from kna1
into (v_var1,v_var2,v_var3)
where kunnr = w_kunnr.
read table out_par with key 'OUTVAR1'.
if sy-subrc eq 0.
move v_var1 to out_par-value.
move sy-tabix to lv_tabix.
endif.
clear out_par.
read table out_par with key 'OUTVAR2'.
if sy-subrc eq 0.
move v_var2 to out_par-value.
move sy-tabix to lv_tabix.
endif.
clear out_par.
read table out_par with key 'OUTVAR3'.
if sy-subrc eq 0.
move v_var3 to out_par-value.
move sy-tabix to lv_tabix.
endif.
clear out_par.
modify out_par index lv_tabix.
endform.
2007 Aug 27 5:38 PM
Hi viki,
Is there any specific reason why you want to use Subroutines in this case?
We use subroutines in sap scripts, when we have to implement some big logic that we can not implement in sap script editor.
For your case, the best way will be to fill the work areas in your driver program and simply write them in you sap script using &var1& &var2& etc..
Make a text element in your address window:
/E ADDRESS
&w_kunnr&,,&kna1-name1&,,&kna1-ort01&,,&kna1-land1&
In your driver program do this:
SELECT SINGLE name1 ort01 land1
FROM KNA1
WHERE kunnr EQ w_kunnr.
IF sy-subrc EQ 0.
CALL FUNCTION WRITE_FORM
EXPORTING
WINDOW = 'address'
ELEMENT = 'ADDRESS'
ENDIF.
Thanks and Best Regards,
Vikas Bittera.
**Points for Usefull answers **
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |