Application Development and Automation 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: 
Read only

Calculation from a set material with components (XVBAP/TKOMV)

Former Member
0 Likes
444

Hi All,

i have a material with components.

I should do a sum of the components to get the price of the material.

Now i did this on the Conditions site in the price setting area (transaction VOFM...loop over TKOMV and write it back to TKOMV) and this is working, but the problem is in the overview of the positions, the price of the "header" material is not correct. But at the moment i double click on a position on the screen and then i go back to the overview the prive is fine. So i checked where this values are from, then i saw that this values are from the VBAP.

Now i searched a userexit and i took the USEREXIT_FIELD_MODIFICATION to change values in the XVBAP, because i saw if i change at this point a value, that this value will be on the screen.

But now the strange thing is, that the price is not fine, but after looping over the XVBAP it looks fine. But here the strange thing are happen, i could loop over more then 20min. and im still in the loop from the userexit and modify screen area.

Could Somebody help my? thanks a lot

HERE the CODE:

IF XVBAP IS NOT INITIAL. 
 DATA: xvbap_line LIKE LINE OF XVBAP, 
       xvbap_line2 LIKE LINE OF XVBAP, 
       tmpxvbapNETWR LIKE XVBAP-NETWR, 
       tmpxvbapNETPR LIKE XVBAP-NETWR, 
       tmpxvbapKZWI1 LIKE XVBAP-KZWI1, 
       tmpxvbapKZWI2 LIKE XVBAP-KZWI2, 
       tmpxvbapKZWI3 LIKE XVBAP-KZWI3, 
       tmpxvbapKZWI4 LIKE XVBAP-KZWI4, 
       tmpxvbapKZWI5 LIKE XVBAP-KZWI5, 
       tmpxvbapKZWI6 LIKE XVBAP-KZWI6, 
       idx TYPE SY-TABIX. 
 
 LOOP AT XVBAP 
  INTO xvbap_line 
   WHERE UEPOS = '000000' 
    OR UEPOS IS INITIAL. 
 
  idx = sy-tabix. 
 
  tmpxvbapNETWR = '0.00'. 
  tmpxvbapNETPR = '0.00'. 
  tmpxvbapKZWI1 = '0.00'. 
  tmpxvbapKZWI2 = '0.00'. 
  tmpxvbapKZWI3 = '0.00'. 
  tmpxvbapKZWI4 = '0.00'. 
  tmpxvbapKZWI5 = '0.00'. 
  tmpxvbapKZWI6 = '0.00'. 
 
  LOOP AT XVBAP 
   INTO xvbap_line2 
    WHERE UEPOS = xvbap_line-POSNR. 
 
 
    tmpxvbapNETWR = tmpxvbapNETWR + xvbap_line2-NETWR. 
    tmpxvbapNETPR = tmpxvbapNETWR * 1000 / xvbap_line-KWMENG. 
 
    tmpxvbapKZWI1 = tmpxvbapKZWI1 + xvbap_line2-KZWI1. 
    tmpxvbapKZWI2 = tmpxvbapKZWI2 + xvbap_line2-KZWI2. 
    tmpxvbapKZWI3 = tmpxvbapKZWI3 + xvbap_line2-KZWI3. 
    tmpxvbapKZWI4 = tmpxvbapKZWI4 + xvbap_line2-KZWI4. 
    tmpxvbapKZWI5 = tmpxvbapKZWI5 + xvbap_line2-KZWI5. 
    tmpxvbapKZWI6 = tmpxvbapKZWI6 + xvbap_line2-KZWI6. 
 
  ENDLOOP. 
 
  xvbap_line-NETWR = tmpxvbapNETWR. 
  xvbap_line-NETPR = tmpxvbapNETPR. 
 
  xvbap_line-KZWI1 = tmpxvbapKZWI1.
  xvbap_line-KZWI2 = tmpxvbapKZWI2. 
  xvbap_line-KZWI3 = tmpxvbapKZWI3. 
  xvbap_line-KZWI4 = tmpxvbapKZWI4. 
  xvbap_line-KZWI5 = tmpxvbapKZWI5. 
  xvbap_line-KZWI6 = tmpxvbapKZWI6. 
 
  MODIFY XVBAP FROM xvbap_line INDEX idx. 
 ENDLOOP. 
ENDIF.

Hi All,

i have a material with components.

