Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

GUI_UPLOAD

Former Member
0 Likes
947

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
845

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.

5 REPLIES 5
Read only

Former Member
0 Likes
845

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

Read only

Former Member
0 Likes
845

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

Read only

andreas_mann3
Active Contributor
0 Likes
845

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 !

Read only

Former Member
0 Likes
846

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.

Read only

0 Likes
845

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