2013年5月31日 星期五

條件金額修改方法

  lw_komg-vkorg = sales org.
  lw_komg-vtweg = sale channel.
  lw_komg-matnr = Material number.
  lw_komg-werks = plant.

  lt_komv-kappl 'V'. "V = Sales and Distribution
  lt_komv-kschl = condition type.
  lt_komv-kbetr = amonut. "須先轉換為SAP儲存值
  lt_komv-waers = currency type.
  lt_komv-kpein 1.
  lt_komv-kmein 'BOX'.
  APPEND lt_komv.

  CASE r_ucomm.
    WHEN '&EXE'.
      CALL FUNCTION 'RV_CONDITION_COPY'
        EXPORTING
          application              'V'
          condition_table          '900'      " 3 character cond. table
          condition_type           = 'XXXX'   " cond. type
*          date_from                = '20120101' " valid on
*          date_to                  = '99991231' " valid to
          enqueue                  'X'        " lock entry
*          i_komk                   = komk
*          i_komp                   = komp
          key_fields               lw_komg    " key fields
          maintain_mode            'A'        " A= create " B= change, " C= display " D= create
          no_authority_check       'X'
*          selection_date           = '20120101' " valid on
          keep_old_records         ' '
          overlap_confirmed        'X'
*          no_db_update             = space
*        IMPORTING
*          e_komk                   = komk
*          e_komp                   = komp
*          new_record               = lv_new_record
        TABLES
          copy_records             lt_komv
        EXCEPTIONS
          enqueue_on_record        1
          invalid_application      2
          invalid_condition_number 3
          invalid_condition_type   4
          no_selection             5
          table_not_valid          6
          no_authority_ekorg       7
          no_authority_kschl       8.

      IF sy-subrc 0.
        CALL FUNCTION 'RV_CONDITION_SAVE'.

        COMMIT WORK.

*        CALL FUNCTION 'RV_CONDITION_RESET'.
*        如果還要繼續改下一筆,要重置條件,不然會出錯
*        "necessary to write data
*
*        COMMIT WORK.
      ELSE.
        PERFORM log_error_msg.
      ENDIF.

沒有留言:

張貼留言