Frage

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

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top