‎2008 Jun 12 12:08 PM
Hi Experts,
As i am not familiar with data types please update me...
I am using the below logic to calculacte years & months between 2 dates and save the result in YY.MM format.
The FM i am using will give years & months between 2 given dates.
My requirment is to save result in YY.MM format.
The code is working correctly...i need a minor enhancement to code
Currently if years are 8 and months are 8 the out put will be 8.08 but i want it in YY.MM format which is 08.08
I want to add a leading 0 if years <10
Please update
DATA: years TYPE tfmatage,
months TYPE tfmatage.
DATA: l_res TYPE p decimals 2 .
IF NOT SOURCE_FIELDS-/bic/zdob IS INITIAL.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
I_DATE_FROM = SOURCE_FIELDS-/bic/zdob
I_DATE_TO = sy-datum
I_FLG_SEPARATE = 'X'
IMPORTING
E_DAYS =
E_MONTHS = months
E_YEARS = years.
l_res = years + months / 100.
WRITE l_res TO RESULT.
ENDIF.
WRITE / RESULT.
‎2008 Jun 12 12:42 PM
‎2008 Jun 12 12:43 PM
Could you please update me in detail as i am not familiar with ABAP
Thanks
‎2008 Jun 12 12:43 PM
here months is 2 character long. do one thing if month is less than 10 . Concatenae '0' month+0(1) into another of same month variable.
‎2008 Jun 12 12:43 PM
Hi,
you could do like this:
REPORT zhabitest4.
PARAMETER:
p_datum LIKE sy-datum.
DATA:
result(20).
DATA: years TYPE tfmatage,
months TYPE tfmatage,
y_num(4) TYPE n,
m_num(2) TYPE n.
DATA: l_res TYPE p DECIMALS 2 .
IF NOT p_datum IS INITIAL.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
i_date_from = p_datum
i_date_to = sy-datum
i_flg_separate = 'X'
IMPORTING
e_days =
e_months = months
e_years = years.
l_res = years + months / 100.
WRITE l_res TO result.
y_num = years.
m_num = months.
CONCATENATE y_num+2(2) '.' m_num INTO result.
ENDIF.
WRITE / result.
regards
Walter Habich
‎2008 Jun 12 1:13 PM
Hi Walter,
Thanks for the update...
Its working as required YY.MM format.
i guess we are using any L_RES
Could you please briefly explain me what the code is doing
Thanks
‎2008 Jun 12 12:48 PM
Hi,
using edit mask for days < 9 results in missing zero after point.
Regards
Walter Habich