cancel
Showing results for 
Search instead for 
Did you mean: 

Function Module RV_CONDITION_COPY for creating without scales pricing

former_member225253
Participant
0 Kudos

Hi ABAP experts / SD experts ,

Greetings for the day ahead .

I am using function moudule RV_CONDITION_COPY for creating without scales pricing and my code is also updating SCALES ARE MAINTAINED flag in VK13 . Screenshot for Reference and code used attached .

I donot want the SCALES flag to be 'X' but should be Blank . What parameter i should pass in code OR what approach should i Try .

Would be grateful for your Replies .

Thanks and Rgds ,

Devendra Singh

Code Snippet

  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 .

Accepted Solutions (1)

Accepted Solutions (1)

JL23
Active Contributor
0 Kudos

why do you a coding for scales if you don't want scales?

former_member225253
Participant
0 Kudos

Thanks Jurgen . Resolved . Actually i was using previously written scales code for without scales .the Fill scales part has to commented .

Best Regards ,

Devendra Singh

Answers (2)

Answers (2)

Janagar
Explorer
0 Kudos

@https://answers.sap.com/users/172/jrgenlins.html

I just want to update the scales in maintenance mode, but scale prices are not getting updated.

i am passing KNUMH value to condition line

Keep old records = 'X'.

updkz = 'X' in condition structure

Still not working any guess what could be the issue.

0 Kudos

Hi

I have follow your code but lwa_cr-ZAEHK_IND not update in KONP.

Could you please help in this case?

Thank you.