Sap script perform subroutine
i got this sample code from sdn, but i have a dobt in this code.
here in form subroutine giving i_intpar and i_outpar i just wanted to know should we declare this structure before writing the subroutine,and what would be that structure
just explain this below code in detail,
pls help
Code this form routine in your script.
/: PERFORM GET_PYMT_DUE_IN IN PROGRAM ZSROINVOICE
/: USING &VBDKR-VBELN&
/: USING &VBDKR-FKDAT&
/: USING &VBDKR-ZTERM&
/: CHANGING &PYMNTDUE&
code it in ur driver program to fetch the details.
FORM get_pymt_due TABLES i_intpar STRUCTURE itcsy
i_outpar STRUCTURE itcsy.
DATA : wa_fkdat LIKE sy-datum,
wa_ztag2 LIKE t052-ztag2,
wa_pymnt LIKE sy-datum.
READ TABLE i_intpar WITH KEY name = 'VBDKR-FKDAT'.
IF sy-subrc = 0.
CONCATENATE i_intpar-value6(4) i_intpar-value3(2)
i_intpar-value+0(2)
INTO wa_fkdat.
ENDIF.
READ TABLE i_intpar WITH KEY name = 'VBDKR-ZTERM'.
IF sy-subrc = 0.
Payment Terms
SELECT SINGLE ztag2
INTO wa_ztag2
FROM t052
WHERE zterm = i_intpar-value.
ENDIF.
wa_pymnt = wa_fkdat + wa_ztag2.
MOVE 'PYMNTDUE' TO i_outpar-name.
CONCATENATE wa_pymnt6(2) '.' wa_pymnt4(2) '.' wa_pymnt+0(4) INTO
i_outpar-value.
APPEND i_outpar.
CLEAR i_outpar.
ENDFORM.
pls help
Hi
Hope it will help you.
Pls reward if help.
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.
/: PERFORM
/: 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.
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&
Similar Messages
-
HI,
I AM USING FOLLOWING CODE IN SAP SCRIPT
/: PERFORM SUM IN PROGRAM ZSUM
/: USING ®UD-WRBTR&
/: USING ®UD-WABZG&
/: CHANGING &VAR&
/: ENDPERFORM
AND PROGRAM
FORM SUM USING TABLES IN_PAR STRUCTURE ITCSY
changing OUT_PAR STRUCTURE ITCSY.
READ TABLE IN_PAR WITH KEY NAME = VAR1.
var1_sc = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY NAME = VAR2.
var2_sc = IN_PAR-VALUE.
tot = var1_sc - var2_sc.
READ TABLE OUT_PAR WITH KEY NAME = VAR.
Out_PAR-VALUE = tot.
ENDFORM.
NOW ITS GIVING DUMP TELLING "This routine contains 3 formal para , but the current call contains 4 actual parameters." IF I COMMENT CODE IN FORM.
IF I REMOVE CODE IN FORM THEN IT GIVE SYSTAX ERROR :
& ALSO in_PAR IS NOT INTERNAL TABLE\
PLEASE HELP MEHi
You are using 2 parameters ®UD-WRBTR&
®UD-WABZG& only with perform
see the sample code and do accordingly
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&
Reward points for useful Answers
Regards
Anji
Message was edited by:
Anji Reddy Vangala -
Sap script perform statement.
hi all,
i have a problem with modifying standard sap script form. i have added a field in the line item of my form using perform statement in sap script. but only the corresponding to last line item is getting displayed for all.please help me on this issue my code and sap script is as follows.
**& Form material_wt
-->IN_TAB text
-->OUT_TAB text
FORM MATERIAL_WT TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
DATA : BEGIN OF IT_MAT OCCURS 0,
ZEILE LIKE J_1IEXCDTL-ZEILE,
MENGE LIKE J_1IEXCDTL-MENGE,
MATNR LIKE J_1IEXCDTL-MATNR,
NTGEW TYPE MARA-NTGEW,
END OF IT_MAT.
DATA : V_DOCNO TYPE J_1IEXCDTL-DOCNO,
V_NTWT TYPE CHAR20.
READ TABLE in_tab WITH KEY name = 'J_1IEXCDTL-DOCNO'.
CHECK sy-subrc = c_zero.
V_DOCNO = in_tab-value.
SELECT ZEILE MATNR MENGE INTO CORRESPONDING FIELDS OF TABLE IT_MAT FROM J_1IEXCDTL
WHERE DOCNO = V_DOCNO AND TRNTYP = '57FC'.
LOOP AT IT_MAT.
SELECT SINGLE NTGEW INTO IT_MAT-NTGEW FROM MARA WHERE MATNR = IT_MAT-MATNR.
modify it_mat.
ENDLOOP.
loop at it_mat.
IF not it_mat[] IS INITIAL.
READ TABLE out_tab WITH KEY name = 'NETWT'.
IF sy-subrc = 0.
V_NTWT = IT_MAT-NTGEW * IT_MAT-MENGE.
CONDENSE:V_NTWT.
out_tab-value = V_NTWT.
MODIFY out_tab INDEX sy-tabix.
ENDIF.
ENDIF.
endloop.
endform.
and my perform statement is as follows,
/E ITEM_VALUES
/: PERFORM MATERIAL_WT IN PROGRAM ZMM_RPT_CHALLAN
/: USING &J_1IEXCDTL-DOCNO&
/: CHANGING &NETWT&
/: ENDPERFORM
I1 &J_1IEXCDTL-ZEILE&,,&J_1IEXCDTL-MATNR&,,&NETWT&answered
-
Sap script - Perform returning multiple line items
I am making payment advice layout which is called from the transaction f-58. I do not need to change the standard program, since all information is available in the standard layout, but I need to display line items in the new layout I am preparing!
So to display line items, I have copied the layout and used perform statement and called another se38 prog to retrieve line items.
The following is written in se71-
PERFORM FORM_GET_DATA IN PROGRAM ZFR005_PAYMENT_ADVICE
USING &VV_VBLNR& (this is my header data)
CHANGING &V_XBLNR1&
CHANGING &V_BLDAT1&
CHANGING &V_BELNR1&
This works fine if I just have to retrieve one line item , but to get multiple , I need to declare multiple changing parameter and print it, because perform is called only once.
PERFORM FORM_GET_DATA IN PROGRAM ZFR005_PAYMENT_ADVICE
USING &VV_VBLNR& (this is my header data)
CHANGING &V_XBLNR1&
CHANGING &V_BLDAT1&
CHANGING &V_BELNR1&
CHANGING &V_XBLNR2&
CHANGING &V_BLDAT2&
CHANGING &V_BELNR2&
.................3
.................4
How do I call this perform multiple times so that I do not have to create multiple changing parameters to retrieve line items?Hi,
In the SAPSCRIPT , we can write abap code if the tag column has '/:' command line....
So, any looping operation can be done to retrieve the data.
Pass the item no. also (in the 'USING' part), for which the details are required.
Hope this helps.
Regards,
Renjith -
Calling subroutine from SAP script
I am using the below code within my SAP script form that prints GR/GI Slips but its not working. And the only way I can issue the output is from MB02 whcih doesn't seem to allow to call the debuger, so I'm at a lost as to what to do.
Code in SAP script
/: PERFORM GET_BINS IN PROGRAM ZMM_SAPSCRIPT_FORMS
USING &MSEG-MATNR&
/: USING &MSEG-LGNUM&
/: CHANGING &MABDR-LGPBE&
/: ENDPERFORM
CODE from my subroutine program:
FORM get_bins TABLES input_table STRUCTURE itcsy
output_table STRUCTURE itcsy.
DATA: lc_matnr TYPE matnr,
lc_lgnum TYPE lgnum,
lc_lgpla TYPE lgpla,
lc_index TYPE sy-tabix.
* Material no
READ TABLE input_table WITH KEY name = 'MSEG-MATNR'.
MOVE input_table-value TO lc_matnr.
* Warehouse number
READ TABLE input_table WITH KEY name = 'MSEG-LGNUM'.
MOVE input_table-value TO lc_lgnum.
* Get BIN
SELECT SINGLE lgpla INTO lc_lgpla
FROM mlgt
WHERE matnr = lc_matnr
AND lgnum = 'CPT' "lc_lgnum
AND lgtyp = '001'.
IF sy-subrc = 0.
READ TABLE output_table WITH KEY name = 'MABDR-LGPBE'.
lc_index = sy-tabix.
MOVE lc_lgpla TO output_table-value.
MODIFY output_table INDEX lc_index.
ENDIF./: PERFORM GET_BINS IN PROGRAM ZMM_SAPSCRIPT_FORMS
/: USING &MSEG-MATNR&
/: USING &MSEG-LGNUM&
/: CHANGING &MABDR-LGPBE&
/: ENDPERFORM
FORM get_bins TABLES input_table STRUCTURE itcsy
output_table STRUCTURE itcsy.
DATA: lc_matnr TYPE matnr,
lc_lgnum TYPE lgnum,
lc_lgpla TYPE lgpla,
lc_index TYPE sy-tabix.
Material no
READ TABLE input_table WITH KEY name = 'MSEG-MATNR'.
MOVE input_table-value TO lc_matnr.
Warehouse number
READ TABLE input_table WITH KEY name = 'MSEG-LGNUM'.
MOVE input_table-value TO lc_lgnum.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = lc_matnr
IMPORTING
OUTPUT = lc_matnr .
Get BIN
SELECT SINGLE lgpla INTO lc_lgpla
FROM mlgt
WHERE matnr = lc_matnr
AND lgnum = 'CPT' "lc_lgnum
AND lgtyp = '001'.
IF sy-subrc = 0.
READ TABLE output_table WITH KEY name = 'MABDR-LGPBE'.
lc_index = sy-tabix.
MOVE lc_lgpla TO output_table-value.
MODIFY output_table TRANSPORTING VALUE WHERE NAME = 'MABDR-LGPBE'.
ENDIF. -
Calling different pages in a single sap script based on conditions?
Hi All,
Can anyone please give me an example of how to call different pages in a single sap script based on condition. Eg., i need to call 5 differnet pages from a single sap script based on 5 company codes.
Please help
Regards
PriyaThis approach to make call from SAPscript. Its concept is similar to make call to a subroutine in another program. I would presume you understand how to use USING and CHANGING parameter. =)
SAPscript -
/: Perform get_date in program z_at_date
/: using &p_year&
/: changing &new_date&
/: endperform.
program z_at_date -
form get_date TABLES rec_in STRUCTURE itcsy
rec_out STRUCTURE itcsy..
DATA:
v_year type char10.
sap script and subroutine uses itcsy structure to transmit parameters
first parameter is incoming while second parameter is out going
their function is like an internal table with header line
all data types between SAPscript and subroutine are string.
so, you might need additional conversion.
read incoming parameter with exact name from SAPscript
READ TABLE rec_in WITH KEY name = 'P_YEAR'.
IF sy-subrc EQ 0.
v_year = rec_in-value.
ENDIF.
to return value, use the exact name on the second structure
CONCATENATE v_year v_year INTO v_year.
READ TABLE rec_out WITH KEY name = 'NEW_DATE'.
IF sy-subrc EQ 0.
rec_out-value = v_year.
MODIFY rec_out TRANSPORTING value WHERE name = 'NEW_DATE'.
ENDIF.
endform.
Hope this helps =) -
How 2 debug a Perform subroutine in sap script
Hi,
I have a perform endperform in Script. But tht is not working in some case. i m trying to debug but i m not able to go inside the routine and see wht it is doing? . can any one help me how to debug a subroutine in sap script.Hi Panigrahi,
1) Put a break point in your perform.
2) YOu should change the dispatch option in your Output screen of the transaction which triggers your sap script. The dispatch option should be 1 (Send with a periodically scheduled job).
Then save your transaction.
3) Go to se38 and run the program RSNAST00.
Give the Object Key as the Document Number for which you are triggering the script output.
The control will stop in your perform.
Regards,
Ravi -
How to use perform statements in sap scripts
how to use perform statements in sap scripts . and pls send me one progam for this
thnaks
rajaHi Raja,
<b>PERFORM</b> key work is used to include subroutine in sapscript form...
But the processing is lttle bit different form the one we use in ABAP.
Here the paramters passed to form is stored in internal table of name-value table. there are two table one for inbound parameter and other for outbound parameters.
Check out the example below to see how this is used..
<b>Definition in the SAPscript form:</b>
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
<b>Coding of the calling ABAP program:</b>
REPORT QCJPERFO.
FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA: PAGNUM LIKE SY-TABIX, "page number
NEXTPAGE LIKE SY-TABIX. "number of next page
READ TABLE IN_PAR WITH KEY PAGE.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY NEXTPAGE.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE OUT_PAR WITH KEY BARCODE.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = |. "First page
ELSE.
OUT_PAR-VALUE = ||. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = L. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
Hope this is clear to understand...
Enjoy SAP.
Pankaj Singh. -
How to write a perform in Sap Script
Hi Guys,
Can anyone let me know how to write a perform statement in Sap Script.
Thanks,
RameshI just took this example from SAP Help
=======================================
Syntax in a form window:
/: 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.
The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:
FORM <form> TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
ENDFORM. -
Sap script form perform statement
HI ALL ,
CAN ANYONE HELP ME WITH SAP-SCRIPT FORM AND PERFORM SYNTAX. THAT IS WHEN U NEED TO ADD A FIELD TO AN EXISTING SAPSCRIPT, BY USING AN EXTERNAL SUBROUTINE.
i NEED THE SYNTAX BOTH FOR PERFORM AND ENDPERFORM STATEMENT AND ALSO THE FORM STSEMENT. ANOTHER TRHING IS IF CAN LET ME KNOW HOW TO USE DEFINE STATEMENT IN SAPSCRIPT. WHATS ITS USE AND IS IT RELATED TO THE QUERY ABOVE.
else,
U PLZ LET ME KNOW ANY HELPFUL LINKS TO GO THROUGH.
THANLS IN ADVANCE,
ANUPMA.Hi anupma,
1. while calling subroutines from sapscripts,
there is a special technique,
which has got its own limitations.
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. -
how should i call a perform statement in SAP script
I have been trying to use it in sap script but it is giving me a dump
the code extract looks as follows:
iN DRIVER'S PROGRAM
FORM POP_ADD USING V_parvw like vbpa-parvw.
READ TABLE i_addr WITH KEY WF_PARVW = 'WE'.
ENDFORM.
IN SAP SCRIPT
/: DEFINE &V_PARVW& = &VBPA-PARVW&
/: PERFORM POP_ADD IN PROGRAM ZSD_SCR_INVOICE
/: USING &V_PARVW&
/: ENDPERFORM
/ &i_addr-WF_PARVW&
IT IS GIVING SHORT DUMP SAYING
In a subroutine call, there were more parameters than in the
routine definition.
Error in ABAP application program.
The current ABAP program "ZSD_SCR_INVOICE " had to be terminated because one of
the
statements could not be executed.
This is probably due to an error in the ABAP program.Hi,
The PERFORM in your program should have the following syntax:
FORM POP_ADD TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
READ TABLE in_tab WITH KEY 'V_PARVW'.
CHECK sy-subrc EQ 0.
ENDFORM.
Take a look at http://www.sapfans.com/forums/viewtopic.php?t=131082&highlight=perform for an example of the required syntax.
Hope this helps.
Regards -
My question is that How to add a report into the SAP-SCRIPT .
by using PERFORM ......ENDPERFORM
I don't know how to used it .Hi Sandeep,
Please check this link
http://help.sap.com/saphelp_40b/helpdata/en/d1/803279454211d189710000e8322d00/content.htm
http://www.allinterview.com/showanswers/37425.html
Calling ABAP Subroutines: PERFORM
You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.
PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.
Syntax in a form window:
/: 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.
The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:
FORM <form> TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
ENDFORM.
The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.
The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.
From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (u2018First pageu2019, u2018Next pageu2019, u2018Last pageu2019) is printed as local variable symbol.
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
Coding of the calling ABAP program:
REPORT QCJPERFO.
FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA: PAGNUM LIKE SY-TABIX, "page number
NEXTPAGE LIKE SY-TABIX. "number of next page
READ TABLE IN_PAR WITH KEY u2018PAGEu2019.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY u2018NEXTPAGEu2019.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY u2018BARCODEu2019.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = u2018|u2019. "First page
ELSE.
OUT_PAR-VALUE = u2018||u2019. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = u2018Lu2019. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
Best regards,
raam -
Using Subroutines in SAP script
Hi Experts,
I am trying to get value of Z variables from a subroutine pool program using Perform ... EndPerform in my sap script form.
In my form window i have written
PERFORM ITEM_LINE_2F IN PROGRAM ZMEPRINTFORMS
USING &EKPO-MENGE&
CHANGING &V_EKPO_MENGE&
ENDPERFORM
and in my subroutine pool program i have written:
FORM ITEM_LINE_2F TABLES IN_PAR STRUCTURE ITCSY
out_par structure itcsy.
data : ZLV_ekpo_menge(17),
v_ekpo_menge(17),
ZLV_temp_split_1(14),
ZLV_temp_split_2(3),
ZLV_temp_menge(8) type p.
constants: zc_menge type TDTPRGNAME value 'EKPO-MENGE'.
field-symbols: <tab> type itcsy.
loop at in_par assigning <tab>.
case <tab>-name.
when zc_menge.
zlv_ekpo_menge = <tab>-value.
when others.
endcase.
endloop.
unassign <tab>.
V_EKPO_MENGE = zlv_ekpo_menge.
SPLIT V_EKPO_MENGE AT '.' INTO ZLV_TEMP_SPLIT_1 ZLV_TEMP_SPLIT_2.
IF ZLV_TEMP_SPLIT_2+0(3) = '000'.
ZLV_TEMP_MENGE = zlv_ekpo_menge.
WRITE ZLV_TEMP_MENGE TO V_EKPO_MENGE.
ELSE.
WRITE zlv_ekpo_MENGE TO V_EKPO_MENGE.
ENDIF.
loop at out_par assigning <tab>.
case <tab>-name.
when V_EKPO_MENGE.
<tab>-value = v_ekpo_menge.
when others.
Modify out_par.
endcase.
endloop.
unassign <tab>.hi,
FORM ITEM_LINE_2F TABLES IN_PAR STRUCTURE ITCSY
out_par structure itcsy.
data : ZLV_ekpo_menge(17),
v_ekpo_menge(17),
ZLV_temp_split_1(14),
ZLV_temp_split_2(3),
ZLV_temp_menge(8) type p.
read table in_par index 1.
V_EKPO_MENGE = zlv_ekpo_menge = in_par-value.
SPLIT V_EKPO_MENGE AT '.' INTO ZLV_TEMP_SPLIT_1 ZLV_TEMP_SPLIT_2.
IF ZLV_TEMP_SPLIT_2+0(3) = '000'.
ZLV_TEMP_MENGE = zlv_ekpo_menge.
WRITE ZLV_TEMP_MENGE TO V_EKPO_MENGE.
ELSE.
WRITE zlv_ekpo_MENGE TO V_EKPO_MENGE.
ENDIF.
read table out_par index 1.
out_par-value = v_ekpo_menge.
Modify out_par.
but frankly speaking... i dint understand your logic... finally you are passing the same value ????????
regards
padma -
HOw can we Call Subroutine in Sap Script?
HOw can we Call Subroutine in Sap Script?
Hi
*You have to call sub routine from script like this.
/: PERFORM DATE_FORMAT IN PROGRAM &SY-REPID&
/: USING &RM06P-LFDAT&
/: USING &PEKKO-LFDAT&
/: CHANGING &VALUE_OLD&
/: CHANGING &VALUE_NEW&
/: ENDPERFORM
*In print program write code.
FORM date_format TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
DATA : date TYPE char10.
DATA : date2 TYPE char10.
DATA : l_dmbtr TYPE char10.
READ TABLE in_tab WITH KEY 'RM06P-LFDAT'.
IF sy-subrc = 0.
"Your code goes here
CLEAR l_dmbtr.
ENDIF.
READ TABLE in_tab WITH KEY 'PEKKO-LFDAT'.
IF sy-subrc = 0.
l_dmbtr = in_tab-value.
"Your code goes here
CLEAR l_dmbtr.
ENDIF.
READ TABLE out_tab WITH KEY 'VALUE_NEW'.
IF sy-subrc EQ 0.
out_tab-value = date2.
MODIFY out_tab INDEX sy-tabix.
ENDIF.
READ TABLE out_tab WITH KEY 'VALUE_OLD'.
IF sy-subrc = 0.
out_tab-value = l_dmbtr.
MODIFY out_tab INDEX sy-tabix.
ENDIF.
ENDFORM. "DATE_FORMAT -
Subroutine call from SAP Script
Hi,
I need to calculate required/outstanding qty. hence am passing existing values of reservation#/item# and issued qty.
both req/out qty are returned blank by the code. please help.
Following is my code segment for a external routine call from SAP Script.
/: PERFORM P_GET_QTY IN PROGRAM ZTEST
/: USING &MSEG-RSNUM&
/: USING &MSEG-RSPOS&
/: CHANGING &REQ_QTY&
/: CHANGING &MSEG-MENGE&
/: CHANGING &OUT_QTY&
/: ENDPERFORM
REPORT ztest .
TABLES resb.
DATA: wa_resb TYPE resb,
req_qty TYPE resb-bdmng,
isd_qty TYPE mseg-menge,
out_qty TYPE resb-bdmng.
FORM p_get_qty TABLES input STRUCTURE itcsy
output STRUCTURE itcsy.
DATA: avlbl TYPE resb-bdmng.
READ TABLE input WITH KEY 'MSEG-RSNUM'.
CHECK sy-subrc = 0.
wa_resb-rsnum = input-value.
READ TABLE input WITH KEY 'MSEG-RSPOS'.
CHECK sy-subrc = 0.
wa_resb-rspos = input-value.
READ TABLE input WITH KEY 'REQ_QTY'.
CHECK sy-subrc = 0.
req_qty = input-value.
READ TABLE input WITH KEY 'MSEG-MENGE'.
CHECK sy-subrc = 0.
isd_qty = input-value.
SELECT SINGLE * INTO wa_resb
FROM resb
WHERE rsnum = wa_resb-rsnum
AND rspos = wa_resb-rspos.
CHECK sy-subrc = 0.
avlbl = wa_resb-bdmng - wa_resb-enmng.
req_qty = avlbl - out_qty.
out_qty = req_qty - isd_qty.
output-name = 'REQ_QTY'.
output-value = req_qty.
MODIFY output TRANSPORTING name value WHERE name = 'REQ_QTY'.
APPEND output.
output-name = 'OUT_QTY'.
output-value = out_qty.
MODIFY output TRANSPORTING name value WHERE name = 'OUT_QTY'.
APPEND output.
ENDFORM.
Thanks,
Ram.Hi Ram,
I think you have to use MODIFY instead of append for the OUTPUT table.
MOdify the table with KEY. This should resolve the problem.
Ram, you can check this code and see how the MODIFY is to be used.
REPORT YLSD999A.
DATA W_LENGTH TYPE I.
* GENERAL PURPOSE SUBROUTINES FOR CALLING FROM SAPSCRIPTS
FORM DISPLAY_POUND TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
DATA: COUNT TYPE P VALUE 16.
DATA: W_VALUE(17) TYPE C. "defined as 7 chars to remove pence
DATA: W_CHAR TYPE C.
DATA: W_DUMMY TYPE C.
DATA: W_CURR(3) TYPE C.
* Get first parameter in input table.
READ TABLE IN_TAB INDEX 1.
WRITE IN_TAB-VALUE TO W_VALUE .
* get second parameter in input table
READ TABLE IN_TAB INDEX 2.
MOVE IN_TAB-VALUE TO W_CURR.
IF W_CURR = 'GBP'.
W_CURR = '£'.
ENDIF.
W_LENGTH = STRLEN( W_CURR ).
* look for first space starting at right.
WHILE COUNT > -1.
W_CHAR = W_VALUE+COUNT(1).
* W_CHAR = IN_TAB-VALUE+COUNT(1).
IF W_CHAR = ' '.
COUNT = COUNT - W_LENGTH + 1.
W_VALUE+COUNT(W_LENGTH) = W_CURR.
COUNT = -1.
ELSE.
* W_VALUE+COUNT(1) = W_CHAR.
COUNT = COUNT - 1.
ENDIF.
ENDWHILE.
* read only parameter in output table
READ TABLE OUT_TAB INDEX 1.
OUT_TAB-VALUE = W_VALUE.
MODIFY OUT_TAB INDEX SY-TABIX.
ENDFORM.
Cheers
VJ
Maybe you are looking for
-
Hello, I have to add a hyperlink in Sapscript form. Any idea how do we do it? Regards, Ahmad
-
IOS7 - Weather widget not showing in notification center
Hello everybody. I have just updated to iOS7 and find there is no weather widget. I have read similar postings, and I can confirm I have Privacy settings ON. Also I refreshed iPhone by turning ON & OFF. Still no luck. Any sugestions?? Thanks!!!
-
Hi; I have been made moe to my win2003 32 bit server dbtier to win 2003 64 bit server dbtier on r12.0.4 wiht 10.2.0.2 db version. Now my db is up lsnr up and i can connect from apps tier to database(new db) I followed note:Using Oracle E-Business Sui
-
When I go to e-mail pictures from iPhoto 08 I get the following message (the e-mail is correctly created though), any suggestions on what to fix / look at? Mail got an error: AppleEvent handler failed http://discussions.apple.com/thread.jspa?threadID
-
I know it's been asked time and time again, but I would like to know if anyone knows of any plans to allow non-Windows Server network locations (such as NAS devices, Linux boxes, and storage plugged into supporting routers) to be indexed and used in