2007 Sep 11 9:47 AM
hello,
we have over 50k materials with starting of "K" and "M".
now i want to put some condition with all materials which is starting with "k".
so when i put this condition with if mara-matnr = 'K*'.
it gives the error.
how can i put this condition with if condition.
regards amit.
2007 Sep 11 9:54 AM
Hi Amit,
you can use this condition in the select query but not in the IF condition...
Proceed like this: -
select all the materials starts from K ...
SELECT ...
FROM
INTO ITAB
WHERE matnr LIKE 'k%'.
This will select all materials starts with k inyour internal table ITAB.
Now process your logic on itab...for k materials.
Simillary do the same for M Materials....
Reward points for helpful answers.
Regards,
Hari krsihna
retrieve all the materials into one internal table...
after that loop on that internal table and check the condition as per following.
here is a sample report...
REPORT ZNA_TEMP.
data: it_mara type table of mara,
wa_mara like line of it_mara.
data: a type c.
select * from mara into table it_mara up to 100 rows.
loop at it_mara into wa_mara.
a = wa_mara-matnr(+1). " this checks the first character of the variable.
if wa_mara-matnr(1) <> 'M' or wa_mara-matnr(1) <> 'K'.
delete it_mara index sy-tabix.
endif.
endloop.
2007 Sep 11 9:48 AM
2007 Sep 11 10:01 AM
well,
if our material ends with "K" or "O"
then how can i put it into if condition like that....
if mara-matnr = '%K' will it works..
2007 Sep 11 9:49 AM
2007 Sep 11 9:54 AM
Hi Amit,
you can use this condition in the select query but not in the IF condition...
Proceed like this: -
select all the materials starts from K ...
SELECT ...
FROM
INTO ITAB
WHERE matnr LIKE 'k%'.
This will select all materials starts with k inyour internal table ITAB.
Now process your logic on itab...for k materials.
Simillary do the same for M Materials....
Reward points for helpful answers.
Regards,
Hari krsihna
2007 Sep 11 9:57 AM
retrieve all the materials into one internal table...
after that loop on that internal table and check the condition as per following.
here is a sample report...
REPORT ZNA_TEMP.
data: it_mara type table of mara,
wa_mara like line of it_mara.
data: a type c.
select * from mara into table it_mara up to 100 rows.
loop at it_mara into wa_mara.
a = wa_mara-matnr(+1). " this checks the first character of the variable.
if wa_mara-matnr(1) <> 'M' or wa_mara-matnr(1) <> 'K'.
delete it_mara index sy-tabix.
endif.
endloop.
2007 Sep 11 10:00 AM
hi,
select the materials starting with K using the statement...
<b>select * from mara into table itab where matnr like'K%'.</b>
u can use the internal table itab for futher operation..
hope it helps..
Regards,
Viji
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |