demo 代码 仅供参考
涉及函数
RV_CONDITION_RESET
RV_CONDITION_COPY
RV_CONDITION_SAVE
CONSTANTS: lc_code_svd1 TYPE kschl VALUE 'SVD1',lc_mwst TYPE kschl VALUE 'MWST',lc_cn TYPE aland VALUE 'CN',lc_valid_to TYPE datum VALUE '99991231',lc_kappl_sales TYPE kappl VALUE 'V',lc_rmb TYPE konwa VALUE 'RMB',lc_tabnr TYPE t681-kotabnr VALUE '850',lc_sy04 TYPE vkorg VALUE 'SY04',lc_sy05 TYPE werks_d VALUE 'SY05',lc_uom_pc TYPE char2 VALUE 'ST'.DATA: ls_wa_komk TYPE komk,ls_wa_komp TYPE komp,ls_wa_komg TYPE komg,lt_komv TYPE TABLE OF komv,lv_amt TYPE /dsd/me_act_qty. "MOD-0004* Build Condtion DataLOOP AT lt_out INTO DATA(ls_out). "#EC CI_LOOP_CLEAR
* Condition headerls_wa_komk-mandt = sy-mandt.ls_wa_komk-vkorg = lc_sy04.ls_wa_komk-kappl = lc_kappl_sales."Vls_wa_komk-erdat = sy-datum.* Condition Positionls_wa_komp-kposn = 1.ls_wa_komp-esokz = 0. "#EC CI_CLEAR_INITls_wa_komg-mandt = sy-mandt.ls_wa_komg-vkorg = lc_sy04."SALES ORG -SY04ls_wa_komg-vhvin = ls_out-vhvin.ls_wa_komg-esokz = 0. "#EC CI_CLEAR_INITAPPEND INITIAL LINE TO lt_komv ASSIGNING FIELD-SYMBOL(<ls_komv>).<ls_komv>-mandt = sy-mandt.<ls_komv>-kappl = lc_kappl_sales.<ls_komv>-kschl = lc_code_svd1. "SVD1READ TABLE lt_aai INTO DATA(ls_aai)WITH KEY account = ls_out-accountsequence = ls_out-sequence BINARY SEARCH.IF sy-subrc EQ 0.<ls_komv>-kbetr = ls_aai-discountc.IF lv_kbetr NE 0.
*MOD-0004 begin
* <ls_komv>-kbetr = 0 - <ls_komv>-kbetr / lv_kbetr.lv_amt = 0 - <ls_komv>-kbetr / lv_kbetr.<ls_komv>-kbetr = lv_amt.
*MOD-0004 endENDIF.READ TABLE lt_a850 INTO DATA(ls_a850)WITH KEY vhvin = ls_out-vhvin BINARY SEARCH.IF sy-subrc EQ 0.READ TABLE lt_konp INTO DATA(ls_konp)WITH KEY knumh = ls_a850-knumh BINARY SEARCH.IF sy-subrc EQ 0 AND ls_konp-kbetr EQ <ls_komv>-kbetr.CONTINUE.ENDIF.ENDIF."MOD-0003 BeginELSE.CONTINUE."MOD-0003 EndENDIF.<ls_komv>-waers = lc_rmb.<ls_komv>-kpein = 1.<ls_komv>-kmein = lc_uom_pc.<ls_komv>-kopos = 01.* Post ConditionsCALL FUNCTION 'RV_CONDITION_RESET'." create price recordCALL FUNCTION 'RV_CONDITION_COPY'EXPORTINGapplication = lc_kappl_salescondition_table = lc_tabnrcondition_type = lc_code_svd1date_from = sy-datumdate_to = lc_valid_toi_komk = ls_wa_komki_komp = ls_wa_kompkey_fields = ls_wa_komgmaintain_mode = /sapmp/if_char_1=>cano_authority_check = /sapmp/if_char_1=>c_falseno_field_check = /sapmp/if_char_1=>c_truekeep_old_records = /sapmp/if_char_1=>c_falseused_by_idoc = /sapmp/if_char_1=>c_falseoverlap_confirmed = /sapmp/if_char_1=>c_trueIMPORTINGe_komk = ls_wa_komke_komp = ls_wa_kompTABLEScopy_records = lt_komvEXCEPTIONSenqueue_on_record = 1invalid_application = 2invalid_condition_number = 3invalid_condition_type = 4no_authority_ekorg = 5no_authority_kschl = 6no_authority_vkorg = 7no_selection = 8table_not_valid = 9no_material_for_settlement = 10no_unit_for_period_cond = 11no_unit_reference_magnitude = 12invalid_condition_table = 13OTHERS = 99.IF sy-subrc <> 0.
* Implement suitable error handling hereMESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgnoWITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.ELSE." commit .CALL FUNCTION 'RV_CONDITION_SAVE'.COMMIT WORK AND WAIT.ENDIF.CLEAR: ls_wa_komk,ls_wa_komp,ls_wa_komg,lt_komv .ENDLOOP.