Application Development 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: 

Concatenate statement -issue

former_member225134
Participant
0 Kudos

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???

14 REPLIES 14

Former Member
0 Kudos

try

matnr IN so_mat

Former Member
0 Kudos

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

0 Kudos

Still it is not working

PeterJonker
Active Contributor
0 Kudos

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)

mayur_priyan
Active Participant
0 Kudos

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).

0 Kudos

YEAH..i tried in your way..but no result

0 Kudos

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?

0 Kudos

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

0 Kudos

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.

0 Kudos

yeah thanx..Now its working perfectly...

in select before i pass like so_mat only..not so_mat-low..

now its working

AnoopMayamkote
Participant
0 Kudos

REPLACE ALL OCCURRENCES OF '*' IN SO_MAT-LOW WITH '%'.

jayanthi_jayaraman
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

If you have fixed length of material no then use

WHERE MATNR eq SO_MAT-low(6)

raymond_giuseppi
Active Contributor
0 Kudos

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