cancel
Showing results for 
Search instead for 
Did you mean: 

Date format required--- dd-mmm-yyyy.

pranav_nagpal2
Contributor
0 Kudos

Hi Experts,

I have a requirement that i have to display date in format dd-mmm-yyyy eg. 23-Nov-2007.

Now if i create a context attribute of type Dats or D what format i get by default is dd-mm-yyyy.

Please note that not only i have to enter date in input field but also the search help i.e. the calander icon, which automatically appears when we bind the input field with a attribute of type Dats, sholud also appear.

Thanks in advance.

Regards

Pranav.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Pranav,

I can give you a solution but its not very neat.

All you have to do is to have 2 input fields

input1 bind to dat2 type string

input2 bind to dat type dats (width = 0)

on enter of the input 2 write the following code

DATA lo_el_context TYPE REF TO if_wd_context_element.
    DATA ls_context TYPE wd_this->element_context.
    DATA lv_dat LIKE ls_context-dat.
*   get element via lead selection
    lo_el_context = wd_context->get_element(  ).

* get single attribute
  lo_el_context->get_attribute(
    EXPORTING
      name =  `DAT`
    IMPORTING
      value = lv_dat ).


  DATA lv_dat2 LIKE ls_context-dat2.
* get element via lead selection
  lo_el_context = wd_context->get_element(  ).

case lv_dat+4(2).
  when '01'.
       lv_dat2 = 'JAN'.
  when '02'.
       lv_dat2 = 'FEB'.   " Do for rest of the month or may be there is a FM doing this
endcase.

concatenate lv_dat+6(2)
            '-'
            lv_dat2
            '-'
            lv_dat+0(4)
       into lv_dat2.
*   set single attribute
    lo_el_context->set_attribute(
      EXPORTING
        name =  `DAT2`
        value = lv_dat2 ).

Hope this helps.

Regards,

Kinshuk

pranav_nagpal2
Contributor
0 Kudos

Hi Kishuk,

Yes it is a good option but than user have to just select the date from calender icon and it should be displayed in the input field in dd-mmm-yyyy format. onEnter action will work only when user will press enter in it.

Please suggesst how to do this.

Regards

Pranav

Answers (2)

Answers (2)

pranav_nagpal2
Contributor
0 Kudos

thnks every one...

alejandro_bindi
Active Contributor
0 Kudos

The date formatting varies according to user profile settings just as in any SAPgui transaction.

Just go to transaction SU3 and change it.

If it's not possible and it must be fixed for all users, you should go with SET COUNTRY statement:

http://help.sap.com/saphelp_scm50/helpdata/en/9f/dba1ef35c111d1829f0000e829fbfe/content.htm

Some customizing must be done with table T005X to use this.

pranav_nagpal2
Contributor
0 Kudos

Hi Alejandro,

I checked it in SU3 transaction, different formats are availabe there but there is no format of type dd-mmm-yyyy. All format have month in mm format. Please explain how to customize it or suggest any other option.

Thanks and regards,

Pranav

alejandro_bindi
Active Contributor
0 Kudos

Then you can probably get around with creating a new Z domain with DATS type and using Z conversion routines (CONVERSION_EXIT_Zxxxx_INPUT / CONVERSION_EXIT_Zxxxx_OUTPUT) which convert YYYYMMDD from / to your format. You can use T247 table for the month conversion as the SDATE routine does.

Then create a data element for that domain and finally your context attribute should have that data element as type.

I think this would work.

With that said, it's quite a lot of work for such a small result. I would try to redefine the date format to one of the standard options with the stakeholders.

Edited by: Alejandro Bindi on Sep 18, 2008 3:52 PM

I did some tests and you wouldn't be able to use the CALENDAR automatic search help along with my last suggestion, because it returns the selected date according to user profile. So you're left with the Date Navigator UI element as an alternative.

Edited by: Alejandro Bindi on Sep 18, 2008 5:26 PM

pranav_nagpal2
Contributor
0 Kudos

Hi,

That is what i was thinking. using Date Navigator is the only option left. In case i will get any other idea by my self i will surely let you know. And in case you click with something please do let me know.

thanks for your help

Regards Pranav

pranav_nagpal2
Contributor
0 Kudos

hi,

sorry for getting back so late... but one of my colleague came up with an idea to use freely programmable help here... wht we did was, we have created another component with date navigator and use this component in main component as a freely programmable help.......

if someone faces similar problem reply back i will explain whole procedure......

regards

Pranav