Skip to Content
Author's profile photo Former Member

RV_CONDITION_COPY Example with Scales

I have seen many people had question about creating scales prices using the function module RV_CONDITION_COPY. However I did not find the answer.

The below sample code will help you load the sales prices including scales. Hope this hepls 🙂 .

***********************************************************************************

* This sample program can create sales price including scales.
* Author: Murali Mikkili

REPORT zz_apct_upload_new_cond_fm.

*- Data
DATA: cr LIKE TABLE OF komv WITH HEADER LINE,
      key_fields LIKE TABLE OF komg WITH HEADER LINE,
      ls_komk TYPE komk,
      ls_komp TYPE komp,
      copy_staffel LIKE TABLE OF condscale WITH HEADER LINE,
      lt_knumh   TYPE STANDARD TABLE OF knumh_comp,
      t_komv_idoc LIKE TABLE OF komv_idoc WITH HEADER LINE.

*- Fill Key fields
CALL FUNCTION ‘SD_CONDITION_KOMG_FILL’
  EXPORTING
    p_kotabnr = ‘304’
    p_kvewe   = ‘A’
    p_vakey   = ‘100010F-01’
  IMPORTING
    p_komg    = key_fields.

*- Fill KOMK
MOVE-CORRESPONDING key_fields TO ls_komk.
ls_komkmandt = symandt.

*- Fill KOMP
MOVE-CORRESPONDING key_fields TO ls_komp.
ls_kompkposn = ‘000001’.

*- Fill KOMV_IDOC
t_komv_idockznep = ‘X’.

APPEND t_komv_idoc.

*- Fill KOMV
crkappl = ‘V’.
crkschl = ‘PR00’.
crkbetr = ’21’. ” Unit Price
crkrech = ‘C’.
crkpein = ‘1’.
crkmein = ‘EA’.
crwaers = ‘EUR’.
crknumh = ‘$000000001’.
crmandt = symandt.

* Bellow are the important fields in KOMV for scales.
crkopos = 1.
crkzbzg = ‘C’.
crkonms = ‘EA’.
crstfkz = ‘A’.
APPEND cr.

* – Fill Scales
*- Scale Item 1
copy_staffelklfn1      = ‘0001’.
copy_staffelkopos      = ’01’.
copy_staffelkstbm      = ‘1’.
copy_staffelkbetr      = ’21’. ” Scale Price
copy_staffelkzbzg      = ‘C’.
copy_staffelrv13akonwa = ‘EUR’.
copy_staffelkonpkmein  = ‘EA’.
copy_staffelkonpkonms  = ‘EA’.
APPEND copy_staffel.

*- Scales item 2
copy_staffelklfn1      = ‘0002’.
copy_staffelkopos      = ’01’.
copy_staffelkstbm      = ’10’.
copy_staffelkbetr      = ’18’. ” Scale Price
copy_staffelkzbzg      = ‘C’.
copy_staffelrv13akonwa = ‘EUR’.
copy_staffelkonpkmein  = ‘EA’.
copy_staffelkonpkonms  = ‘EA’.
APPEND copy_staffel.

*- Scales item 3
copy_staffelklfn1      = ‘0003’.
copy_staffelkopos      = ’01’.
copy_staffelkstbm      = ’10’.
copy_staffelkbetr      = ’14’. ” Scale Price
copy_staffelkzbzg      = ‘C’.
copy_staffelrv13akonwa = ‘EUR’.
copy_staffelkonpkmein  = ‘EA’.
copy_staffelkonpkonms  = ‘EA’.
APPEND copy_staffel.

CALL FUNCTION ‘RV_CONDITION_COPY’
  EXPORTING
    application              = ‘V’
    condition_table          = ‘304’
    condition_type           = ‘PR00’
    date_from                = ‘20131101’
    date_to                  = ‘99991231’
    enqueue                  = ‘X’
    i_komk                   = ls_komk
    i_komp                   = ls_komp
    key_fields               = key_fields
    maintain_mode            = ‘A’
    no_authority_check       = ‘X’
*    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             = cr
    copy_staffel             = copy_staffel
    copy_recs_idoc           = t_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.

BREAKPOINT.

CALL FUNCTION ‘RV_CONDITION_SAVE’
  TABLES
    knumh_map = lt_knumh.
CALL FUNCTION ‘RV_CONDITION_RESET’.

COMMIT WORK AND WAIT.

Assigned Tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Murli,

      We have used your program and it works perfectly fine for create mode.

      The problem occurs when we are trying to update scales in Change mode.

      The program doesn't update any entry for scales when we execute it in

      MAINTAIN_MODE               = 'B'.

      But if we run the program with Maintain Mode A, it updates the scale but a new condition record no. is created.

      The same is visible in KONM table. That means if we update the scales using Mode A, we can see two entries for scales.

      Can you please help as to how can we update the scales using Mode B

      Author's profile photo Sumit Gupta
      Sumit Gupta

      Hi Ankit,

      Did you found any solution for your issue? I am facing the same.

      Regards

       

      Author's profile photo Janagar Sundaramoorthy
      Janagar Sundaramoorthy

      Hi Sumit,

      did you got any update on this..i am also really in need of knowing this.

       

      Regards

      S.Janagar

      Author's profile photo Marcelo M Bovo
      Marcelo M Bovo

      Hello,

      I faced the same problem and solved with a enhancement on the end of function RV_CONDITION_COPY.

      You have to fill the table/column staffel-updkz with 'U'. Bear in mind that the program will try to UPDATE the KONM row based on that table, so if the line with U doenst exist, you'll probably get an error.

      What I did is fill copy_staffel-updkz with U only on those lines that exist on KONM and on the enhancement I added the bellow code:

       

          loop at copy_staffel assigning field-symbol(<copy_staffel>).
      
            read table staffel assigning field-symbol(<staffel>) with key kopos = <copy_staffel>-kopos klfn1 = <copy_staffel>-klfn1.
            if <copy_staffel>-updkz is not initial and <copy_staffel>-updkz <> <staffel>-updkz.
              <staffel>-updkz = <copy_staffel>-updkz.
            endif.
      
          endloop.

       

       

       

      Author's profile photo Dev1 Train1
      Dev1 Train1

      How about deleting scales?