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

Re: date format

Former Member
0 Likes
1,033

Hi Expert,

I have to change the date from excel i am downloading data from excel to interna table and i have to pass to the data base table and date format in excel is ddmmyyyy.

below is my code

   CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                = p_file
      FILETYPE                = 'ASC'
    TABLES
      DATA_TAB                = gtab
    EXCEPTIONS
      FILE_OPEN_ERROR         = 1
      FILE_READ_ERROR         = 2
      NO_BATCH                = 3
      GUI_REFUSE_FILETRANSFER = 4
      INVALID_TYPE            = 5
      NO_AUTHORITY            = 6
      UNKNOWN_ERROR           = 7
      BAD_DATA_FORMAT         = 8
      HEADER_NOT_ALLOWED      = 9
      SEPARATOR_NOT_ALLOWED   = 10
      HEADER_TOO_LONG         = 11
      UNKNOWN_DP_ERROR        = 12
      ACCESS_DENIED           = 13
      DP_OUT_OF_MEMORY        = 14
      DISK_FULL               = 15
      DP_TIMEOUT              = 16
      OTHERS                  = 17.
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  loop at gtab from 2.

    split  gtab-line at ',' into wa-ebeln wa-ebelp wa-ebtyp wa-date2 wa-menge.

in wa_date2 field date format is 25.05.2012 but i need 20120525.

Regards,

Addu

Moderator message: basic date formatting, please do more research before posting.

Message was edited by: Thomas Zloch

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
989

Hi Addu,

Use below peace of code to change date format from DD.MM.YYYY to YYYYMMDD.

Data : lv_date2 type sy-datum.

CONCATENATE wa-date2+6(4) wa-date2+3(2) wa-date2+0(2) INTO lv_date2.

see below link.

http://scn.sap.com/thread/802886

Regards,

Rajesh

8 REPLIES 8
Read only

Former Member
0 Likes
990

Hi Addu,

Use below peace of code to change date format from DD.MM.YYYY to YYYYMMDD.

Data : lv_date2 type sy-datum.

CONCATENATE wa-date2+6(4) wa-date2+3(2) wa-date2+0(2) INTO lv_date2.

see below link.

http://scn.sap.com/thread/802886

Regards,

Rajesh

Read only

Former Member
0 Likes
989

Hi Addu,

Try like this

Data : lv_date type sy-datum.

CONCATENATE wa-date2+6(2) wa-date2+4(2) wa-date2+0(4) INTO lv_date.

condense lv_date no-gaps.

Then Modify the particular field in internal by transporting it based on index.

With Regards,

Sudhir S

Read only

0 Likes
989

Hi Sudhir,

as you have seen my code from excel i am downloading data in which date format isddmmyyyy

but how to convert this from excel toyyyymmdd. how i have to write the code after gui_upload.

Regards,

Addu

   CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                = p_file
      FILETYPE                = 'ASC'
    TABLES
      DATA_TAB                = gtab
    EXCEPTIONS
      FILE_OPEN_ERROR         = 1
      FILE_READ_ERROR         = 2
      NO_BATCH                = 3
      GUI_REFUSE_FILETRANSFER = 4
      INVALID_TYPE            = 5
      NO_AUTHORITY            = 6
      UNKNOWN_ERROR           = 7
      BAD_DATA_FORMAT         = 8
      HEADER_NOT_ALLOWED      = 9
      SEPARATOR_NOT_ALLOWED   = 10
      HEADER_TOO_LONG         = 11
      UNKNOWN_DP_ERROR        = 12
      ACCESS_DENIED           = 13
      DP_OUT_OF_MEMORY        = 14
      DISK_FULL               = 15
      DP_TIMEOUT              = 16
      OTHERS                  = 17.
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  loop at gtab from 2.

  Data : lv_date2 type ekes-eindt.          "sy-datum.

  CONCATENATE wa-date2+6(4) wa-date2+3(2) wa-date2+0(2) INTO lv_date2.
   condense lv_date2 no-gaps.
     wa-date2 = lv_date2.







    split  gtab-line at ',' into wa-ebeln wa-ebelp wa-ebtyp wa-date2 wa-menge.

Read only

0 Likes
989

Hi ,

Declare your variable outside the loop.

Data : lv_date2 type ekes-eindt.          "sy-datum.

          lv_index type sy-index.

clear :wa,lv_index.

loop at gtab into wa.

lv_index = sy-tabix.
  CONCATENATE wa-date2+6(4) wa-date2+3(2) wa-date2+0(2) INTO lv_date2.
   condense lv_date2 no-gaps.
   wa-date2 = lv_date2.

modify gtab from wa index lv_index transporting date2.

Endloop.

clear: wa.

Yes you have to write code below the GUI_UPLOAD function module.

Please reward points if useful.

With Regards,

Sudhir S

Read only

0 Likes
989

Hi Sudhir,

I have declare the code like below how u said

   FORM GET_UPLOAD .


  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                = p_file
      FILETYPE                = 'ASC'
    TABLES
      DATA_TAB                = gtab
    EXCEPTIONS
      FILE_OPEN_ERROR         = 1
      FILE_READ_ERROR         = 2
      NO_BATCH                = 3
      GUI_REFUSE_FILETRANSFER = 4
      INVALID_TYPE            = 5
      NO_AUTHORITY            = 6
      UNKNOWN_ERROR           = 7
      BAD_DATA_FORMAT         = 8
      HEADER_NOT_ALLOWED      = 9
      SEPARATOR_NOT_ALLOWED   = 10
      HEADER_TOO_LONG         = 11
      UNKNOWN_DP_ERROR        = 12
      ACCESS_DENIED           = 13
      DP_OUT_OF_MEMORY        = 14
      DISK_FULL               = 15
      DP_TIMEOUT              = 16
      OTHERS                  = 17.
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



  Data : lv_date2 type ekes-eindt,          "sy-datum.
         lv_index type sy-index.
clear :wa,lv_index.

loop at gtab into wa.

lv_index = sy-tabix.
  CONCATENATE wa-date2+6(4) wa-date2+3(2) wa-date2+0(2) INTO lv_date2.
   condense lv_date2 no-gaps.
   wa-date2 = lv_date2.

modify gtab from wa index lv_index  transporting date2.

endloop.
clear: wa.



  loop at gtab from 2.


    split  gtab-line at ',' into wa-ebeln wa-ebelp wa-ebtyp wa-date2 wa-menge.

I am getting error at modify statement that date2 is no component exit with name2 it is saying

Regards,

Addu

Read only

0 Likes
989

Hi ,

   Explain me clearly for what requirement you are doing this . Either BDC .

If possible share your complete program .It will be easy to analyze.

With Regards,

Sudhir S

Read only

Former Member
0 Likes
989

Hi Addu ,

    Check with basis for your profile the date format assigned.

With Regards,

Sudhir S

Read only

former_member213851
Active Contributor
0 Likes
989

Hi Addu,

Use below peace of code in order to change date format from DD.MM.YYYY to YYYYMMDD.

Data : lv_date2 type sy-datum.

CONCATENATE wa-date2+6(4) wa-date2+3(2) wa-date2+0(2) INTO lv_date2.

CONDENSE lv_date2 NO-GAPS .

If changes are not visible in excel ,just change your Excel sheet settings:

In excell go to the date field , right click and goto format cell, then under category select date and proide the type you need.

if nothing helps,

Go to T_code : SU3

or system-> User profile-> Own data

Now adjust the date parameters as per requirement

Problem still persits then check with Basis team regarding your profile .



Best Regards,

Sachin.