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

sy-datum

Former Member
0 Likes
1,191

Hallo,

in the follwoing code I am trying to have the year 2009 and previous year 2008. But it dont function.Can somebody tell me What can I do to get in prvious_year 2008.

DATA: cha TYPE d,

previous_year type d.

cha = sy-datum+0(4).

previous_year = cha - 1.

regards

rana

11 REPLIES 11
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,131

Hi,

Try this.

DATA: cha(4) TYPE c,
previous_year(4) type c.

cha = sy-datum+0(4).

previous_year = cha - 1.
write previous_year.

Read only

Former Member
0 Likes
1,131

Hi Rana,

Use this logic.

data:
  w_present type d,
  w_next     type d.

w_next+0(4) = w_present+0(4) - 1.

Sy-datum and d are 2 different date types.

Their formats are sometjing like this.

d : 'yyyymmdd'.

sy-datum : 'dd:mm:yyyy'(depends on the settings)

Much Regards,

Amuktha.

Read only

0 Likes
1,131

HI Rana,

Try the with the below code.

data : v_date type d.

data : v_temp(4) type c.

data : v_date1 type d.

v_date = sy-datum.

v_temp = v_date+0(4) - 1.

CONCATENATE v_temp v_date+4(4) into v_date1.

write : v_date1 .

Read only

Former Member
0 Likes
1,131

See the below code

Edited by: Swastik Bharati on May 28, 2009 2:12 PM

Read only

Former Member
0 Likes
1,131

DATA: cha(4) TYPE N,
previous_year(4) type N.

cha = sy-datum+0(4).

previous_year = cha - 1.

Read only

Former Member
0 Likes
1,131

Hi,

Data : lv_date type dats,

lv_date = sy-datum.

lv_date0(4) = lv_date0(4) - 1

Read only

Former Member
0 Likes
1,131

you can use ths code I can you are facing fiscal year problem:

l_pdatl = sy-datum+0(4)  .    " year
      l_pprdl = sy-datum+5(2)  .    "month

      CASE l_pprdl .
        WHEN 01 .
          l_pprdl = 10 .
        WHEN 02 .
          l_pprdl = 11 .
        WHEN 03 .
          l_pprdl = 12.
        WHEN OTHERS .
          l_pprdl = l_pprdl - 3 .
      ENDCASE.l_pdatl = sy-datum+0(4)  .

thanx aryan

Edited by: Aryan@sap on May 28, 2009 2:14 PM

Read only

Former Member
0 Likes
1,131

Hi,

Try like this

DATA: cha TYPE string,

previous_year type string.

cha = sy-datum+0(4).

previous_year = cha - 1.

Read only

Former Member
0 Likes
1,131

Thanks This solved my problem.

Read only

Former Member
0 Likes
1,131

Hi Rana ,

Check the code - -

DATA: cha(4) TYPE c,
previous_year(4) TYPE c.

cha = sy-datum+0(4).

previous_year = cha - 1.
WRITE : previous_year.

Read only

Former Member
0 Likes
1,131

Hello Rana,

Declare the variables as below.

Data: cha(4) type n,

previous_year(4) type n.

cha = sy-datum+0(4).

previous_year = cha - 1.

write : / cha , previous_year.

Regards,

Jyothi