Date Format IN BDC

Hi,
In One Interview I was asked that How can You Handle Data Format when Writing BDC ?

Satya,
The date format depends on User settings. Its different for different login ID's.
It can be YYYY.MM.DD or MM.DD.YYYY or anything.
To handle the date format, you need to query on table USR01 and fetch DATFM field that stores date format.
Refer below piece of code
*/...Fetch the date format settings for the user
      SELECT SINGLE datfm
               INTO gv_date_format
               FROM usr01
              WHERE bname = sy-uname.
  CASE gv_date_format.
    WHEN 1.     "DD.MM.YYYY
      CONCATENATE fv_impdate+6(2) '.'
                  fv_impdate+4(2) '.'
                  fv_impdate+0(4) INTO fv_expdate.
    WHEN 2.     "MM/DD/YYYY
      CONCATENATE fv_impdate+4(2) '/'
                  fv_impdate+6(2) '/'
                  fv_impdate+0(4) INTO fv_expdate.
    WHEN 3.     "MM-DD-YYYY
      CONCATENATE fv_impdate+4(2) '-'
                  fv_impdate+6(2) '-'
                  fv_impdate+0(4) INTO fv_expdate.
    WHEN 4.     "YYYY.MM.DD
      CONCATENATE fv_impdate+0(4) '.'
                  fv_impdate+4(2) '.'
                  fv_impdate+6(2) INTO fv_expdate.
    WHEN 5.     "YYYY/MM/DD
      CONCATENATE fv_impdate+0(4) '/'
                  fv_impdate+4(2) '/'
                  fv_impdate+6(2) INTO fv_expdate.
    WHEN 6.     "YYYY-MM-DD
      CONCATENATE fv_impdate+0(4) '-'
                  fv_impdate+4(2) '-'
                  fv_impdate+6(2) INTO fv_expdate.
  ENDCASE.
This would convert the date into the format set for user.
Hope this is helpful.
Amogh

