Dear Gurus,
We have develop a custom Z program to upload Price Condition Record (VK11). My program runs well when it comes to Creation nor Change.
But unfortunately when we observe during Change mode it always gives an unwanted log (Environment -> Changes -> Per Condition Record)
Deletion Indicator for Condition Item = T.
We want to get rid of this deletion indicator = T in the log since its confusing for user.
Below is my modified code.
*&---------------------------------------------------------------------*
*& Form F_PROCESS_DATA
*&---------------------------------------------------------------------*
FORM f_process_data USING p_tabnum.
DATA: cr LIKE TABLE OF komv WITH HEADER LINE, " copy_records
* cri LIKE TABLE OF komv_idoc WITH HEADER LINE,
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,
lw_pispr LIKE TABLE OF pispr WITH HEADER LINE,
lt_data LIKE gt_data OCCURS 0 WITH HEADER LINE,
ls_konp TYPE konp,
lv_matnr_input LIKE mara-matnr,
lv_mara_meins LIKE mara-meins,
lv_count TYPE i VALUE 1,
lv_output1 TYPE zp22j_dest_27,
lv_output2 TYPE zp22j_dest_35,
lv_tabnum TYPE kotabnr,
lv_counter TYPE i,
lv_tax_rate TYPE fwste,
lv_tax_amount TYPE hwste,
lv_maintain_mode,
nr.
REFRESH gt_display.
CLEAR: gt_display.
* lv_mara_meins.
lt_data[] = gt_data[].
SORT lt_data BY mark statu.
DELETE lt_data WHERE mark = space.
LOOP AT lt_data.
MOVE-CORRESPONDING lt_data TO gt_display.
REFRESH lw_pispr.
lw_pispr-waerk = lt_data-waerk.
lw_pispr-kunnr = lt_data-kunag.
lw_pispr-matnr = lt_data-matnr.
lw_pispr-vkorg = lt_data-vkorg.
lw_pispr-vtweg = '10'.
lw_pispr-spart = '00'.
APPEND lw_pispr.
CALL FUNCTION 'SPR_KOMK_KOMP_FILL'
EXPORTING
pi_i_spr = lw_pispr
IMPORTING
pe_i_komk = komk
pe_i_komp = komp
EXCEPTIONS
OTHERS = 8.
REFRESH key_fields.
key_fields-vkorg = lt_data-vkorg.
key_fields-kunag = lt_data-kunag.
key_fields-waerk = lt_data-waerk.
key_fields-zterm = lt_data-zterm.
key_fields-inco1 = lt_data-inco1.
key_fields-matnr = lt_data-matnr.
key_fields-kvgr4 = lt_data-kvgr4.
key_fields-zkdgrp = lt_data-zkdgrp.
key_fields-zzcommagent = lt_data-zzcommagent.
key_fields-zzrespsoff = lt_data-zzrespsoff.
key_fields-zzsconf = lt_data-zzsconf.
key_fields-zzcateg = lt_data-zzcateg.
key_fields-zzarticle1_vc = lt_data-zzarticle1.
key_fields-zzarticle2_vc = lt_data-zzarticle2.
APPEND key_fields.
* Check existing record
PERFORM f_read_cond USING lt_data
p_tabnum
CHANGING
gt_konp
lv_maintain_mode.
* Change record
REFRESH cr.
LOOP AT gt_konp INTO ls_konp.
cr-kappl = ls_konp-kappl. "'V'.
cr-kschl = ls_konp-kschl. "lt_data-kschl.
cr-kbetr = lt_data-kbetr. "ls_konp-kbetr.
cr-kmein = ls_konp-kmein. "ls_konp-meins. "lv_mara_meins.
cr-waers = ls_konp-konwa. "lt_data-scurr.
cr-kpein = ls_konp-kpein. "1
cr-krech = ls_konp-krech. "++
cr-kopos = ls_konp-kopos. "++
cr-kzbzg = ls_konp-kzbzg. "++
cr-knumv = ls_konp-knumh. "++
* cr-kposn = ls_konp-kopos. "++
* cr-loevm_ko = space.
APPEND cr.
ENDLOOP.
* New record
IF gt_konp[] IS INITIAL AND lv_maintain_mode EQ 'A'.
CLEAR: lv_matnr_input,
lv_mara_meins.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = lt_data-matnr
IMPORTING
output = lv_matnr_input
EXCEPTIONS
length_error = 1
OTHERS = 2.
IF sy-subrc = 0.
SELECT SINGLE meins INTO lv_mara_meins
FROM mara
WHERE matnr EQ lv_matnr_input.
ENDIF.
cr-kappl = 'V'.
cr-kschl = lt_data-kschl.
cr-kbetr = lt_data-kbetr.
cr-kmein = lv_mara_meins.
cr-waers = lt_data-scurr.
cr-kpein = 1.
APPEND cr.
ENDIF.
CALL FUNCTION 'RV_CONDITION_COPY'
EXPORTING
application = 'V'
condition_table = p_tabnum
condition_type = lt_data-kschl
date_from = lt_data-datab
date_to = lt_data-datbi
enqueue = 'X'
i_komk = komk
i_komp = komp
key_fields = key_fields
maintain_mode = lv_maintain_mode " 'A' New; 'B' Change
no_authority_check = 'X'
no_field_check = 'X'
* used_by_idoc = 'X'
selection_date = lt_data-datab "++
keep_old_records = '' "
overlap_confirmed = 'X'
* no_db_update = space
IMPORTING
e_komk = komk
e_komp = komp
new_record = nr
TABLES
copy_records = cr
* copy_recs_idoc = cri
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 = 0.
CALL FUNCTION 'RV_CONDITION_SAVE'.
CALL FUNCTION 'RV_CONDITION_RESET'.
COMMIT WORK.
ELSE.
PERFORM f_get_msg USING sy-msgid
sy-msgno
sy-msgv1
sy-msgv2
sy-msgv3
sy-msgv4
CHANGING gt_display-msg.
ENDIF.
APPEND gt_display.
CLEAR gt_display.
ENDLOOP.
ENDFORM. " F_PROCESS_DATA
Thanks and Regards,
AT