[ABAP] Muster-Leistungsverzeichnisse lesen

* Muster-LV-Nummer
PARAMETERS: p_spec TYPE tmp_spec-spec_no.

START-OF-SELECTION.

* Muster-Leistungsverzeichnis
  SELECT SINGLE FROM tmp_spec
    FIELDS *
    WHERE spec_no = @p_spec
    INTO @DATA(lv_spec).

  IF sy-subrc = 0.
    DATA(it_esll) = VALUE mmsrv_ml_esll( ).

* Leistungsverzeichnis lesen für Listausgabe im PM/PS
    CALL FUNCTION 'MS_FETCH_SPEC_FOR_LIST'
      EXPORTING
        spec_packno            = lv_spec-packno
      TABLES
        servicetab             = it_esll
*       LIMITTAB               =
      EXCEPTIONS
        no_specification_exist = 1
        OTHERS                 = 2.

    IF sy-subrc = 0.
* Hier Objekte für die Ausgabe hinzufügen
      cl_demo_output=>write_data( it_esll ).

* 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       = 'Leistungsverzeichnis'
                                            html_string = lv_html
                                            container   = cl_gui_container=>default_screen ).

* cl_gui_container=>default_screen erzwingen
      WRITE: space.
    ENDIF.
  ENDIF.

[ABAP] Material-Ledger: Materialpreise für unterschiedliche Währungstypen pflegen

* MATNR
PARAMETERS: p_matnr TYPE mara-matnr.
* Bewertungskreis
PARAMETERS: p_bwkey TYPE t001k-bwkey.
* Preis
PARAMETERS: p_price TYPE bapi_matval_prices-price DEFAULT '1.00'.
* Währung
PARAMETERS: p_waers TYPE tcurc-waers DEFAULT 'EUR'.

START-OF-SELECTION.

* Bewertungskreis (MBEW-BWKEY) == WERKS
  DATA(lv_valuationarea) = CONV bapi_matval_key-val_area( p_bwkey ).
* Bewertungsart (MBEW-BWTAR), siehe Tabelle T149D
  DATA(lv_valuationtype) = CONV bapi_matval_key-val_type( ' ' ).
* Struktur Preisänderungs-Datum
  DATA(lv_pricedate) = VALUE bapi_matval_pricedate( price_date  = sy-datum
                                                    fisc_period = sy-datum+4(2)
                                                    fisc_year   = sy-datum+0(4)
                                                  ).
* Belegkopftext
  DATA(lv_doc_header_text) = CONV bktxt( 'Materialbeleg Text' ).

* Material-Ledger-Typ zum Bewertungskreis
  SELECT SINGLE FROM tckm2
    FIELDS matled
    WHERE bwkey = @p_bwkey
    INTO @DATA(lv_matled).

  IF sy-subrc = 0.
* Währungs-, Bewertungstypen zum Material-Ledger-Typ
* CURTP (Währungstyp)
    SELECT FROM tckmit
      INNER JOIN tcval ON tckmit~cvtyp = tcval~cvtyp
      FIELDS tckmit~cvtyp,  " Währungs- und Bewertungstyp
             tcval~currtyp, " Währungstyp
             tcval~valutyp  " Bewertungssicht
      WHERE matled = @lv_matled
      INTO TABLE @DATA(it_cvtyp).

    IF sy-subrc = 0.
* Währungscodes
      SELECT SINGLE FROM tcurc
        FIELDS altwr
        WHERE waers = @p_waers
        INTO @DATA(lv_iso).

      IF sy-subrc = 0.
* Preise für alle Währungstypen (CVTYP) setzen
        DATA: it_prices TYPE STANDARD TABLE OF bapi_matval_prices WITH DEFAULT KEY.

        LOOP AT it_cvtyp ASSIGNING FIELD-SYMBOL(<cv>).
