‎2011 Jun 03 1:59 AM
Hi ,
I have added two character fields by removing ',' from them.
After adding i want now the ',' back . snippet of code written
ls_num_1 TYPE c LENGTH 32,"P DECIMALS 2,"LENGTH 32,
ls_num_2 TYPE c LENGTH 32,
ls_num_3 TYPE c LENGTH 32,
ls_str_amt TYPE c LENGTH 32,
ls_dec_amt TYPE c LENGTH 32,
ls_str_amt_final TYPE c length 32
.
ls_num_1 = ls_price_form_data-column2.
ls_num_2 = ls_price_form_data-column3.
Remove commas to be able to add the numbers
replace ',' in ls_num_1 with ''.
replace ',' in ls_num_2 with ''.
ls_str_amt = ls_num_1 + ls_num_2.
ls_dec_amt = ls_str_amt.
write ls_dec_amt to ls_str_amt.
Right-justify the string
shift ls_str_amt right deleting trailing space.
ls_price_form_data-column4 = ls_str_amt.
I want to print in smart form by adding ','. Tried to move to type p but did not work.
any suggestions to get back the ',' into numbers.
thanks,
Kamala
‎2011 Jun 06 10:43 AM
erm, this seems very weird to me.
This is not how one would do calculations. If your number after the comma are not 00 then you will mess up the outcome highly by your routine.
Normally calculations are done in number formats, and then when they done, you can move the outcome to some char variable for formatting issues.
If you want to concatenate stuff, then you need char variable. Anyway have a look at the help to the "WRITE TO" statement. this can spare you a lot of coding and variables like it seems.
‎2011 Jun 06 8:12 AM
‎2011 Jun 06 10:15 AM
‎2011 Jun 06 10:26 AM
Can you tell us more about the requirement, i.e. inputs and the desired output?
Are you meaning to work on number with explicit declaration using character type?
‎2011 Jun 06 10:38 AM
Hi,
Declare a variable of type I and move the value to it. Use this variable to display.
‎2011 Jun 06 10:43 AM
erm, this seems very weird to me.
This is not how one would do calculations. If your number after the comma are not 00 then you will mess up the outcome highly by your routine.
Normally calculations are done in number formats, and then when they done, you can move the outcome to some char variable for formatting issues.
If you want to concatenate stuff, then you need char variable. Anyway have a look at the help to the "WRITE TO" statement. this can spare you a lot of coding and variables like it seems.