Skip to Content

Transfer Date from Excel file to Internal Table (Date Format Issue)

Hi all,

I'm working on an SAP ABAP assignment in which I should upload data from Excel file to the Database Table I'v already created in SAP. I have two columns containing dates in the Excel file in which the dates are in the 11/18/2018 (MM/DD/YYYY) format. But when uploading to internal table and updating the database, it is displayed as 8//20/11/1.

Is this relate to the difference between value unconverted and the value displayed?

I will appreciate if anyone helps me with this issue.

Thank you

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Mar 11 at 05:37 PM

    >> Is this relate to the difference between value unconverted and the value displayed?

    Yes, first of all, there is a missing conversion (from 'MM/DD/YYYY' to 'YYYYMMDD') and second, in GUIs, these wrongfully copied date values will be displayed also 'wrong'.

    your logic:
    EXCEL        =>   ABAP      =>   SAP-GUI
    MM/DD/YYYY   =>   YYYYMMDD  =>   MM/DD/YYYY 
    11/18/2018   =>   11/18/20  =>   8//20/11/1
    
    
    expected logic:
    EXCEL        =>   ABAP      =>   SAP-GUI
    MM/DD/YYYY   =>   YYYYMMDD  =>   MM/DD/YYYY 
    11/18/2018   =>   20181118  =>   11/18/2018
    

    If you want to have the Excel-Dates in SAP as the data type DATS (which I strongly recommend for all the underlying ABAP date functionalities), you have to convert the Excel-Date fields into the specific 8 character field for data type DATS.

    Lets assume you already have the import rows in a table with separate structure fields for the different Excel rows and want to transfer the date values (which have a string or at least a char10 type, if it is string, you make sure that the import value has at least a string-length of 10 characters to avoid a dump, you might also do other value checks if required) from the import rows to the 'export' rows to insert those into your SAP ABAP database tables:

    1. First, you take the four characters from the sixth position for the year
    2. concatenate that with the first two characters for the month
    3. and lastly concatenate that with the two characters from the third position for the day
    export_row-date = import_row-date+6(4) && import_row-date(2) && import_row-date+3(2).
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 11 at 02:11 PM

    Hi

    In SAP the dates are store in YYYYMMDD format - so you need to convert the string in ths format and then assign it to the uploading field.

    Example - if your variable read from excel file is having 08/01/2020 - then before assigning you write the following statment to reconvert it

    concatinae wa_file-date+6(4) wa_file-date+3(2) wa_file-date+0(2) into target varialble

    OR

    write wa_file-date to targetfield 'YYYYMMDD'.

    Regards,

    Venkat

    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.