[ABAP] Daten zum Material anzeigen

* siehe auch Report RMMMTREE
PARAMETERS: p_mat TYPE matnr.

START-OF-SELECTION.

* Allgemeine Materialdaten
  SELECT
    FROM mara
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_mara).

* Werksdaten zum Material
  SELECT
    FROM marc
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_marc).

  IF lines( it_marc ) > 0.
* Lagerortdaten zum Material
    SELECT
      FROM mard AS m
      FIELDS *
      FOR ALL ENTRIES IN @it_marc
      WHERE m~matnr EQ @p_mat
        AND m~werks EQ @it_marc-werks
      ORDER BY PRIMARY KEY
      INTO TABLE @DATA(it_mard).
  ENDIF.

* Materialkurztexte
  SELECT
    FROM makt
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_makt).

* STXD SAPscript Text-Datei Header
  SELECT
    FROM stxh
    FIELDS *
    WHERE tdobject EQ 'MATERIAL'
      AND tdname EQ @( |{ p_mat WIDTH = 18 ALPHA = IN }| )
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_stxh).
      
* Reservierung/Sekundärbedarf
  SELECT
    FROM resb
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_resb).

* Bestellanforderung
  SELECT
    FROM eban
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_eban).

* Einkaufsbelegposition
  SELECT
    FROM ekpo
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_ekpo).

  IF lines( it_ekpo ) > 0.
* Einkaufsbelegkopf
    SELECT
      FROM ekko AS e
      FIELDS *
      FOR ALL ENTRIES IN @it_ekpo
      WHERE e~ebeln EQ @it_ekpo-ebeln
      ORDER BY PRIMARY KEY
      INTO TABLE @DATA(it_ekko).
  ENDIF.

* Materialstamm: Standardfelder und spezielle Retail-Felder
  SELECT
    FROM maw1
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_maw1).

  IF lines( it_makt ) > 0.
* Materialstamm-Texte je Mengeneinheit und Text-Id
    SELECT
      FROM mamt AS m
      FIELDS *
      FOR ALL ENTRIES IN @it_makt
      WHERE m~matnr EQ @p_mat
        AND m~spras EQ @it_makt-spras
      ORDER BY PRIMARY KEY
      INTO TABLE @DATA(it_mamt).
  ENDIF.

* Mengeneinheiten zum Material
  SELECT
    FROM marm
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_marm).

  IF lines( it_marm ) > 0.
* Europäische Artikelnummern zum Material
    SELECT
      FROM mean AS m
      FIELDS *
      FOR ALL ENTRIES IN @it_marm
      WHERE m~matnr EQ @p_mat
        AND m~meinh EQ @it_marm-meinh
      ORDER BY PRIMARY KEY
      INTO TABLE @DATA(it_mean).

* Zuordnung von Layoutbausteinen zu Materialien
    SELECT
      FROM malg AS m
      FIELDS *
      FOR ALL ENTRIES IN @it_marm
      WHERE matnr EQ @p_mat
        AND m~meinh EQ @it_marm-meinh
      ORDER BY PRIMARY KEY
      INTO TABLE @DATA(it_malg).
  ENDIF.

* Verkaufsdaten zum Material
  SELECT
    FROM mvke
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_mvke).

* Materialbewertung
  SELECT
    FROM mbew
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_mbwe).

* Materialdaten pro Lagernummer
  SELECT
    FROM mlgn
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_mlgn).

  IF lines( it_mlgn ) > 0.
* Materialdaten pro Lagertyp
    SELECT
      FROM mlgt AS m
      FIELDS *
      FOR ALL ENTRIES IN @it_mlgn
      WHERE m~matnr EQ @p_mat
        AND m~lgnum EQ @it_mlgn-lgnum
      ORDER BY PRIMARY KEY
      INTO TABLE @DATA(it_mlgt).
  ENDIF.

* Einkaufsinfosatz - allgemeine Daten
  SELECT
    FROM eina
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_eina).

  IF lines( it_eina ) > 0.
