07-14-2014 11:14 AM
Hi,
My requirement is to update the price for the condition record no in konp table by using rv_condition_copy function module.
In this program i am trying to change the price of this condition record number but it is not affecting to the database.
program is successfully executing but it doesnt affect the database.
DATA:i_komv TYPE TABLE OF komv. " Pricing Communications-Condition Record
DATA:wa_key_fields TYPE komg, "
wa_konp TYPE konp, " Konp table - Conditions (Item)
w_komv LIKE LINE OF i_komv,
w_mara LIKE mt06e, " Material Master Fields: Purchasing
komk TYPE komk, " Communication Header for Pricing
komp TYPE komp, " Communication Item for Pricing
wa_pispr TYPE pispr,
l_new_record.
START-OF-SELECTION.
SELECT SINGLE *
FROM konp
INTO wa_konp
WHERE knumh = '0000032426'
AND loevm_ko <> 'X'.
CLEAR : wa_key_fields, w_komv.
REFRESH : i_komv.
wa_pispr-matnr = 'T-EC0101'.
wa_pispr-vkorg = '0005'.
wa_pispr-vtweg = '12'.
CALL FUNCTION 'SPR_KOMK_KOMP_FILL'
EXPORTING
pi_i_spr = wa_pispr
IMPORTING
pe_i_komk = komk
pe_i_komp = komp.
wa_key_fields-matnr = 'T-EC0101'.
w_komv-knumh = wa_konp-knumh. " Condition record number
w_komv-kposn = wa_konp-kopos. " Sequential number of the condition
w_komv-kappl = wa_konp-kappl. " Application
w_komv-kschl = wa_konp-kschl. " Condition type
w_komv-kbetr = '49.99'. " Rate (condition amount or percentage) where no scale exists
w_komv-waers = wa_konp-konwa. " Rate unit (currency or percentage)
w_komv-krech = wa_konp-krech. " Calculation type for condition
w_komv-stfkz = wa_konp-stfkz. " Scale Type
w_komv-kpein = wa_konp-kpein. " Condition pricing unit
w_komv-kmein = wa_konp-kmein. " Unit of measurement
w_komv-zaehk_ind = wa_konp-zaehk_ind. " Condition item index
w_komv-loevm_ko = 'X'. " Deletion indicator for condition item
APPEND w_komv TO i_komv.
w_mara-matkl = '009'. " Material group
w_mara-meins = 'ST'. " Basic Unit of measure
w_mara-mtart = 'HAWA'. " Material type
w_mara-maktx = 'Saddle bag'. " Material Description
CALL FUNCTION 'RV_CONDITION_COPY'
EXPORTING
application = 'V' " Application V = Sales
condition_table = '304' " Condition table
condition_type = 'PR00' " Condition type
date_from = '20060327' " Validity start date of the condition record
date_to = '99991231' " Validity End date of the condition record
enqueue = 'X'
i_komk = komk " Communication block for header(pricing)
i_komp = komp " Communication block for item(pricing)
selection_date = '20060327'
key_fields = wa_key_fields
maintain_mode = 'B' " Mode: Create(A), Change(B), Display(C).
* no_authority_check = 'X'
* no_field_check = ' '
keep_old_records = 'X'
material_m = w_mara
overlap_confirmed = 'X'
no_db_update = ' '
IMPORTING
e_komk = komk
e_komp = komp
new_record = l_new_record
TABLES
copy_records = i_komv
EXCEPTIONS
enqueue_on_record = 1
invalid_application = 2
invalid_condition_number = 3
invalid_condition_type = 4
no_authority_ekorg = 5
no_authority_kschl = 6
no_authority_vkorg = 7
no_selection = 8
table_not_valid = 9
no_material_for_settlement = 10
no_unit_for_period_cond = 11
no_unit_reference_magnitude = 12
invalid_condition_table = 13
OTHERS = 14.
IF sy-subrc ne 0.
WRITE:/10 'not executed successfully'.
ELSE.
CALL FUNCTION 'RV_CONDITION_SAVE'.
COMMIT WORK.
CALL FUNCTION 'RV_CONDITION_RESET'.
COMMIT WORK.
WRITE:/10 ' executed successfully'.
ENDIF.
Regards,
Avinash.
07-14-2014 11:30 AM
Hi,
Remove redundant commit work:
ELSE.
CALL FUNCTION 'RV_CONDITION_SAVE'.
* COMMIT WORK.
CALL FUNCTION 'RV_CONDITION_RESET'.
COMMIT WORK.
One commit work is enough.
Regards,
07-14-2014 11:30 AM
Hi,
Remove redundant commit work:
ELSE.
CALL FUNCTION 'RV_CONDITION_SAVE'.
* COMMIT WORK.
CALL FUNCTION 'RV_CONDITION_RESET'.
COMMIT WORK.
One commit work is enough.
Regards,
07-14-2014 12:05 PM
Hi chandra,
Thanks for your reply.
Even though i tried in this manner , i couldnt get the result.
Regards,
Avinash.
07-14-2014 1:27 PM
Hi Avinash,
I was used in my project and its work with below code, please try to change your program just like below and check I think it will be helpfull for you.
Regards,
Prasenjit
PARAMETERS: p_KBETR type KBETR DEFAULT '99'.
PARAMETERS: p_KNUMA type KNUMA_AG DEFAULT 'X000009996'.
PARAMETERS: p_datef type sy-datum DEFAULT '20130401'.
PARAMETERS: p_datet type sy-datum DEFAULT '20130731'.
PARAMETERS: p_kunnr TYPE kunnr DEFAULT '28523272'.
PARAMETERS: p_matnr type matnr DEFAULT 'P7734527'.
START-OF-SELECTION.
DATA:
cr LIKE TABLE OF komv WITH HEADER LINE, " copy_records
nr, "New_Record
key_fields LIKE TABLE OF komg WITH HEADER LINE,
komk LIKE TABLE OF komk WITH HEADER LINE,
komp LIKE TABLE OF komp WITH HEADER LINE,
COPY_RECS_IDOC LIKE TABLE OF KOMV_IDOC WITH HEADER LINE,
i_kona TYPE kona.
**********************************************************
* KOMK/KOMP Fuellen
*Fill KOMK
komk-mandt = '210'.
komk-vkorg = '1310'.
komk-vtweg = '01'.
komk-spart = '01'.
komk-kunnr = p_kunnr.
komk-kappl = 'V'.
komk-ERDAT = sy-datum.
komp-kposn = '000001'.
komp-matnr = p_matnr.
komp-KNUMA_AG = p_KNUMA.
komp-kposn = '000001'.
key_fields-mandt = '210'.
key_fields-vkorg = '3376'.
key_fields-kunnr = p_kunnr.
key_fields-vtweg = '01'.
key_fields-spart = '01'.
key_fields-matnr = p_matnr.
cr-kappl = 'V'.
cr-kschl = 'ZLPO'.
cr-krech = 'C'.
cr-KBETR = p_KBETR.
cr-waers = 'GBP'.
cr-kpein = 1.
cr-kmein = 'CS'.
cr-kopos = 01.
cr-kzbzg = 'C'.
*cr-knumh = '0005014306'.
APPEND cr.
i_kona-abtyp = 'C'.
i_kona-knuma = p_knuma.
*COPY_RECS_IDOC-KNUMA_AG = p_KNUMA.
*append COPY_RECS_IDOC.
CALL FUNCTION 'RV_CONDITION_RESET'.
* --> KOMK/KOMP werden korrekt gefüllt. Funktion i.o.
**********************************************************
CALL FUNCTION 'RV_CONDITION_COPY'
EXPORTING
application = 'V'
condition_table = '517'
condition_type = 'ZLPO'
date_from = p_datef
date_to = p_datet
enqueue = 'X'
i_komk = komk
i_komp = komp
key_fields = key_fields
maintain_mode = 'A'
no_authority_check = space
no_field_check = 'X'
keep_old_records = space
overlap_confirmed = 'X'
i_kona = i_kona
SELECTION_DATE = sy-datum
IMPORTING
e_komk = komk
e_komp = komp
new_record = nr
TABLES
copy_records = cr
COPY_RECS_IDOC = COPY_RECS_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.
CALL FUNCTION 'RV_CONDITION_SAVE'.
CALL FUNCTION 'RV_CONDITION_RESET'.
commit work.
07-14-2014 11:43 AM
Hi Avinash,
AS Chandra says,
One Commit work is enough just like below to save data in the data base.
CALL FUNCTION 'RV_CONDITION_SAVE'.
CALL FUNCTION 'RV_CONDITION_RESET'.
COMMIT WORK.
Regards,
Prasenjit
07-14-2014 1:34 PM
Hi Avinash,
Instead of writing commit work two times u can write it only once as shown below.
call function 'rv_condition_save'.
call function 'rv_condition_reset'.
commit work.
You can also use BAPI_PRICES_CONDITIONS bapi to chnage the price value of condition record.
06-30-2016 7:25 AM
Hello Prasenjit & all,
I'm using the similar way but not getting the record created neither getting any error.
REPORT ztest.
DATA:
cr LIKE TABLE OF komv WITH HEADER LINE, " copy_records
nr,
ls_komg LIKE TABLE OF komg WITH HEADER LINE,
komk type komk,
komp type komp.
ls_komg-vkorg = '1000'.
ls_komg-vtweg = '04'.
ls_komg-matnr = '000000000000100727'.
cr-kappl = 'V'.
cr-kschl = 'ZSP2'.
cr-krech = 'C'.
cr-kbetr = '15.00'.
cr-kpein = '1'.
cr-kmein = 'PCS'.
cr-waers = 'NAB'.
APPEND cr.
DATA wa_pispr LIKE TABLE OF pispr WITH HEADER LINE.
wa_pispr-matnr = '000000000000900065'.
wa_pispr-vkorg = '1000'.
wa_pispr-vtweg = '04'.
APPEND wa_pispr.
CALL FUNCTION 'SPR_KOMK_KOMP_FILL'
EXPORTING
pi_i_spr = wa_pispr
IMPORTING
pe_i_komk = komk
pe_i_komp = komp
EXCEPTIONS
org_structure_not_completed = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE 'error'.
ENDIF.
CALL FUNCTION 'RV_CONDITION_RESET'.
CALL FUNCTION 'RV_CONDITION_COPY'
EXPORTING
application = 'V'
condition_table = '004'
condition_type = 'ZSP2'
date_from = '20160801'
date_to = '99991231'
* enqueue = 'X'
i_komk = komk
i_komp = komp
key_fields = ls_komg
maintain_mode = 'A'
* no_authority_check = 'X'
no_authority_check = space
no_field_check = 'X'
SELECTION_DATE = sy-datum
keep_old_records = 'X'
overlap_confirmed = 'X'
* NO_DB_UPDATE = ' '
IMPORTING
e_komk = komk
e_komp = komp
new_record = nr
TABLES
copy_records = cr
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.
IF sy-subrc ne 0.
WRITE:/10 'not executed successfully'.
ELSE.
CALL FUNCTION 'RV_CONDITION_SAVE'.
CALL FUNCTION 'RV_CONDITION_RESET'.
COMMIT WORK.
WRITE:/10 ' executed successfully'.
ENDIF.