* Beispiel:
*   Preise + Währungen für alle Währungstypen des Ledgers zum Bewertungskreis gleich setzen
* Beachte: es gibt andere Anwendungsfälle, insbesondere bei abweichenden Währungstypen (anderen Konzernwährungen (USD usw.)),
*          bei denen die Preise unterschiedlich sein können
* siehe auch MM03 (Reiter "Buchhaltung 1")
          APPEND VALUE #( valuation_view = <cv>-valutyp            " DOMÄNE VALUTYP: 0  - Legale Bewertung, 1 - Konzernbewertung, 2 - Profit-Center-Bewertung
                          curr_type      = <cv>-cvtyp              " 10 - Buchungskreiswährung, 30 - Konzernwährung, 31 - Konzernwährung, Konzernbewertung
                          currency       = p_waers                 " EUR
                          currency_iso   = lv_iso                  " EUR -> 978
                          price_unit     = 1                       " Preiseinheit aus MBEW-BWPEI
                          price          = p_price ) TO it_prices. " Preis ggf. aus MBEW-VERPR
        ENDLOOP.

* Materialpreis-Änderungsbeleg
        DATA: lv_pricechangedocument TYPE bapi_pricechange_document.
* Fehlermeldungen des BAPIs
        DATA(it_bapiret2) = VALUE bapiret2_t( ).

* Materialpreis-Änderung
* Voraussetzung ist Pflege der Materialbewertung zum Materialstamm
        CALL FUNCTION 'BAPI_MATVAL_PRICE_CHANGE'
          EXPORTING
            material            = CONV bapi_matval_key-material( p_matnr ) " MARA-MATNR
            valuationarea       = lv_valuationarea                         " MBEW-BWKEY
            valuationtype       = lv_valuationtype                         " MBEW-BWTAR
            pricedate           = lv_pricedate
            doc_header_text     = lv_doc_header_text
          IMPORTING
            pricechangedocument = lv_pricechangedocument
          TABLES
            prices              = it_prices
            return              = it_bapiret2.

        IF lines( it_bapiret2 ) > 0.
          IF it_bapiret2[ 1 ]-type CA 'EAX'.
* bei Fehler: Rollback
            CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
          ELSE.
            DATA(lv_return) = VALUE bapiret2( ).
* alles ok: COMMIT
            CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
              EXPORTING
                wait   = abap_true
              IMPORTING
                return = lv_return.
          ENDIF.
        ENDIF.

        cl_demo_output=>write_data( p_matnr ).
        cl_demo_output=>write_data( p_bwkey ).
        cl_demo_output=>write_data( lv_pricedate ).
        cl_demo_output=>write_data( lv_doc_header_text ).
        cl_demo_output=>write_data( it_prices ).
        cl_demo_output=>write_data( lv_pricechangedocument ).
        cl_demo_output=>write_data( it_bapiret2 ).
        cl_demo_output=>write_data( lv_return ).

* 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       = 'Daten'
                                              html_string = lv_html
                                              container   = cl_gui_container=>default_screen ).

* cl_gui_container=>default_screen erzwingen
        WRITE: space.
      ENDIF.
    ENDIF.
  ENDIF.

[ABAP] Übernahme von Dokumenteninfosätzen beim Anlegen von Einkaufsbelegen unterdrücken

Das Beispiel zeigt, wie die Übernahme der Dokumenteninfosätze beim Anlegen einer neuen Bestellung aus einem Kontrakt unterdrückt werden kann.

* Programm: SAPLMEPO
* INCLUDE: LMEPOF7X
* FORM mepo_documents_copy (handles PO, contract and RFQ only; no requisitions)
* Implizites Enhancement
ENHANCEMENT 1  Z_YOUR_ENH_NAME.

* wenn Bestell-Belegart = 'NB' und Quelle ein Kontrakt
IF im_nekko-bsart EQ 'NB' AND NOT im_nekko-konnr IS INITIAL.
* Abbruch der Übernahme der DI in die neue Bestellung
  EXIT.
ENDIF.

ENDENHANCEMENT.

[ABAP] Retourenumlagerungsbestellungen lesen

* Bestellung
PARAMETERS: p_ebeln TYPE ekko-ebeln.

START-OF-SELECTION.

