2006 Sep 14 7:57 PM
Hi: Im really fighting with sapscripts. I dont know if its possible to make arithmetic operations inside a sapscript. I've tried with the next sintaxis:
/: DEFINE &var1& = &var2& + &var3&.
and it says thas + is too long.
First of all Is possible to make arithmetic operactions in SAPSCRIPTS??????
If it's posssible, can u show me some sintaxis, cause don't find any documentation about.
Thanks
2006 Sep 14 8:22 PM
Hi,
You can send several parameters form sapscript like in a report program:
DEFINE &VSERNR(I77)& TYPE C
/: DEFINE &VSERNR2(I77)& TYPE C
/: PERFORM TOMARSERIES IN PROGRAM ZENS
/: USING &MKPF-MBLNR&
/: USING &MKPF-MJAHR&
/: USING &MSEG-MATNR&
/: USING &MSEG-ZEILE&
/: CHANGING &VSERNR&
/: CHANGING &VSERNR2&
/: ENDPERFORM
regards,
Alejandro.
2006 Sep 14 8:00 PM
Hello,
You cannot do any arithmetic operations like adding,subtracting etc in SAP scripts.You need to do that in the print program and pass the variable into the Sapscript.
Thanks,
Kalyan
2006 Sep 14 8:02 PM
Hi,
you can create an Include program an define a Form into it. Then from sapscript invoke this form to make the atithmetic operations and return the value to sapscript.
regards,
Alejandro
2006 Sep 14 8:02 PM
Hi Hund,
You cant perform arithmetic operations directly in sapscripts.
You need to perform that operations in Driver program ang get the resultant values into script. (or)
Call a subroutine from your sap script by passing parameters and define the form in driver program.
Thanks,
Vinay
2006 Sep 14 8:09 PM
Thaks to all..now my problem is..
I have this sintaxis inside de SAPSCRIPT
PERFORM MODIFY IN PROGRAM ZMOD_PREC
USING &EKPO-MWSKZ& &EKPO-NETWR&
CHANGING &W_TEMP&
the program in my form starts like this:
FORM X TABLES p_input STRUCTURE ITCSY
p_input1 STRUCTURE ITCSY.
p_output STRUCTURE ITCSY.
when I execute the smartforms show me a dump that says:
the program expected 6 parameters and you have 4.
Any idea what it's wrong at my sintaxis??
2006 Sep 14 8:24 PM
Hi Hund,
1)The routines in scripts needs only two parameters but you are using three in your FORM statement.
2)The form defintion should be like this
<b>FORM X TABLES p_input STRUCTURE ITCSY
p_output STRUCTURE ITCSY.</b>
instead of
FORM X TABLES p_input STRUCTURE ITCSY
p_input1 STRUCTURE ITCSY
p_output STRUCTURE ITCSY.
3) All your USING parameters will be in P_INPUT structure and CHANGING parameters will be in P_OUTPUT structure
Note: Plz reward all helpful answers..
Thanks,
Vinay
2006 Sep 14 8:15 PM
/: PERFORM GET_VALUE IN PROGRAM ZPROG
/: USING &V_VAR1&
/: CHANGING &V_VAR2&
/: ENDPERFORM
Coding of the calling ABAP program:
REPORT ZPROG.
FORM GET_VALUE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
data: l_field type i,
l_field2 type i.
*-- if the date is in MM/DD/YYYY format
READ TABLE IN_PAR WITH KEY MHNK-AUSDT.
IF SY-SUBRC = 0.
l_field = IN_PAR-VALUE.
ENDIF.
l_field2 = l_field + l_field2.
READ TABLE OUT_PAR WITH KEY V_VAR2.
IF SY-SUBRC = 0.
OUT_PAR-VALUE = l_field2.
ENDIF.
ENDIF.
2006 Sep 14 8:17 PM
2006 Sep 14 8:27 PM
you can any number of parameters in perform statement.
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
......
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
......
/: ENDPERFORM
Coding of the calling ABAP program:
you need to
READ TABLE IN_PAR WITH KEY INVAR1.
to get the first passed value
READ TABLE IN_PAR WITH KEY INVAR2.
to get the first passed value
similarly to pass the value to the out table
READ TABLE OUT_PAR WITH KEY OUTVAR1.
to get the first passed value
READ TABLE OUT_PAR WITH KEY OUTVAR2.
to get the first passed value
and we need to modify the OUT_PAR table.
2006 Sep 14 8:22 PM
Hi,
You can send several parameters form sapscript like in a report program:
DEFINE &VSERNR(I77)& TYPE C
/: DEFINE &VSERNR2(I77)& TYPE C
/: PERFORM TOMARSERIES IN PROGRAM ZENS
/: USING &MKPF-MBLNR&
/: USING &MKPF-MJAHR&
/: USING &MSEG-MATNR&
/: USING &MSEG-ZEILE&
/: CHANGING &VSERNR&
/: CHANGING &VSERNR2&
/: ENDPERFORM
regards,
Alejandro.