Similar Messages

  • How to write date format in bdc

    how to write date format in bdc report

    Hi,
         First you have a data decleration i.e data l_format(10) type c.
    now if a variable say l_date which is of sy-datum type, you will have to  <b>write l_date to l_format</b>, this will transfer the date in which you(user) have set the date format in user settings. Never hard code the format such as dd.mm.yyyy. or mm/dd/yyyy because the may have different formats, and the BDC will fails. After you have used write to to new l_format, pass this new value to BDC recording.
    Reward if useful.
    Kiran

  • Check the date format

    Hi,
      Can anybody tell me how to check the date format in BDC while updating.
      The system date format is like mm/dd/yyyy. Check the dates format, in case of error return the following message “The date format should be YYYYMMDD”.
    Thanks......

    Dear Anil,
    This is a common problem, when carrying out BDC.
    For example, while recording you met with the field --> MKPF-BUDAT.
    Go to SE11 --> MKPF --> Search for BUDAT --> Double click on the Data Element i.e. BUDAT --> Double Click on the domain DATUM --> You can see under the block Output Characteristics : Output Length = 10.
    While declaring the TYPES Structure, make it CHAR(10).
    Consider this technique as the Rule-of-Thumb while doing BDC.
    Regards,
    Abir
    Don't forget to award points *

  • In bdc if date format of records is different  do we need to hard code

    in bdc if date format of records is different  do we need to hard code or bdc will support automatically,please provide the answer.

    Make sure to format the date before passing to BDC.
    data: datum(10) type c.
    call function 'CONVERT_DATE_TO_EXTERNAL'
      EXPORTING
        DATE_INTERNAL                  = SY-DATUM
      IMPORTING
        DATE_EXTERNAL                  = datum.
    Regards,
    Rich Heilman

  • Date format in flat file of bdc

    Hi Folks,
    In BDC I have a flat file which has to be uploaded from a flat file and 4 users are using each of one has their date format.
    so inorder to get their required date format what i need to do .

    Hi,
           use the below logic in your code.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-031.
    PARAMETERS: date1 RADIOBUTTON GROUP rad1 DEFAULT 'X',                                     "SAP date format YYYYDDMM
                date2 RADIOBUTTON GROUP rad1,                                                 "Date format like aprial31, 2006
                date3 RADIOBUTTON GROUP rad1,                                                 "Date format like 31 apr,2006
                date4 RADIOBUTTON GROUP rad1,                                                 "Date format like DD/MM/YYYY
                date5 RADIOBUTTON GROUP rad1.                                                 "Date format like DD.MM.YYYY
    SELECTION-SCREEN END OF BLOCK b2
    FORM getmonth .
      SELECT mnr
             ktx
             ltx
       INTO TABLE T_month
       FROM t247
       WHERE spras = 'EN'.
      IF sy-subrc NE '0'.
          MESSAGE I                                                          "Message - Not able to get month values from the table T247
      ENDIF.
    ENDFORM.                                                                               
    DATA : temp_date(16)  TYPE c,
             temp1_date(60) TYPE c,
             year(4)        TYPE c,
             daymonth(11)   TYPE c,
             daymonth1(11)  TYPE c,
             month(9)       TYPE c,
             day(2)         TYPE c,
             mon            LIKE t247-ktx,
             len            TYPE i   .
      MOVE date TO temp1_date .
      CONDENSE temp1_date NO-GAPS.
      MOVE temp1_date TO temp_date .
      IF date2 EQ 'X'.                                                                     "The date format is like Aprial 31, 2007
        CONDENSE temp_date NO-GAPS.
        SPLIT date AT ',' INTO daymonth year.
        IF STRLEN( year ) NE '4'.
          error = 'X'.
          WRITE :  'Invalid date format.'.
        ELSE.
          daymonth1 = daymonth.
          CONDENSE daymonth1 NO-GAPS.
          _len      = STRLEN( _daymonth1 ).
          l_len      = 13 - len.
          SHIFT daymonth1 RIGHT BY len PLACES.
          CONDENSE daymonth1 NO-GAPS.
          month    = daymonth1.
          CONDENSE month NO-GAPS.
          SORT t_month BY monthltx.
          READ TABLE t_month WITH KEY monthltx =  month.
          IF sy-subrc <> 0.
            error = 'X'.
            WRITE : 'Invalid date format.' .
          ELSE.
            len = STRLEN( month ).
            CONDENSE daymonth NO-GAPS.
            SHIFT daymonth LEFT BY len PLACES.
            day =  daymonth.
            CONDENSE day NO-GAPS.
            CONCATENATE year t_month-monthnumber day INTO o_date.
          ENDIF.
        ENDIF.
      ELSEIF p_date3 EQ 'X'.                                                                "The date format is like 31 apr, 2007
        CONDENSE temp_date NO-GAPS.
        SPLIT i_date AT ',' INTO daymonth year.
        IF STRLEN( year ) NE '4'.
          error = 'X'.
          WRITE :  'Invalid date format.'.
        ELSE.
          daymonth1 = daymonth.
          CONDENSE daymonth1 NO-GAPS.
          SHIFT daymonth1 LEFT BY 2 PLACES.
          CONDENSE daymonth1 NO-GAPS.
          month  = daymonth1.
          CONDENSE month NO-GAPS.
          TRANSLATE month TO UPPER CASE.
          SORT t_month BY monthstx.
          MOVE month to mon.
          READ TABLE t_month WITH KEY monthstx = mon.                                 
          IF sy-subrc <> 0.
            error = 'X'.
            WRITE : 'Invalid date format.' .
          ELSE.
            CONDENSE daymonth NO-GAPS.
            day =  daymonth+0(2).
            CONDENSE day NO-GAPS.
            CONCATENATE year t_month-monthnumber day INTO o_date.
         ENDIF.
       ENDIF.
      ELSEIF p_date4 EQ 'X' OR p_date5 EQ 'X'.                                             "Date format is like DD.MM.YYYY or DD/MM/YYYY
        CONDENSE temp_date NO-GAPS.
        IF STRLEN( temp_date ) EQ 10.
          o_date0(4) = temp_date6(4).
          o_date4(2) = temp_date3(2).
          o_date6(2) = temp_date0(2).
        ELSE.
          error = 'X'.
          WRITE : 'Invalid date format.' .
        ENDIF.
    ENDIF.
    IF STRLEN( o_date ) NE '8'.
         error = 'X'.
         WRITE : 'Invalid date format.'.
    ENDIf.
    ENDFORM.                                                                               
    regards

  • BDC of below data format

    my EXCEL FORMAT IS LIKE BELOW :
    header                                       Item
    F1        I     F2     I    F3     I        F4   I        F5      I 
    2                3             TR             R5              U6
                                    ER             TY              FG
                                    FG             RG             RF
    1               5             TT               TR              TR
                                   RTE            TT                RTR
    i want to do bdc for the above data format.Can anybody suggest
    me how to do with simple coding ?
    thanks

    Hello,
    Use a FM to upload the file into an internal table....
    FM GUI_UPLOAD WILL BE ENOUGH.
    the create the Bdc seassion.... you ´ll find a lot of samples on the forum
    Bye
    gabriel p

  • Authorization in BDC session (date format)

    Hi All,
      I have a very peculiar problem, When I am executing a Background job (XK15) sometimes the job is successful and sometimes it is failing. When I am checking the error (SM35)it is showing as Date format (MM/DD/YYYY). My data format is same as MM/DD/YYYY but observed that under authorization it is taking different users.Sometimes it is taking my user id and the jobs are successful.
    I feel that when it is taking different user ids for the sessions executed by me it is taking the date format of those user ids and I am getting the date format error.
    Formatting error in the field RV13A-DATAB;
    see next message     XK15     1     SAPMV13A     1806     2     E     0
    Enter date in the format ____/__/__
    Please let me know why it is taking different userid's and how to resolve this issue ?
    Early response is highly appreciated.
    Thanks
    Supriya

    Hi,
    Goto tableUSR01.
    Take field value 'DATFM' for every user.
    Depends on this use FM, 'CONVERSION_EXIT_PDATE_OUTPUT' to convert date.
    or do manual processing using concatenate statement to get user specific date format.
    If you struck up anywhere revert back,
    Thanks,
    Krishna.

  • Date format in ALV report

    Hi all,
    I want to change date format in ALV list that is displayed in wrong format.
    I use this piece of code:
    CALL METHOD r_alv_grid->set_table_for_first_display
        EXPORTING
          i_structure_name = 'ZSTANJEKOMISIONARA'
          is_layout        = gs_layout
        CHANGING
          it_outtab        = it_stanja
        EXCEPTIONS
          OTHERS           = 4.
    Problematic field of structure ZSTANJEKOMISIONARA is defined like this:
    VRIJEDI_DO     ZEVO_VRIJEDI_DO     DATS     8
    Now, date is displayed like this: 09.20.3009 insted it should be like this: 30.09.2009.
    How can I change this? Thanks.

    The data is internally stored in an external format. Go back to the program that filled this field, there is something missing there.
    Look at FM like
    - CONVERT_DATE_TO_INTERN_FORMAT
    - CONVERSION_EXIT_PDATE_INPUT
    You only keep date in external format when filling a BDC, for most other input mode (BAPI and the like) data must be converted to internal format.
    Regards,
    Raymond

  • Date formating Problem

    Hi Experts,
    Please guide me i am alone here.
    I Developed one BDC program For IW51.
    I want to wirite the condition for already exitting record based on the date.
    So i select the data from VIQMEL(view).
    I am getting the problem with date format, when i am selecting the data the date format coming like yymmdd,
    but the tcode updating the format is like ddmmyy. 
    please guide me how can i solve this problem.
    Please give any sample code for this scnario.
    Thanks Advance
    Edited by: krishnab121 on Feb 18, 2011 6:32 AM
    Moderator Message: Date related questions are not allowed.
    Edited by: kishan P on Feb 18, 2011 11:27 AM

    Hi,
    <<removed by moderator>>
    Close the thread if answered correctly.
    Regards,
    Saurabh
    MOderator Message: Do NOT answer basic questions. Do NOT ask the Poster to close his questions. Thats not your job and thats against the rules of the forum.
    Edited by: kishan P on Feb 18, 2011 11:28 AM

  • Invalid Date format

    Hi All, My issue is that I download data to excel from a web report and then I try to use the date fields to do some calculations, but when I do so, the fomula doesn't accepts the formats. When I check the format it shows 'Text format' for these fields. Then to do the calculation I have to convert the date fields in excel to date format and then use them. Is there a way I can get the dates downloaded in date format and then I can do the calculations without doing any processing in excel. Thanks
    Puneet

    Dear Peri,
    This is a common problem, when carrying out BDC.
    For example, while recording you met with the field --> MKPF-BUDAT.
    Go to SE11 --> MKPF --> Search for BUDAT --> Double click on the Data Element i.e. BUDAT --> Double Click on the domain DATUM --> You can see under the block Output Characteristics : Output Length = 10.
    While declaring the TYPES Structure, make it CHAR(10).
    Consider this technique as the Rule-of-Thumb while doing BDC.
    Regards,
    Abir
    Don't forget to award points *
    Regards,
    Abir
    Don't forget to award Points *

  • Date Format in Webview Report

    Hi,
    We have just upgraded the ICM Enterprise 6.0 to UCCE 7.5. But when we tried  to generate the Webview Historical Report (e.g. Call Type Daily Report), the  following occurs:
    1. The date format is in mm/dd/yyyy format, whereas the date format in ICM  Webview 6.0 previously was in dd-M-yy format (e.g. 12-Jul-10). I checked the  Regional setting in the new ICM Adminworkstation (with webview), the date format  is in mm/dd/yyyy format, i tried to change the date format to match the previous  one, but the date format still does not change accordingly in the report.
    2. Some of the data in the new webview report does not match the one in  previous webview report, based on the same selected report period and same Call  Type. some data was missing.
    Are the 2 cases mentioned above related and caused by the common problem?
    Appreciate any advice.
    Thanks & Regards,
    Eric

    The data is internally stored in an external format. Go back to the program that filled this field, there is something missing there.
    Look at FM like
    - CONVERT_DATE_TO_INTERN_FORMAT
    - CONVERSION_EXIT_PDATE_INPUT
    You only keep date in external format when filling a BDC, for most other input mode (BAPI and the like) data must be converted to internal format.
    Regards,
    Raymond

  • Date format for call transaction

    Hi,
    What is the best solution for passing a date field to a call transaction in the date format that the user has in his settings?.
    Rgds

    The best solution is to define a character field of length 10.  Then WRITE the date to the BDC_DATE and then use this variable when passing to BDC.
    data: bdc_date(10) type c.
    write sy-datum to bdc_Date.
    Regards,
    Rich Heilman

  • Convert the date into user default date formate

    I am wrinting a bdc and i want to convert the date into user default date farmate ..please suggust the functiom module should i use...

    actually by using dats or d type you can get the user specific date itself.
    but if u have different dates format that need to be converted to the user specific date then you can follow below procedure
    1. retrieve the user format from usr01
        SELECT SINGLE datfm
          INTO w_datfm
          FROM usr01
         WHERE bname EQ sy-uname.
    pass w_datfm to the below FM (4th import parameter)
    2. create Z - FM and retrieve the user secific date
    FUNCTION ZFXX_USER_SPECIFIC_DATE.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(IW_DAY) TYPE  CHAR2
    *"     VALUE(IW_MONTH) TYPE  CHAR2
    *"     VALUE(IW_YEAR) TYPE  CHAR4
    *"     VALUE(IW_DATFM) TYPE  USR01-DATFM
    *"  EXPORTING
    *"     VALUE(EW_USER_DATE) TYPE  CHAR0008
    *1  DD.MM.YYYY
    *2  MM/DD/YYYY
    *3  MM-DD-YYYY
    *4  YYYY.MM.DD
    *5  YYYY/MM/DD
    *6  YYYY-MM-DD
    CASE iw_datfm.
      when '1'.
        concatenate iw_day iw_month iw_year
               into ew_user_date.
      when '2'.
        concatenate iw_month iw_day iw_year
               into ew_user_date.
      when '3'.
        concatenate iw_month iw_day iw_year
               into ew_user_date.
      when '4'.
        concatenate iw_year iw_month iw_day
               into ew_user_date.
      when '5'.
        concatenate iw_year iw_month iw_day
               into ew_user_date.
      when '6'.
        concatenate iw_year iw_month iw_day
               into ew_user_date.
      when others.
        clear ew_user_date.
    endcase.
    ENDFUNCTION.

  • Date format error in loading Programme

    Hi all,
    I am getting the error as I_BLDAT invalid date (ORA-01840: input value not long enough for date format) but some how in loading program I am getting the date as . .0 instead of 00000000. can someone please help me where it went wrong.These are the lines involing BLDAT
    CONCATENATE:
             wa_zfrcptp-bldat+6(2) wa_zfrcptp-bldat+4(2)
             wa_zfrcptp-bldat+0(4) INTO l_lla_dtl_rec-pay_date,
    wa_zfrcptp-bldat        TO l_huon_crr_rec-receipt_date.
    wa_zfrcptp-bldat        TO l_huon_ipr_rec-receipt_date.
    CONCATENATE wa_zfrcptp-bldat+6(2)
                    wa_zfrcptp-bldat+4(2)
                    wa_zfrcptp-bldat+0(4)
                               INTO l_cal_dtl_rec-receipt_date
    bldat_i(8)           TYPE c,
    l_cid_dtl_rec-bldat_i     = wa_zfrcptp-bldat.
    Thanks in advance,
    Rishik.
    Edited by: Rishik on Apr 16, 2009 8:44 AM

    HI,
    If you are using the BDC for loading data..then while passing BLDAT to the BDC
    Use the WRITE statement to convert the date to user format and pass to BDC
    l_endda1 is of type char with length 10. endda type sy-datum.
    WRITE i_input_line-endda TO l_endda1.
        PERFORM bdc_field       USING 'RP50G-ENDDA'    l_endda1.

  • Problem with Date formatting

    Hi Tim,
    I am facing some issues with formatting the date using XMLP. The following is the sample XML data file i am using:
    <LIST_G_HEADER>
    <G_HEADER>
    <QUOTE_HEADER_ID>1455</QUOTE_HEADER_ID>
    <QUOTE_NUMBER>2027</QUOTE_NUMBER>
    <QUOTE_VERSION>1</QUOTE_VERSION>
    <QUOTE_NAME>Test GM Report - Rabindra</QUOTE_NAME>
    <SOURCE_NAME>Fletcher, MR. Paul</SOURCE_NAME>
    <QUOTE_DATE>27-OCT-2005</QUOTE_DATE>
    <CURRENCY_CODE>GBP</CURRENCY_CODE>
    </G_HEADER>
    </LIST_G_HEADER>
    The formatting i use for my date field i.e <QUOTE_DATE>, ends up either with NO formatting or giving me an error "[010906_114656657][][ERROR] Invalid XSD string: 27-OCT-2005 (XMLP Template Viewer)". The default formatting available with the form field dialog box (MS-Word) feature also doesn't work.
    I have the following formatting for this field in the form field:
    <?format-date:QUOTE_DATE; 'MEDIUM' ?>
    When i read the user guide, it reads that the date should be in the canonical format i.e: YYY-MM-DDThh:mm:ss+HH:MM
    However i am not getting the date from the base table's in this format. Is the error happening due to incorrect format or is there some other reason behind this? Please let me know, how can i overcome this issue.
    Thx,
    Nitin

    As i mentioned in another thread
    substring function and date format
    Please use this standards
    <?xdofx:expression?>
    for extended SQL functions or
    <?xdoxslt:expression?>
    for extended XSL functions.
    Use like
    <?xdofx:rpad(LAST_NAME),30, ’x’)?>
    <?xdofx:Instr(’abcabcabc’,’a’,2))?>
    <?xdofx:upper(char)?>
    <?xdofx:lower (char)?>
    <?xdofx:greatest ( expr [, expr]... )?>
    ETC.....

Maybe you are looking for

  • Disjointed rollover on a apDiv (CS5.5)

    Hi There, I'm working on a disjointed rollover using css. I want to apply this on an apDiv but somehow it's not working. Here's what I try to do: I have a div with a big animated gif that auto starts. On top of that I have an apDiv with a small logo

  • How do I make the Volumes folder visible so it will back up using Time Machine?

    Hi How do I unhide the Volumes folder for backing up using Time Machine?

  • Using Apple TV abroad

    Moving to Spain from USA. My apple ID is from the States. Will I be able to access content from the US with Apple TV once I'm over there?

  • US BANK RE-CON?

    Has anyone had succes recently with overturning a denial for a US Bank business card?  I waited five plus months from my last CC app. and froze ARS before applying for the Business Edge card, and was immediately declined for "high balances."  I do ha

  • Hardware Reccommentations on Hardware and Performance for Collaboration???

    Hello Gurus, We are planning to implement KMC as part of our collaboration tool. We are planning to use the following: 1. CLP (Chat, Webex) 2. KM Quick Polls 3. KM Discussions 4. KM Rooms, Feedback, Rating, Task Assignment Are there any special recom