Skip to Content
-4

issue with date format save in custom database table

Jun 08, 2017 at 04:09 PM

117

avatar image

Hi ,

I want to save date in MM/DD/YYYY in custom database table field . its displaying as dd.mm.yyyy format. I know we can use char 10 and do necessary concatenation but i want any other good method for this.

rg

10 |10000 characters needed characters left characters exceeded

You should tell your client that it's a very bad idea from the modeling point of view, to not using the predefined date type (because it's then impossible to sort efficiently). Of course, they probably have a good reason to do that.

1

Same as Sandra Rossi......and wondering why you aren't just making this a "date" type field.....then use the "external-to-interal" conversion function to take "whatever" format the end user is using (based on their user profile setting as mentioned elsewhere in this thread) and then puts into the "internal" format SAP uses to actually store dates. Why try to complicate it? Unless as Sandra said, there are other "good" reasons for doing this.

1

Another voice to this being a bad idea... maybe if you share the specific reason for trying to store a formatted date, we can give you better (or just other) ways of addressing your primary issue.

0

She says it's displaying ...

Maybe the storage format is even OK but not recognized as such. Simply not distinguishing internal format and external formats.

0
Further commenting has been locked.
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Raju Shrestha Jun 08, 2017 at 06:57 PM
-4

Go to System->User Profile -> Own Data -> Defaults -> Date Format (choose 2. MM/DD/YYYY).

Your default setting is the reason you are seeing the date in that way.

Raju.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi,

I know we can maintain that in SU3, I am looking for any other method.

rg

0

"Date Format (choose 2. MM/DD/YYYY)"

It's a "other good method". No?

1
Further commenting has been locked.
Mike Pokraka Jun 09, 2017 at 01:00 PM
3

It's all in the documentation. Please look at the formatting options of string templates or the WRITE statement.

Share
10 |10000 characters needed characters left characters exceeded
Rajkumar Narasimman Jun 09, 2017 at 02:47 PM
-1

Hi Ramya,

Can you try EDIT MASK option in WRITE statement for DD/MM/YYYY format as shown below.

data: l_date TYPE char10.

write sy-datum to l_date USING EDIT MASK '__/__/_____'.
write sy-datum to l_date USING EDIT MASK '__.__._____'.
write sy-datum to l_date USING EDIT MASK '__-__-_____'.

Regards

Rajkumar Narasimman

Share
10 |10000 characters needed characters left characters exceeded
Kiran Vasant Kere Jun 09, 2017 at 01:23 PM
-2

see if you can use any of customer exit for eg below one

split the date like below(I am giving just a psudo code) in the customer exit

example: MM/DD/YYYY - YYYYMMDD

A1 = SOURCE_FIELDS-calday+0(4) . ** YYYY

A2 = SOURCE_FIELDS-calday+0(2). **MM

A3= SOURCE_FIELDS-calday+2(2). ** DD

Concatenate A1 A2 A3 into your date field.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Use a structure rather that substrings, or use the substring() function. The structure method is self documenting this in my view is a better way of coding it.

Types: Begin Of My_Date,
             Month Type My_Month,
             Fill1 Type c,
             Day   Type My_Day,
             Fill2 type c,
             Year  Type My_Year,
       End Of My_Date,
       Begin Of Sap_Date,
             Year  Type My_Year,
             Month Type My_Month,
             Day   Type My_Day,
       End Of Sap_Date.
Data: l_Date     Type my_Date,
      l_Sap_Date type sap_Date.
l_Date = 'MM/DD/YYYY'.
Move-Corresponding l_Date to l_Sap_Date.

And then just move l_Sap_Date to a real date field. To go the other way, populate the SAP date and move to the l_Date, populating the fill fields.

Rich

0
Further commenting has been locked.