cancel
Showing results for 
Search instead for 
Did you mean: 

Format a date

Former Member
0 Kudos

Hi all

I need to format a date. I have a date like YYYYMMDD and I would like to format it like DD/MM/YYYY .... Has anybody a solution ?

J

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Jerome-

Could you please forward me your JavaScript function for converting to and from SAP date?

I would like to use it at one of my projects where I currently need it.

Thanks,

- Vik.

former_member181879
Active Contributor
0 Kudos

We usually do the internal to external (and back) conversions at the server. If you use for example a model class, or a page attribute that is flagged as autofill, the conversion routines should handle it.

Otherwise look at class CL_BSP_UTILITY. You are interested in methods MAKE_STRING and INSTANTIATE_SIMPLE_DATA. This shows how 'D' in converted back and forth. You can use these two methods to just convert your data yourself.

Former Member
0 Kudos

Hi Brian,

the INSTANTIATE_SIMPLE_DATA-method seems to be a solution for my problem as well: it has nothing to do with BSPs, it's "only" an ABAP report for uploading data from the PC client.

But if I use this method for character fields with conversion exit it does not work correct because the conversion exit is not executed. Thus, I have to execute the conversion exit separately in my program for CHAR fields. I.e.: field GDATU of database TCURR.

It seems to be a gap in functionality ... What do you think?

former_member181879
Active Contributor
0 Kudos

Hallo Frank,

> It seems to be a gap in functionality ... What do you think?

I asked my colleague about this, and the answer was "work as designed" :). In principle the code was written long time ago, and for the place where we use it, there was no need for exit routines.

However, you are right that there is a general need for this. The MVC stuff, the model code does call the conversion exists correctly. So we do have it, when the going gets tough.

You could consider to use such a model class without BSP. I suspect you might even make it work relatively easy. I have achieved something close to that once. (Or just borrow the code.)

+bcm

Former Member
0 Kudos

Hi Brian-

I used the function module

'CONVERT_DATE_TO_INTERNAL'. This one worked out quite well for me.

Thank you,

- Vik.

Former Member
0 Kudos

Dont worry It's ok. But your method isn't client systems dependent but SAP dependent. So I use a javascript to convert a SAP DATE into a Web format date.

Former Member
0 Kudos

great <% page->write( mydate ) %> Nice

Former Member
0 Kudos

Hi, take care about this solution because with HTMLB tag it seems to not work.

Regards,

Bertrand

athavanraja
Active Contributor
0 Kudos

Hi Jerome,

Sorry man, when i answered your question, i didnt realise that i wa in BSP forum. Sorry again.

You may look at BSP application IT00 - page basic_write.htm for samples on formatting options.

e.g <%= page->to_string( value = sy-datum ) %>

Regards

Raja

athavanraja
Active Contributor
0 Kudos

Look at ABAP key word WRITE and its Formatting options .

Regards

Raja