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

string on number

Former Member
0 Likes
890

hi all

I have internal table lt_mara

some material number begin with X

eg.

34532

X5435

45355

53

X46534

X532

how to isolate materijals vith X.

8 REPLIES 8
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
852

Hello,

If you are open to using LOOP on LT_MARA, then i can propose.


  LOOP AT IT_MARA WHERE MATNR+0(1) = 'X'.
    DELETE IT_MARA.
  ENDLOOP.

BR,

Suhas

BTW the field MATNR is not numneric, it is of type CHAR length 18. So what is your issue?

Read only

Former Member
0 Likes
852

no runtime error

Unable to interpret "X" as a number.

Read only

Former Member
0 Likes
852

Hi Suhas,

Can we use the following instead of looping.

DELETE IT_MARA WHERE MATNR+0(1) = 'X'.

Regards,

nilesh.

Read only

Former Member
0 Likes
852

here is solution

loop at t2 where matnr cp 'X*'.

write : t2.

endloop.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
852

Hello Nick,

We need to have a look @ the structure of LT_MARA, you must have declared MATNR as numeric;-)

That's what i have added in my PS. Is there any reason of declaring MATNR as numeric, can you switch the declaration to

TYPE MATNR

@ Nilesh: I was thinking about the same & checked

DELETE IT_MARA[] WHERE MATNR+0(1) = 'X'.

works

BR,

Suhas

Read only

Former Member
0 Likes
852

TYPES :

begin of ty_matnr,

matnr type matnr,

end of ty_matnr.

data : i_tab type STANDARD TABLE OF ty_matnr,

wa_tab type ty_matnr.

data : r_range type RANGE OF matnr,

wa_range like line of r_range.

wa_tab-matnr = '3453562'.

append wa_tab to i_tab.

wa_tab-matnr = 'X36732'.

append wa_tab to i_tab.

wa_tab-matnr = '34532'.

append wa_tab to i_tab.

wa_tab-matnr = 'X34532546'.

append wa_tab to i_tab.

wa_tab-matnr = '3453256'.

append wa_tab to i_tab.

wa_tab-matnr = '34535462'.

append wa_tab to i_tab.

wa_range-sign = 'I'.

wa_range-option = 'CP'.

wa_range-low = 'X*'.

append wa_range to r_range.

loop at i_tab into wa_tab where matnr in r_range.

write : / wa_tab-matnr.

endloop.

Read only

Former Member
0 Likes
852

solved

Read only

Former Member
0 Likes
852

Let me see if I understand:

You have a character field. Some values are entirely numeric and some start with 'X'. You don't know how to find the ones that start with 'X'.

Is that correct?

Rob