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

help with sap function

Former Member
0 Likes
890

hallow

i using this function to get how much month btween the to date i put

and it bring me wrong num

CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

EXPORTING

i_date_from = l_begda "010107

i_date_to = l_endda "311207

IMPORTING

e_months = no_months" i get <b>36132</b>

way its not working i have to get 12 month

Regards

i reward

.

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
852

hi SHNYA,

the FM works properly for me. Pls. check the values of l_begda nd l_endda when you program call the FM

hope this helps

ec

7 REPLIES 7
Read only

JozsefSzikszai
Active Contributor
0 Likes
853

hi SHNYA,

the FM works properly for me. Pls. check the values of l_begda nd l_endda when you program call the FM

hope this helps

ec

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
852

Hi,

Give the input as

CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

EXPORTING

i_date_from = '20070101'

i_date_to = '20073112'

IMPORTING

e_months = no_months.

The type of i_date_from and i_date_to is DATS so you should give like this '20070101' YYYYMMDD format.

Regards,

Sesh

Read only

0 Likes
852

hi Sesh Madala

the problem is that i get from user the date like 01.01.07 and 31.12.07

the is simple wat to cahnge it or to ask if date in format like 01.01.07 put x

in i_date_from if date in format 01012007 put y thier

thankes

Read only

Former Member
0 Likes
852

write it out this way

REPORT ZDATEDIFF.

DATA: EDAYS LIKE VTBBEWE-ATAGE,

EMONTHS LIKE VTBBEWE-ATAGE,

EYEARS LIKE VTBBEWE-ATAGE.

PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,

TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.

call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

exporting

i_date_from = FROMDATE

i_date_to = TODATE

  • I_FLG_SEPARATE = ' '

IMPORTING

E_DAYS = EDAYS

E_MONTHS = EMONTHS

E_YEARS = EYEARS.

WRITE:/ 'Difference in Days ', EDAYS.

WRITE:/ 'Difference in Months ', EMONTHS.

WRITE:/ 'Difference in Years ', EYEARS.

INITIALIZATION.

FROMDATE = SY-DATUM - 60.

<b>

try the diff between 31st Dec 2006 and 1st Jan 2007. See if the answers you get is what you want.</b>

or else try something of these

DATA: EYEARS LIKE VTBBEWE-ATAGE.

PARAMETERS: FROMDATE LIKE PREL-BEGDA,

TODATE LIKE PREL-BEGDA DEFAULT SY-DATUM.

CALL FUNCTION 'COMPUTE_YEARS_BETWEEN_DATES'

EXPORTING

first_date = fromdate

  • MODIFY_INTERVAL = ' '

second_date = todate

IMPORTING

YEARS_BETWEEN_DATES = EYEARS

  • EXCEPTIONS

  • SEQUENCE_OF_DATES_NOT_VALID = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Write:/ eyears.

DATA: EMONTHS LIKE VTBBEWE-ATAGE.

PARAMETERS: FROMDATE LIKE SY-DATUM,

TODATE LIKE SY-DATUM

DEFAULT SY-DATUM.

CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'

EXPORTING

i_datum_bis = fromdate

i_datum_von = todate

  • I_KZ_INCL_BIS = ' '

IMPORTING

E_MONATE = emonths

.

write:/ emonths

regards,

srinivas

<b>*reward for useful answers*</b>

Read only

Former Member
0 Likes
852

Hi,

See tht ur l_begda, l_endda field should have values in the format yyyymmdd not 010107

eg - l_begda - 20070101

l_endda - 20071231

use like this u will get correct ans.

Reward points if usefull.

Regards,

Vimal

Read only

Former Member
0 Likes
852

Hi SHNYA,

I think ur format of giving Date is incorrect. So, check 'dd.mm.yyyy' or 'yyyymmdd'.

It should work.In case any problem pls reply.

Rewards if useful.

Sachin.

Read only

Former Member
0 Likes
852

regards,

srinivas

<b>*reward for useful answers*</b>