Hi all,
I am working on ranges.
And i want to use values of these ranges in Parameters. i.e Range-low should come by default in P_FROM and Range-high shold come by defalut on P_TO
so frnds can anyone help me how to get it.
Below i m providing my code.
<code>
REPORT ZDEMO_FOR_RANGES_1.
ranges : date1 for sy-datum,
date2 for sy-datum,
date3 for sy-datum.
date1-sign = 'I'.
date1-option = 'BT'.
date1-low = sy-datum + 1. "tommorrows date
date1-high = sy-datum + 60. "60 days later.
APPEND date1.
date2-sign = 'I'.
date2-option = 'BT'.
date2-low = date1-low + 61. "61days after of tomorrow
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
months = '6'
olddate = date2-low
IMPORTING
NEWDATE = date2-high.
APPEND date2.
read table date1 index 1.
*append lines of date1 to p_from index 1.
parameters : p_from like sy-datum ,
p_to like sy-datum,
p_from_1 like sy-datum,
p_to_1 like sy-datum.
</code>
I have tried in many ways but i m not getting any help frnds.
regards,
satish
Hi Satish,
If you want to read a range, you need to READ TABLE <range> INDEX x for the range, hence if you need values from date1 and date2, perform READ TABLE on both ranges to get the low and high values in the range header.
Also, to default the values you can code within the AT SELECTION-SCREEN OUTPUT event like this:
INITIALIZATION.
date1-sign = 'I'.
date1-option = 'BT'.
date1-low = sy-datum + 1. "tommorrows date
date1-high = sy-datum + 60. "60 days later.
APPEND date1.
date2-sign = 'I'.
date2-option = 'BT'.
date2-low = date1-low + 61. "61days after of tomorrow
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
months = '6'
olddate = date2-low
IMPORTING
NEWDATE = date2-high.
APPEND date2.
read table date1 index 1.
AT SELECTION-SCREEN OUTPUT.
IF p_from IS INITIAL.
MOVE date1-low TO p_from.
ENDIF.
IF p_to IS INITIAL.
MOVE date1-high TO p_to.
ENDIF.
--- the IF condition is to ensure that the user's entered value in p_from/p_to is not again overwritten by the default.
Regards,
Aditya
>
> Hi all,
> I am working on ranges.
>
> And i want to use values of these ranges in Parameters. i.e Range-low should come by default in P_FROM and Range-high shold come by defalut on P_TO
> so frnds can anyone help me how to get it.
>
> Below i m providing my code.
>
>
> <code>
>
> REPORT ZDEMO_FOR_RANGES_1.
PARAMETERS : p_from TYPE sy-datum, p_to TYPE sy-datum.
>
> ranges : date1 for sy-datum,
> date2 for sy-datum,
> date3 for sy-datum.
>
> date1-sign = 'I'.
> date1-option = 'BT'.
> date1-low = sy-datum + 1. "tommorrows date
> date1-high = sy-datum + 60. "60 days later.
>
> APPEND date1.
>
>
> date2-sign = 'I'.
> date2-option = 'BT'.
> date2-low = date1-low + 61. "61days after of tomorrow
>
> CALL FUNCTION 'MONTH_PLUS_DETERMINE'
> EXPORTING
> months = '6'
> olddate = date2-low
> IMPORTING
> NEWDATE = date2-high.
>
> APPEND date2.
p_from = range-low. " I'm not sure which range low you are going to assign p_to = range-high.
> </code>
>
> I have tried in many ways but i m not getting any help frnds.
>
> regards,
> satish
Add a comment