Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3523

How to create conditions for a sales deal (VB22) automatically (RV_CONDITION_COPY)

$
0
0

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:

MaterialCondition TypePayment TypeAmount
20210254PR001/1011
20210254PR001/510
20210254PR00PTOP12
20210254PR00VPNK13
20210254PR1011
20210254V0021/1011
20210254V0021/50,60
20210254V002PTOP3,1
20210254V002VPNK1

 

 

 

I exported these records and I was able to create them in pricing tables as below:

 

1.PNG

 

2.PNG

 

3.PNG

 

When I check my conditions, here are my records with the sales deal, 176.

 

4.PNG

 

And KONP....

5.PNG

 

Finally, KONA.

6.PNG

 

Everthing seems correct until now. But, when I check my sales deal from VB22, I am not able to view my condition records:

 

7.PNG

 

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


Viewing all articles
Browse latest Browse all 3523

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>