‎2007 Jul 16 1:45 PM
i desire to pass a date to function /SDF/CMO_DATETIME_DIFFERENCE and i have a date variable in the format 12102006 (t_datatabfinal-capitalisation) and i want to concatenate datatab in2 a format that will be accepted by the function, please assist
this is wat i have:
concatenate t_datatabfinal-capitalisation4(4) t_datatabfinal-capitalisation2(2) t_datatabfinal-capitalisation(2) into capitalisation.
break-point.
data: date_2 type p .
date_2 = capitalisation.
CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'
EXPORTING
DATE1 = '20070630'
TIME1 = '000000'
DATE2 = date_2
TIME2 = '000000'
IMPORTING
DATEDIFF = days
TIMEDIFF =
EARLIEST =
EXCEPTIONS
INVALID_DATETIME = 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.
‎2007 Jul 16 1:48 PM
Hi tatenda,
1. If the variable, u are passing to the FM,
is of type DATE,
then pass the variable, as it is.
There will be no problem.
2. All dates are stored internally in the format YYYYMMDD,
but while displaying, the are displayed in the user format,
which can vary.
regards,
amit m.
‎2007 Jul 16 1:52 PM
The problem is that there is a field in the BDC program that wants the date as DDMMYYYY so we want to change the date from that format to this format YYYYMMDD.
‎2007 Jul 16 1:49 PM
Hi Tatenda,
Date_2 should be of the same type as in the function module.
Regards
Arun
‎2007 Jul 16 1:55 PM
Thats what we are trying to do. the format is of type P so we are trying to change the date format to type p so tat FM can accept it
‎2007 Jul 16 2:04 PM
Hi Tatenda Chaibva ,
<b>Date format for entry into BDC</b>
Because a date field is stored and displayed in different formats within SAP the following code is required to convert the date into a format which can be input onto a screen field.
* Date field
data: ld_date(8).
ld_date(2) = t_datatabfinal-capitalisation+6(2).
ld_date+2(2) = t_datatabfinal-capitalisation+4(2).
ld_date+4(4) = t_datatabfinal-capitalisation(4).
use ld_date . /* it is as per sap format for BDC
reward points if it is usefull ...
Girish
‎2007 Jul 16 2:06 PM
Hi,
Check this code : in this FM the date format is type D (YYYYMMDD).
data : date_diff type p, earliest type C, timediff type p.
data : a_new type d, b_new type d.
a_new = '20070701'. "Date format is YYYYMMDD
b_new = '20070730'. "Date format is YYYYMMDD
CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'
EXPORTING
date1 = a_NEW
time1 = '000000'
date2 = b_NEW
time2 = '000000'
IMPORTING
DATEDIFF = date_diff
TIMEDIFF = timediff
EARLIEST = earliest
EXCEPTIONS
INVALID_DATETIME = 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 : / date_diff.
write : / timediff.
write : / earliest.
Reward points, if helpful,
Sandeep Kaushik