Application Development 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: 

data element creation for a date field

Former Member
0 Kudos

My problem is that in a structure I use, I use some date fields. Right now my date field is defined by data type DATS, which contains the date in the form: YYYY.MM.DD.

I would like to create a data element in SE11, that contains dates in the form DD.MM.YYYY. How can I do that?

Maybe there are some convertation functions? How can I use those?

Thanks,

Peter

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You can create a data element of type CHAR and use it appropriately with the help og offset logic.

Regards,

Amit

3 REPLIES 3

Former Member
0 Kudos

Hello Peter ,

The Format of date display depends on the SU3 settings of the User ID. Also there are advantages of storing the date in YYYYMMDD format for comparision etc. So you can store the date as YYYYMMDD and when you require the date for dispaly you can use the FM CONVERT_DATE_TO EXTERNAL or SLS_MISC_CONVERT_TO_DATE which requires yot to pass the date and format.

So my sugesstion is to store the date as the sytem format and use the above mentioned FM when you require the date in your format.

<b>Reware points if useful</b>

Saket Sharma

Former Member
0 Kudos

You can create a data element of type CHAR and use it appropriately with the help og offset logic.

Regards,

Amit

Former Member
0 Kudos

Here is the Solution for Date's in the sap .

The following ABAP code demonstrates a number of ways to format a SAP date value:

* Using the WRITE statement
***************************
  data: gd_date(10).  "field to store output date

* Converts SAP date from 20020901 to 01.09.2002
  write sy-datum to gd_date dd/mm/yyyy.
* Converts SAP date from 20020901 to 01.09.02
  write sy-datum to gd_date dd/mm/yy.



* Using data manipulation techniques
************************************
  data: gd_date(8).  "field to store output date

* Converts SAP date from 20010901 to 01092001
  gd_date(2)   = sy-datum+6(2).
  gd_date+2(2) = sy-datum+4(2).
  gd_date+4(4) = sy-datum(4).


* Using Function modules
************************
  data: gd_date(8).  "field to store output date

* Converts date from 20010901 to 01SEP2001
  gd_date   = sy-datum.
  CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'
    EXPORTING
      input         = gd_date
    IMPORTING
      OUTPUT        = gd_date.


Reward points if it is usefull.....

Girish