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: 

Condition base value formula- VOFM

Former Member
0 Kudos

Hi!

I am trying to create a new formula to calculate the number of days a contract is valid for in the VFOM transaction. Has anyone done this before and could suggest how to create the formula for calculating the number of days a contract is valid for . Essentially we will be able to use the fields from KOMP to calculate how many days the contract is open for and then enter that number in xkwert but how do write down the formula if someone has done this before pls suggest .

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos
12 REPLIES 12

Former Member
0 Kudos

0 Kudos

Hi!

Thanks . But I need to create a formula or aline of code that will calculate the number of days a contract is valid considering the fields vbak-guebg and vbak-gueen (valid from and to), I want to get the total number of days to be calculated in between these dates. Like 11/02/2007 to 04/05/2008. and store that in xkwert.Can anyone please help out please.

Thanks

0 Kudos

HI,

We done like this.

  • Calculate Contract Period

date_diff = IT_REPORT-LV_ENDDATE - IT_REPORT-LV_STRTDATE. -- in days

IT_REPORT-lv_CPERIOD = ( DATE_DIFF / 30 ). -- in months

  • end of Calculation of Contract Period

or else

use this FM .

HR_99S_INTERVAL_BETWEEN_DATES

SD_DATETIME_DIFFERENCE

0 Kudos

Thanks Monika!

But this will give the contract period in months right ? If I would like to get it in days for a period like 12/03/2006 to 02/11/2009 will it be giving the number of days or in someother format when I use the lines you have sent.

Thanks

0 Kudos

Moreso not every month is of 30 days and if we get like 2-3 years even the days in all the years are not the same. I need to get the correct number of days between the valid from and to dates in the contract.

0 Kudos

Ok I ahve used the FM to get the number of days , but when I save and activate it , it says 'There is no main program for include RV63A904. How will I add that to the main program and which will be the main program for that, could someone please suggest as what to do here.

Thanks

0 Kudos

Hi,

Sorry for late reply .

u add ur code in the loop where u r calculateing other values and appending it.

i have no idea about ur program . so how can i help u?

0 Kudos

Hi Monika!

I have added the following code for the formula to calculate the number of days between valiud from and to dates , the only thing I am wondering is as how to verify the contract number and item number of the contract enterd with this formula so that it calculates the number of days for the netred contract. KOMP and KOMK tables needs to be used to verify but how to verify is what I am looking for.

FORM FRM_KOND_BASIS_904.

data: tp_days type komv-kwert.

data: wa_vbak like vbak.

data: tp_text(100) type c.

clear : wa_vbak, tp_text, xkwert.

field-symbols : <f> type any.

  • Get data from vbak

concatenate '(SAPMV45A)' 'XVBAK' into tp_text.

assign (tp_text) to <f>.

select single * from vbak into wa_vbak where vbeln = komk-belnr .

  • wa_vbak = <f>.

if komk-belnr = wa_vbak-vbeln.

tp_days = wa_vbak-gueen - wa_vbak-guebg.

xkwert = ( tp_days ) * 100.

endif.

ENDFORM.

Thanks

0 Kudos

Hi,

U have to use these code in the Loop.

Like


Loop at It_vbak.
.
.
it_final-Contract_period = tp_days
Append it_final.
Endloop.

Former Member
0 Kudos

.

Former Member
0 Kudos

.

0 Kudos

I think you will want to add 1 to tp_days.

(End_Date - Start_Date) + 1

The way you have it actually reduces the effective contract period by a day