* Einkaufsinfosatz - Einkaufsorganisationsdaten
    SELECT
      FROM eine AS e
      FIELDS *
      FOR ALL ENTRIES IN @it_eina
      WHERE e~infnr EQ @it_eina-infnr
      ORDER BY PRIMARY KEY
      INTO TABLE @DATA(it_eine).
  ENDIF.

* Materialstammstatus
  SELECT
    FROM msta
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_msta).

* noch offene Materialstaemme
  SELECT
    FROM moff
    FIELDS *
    WHERE matnr EQ @p_mat
      ORDER BY statm
      INTO TABLE @DATA(it_moff).

* Planauftrag
  SELECT
    FROM plaf
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_plaf).

* Kopfsatz für Bedarfssummensätze im MRP
  SELECT
    FROM rqhd
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_rqhd).

* Positionssatz für Bedarfssummensätze im MRP
  SELECT
    FROM rqit
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_rqit).

* Material (Konditionssätze)
  SELECT
    FROM a004
    FIELDS *
    WHERE matnr EQ @p_mat
    ORDER BY PRIMARY KEY
    INTO TABLE @DATA(it_a004).

  IF lines( it_a004 ) > 0.
* Konditionen (Kopf)
    SELECT
      FROM konh
      FIELDS *
      FOR ALL ENTRIES IN @it_a004
      WHERE knumh EQ @it_a004-knumh
      ORDER BY PRIMARY KEY
      INTO TABLE @DATA(it_konh).

* Konditionen (Position)
    SELECT
      FROM konp
      FIELDS *
      FOR ALL ENTRIES IN @it_a004
      WHERE knumh EQ @it_a004-knumh
      ORDER BY PRIMARY KEY
      INTO TABLE @DATA(it_konp).
  ENDIF.

  cl_demo_output=>next_section( 'Materialstamm' ).
  cl_demo_output=>write_data( value = it_mara name = 'MARA (Allgemeine Materialdaten)' ).
  cl_demo_output=>write_data( value = it_marc name = 'MARC (Werksdaten zum Material)' ).
  cl_demo_output=>write_data( value = it_mard name = 'MARD (Lagerortdaten zum Material)').
  cl_demo_output=>next_section( 'Texte' ).
  cl_demo_output=>write_data( value = it_makt name = 'MAKT (Materialkurztexte)').
  cl_demo_output=>write_data( value = it_stxh name = 'STXH (STXD SAPscript Text-Datei Header)').
  cl_demo_output=>next_section( 'Einkauf' ).
  cl_demo_output=>write_data( value = it_resb name = 'RESB (Reservierung/Sekundärbedarf)').
  cl_demo_output=>write_data( value = it_eban name = 'EBAN (Bestellanforderung)').
  cl_demo_output=>write_data( value = it_ekko name = 'EKKO (Einkaufsbelegkopf)').
  cl_demo_output=>write_data( value = it_ekpo name = 'EKPO (Einkaufsbelegposition)').
  cl_demo_output=>next_section( 'Infosatz' ).
  cl_demo_output=>write_data( value = it_eina name = 'EINA (Einkaufsinfosatz - allgemeine Daten)').
  cl_demo_output=>write_data( value = it_eine name = 'EINE (Einkaufsinfosatz - Einkaufsorganisationsdaten)').
  cl_demo_output=>next_section( 'Konditionen' ).
  cl_demo_output=>write_data( value = it_a004 name = 'A004 (Material (Konditionssätze)').
  cl_demo_output=>write_data( value = it_konh name = 'KONH (Konditionen (Kopf))').
  cl_demo_output=>write_data( value = it_konp name = 'KONP (Konditionen (Position))').
  cl_demo_output=>next_section( 'Bewertung' ).
  cl_demo_output=>write_data( value = it_mbwe name = 'MBEW (Materialbewertung)').
  cl_demo_output=>next_section( 'Verkaufsdaten' ).
  cl_demo_output=>write_data( value = it_mvke name = 'MVKE (Verkaufsdaten zum Material)').
  cl_demo_output=>next_section( 'Mengeneinheiten' ).
  cl_demo_output=>write_data( value = it_marm name = 'MARM (Mengeneinheiten zum Material)').
  cl_demo_output=>next_section( 'Materialdaten' ).
  cl_demo_output=>write_data( value = it_mlgn name = 'MLGN (Materialdaten pro Lagernummer)').
  cl_demo_output=>write_data( value = it_mlgt name = 'MLGT (Materialdaten pro Lagertyp)').
  cl_demo_output=>next_section( 'Planaufträge' ).
  cl_demo_output=>write_data( value = it_plaf name = 'PLAF (Planauftrag)').
  cl_demo_output=>next_section( 'MRP' ).
  cl_demo_output=>write_data( value = it_rqhd name = 'RQHD (Kopfsatz für Bedarfssummensätze im MRP)').
  cl_demo_output=>write_data( value = it_rqit name = 'RQIT (Positionssatz für Bedarfssummensätze im MRP)').
  cl_demo_output=>next_section( 'Materialstammstatus' ).
  cl_demo_output=>write_data( value = it_msta name = 'MSTA (Materialstammstatus)').
  cl_demo_output=>write_data( value = it_moff name = 'MOFF (noch offene Materialstaemme)').
  cl_demo_output=>next_section( 'Sonstges' ).
  cl_demo_output=>write_data( value = it_maw1 name = 'MAW1 (Materialstamm: Standardfelder und spezielle Retail-Felder)').
  cl_demo_output=>write_data( value = it_mamt name = 'MAMT (Materialstamm-Texte je Mengeneinheit und Text-Id)').
  cl_demo_output=>write_data( value = it_mean name = 'MEAN (Europäische Artikelnummern zum Material)').
  cl_demo_output=>write_data( value = it_malg name = 'MALG (Zuordnung von Layoutbausteinen zu Materialien)').