* Retourenumlagerungsbestellungen zur Bestellung lesen
  SELECT FROM ekko AS e
    INNER JOIN ekpo AS p ON ( e~ebeln EQ p~ebeln )
* Verwendung von CAST und substring, da Belegposition unterschiedliche Typen (NUMC5 und NUMC10) verwendet
    INNER JOIN msr_d_executed AS r ON ( p~ebeln EQ r~ref_doc_nr ) AND ( CAST( p~ebelp AS CHAR ) EQ substring( CAST( r~ref_doc_item AS CHAR ), 6, 5 ) )
  FIELDS DISTINCT
      e~ebeln,
      p~ebelp,
      p~matnr,
      p~txz01,
      p~menge,
      p~meins,
      p~netpr,
      r~doc_nr,
      r~doc_item
  WHERE e~ebeln EQ @p_ebeln
  INTO TABLE @DATA(it_ebeln).

  IF sy-subrc = 0.
    cl_demo_output=>write_data( it_ebeln ).
    DATA(lv_html) = cl_demo_output=>get( ).
    cl_abap_browser=>show_html( EXPORTING title       = 'Daten'
                                          html_string = lv_html
                                          container   = cl_gui_container=>default_screen ).

    WRITE: space.
  ENDIF.

Links

[ABAP] Geschäftspartner: Adressdaten lesen

PARAMETERS: p_bp TYPE bapibus1006_head-bpartner.

DATA: lv_bapibus1006_address TYPE bapibus1006_address.
DATA: lv_bapibus1006_addr_dep_att TYPE bapibus1006_addr_dep_att.
DATA: it_bapiadtel TYPE STANDARD TABLE OF bapiadtel.
DATA: it_bapiadfax TYPE STANDARD TABLE OF bapiadfax.
DATA: it_bapiadttx TYPE STANDARD TABLE OF bapiadttx.
DATA: it_bapiadtlx TYPE STANDARD TABLE OF bapiadtlx.
DATA: it_bapiadsmtp TYPE STANDARD TABLE OF bapiadsmtp.
DATA: it_bapiadrml TYPE STANDARD TABLE OF bapiadrml.
DATA: it_bapiadx400 TYPE STANDARD TABLE OF bapiadx400.
DATA: it_bapiadrfc TYPE STANDARD TABLE OF bapiadrfc.
DATA: it_bapiadprt TYPE STANDARD TABLE OF bapiadprt.
DATA: it_bapiadssf TYPE STANDARD TABLE OF bapiadssf.
DATA: it_bapiaduri TYPE STANDARD TABLE OF bapiaduri.
DATA: it_bapiadpag TYPE STANDARD TABLE OF bapiadpag.
DATA: it_bapiad_rem TYPE STANDARD TABLE OF bapiad_rem.
DATA: it_bapicomrem TYPE STANDARD TABLE OF bapicomrem.
DATA: it_addressusage TYPE STANDARD TABLE OF bapibus1006_addressusage.
DATA: it_bapiadversorg TYPE STANDARD TABLE OF bapiad1vd.
DATA: it_bapiadverspers TYPE STANDARD TABLE OF bapiad2vd.
DATA: it_bapiaduse TYPE STANDARD TABLE OF bapiaduse.
DATA: it_return TYPE STANDARD TABLE OF bapiret2.

* SAP-GP, BAPI: Adresse lesen
CALL FUNCTION 'BAPI_BUPA_ADDRESS_GETDETAIL'
  EXPORTING
    businesspartner       = p_bp
*   ADDRESSGUID           =
*   VALID_DATE            = SY-DATLO
*   RESET_BUFFER          =
  IMPORTING
    addressdata           = lv_bapibus1006_address
    address_dep_attr_data = lv_bapibus1006_addr_dep_att
  TABLES
    bapiadtel             = it_bapiadtel
    bapiadfax             = it_bapiadfax
    bapiadttx             = it_bapiadttx
    bapiadtlx             = it_bapiadtlx
    bapiadsmtp            = it_bapiadsmtp
    bapiadrml             = it_bapiadrml
    bapiadx400            = it_bapiadx400
    bapiadrfc             = it_bapiadrfc
    bapiadprt             = it_bapiadprt
    bapiadssf             = it_bapiadssf
    bapiaduri             = it_bapiaduri
    bapiadpag             = it_bapiadpag
    bapiad_rem            = it_bapiad_rem
    bapicomrem            = it_bapicomrem
    addressusage          = it_addressusage
    bapiadversorg         = it_bapiadversorg
    bapiadverspers        = it_bapiadverspers
    bapiaduse             = it_bapiaduse
    return                = it_return.

