Application Development and Automation 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: 
Read only

Chenge Date format in smartforms

Former Member
0 Likes
4,537

I want to convert date format

Example :  01.01.2000 convert it into 01.Jan.00

How i can get this?

7 REPLIES 7
Read only

Former Member
0 Likes
2,705

Hello Jaya,

you can try converting it by using

SET DATE MASK = 'DD.MMMM.YY'

Read only

Former Member
0 Likes
2,705
Formatting Date Fields: SET DATE MASK 

To define the formatting of date fields, use the SET DATE MASK control
command. Executing this command causes all subsequent date fields to be printed
using the specified format.
Syntax:

/: SET DATE MASK = 'date_mask'
In the date mask, you can use the following codes:
  • DD: day (two digits)
  • DDD: day name - abbreviated
  • DDDD: day name - written out in full
  • MM: month (two digits)
  • MMM: month name - abbreviated
  • MMMM: month name - written out in full
  • YY: year (two digits)
  • YYYY: year (four digits)
  • LD: day (formatted as for the L option)
  • LM: month (formatted as for the L option)
  • LY: year (formatted as for the L option)
All other characters found in a date mask are interpreted as simple text and
are copied straight into the output.
Assuming the current system date is March 1st, 1997.

/: SET DATE MASK = 'Foster City, MM/DD/YY'
&DATE& -> Foster
City, 03/01/97
/: SET DATE MASK = 'MMMM DD, YYYY'
&DATE& -> March 01,
1997

The date mask may be reset to the default setting by using an empty
string:

/: SET DATE MASK = ' '

The abbreviated and full forms of the names of the days and months are stored
in the language dependent TTDTG table under the following keys:
  • %%SAPSCRIPT_DDD_dd: abbreviated day name
  • %%SAPSCRIPT_DDDD_dd: full form of day name
  • %%SAPSCRIPT_MMM_mm: abbreviated month name
  • %%SAPSCRIPT_MMMM_mm: full form of month name
dd: day number 01 = Monday,..., 07 = Sunday
Read only

Former Member
0 Likes
2,705

Hi Jaya,

You can use the SET DATE MASK to change the date format in the Smartform output as indicated by Nicolas Glänzer.

Create code lines (before the node where you print the date) in the Smart Form and write the command to change the date format.

For printing the date as "01.Jan.00", you can use the below command.

SET DATE MASK = "DD.MMM.YY".

For reference you can see the documentation in the following link.

http://help.sap.com/saphelp_nw73ehp1/helpdata/en/4e/3663165fff02c9e10000000a15822b/content.htm

Regards,

Narayana Reddy A V L.

Read only

Former Member
0 Likes
2,705

Deara jaya Reddy,

please use the following code or make a funciton module and use it in command lines before the text in smart form you will get your result.

PARAMETERS: dat type sy-datum.

data : e_month type c LENGTH 2,

        e_year type c LENGTH 4.

data: day type c LENGTH 2.

data: date TYPE c LENGTH 25.

data: MONTH_NAMES LIKE  T247 OCCURS 0.

data: wa_month like LINE OF month_names.

day = dat+0(2).

CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH'

   EXPORTING

     I_DATE  = dat

   IMPORTING

     E_MONTH = e_month

     E_YEAR  = e_year.

CALL FUNCTION 'MONTH_NAMES_GET'

  EXPORTING

    LANGUAGE                    = SY-LANGU

* IMPORTING

*   RETURN_CODE                 =

   TABLES

     MONTH_NAMES                 = month_names

    EXCEPTIONS

    MONTH_NAMES_NOT_FOUND       = 1

    OTHERS                      = 2

           .

IF SY-SUBRC <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

delete month_names where mnr ne e_month.

READ TABLE month_names into wa_month index 1.

CONCATENATE day '-' wa_month-ltx '-' e_year into date.

CONDENSE date.

write: date.

Read only

Former Member
0 Likes
2,705

Hi Jaya Reddy,

Please check the below link. You can find a similar discussion here.

http://scn.sap.com/thread/394228

Regards,

Riju Thomas.

Read only

Former Member
0 Likes
2,705

Hi Jaya,

Hi Jaya,

You can achieve your object using table T247.

Algo for code will be:

let DATE = 07.10.2013

You can use table T247 Pass Spras = EN and MNR = '10' and fetch KTX field value.

This will give you Month name  as OCT.

CONCATENATE  '07.' KTX '.'  date+8(2) into date1 RESPECTING BLANKS.

This will give you date as required.

Regards,

Jeetendra


Read only

Former Member
0 Likes
2,705

Hi Jaya,

You can also use FM 'CONVERSION_EXIT_SDATE_OUTPUT'.

EXAMPLE

DATA:  INT_DATUM TYPE SY-DATUM VALUE '19940102',

EXT_DATUM(11) TYPE C.

CALL FUNCTION 'CONVERSION_EXIT_SDATE_OUTPUT'

EXPORTING

INPUT         = INT_DATUM

IMPORTING

OUTPUT        = EXT_DATUM.

Regards,

Anoop