I should do a sum of the components to get the price of the material.

Now i did this on the Conditions site in the price setting area (transaction VOFM...loop over TKOMV and write it back to TKOMV) and this is working, but the problem is in the overview of the positions, the price of the "header" material is not correct. But at the moment i double click on a position on the screen and then i go back to the overview the prive is fine. So i checked where this values are from, then i saw that this values are from the VBAP.

Now i searched a userexit and i took the USEREXIT_FIELD_MODIFICATION to change values in the XVBAP, because i saw if i change at this point a value, that this value will be on the screen.

But now the strange thing is, that the price is not fine, but after looping over the XVBAP it looks fine. But here the strange thing are happen, i could loop over more then 20min. and im still in the loop from the userexit and modify screen area.

Could Somebody help my? thanks a lot

HERE the CODE:

IF XVBAP IS NOT INITIAL. 
 DATA: xvbap_line LIKE LINE OF XVBAP, 
       xvbap_line2 LIKE LINE OF XVBAP, 
       tmpxvbapNETWR LIKE XVBAP-NETWR, 
       tmpxvbapNETPR LIKE XVBAP-NETWR, 
       tmpxvbapKZWI1 LIKE XVBAP-KZWI1, 
       tmpxvbapKZWI2 LIKE XVBAP-KZWI2, 
       tmpxvbapKZWI3 LIKE XVBAP-KZWI3, 
       tmpxvbapKZWI4 LIKE XVBAP-KZWI4, 
       tmpxvbapKZWI5 LIKE XVBAP-KZWI5, 
       tmpxvbapKZWI6 LIKE XVBAP-KZWI6, 
       idx TYPE SY-TABIX. 
 
 LOOP AT XVBAP 
  INTO xvbap_line 
   WHERE UEPOS = '000000' 
    OR UEPOS IS INITIAL. 
 
  idx = sy-tabix. 
 
  tmpxvbapNETWR = '0.00'. 
  tmpxvbapNETPR = '0.00'. 
  tmpxvbapKZWI1 = '0.00'. 
  tmpxvbapKZWI2 = '0.00'. 
  tmpxvbapKZWI3 = '0.00'. 
  tmpxvbapKZWI4 = '0.00'. 
  tmpxvbapKZWI5 = '0.00'. 
  tmpxvbapKZWI6 = '0.00'. 
 
  LOOP AT XVBAP 
   INTO xvbap_line2 
    WHERE UEPOS = xvbap_line-POSNR. 
 
 
    tmpxvbapNETWR = tmpxvbapNETWR + xvbap_line2-NETWR. 
    tmpxvbapNETPR = tmpxvbapNETWR * 1000 / xvbap_line-KWMENG. 
 
    tmpxvbapKZWI1 = tmpxvbapKZWI1 + xvbap_line2-KZWI1. 
    tmpxvbapKZWI2 = tmpxvbapKZWI2 + xvbap_line2-KZWI2. 
    tmpxvbapKZWI3 = tmpxvbapKZWI3 + xvbap_line2-KZWI3. 
    tmpxvbapKZWI4 = tmpxvbapKZWI4 + xvbap_line2-KZWI4. 
    tmpxvbapKZWI5 = tmpxvbapKZWI5 + xvbap_line2-KZWI5. 
    tmpxvbapKZWI6 = tmpxvbapKZWI6 + xvbap_line2-KZWI6. 
 
  ENDLOOP. 
 
  xvbap_line-NETWR = tmpxvbapNETWR. 
  xvbap_line-NETPR = tmpxvbapNETPR. 
 
  xvbap_line-KZWI1 = tmpxvbapKZWI1.
  xvbap_line-KZWI2 = tmpxvbapKZWI2. 
  xvbap_line-KZWI3 = tmpxvbapKZWI3. 
  xvbap_line-KZWI4 = tmpxvbapKZWI4. 
  xvbap_line-KZWI5 = tmpxvbapKZWI5. 
  xvbap_line-KZWI6 = tmpxvbapKZWI6. 
 
  MODIFY XVBAP FROM xvbap_line INDEX idx. 
 ENDLOOP. 
ENDIF.

1 REPLY 1
Read only

Former Member
0 Likes
374

The Problem was, that the customer had a z-program at the end of the hole price finding process, whiche recalculate the hole thing, thats why it wasnt working.