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

converting quantity field to integer and then to string

Former Member
0 Likes
7,191

Hi All,

I have a quantity field which displays blanks values as 0.000.The requirement was to change it to 0 ad

So I had assigned this quantity field to  an integer variable and it worked.

Now I have to change this 0 to blank , but assigning to a string variable doesn't work.

Is there any better way of doing this as I find this method very crude.

Regards,

Faiz


Hi All,

I have a quantity field which displays blanks values as 0.000.The requirement was to change it to 0 ad

So I had assigned this quantity field to  an integer variable and it worked.

Now I have to change this 0 to blank , but assigning to a string variable doesn't work.

Is there any better way of doing this as I find this method very crude.

Regards,

Faiz


3 REPLIES 3
Read only

Former Member
0 Likes
2,802

take a look at this

data:
  lv_string(20),
  lv_quan type dzmeng value '0.000'.

write lv_quan to lv_string no-zero.

Read only

adrian_mejido
Contributor
0 Likes
2,802

Hi Faizur,

If you want to have a empty string if the value is '0.000', you can try this:

if    l_quan IS NOT INITIAL. 

     l_string = l_quan.

ENDIF.

If you want to pass the quantity without decimals, you can do a TRUNC.

if    l_quan IS NOT INITIAL.

     l_string = trunc(l_quan).

ENDIF.

Best regards

Read only

Former Member
0 Likes
2,802

Hi,

TYPES : BEGIN OF GI_DATA1,

                VBELN TYPE VBAK-VBELN, " SO No.

                NTGEW TYPE VBAP-NTGEW, " Net Weight of the Item

                GEWEI TYPE VBAP-GEWEI, " Weight Unit

             END OF GI_DATA1.

DATA :  IT_DATA1 TYPE STANDARD TABLE OF GI_DATA1 WITH HEADER LINE,

            V_VALUE TYPE CHAR15,

WRITE IT_DATA1-NTGEW UNIT IT_DATA1-GEWEI to V_VALUE.

CONDENSE V_VALUE.

Reference Link :

Special Output Formats (SAP Library - ABAP Programming (BC-ABA))

Regards,

Kemal Tsani N