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_komk–mandt = sy–mandt.
*- Fill KOMP
MOVE-CORRESPONDING key_fields TO ls_komp.
ls_komp–kposn = ‘000001’.
*- Fill KOMV_IDOC
t_komv_idoc–kznep = ‘X’.
APPEND t_komv_idoc.
*- Fill KOMV
cr–kappl = ‘V’.
cr–kschl = ‘PR00’.
cr–kbetr = ’21’. ” Unit Price
cr–krech = ‘C’.
cr–kpein = ‘1’.
cr–kmein = ‘EA’.
cr–waers = ‘EUR’.
cr–knumh = ‘$000000001’.
cr–mandt = sy–mandt.
* Bellow are the important fields in KOMV for scales.
cr–kopos = 1.
cr–kzbzg = ‘C’.
cr–konms = ‘EA’.
cr–stfkz = ‘A’.
APPEND cr.
* – Fill Scales
*- Scale Item 1
copy_staffel–klfn1 = ‘0001’.
copy_staffel–kopos = ’01’.
copy_staffel–kstbm = ‘1’.
copy_staffel–kbetr = ’21’. ” Scale Price
copy_staffel–kzbzg = ‘C’.
copy_staffel–rv13akonwa = ‘EUR’.
copy_staffel–konpkmein = ‘EA’.
copy_staffel–konpkonms = ‘EA’.
APPEND copy_staffel.
*- Scales item 2
copy_staffel–klfn1 = ‘0002’.
copy_staffel–kopos = ’01’.
copy_staffel–kstbm = ’10’.
copy_staffel–kbetr = ’18’. ” Scale Price
copy_staffel–kzbzg = ‘C’.
copy_staffel–rv13akonwa = ‘EUR’.
copy_staffel–konpkmein = ‘EA’.
copy_staffel–konpkonms = ‘EA’.
APPEND copy_staffel.
*- Scales item 3
copy_staffel–klfn1 = ‘0003’.
copy_staffel–kopos = ’01’.
copy_staffel–kstbm = ’10’.
copy_staffel–kbetr = ’14’. ” Scale Price
copy_staffel–kzbzg = ‘C’.
copy_staffel–rv13akonwa = ‘EUR’.
copy_staffel–konpkmein = ‘EA’.
copy_staffel–konpkonms = ‘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.
BREAK–POINT.
CALL FUNCTION ‘RV_CONDITION_SAVE’
TABLES
knumh_map = lt_knumh.
CALL FUNCTION ‘RV_CONDITION_RESET’.
COMMIT WORK AND WAIT.
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
Hi Ankit,
Did you found any solution for your issue? I am facing the same.
Regards
Hi Sumit,
did you got any update on this..i am also really in need of knowing this.
Regards
S.Janagar
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:
How about deleting scales?