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

VOFM condition value calculation issue

Former Member
0 Likes
1,048

Hi Friends,

I am having a strange kind of issue. I have a requirement of calculating a condition type value based upon one more available condition type.

In my case the condition value to find out is 'ZWTH' and the condition value from find out is 'ZWHC'.

Now the routine is assigned to pricing procedure with condition type 'ZWTH' and it calculates fine on screen. But as soon as I save document it calculates the values wrong.

Does anybody have any idea, what is the exact problem and what goes wrong?

DATA : L_KOMV LIKE XKOMV,

LV_ZWHC_VALUE TYPE KWERT,

LV_ZWTH_KBETR TYPE KBETR.

CLEAR : L_KOMV,

LV_ZWHC_VALUE,

LV_ZWTH_KBETR.

READ TABLE XKOMV INTO L_KOMV WITH KEY KPOSN = XKOMV-KPOSN

KSCHL = 'ZWHC'.

IF SY-SUBRC EQ 0.

LV_ZWHC_VALUE = L_KOMV-KWERT.

LV_ZWTH_KBETR = XKOMV-KBETR.

IF LV_ZWHC_VALUE NE 0.

PERFORM CALCULATE_XKWERT IN PROGRAM ZRV64A903_ROUTINES

USING LV_ZWHC_VALUE

LV_ZWTH_KBETR

CHANGING XKWERT.

ENDIF.

ENDIF.

&----


*& Form CALCULATE_XKWERT

&----


FORM calculate_xkwert USING p_zwhc_value TYPE kwert

p_zwth_kbetr TYPE kbetr

CHANGING p_xkwert TYPE kwert.

p_xkwert = p_zwhc_value * ( p_zwth_kbetr / 1000 ).

ENDFORM. " CALCULATE_XKWERT

3 REPLIES 3
Read only

Former Member
0 Likes
729

Hi,

For one thing, you are changing the value of the XKOMV workarea.

I would recommend you add :

DATA : lt_xkomv TYPE STANDARD TABLE OF indexed_komv.

  • Local copy

lt_xkomv[] = xkomv[].

and then did the read of lt_xkomv rather than xkomv.

Also, did you define ZRV64A903_ROUTINES to work with fixed-point arithmetic ?

- Ole

Read only

Former Member
0 Likes
729

Yes you are changin the value in your routine based on formula,once you changed the value and it will go some other program and there it is modifying the value so,

keep watch point for ur field and try

Read only

former_member186078
Active Participant
0 Likes
729

Hi Sagar,

What is the exact problem you are facing? Can you check once, there might be a problem while you are performing calculations on KBETR and KWERT, because they are of different data types, one is of decimals 3 and another of decimals 2. If that is the case, use unpack fields logic so that the calculated value is right.

Note: Reward points if the suggestion is useful.

From,

Adithya K

askSAP@googlegroups.com