Code: Alles auswählen.
REPORT zcheck_for_all_entries.
TABLES:
mara.
SELECT-OPTIONS:
s_matnr FOR mara-matnr.
TYPES:
BEGIN OF ty_makt_s,
matnr TYPE matnr,
spras TYPE spras,
maktx TYPE maktx,
END OF ty_makt_s.
DATA: gt_makt TYPE STANDARD TABLE OF ty_makt_s.
DATA: gt_makt_srt TYPE SORTED TABLE OF ty_makt_s WITH UNIQUE KEY matnr spras.
START-OF-SELECTION.
SELECT matnr maktx FROM makt
INTO CORRESPONDING FIELDS OF TABLE gt_makt
FOR ALL ENTRIES IN s_matnr
WHERE matnr = s_matnr-low
AND spras = sy-langu.
LOOP AT gt_makt_srt ASSIGNING FIELD-SYMBOL(<makt>)
WHERE spras <> sy-langu.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / <makt>-matnr, <makt>-spras.
ENDIF.
SELECT matnr spras maktx FROM makt
INTO CORRESPONDING FIELDS OF TABLE gt_makt_srt
FOR ALL ENTRIES IN s_matnr
WHERE matnr = s_matnr-low
AND spras = sy-langu
ORDER BY PRIMARY KEY.
LOOP AT gt_makt_srt ASSIGNING FIELD-SYMBOL(<makt_srt>)
WHERE spras <> sy-langu.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / <makt_srt>-matnr, <makt_srt>-spras.
ENDIF.
Code: Alles auswählen.
REPORT zcheck_for_all_entries.
TABLES:
mara.
SELECT-OPTIONS:
s_matnr FOR mara-matnr.
TYPES:
BEGIN OF ty_makt_s,
matnr TYPE matnr,
spras TYPE spras,
maktx TYPE maktx,
END OF ty_makt_s.
DATA: gt_makt TYPE STANDARD TABLE OF ty_makt_s.
DATA: gt_makt_srt TYPE SORTED TABLE OF ty_makt_s WITH UNIQUE KEY matnr spras.
START-OF-SELECTION.
SELECT matnr spras maktx FROM makt
INTO CORRESPONDING FIELDS OF TABLE gt_makt
FOR ALL ENTRIES IN s_matnr
WHERE matnr = s_matnr-low
AND spras = sy-langu.
LOOP AT gt_makt ASSIGNING FIELD-SYMBOL(<makt>)
WHERE spras <> sy-langu.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / <makt>-matnr, <makt>-spras.
ENDIF.
* this select statement reads other languages also !?!
SELECT matnr spras maktx FROM makt
INTO CORRESPONDING FIELDS OF TABLE gt_makt_srt
FOR ALL ENTRIES IN s_matnr
WHERE matnr = s_matnr-low
AND spras = sy-langu
ORDER BY PRIMARY KEY.
LOOP AT gt_makt_srt ASSIGNING FIELD-SYMBOL(<makt_srt>)
WHERE spras <> sy-langu.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / <makt_srt>-matnr, <makt_srt>-spras.
ENDIF.
Before using an internal table itab after FOR ALL ENTRIES, always check that the internal table is not initial. In an initial internal tables, all rows are read from the database regardless of any further conditions specified after WHERE. This is not usually the required behavior.