‎2007 Sep 07 4:04 AM
hi friends, i need to calculate the days lapsed between, when the idoc was created and when it showed error.
so i thought, i need to extract date1 from a table edids when status =50 (ie. idoc created ),
and then date2 should be picked up as soon as the status of this idoc becomes 51 ( ie. error idoc).
for this i thought of doing like below:
data: date1 type sy-datum,
date2 type sy-datum.
select * from edids into table int_edids
where docnum = t_edidc-docnum
and order by countr.
loop at int_edids.
if t_edidc-status = 50.
date1= int_edids-credat.
endif.
if t_edidc-status = 51.
date2 = int_edids-credat.
exit.
endif.
endloop.
lapsed_days = date1 - date2.
will this statement work.
is there a better way of doing this ?
can some one help me with this ?
‎2007 Sep 07 4:09 AM
‎2007 Sep 07 4:09 AM
Check these FM:
FIMA_DAYS_AND_MONTHS_AND_YEARS
Test the FM with the parameters as
Import parameters Value
I_DATE_FROM 12.08.2007
I_DATE_TO 15.08.2007
I_FLG_SEPARATE X " You wull get the output as Export parameters Value
E_DAYS 3
E_MONTHS 0
E_YEARS 0Regards
Gopi
‎2007 Sep 07 4:09 AM
‎2007 Sep 07 4:30 AM
Use this function module to count the number of days...
/SDF/CMO_DATETIME_DIFFERENCE
Pass date 1 and date 2 and get the difference in dates.
Regards,
SaiRam
‎2007 Sep 07 5:47 AM
hai Sanjana,
Use the Function Module ISHMED_CALC_DATE_TIME_DIFF
Import parameters Value
I_BEGDT 01.01.2007
I_BEGTM 00:00:00
I_ENDDT 01.08.2007
I_ENDTM 00:00:00
Changing parameters Value
CR_ERRORHANDLER
Export parameters Value
E_DIFF_DAY 212
E_ENDDT_EARLY
E_RC 0
U can find the time diff also from this function module.
OR OR OR OR
you Use SD_DATETIME_DIFFERENCE
DATE1 01.01.2007
TIME1 12:00:00
DATE2 01.08.2007
TIME2 10:00:00
Export parameters Value
DATEDIFF 211
TIMEDIFF 22
EARLIEST 1
Reward Points If Use Full
Thanks & Regards.
Shiva
Thanks & Regards,
Shiva
‎2007 Sep 07 5:52 AM
Hi,
Try with this code:
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.
Regards,
Bhaskar