VK11条件价格创建/更改/删除

Posted 想发财的小夏

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VK11条件价格创建/更改/删除相关的知识,希望对你有一定的参考价值。

在项目上要求对条件价格进行批导,在网上查阅相关资料,并记录。

使用BAPI_PRICES_CONDITONS对条件价格进行创建,并不会去检查主键,会有各种各样的Bug产生;
在网上找了另外一个Bapi:RV_CONDITION_COPY,使用后发现可以自动对区间进行拆分,不会产生主键重复的Bug,以下是源代码

FUNCTION zfmsd012.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     REFERENCE(IS_INPUT) TYPE  ZSSD027
*"  EXPORTING
*"     REFERENCE(ES_OUTPUT) TYPE  ZSSD025_RET
*"----------------------------------------------------------------------

  DATA:
    ls_key_fields   TYPE komg,
    lt_copy_records TYPE TABLE OF komv,
    ls_copy_records TYPE komv,
    lt_knumh_comp   TYPE TABLE OF knumh_comp,
    ls_knumh_comp   TYPE knumh_comp.

*  SELECT SINGLE matnr,meins
*    FROM mara
*    INTO @DATA(ls_mara)
*    WHERE matnr = @is_input-matnr.

  CLEAR: ls_key_fields.
  ls_key_fields-vkorg = is_input-vkorg.  " 销售组织
  ls_key_fields-vtweg = is_input-vtweg.  " 分销渠道
  ls_key_fields-kunnr = is_input-kunnr.  " 客户
  ls_key_fields-matnr = is_input-matnr.  " 物料号

  CLEAR ls_copy_records.
  " condtion fields
  ls_copy_records-kopos = '01'.           " 条件的序列号
  ls_copy_records-kschl = is_input-kschl. " 条件类型
  ls_copy_records-kappl = 'V'.            " 应用程序
  ls_copy_records-waers = is_input-konwa. " 货币码
  ls_copy_records-kmein = is_input-meins. " 单位
  ls_copy_records-kbetr = is_input-netpr. " 金额
  ls_copy_records-kpein = '10000'.        " 条件定价单位
  ls_copy_records-stfkz = 'A'.            " 等级类型
  ls_copy_records-krech = 'C'.            " 条件的计算类型
  APPEND ls_copy_records TO lt_copy_records.

  CALL FUNCTION 'RV_CONDITION_RESET'.
  CALL FUNCTION 'RV_CONDITION_COPY'
    EXPORTING
      application                 = 'V'
      condition_table             = '005'
      condition_type              = is_input-kschl
      date_from                   = is_input-datab
      date_to                     = is_input-datbi
      key_fields                  = ls_key_fields
      maintain_mode               = 'A'              "A:创建  B:更新
      overlap_confirmed           = 'X'
      used_by_idoc                = 'X'
      keep_old_records            = 'X'
*      IMPORTING
*     e_komk                      = ls_komk
*     e_komp                      = ls_komp
*     new_record                  = lv_record
    TABLES
      copy_records                = lt_copy_records
*     copy_staffel                = lt_copy_staffel
    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.
    " Commit and Get Condition NO.
    CALL FUNCTION 'RV_CONDITION_SAVE'
      TABLES
        knumh_map = lt_knumh_comp.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.

    CALL FUNCTION 'RV_CONDITION_RESET'.

    READ TABLE lt_knumh_comp INTO ls_knumh_comp INDEX 1.
    IF sy-subrc = 0 AND ls_knumh_comp-knumh_new IS NOT INITIAL.
      es_output-msg = ls_knumh_comp-knumh_new.
      es_output-type    = 'S'.
    ELSE.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
              INTO es_output-msg.
      es_output-type    = 'E'.
    ENDIF.
  ELSE.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
            INTO es_output-msg.
    es_output-type    = 'E'.
  ENDIF.

ENDFUNCTION.

以上是关于VK11条件价格创建/更改/删除的主要内容,如果未能解决你的问题,请参考以下文章

php 在Yoast SEO中更改或删除OpenGraph输出的代码片段。此代码中有多个代码段。

VK CUP 2017 CString Reconstruction

当sqlite android片段中的数据更改或删除时如何刷新recyclerview?

使用删除与隐藏时未调用自定义动画

Django REST框架--认证和权限

如何从活动中更改片段中视图的可见性