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

Date format in Script

Former Member
0 Likes
1,273

Hi ,

How can I change the date format in MAIN window.

I am ablt to used SET DATE MASK in all the windows, but in main window this option is not working.please suggest how to change the date format?

Regards,

Sri.

8 REPLIES 8
Read only

Former Member
0 Likes
1,035

Dear Sri Kant,

SET DATE MASK is the way to get the date format. Please check whether you have transported the form to the testing client. This is normal error which we developer's do.

Regards,

Deva.

Read only

Former Member
0 Likes
1,035

for sap script u can change the date format in driver programm and store it into any variable and than write it in to sap script main window...

for example..

Suppose a date is given in the format 20050428 how to get the output in the format 28th Apr 2005.

FORM set_text_date.

DATA: month(9),

year(4),

date(2).

CASE p_frd+4(2).

WHEN '01'.

month = 'January'.

WHEN '02'.

month = 'February'.

WHEN '03'.

month = 'March'.

WHEN '04'.

month = 'April'.

WHEN '05'.

month = 'May'.

WHEN '06'.

month = 'June'.

WHEN '07'.

month = 'July'.

WHEN '08'.

month = 'August'.

WHEN '09'.

month = 'September'.

WHEN '10'.

month = 'October'.

WHEN '11'.

month = 'November'.

WHEN '12'.

month = 'December'.

WHEN OTHERS.

ENDCASE.

WRITE p_frd+0(4) TO year.

WRITE p_frd+6(2) TO date.

CONCATENATE month date ',' year INTO return_date SEPARATED BY space.

CONDENSE return_date.

ENDFORM.

Read only

vinod_gunaware2
Active Contributor
0 Likes
1,035

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

mm: month number 01 = January,..., 12 = December

OR

CHECK

USER PROFILE ->OWN DATA

OR
Check

OY01 -> selct country -> Details

regards
OR
Use

WRITE INTO

statement with date format

regards

vinod

Read only

0 Likes
1,035

I have date format in 20050102 format i want to sidpaly it in 2 0 0 5 0 1 0 2 format how do i that.

Any suggestions on this wd be appreciated

Read only

0 Likes
1,035

Shilpa

Please put your query as a separate query ....

for your question here is the solution,

ldate = sy-datum.

lchr = ldate.

lcdate = lchr(1).

do 8 times.

shift lchr.

concatenate lcdate lchr(1) into lcdate

separated by space.

enddo.

Regards

Anurag

Read only

0 Likes
1,035

Thnx for the info n snippet.

can the write the same code in SAP Script using DEFINE command or do i need to write a FORM to call that PERFORM in Script ?

or do i need to make changes in print pgm ?

plz let me know abt the same,

thanks in Advance .

Read only

Former Member
0 Likes
1,035

Hi srikanth,

1. capital

2. make sure you have written in CAPITAL

ie.

/: SET DATE MASK = <b>'DD-MM-YYYY'</b>

regards,

amit m.

Read only

0 Likes
1,035

I have used the same thing bu tstill the date in main window is only not changed, but all other dates are changed