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: 

LIKE in SELECT FOR ALL ENTRIES

Former Member
0 Kudos

Hello all,

select * from mara

into corresponding fields of tabel itab_mara

for all entries in table itab

where matnr LIKE itab-matnr.

for my requirement, I want to use the above statement. because in ITAB, i have MATNR with only 10 digit.

But the problem is system does not allow this syntax.

Do you have an idea which will avoid any other SELECT s and get away with it.

Thanks.

14 REPLIES 14

former_member404244
Active Contributor
0 Kudos

Hi,

do like this..

IF NOT ITAB[] IS INITIAL.

select * from mara

into corresponding fields of table itab_mara

for all entries in itab

where matnr = itab-matnr.

ENDIF..

Reward if helpful.

Regards,

Nagaraj

0 Kudos

Thanks for reply.

But if I do like you said, I will not get any data from MARA. Right ? because ITAB-MATNR is only 10 digit

0 Kudos

Hi,

Then do like this before the select statement.

LOOP AT ITAB.

CALL FUNCTION "CONVERSION_EXIT_ALPHA_OUTPUT"

PASS THE MATERIAL NUMBER

ANDTHEN MODIFY THE ITAB.

ENDLOOP.

Reward if helpful.

Regards,

nagaraj

Former Member
0 Kudos

HI,

select * from mara

into corresponding fields of <b>table</b> itab_mara

for all entries in table itab

where matnr <b>=</b> itab-matnr.

rgds,

bharat.

Former Member
0 Kudos

Hi

Select Statements contd…For All Entries

• The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.

The plus

• Large amount of data

• Mixing processing and reading of data

• Fast internal reprocessing of data

• Fast

The Minus

• Difficult to program/understand

• Memory could be critical (use FREE or PACKAGE size)

Points to be must considered FOR ALL ENTRIES

• Check that data is present in the driver table

• Sorting the driver table

• Removing duplicates from the driver table

Consider the following piece of extract

Loop at int_cntry.

Select single * from zfligh into int_fligh

where cntry = int_cntry-cntry.

Append int_fligh.

Endloop.

The above mentioned can be more optimized by using the following code.

Sort int_cntry by cntry.

Delete adjacent duplicates from int_cntry.

If NOT int_cntry[] is INITIAL.

Select * from zfligh appending table int_fligh

For all entries in int_cntry

Where cntry = int_cntry-cntry.

Endif.

Former Member
0 Kudos

Hi Kumar,

try like this..take one extra variable like..

DATA : matnr LIKE mara-matnr.

CONCATENATE itab-matnr '%' INTO matnr.

then change your select statement.

select * from mara

into corresponding fields of tabel itab_mara

for all entries in table itab

where matnr LIKE matnr.

IT should work..I've tried...:)

Message was edited by:

Sudhakar G

former_member386202
Active Contributor
0 Kudos

Hi,

while defining structure of internal table put datatype of both the matrial numbers same. then use

if not itab[] is inital.

select * from mara

into corresponding fields of tabel itab_mara

for all entries in table itab

where matnr EQ itab-matnr.

endif.

Regards,

Prashant

Former Member
0 Kudos

Hi,

do like this

select * from mara

into tabel itab_mara

for all entries in table itab

where matnr = itab-matnr+0(10).

Reward if it helps,

Satish

Former Member
0 Kudos

Hi Surendra,

Try This Out

concatenate '%' itab-matnr '%' into variable.

select * from mara

into corresponding fields of tabel itab_mara

for all entries in table itab

where matnr LIKE variable.

Surely it will work

Kindly reward if useful

Rohit G

mahaboob_pathan
Contributor
0 Kudos

hi,

before writing for all enteries.

it's better check where the internal table is initial or not.

if not itab[] is initial.

select * from mara

into corresponding fields of table itab_mara

for all entries into table itab

where matnr = itab-matnr.

endif.

delete adjacent duplicates from itab[].

0 Kudos

Hello ,

Problem solved with ranges filled with CP option

0 Kudos

Thats only a temporary fix, once you get a few thousand entries in your range table you WILL get a shortdump.

0 Kudos

Better solution is to add an extra column to your internal table say field MATNR2 that is 18 char long like MARA-MATNR. Then loop over your internal table copying MATNR to MATNR2 using conversion_exit_alpha_input. Once done you can use the FOR ALL ENTRIES command on the new column MATNR2.

Former Member
0 Kudos

Your idea wouldn't even work if the syntax allowed if, since LIKE would only work if the values were wild-carded.

What you need to do is LOOP AT itab_mara and run the conversion exit on MATNR to get it into the right format, and then do your select with an equal condition.

If you need to preserve the original data, make a copy of the table before running the conversion exit.

  FIELD-SYMBOLS: <itab_mara> TYPE  mara.  "use same type as for itab_mara

  IF itab_mara[] IS NOT INITIAL.

    LOOP AT itab_mara ASSIGNING <itab_mara>.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = <itab_mara-matnr>
        IMPORTING
          output = <itab_mara-matnr>.

    ENDLOOP.

    SELECT * FROM mara
      INTO CORRESPONDING FIELDS OF TABLE itab_mara
      FOR ALL ENTRIES IN table itab_mara
      WHERE matnr = itab_mara-matnr.

  ENDIF.

Good luck

Brian

fix spelling

Message was edited by:

Brian Sammond