Skip to Content

how to convert the date format in excel sheet upload ( BDC ) to default date format of the user executing the BDC

Hi Members ,

Greetings for the day ahead .

I am writing a conversion program ( BDC ) in which the date fieldis there . Now the user who is going to execute this BDC has a different Default date format ( decimal format ) . I want to make / know a reusable object like method of a class or a Function module which can be used in all other BDC's also to convert any date format to the default date format of the user executing the BDC .

I know that the default date format is stored in USR01 table in field DATFM.. my BDC is giving dump because the user has a different Default date format then the one given in file .

I want to make it working for all date formats . Screenshot below .

Plz suggest a reusable solution which can be used for other programs like FM or Class Method .

Thanks in Advance .

Devendra Singh

date.png (31.4 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Sep 07, 2016 at 12:41 AM

    I suggest that you use BAPIs instead of BDC; then you won't have to worry about any of these format issues.

    BDC is old, unreliable technology and is no longer used at many sites.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 06, 2016 at 08:09 PM

    Hi Devendra,

    For this also use the similar logic that I mentioned for the quantity. Use the 'Write' statement.

    Just a reminder.... please do some more research before posting these questions. Also, mark the answers as Helpful or Answered where applicable.

    -Chandra

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 07, 2016 at 04:00 AM

    Hi,

    there is FM "KCD_EXCEL_DATE_CONVERT" to convert the date in SAP internal format which is year month date.

    Using this FM you can specify 4 date formats: TMJ / MTJ / JMT / JTM

    where, J = Year, M = Month & T = Date.

    DATE_EXTERNAL = '07/09/2016'.

    CALL FUNCTION 'KCD_EXCEL_DATE_CONVERT'

    EXPORTING

    EXCEL_DATE = DATE_EXTERNAL

    DATE_FORMAT = 'TMJ'

    IMPORTING

    SAP_DATE = DATE_INTERNAL

    EXCEPTIONS

    OTHERS = 0.

    WRITE : / date_internal.

    thanks!!

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 07, 2016 at 06:49 AM

    hi devendra,

    you can just use a simple WRITE statement,

    that would converts into the default date format.

    see below samle code,

    TYPE-POOLS:TRUXS.

    *data and internal table declaration ****************


    types : BEGIN OF ty_itab,
    serno type i,
    date type erdat,
    END OF ty_itab.

    data : wa_itab type ty_itab,
    it_itab type TABLE OF ty_itab.


    data : BEGIN OF wa_itab1,
    serno type n,
    date type char10,
    END OF wa_itab1.

    data : it_itab1 like TABLE OF wa_itab1.




    DATA:IT_RAW TYPE TRUXS_T_TEXT_DATA,
    IT_FNAM TYPE FILETABLE,
    RETURN TYPE I.



    *sel screen declaration *****************************
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

    SELECTION-SCREEN skip 1.

    PARAMETERS : FILE LIKE RLGRAP-FILENAME OBLIGATORY.

    SELECTION-SCREEN skip 4.

    SELECTION-SCREEN COMMENT 2(75) comm1.

    SELECTION-SCREEN END OF BLOCK b1.
    *****************************************************


    *include bdcrecx1.


    AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    FILE_NAME = FILE.



    start-of-selection.


    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
    I_FIELD_SEPERATOR = 'X' "is an .xls file
    I_LINE_HEADER = 'X' "has a header line
    I_TAB_RAW_DATA = IT_RAW
    I_FILENAME = FILE
    TABLES
    I_TAB_CONVERTED_DATA = it_itab.


    loop at it_itab into wa_itab.

    write wa_itab-serno to wa_itab1-serno.
    write wa_itab-date to wa_itab1-date.
    APPEND wa_itab1 to it_itab1.

    endloop.


    loop at it_itab1 into wa_itab1.

    endloop.

    excel file,

    let me debug the code also,


    d_excel.jpg (24.4 kB)
    d1_itab.jpg (44.8 kB)
    d1_itab1.jpg (64.2 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 06, 2016 at 07:49 PM

    Get the date in YYYYMMDD format from the user, and you won't have to worry about the Date format.

    -Amit.

    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.