Skip to Content
author's profile photo Former Member
Former Member

GUI_UPLOAD

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2005 at 09: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.

    Add a comment
    10|10000 characters needed characters exceeded

    • 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
      

  • Posted on Jan 11, 2005 at 09: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 !

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2005 at 07: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2005 at 09: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.