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: 

Date format DD-MMM-YYYY in input option

Former Member
0 Kudos

Hi all,

     I have a requirement in which two date field are manual entry fields and editable fields.

The report is working fine with dd.mm.yyyy format but now i have a requirement to change those fields to DD-MMM-YYYY format and save it.

How can i acheive this . Pls help.

Regards,

Sam.

20 REPLIES 20

PeterJonker
Active Contributor
0 Kudos

Do you have some more info, what is the source code snippet where you need it.

And just out of curiosity; how does a date look in this format e.g. todays date ????

0 Kudos

Hi Peter,

        Iam able to convert the date into DD-MMM-YYYY format for the manual field. Since it is an editable field the user will change the date. In that case in which format should the user enter the date. Iam changing the date from dd.mm.yyyy to dd-mm-yyyy using CONVERSION_EXIT_SDATE_OUTPUT.

Rgds,

Sam.

raymond_giuseppi
Active Contributor
0 Kudos

Look for a domain that use IDATE conversion exit (at least there is IDATS domain) and use it for your field.

(Or create your own domain after copying conversion exit and its FMs to a conversion exit in your namespace a ZDATE conversion exit, to add the "-" in the string for OUTPUT and removing it for INPUT)

Regards,

Raymond

Former Member
0 Kudos

Do one thing,

suppose you have data in lv_date.

data lv_date type char12 value '16.10.2013'.

REPLACE ALL OCCURENCES OF '.' IN lv_date WITH '-'.

and now save the data.

BR

ChanS.

0 Kudos

Hi Chandra,

      By doing so you can only replace '.' with '-' . how can you change the format to dd-mmm-yyyy.

Cheers,

Sam.

0 Kudos

Hi Samuel Dennis

Can you try like this

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.

0 Kudos

What is your input and what you want in output.

i guess your input is dd.mm.yyyy and output you want dd-mm-yyyy. right ?

rodrigo_paisante3
Active Contributor
0 Kudos

Hi.

You can use the FM:

FM HR_IN_GET_DATE_COMPONENTS

It will return short and long text of month.

Best regards

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Solution could be like this :

You can go for custom DOMAIN and use a Conversion. Routine at domain level to format the data in the required format.

Regards

Ansumesh

Former Member
0 Kudos

Dear all,

I would like to make it clear that i hav got the answer by doing conversion but my question is since it is a manual editable field how and in which format should the user enter the date. Earlier the user used dd.mm.yyyy format to enter date now i don know in which format i should enter since i have converted the date to dd-mmm-yyyy format. In which  format should i enter the date and save the entered date when the save button is pressed.

Thanks,

Sam.

0 Kudos

Hi,

Why dont you input the date in dd.mmm.yyyy format itself. Or you can give a F4 help on the date field, keep domain of the date datum and use the SET DATE MASK to convert the date dd.mmm.yyyy .

0 Kudos

Hi Shruti,

     I tried inputting the date format in dd-mmm-yyyy but it is not getting saved.

VijayaKrishnaG
Active Contributor
0 Kudos

Hi Samuel,

Call this function module MONTH_NAMES_GET which gives the list of months in specified language with Month number, Short text like JAN, FEB etc (MMM) and long text into a Table.

So, after you getting your date read the table (list of months) with the Month number and replace month number with month name (MMM) and "." with "-".

Thanks & Regards,

- Vijay

0 Kudos

Hi Vijay,

Thanks for your reply. But will this accept the input date in dd-mmm-yyyy format and save.

Rgds,

Sam.

0 Kudos

Hi Samuel,

Let the user enter in present format DD.MM.YYYY, internally in report you change the date format with the help of function module as I mentioned above.

And where it has to save?

If this has to be saved in a database table, create a custom domain with required format or else create/use domain with CHAR type and length 11.

Thanks & Regards,

-Vijay

0 Kudos

Vijay,

      I have created a ztable to store the data and its all workin fine for dd.mm.yyyy format but its not working for dd-mmm-yyyy format.

Rgds,

Sam.

0 Kudos

Samuel,

Then you change the data element of the date field in your custom table. Assign data element with Char 12. Then it will accept the date in DD-MMM-YYYY format.

-Vijay

miko2
Explorer
0 Kudos

Hope that helps...

Regards Miko.

Former Member
0 Kudos

Hi Samuel,

If i understand your requirement correctly.

Input like: 01-Jan-2013

Validate the user input in at selection-screen output like by throwing information message upon wrong entry.

And internally with in the program you can change 'Jan' in 01-Jan-2013 to 01-01-2013.

Move 01-Jan-2013(4:3) to month.

Mve   01-Jan-2013(1:2) to days.

Move 01-Jan-2013(8:4) to year.

Case month

When 'Jan'

month_no = '01'

Concatenate days month_no year into result_date.

similarly for feb and so on....

Use result_date to update your database.

Or in Case you want to update Database in DD-MMM-YYYY then create field and data element with the correct length of char type and update it.