*   HTML-Code vom Demo-Output holen
  DATA(lv_html) = cl_demo_output=>get( ).

*   Daten im Inline-Browser im SAP-Fenster anzeigen
  cl_abap_browser=>show_html( EXPORTING title       = 'Material'
                                        html_string = lv_html
                                        container   = cl_gui_container=>default_screen ).

* leere Standard-Toolbar ausblenden
  cl_abap_list_layout=>suppress_toolbar( ).

* cl_gui_container=>default_screen erzwingen
  WRITE: space.

[ABAP] BAPI zum Lesen von Infos zur Bestellanforderung (BANF)

PARAMETERS: p_banfn TYPE eban-banfn.

START-OF-SELECTION.
  DATA: lv_bapimereqheader TYPE bapimereqheader.
  DATA: it_bapiret2 TYPE STANDARD TABLE OF bapiret2 WITH DEFAULT KEY.
  DATA: it_bapimereqitem TYPE STANDARD TABLE OF bapimereqitem WITH DEFAULT KEY.
  DATA: it_bapimereqaccount TYPE STANDARD TABLE OF bapimereqaccount WITH DEFAULT KEY.
  DATA: it_bapimerqaddrdelivery TYPE STANDARD TABLE OF bapimerqaddrdelivery WITH DEFAULT KEY.
  DATA: it_bapimereqitemtext TYPE STANDARD TABLE OF bapimereqitemtext WITH DEFAULT KEY.
  DATA: it_bapimereqheadtext TYPE STANDARD TABLE OF bapimereqheadtext WITH DEFAULT KEY.
  DATA: it_bapiparex TYPE STANDARD TABLE OF bapiparex WITH DEFAULT KEY.
  DATA: it_bapimedcm_allversions TYPE STANDARD TABLE OF bapimedcm_allversions WITH DEFAULT KEY.
  DATA: it_bapimereqcomponent TYPE STANDARD TABLE OF bapimereqcomponent WITH DEFAULT KEY.
  DATA: it_bapimereqserialno TYPE STANDARD TABLE OF bapimereqserialno WITH DEFAULT KEY.
  DATA: it_bapi_srv_outline TYPE STANDARD TABLE OF bapi_srv_outline WITH DEFAULT KEY.
  DATA: it_bapi_srv_service_line TYPE STANDARD TABLE OF bapi_srv_service_line WITH DEFAULT KEY.
  DATA: it_bapi_srv_limit_data TYPE STANDARD TABLE OF bapi_srv_limit_data WITH DEFAULT KEY.
  DATA: it_bapi_srv_contract_limits TYPE STANDARD TABLE OF bapi_srv_contract_limits WITH DEFAULT KEY.
  DATA: it_bapi_srv_acc_data TYPE STANDARD TABLE OF bapi_srv_acc_data WITH DEFAULT KEY.
  DATA: it_bapi_srv_longtexts TYPE STANDARD TABLE OF bapi_srv_longtexts WITH DEFAULT KEY.

  CALL FUNCTION 'BAPI_PR_GETDETAIL'
    EXPORTING
      number                = p_banfn
      account_assignment    = abap_true
      item_text             = abap_true
      header_text           = abap_true
      delivery_address      = abap_true
