Hi All,
I want to export my prices with PR00, PR10, V002 (or V041) conditions from excel.
I used RV_CONDITION_COPY bapi to create condition records in pricing tables and also I want to view these prices in given sales deal through VB22 transaction code.
Here is my sample data:
Material | Condition Type | Payment Type | Amount |
---|---|---|---|
20210254 | PR00 | 1/10 | 11 |
20210254 | PR00 | 1/5 | 10 |
20210254 | PR00 | PTOP | 12 |
20210254 | PR00 | VPNK | 13 |
20210254 | PR10 | 11 | |
20210254 | V002 | 1/10 | 11 |
20210254 | V002 | 1/5 | 0,60 |
20210254 | V002 | PTOP | 3,1 |
20210254 | V002 | VPNK | 1 |
I exported these records and I was able to create them in pricing tables as below:
When I check my conditions, here are my records with the sales deal, 176.
And KONP....
Finally, KONA.
Everthing seems correct until now. But, when I check my sales deal from VB22, I am not able to view my condition records:
Here is my code below:
IF gt_k-kschl EQ 'PR00'.
CONCATENATE gv_vtweg
gs_b-auart
lv_pltyp
gs_b-augru
gt_k-zterm
gt_k-waers
gt_k-matnr
INTO gv_vakey
RESPECTING BLANKS.
lv_tabnr = '650'.
ELSEIF gt_k-kschl EQ 'PR10'.
lv_tabnr = '653'.
CONCATENATE gv_vtweg
gs_b-auart
lv_pltyp
gs_b-augru
gt_k-waers
gt_k-matnr
INTO gv_vakey
RESPECTING BLANKS.
ELSEIF gt_k-kschl EQ 'V002' OR gt_k-kschl EQ 'V041'.
lv_tabnr = '882'.
CONCATENATE gs_b-auart
lv_pltyp
gs_b-augru
gt_k-zterm
gt_k-waers
gt_k-matnr
INTO gv_vakey
RESPECTING BLANKS.
ENDIF.
gs_cr-kappl = 'V '.
gs_cr-kschl = gt_k-kschl.
gs_cr-mandt = sy-mandt.
gs_cr-kbetr = gt_k-kbetr.
gv_datab = gs_b-datab.
gv_datbi = gs_b-datbi.
CALL FUNCTION 'SD_CONDITION_KOMG_FILL'
EXPORTING
p_kotabnr = lv_tabnr
p_kvewe = 'A'
p_vakey = gv_vakey
IMPORTING
p_komg = gs_key_fields.
CLEAR : gs_komk,
gs_komp,
gs_komv_idoc.
REFRESH : gt_komv_idoc.
*- Fill KOMK
MOVE-CORRESPONDING gs_key_fields TO gs_komk.
gs_komk-mandt = sy-mandt.
gs_komk-zknuma_ag = gs_b-knuma_ag.
*- Fill KOMP
MOVE-CORRESPONDING gs_key_fields TO gs_komp.
gs_komp-kposn = '000001'.
gs_komp-knuma_ag = gs_b-knuma_ag.
*- Fill KOMV_IDOC
gs_komv_idoc-kznep = abap_true.
gs_komv_idoc-knuma_ag = gs_b-knuma_ag.
APPEND gs_komv_idoc TO gt_komv_idoc.
APPEND gs_cr TO gt_cr.
CALL FUNCTION 'RV_CONDITION_RESET'.
CALL FUNCTION 'RV_CONDITION_COPY'
EXPORTING
application = 'V '
condition_table = lv_tabnr
condition_type = gt_k-kschl
date_from = gv_datab
date_to = gv_datbi
enqueue = 'X'
i_komk = gs_komk
i_komp = gs_komp
key_fields = gs_key_fields
maintain_mode = 'A'
no_authority_check = 'X'
* keep_old_records = 'X'
used_by_idoc = 'X'
overlap_confirmed = 'X'
TABLES
copy_records = gt_cr
copy_recs_idoc = gt_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.
IF sy-subrc EQ 0.
REFRESH gt_knumh.
CALL FUNCTION 'RV_CONDITION_SAVE'
TABLES
knumh_map = gt_knumh.
IF gt_knumh IS NOT INITIAL.
lv_status = 'X'.
COMMIT WORK AND WAIT.
ELSE.
CALL FUNCTION 'RV_CONDITION_RESET'.
ENDIF.
ELSE.
CLEAR lv_status.
CALL FUNCTION 'RV_CONDITION_RESET'.
ENDIF.
What I am missing? How can I create condition records inside a sales deal and view them from VB22?
Thanks in advance!
Mina