Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with MWST replace by condition formula

Former Member
0 Kudos

Hi Gurus,

I have settled an EDI process (inbound message ORDERS05) to create a sales order in SAP ECC 700.

The requirement is to acquire MWST value passed by IDOC as they are.

To fit the requirement, considering I didn't find the solution by means of IDOC, I added to the pricing procedure a manual statistical condition ZSWT that ia fulfilled by IDOC values.

Then I use this condition to set values in MWST (real VAT condition) with a value formula (904).

The ABAP code of the formula is the following:

------------------------------------------------------------------------------------------------------------------------

CONSTANTS: c_zwst TYPE C LENGTH 4 VALUE 'ZWST',

            c_mwst TYPE C LENGTH 4 VALUE 'MWST'.

DATA: ls_vbkd TYPE vbkd,

       tkomv type standard table of komv_index

                      with header line,

       idx type I,

       work_kbetr type P,

       work_kwert type P.

FIELD-SYMBOLS <lt_xvbkd> TYPE ANY TABLE.

FIELD-SYMBOLS: <ls_xkomv> LIKE LINE OF tkomv,

                <ls2_xkomv> LIKE LINE OF tkomv.

CLEAR ls_vbkd.

ASSIGN ('(SAPMV45A)XVBKD[]') TO <lt_xvbkd>.

IF sy-subrc = 0.

   CLEAR: ls_vbkd, tkomv, idx.

    LOOP AT  <lt_xvbkd> INTO ls_vbkd.

     IF ls_vbkd-posnr = xkomv-kposn.

        if xkomv-kschl EQ c_mwst.

           IF ls_vbkd-posex_e NE ''.

             xkomv-mwsk1 = ls_vbkd-posex_e.

              clear: work_kbetr, work_kwert.

              READ TABLE xkomv ASSIGNING <ls_xkomv> WITH KEY

                          kposn = ls_vbkd-posnr kschl = c_zwst.

                 if sy-subrc = 0.

                       work_kbetr = <ls_xkomv>-kbetr.

                       work_kwert = <ls_xkomv>-kwert.

                       READ TABLE xkomv ASSIGNING <ls2_xkomv> WITH KEY

                                  kposn = ls_vbkd-posnr kschl = c_mwst.

                       if sy-subrc = 0.

                             idx = sy-tabix.

                             <ls2_xkomv>-kbetr <ls_xkomv>-kbetr.

                             <ls2_xkomv>-kofrm = 0.

                             xkwert = <ls_xkomv>-kwert.

                             MODIFY xkomv INDEX idx FROM <ls2_xkomv>

                                    TRANSPORTING kbetr kofrm.

                       endif.

                endif.

           ENDIF.

        ENDIF.

     ENDIF.

   ENDLOOP.

ENDIF.


----------------------------------------------------------------------------------------------------------------------------------


I cheched that XKOMV after running this formula set properly values coming form i-doc in XKOMV-KBETR, XKOMV-KWERT and XKOMV-MWSK1 as requested in the requirement.


But the last call of the value formula during debug process before saving the order is called by this piece of code inside INCLUDE LV61AA55



* execute condition value formula not changing xkomv

* will normally be processed in xkomv_kwert_ermitteln

     if xkomv-kofrm ne 0 and wertformel eq space and komp-kposn ne 0.

       rettkomv = xkomv.

       xkwert   = xkomv-kwert.

       frm_kondi_wert-nr = xkomv-kofrm.

       perform (frm_kondi_wert) in program saplv61a if found.

       xkomv    = rettkomv.

     endif.


I tried to set in my condition value formula the field XKOMV-KOFRM = 0 in order to by-bass this last call, because structure rettkomv is determined by the system and cannot be modified inside the condition value formula, but unsuccessfully.


Can anyone of you help me in finding the right solution to the issue?


Many Thanks in advance for your support.


Gianni

2 REPLIES 2

sez41
Active Contributor
0 Kudos

Hi,

First of all what you've done by setting value of MWST by ZSWT is a head-scratching move as it can break the whole Order to Cash process. Calculating taxes by formulaes like this is never best-practice. As this is related to IDOC messaging, I strongly advise you to find the solution within IDOC processing and not the pricing procedure.

About the piece of code you've mentioned : This is where SAP checks if there is a special formula for the relevant condition type in the pricing procedure or not. Sometimes, if you've made the wrong choice while creating formula type in VOFM (instead of condition base value, you've chosen condition value), things tend to get corrected here.

What is komp-kposn in the final call? Is it '000000'? If so, you probably have chosen wrong formula type, as taxes are supposed to be calculated only at item level.

if xkomv-kofrm ne 0 and wertformel eq space and komp-kposn ne 0.

Jelena
Active Contributor
0 Kudos

I agree - this is just a very bad idea in general. Taxes need to be calculated properly in SAP, not passed in the order. How can the customer dictate what taxes need to be paid?

Using "dirty ASSIGN" is a no-no as well: