Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

adding type c fields

kp_25
Participant
0 Likes
770

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
733

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.

5 REPLIES 5
Read only

Former Member
0 Likes
733

Is this a workflow question?

Read only

matt
Active Contributor
0 Likes
733

Moved to ABAP forum

Read only

Former Member
0 Likes
733

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?

Read only

Former Member
0 Likes
733

Hi,

Declare a variable of type I and move the value to it. Use this variable to display.

Read only

Former Member
0 Likes
734

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.