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

Change in date format in sap script

Former Member
0 Likes
3,134

Hi ,

i am working on the check layout. Here the date format that we want is mm.dd.yyyy. I changed the SAP system setting to mm.dd.yyyy. Now in the application side, every where we can see this format. Even in the table level we can see the same format. But still in the layut it printing as dd.mm.yyyy.

Is there a way where i can change for date format to mm.dd.yyyy for REGUP-BLDAT field.

Its really urgent.

Thanks .

NC

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,270

Yes, although I'm a little confused why its not taking your default system setting.

You can use the SET DATE MASK statement in your sapscript.



/:   SET DATE MASK 'MM/DD/YYYY'

or

maybe this statement is already there in the sapscript which is causing it to display the other way. If so, then remove this statment



/:   SET DATE MASK 'DD.MM.YYYY'

Regards,

Rich Heilman

13 REPLIES 13
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,271

Yes, although I'm a little confused why its not taking your default system setting.

You can use the SET DATE MASK statement in your sapscript.



/:   SET DATE MASK 'MM/DD/YYYY'

or

maybe this statement is already there in the sapscript which is causing it to display the other way. If so, then remove this statment



/:   SET DATE MASK 'DD.MM.YYYY'

Regards,

Rich Heilman

Read only

0 Likes
2,270

I tried to locate this command. But i couldnt find it.

I also tried to enter this new command to have

/: set date mask as mm.dd.yyyy,

AS &regup-bldat&

but still its not accepting. It is giving the same format in the output, as

dd.mm.yyyy

Thanks,

NC

Read only

0 Likes
2,270

A quick solution for your problem if it's urgent:

1) Split the date

2) Concatenate between '/'

3) Print the Char Variable.

With this you can print your sapscript and gain more time to figure it out what's wrong.

As Rich sayas it's a confused thing the reason that is not taking your default system setting.

Read only

0 Likes
2,270

Hi Carlos,

I checked up the main program. There i can see the date is hardcodded as DD.mm.YYYY. The entries for the same are at many places. So instead of changing the std, i think we can split and concatenate and u suggested.

When i try to split the date '20050321'. I dont want to hard code it as split after 5.

Is there a way by whichi can split it as first 4 digits, then 2 digits and then last 2 digits.

Pls suggest.

Thanks.

Read only

0 Likes
2,270

Use offsets......



Data: today(10) type c.

concatenate sy-datum+4(2) '/'
            sy-datum+6(2) '/'
            sy-datum+0(4)
                  into today.

Regards,

Rich Heilman

Read only

0 Likes
2,270

Hi,

I tried it, its not working some how.

All i need here to split based on the offset.

And later i will concatenate once i have dd mm and yyyy in three variables.

Thanks,

Read only

0 Likes
2,270

My code should have worked for you.......post your code.

Regards,

Rich Heilman

Read only

0 Likes
2,270

Hi,

I am working for the layout.

so i have created a subroutine to capture the date and print.

the code in the form is

data tdate type d.

WRITE ITAB-ZALDT to NDATE. " ndate = '20010521'

concatenate ndate+4(2) '/'

ndate+6(2) '/'

ndate+0(4)

into tdate.

Its really urgent

Thanks

NC

Read only

0 Likes
2,270

Change this



data tdate type d. 

to this



data tdate(10) type c. 

Regards,

Rich Heilman

Read only

0 Likes
2,270

Hi,

tried the saem set of code, its not working.

I also created a new program to see if the concatenate function works,

here is the complete code.

REPORT ZNEW .

data ndate type d value '20010521'.

data tD type C.

WRITE ' HELLO'.

concatenate NDATE+4(2) '/'

ndate+6(2) '/'

ndate+0(4)

into td.

write : ndate , tD.

output is

HELLO 05212001 0

Read only

0 Likes
2,270

change your code to be like this.....



data ndate type d value '20010521'.
data tD<b>(10)</b> type C.

concatenate NDATE+4(2) '/'
ndate+6(2) '/'
ndate+0(4)
into td.

write : ndate , tD.


Regards,

Rich Heilman

Read only

0 Likes
2,270

Hi Rich,

Thanks for the help. Your code is wokring, i was making a very silly mistake.

Thanks again,

NC

Read only

Former Member
0 Likes
2,270

You have a sapscript instruction to set the language of the sapscript .

If you select country DE Deutschland you use the format for this country points of miles ,dates and points of decimals

The instruction is set country