Hello,
I am facing currently an issue with the RV_CONDITION_COPY function module. I use this FM to create new conditions. If I enter a single entry in the COPY_RECORDS table the condition is create correctly without a problem.
Now my task requries also to create a supplement condition. My assumption would be to create a second entry in the COPY_RECORDS table but if I try this there is no new supplement condition and my working first entry is now empty and has a deletion flag.
In my source code you see iv_kbetrc1 which is my main condition type and with only this type my condition is created correctly.
iv_kbetrc2 is now my subblement condition type. I tried simply adding a second entry in COPY_RECORDS but without any luck.
*--------------------------------------------------------------------*
* FIELD-SYMBOLS
*--------------------------------------------------------------------*
FIELD-SYMBOLS: <s_records> TYPE komv.
*--------------------------------------------------------------------*
s_pricing_keys-vkorg = iv_vkorg.
s_pricing_keys-vtweg = iv_vtweg.
s_pricing_keys-pltyp = iv_pricel.
s_pricing_keys-waerk = iv_konwa.
s_pricing_keys-matnr = iv_material.
s_pricing_keys-j_3asize = iv_j3akord.
APPEND INITIAL LINE TO t_records ASSIGNING <s_records>.
<s_records>-kappl = 'V'.
<s_records>-stfkz = 'A'.
<s_records>-krech = 'C'.
<s_records>-kschl = iv_kschl1.
<s_records>-kbetr = iv_kbetrc1.
<s_records>-waers = iv_konwa.
<s_records>-kpein = 1.
<s_records>-kmein = 'ST'.
<s_records>-zaehk_ind = '1'.
<s_records>-kopos = '1'.
UNASSIGN: <s_records>.
IF iv_kschl2 IS NOT INITIAL.
APPEND INITIAL LINE TO t_records ASSIGNING <s_records>.
* <s_records>-
<s_records>-kappl = 'V'.
<s_records>-stfkz = 'A'.
<s_records>-krech = 'C'.
<s_records>-kschl = iv_kschl2.
<s_records>-kbetr = iv_kbetrc2.
<s_records>-waers = iv_konwa.
<s_records>-kpein = 1.
<s_records>-kmein = 'ST'.
<s_records>-zaehk_ind = '2'.
<s_records>-kopos = '2'.
UNASSIGN: <s_records>.
ENDIF.
CALL FUNCTION 'RV_CONDITION_COPY'
EXPORTING
application = 'V' " Application
condition_table = '940' " Condition Table Number
condition_type = 'J3AP' " Condition type
date_from = iv_datam " Valid-from date
* date_to = '00000000' " Valid-to Date
enqueue = abap_true " Lock indicators of condition recor
i_komk = s_pricing_header " Communication block header (pricing)
i_komp = s_pricing_position " Communication block item (pricing)
key_fields = s_pricing_keys " Key fields
maintain_mode = 'A' " Mode: Create, Change, Display
no_authority_check = abap_true " Do not carry out authorization check
* no_field_check = ' ' " Do not carry out field checks
* selection_date = '00000000' " Selection date
* keep_old_records = abap_true " Indicator: Old records are not deleted
* material_m = material_m " MAPOV segment (application V)
* used_by_idoc = abap_true " Controls special handling in case of IDoc processing
* i_kona = i_kona " Transfer of KOMA (for IDoc processing)
overlap_confirmed = abap_true " Automatic confirmation in case of overlapping periods
* no_db_update = ' ' " Automatic confirmation in case of overlapping periods
* used_by_retail = ' ' " Automatic confirmation in case of overlapping periods
* IMPORTING
* e_komk = e_komk " Communication block header (pricing)
* e_komp = e_komp " Communication block item (pricing)
* new_record = <new_record> " New condition record was created
* e_datab = e_datab " New condition record was created
* e_datbi = e_datbi " New condition record was created
* e_prdat = e_prdat " New condition record was created
TABLES
copy_records = t_records " Table of conditions to be copied
* copy_staffel = copy_staffel
* copy_recs_idoc = copy_recs_idoc
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.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'RV_CONDITION_SAVE'.
CALL FUNCTION 'RV_CONDITION_RESET'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true.
ENDIF.
CLEAR: t_records.
CLEAR: s_pricing_keys.
If you know a solution or another way to create those supplements condition I would be very gratefull.
Thank you.
BR,
Andreas