‎2008 Mar 12 10:49 AM
Please answer my quest
in subroutine inside script all the variables are in char format.
Suppose passed values are of amount.
I want to make total of it in (se38) program, so i need to convert it from character to numeric or integer.
Explain me how datatype can be converted from char to I or P.
Thanking you
Gargi.
Edited by: GARGI PARIKH on Mar 12, 2008 11:51 AM
‎2008 Mar 12 11:04 AM
Hi,
try it
1. To remove all camms(,)
REPLACE ALL OCCURRENCES OF ',' IN <variable1> WITH ''.
2. Conver to number(internal convertion)
<number _variable> = <variable1>
L.Velu
‎2008 Mar 13 9:38 AM
hi,
thank you for answering.
which comma are you talkng about and what '< --- >' stands for?
Edited by: GARGI PARIKH on Mar 18, 2008 7:12 PM
Edited by: GARGI PARIKH on Mar 18, 2008 7:14 PM
‎2008 Mar 19 1:59 AM
I think you'll just need something like this (not syntax checked):
form do_count
tables
it_data structure itcsy
ot_data structure itcsy.
data:
ls_itcsy like itcsy,
l_total type i,
l_count type i.
read table it_data into ls_data
with key name = 'MY_COUNT'. "or whatever
if sy-subrc is initial.
l_count = ls_data-value. "will convert Char to I
add l_count to l_total.
endif.
"etc
endform.
but to make it more robust (i.e. in case the SAPScript calls it with a non-numeric) you might like to wrap a "try" or "catch" around the assignment from the character to the number as in:
http://help.sap.com/saphelp_nw70/helpdata/en/a9/b8eef8fe9411d4b2ee0050dadfb92b/frameset.htm
Jonathan