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

Problem in function module.

Former Member
0 Likes
754

Hi experts,

I have used this function module "C14B_DIFF_BT_2_DATES" to find out the difference between the two dates.

I have declared two local variables as like in the function module for those two dates and fetched the no of the months in between those dates.

Here comes the problem while I am checking in function module individually in se37 its working fine. But while using this function module in my report the no. of months which is returning is not correct.

I have declared same as like that of in the function module but the values are not correct.Where is the actual error?

Thanks,

Sakthi

1 ACCEPTED SOLUTION
Read only

bpawanchand
Active Contributor
0 Likes
592

Hi

Check this Snippet

DATA :
  w_d TYPE sy-datum,
  w_d2 TYPE sy-datum,
  w_days TYPE i,
  w_months TYPE i,
  w_years TYPE i.

w_d = '20080810'.
w_d2  = sy-datum .

CALL FUNCTION 'C14B_DIFF_BT_2_DATES'
  EXPORTING
    i_date_from               = w_d
    i_date_to                 = w_d2
  IMPORTING
    e_days                    = w_days
    e_months                  = w_months
    e_years                   = w_years
  EXCEPTIONS
    plausibility_check_failed = 1.

WRITE /:
  w_days,
  w_months,
  w_years.

output is 14

regards

Pavan

4 REPLIES 4
Read only

anversha_s
Active Contributor
0 Likes
592

Hi Sakti,

Please replace ur FM with below FM. It will work perfectly.

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.

Regards,

Anversha

Read only

bpawanchand
Active Contributor
0 Likes
593

Hi

Check this Snippet

DATA :
  w_d TYPE sy-datum,
  w_d2 TYPE sy-datum,
  w_days TYPE i,
  w_months TYPE i,
  w_years TYPE i.

w_d = '20080810'.
w_d2  = sy-datum .

CALL FUNCTION 'C14B_DIFF_BT_2_DATES'
  EXPORTING
    i_date_from               = w_d
    i_date_to                 = w_d2
  IMPORTING
    e_days                    = w_days
    e_months                  = w_months
    e_years                   = w_years
  EXCEPTIONS
    plausibility_check_failed = 1.

WRITE /:
  w_days,
  w_months,
  w_years.

output is 14

regards

Pavan

Read only

Former Member
0 Likes
592

it is working fine, error lies in your code.

add 1 day extra to the i_date_to and see ..

check this code..

REPORT  ZTEST_DATE_DIIF.

data: i_date_from type sy-datum,
      i_date_to type sy-datum.
data: e_days type i,
      e_months type i,
      e_years type i.

 i_date_to = '20090101'.
 i_date_from = '20080101'.


CALL FUNCTION 'C14B_DIFF_BT_2_DATES'
  EXPORTING
    i_date_from                     = i_date_from
    i_date_to                       = i_date_to
 IMPORTING
   E_DAYS                          = E_DAYS
   E_MONTHS                        = E_MONTHS
   E_YEARS                         = E_YEARS
 EXCEPTIONS
   PLAUSIBILITY_CHECK_FAILED       = 1
          .
write:/ e_days, e_months, e_years.

Read only

Former Member
0 Likes
592

Problem Solved.

Thanks for all your answers.

Hope you received your valuable points.

Regards,

Sakthi