cancel
Showing results for 
Search instead for 
Did you mean: 

customer exit

Former Member
0 Kudos

Hi experts,

I have the following code to count the number of days from the user selection variable.

DATA: L_S_RANGE TYPE RSR_S_RANGESID,

LOC_VAR_RANGE LIKE RRRANGEEXIT,

d1 type sy-datum,

d2 type sy-datum,

d3 type i.

Read table i_t_var_range INTO loc_var_range with key vnam = 'user input variable'.

d1 = loc_var_range-low.

d2 = loc_var_range-high.

d3 = d2 - d1.

l_s_range-low = d3 .

l_s_range-sign = 'I'.

l_s_range-opt = 'EQ'.

APPEND l_s_range TO e_t_range.

If the ABAP'er debug's the code, it is returning the number of days correctly. But when i display it in the query, it is returning '0' value. Could you please suggest me wht went wrong in this?

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

shanthi_bhaskar
Active Contributor
0 Kudos

DATA: L_S_RANGE TYPE RSR_S_RANGESID, 
LOC_VAR_RANGE LIKE RRRANGEEXIT,
d1 type sy-datum,
d2 type sy-datum,
d3 type i.

Read table i_t_var_range INTO loc_var_range with key vnam = 'user input variable'. 


d1 = loc_var_range-low.
d2 = loc_var_range-high.

if i_vnam = 'Query Varaible'*   "put varaible to which you want to populate
d3 = d2 - d1.
l_s_range-low = d3 . 
l_s_range-sign = 'I'. 
l_s_range-opt = 'EQ'. 
APPEND l_s_range TO e_t_range.
endif.


Former Member
0 Kudos

Thank you for the quick response. I tried as you mentioned but still the result is same like before.

Any further inputs will be appreciated.

shanthi_bhaskar
Active Contributor
0 Kudos

give me your exact code..

Former Member
0 Kudos

Hi,

CASE i_vnam. " Variablenname

  • when 'ZVAR_DCOUNT'.

*DATA: L_S_RANGE TYPE RSR_S_RANGESID,

  • LOC_VAR_RANGE LIKE RRRANGEEXIT,

  • d1 type sy-datum,

  • d2 type sy-datum,

  • d3 type i.

*

*Read table i_t_var_range INTO loc_var_range With key vnam = '0I_DAYS'.

*

*d1 = loc_var_range-low.

*d2 = loc_var_range-high.

*

*d3 = d2 - d1.

  • l_s_range-low = d3 .

  • l_s_range-sign = 'I'.

  • l_s_range-opt = 'EQ'.

  • APPEND l_s_range to e_t_range.

  • ENDCASE.

In the above code:

0I_DAYS is the userinput variable of 0calday.

ZVAR_DCOUNT is the formula variable.

Thanks.

Former Member
0 Kudos

Hi,

"d3 = d2 - d1" ...is correct & should be working.

Anyway, why you don't go for function module to get difference between two dates.

Like

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'

EXPORTING

i_datum_bis = d1

i_datum_von = d2

IMPORTING

e_tage = d3.

Their are many other 'date difference' function, if above FM is not working .... look for other FMs.

Thanks,

Jitender.

Answers (0)