Application Development 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: 

Substract field and Sy-datum in select clause

Former Member
0 Kudos

I am new in ABAP

I would like to do something like this.

SELECT sy-datum - field INTO... FROM ...

But I receive the following error ...

Unknown column name sy-datum. not determined until runtime.

How can i solve this?

Thanx

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Sy-datum is a system field.it cannot be selected.

current date will be in sy-datum.

the following statement will print current date.

write: sy-datum.

if u want to do any manipulations u can copy it to a local variable and can be used.

for ex: data:v_date type sy-datum.

v_date = sy-datum.

use v_date for further operations.

Thanks,

VAmsi.

5 REPLIES 5

Former Member
0 Kudos

Hi,

Sy-datum is a system field.it cannot be selected.

current date will be in sy-datum.

the following statement will print current date.

write: sy-datum.

if u want to do any manipulations u can copy it to a local variable and can be used.

for ex: data:v_date type sy-datum.

v_date = sy-datum.

use v_date for further operations.

Thanks,

VAmsi.

Former Member
0 Kudos

Jose,

U cannot use SELECT and Sy-datum.

Instead, u can have

data: myDate type sy-datum.

myDate = sy-datum - 1.

Thanks

Kam

Former Member
0 Kudos

Hi,

Its not possible to subtract the field from the sy-datum

when you are making a select.

And also you cannot select the sy-datum from the database table.

Its a structure called syst.

Cheers,

Sampath

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You can't do that calc untill after the selection of data.

Data: begin of xvbak,
      vbeln type vbak-vbeln,
      erdat type vbak-erdat,
      end of xvbak.

data: number_of_days type i.

select Single vbeln erdat into xvbak
          from vbak
                where vbeln = p_vbeln.
number_of_days = sy-datum - xvbak-erdat.

Welcome to SDN!

Regards,

Rich Heilman

Former Member
0 Kudos

Hi, you can do it like this:

v_fecha = sy-datum - pdias.

pdias is numeric.

Robert