2014 Dec 09 10:05 AM
Hi,
In my requirement am having material in one internal table.
itab1[] = 123456..
in another select am passing the itab1 material with *...(123456*)
because in z-table material first stage only there..
while [assing z-table value to mseg means it display all material stages, like 123456-ab
123456-po 123456-iy etc...
so in my code..
IF IT_QTY[] IS NOT INITIAL.
LOOP AT IT_QTY WHERE WERKS IN SO_PLANT.
SO_MAT-OPTION = 'BT'.
SO_MAT-SIGN = 'I'.
SO_MAT-LOW = IT_QTY-MATNR.
SO_MAT-HIGH = IT_QTY-MATNR.
CONCATENATE IT_QTY-MATNR '*' INTO SO_MAT-LOW.
CONCATENATE IT_QTY-MATNR '*' INTO SO_MAT-HIGH.
APPEND SO_MAT.
endloop.
endif.
IF IT_QTY[] IS NOT INITIAL.
LOOP AT IT_QTY WHERE WERKS IN SO_PLANT.
N = N + 1.
READ TABLE so_mat INDEX N.
SELECT MBLNR MJAHR ZEILE BWART MATNR WERKS MENGE FROM MSEG INTO CORRESPONDING FIELDS OF TABLE IT_MSQTY
WHERE MATNR eq SO_MAT-low AND
WERKS in so_plant AND
BWART IN (551,552,521,553,522).
so_mat-low = 123456*.
but it is not fetching value from table.Any one give idea???
2014 Dec 09 10:08 AM
2014 Dec 09 10:15 AM
Hi Anitha,
SO_MAT is an internal with header line so instead of using read table S_MAT, use matnr in S_MAT in select statement where condition. and no need to write the select statement inside the loop.
write the statement like below.
SELECT MBLNR MJAHR ZEILE BWART MATNR WERKS MENGE FROM MSEG INTO CORRESPONDING FIELDS OF TABLE IT_MSQTY
WHERE MATNR in SO_MAT AND
WERKS in so_plant AND
BWART IN (551,552,521,553,522).
Thanks,
Sree
2014 Dec 09 11:13 AM
2014 Dec 09 10:26 AM
In ABAP the wild card is % and not *
You will need to replace the * with % like e.g.
REPLACE FIRST OCCURRENCE OF '*' IN SO_MAT-LOW WITH '%'.
Maybe yo also have to keep the leading zeroes in mind. In that case an extra statement is necessary like:
CONCATENATE '%' SO_MAT-LOW INTO SO_MAT-LOW.
For more info check the ABAP help on LIKE (in the context of WHERE)
2014 Dec 09 11:16 AM
IF IT_QTY[] IS NOT INITIAL.
LOOP AT IT_QTY WHERE WERKS IN SO_PLANT.
SO_MAT-OPTION = 'CP'. <<<< Contains Pattern
SO_MAT-SIGN = 'I'.
SO_MAT-LOW = IT_QTY-MATNR.
SO_MAT-HIGH = IT_QTY-MATNR.
CONCATENATE IT_QTY-MATNR '*' INTO SO_MAT-LOW.
CONCATENATE IT_QTY-MATNR '*' INTO SO_MAT-HIGH.
APPEND SO_MAT.
endloop.
endif.
IF IT_QTY[] IS NOT INITIAL.
LOOP AT IT_QTY WHERE WERKS IN SO_PLANT.
N = N + 1.
READ TABLE so_mat INDEX N.
SELECT MBLNR MJAHR ZEILE BWART MATNR WERKS MENGE FROM MSEG INTO CORRESPONDING FIELDS OF TABLE IT_MSQTY
WHERE MATNR IN SO_MAT
AND WERKS in so_plant
AND BWART IN (551,552,521,553,522).
2014 Dec 09 11:32 AM
2014 Dec 09 11:55 AM
the select option really should be fine with
SIGN = I
OPTION = BT
LOW = mat1*
HIGH = mat2*
% is normally used with the LIKE operator - wildcard of * is fine with select option
is the mat number requiring any leading zero too?
2014 Dec 09 11:59 AM
SELECT MBLNR MJAHR ZEILE BWART MATNR WERKS MENGE FROM MSEG INTOCORRESPONDING FIELDS OF TABLE IT_MSQTY
WHERE MATNR LIKE SO_MAT
AND WERKS in so_plant
AND BWART IN (551,552,521,553,522). also not working
2014 Dec 09 12:11 PM
Won't work. You need to say so_matnr-LOW LIKE........ Please do as I said before (And Anoop).
Maybe I understood you wrong, because the requirement is not really clear to me, but you cannot use * as a wild card in ABAP code. You can use it in the selection screen fields.
So if you have select-options SO_Matnr for wa_mara-matnr, the user can fill in value 123456* and SAP will translate this to the correct select statement when you use:
select * from mara where matnr in so_matnr. (As Steve already explained in his post)
So why can you not do it like that ? Can you explain, maybe I then will understand what you really want/need to do.
2014 Dec 09 12:22 PM
yeah thanx..Now its working perfectly...
in select before i pass like so_mat only..not so_mat-low..
now its working
2014 Dec 09 11:22 AM
2014 Dec 09 12:22 PM
Hi,
Useappend '%" instead of '*' and do change the coding as below.
Try with Matnr according to your statement.
types : begin of ty,
pernr type pa0000-pernr,
end of ty.
data itab type standard table of ty.
data wa type ty.
data lv_pernr(8) type c.
lv_pernr = '000000%'.
select pernr from pa0000 into table itab where pernr like lv_pernr.
loop at itab into wa.
write 😕 wa-pernr.
endloop.
2014 Dec 09 12:40 PM
If you have fixed length of material no then use
WHERE MATNR eq SO_MAT-low(6)
2014 Dec 09 12:41 PM
Replace
so_mat-sign = 'I'.
so_mat-option = 'BT'.
so_mat-low = it_qty-matnr.
so_mat-high = it_qty-matnr.
CONCATENATE it_qty-matnr '*' INTO so_mat-low.
CONCATENATE it_qty-matnr '*' INTO so_mat-high.with
so_mat-sign = 'I'.
so_mat-option = 'CP'.
CONCATENATE it_qty-matnr '*' INTO so_mat-low.Now use a IN operator in your WHERE clause.
Regards,
Raymond