Folgende Bausteine sind ab S/4 HANA verfügbar:
Variante 1 (Anlegen und ändern eines Infosatzes)
* Neuen Infosatz anlegen? PARAMETERS: lv_creat TYPE abap_bool DEFAULT abap_true. * Testlauf? PARAMETERS: lv_test TYPE abap_bool DEFAULT abap_true. * Nummer des Einkaufsinfosatzes PARAMETERS: lv_infnr TYPE infnr. * Materialnummer PARAMETERS: lv_matnr TYPE matnr. * Lieferant PARAMETERS: lv_lifnr TYPE lifnr. * Basismengeneinheit PARAMETERS: lv_meins TYPE meins. * Bestellmengeneinheit PARAMETERS: lv_bstme TYPE bstme. * Zähler für die Umrechnung BPRME in BME PARAMETERS: lv_bpumz TYPE bpumz. * Nenner für die Umrechnung BPRME in BME PARAMETERS: lv_bpumn TYPE bpumn. * Einkaufsorganisation PARAMETERS: lv_ekorg TYPE ekorg. * Werk PARAMETERS: lv_werks TYPE werks. * Typ des Einkaufsinfosatzes * 0 Normal * 2 Konsignation * 3 Lohnbearbeitung * P Pipeline * 1 Chargeable PARAMETERS: lv_esokz TYPE esokz. * Planlieferzeit in Tagen PARAMETERS: lv_plifz TYPE plifz. * Einkäufergruppe PARAMETERS: lv_bkgrp TYPE bkgrp. * Umsatzsteuerkennzeichen PARAMETERS: lv_mwskz TYPE mwskz. START-OF-SELECTION. DATA(ls_eina) = VALUE mewieina( info_rec = lv_infnr material = lv_matnr vendor = lv_lifnr base_uom = lv_meins po_unit = lv_bstme conv_num1 = lv_bpumz conv_den1 = lv_bpumn ). DATA(ls_einax) = VALUE mewieinax( info_rec = lv_creat " neuen Infosatz anlegen? material = 'X' vendor = 'X' base_uom = 'X' po_unit = 'X' conv_num1 = 'X' conv_den1 = 'X' ). DATA(ls_eine) = VALUE mewieine( info_rec = lv_infnr purch_org = lv_ekorg plant = lv_werks info_type = lv_esokz conv_num1 = lv_bpumz conv_den1 = lv_bpumn plnd_delry = lv_plifz pur_group = lv_bkgrp tax_code = lv_mwskz ). DATA(ls_einex) = VALUE mewieinex( info_rec = lv_creat " neuen Infosatz anlegen? purch_org = 'X' plant = 'X' info_type = 'X' conv_num1 = 'X' conv_den1 = 'X' plnd_delry = 'X' pur_group = 'X' tax_code = 'X' ). DATA(it_return) = VALUE mewi_t_return( ). * RFC Function Module to Create and Change Info Record CALL FUNCTION 'ME_INFORECORD_MAINTAIN' EXPORTING i_eina = ls_eina i_einax = ls_einax i_eine = ls_eine i_einex = ls_einex testrun = lv_test * IMPORTING * E_EINA = * E_EINE = TABLES * TXT_LINES = * COND_VALIDITY = * CONDITION = * COND_SCALE_VALUE = * COND_SCALE_QUAN = return = it_return. * Fehlerauswertung DATA(lv_message) = ||. LOOP AT it_return INTO DATA(ls_return) WHERE type CA 'AEX'. IF lv_message IS INITIAL. lv_message = ls_return-message. ELSE. lv_message = |{ lv_message }/{ ls_return-message }|. ENDIF. ENDLOOP. IF lv_message IS INITIAL. DATA(lv_return) = VALUE bapiret2( ). * alles ok: COMMIT CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = lv_return. ELSE. * bei Fehlern: ROLLBACK CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. ENDIF.
Variante 2 (Anlegen und ändern mehrerer Infosätze)
* https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=533669791 * SAP Note: 2492873 (Verbesserung im Beschaffungsprozess zur Pflege mehrerer Infosätze zusammen mit Konditionen) * https://launchpad.support.sap.com/#/notes/2492873 * RFC Function Module to Create and Change multiple Info Records CALL FUNCTION 'ME_INFORECORD_MAINTAIN_MULTI' * EXPORTING * TESTRUN = * IMPORTING * ET_EINA = * ET_EINE = * TABLES * T_EINA = * T_EINAX = * T_EINE = * T_EINEX = * TXT_LINES = * COND_VALIDITY = * CONDITION = * COND_SCALE_VALUE = * COND_SCALE_QUAN = * RETURN = . DATA(lv_return) = VALUE bapiret2( ). * Daten verbuchen CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = abap_true IMPORTING return = lv_return. WRITE: / |COMMIT [{ lv_return-type } { lv_return-number }]: { lv_return-message }|.
Variante 3 (DMC_MIG_PURCH_INFO_RECORD)
DATA(lv_test) = abap_true. DATA(ls_eina) = VALUE eina( ). DATA: it_eine TYPE STANDARD TABLE OF eine WITH DEFAULT KEY. * Migration of purchasing info record * kapselt folgende Funktionsbausteine * ME_INITIALIZE_INFORECORD * ME_MAINTAIN_INFORECORD * ME_POST_INFORECORD CALL FUNCTION 'DMC_MIG_PURCH_INFO_RECORD' EXPORTING * ACTIVITY = 'H' " V - update, H - create i_eina = ls_eina * I_EINE = * O_EINA = * O_EINE = * I_VORGA = 'B' " Kennung für die Anwendung, die den Funktionsbaustein aufruft: A - Integrierte Artikelpflege, B - ALE testrun = lv_test * IMPORTING * E_EINA = * E_EINE = TABLES * T_HEAD = * T_LINE = t_eine = it_eine.