‎2006 Sep 06 8:42 PM
Hi, I need to write a rannge which will include or the weekdays.
can someone guide i can i do so.
‎2006 Sep 06 8:45 PM
‎2006 Sep 06 8:45 PM
‎2006 Sep 06 8:47 PM
I have to get the data for the last 10 days excluding saturay and sunday of production order quantity
so I wanted to write range for all the weekdays.
or can you suggest me with some other method to get the following data. or if there is anytype of function.
‎2006 Sep 06 8:54 PM
You don't need to build ranges.. just pass the date to the function module DAY_IN_WEEK. If the return value is 6 its a Saturday or if its 7 it is a Sunday.
~Suresh
‎2006 Sep 07 4:40 AM
oK, SO I think you are going to code a select from somewhere and want to include 'and date in r_last_10_working_days'.....
to set up your range you can do this:
RANGES R_LAST_TEN_WORKNG_DAYS FOR SY-DATUM.
DATA WORK_DATE TYPE SY-DATUM.
DATA COUNT TYPE I VALUE 0.
DATA DAY_NUMBER TYPE P.
R_LAST_TEN_WORKNG_DAYS-OPTION = 'EQ'.
R_LAST_TEN_WORKNG_DAYS-SIGN = 'I'.
WORK_DATE = SY-DATUM.
DO.
WORK_DATE = WORK_DATE - 1.
CALL FUNCTION 'DAY_IN_WEEK'
EXPORTING
DATUM = WORK_DATE
IMPORTING
WOTNR = DAY_NUMBER.
IF DAY_NUMBER < 6.
R_LAST_TEN_WORKNG_DAYS-LOW = WORK_DATE.
APPEND R_LAST_TEN_WORKNG_DAYS.
ADD 1 TO COUNT.
ENDIF.
IF COUNT = 10. EXIT. ENDIF.
ENDDO.
LOOP AT R_LAST_TEN_WORKNG_DAYS.
WRITE:/ R_LAST_TEN_WORKNG_DAYS.
endloop.
‎2006 Sep 07 7:34 AM
hi,
to exclude holidays too,
use fm <b>RKE_SELECT_FACTDAYS_FOR_PERIOD</b>
CALL FUNCTION 'RKE_SELECT_FACTDAYS_FOR_PERIOD'
EXPORTING
i_datab = start_date
i_datbi = end_date
i_factid = '01'
TABLES
eth_dats = itab.Message was edited by: Andreas Mann
‎2006 Sep 07 7:54 AM
Hi Kamlesh,
i did it on this way:
DATA: TAGE TYPE I.
DATA: ANZAHL TYPE I.
DATA: DATE LIKE SY-DATUM.
*
ANZAHL = 10 * ( -1 ). "Negative days
DATE = SY-DATUM.
*
WHILE TAGE > ANZAHL.
*
DATE = DATE - 1.
*
CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
EXPORTING
DATE = DATE
FACTORY_CALENDAR_ID = 'ZO' "Your Factory Calender
MESSAGE_TYPE = 'I'
EXCEPTIONS
DATE_NO_WORKINGDAY = 4.
*
IF SY-SUBRC <> 4.
TAGE = TAGE - 1 .
ENDIF.
*
ENDWHILE.
*
WRITE: / SY-DATUM, DATE.
Regards, Dieter
‎2006 Sep 07 8:56 AM
U can define the range for weekday as below.
range : r_wday for sy-fdayw,
r_date for sy-datum.
Initialization.
r_wday-low = '1'. "Monday
r_wday-high = '5'. "Friday
r_wday-sign = 'BT'.
r_wday-option = 'I'.
append r_wday.
Your requirement.
ldate = sy-datum.
do 10 times.
call function 'day_in_week'
exporting
datum = ldate
changing
wotnr = ldayw.
ldate = ldate + 1.
check ldayw in r_wday.
r_date-sign = 'EQ'.
r_date-option = 'I'.
r_date-low = ldate - 1.
append r_date.
enddo.