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

Date type problem

Former Member
0 Likes
765

Hello,

I have a program that goes like this :

DATA : p_audatto, p_audatfrom TYPE sy-datum.

p_audatto = sy-datum.

p_audatfrom = sy-datum - 3.

....

when i debug this i have

p_audatto == 2,

p-audatfrom == 20070521 and

sy-datum ==20070524

Can somebody explain me why my p_audatto value is 2 ?

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
745

Hi

Because you've defined it as field of <b>ONLY 1 CHAR</b>, so it can store only the first number of the date.

DATA : p_audatto   TYPE SY-DATUM, "<---- Right definition 
       p_audatfrom TYPE sy-datum.
p_audatto = sy-datum.
p_audatfrom = sy-datum - 3.

Max

8 REPLIES 8
Read only

Former Member
0 Likes
746

Hi

Because you've defined it as field of <b>ONLY 1 CHAR</b>, so it can store only the first number of the date.

DATA : p_audatto   TYPE SY-DATUM, "<---- Right definition 
       p_audatfrom TYPE sy-datum.
p_audatto = sy-datum.
p_audatfrom = sy-datum - 3.

Max

Read only

Former Member
0 Likes
745

Hello

Delcare the fields like this


DATA : p_audatto TYPE sy-datum,  " Check here
           p_audatfrom TYPE sy-datum.

Vasanth

Read only

Former Member
0 Likes
745

Hi,

Decalre p_audatto TYPE sy-datum.

this will work and the result will be

24.05.2007

Revert back if nay issues.

Reward with points if helpful.

Regards

Naveen.

Read only

Former Member
0 Likes
745

Bcoz when you are defining DATA : p_audatto, p_audatfrom TYPE sy-datum.

p_audatto will be taken as type c of length 1. for desired result you need to define like this

DATA : p_audatto TYPE sy-datum,

p_audatfrom TYPE sy-datum.

regards,

Amit

Read only

Former Member
0 Likes
745

Hi Tomislav,

By default if you didnt specify any thing to a variable in DATA statement then it will be treated as CHARACTER type.

In your case p_audatto is acting as CHARACTER data type of length 1.

DATA : <b>p_audatto type sy-datum,</b>

p_audatfrom TYPE sy-datum.

Thanks,

Vinay

Read only

Former Member
0 Likes
745

Hi,

If you want to get date in p_audatto,define p_audatto as

DATA: p_audatto like sy-datum.

Regards,

Savitha

Read only

Former Member
0 Likes
745

Hi

Do like this......

DATA : p_audatto TYPE sy-datum,

p_audatfrom TYPE sy-datum.

Reward All Helpfull Answers........

Read only

former_member196280
Active Contributor
0 Likes
745

Data type declaration for p_audatto is C.

By default if you don't declare any it will consider as type C lenght of 1 char.

That is the cause of your problem.

Reward points to all useful answers.

Regards,

SaiRam