Funktionsbaustein SD CUSTOMER MAINTAIN ALL
Aus SAP-Wiki
Zur Navigation springenZur Suche springen
. Siehe Kategorie: TP Funktionsbausteine.
Siehe Sammlung Funktionsbausteine.
Mit dem Funktionsbaustein SD_CUSTOMER_MAINTAIN_ALL kann man Geschäftspartner-Kunden anlegen und ändern.
Muster
CALL FUNCTION 'SD_CUSTOMER_MAINTAIN_ALL' * EXPORTING * I_KNA1 = * I_KNB1 = * I_KNVV = * I_BAPIADDR1 = * I_BAPIADDR2 = * I_MAINTAIN_ADDRESS_BY_KNA1 = ' ' * I_KNB1_REFERENCE = ' ' * I_FORCE_EXTERNAL_NUMBER_RANGE = ' ' * I_NO_BANK_MASTER_UPDATE = ' ' * I_CUSTOMER_IS_CONSUMER = ' ' * I_RAISE_NO_BTE = ' ' * PI_POSTFLAG = ' ' * PI_CAM_CHANGED = ' ' * PI_ADD_ON_DATA = * I_FROM_CUSTOMERMASTER = ' ' * IMPORTING * E_KUNNR = * O_KNA1 = * E_SD_CUST_1321_DONE = * TABLES * T_XKNAS = * T_XKNBK = * T_XKNB5 = * T_XKNVA = * T_XKNVD = * T_XKNVI = * T_XKNVK = * T_XKNVL = * T_XKNVP = * T_XKNZA = * T_YKNAS = * T_YKNBK = * T_YKNB5 = * T_YKNVA = * T_YKNVD = * T_YKNVI = * T_YKNVK = * T_YKNVL = * T_YKNVP = * T_YKNZA = * T_UPD_TXT = * EXCEPTIONS * CLIENT_ERROR = 1 * KNA1_INCOMPLETE = 2 * KNB1_INCOMPLETE = 3 * KNB5_INCOMPLETE = 4 * KNVV_INCOMPLETE = 5 * KUNNR_NOT_UNIQUE = 6 * SALES_AREA_NOT_UNIQUE = 7 * SALES_AREA_NOT_VALID = 8 * INSERT_UPDATE_CONFLICT = 9 * NUMBER_ASSIGNMENT_ERROR = 10 * NUMBER_NOT_IN_RANGE = 11 * NUMBER_RANGE_NOT_EXTERN = 12 * NUMBER_RANGE_NOT_INTERN = 13 * ACCOUNT_GROUP_NOT_VALID = 14 * PARNR_INVALID = 15 * BANK_ADDRESS_INVALID = 16 * TAX_DATA_NOT_VALID = 17 * NO_AUTHORITY = 18 * COMPANY_CODE_NOT_UNIQUE = 19 * DUNNING_DATA_NOT_VALID = 20 * KNB1_REFERENCE_INVALID = 21 * CAM_ERROR = 22 * OTHERS = 23 . IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. * Wenn Returntabelle gefüllt ist, liegt ein Fehler vor IF lines( lt_return ) > 0. * Rollback bei Fehler CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK' IMPORTING return = ls_return. IF ls_return IS NOT INITIAL. MESSAGE ID ls_return-id "Nachrichtenklasse TYPE 'I' "Typ (E = Error, S = Success, I = Info, A = Abbruch) NUMBER ls_return-number "Nachrichtennummer WITH ls_return-message_v1 "Platzhaltervariable1 ls_return-message_v2 "Platzhaltervariable2 ls_return-message_v3 "Platzhaltervariable3 ls_return-message_v4. "Platzhaltervariable4 ENDIF. * Wenn Returntabelle leer ist, ist alles ok und COMMIT WORK ELSE. * Daten verbuchen CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = abap_true IMPORTING return = ls_return. * Erfolgsmeldung MESSAGE i082(/isdfps/mm) WITH ls_headret-mat_doc "Materialbeleg &1/&2 erfolgreich gebucht. ls_headret-doc_year. IF ls_return IS NOT INITIAL. MESSAGE ID ls_return-id "Nachrichtenklasse TYPE 'I' "Typ (E = Error, S = Success, I = Info, A = Abbruch) NUMBER ls_return-number "Nachrichtennummer WITH ls_return-message_v1 "Platzhaltervariable1 ls_return-message_v2 "Platzhaltervariable2 ls_return-message_v3 "Platzhaltervariable3 ls_return-message_v4. "Platzhaltervariable4 ENDIF. ENDIF. ENDFORM.
Projektbeispiel
*&---------------------------------------------------------------------* *& Methode Funktionsbaustein SD_CUSTOMER_MAINTAIN_ALL *&---------------------------------------------------------------------* * Kundenstamm ändern bezüglich Steuerklassifikation *----------------------------------------------------------------------* METHOD sd_customer_maintain_all. CONSTANTS: lc_11 TYPE i VALUE 11, lc_12 TYPE i VALUE 12, lc_13 TYPE i VALUE 13, lc_14 TYPE i VALUE 14, lc_15 TYPE i VALUE 15, lc_16 TYPE i VALUE 16, lc_17 TYPE i VALUE 17, lc_18 TYPE i VALUE 18, lc_19 TYPE i VALUE 19, lc_20 TYPE i VALUE 20, lc_21 TYPE i VALUE 21, lc_22 TYPE i VALUE 22, lc_23 TYPE i VALUE 23. DATA: lv_count TYPE i, lv_uname type SYST_UNAME value 'JKUSKE', lv_erdat type syst_datum value '20191017'. LOOP AT mt_itab ASSIGNING FIELD-SYMBOL(<fs_itab>). ADD 1 TO lv_count. DATA(ls_kna1) = VALUE kna1( kunnr = <fs_itab>-kunnr ktokd = 'CUST' ). * 001, FFISCHER, 21.06.2021, XXX, Korrektur Füllen KNVV, da Bug im TEP. * Alle Felder KNVV im Produktiv wurden gecleart (Ausnahme Key), wenn nur * Feld Kundennummer, VKORG, VTWEG und SPART übergeben werden. DATA(ls_knvv) = VALUE knvv( kunnr = <fs_itab>-kunnr vkorg = mp_vkorg vtweg = mp_vtweg spart = mp_spart zterm = 'VK01' KALKS = '11' KDGRP = mp_kdgrp PLTYP = '03' INCO1 = 'CFR' INCO2 = 'Norderstedt' AUTLF = 'X' KZTLF = 'C' VSBED = '01' KTGRD = '03' KABSS = '0002' WAERS = 'GBP' ERNAM = lv_uname ERDAT = lv_erdat INCO2_L = 'Norderstedt' ). DATA(lt_xknvi) = VALUE fknvi_tab( ( mandt = sy-mandt kunnr = <fs_itab>-kunnr aland = mp_aland tatyp = mp_tatyp taxkd = mp_taxkd ) ). CALL FUNCTION 'SD_CUSTOMER_MAINTAIN_ALL' EXPORTING i_kna1 = ls_kna1 * I_KNB1 = I_KNB1 i_knvv = ls_knvv * I_BAPIADDR1 = I_BAPIADDR1 * I_BAPIADDR2 = I_BAPIADDR2 * I_MAINTAIN_ADDRESS_BY_KNA1 = ' ' * I_KNB1_REFERENCE = ' ' * I_FORCE_EXTERNAL_NUMBER_RANGE = ' ' * I_NO_BANK_MASTER_UPDATE = ' ' * I_CUSTOMER_IS_CONSUMER = ' ' * I_RAISE_NO_BTE = ' ' * PI_POSTFLAG = ' ' * PI_CAM_CHANGED = ' ' * PI_ADD_ON_DATA = PI_ADD_ON_DATA * I_FROM_CUSTOMERMASTER = ' ' * IMPORTING * E_KUNNR = E_KUNNR * O_KNA1 = O_KNA1 * E_SD_CUST_1321_DONE = E_SD_CUST_1321_DONE TABLES * T_XKNAS = T_XKNAS * T_XKNBK = T_XKNBK * T_XKNB5 = T_XKNB5 * T_XKNVA = T_XKNVA * T_XKNVD = T_XKNVD t_xknvi = lt_xknvi * T_XKNVK = T_XKNVK * T_XKNVL = T_XKNVL * T_XKNVP = T_XKNVP * T_XKNZA = T_XKNZA * T_YKNAS = T_YKNAS * T_YKNBK = T_YKNBK * T_YKNB5 = T_YKNB5 * T_YKNVA = T_YKNVA * T_YKNVD = T_YKNVD * T_YKNVI = T_YKNVI * T_YKNVK = T_YKNVK * T_YKNVL = T_YKNVL * T_YKNVP = T_YKNVP * T_YKNZA = T_YKNZA * T_UPD_TXT = T_UPD_TXT EXCEPTIONS client_error = 1 kna1_incomplete = 2 knb1_incomplete = 3 knb5_incomplete = 4 knvv_incomplete = 5 kunnr_not_unique = 6 sales_area_not_unique = 7 sales_area_not_valid = 8 insert_update_conflict = 9 number_assignment_error = 10 number_not_in_range = lc_11 number_range_not_extern = lc_12 number_range_not_intern = lc_13 account_group_not_valid = lc_14 parnr_invalid = lc_15 bank_address_invalid = lc_16 tax_data_not_valid = lc_17 no_authority = lc_18 company_code_not_unique = lc_19 dunning_data_not_valid = lc_20 knb1_reference_invalid = lc_21 cam_error = lc_22 OTHERS = lc_23. IF sy-subrc <> 0. DATA(lv_error) = abap_true. BREAK ffischer ##NO_BREAK ##USER_OK. ENDIF. ENDLOOP. IF lv_error = abap_true. ROLLBACK WORK. MESSAGE i531(0u) WITH 'Keine Änderungen vorgenommen'(002). ELSE. COMMIT WORK AND WAIT. MESSAGE i532(0u) WITH lv_count 'Updates in KNVI wurden vorgenommen'(003). ENDIF. ENDMETHOD.