TABLES mara.
FIELD-SYMBOLS: <it_mara> TYPE STANDARD TABLE,
<it_makt> TYPE STANDARD TABLE.
INITIALIZATION.
SELECT-OPTIONS s_matnr FOR mara-matnr.
CLASS mat DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF ts_mara,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
maktx TYPE makt-maktx,
END OF ts_mara.
TYPES: BEGIN OF ts_makt,
matnr TYPE makt-matnr,
spras TYPE makt-spras,
maktx TYPE makt-maktx,
END OF ts_makt.
DATA dref TYPE REF TO data.
METHODS: mara, makt, output.
ENDCLASS.
CLASS mat IMPLEMENTATION.
METHOD mara.
CREATE DATA dref TYPE TABLE OF ts_mara.
ASSIGN dref->* TO <it_mara>.
SELECT matnr mtart matkl
FROM mara INTO TABLE <it_mara>
WHERE matnr IN s_matnr.
ENDMETHOD.
METHOD makt.
IF <it_mara> IS ASSIGNED AND <it_mara> IS NOT INITIAL.
CREATE DATA dref TYPE TABLE OF ts_makt.
ASSIGN dref->* TO <it_makt>.
ASSIGN 'matnr = <it_mara>-matnr' TO FIELD-SYMBOL(<matnr>).
SELECT matnr spras maktx
FROM makt INTO TABLE <it_makt>
FOR ALL ENTRIES IN <it_mara>
WHERE (<matnr>)
AND spras = sy-langu.
ENDIF.
ENDMETHOD.
METHOD output.
FIELD-SYMBOLS: <wa_mara> TYPE ts_mara,
<wa_makt> TYPE ts_makt.
IF <it_makt> IS ASSIGNED.
SORT <it_makt> BY ('MATNR').
ENDIF.
IF <it_mara> IS ASSIGNED.
LOOP AT <it_mara> ASSIGNING <wa_mara>.
IF <it_makt> IS ASSIGNED.
READ TABLE <it_makt> ASSIGNING <wa_makt>
WITH KEY ('MATNR') = <wa_mara>-matnr
BINARY SEARCH.
IF sy-subrc = 0.
<wa_mara>-maktx = <wa_makt>-maktx.
ENDIF.
ENDIF.
WRITE: / <wa_mara>-mtart,
<wa_mara>-matkl,
<wa_mara>-maktx,
<wa_mara>-matnr.
ENDLOOP.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA material TYPE REF TO mat.
CREATE OBJECT material.
CALL METHOD: material->mara,
material->makt,
material->output.
FIELD-SYMBOLS: <it_mara> TYPE STANDARD TABLE,
<it_makt> TYPE STANDARD TABLE.
INITIALIZATION.
SELECT-OPTIONS s_matnr FOR mara-matnr.
CLASS mat DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF ts_mara,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
maktx TYPE makt-maktx,
END OF ts_mara.
TYPES: BEGIN OF ts_makt,
matnr TYPE makt-matnr,
spras TYPE makt-spras,
maktx TYPE makt-maktx,
END OF ts_makt.
DATA dref TYPE REF TO data.
METHODS: mara, makt, output.
ENDCLASS.
CLASS mat IMPLEMENTATION.
METHOD mara.
CREATE DATA dref TYPE TABLE OF ts_mara.
ASSIGN dref->* TO <it_mara>.
SELECT matnr mtart matkl
FROM mara INTO TABLE <it_mara>
WHERE matnr IN s_matnr.
ENDMETHOD.
METHOD makt.
IF <it_mara> IS ASSIGNED AND <it_mara> IS NOT INITIAL.
CREATE DATA dref TYPE TABLE OF ts_makt.
ASSIGN dref->* TO <it_makt>.
ASSIGN 'matnr = <it_mara>-matnr' TO FIELD-SYMBOL(<matnr>).
SELECT matnr spras maktx
FROM makt INTO TABLE <it_makt>
FOR ALL ENTRIES IN <it_mara>
WHERE (<matnr>)
AND spras = sy-langu.
ENDIF.
ENDMETHOD.
METHOD output.
FIELD-SYMBOLS: <wa_mara> TYPE ts_mara,
<wa_makt> TYPE ts_makt.
IF <it_makt> IS ASSIGNED.
SORT <it_makt> BY ('MATNR').
ENDIF.
IF <it_mara> IS ASSIGNED.
LOOP AT <it_mara> ASSIGNING <wa_mara>.
IF <it_makt> IS ASSIGNED.
READ TABLE <it_makt> ASSIGNING <wa_makt>
WITH KEY ('MATNR') = <wa_mara>-matnr
BINARY SEARCH.
IF sy-subrc = 0.
<wa_mara>-maktx = <wa_makt>-maktx.
ENDIF.
ENDIF.
WRITE: / <wa_mara>-mtart,
<wa_mara>-matkl,
<wa_mara>-maktx,
<wa_mara>-matnr.
ENDLOOP.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA material TYPE REF TO mat.
CREATE OBJECT material.
CALL METHOD: material->mara,
material->makt,
material->output.
No comments:
Post a Comment