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

set date mask

Former Member
0 Likes
1,440

Hi Gurus, I have to set date as per the company code REGUP-BUKRS using sap-script. I am unable to get the date..

/: IF &REGUP-BURKS& EQ 2000

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

  • &REGUP-BLDAT&

/: ENDIF

This there is anything wrong in this code ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,017

/: IF &REGUP-BURKS& EQ '2000' -> should be single quotation

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

&REGUP-BLDAT&

/: ENDIF

Thanks

Seshu

Hi Gurus, I have to set date as per the company code REGUP-BUKRS using sap-script. I am unable to get the date..

/: IF &REGUP-BURKS& EQ 2000

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

  • &REGUP-BLDAT&

/: ENDIF

This there is anything wrong in this code ?

8 REPLIES 8
Read only

Former Member
0 Likes
1,017

can anyone help me out

Read only

Former Member
0 Likes
1,018

/: IF &REGUP-BURKS& EQ '2000' -> should be single quotation

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

&REGUP-BLDAT&

/: ENDIF

Thanks

Seshu

Read only

Former Member
0 Likes
1,017

Thanks Seshu for the reply. I want to know if we use set date mask like below

set date mask = 'dd/mm/yyyy' only

does this changes all dates with data element DATS ? or this only changes the field following set date mask like &ergup-bldat& defined as below

set date mask = 'dd/mm/yyyy'

&regup-bldat&

Thanks in advance

Read only

0 Likes
1,017

Not Sure, I guess it effects the only that field.

if not then

if you want to have only one field then you can have simple perform routine to get date format

Thanks

Seshu

Read only

0 Likes
1,017

I have three date date fields that need to be a particular date format when we have a 2000 company code. For all remaining we need another format. How can we do this in sapscripts. I tried but i didnt get. Can anyone help me out ?

Read only

Former Member
0 Likes
1,017

did tht but not getting any help ?

Read only

0 Likes
1,017

Please use below syntax in SE71 Text editor ( Before displaying date)

/: PERFORM GET_DATE_FORMAT IN PROGRAM ZGET_DATE

/: USING &REGUP-BLDAT&

/: CHANGING &DATE&

/: ENDPERFORM

Now goto SE38 -> create program(ZGET_DATE) -> now use below syntax

FORM GET_DATE_FORMAT

tables in_tab structure itcsy

out_tab structure itcsy.

  • lOCAL VARIABLES

data: LV_DATE(10) TYPE C,

LV_DAY(2),

LV_MON(2),

LV_YEAR(4),

LV_FDATE(10) TYPE C.

CLEAR : LV_DATE,

LV_DAY,

LV_MON,

LV_YEAR,

LV_FDATE.

read table in_tab with key NAME = 'REGUP-BLDAT'.

if sy-subrc eq 0.

LV_DATE = IN_TAB-VALUE

endif.

  • Date Formatting

lv_year = lv_date+0(4).

lv_mon = lv_date+5(2).

lv_day = lv_date+8(2).

concatenate lv_day '/' lv_mon '/' lv_year into lv_fdate.

read table out_tab with key NAME = 'DATE'.

if sy-subrc eq 0.

out_tab-value = lv_fdate.

modify out_tab index sy-tabix.

endif.

ENDFORM.

You can use same logic for all dates.

Thanks

Seshu

Read only

Former Member
0 Likes
1,017

it worked for me. Thanks to all for there helpful answers