03-27-2009 5:16 PM
Hi,
I have a selection for date on in an report,
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : dat_rang FOR sy-datum.
SELECTION-SCREEN END OF BLOCK blk1.
I want to create a flat list of dates from this selection. This list should exclude the date(s), which are excluded in the selection.
Please give some starters on how to do this.
Thank you,
CD
03-27-2009 5:21 PM
03-27-2009 5:21 PM
03-27-2009 5:29 PM
Ex: If user selects date 06/1/2008, 07/01/2008 to 07/31/2008, and exlcude 07/4/2008, 07/07/2008 - 07/10/2008
Then I want a list of all dates to be included ex: in this case, 06/1/2008, 07/01/2008, 07/02/2008, 07/03/2008, 07/05/2008, 07/05/2008, and from 07/11/2008 to 07/31/2008
I want to bring all this dates in an internal table
This may be a silly question, but I am new to ABAP so please help me with some hints.
Thank you,
CD
03-27-2009 5:31 PM
HI,
If date IN dat_rang. ---> It will take care of exclusion if date provided to exlude in the dat_rang you need to write any logic for this
Write the Data.
ENDIF.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : dat_rang FOR sy-datum.
SELECTION-SCREEN END OF BLOCK blk1.
If user selects date 06/1/2008 to 06/30/2008, and exlcude 06/4/2008, 06/10/2008 - 06/20/2008
l_date = '20080601'.
DO 30 TIMES.
IF l_date IN dat_rang.
Write:/ l_date.
Endif.
ENDDO.
OUTPUT:.
06/1/2008 - 06/3/2008
06/5/2008 - 06/9/2008
06/21/2008 - 06/30/2008
Edited by: Avinash Kodarapu on Mar 27, 2009 11:03 PM
03-27-2009 5:33 PM
Here is another example, adding the dates to an internal table.
REPORT zrich_0001.
TYPES: BEGIN OF t_datum,
datum TYPE sy-datum,
END OF t_datum.
DATA: lt_datum TYPE TABLE OF t_datum.
DATA: ls_datum LIKE LINE OF lt_datum.
DATA: lv_date TYPE sy-datum.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : dat_rang FOR sy-datum.
SELECTION-SCREEN END OF BLOCK blk1.
INITIALIZATION.
lv_date = '19000101'.
START-OF-SELECTION.
DO.
IF lv_date IN dat_rang.
ls_datum-datum = lv_date.
APPEND ls_datum TO lt_datum.
ENDIF.
lv_date = lv_date + 1.
IF lv_date = '20500101'.
EXIT.
ENDIF.
ENDDO.
LOOP AT lt_datum INTO ls_datum.
WRITE:/ ls_datum-datum.
ENDLOOP.
Regards,
Rich Heilman
03-27-2009 5:27 PM
Probably better to change the design of your program, but here is a solution.
REPORT zrich_0001.
DATA: lv_date TYPE sy-datum.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : dat_rang FOR sy-datum.
SELECTION-SCREEN END OF BLOCK blk1.
INITIALIZATION.
lv_date = '19000101'.
START-OF-SELECTION.
DO.
IF lv_date IN dat_rang.
WRITE:/ lv_date.
ENDIF.
lv_date = lv_date + 1.
IF lv_date = '20500101'.
EXIT.
ENDIF.
ENDDO.
Regards,
Rich Heilman
03-27-2009 5:39 PM
Hi,
Check this..
SELECT-OPTIONS so_date FOR sy-datum.
DATA: t_dates TYPE STANDARD TABLE OF sydatum,
s_dates TYPE sydatum.
START-OF-SELECTION.
* get the records that are included.
LOOP AT so_date WHERE sign = 'I'.
s_dates = so_date-low.
APPEND s_dates TO t_dates.
CHECK NOT so_date-high IS INITIAL.
* Add the dates in between low and high.
WHILE s_dates < so_date-high.
s_dates = s_dates + 1.
APPEND s_dates TO t_dates.
ENDWHILE.
ENDLOOP.
* Display the dates.
LOOP AT t_dates INTO s_dates.
WRITE: / s_dates.
ENDLOOP.
THanks
Naren