2007 Apr 07 8:28 AM
i've written a perform statement in sapscript to calculate:
1.) substraction of two amount values .
But in the perform statement the amount is in format 20.000,00 (for 20 thousand)
and hence it doesnot allow me to substract the two amounts and gives a dump stating not a number.
please tell me how can i convert the amount, substract the values and again send it back to sapscript for display.
also how can i print the sl. No. (Serial Number) which should get incremented everytime the line items r printed.
i can't change the program as it is standard so i've to do it through the sapscript only.
please help.
2007 Apr 07 8:31 AM
Hi,
Do all the computation in the Zprogram you have associated to your script using Perform statement.
Convert characters to packed values using Unpack and Pack statements.
Use this sample code for reference
data: v_char1(13) type c value '1.613,000',
v_char2(13) type c value '8.240,000'.
data: v_res type p decimals 0,
v_flag1 type p decimals 0,
v_flag2 type p decimals 0.
translate v_char1 using '. '.
translate v_char1 using ',.'.
condense v_char1 no-gaps.
translate v_char2 using '. '.
translate v_char2 using ',.'.
condense v_char2 no-gaps.
pack v_char1 to v_flag1.
pack v_char2 to v_flag2.
v_res = v_char1 + v_char2.
write v_res. "This contains packed value
You can unpack the packed value to character format again.
Regards,
Sailaja.
Message was edited by:
Sailaja N.L.
Hi,
Do all the computation in the Zprogram you have associated to your script using Perform statement.
Convert characters to packed values using Unpack and Pack statements.
Use this sample code for reference
data: v_char1(13) type c value '1.613,000',
v_char2(13) type c value '8.240,000'.
data: v_res type p decimals 0,
v_flag1 type p decimals 0,
v_flag2 type p decimals 0.
translate v_char1 using '. '.
translate v_char1 using ',.'.
condense v_char1 no-gaps.
translate v_char2 using '. '.
translate v_char2 using ',.'.
condense v_char2 no-gaps.
pack v_char1 to v_flag1.
pack v_char2 to v_flag2.
v_res = v_char1 + v_char2.
write v_res. "This contains packed value
You can unpack the packed value to character format again.
Regards,
Sailaja.
Message was edited by:
Sailaja N.L.
2007 Apr 07 8:31 AM
Hi,
Do all the computation in the Zprogram you have associated to your script using Perform statement.
Convert characters to packed values using Unpack and Pack statements.
Use this sample code for reference
data: v_char1(13) type c value '1.613,000',
v_char2(13) type c value '8.240,000'.
data: v_res type p decimals 0,
v_flag1 type p decimals 0,
v_flag2 type p decimals 0.
translate v_char1 using '. '.
translate v_char1 using ',.'.
condense v_char1 no-gaps.
translate v_char2 using '. '.
translate v_char2 using ',.'.
condense v_char2 no-gaps.
pack v_char1 to v_flag1.
pack v_char2 to v_flag2.
v_res = v_char1 + v_char2.
write v_res. "This contains packed value
You can unpack the packed value to character format again.
Regards,
Sailaja.
Message was edited by:
Sailaja N.L.
2007 Apr 07 8:38 AM
i have one doubt that is print format it is not at all related to processing
please give ur script here i can solve ur problem
send ur subroutine code.
i hope that u are not converting it into integer format .
if u send any thing to perform it come in to character format.
you move in to integer format and do calculations and sent to script.
Message was edited by:
sunil kumar
2007 Apr 07 9:40 AM
my code in sapscript is :
/: DEFINE &V1& = ®UP-WRBTR&
/: DEFINE &V2& = ®UP-WSKTO&
/: DEFINE &V3& = ''
/: PERFORM GET_DEDUCTION_VAL IN PROGRAM ZT_CHK
/: USING &V1&
/: USING &V2&
/: CHANGING &V3&
/: ENDPERFORM.
and the code that i've written in program zt_chk is:
Tables: REGUP.
FORM get_deduction_val TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
DATA : w_amt1 LIKE REGUP-WRBTR,
w_amt2 LIKE REGUP-WSKTO,
w_total LIKE REGUP-DMBTR.
READ TABLE in_tab WITH KEY 'V1'.
w_amt1 = in_tab-value.
READ TABLE in_tab WITH KEY 'V2'.
w_amt2 = in_tab-value.
w_total = w_amt1 - w_amt2. " -
>Gives Dump Here
READ TABLE out_tab WITH KEY 'V3'.
out_tab-value = w_amt1.
MODIFY out_tab INDEX sy-tabix.
ENDFORM.
Also i wld like to know how to print serial Number? is it possible through this perform. this perform gets called in loop and the next statement in sapscript prints the values.
2007 Apr 07 9:43 AM
2007 Apr 07 10:12 AM
Hi Annie,
Change your User profile settings and see....
From any screen in SAP...
Click on Menu System->User Profile->Own Data, In that go to tab Own Data and change the decimal notation and save.
Now execute your script and see.
Correct me if I am wrong.
Regards,
Ramesh S
*Award points if reply is helpful
2007 Apr 07 3:18 PM
Hello,
May be this might solve your problem. Move the variables in which you have the amounts to be computed to new variables declared as type compatible to amounts (i.e. BSEG-WRBTR o VBAP-NETWR). You have to use the 'MOVE' command with the extension 'Currency' i guess. This will automatically change the decimal notations of the amount variables in compatible to that of User settings. Then you can compute the values as you required and can use the same to display in the form / Script.
In this way you will not have to change the user settings all the time.
Hope this solves your issue.
Thanks and Regards,
Pavan
2007 Apr 09 6:18 AM
i've tried all your suggestion but it doesnot work and every time a dump comes. in my user setting already the format 1,234,567.89 is maintained.
And i didn't find any move command with currency extension
please help.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |