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 help with this code

Former Member
0 Likes
901

Hello Friends ,

Please help me with this code

I am calculating no. of days closed , which is a keyfigure. I am using the call below but I getting error during data load .

DATA: create_date TYPE sy-datum,

update_date TYPE sy-datum ,

number of days closed(Keyfigure) (4) TYPE C ,

alert close flag (1) TYPE C .

IF alert cloase flag EQ 'Y'.

number of days closed(Keyfigure) = update_date - create_date .

ELSE.

number of days closed(Keyfigure) ='NULL'.

ENDIF.

RESULT = number of days closed(Keyfigure).

Thanks a lot!!!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
886

Data load? Did it pass a syntax check?

Anyway, maybe this will help:

DATA: create_date              TYPE sy-datum,
      update_date              TYPE sy-datum,
      number_of_days_closed(4) TYPE c,
      alert_close_flag(1)      TYPE c,
      result                   LIKE number_of_days_closed.

IF alert_close_flag EQ 'Y'.
  number_of_days_closed = update_date - create_date .
ELSE.
  CLEAR number_of_days_closed.
ENDIF.

result = number_of_days_closed.

Rob

8 REPLIES 8
Read only

Former Member
0 Likes
887

Data load? Did it pass a syntax check?

Anyway, maybe this will help:

DATA: create_date              TYPE sy-datum,
      update_date              TYPE sy-datum,
      number_of_days_closed(4) TYPE c,
      alert_close_flag(1)      TYPE c,
      result                   LIKE number_of_days_closed.

IF alert_close_flag EQ 'Y'.
  number_of_days_closed = update_date - create_date .
ELSE.
  CLEAR number_of_days_closed.
ENDIF.

result = number_of_days_closed.

Rob

Read only

0 Likes
886

Thnaks a ton ROB.

and yea it passed the syntax check ))

your code really helped I just replaced one line in my code from your's that is

CLEAR number_of_days_closed.

and hurray...it worked.

Thanks a ton again...

appreciated

Message was edited by:

sap_newbee

Read only

0 Likes
886

It passed a syntax check with:

alert close flag (1) TYPE C .
IF alert cloase flag EQ 'Y'.

?

Anyway, glad to help. Close the thread if your question is answered.

Rob

Read only

0 Likes
886

actually I wrote those 2 line in general , I mean just for the sake of proper understanding of feilds , but actually they are properly named InfoObjects.

Thanks a lot .

Read only

0 Likes
886

OK - anyway, you should stick with CLEAR. If you put a space into the field and then change the data type, you may run into problems. CLEAR (without any additions) put initial values for any data type into the field.

Rob

Read only

0 Likes
886

Thanks again

Read only

Former Member
0 Likes
886

Replace the work 'NULL' by ' '.

Shreekant

Read only

0 Likes
886

Thanks Shreekant.