[ABAP] MM: Preiskonditionen für Material ändern

TYPES: ty_it_copy_records TYPE STANDARD TABLE OF komv WITH DEFAULT KEY.

DATA(lv_komg) = VALUE komg( bukrs = '0001'       " Buchungskreis (Tabelle T001)
                            matnr = '1234567890' " Materialnummer
                            vkorg = '0100'       " Verkaufsorganisation (Tabelle TVKO)
                            vtweg = '01'         " Vertriebsweg (Tabelle TVTW)
                          ).

DATA(it_copy_records) = VALUE ty_it_copy_records( ( kappl = 'V'     " Applikation: V - Vertrieb (Tabelle T681A / T681B)
                                                    kschl = 'PR00'  " Konditionsart (Tabelle T685)
                                                    kbetr = '10.00' " Konditionsbetrag oder -prozentsatz
                                                    waers = 'EUR'   " Konditionseinheit (Währung oder Prozentsatz) (Tabelle TCURC)
                                                    kpein = '1'     " Konditions-Preiseinheit
                                                    kmein = 'ST'    " Konditionsmengeneinheit (Tabelle T006)
                                                ) ).

DATA: lv_datab TYPE vake-datab.
DATA: lv_datbi TYPE vake-datbi.
DATA: lv_prdat TYPE vake-datbi.

CALL FUNCTION 'RV_CONDITION_COPY'
  EXPORTING
    application                 = 'V'        " Applikation: V - Vertrieb (Tabelle T681A / T681B)
    date_from                   = sy-datum   " von Datum
    date_to                     = '99991231' " max. Datum für Konditionen
    condition_table             = '004'      " Konditionstabelle (Tabelle T681)
    condition_type              = 'PR00'     " Konditionsart (Tabelle T685)
    enqueue                     = abap_true  " Lock
    key_fields                  = lv_komg    " Schlüsselfelder
    maintain_mode               = 'A'        " Modus (A - Anlegen, B - Ändern, C - Anzeigen, D - Anlegen mit Vorlage)
    overlap_confirmed           = abap_true  " automatische Bestätigung bei Zeitraumüberlappung
    no_authority_check          = abap_true  " keine Berechtigungprüfung durchführen
  IMPORTING
    e_datab                     = lv_datab
    e_datbi                     = lv_datbi
    e_prdat                     = lv_prdat
  TABLES
    copy_records                = it_copy_records
  EXCEPTIONS
    enqueue_on_record           = 1
    invalid_application         = 2
    invalid_condition_number    = 3
    invalid_condition_type      = 4
    no_authority_ekorg          = 5
    no_authority_kschl          = 6
    no_authority_vkorg          = 7
    no_selection                = 8
    table_not_valid             = 9
    no_material_for_settlement  = 10
    no_unit_for_period_cond     = 11
    no_unit_reference_magnitude = 12
    invalid_condition_table     = 13
    OTHERS                      = 14.

IF sy-subrc = 0.
  CALL FUNCTION 'RV_CONDITION_SAVE'.
  CALL FUNCTION 'RV_CONDITION_RESET'.
  COMMIT WORK.

  WRITE: / lv_datab.
  WRITE: / lv_datbi.
  WRITE: / lv_prdat.
ENDIF.

Weiterführende Infos: Link