[ABAP] MM: Materialdaten lesen

DATA: lv_matnr TYPE bapi_mara_ga-material VALUE '000000001234567890'.
DATA: lv_clientdata TYPE bapi_mara_ga.

DATA: it_materialdescription TYPE STANDARD TABLE OF bapi_makt_ga WITH DEFAULT KEY.
DATA: it_return TYPE STANDARD TABLE OF bapireturn WITH DEFAULT KEY.

CALL FUNCTION 'BAPI_MATERIAL_GET_ALL'
  EXPORTING
    material            = lv_matnr
*   COMP_CODE           =
*   VAL_AREA            =
*   VAL_TYPE            =
*   PLANT               =
*   STGE_LOC            =
*   SALESORG            =
*   DISTR_CHAN          =
*   WHSENUMBER          =
*   STGE_TYPE           =
*   LIFO_VALUATION_LEVEL =
*   KZRFB_ALL           =
  IMPORTING
    clientdata          = lv_clientdata
*   PLANTDATA           =
*   FORECASTPARAMETERS  =
*   PLANNINGDATA        =
*   STORAGELOCATIONDATA =
*   VALUATIONDATA       =
*   WAREHOUSENUMBERDATA =
*   SALESDATA           =
*   STORAGETYPEDATA     =
*   PRTDATA             =
*   LIFOVALUATIONDATA   =
  TABLES
    materialdescription = it_materialdescription
*   UNITSOFMEASURE      =
*   INTERNATIONALARTNOS =
*   MATERIALLONGTEXT    =
*   TAXCLASSIFICATIONS  =
*   EXTENSIONOUT        =
    return              = it_return.

* Fehlermeldungen ausgeben
LOOP AT it_return ASSIGNING FIELD-SYMBOL(<r>).
  WRITE: / <r>-type, <r>-code, <r>-message.
ENDLOOP.

* Materialdaten (MARA)
WRITE: / lv_clientdata-material,
         lv_clientdata-matl_type,
         lv_clientdata-mat_status,
         lv_clientdata-del_flag,
         lv_clientdata-matl_group,
         lv_clientdata-base_uom.

* Materialkurztexte (MAKT)
LOOP AT it_materialdescription ASSIGNING FIELD-SYMBOL(<d>).
  WRITE: / <d>-langu, <d>-langu_iso, <d>-matl_desc.
ENDLOOP.

[ABAP] Daten zu einem Material (MATNR) ermitteln

DATA: lv_material_general_data TYPE bapimatdoa.
DATA: lv_return	TYPE bapireturn.
DATA: lv_materialplantdata TYPE bapimatdoc.
DATA: lv_materialvaluationdata TYPE bapimatdobew.

* Materialdaten holen
CALL FUNCTION 'BAPI_MATERIAL_GET_DETAIL'
  EXPORTING
    material              = '000000001234567890'   " MATNR
    valuationarea         = '01'                   " Werk
  IMPORTING
    material_general_data = lv_material_general_data
    return                = lv_return
    materialplantdata     = lv_materialplantdata
    materialvaluationdata = lv_materialvaluationdata.

* Fehlermessage
WRITE: / lv_return-type, lv_return-code, lv_return-message.

* Kurzbezeichnung
WRITE: / lv_material_general_data-matl_desc.

* Preis
WRITE: / SWITCH string( lv_materialvaluationdata-price_ctrl
                        WHEN 'S' THEN lv_materialvaluationdata-std_price
                        ELSE lv_materialvaluationdata-moving_pr ), lv_materialvaluationdata-currency.