Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Range Statement

Former Member
0 Likes
1,134

Hi, I need to write a rannge which will include or the weekdays.

can someone guide i can i do so.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
982

Hi

Please be clear on your requirement.

Regards,

Raj

7 REPLIES 7
Read only

Former Member
0 Likes
983

Hi

Please be clear on your requirement.

Regards,

Raj

Read only

0 Likes
982

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.

Read only

0 Likes
982

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

Read only

0 Likes
982

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.

Read only

andreas_mann3
Active Contributor
0 Likes
982

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

Read only

Former Member
0 Likes
982

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

Read only

Former Member
0 Likes
982

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.