cl_demo_output=>write_data( lv_bapibus1006_address ).
cl_demo_output=>write_data( lv_bapibus1006_addr_dep_att ).
cl_demo_output=>write_data( it_bapiadtel ).
cl_demo_output=>write_data( it_bapiadfax ).
cl_demo_output=>write_data( it_bapiadtlx ).
cl_demo_output=>write_data( it_bapiadsmtp ).
cl_demo_output=>write_data( it_bapiadrml ).
cl_demo_output=>write_data( it_bapiadx400 ).
cl_demo_output=>write_data( it_bapiadrfc ).
cl_demo_output=>write_data( it_bapiadprt ).
cl_demo_output=>write_data( it_bapiadssf ).
cl_demo_output=>write_data( it_bapiaduri ).
cl_demo_output=>write_data( it_bapiadpag ).
cl_demo_output=>write_data( it_bapiad_rem ).
cl_demo_output=>write_data( it_bapicomrem ).
cl_demo_output=>write_data( it_addressusage ).
cl_demo_output=>write_data( it_bapiadversorg ).
cl_demo_output=>write_data( it_bapiadverspers ).
cl_demo_output=>write_data( it_bapiaduse ).
cl_demo_output=>write_data( it_return ).
cl_demo_output=>display( ).

[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] Leistungstammsatz anlegen

DATA: lv_service  TYPE bapisrv_asmd.
DATA: lv_servicex TYPE bapisrv_asmdx.
DATA: it_bapiret2 TYPE STANDARD TABLE OF bapiret2 WITH DEFAULT KEY.

lv_service-service           = '1234567890'. " Leistungsnummer
lv_service-matl_group        = '10000000'.   " Warengruppe
lv_service-base_uom          = 'ST'.         " Basismengeneinheit
lv_service-serv_cat          = 'SERV'.       " Leistungstyp
lv_service-val_class         = '1000'.       " Bewertungsklasse
lv_service-master_langu      = sy-langu.     " Sprache
lv_service-master_langu_iso  = cl_i18n_languages=>sap1_to_sap2( im_lang_sap1 = lv_service-master_langu ).

lv_servicex-service          = lv_service-service.
lv_servicex-matl_group       = abap_true.
lv_servicex-base_uom         = abap_true.
lv_servicex-serv_cat         = abap_true.
lv_servicex-val_class        = abap_true.
lv_servicex-master_langu     = abap_true.
lv_servicex-master_langu_iso = abap_true.

DATA it_shorttext TYPE STANDARD TABLE OF bapisrv_asmdt WITH DEFAULT KEY.

it_shorttext = VALUE #( ( language     = lv_service-master_langu
                          language_iso = lv_service-master_langu_iso
                          short_text   = 'Kurztext'
                          change_id    = 'I' ) ).

DATA(it_longtext) = VALUE srv_sm_text_tty( ( language     = sy-langu
                                             language_iso = cl_i18n_languages=>sap1_to_sap2( im_lang_sap1 = sy-langu )
                                             format       = '/'
                                             line         = 'Langtext'
                                             change_id    = 'I' ) ).

CALL FUNCTION 'BAPI_SERVICE_CREATE'
  EXPORTING
    im_service_data     = lv_service
    im_service_datax    = lv_servicex
    testrun             = ''
  TABLES
    return              = it_bapiret2
    service_description = it_shorttext
    service_long_texts  = it_longtext.

TRY.
    IF lines( it_bapiret2 ) > 0.
      IF it_bapiret2[ 1 ]-type CA 'EAX'.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      ENDIF.
    ENDIF.
  CATCH cx_sy_itab_line_not_found.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDTRY.