*     VERSION               = ' '
      sc_components         = abap_true
      serial_numbers        = abap_true
      services              = abap_true
    IMPORTING
      prheader              = lv_bapimereqheader
    TABLES
      return                = it_bapiret2
      pritem                = it_bapimereqitem
      praccount             = it_bapimereqaccount
      praddrdelivery        = it_bapimerqaddrdelivery
      pritemtext            = it_bapimereqitemtext
      prheadertext          = it_bapimereqheadtext
      extensionout          = it_bapiparex
      allversions           = it_bapimedcm_allversions
      prcomponents          = it_bapimereqcomponent
      serialnumbers         = it_bapimereqserialno
      serviceoutline        = it_bapi_srv_outline
      servicelines          = it_bapi_srv_service_line
      servicelimit          = it_bapi_srv_limit_data
      servicecontractlimits = it_bapi_srv_contract_limits
      serviceaccount        = it_bapi_srv_acc_data
      servicelongtexts      = it_bapi_srv_longtexts.

  cl_demo_output=>write_data( lv_bapimereqheader ).
  cl_demo_output=>write_data( it_bapiret2 ).
  cl_demo_output=>write_data( it_bapimereqitem ).
  cl_demo_output=>write_data( it_bapimereqaccount ).
  cl_demo_output=>write_data( it_bapimerqaddrdelivery ).
  cl_demo_output=>write_data( it_bapimereqitemtext ).
  cl_demo_output=>write_data( it_bapimereqheadtext ).
  cl_demo_output=>write_data( it_bapiparex ).
  cl_demo_output=>write_data( it_bapimedcm_allversions ).
  cl_demo_output=>write_data( it_bapimereqcomponent ).
  cl_demo_output=>write_data( it_bapimereqserialno ).
  cl_demo_output=>write_data( it_bapi_srv_outline ).
  cl_demo_output=>write_data( it_bapi_srv_service_line ).
  cl_demo_output=>write_data( it_bapi_srv_limit_data ).
  cl_demo_output=>write_data( it_bapi_srv_contract_limits ).
  cl_demo_output=>write_data( it_bapi_srv_acc_data ).
  cl_demo_output=>write_data( it_bapi_srv_longtexts ).

* HTML-Code vom Demo-Output holen
  DATA(lv_html) = cl_demo_output=>get( ).

* Daten im Inline-Browser im SAP-Fenster anzeigen
  cl_abap_browser=>show_html( EXPORTING
                                title        = 'BANF-Daten'
                                html_string  = lv_html
                                container    = cl_gui_container=>default_screen ).

* cl_gui_container=>default_screen erzwingen
  WRITE: space.

[ABAP] BANF freigeben

PARAMETERS: p_banfn TYPE eban-banfn.

DATA(lv_updated) = VALUE char1( ).

* ME54N
CALL FUNCTION 'ME_RELEASE_REQUISITION'
  EXPORTING
    im_banfn     = p_banfn
  IMPORTING
    ex_updkz     = lv_updated
  EXCEPTIONS
    no_authority = 1
    OTHERS       = 2.

IF sy-subrc = 0.
  IF lv_updated = abap_true.
    WRITE: / 'Updated.'.
  ELSE.
    WRITE: / 'Not updated.'.
  ENDIF.
ELSE.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

[SAP] Bestellung

Transaktionen

