01-31-2008 6:41 AM
Hi,
I'm trying to load some data from a flat file into BW. I have a date column in the CSV file that has the date in YYYYMMDD format. when I load it into Bw, I want to change the format to DD.MM.YYYY .
I have written a small routine that should do this, but it doesn't seem to work.
data:v_date like sy-datum,
v_date1(10) type c.
Concatenate v_date+6(2) '.' v_date+4(2) '.' v_date+0(4) into v_date1.
RESULT = V_DATE1.
The result of this routine is YY.YYMM.DD instead of DD.MM.YYYY.
Can anyone tell me where I'm going wrong?
Thanks
Sam
01-31-2008 6:43 AM
Hi,
Use Write statement using EDIT MASK .you can achieve the result.
WRITE .... EDIT MASK .....
ex:
data : ldate type sy-datum,
wdate type char10.
ldate = sy-datum.
write ldate TO wdate USING EDIT MASK '____.__.__'.
WRITE : / wdate.
Edited by: Ramesh Hirial on Jan 31, 2008 3:45 PM
01-31-2008 6:43 AM
Hi,
Use Write statement using EDIT MASK .you can achieve the result.
WRITE .... EDIT MASK .....
ex:
data : ldate type sy-datum,
wdate type char10.
ldate = sy-datum.
write ldate TO wdate USING EDIT MASK '____.__.__'.
WRITE : / wdate.
Edited by: Ramesh Hirial on Jan 31, 2008 3:45 PM
01-31-2008 7:06 AM
Thanks to all of you for your help. All of your codes work, but the result is still the same. It display the values as YY.YYMM.DD instead of DD.MM.YYYY.
The CSV file is been created by a program in a different system. The date field is a general number. when i try to change the format of the column to 'date', the ouput of the column is '###########' . Could this be one of the reason as to why the code is not inverting the values and keeping it the same?
Regards,
Sam
01-31-2008 7:20 AM
Your code is right only. It is working perfectly. Problem may be because of the type of result field.
Can you try to write the value of v_date1.
01-31-2008 7:28 AM
Hi,
Thanks again for the help. the problem was with the setting of my system date. I had them as DD.MM.YYYY. When I changed it to YYYY.MM.DD and ran the routine, it worked great.
Now I'm still getting a error for the rows where there is no date present. How can I have the system disregard the blank date column and still take the rest of the record?
I'm assigning points for all you that helped.
Regards
Sam
01-31-2008 7:34 AM
only fetch the record whete date is not initial.
ex: loop at itab where date ne space.
endloop.
01-31-2008 7:35 AM
sorry its like this
loop at itab where date is not initial.
endloop.
01-31-2008 7:54 AM
Hi Keshu,
When I add the loop to my code, it doesn't seem to work. It gives me the following error:
does not match the user-dependent date format --> long text
Diagnosis
does not correspond to the date format that is assigned to the current user ASDSAD.
System Response
The date cannot be converted; the process was terminated.
Procedure
Enter the conversion exit RSDAT for automatic date format detection.
Any suggestions?
01-31-2008 8:15 AM
This is new to me...may be probs in some system format specs..
try this.
data:v_dat(10) type c.
loop at itab.
v_dat = itab.-date.
if v_dat is not initial.
process u r code.
endif.
endloop.
revert is any probs occurs....:-)
01-31-2008 6:44 AM
01-31-2008 6:46 AM
Hi,
Try like this..
data:v_date like sy-datum,
v_date1(12) type c.
Concatenate v_date+6(2) '.' v_date+4(2) '.' v_date+0(4) into v_date1.
RESULT = V_DATE1.
regards,
Omkar.
01-31-2008 6:47 AM
use fm CONVERT_DATE_TO_EXTERNAL /CONVERT_DATE_TO_INTERNAL
CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'
EXPORTING
datum = lv_date1
dtype = 'DATS'
IMPORTING
idate = lv_date2.
write lv_date2.
01-31-2008 6:48 AM
data v_date type sydatum.
v_date = '20081225'.
data v_date1 type string.
concatenate v_date6(2) '.' v_date4(2) '.' v_date+0(4) into v_date1.
write v_date1.
Just try this...
The coding which u have written is correct only...
Reward if helpfull.
01-31-2008 6:51 AM
Hi,
Try this
concatenate lv_date6(2) lv_date4(2) lv_date+0(4) into lv_date_temp separated by '.'.
Some of the FM used are:
CONVERT_DATE_TO_INTERN_FORMAT
CONVERT_DATE_FORMAT
CONVERSION_EXIT_PDATE_OUTPUT
Regards,
Satish
01-31-2008 7:13 AM
data:date(10) type c.
write sy-datum to date.
write date.
this will be sufficient...date holds value like 31.01.2008
01-31-2008 7:14 AM
Hi
use
convert_date_to_external or
convert_field_to_extern_format
in SAP date is tored as YYYYMMDD
so use sy-datum and pass the value to it
Reward if useful.