Skip to Content
avatar image
Former Member

sales deal and promotion upload through Function Module RV_CONDITION_COPY

Hi ABAP experts / SD experts ,

Greetings for the day ahead .

I have a requirement to Upload sales deal (KONH - KNUMA_AG ) and promotion (

KONH - KNUMA_PI ) through already written code for Pricing by Function Module RV_CONDITION_COPY . This sales deal should be displayed in VB23 .

Experts , How to achieve this Programitically ?

If somebody has worked on similar Requirement , Kindly Guide .

Would be grateful for your Replies .

Thanks and Rgds ,

Devendra Singh

=============================================================

Screenshots for Reference .

On Clicking Right Mark

Code Written is as follows :

 CONSTANTS : lc_mode  TYPE char1 VALUE 'A',
              lc_kposn TYPE kposn VALUE '000001',
              lc_type  TYPE char1 VALUE 'E',
              lc_stype TYPE char1 VALUE 'S'.


  DATA : lv_kvewe   TYPE char1,
         lv_kotabnr TYPE char3.

  CLEAR : lv_kotabnr , lv_kvewe .

  DATA : lt_cr            TYPE TABLE OF komv,
         lwa_cr           TYPE komv,
         lwa_key_fields   TYPE komg,
         lwa_komk         TYPE komk,
         lwa_komp         TYPE komp,
         lt_copy_staffel  TYPE TABLE OF condscale,
         lwa_copy_staffel TYPE condscale,
         lt_knumh         TYPE STANDARD TABLE OF knumh_comp,
         lt_komv_idoc     TYPE TABLE OF komv_idoc,
         lwa_komv_idoc    TYPE komv_idoc.

  " condition records update row by row for without scales data
  LOOP AT gt_tabdata INTO  gwa_tabdata .

    gwa_tabdata-varkey = gwa_tabdata-dyn .
    MODIFY gt_tabdata FROM gwa_tabdata TRANSPORTING varkey .
    CLEAR : gwa_tabdata .

  ENDLOOP .

  lv_kotabnr = gv_table+1(3) .
  lv_kvewe   = gv_table+0(1) .

  LOOP AT  gt_tabdata INTO  gwa_tabdata .

*- Fill Key fields " " Filling a KOMG Structure According to KVEWE, KOTABNR, and VAKEY
    CALL FUNCTION 'SD_CONDITION_KOMG_FILL'
      EXPORTING
        p_kotabnr = '304'
        p_kvewe   = 'A'
        p_vakey   = gwa_tabdata-varkey
      IMPORTING
        p_komg    = lwa_key_fields.

    lwa_key_fields-kbstat = 'SM' .

*- Fill mandt for KOMK workarea
    lwa_komk-mandt = sy-mandt.

*- Fill kposn for KOMP workarea
    lwa_komp-kposn = '000001'

*- Fill KOMV_IDOC
    lwa_komv_idoc-kznep = ''.

    APPEND lwa_komv_idoc TO lt_komv_idoc.

*- Fill KOMV
    lwa_cr-kappl = 'V'.
    lwa_cr-kschl = 'PR00'.
    lwa_cr-kbetr = gwa_tabdata-amount . " Unit Price
    lwa_cr-krech = 'C'
    lwa_cr-kpein = 1 .
    lwa_cr-kmein = 'EA'.
    lwa_cr-waers = gwa_tabdata-unit.
    lwa_cr-knumh = '$000000001'.
    lwa_cr-mandt = sy-mandt.

* Below are the important fields in KOMV for scales.
    lwa_cr-kopos = 1.
    lwa_cr-kzbzg = 'C'.
    lwa_cr-konms = 'EA'.
    lwa_cr-stfkz = ''.

    APPEND lwa_cr TO lt_cr .

*     - Fill Scales
    lwa_copy_staffel-klfn1      = 1 .
    lwa_copy_staffel-kopos      = '01'.
    lwa_copy_staffel-kstbm      = '0.00' .
    lwa_copy_staffel-kbetr      = gwa_tabdata-amount . " Scale Price
    lwa_copy_staffel-kzbzg      = 'C' .
    lwa_copy_staffel-rv13akonwa = gwa_tabdata-unit .
    lwa_copy_staffel-konpkmein  = gwa_tabdata-cond_unit .
    lwa_copy_staffel-konpkonms  = gwa_tabdata-cond_unit .
    APPEND lwa_copy_staffel TO lt_copy_staffel.


    " condition upload for without scales values
    CALL FUNCTION 'RV_CONDITION_COPY'
      EXPORTING
        application              = gc_kappl
        condition_table          = lv_kotabnr
        condition_type           = p_kschl
        date_from                = gwa_tabdata_scale-valid_from
        date_to                  = gwa_tabdata_scale-valid_to
        enqueue                  = gc_flag
        i_komk                   = lwa_komk
        i_komp                   = lwa_komp
        key_fields               = lwa_key_fields
        maintain_mode            = lc_mode
        no_authority_check       = gc_flag
*       keep_old_records         = 'X'
        used_by_idoc             = 'X'      " when suppling scales prices, this flag must be X else price will be created with Zero price.
        overlap_confirmed        = 'X'
      TABLES
        copy_records             = lt_cr
        copy_staffel             = lt_copy_staffel
        copy_recs_idoc           = lt_komv_idoc
      EXCEPTIONS
        enqueue_on_record        = 01
        invalid_application      = 02
        invalid_condition_number = 03
        invalid_condition_type   = 04
        no_authority_ekorg       = 05
        no_authority_kschl       = 06
        no_authority_vkorg       = 07
        no_selection             = 08
        table_not_valid          = 09.

    CASE sy-subrc .
      WHEN 0 .
        CALL FUNCTION 'RV_CONDITION_SAVE'
          TABLES
            knumh_map = lt_knumh.
        CALL FUNCTION 'RV_CONDITION_RESET'.

        COMMIT WORK AND WAIT.

    ENDCASE .
1234.png (36.4 kB)
5678.png (25.4 kB)
9101112.png (48.7 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Aug 09, 2017 at 06:21 AM

    Perhaps, you need to rephrase your question. When you say some ABAP code is there, what is the challenge you have in uploading ?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 13, 2017 at 11:54 AM

    I found fields sales deal and promotion in Function Module structure and updated sales deal and promotion using the same successfully Programatically .

    Best Regards ,

    Devendra Singh

    Add comment
    10|10000 characters needed characters exceeded