MEPO (Bestellung)

  • Transaktion für ME21N/ME22N/ME23N

ME21N (Bestellung anlegen)
ME22N (Bestellung ändern)
ME23N (Bestellung anzeigen)

ME25 (Bestellung anlegen, Lieferant unbekannt)
ME28 (Sammelfreigabe)
ME29N (Einzelfreigabe)
ME58 (Bestellungen über Banf Zuordnungsliste)
ME59N (automatische Bestellerzeugung aus BANFen)
ME80FN (Allgemeine Auswertungen)

  • Listansicht zu versch. Belegarten
  • Selektion nach Materialnummer, Werk, Lagerort, Belegart, Datum, EKOrg, gemerkt etc.

ME81N (Bestellwertanalyse zu Bestellungen)

ME2L (Bestellungen zum Lieferanten)

  • mit Selektionsparameter WE101 (offener Wareneingang)

ME2M (Bestellungen zum Material)
ME2N (Bestellungen zur Bestellnummer)
ME2K (Bestellungen zur Kontierung)
ME2C (Bestellungen zur Warengruppe)
ME91F (Bestellungen mahnen und erinnern)

  • Liefermahnungen

ME9F (Nachrichtenausgabe Bestellungen)
OMH6 (Nummernkreise Einkaufsbelege)

Funktionsbausteine

ME_DISPLAY_PURCHASE_DOCUMENT (Anzeigen eines Einkaufsbeleges)

BAPIs

BAPI_PO_CREATE1 (Create Purchase Order)
BAPI_PO_CHANGE (Change Purchase Order)
BAPI_PO_GETDETAIL1 (Detail Information for a Purchase Order)

Tabellen

EKKO (Einkaufsbelegkopf)
EKPO (Einkaufsbelegposition)
EKKN (Kontierung im Einkaufsbeleg)
EKBE (Historie zum Einkaufsbeleg)
EBAN (Bestellanforderung)
T161 (Einkaufsbelegarten)

Views

MASSEKPO (Bestellposition)
V_EKKONA (View zur Ausgabe von Einkaufsbelegen) (EKKO, NAST)

Fiori-Apps

F3292 (Bestellungen zentral verwalten)
F2593 (Massenänderungen an Bestellungen)

Links

[SAP] Bestellanforderungen / BANF

Transaktionen

ME51N (Bestellanforderunganlegen)
ME52N (Bestellanforderung ändern)
ME53N (Bestellanforderung anzeigen)
ME54N (Bestellanforderung freigeben)

ME5A (Listanzeige Bestellanforderungen)

  • Bestellanforderung: BANF eingeben
  • Listumfang: ALV
  • Haken bei:
    • Zugeordnete BANFen
    • Auch gemerkte BANFen listen
    • Erledigte BANFen
    • Teilbestellte BANFen
    • BANFen zur Gesamtfreigabe
    • BANFen zur Positionsfreigabe
  • Button „Ausführen“
  • in der Listanzeige der Bestellanforderungen sind die zugeordneten Bestellungen in der Spalte „Bestellung“ aufgelistet

ME55 (Sammelfreigabe Bestellanforderungen)

ME56 (Bezugsquelle zur BANF zuordnen)
ME57 (BANF zuordnen und bearbeiten)
ME58 (Bestellung über Zuordnungsliste)

OMH7 (Nummernkreise Bestellanforderung)

Funktionsbausteine

ME_RELEASE_REQUISITION (Bestellanforderung bearbeiten)

BAPIs

BAPI_PR_CREATE (Create Enjoy Purchase Requisistion)
BAPI_PR_CHANGE (Change Enjoy Purchase Requisistion)
BAPI_PR_GETDETAIL (Get Details for One MEREQ Object)

Erweiterungen

Paket: MEREQ (Einkauf Bestellanforderung)
Erweiterung: MEREQ001 (Kundeneigene Daten in der Bestellanforderung)
Funktionsgruppe: XM02 (User-Exits Banf)

Tabellen

EBAN (Bestellanforderung)
T161 (Einkaufsbelegarten)

Fiori-Apps

F2229 (Bestellanforderungen verwalten – Professionell)