Code: Alles auswählen.
data: begin of LS_LIEF,
BUKRS type EKPO-BUKRS,
WERKS type EKPO-WERKS,
KUNNR type EKPO-KUNNR,
LIFNR type EKKO-LIFNR,
end of LS_LIEF,
LT_LIEF like standard table of LS_LIEF with header line.
data: R_LIEFNR type range of LFM1-LIFNR, " RANGE-Tabelle
R_LIEFNR_LINE like line of R_LIEFNR.
data: begin of LS_LFM1,
LIFNR type LFM1-LIFNR,
EKORG type LFM1-EKORG,
end of LS_LFM1,
LT_LFM1 like standard table of LS_LFM1.
data: LS_ALV_OUT type TY_ALV_OUT.
select P~BUKRS P~WERKS P~KUNNR K~LIFNR
from EKPO as P inner join EKKO as K on P~EBELN = K~EBELN
into corresponding fields of table LT_LIEF
where P~BUKRS = '0020'
and P~WERKS = '0010'.
delete adjacent duplicates from LT_LIEF comparing LIFNR.
loop at lt_lief into r_liefnr_line.
R_LIEFNR_LINE-SIGN = 'I'. "I = include
R_LIEFNR_LINE-OPTION = 'NE'.
R_LIEFNR_LINE-LOW = 'LT_LIEF-LIFNR'.
append R_LIEFNR_LINE to R_LIEFNR.
endloop.
select LIFNR EKORG from LFM1 into table LT_LFM1
where LIFNR in R_LIEFNR
and EKORG = '0020'.
loop at LT_LFM1 into LS_LFM1.
move-corresponding LS_LFM1 to LS_ALV_OUT.
append LS_ALV_OUT to GT_ALV_OUT.
endloop.
Code: Alles auswählen.
data: begin of LS_LIEF,
* So zu typisieren ist eine grundsätzlich schlechte Idee: BUKRS type BUKRS etc. ist besser.
BUKRS type EKPO-BUKRS,
WERKS type EKPO-WERKS,
KUNNR type EKPO-KUNNR,
LIFNR type EKKO-LIFNR,
end of LS_LIEF,
LT_LIEF like standard table of LS_LIEF with header line.
data: R_LIEFNR type range of LFM1-LIFNR, " RANGE-Tabelle
R_LIEFNR_LINE like line of R_LIEFNR.
data: begin of LS_LFM1,
LIFNR type LFM1-LIFNR,
EKORG type LFM1-EKORG,
end of LS_LFM1,
LT_LFM1 like standard table of LS_LFM1.
data: LS_ALV_OUT type TY_ALV_OUT.
select P~BUKRS P~WERKS P~KUNNR K~LIFNR
from EKPO as P inner join EKKO as K on P~EBELN = K~EBELN
into corresponding fields of table LT_LIEF
where P~BUKRS = '0020'
and P~WERKS = '0010'.
delete adjacent duplicates from LT_LIEF comparing LIFNR.
loop at lt_lief into ls_lief . "r_liefnr_line hat einen anderen typ als lt_lief
R_LIEFNR_LINE-SIGN = 'I'. "I = include
R_LIEFNR_LINE-OPTION = 'NE'.
* R_LIEFNR_LINE-LOW = 'LT_LIEF-LIFNR'. "So schreibt er das Literal "LT_LIEF-LIFNR" da rein
R_LIEFNR_LINE-LOW = ls_lief-lifnr.
append R_LIEFNR_LINE to R_LIEFNR.
endloop.
select LIFNR EKORG from LFM1 into table LT_LFM1
where LIFNR in R_LIEFNR
and EKORG = '0020'.
loop at LT_LFM1 into LS_LFM1.
move-corresponding LS_LFM1 to LS_ALV_OUT.
append LS_ALV_OUT to GT_ALV_OUT.
endloop.
Code: Alles auswählen.
select LIFNR EKORG from LFM1 into table LT_LFM1
where LIFNR in R_LIEFNR
and EKORG = '0020'.
Folgende Benutzer bedankten sich beim Autor Unit605 für den Beitrag:
Nadine_2706
Code: Alles auswählen.
select LIFNR EKORG into table LT_LFM1 from LFM1
for all entries in LT_LIEF
where LIFNR ne LT_LIEF-LIFNR
and EKORG = '0020'.
Code: Alles auswählen.
data: begin of LS_LIEF,
* So zu typisieren ist eine grundsätzlich schlechte Idee: BUKRS type BUKRS etc. ist besser.
BUKRS type EKPO-BUKRS,
WERKS type EKPO-WERKS,
KUNNR type EKPO-KUNNR,
LIFNR type EKKO-LIFNR,
end of LS_LIEF,
LT_LIEF like standard table of LS_LIEF with header line.
data: R_LIEFNR type range of LFM1-LIFNR, " RANGE-Tabelle
R_LIEFNR_LINE like line of R_LIEFNR.
data: begin of LS_LFM1,
LIFNR type LFM1-LIFNR,
EKORG type LFM1-EKORG,
end of LS_LFM1,
LT_LFM1 like standard table of LS_LFM1.
data: LS_ALV_OUT type TY_ALV_OUT.
select P~BUKRS P~WERKS P~KUNNR K~LIFNR
from EKPO as P inner join EKKO as K on P~EBELN = K~EBELN
into corresponding fields of table LT_LIEF
where P~BUKRS = '0020'
and P~WERKS = '0010'.
delete adjacent duplicates from LT_LIEF comparing LIFNR.
loop at lt_lief into ls_lief . "r_liefnr_line hat einen anderen typ als lt_lief
R_LIEFNR_LINE-SIGN = 'I'. "I = include
R_LIEFNR_LINE-OPTION = 'NE'.
* R_LIEFNR_LINE-LOW = 'LT_LIEF-LIFNR'. "So schreibt er das Literal "LT_LIEF-LIFNR" da rein
R_LIEFNR_LINE-LOW = ls_lief-lifnr.
append R_LIEFNR_LINE to R_LIEFNR.
endloop.
==================== ALT ALT ALT =================================================
select LIFNR EKORG from LFM1 into table LT_LFM1
where LIFNR in R_LIEFNR
and EKORG = '0020'.
==================== NEU NEU NEU =================================================
select LIFNR EKORG from LFM1 into table LT_LFM1 for all entries in R_LIEFNR
where LIFNR eq R_LIEFNR-LIFNR
and EKORG = '0020'.
=====================================================================
loop at LT_LFM1 into LS_LFM1.
move-corresponding LS_LFM1 to LS_ALV_OUT.
append LS_ALV_OUT to GT_ALV_OUT.
endloop.
Code: Alles auswählen.
where LIFNR eq R_LIEFNR-LIFNR
Code: Alles auswählen.
where LIFNR eq R_LIEFNR-LOW
Code: Alles auswählen.
where LIFNR ne R_LIEFNR-LOW
Nicht nur Reden schwingen... besser machen.a-dead-trousers hat geschrieben:Sag bloß, du hast in der Range-Tabelle alles als ausschließendes Kriterium hinterlegt.
Ich würde dringend davon abraten so etwas (noch dazu mit 2300 Einträgen) auf die Datenbank loszulassen.
Je nach dem wie viele Einträge die Tabelle hat, kann so eine Abfrage EWIGKEITEN dauern.
Ich rate dir wirklich, die Abfrage zu überdenken und das Ganze irgendwie "positiv" (einschließendes Kriterium) zu formulieren.
lg ADT