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: 

Need help with this code

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

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 .

0 Kudos

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

0 Kudos

Thanks again

Former Member
0 Kudos

Replace the work 'NULL' by ' '.

Shreekant

0 Kudos

Thanks Shreekant.