Skip to Content

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.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Ankit Agarwal

    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

    (0) 

Leave a Reply