‎2007 Mar 23 4:52 AM
There are a few basic questions on SAP Script that I have..
1. Can data be passed from my abap code to the SAP Script from where I am calling the SAP-Script..... IF Yes how??
2. I am using the write_form function and exporting the element name defined in SAP Script. But i am only able to print hardcoded text on the form. How can i use variables and other commands by which I can make my sap script more powerful??
‎2007 Mar 23 4:59 AM
same name as in your prog..
suppose your itab contains matnr.
loop at itab.
call write form.
endloop.
in script
P1(yuor paragraph format) &itab-matnr&
regards
shiba dutta
‎2007 Mar 23 4:57 AM
Hi,
To pass the data to form u have to use functio modules open_form,write_form,close_form.if ur modifying standard forms,then u have to go for external sub routines using ITCSY structure.
i think u have to give /E in command prompt on text editor,also put the values in between &&.
regards
ram..
‎2007 Mar 23 5:18 AM
Thanks Ram for ur effort...
Actually i am already using the open_form, write_form & close_form.
& I am not changing any of the standard forms. Using write_form I specify the name of the text element. which is defined in the SAP Script. But it is not helping me to pass values.
I have also used /E in the form layout.
i.e. /E Write : 'Hello World'.
But the above command doesnt display anything on print preview.
Can u help.
‎2007 Mar 23 4:59 AM
same name as in your prog..
suppose your itab contains matnr.
loop at itab.
call write form.
endloop.
in script
P1(yuor paragraph format) &itab-matnr&
regards
shiba dutta
‎2007 Mar 23 5:26 AM
Thanks Shiba. I understood what u r trying to say, but I am still not clear on how to pass the value from my abap code to the layout set.
I am already using write_form.
Call 'write_form'
exporting
element = 'XYZ'
..........
..........
I think this XYZ is an element defined in the page window of the layout. But i am still not able to pass any values from my ABAp-editor.
Can u help
‎2007 Mar 23 4:59 AM
Hi,
You have to use PERFORM subroutine to pass data to script from an external program written in SE38.
here is the sample code:
How to call a subroutine form SAPscripts
The Form :
/:PERFORM CDE_CENT IN PROGRAM ZKRPMM_PERFORM_Z1MEDRUCK
/:USING &EKKO-EBELN&
/:CHANGING &CDECENT&
/:ENDPERFORM
The report :
REPORT zkrpmm_perform_z1medruck .
DATA : BEGIN OF it_input_table OCCURS 10.
INCLUDE STRUCTURE itcsy.
DATA : END OF it_input_table.
déclaration de la table output_table contenant les
variables exportées
DATA : BEGIN OF it_output_table OCCURS 0.
INCLUDE STRUCTURE itcsy.
DATA : END OF it_output_table.
DATA : w_ebeln LIKE ekko-ebeln,
w_vbeln LIKE vbak-vbeln,
w_zcdffa LIKE vbak-zcdffa.
*----
*
FORM CDE_CENT
*
*----
*
FORM cde_cent TABLES input output.
it_input_table[] = input[].
it_output_table[] = output[].
READ TABLE it_input_table INDEX 1.
MOVE it_input_table-value TO w_ebeln.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_ebeln
IMPORTING
output = w_ebeln.
SELECT SINGLE zcdffa FROM ekko
INTO w_zcdffa
WHERE ebeln = w_ebeln.
it_output_table-name = 'CDECENT'.
MOVE w_zcdffa TO it_output_table-value.
MODIFY it_output_table INDEX 1.
output[] = it_output_table[].
ENDFORM.
*************************************************************************
REPORT ZMPO1 .
form get_freight tables in_par structure itcsy out_par structure itcsy.
tables: ekko,konv,t685t.
data: begin of itab occurs 0,
ebeln like ekko-ebeln,
knumv like ekko-knumv,
end of itab.
data: begin of itab1 occurs 0,
knumv like konv-knumv,
kposn like konv-kposn,
kschl like konv-kschl,
kbetr like konv-kbetr,
waers like konv-waers,
kwert like konv-kwert,
end of itab1.
data: begin of iout occurs 0,
kschl like konv-kschl,
vtext like t685t-vtext,
kbetr like konv-kbetr,
kwert like konv-kwert,
end of iout.
data v_po like ekko-ebeln.
read table in_par with key 'EKKO-EBELN'.
if sy-subrc = 0.
v_po = in_par-value.
select
ebeln
knumv
from ekko
into table itab
where ebeln = v_po.
if sy-subrc = 0.
loop at itab.
select
knumv
kposn
kschl
kbetr
waers
kwert
into table itab1
from konv
where knumv = itab-knumv and
kappl = 'M'.
endloop.
loop at itab1.
if itab1-kposn <> 0.
select single * from t685t
where kschl = itab1-kschl
and kappl = 'M'
and spras = 'EN'.
iout-vtext = t685t-vtext.
iout-kschl = itab1-kschl.
iout-kbetr = itab1-kbetr.
iout-kwert = itab1-kwert.
append iout.
clear iout.
endif.
endloop.
sort itab1 by kposn.
loop at iout.
sort iout by kschl.
if ( iout-kschl eq 'GSDC' OR
iout-kschl eq 'GSFR' OR
iout-kschl eq 'GSIR' ).
at end of kschl.
read table iout index sy-tabix.
sum.
write:/ iout-kschl,iout-vtext,iout-kwert.
out_par-name = 'A1'.
out_par-value = iout-vtext.
append out_par.
out_par-name = 'A2'.
out_par-value = iout-kwert.
append out_par.
endat.
endif.
endloop.
endif.
endif.
endform.
IN THE FORM I AM WRITING THIS CODE.
/:DEFINE &A1& = ' '
/:DEFINE &A2& = ' '
/:PERFORM GET_FREIGHT IN PROGRAM ZMFORM_PO1
/:USING &EKKO-EBELN&
/:CHANGING &A1&
/:CHANGING &A2&
/:ENDPERFORM
&A1&
&A2&
This Code is to be written in the PO form under ADDRESS window.
-
-
/:DEFINE &A1& = ' '
/:DEFINE &A2& = ' '
/:DEFINE &A3& = ' '
/:DEFINE &A4& = ' '
/:DEFINE &A5& = ' '
/:DEFINE &A6& = ' '
/:PERFORM GET_VENDOR IN PROGRAM ZMFORM_PO
/:USING &EKKO-EBELN&
/:CHANGING &A1&
/:CHANGING &A2&
/:CHANGING &A3&
/:CHANGING &A4&
/:CHANGING &A5&
/:CHANGING &A6&
/:ENDPERFORM
&A1&
&A2&
&A3&
&A4&
&A5&
&A6&
You can export ELEMENT and WINDOW using the Write_form fun module and in the text elements of the window ins cript define that text element in that window and write your data.
just see any std script and driver program.
MEDRUCK is the Script for PO and SAPMF06P is the program.
reward if useful,
regards,
Anji