-1

My Problem:

I "loop" over a table into a local structure named ls_eban..

and with those information I must follow these instructions:

  1. ls_eban-matnr MUST BE in table zmd_scmi_st01 ( 1. control Table (global) )
  2. ls_eban-werks MUST BE in table zmd_scmi_st05 ( 2. control Table (global) )
  3. ls_eban-knttp MUST BE in table zmd_scmi_st06 ( 3. control Table (global) )

I need a selection that is clear and performant. I actually have one, but it isn't performant at all.

My solution:

SELECT st01~matnr st05~werks st06~knttp
  FROM       zmd_scmi_st01 AS st01
  INNER JOIN zmd_scmi_st05 AS st05
  ON         st05~werks = ls_eban-werks
  INNER JOIN zmd_scmi_st06 AS st06
  ON         knttp = ls_eban-knttp
INTO TABLE   lt_control
WHERE        st01~matnr = ls_eban-matnr AND st01~bedarf = 'X'
  AND        st05~bedarf = 'X'.

I also have to say, that the control tables doesn't have any relation with each other (no primary key and no secondary key).

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • 1
    Could you please show us a complete code sample as well as the structures of all tables involved? I can only guess what your problem might be, and you don't want an "answer" that is pure guesswork... – vwegert Mar 01 '13 at 14:01
  • 1
    If the 3 control tables have no relation to each other, you should not be joining them. Do separate selects for each rule. Also due to the nature of control tables they are often relatively small tables, as such you can select all entries from each table into a separate internal table, and then just do a read inside of the loop. – Esti Mar 02 '13 at 02:08

1 Answers1

0

The first thing you should not do is have the select inside the loop. Instead of

loop at lt_eban into ls_eban.
      Select ....
endloop.

You should do a single select.

if lt_eban[] is not initial.
   select ...
     into table ...
     from ...
      for all entries in lt_eban
    where ...
endif.

There may be more inefficiencies to be corrected if we had more info ( as mentioned in the comment by vwegert. For instance, really no keys on the control tables? ) but the select in a loop is the first thing that jumps out at me.

Bryan Cain
  • 1,736
  • 9
  • 17
  • Thanks for your response. Actually the select in the loop works :) but i'll try it your way.. next monday 'cause now i go home :D thanks again :) very friendly! – Mike Turner Mar 01 '13 at 14:38