‎2009 May 15 3:42 PM
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
‎2009 May 15 6:24 PM
for reference: http://saptechsolutions.com/pdf/VOFMFormulaRoutines.pdf
thanq
‎2009 May 15 6:24 PM
for reference: http://saptechsolutions.com/pdf/VOFMFormulaRoutines.pdf
thanq
‎2009 May 21 2:07 AM
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
‎2009 May 21 5:16 AM
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
‎2009 May 21 3:46 PM
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
‎2009 May 21 3:48 PM
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.
‎2009 May 21 4:20 PM
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
‎2009 May 22 4:57 AM
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?
‎2009 May 26 4:50 PM
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
‎2009 May 27 4:45 AM
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.
‎2009 May 26 4:50 PM
‎2009 May 28 9:06 PM
‎2009 Jun 24 5:18 PM
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