cl_demo_output=>write_data( lv_service ).
cl_demo_output=>write_data( lv_servicex ).
cl_demo_output=>write_data( it_shorttext ).
cl_demo_output=>write_data( it_longtext ).
cl_demo_output=>write_data( it_bapiret2 ).

* 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        = 'Leistungsstammsatz'
                              html_string  = lv_html
                              container    = cl_gui_container=>default_screen ).

* cl_gui_container=>default_screen erzwingen
WRITE: space.

[ABAP] Leistungstammsatz lesen

PARAMETERS: p_srv_nr TYPE asmd-asnum. "bapisrvpar-service.

START-OF-SELECTION.
  DATA: lv_service_info TYPE bapisrv.
  DATA: it_servicetextlines TYPE STANDARD TABLE OF bapisrvtxt WITH DEFAULT KEY.
  DATA: it_bapiret2 TYPE STANDARD TABLE OF bapiret2 WITH DEFAULT KEY.

  CALL FUNCTION 'BAPI_SERVICE_GET_DETAIL'
    EXPORTING
      servicenumber      = p_srv_nr
    IMPORTING
      servicegeneraldata = lv_service_info
    TABLES
      servicetextlines   = it_servicetextlines
      return             = it_bapiret2.

  cl_demo_output=>write_data( p_srv_nr ).
  cl_demo_output=>write_data( lv_service_info ).
  cl_demo_output=>write_data( it_servicetextlines ).
  cl_demo_output=>write_data( it_bapiret2 ).

* 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        = 'Leistungsstammsatz'
                                html_string  = lv_html
                                container    = cl_gui_container=>default_screen ).

* cl_gui_container=>default_screen erzwingen
  WRITE: space.

[ABAP] Fixkontentabelle (T030) auslesen

* Kontenplan
DATA: lv_ktopl TYPE ktopl.
* Vorgangsschlüssel
DATA: lv_ktosl TYPE ktosl.
* Bewertungsmodifikationskonstante
DATA: lv_bwmod TYPE bwmod.
* Konto-Modifikation
DATA: lv_komok TYPE komok.
* Bewertungsklasse
DATA: lv_bklas TYPE bklas.
* Nummer des Sachkontos
DATA: lv_konts TYPE saknr.
* Nummer des Sachkontos
DATA: lv_konth TYPE saknr.

SELECT-OPTIONS: so_ktopl FOR lv_ktopl.
SELECT-OPTIONS: so_ktosl FOR lv_ktosl.
SELECT-OPTIONS: so_bwmod FOR lv_bwmod.
SELECT-OPTIONS: so_komok FOR lv_komok.
SELECT-OPTIONS: so_bklas FOR lv_bklas.
SELECT-OPTIONS: so_konts FOR lv_konts.
SELECT-OPTIONS: so_konth FOR lv_konts.

START-OF-SELECTION.

* T030 (Fixkontentabelle)
  SELECT *
    INTO TABLE @DATA(it_t030)
    FROM t030
    WHERE ktopl IN @so_ktopl.
*      ktosl IN @so_ktosl
*      bwmod IN @so_bwmod
*      komok IN @so_komok
*      bklas IN @so_bklas
*      konts IN @so_konts
*      konth IN @so_konth.

  IF sy-subrc = 0.
    TRY.
        DATA: o_salv TYPE REF TO cl_salv_table.

        cl_salv_table=>factory( EXPORTING
                                  r_container  = cl_gui_container=>default_screen
                                IMPORTING
                                  r_salv_table = o_salv
                                CHANGING
                                  t_table      = it_t030 ).

        o_salv->get_display_settings( )->set_striped_pattern( abap_true ).
        o_salv->get_columns( )->set_optimize( abap_true ).
        o_salv->get_functions( )->set_all( ).
        o_salv->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).
        o_salv->display( ).

        WRITE: / space.
      CATCH cx_root INTO DATA(e_text).
        WRITE: / e_text->get_text( ).
    ENDTRY.
  ENDIF.