‎2005 Jan 11 7:42 AM
hai,
I wrote program to upload text file to internal table(referred by ADDON TABLE)using FM GUI_UPLOAD.
while uploading i have one field with date value '2005/01/05' in text file.
where as in ADDON TABLE i have defined standard date element as DATS with 8char for date field.
so while uploading it gets mismatched and displaying date output wrongly.
if i input 20050108 as input from text file it works fine. how to solve this?
Chandra
‎2005 Jan 11 9:46 PM
hai,
Thanks for your assistance.
I think we are in diff track.
my requirement is, I have one datefield in text file as '2005/02/11'.
Now i want to insert this field(ie record) in to addon table
where this field is declared as "DATS" in dateelement.
Now i guess we want to convert this textfile datefield into
ABAP DATS(8 char) field.
how to convert this? does ur before code suits this requirement
Chandra.
‎2005 Jan 11 7:54 AM
Chandra, define the date element as char(10), then, when you have the internal table with the file upload you can get it modify later.
Regards.
Carlos
‎2005 Jan 11 9:04 AM
hai,
Thanks foryour reply.
if i want to save date as date format in table no other way.?
then whats the use of "Dats" data element in data dictionary.
when we display records of table the values are displayed in "2005/01/11" format in the list.
if i use char(10) to store date, then when we use "Dats" date type.
Chandra
‎2005 Jan 11 9:52 AM
Hi Chandra,
here's a possible solution
DATA digit(11) VALUE '0123456789 '.
DATA x_date(10) VALUE '2005/01/05' .
DATA ok_date TYPE sy-datum.
CALL FUNCTION 'PREPARE_STRING'
EXPORTING
i_valid_chars = digit
i_xvalid_check = 'X'
i_xchar_repl = 'X'
i_xtoupper = 'X'
CHANGING
c_string = x_date.
CONDENSE x_date NO-GAPS.
MOVE x_date TO ok_date.
-> go on processing with ok_date !
‎2005 Jan 11 9:46 PM
hai,
Thanks for your assistance.
I think we are in diff track.
my requirement is, I have one datefield in text file as '2005/02/11'.
Now i want to insert this field(ie record) in to addon table
where this field is declared as "DATS" in dateelement.
Now i guess we want to convert this textfile datefield into
ABAP DATS(8 char) field.
how to convert this? does ur before code suits this requirement
Chandra.
‎2005 Jan 11 10:09 PM
Hi Chandra,
When you are uploading the file, there is no alternative to you except to declare the internal table fields to be of the same length as it is in the file. So, if the file is coming with date as 10 characters length, you have to have your internal table field length as 10 characters.
Once you upload the data, you can then do as follows
*-- internal table to be used for upload of the file
DATA: BEGIN OF itab1 OCCURS 0,
*-------all other fields of the internal table
date1(10).
*-- all other fields of the internal table
DATA: END OF itab1.
*-- internal table to be used after upload of the file
DATA: BEGIN OF itab2 OCCURS 0,
*-------all other fields of the internal table
date2 LIKE sy-datum.
*-- all other fields of the internal table
DATA: END OF itab2.
*-- upload the file using itab1
LOOP AT itab1.
*-- move all other fields of itab1 to itab2.
*-- assuming that the date is always coming in the format YYYY/MM/DD
SPLIT itab1-date1 AT '/' INTO itab2-date2+0(4)
itab2-date2+4(2)
itab2-date2+6(2).
APPEND itab2.
CLEAR itab2.
ENDLOOP.
Hope this helps, if not let me know.
Srinivas