‎2010 Jan 12 8:05 AM
Hi all,
In the Selection screen of my report i had maintained two fields
SELECT-OPTIONS : S_DATE FOR TPCDATE-FROM_DATE.
PARAMETERS : P_NUMBER TYPE ZMMAREA-NUMBER.
I need to code such that
S_DATE should be splitted into P_NUMBER times
for example if P_NUMBER is 4 i need S_DATE should be splitted into 4 equal parts or near by equal parts
IF P_NUMBER is 2 i need S_DATE should be splitted into 2 equal parts or near by equal parts
Please suggest me the code of if any Function module exists fot this date splitting
Thanks in advance
Ajay.D
‎2010 Jan 12 8:23 AM
Hello
Try this logic:
SELECT-OPTIONS : S_DATE FOR TPCDATE-FROM_DATE.
PARAMETERS : P_NUMBER TYPE ZMMAREA-NUMBER.
DATA: DAYS TYPE I,
COUNT TYPE I,
XXX TYPE I.
DATA: BEGIN OF ITAB OCCURS 0,
LDATE LIKE SY-DATUM,
HDATE LIKE SY-DATUM,
END OF ITAB.
DAYS = S_DATE-HIGH - S_DATE-LOW.
COUNT = TRUNC( DAYS / P_NUMBER ).
XXX = P_NUMBER - 1.
DO XXX TIMES.
ITAB-LDATE = S_DATE-LOW.
S_DATE-LOW = S_DATE-LOW + COUNT.
ITAB-HDATE = S_DATE-LOW.
APPEND ITAB.
S_DATE-LOW = S_DATE-LOW + 1.
CLEAR ITAB.
ENDDO.
ITAB-LDATE = S_DATE-LOW.
ITAB-HDATE = S_DATE-HIGH.
APPEND ITAB.
In table ITAB you will have date intervals.
‎2010 Jan 12 8:14 AM
Hi,
your question seems to be not clear to me. Can you eloborate about the requirement.
Are you looking for splitting of date range? Please note that Select options can have ranges, exclusions and single values.
Thanks,
Vinod.
‎2010 Jan 12 8:23 AM
Hello
Try this logic:
SELECT-OPTIONS : S_DATE FOR TPCDATE-FROM_DATE.
PARAMETERS : P_NUMBER TYPE ZMMAREA-NUMBER.
DATA: DAYS TYPE I,
COUNT TYPE I,
XXX TYPE I.
DATA: BEGIN OF ITAB OCCURS 0,
LDATE LIKE SY-DATUM,
HDATE LIKE SY-DATUM,
END OF ITAB.
DAYS = S_DATE-HIGH - S_DATE-LOW.
COUNT = TRUNC( DAYS / P_NUMBER ).
XXX = P_NUMBER - 1.
DO XXX TIMES.
ITAB-LDATE = S_DATE-LOW.
S_DATE-LOW = S_DATE-LOW + COUNT.
ITAB-HDATE = S_DATE-LOW.
APPEND ITAB.
S_DATE-LOW = S_DATE-LOW + 1.
CLEAR ITAB.
ENDDO.
ITAB-LDATE = S_DATE-LOW.
ITAB-HDATE = S_DATE-HIGH.
APPEND ITAB.
In table ITAB you will have date intervals.
‎2010 Jan 12 8:24 AM
‎2010 Jan 12 8:24 AM
Hi Ajay,
1. Find the difference betweem low and high of the selction date (say value = x)
2. Divide x by P_number (say the resut = y)
3. add Y to low of selection data.. till it reaches High value..
Please consider point of vinod as well..
Are you looking for splitting of date range? "Please note that Select options can have ranges, exclusions and single values.
Hope this helps,
Nag
‎2010 Jan 12 8:24 AM
Yes u can do as u need i.e, first get the parameter value and then get the difference (in no.of years) between the given date range and divide it by value (given for paratmer) and update the select option accordingly. But your logic should cover all the cases i.e, if user gives single day for selecti option then how u will divide it based on the parameter value. So be clear about the requirement first and build logic accordingly.
‎2010 Jan 12 8:27 AM
Hi,
Please be clear with your requirement then only we can suggest some solution.
Regards,
Amit
‎2010 Jan 12 8:30 AM
though date question are not allowed, this requirement sounds little different.
you can take a difference between those days by: S_date-high - S_date-low.
then divide the difference by p_number. now you get the split positions.
now in a do enddo you can negate the dates by the split amount you got from the divisions.
like...
PARAMETERS: num type i.
select-OPTIONS: s_date for sy-datum.
data : gv_split type i, gv_temp type sy-datum.
gv_split = s_date-high - s_date-low.
gv_split = gv_split / num.
gv_temp = s_date-high.
do num times.
gv_temp = gv_temp - gv_split.
WRITE / gv_temp.
enddo.
‎2010 Jan 12 8:41 AM
‎2010 Jan 12 8:50 AM