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

regarding date variable

Former Member
0 Likes
1,998

Hi,

i have a date variable which is "date".

what is the difference between the following two statements?

if date is initial.

-


-


endif.

if date = space.

-


-


endif.

many thanks in advance,

Ravi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,363

hi,,

if date is initial. " this will check according to the data type..

if data type is char then initial = space, if integer initial = 0.

-


-


endif.

if date = space. " this exclusively checks whethere the date variable has blank space

-


-


endif.

rewards if useful,

regards,

nazeer

11 REPLIES 11
Read only

Former Member
0 Likes
1,364

hi,,

if date is initial. " this will check according to the data type..

if data type is char then initial = space, if integer initial = 0.

-


-


endif.

if date = space. " this exclusively checks whethere the date variable has blank space

-


-


endif.

rewards if useful,

regards,

nazeer

Read only

Former Member
0 Likes
1,363

Hi

IF date is of TYPE DATS

then initial means it has value '00000000'

equal to space mean ' '.

CHAR by deafult takes space.

If date is of CHAR type then both statements do the same thing.

other wise

if date is initial. (means 00000000)

-


-


endif.

if date = space.

-


-


endif.

Reward points if useful

Regards

Anji

Read only

suresh_datti
Active Contributor
0 Likes
1,363

the initial value depends on the data type..

it would be space for Char type & '0' for NUMC type so in your case if you have defined as

data w_date type dats.

both the IF statements will give you the sam eresult as the initial value of DATS is space.

But if you define it as

data: w_date(8) type n.

the initial value will be '00000000'.

~Suresh

Ignore my repsonse.. badly mixed up the initial value of dats with chars

Message was edited by:

Suresh Datti

Read only

Former Member
0 Likes
1,363

Hi,

There is no differnce.

Thanks

Sandeep

Read only

0 Likes
1,363

sorry sandeep but thats absoluteley wrong!

his second statement will under NO CURCUMSTANCES be true!

Read only

0 Likes
1,363

FYI,

in the data declaration this variable is defined as

date like sy-datum.

now i donno whether this sy-datum is of char type or num

any inputs now?

Ravi

Read only

0 Likes
1,363

Sy-datum is of type DATS & is stored as Char but has the initial value '00000000'.

~Suresh

Read only

Former Member
0 Likes
1,363

well your second statement will NEVER be true.

SPACE is the initial VALUE of Character variables.

while the initial value for DATS-fields is 00000000

Read only

Former Member
0 Likes
1,363

Hi,

<i><b>SPACE:</b></i>

The data object SPACE is a constant with type C. It is one byte long, and contains a space

character. SPACE is a constant, and as such, cannot be changed.

<i><b>INITIAL:</b></i>

CONSTANTS: pi TYPE P DECIMALS 10 VALUE '3.1415926536'.

ref_c1 TYPE REF TO C1 VALUE IS INITIAL.

The last line shows how you can use the IS INITIAL argument in the VALUE

addition. Since you must use the VALUE addition in the CONSTANTS statement,

this is the only way to assign an initial value to a constant when you declare it.

Regards,

Bhaskar

Read only

Former Member
0 Likes
1,363

hi,

date initial means it will have default value.

date = '00000000'.

date = space means..default value is not assigned.

date = ' '.

Reward with points if helpful.

Read only

Former Member
0 Likes
1,363

Hi Ravi,

hi,

If DATE IS IN INITIAL STAGE THEN

date = '00000000'.

AND DATE IS SPACE MEANS.

date = ' '.

Reward.