‎2008 Jul 31 2:25 PM
I have a decimal datatype DEC length 15 which contains a date and time information for eg: 20,080,428,193,043
I need to convert this into two fields containing date and time separately.
Foe eg: here should be:
2008/04/28 and 19:30:43
How can I do this?
Thanks.
‎2008 Jul 31 4:54 PM
Hi,
Check this sample code,
DATA:
* If it is of type DEC of lenght 15 and decimal 0,
* then it will not hold '20,080,428,193,043',
w_dec TYPE cifpuorout-req_tstamp,
"value '20,080,428,193,043',
w_date TYPE sy-datum,
w_time TYPE sy-uzeit,
* If the value '20,080,428,193,043',then replace ',' with ''
w_char(20) TYPE c VALUE '20,080,428,193,043'.
REPLACE ALL OCCURRENCES OF ',' IN w_char WITH ''.
CALL FUNCTION 'CACS_TIMESTAMP_GET_DATE'
EXPORTING
i_timestamp = w_char
IMPORTING
e_date = w_date
e_time = w_time.
WRITE:/
w_date,
w_time.Note: moving value's from char to dec is not allowed ,please check what value you are getting '20,080,428,193,043',
or '20080428193043'.
Regards
Adil
‎2008 Jul 31 2:29 PM
‎2008 Jul 31 2:33 PM
Hi,
I am not into ABAP but from BW.
Can you please provide me the code?
‎2008 Jul 31 2:32 PM
Hi,
Try this FM,
CACS_TIMESTAMP_GET_DATEor
Try logic using offset.
Regards
Adil
Edited by: Syed Abdul Adil on Jul 31, 2008 3:33 PM
‎2008 Jul 31 2:35 PM
first use replace all occurrences and then concatenate
replace all occurrences of ',' in v_char with ''.
concatenate v_char0(4) '/' v_char4(2) '/' v_char+6(2) into
v_date.
concatenate v_char8(2) ':' v_char10(2) ':' v_char+12(2) into
v_time.
write 😕 v_date , v_time.
‎2008 Jul 31 2:36 PM
data:char(25) value '20,080,428,193,043' .
replace all occurrences of ',' in char with ' ' .
concatenate char0(4) '/' char4(2) '/' char+6(2) into char .
write:/ char.
‎2008 Jul 31 2:40 PM
Hi ,
It is not just one value I want to convert so I cannot specify a particular value.
I was just giving an example.
I will get DEC(15) values which I need to convert to date and time.
‎2008 Jul 31 2:49 PM
First move this DEC(15) variable to a type char15 variable.
Suppose this char variable is lv_date
Then first use
REPLACE all occurenceos of ',' with ''.
Then use
CONCATENATE lv_date(4) '/' lv_date4(2) '/' lv_date6(2) to lv_date.
Similarly you can fetch time in another variable.
Hope this clears your doubt.
‎2008 Jul 31 2:36 PM
Hi,
try this,
20,080,428,193,043 remove commas and pass the value to this FM
CACS_TIMESTAMP_GET_DATE
result will be date and time .
Regards
Adil
‎2008 Jul 31 2:41 PM
‎2008 Jul 31 2:43 PM
data:char(25) value '20,080,428,193,043',
char1(10),
char2(10) .
replace all occurrences of ',' in char with ' ' .
concatenate char0(4) '/' char4(2) '/' char+6(2) into char1 .
concatenate char8(2) ':' char10(2) ':' char+12(2) into char2 .
write:/ char1.
write:/ char2.
‎2008 Jul 31 2:57 PM
Hi,
Use this syntax:
if v_timestamp is teh one which contains the value
CONVERT TIME STAMP v_timestamp
TIME ZONE SY-ZONLO
INTO DATE dat
TIME tim.
After executing this statement
'dat' holds the value of the DATE
and 'tim' holds the value of TIME.
Hope this will help.
Regards,
Swarna Munukoti.
‎2008 Jul 31 3:04 PM
Let me try these different options and I shall get back to you.
‎2008 Jul 31 4:54 PM
Hi,
Check this sample code,
DATA:
* If it is of type DEC of lenght 15 and decimal 0,
* then it will not hold '20,080,428,193,043',
w_dec TYPE cifpuorout-req_tstamp,
"value '20,080,428,193,043',
w_date TYPE sy-datum,
w_time TYPE sy-uzeit,
* If the value '20,080,428,193,043',then replace ',' with ''
w_char(20) TYPE c VALUE '20,080,428,193,043'.
REPLACE ALL OCCURRENCES OF ',' IN w_char WITH ''.
CALL FUNCTION 'CACS_TIMESTAMP_GET_DATE'
EXPORTING
i_timestamp = w_char
IMPORTING
e_date = w_date
e_time = w_time.
WRITE:/
w_date,
w_time.Note: moving value's from char to dec is not allowed ,please check what value you are getting '20,080,428,193,043',
or '20080428193043'.
Regards
Adil