‎2009 Jun 08 9:56 AM
Hello,
I am calling a subrouting from SAP SCRIPT.
But in the subroutine I am not able to change the currecy value to integer.
FORM cal_Tot tables ntwr structure itcsy
tot structure itcsy.
DATA value type vbap-netwr.
value = ntwr-value.
ENDFORM.
If the value of ntwr-value is 300.0 its working but
if the value of ntwr-value is 1,345.0 this is giving runtime error.
How can store 1,345 into variable value
‎2009 Jun 08 10:09 AM
MOVE_CHAR_TO_NUM
use this FM to convert char to num.... this works
data : xyz type itcsy-value,
value type vbap-netwr.
xyz = '1,345.0'.
CALL FUNCTION 'MOVE_CHAR_TO_NUM'
EXPORTING
chr = xyz
IMPORTING
NUM = value
EXCEPTIONS
CONVT_NO_NUMBER = 1
CONVT_OVERFLOW = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE : xyz , ' = ' , value.Edited by: soumya prakash mishra on Jun 8, 2009 11:10 AM
‎2009 Jun 08 10:20 AM
Hi soumya,
I tried your code but the variable value is remaining 0. I mean there is no change in the output variable and in import i m passing xyz-value not xyz.
‎2009 Jun 08 10:21 AM
check what type i have declared for xyz.... xyz type itcsy-value
so u change as u need..
‎2009 Jun 08 10:24 AM
Sorry soumya,
This is my code can please tell why i m not getting the value in the variable value
FORM CAL_TOT TABLES NTWR STRUCTURE ITCSY
TOT STRUCTURE ITCSY.
DATA: value type VBAP-NETWR value '0'.
statics value1 type VBAP-NETWR.
Read table ntwr index 1.
CALL FUNCTION 'MOVE_CHAR_TO_NUM'
EXPORTING
chr = NTWR-VALUE
IMPORTING
NUM = value.
value1 = value1 + value.
Read table tot index 1.
tot-value = value.
modify tot index 1.
ENDFORM.
‎2009 Jun 08 10:14 AM
Hi ,
Chk this one
report zcurr.
data: input type bapicurr-bapicurr .
data: c(20) type c.
data: output(15) type p decimals 2.
c = '12,345.78'.
clear sy-subrc.
while sy-subrc = 0.
replace ',' with space into c.
endwhile.
condense c no-gaps.
input = c.
call function 'BAPI_CURRENCY_CONV_TO_INTERNAL'
exporting
currency = 'INR'
amount_external = input
max_number_of_digits = 25
importing
amount_internal = output
RETURN =
‎2009 Jun 08 10:25 AM
Hi Shah,
Try this way,
replace ',' WITH ' ' INTO v_menge.
CONDENSE V_MENGE NO-GAPS.
‎2009 Jun 08 10:27 AM
code seems ok.. can u please debug and check what values are u fetching in what point...!!!
‎2009 Jun 08 10:36 AM
Thanks Suresh,
Now I am able to add the values but how to again convert into the earlier format as I have to return the value so I have to store in the variable tot-value
‎2009 Jun 08 12:41 PM
Hi Shah,
if you want the original value just keep that in some other variable so that the value don't change you can use it for later purpose.
generally the value with , will store in the database tables you can also fetch from there.
‎2009 Jun 08 10:28 AM
Use this class to change from any type to char
CL_ABAP_CONTAINER_UTILITIES=>FILL_CONTAINER_C
use this class to pass type c to any type
CL_ABAP_CONTAINER_UTILITIES=>READ_CONTAINER_C