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

need current year alone.

Former Member
0 Likes
1,232

hi experts,

i need system year. can we take year alone from sy-datum or is there some other field like sy-year?????

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,083

HI,

try

write: sy-datum+0(4).

reward points if helpful

regards,

venkatesh

7 REPLIES 7
Read only

Former Member
0 Likes
1,083

Hi,

SY_DATUM is the only field in SYST table to get the date. You can extract the year from sy-datum.

write: sy-datum+0(4).

Regards,

Richa

Read only

Former Member
0 Likes
1,084

HI,

try

write: sy-datum+0(4).

reward points if helpful

regards,

venkatesh

Read only

Former Member
0 Likes
1,083

hi,

I think we need to take the year from Sy-DATUM only.There is no seperate system field for current year.

Read only

Former Member
0 Likes
1,083

Hi,

We can take the system year only from the System Date.For that try the following report program.

REPORT demo_field_symbols_casting.

TYPES: BEGIN OF t_date,

year(4) TYPE n,

month(2) TYPE n,

day(2) TYPE n,

END OF t_date.

FIELD-SYMBOLS <fs> TYPE t_date.

ASSIGN sy-datum TO <fs> CASTING.

WRITE / sy-datum.

SKIP.

WRITE: / <fs>-year

Regards,

Padmam.

Read only

Former Member
0 Likes
1,083

Hello,

write: sy-datum+0(4).

Vasanth

Read only

Former Member
0 Likes
1,083

Hi Muruga,

The date in ABAP is internally stored as YYYYMMDD.

use date+0(2).

this will surely solve your problem.

Read only

Former Member
0 Likes
1,083

System date is stored as YYYYMMDD.

So to extract the year from the System date, you can write:

sy-datum+0(4)

This will extract the system date's year.

You can write the following short code to check also:-

data: v_date type date.

write:/ sy-datum.

v_date = sy-datum+0(4).

write:/ v_date.

v_date will fetch the year.

Regards,

Sangeeta.