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

Formatting and data type problem...

Former Member
0 Likes
822

Hi,

I have a small code line as follows:

Data: w_qty type int4.

w_qty = EKET-MENGE.

Now w_qty has many leading spaces, so if I use

shift w_qty left deleting leading spaces.

It gives error that w_qty should be C,N or string type.

But If I define w_qty as Char5 or something, then if the value of EKET-MENGE is 5000, it does not convert automatically to 5,000 but if it is an int4 then it converts itself automatically to 5,000.

Hence I want to delete the leading spaces as well as I want to have it format getting converted to comma format as defined in user profile in system...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
785

hi Tushar,

Do this way

Data: w_qty type i,
       w_final type i.

w_qty = EKET-MENGE.

w_final = w_qty.

Write : w_final.

you get the values in the required format now

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
785

Make the w_qty field a type c field and write the value.

data: w_qty(15) type c.


write eket-menge to w_qty decimals 0.
shift w_qty left deleting leading space.


check sy-subrc = 0.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
786

hi Tushar,

Do this way

Data: w_qty type i,
       w_final type i.

w_qty = EKET-MENGE.

w_final = w_qty.

Write : w_final.

you get the values in the required format now

Read only

0 Likes
785

But I am wondering that this may not solve problem because if I define it as type C then at the time of outputting on form it will not convert itself to comma format I mean 5,000 or 10,000.

It only does it when its not type C...

Read only

0 Likes
785

hi Tushar,

Did you try the above method as i have specified in my previous post????.....

Read only

0 Likes
785

If it is type c, then it will show whatever is in the field. Since in my example, I am using the WRITE statement, it is formatting with a comma, as the thousands separator(via user specific setting). If my user settings was to have '.' as the separator, it will write that as well. You form will show the separator as you need it to.

Regards,

Rich Heilman

Read only

0 Likes
785

Ya but it won't remove leading spaces if I define as type i.

Read only

0 Likes
785

If you use the code here, it will work.




data: w_qty(15) type c.
 
 
write eket-menge to w_qty decimals 0.
shift w_qty left deleting leading space.
 

REgards,

Rich Heilman