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

Remove commas/dots from comp_qty

Former Member
0 Likes
626

Hello Folks,

I know this question has been asked many times, but i could not find my answer anywhere.

Iam using BAPI 'CSAP_MAT_BOM_READ' which returns the field COMP_QTY in table T_STPO.

When this field greter than or equal to 1000, it contains a comma in it like 1,000.

And later when i use this field for my calculcations, it gives me an error (dump)saying unable to interpret this as a number.

I know this is because this number contains the comma in it.

All the solutions i found so far is to replace the commas with space and condense it.

But what if the user has the different decimal notation settings. All the decimals will be displayed as commas.

And that time replacing the commas with space doenst work.

For eq: 1000.33 will be displayed as 1000,33

And replacing the commas with space becomes 100033.

Please let me know if there is any other way in sap we can handle this with.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
530

Nevermind,

table USR01 got the user settings.

and i used following logic

        CASE USR01-DCPFM.
          WHEN ''.
            REPLACE ALL OCCURRENCES OF '.' IN WA_STPO-COMP_QTY WITH ' '.
            REPLACE ALL OCCURRENCES OF ',' IN WA_STPO-COMP_QTY WITH '.'.
          WHEN 'X'.
            REPLACE ALL OCCURRENCES OF ',' IN WA_STPO-COMP_QTY WITH ' '.
          WHEN 'Y'.
            REPLACE ALL OCCURRENCES OF ',' IN WA_STPO-COMP_QTY WITH '.'.
        ENDCASE.

Nevermind,

table USR01 got the user settings.

and i used following logic

        CASE USR01-DCPFM.
          WHEN ''.
            REPLACE ALL OCCURRENCES OF '.' IN WA_STPO-COMP_QTY WITH ' '.
            REPLACE ALL OCCURRENCES OF ',' IN WA_STPO-COMP_QTY WITH '.'.
          WHEN 'X'.
            REPLACE ALL OCCURRENCES OF ',' IN WA_STPO-COMP_QTY WITH ' '.
          WHEN 'Y'.
            REPLACE ALL OCCURRENCES OF ',' IN WA_STPO-COMP_QTY WITH '.'.
        ENDCASE.

1 REPLY 1
Read only

Former Member
0 Likes
531

Nevermind,

table USR01 got the user settings.

and i used following logic

        CASE USR01-DCPFM.
          WHEN ''.
            REPLACE ALL OCCURRENCES OF '.' IN WA_STPO-COMP_QTY WITH ' '.
            REPLACE ALL OCCURRENCES OF ',' IN WA_STPO-COMP_QTY WITH '.'.
          WHEN 'X'.
            REPLACE ALL OCCURRENCES OF ',' IN WA_STPO-COMP_QTY WITH ' '.
          WHEN 'Y'.
            REPLACE ALL OCCURRENCES OF ',' IN WA_STPO-COMP_QTY WITH '.'.
        ENDCASE.