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

Check condition points surely ;)

Former Member
0 Likes
1,397

Hi

Actually i had a requirement in which i have to check the amount for every three days.

<b>Example:</b> It has to check for every three consecutive days such as

monday, tuesday, wednesday.......

tuesday,wednesay,thursday

wednesay,thursday,friday

in which i have to omit 2nd and 4th saturdays and also public holidays..

While performing this it has to check If the amount is greater than three crore then it has to fire an mail automatically. Firing an mail if the amount is greater is not a big issue but the problem is how to compare three consecutive days????? how to omit the 2nd & 4th saturdays and also public holidays???

Regards

Krishna

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,373

Hi

Check this sample code

YOu can write your own FM with the following code



TABLES: T001W.

DATA: WORKDAY_FLAG(1) TYPE C.

CLEAR: T001W, RESULT_DATE.

* Check whether base date is required to be included
IF INCLUDE_BASE <> SPACE.
DATUM = DATUM - 1.
ENDIF.

* Get the Factory calender ID if not supplied
IF FABKL IS INITIAL.
SELECT SINGLE * FROM T001W WHERE WERKS = WERKS.
FABKL = T001W-FABKL.
ENDIF.

* Make sure you have atleaset a day for calculation.
IF DAYS = 0.
DAYS = 1.
ENDIF.

WHILE DAYS > 0.

DATUM = DATUM + 1.

CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
DATE = DATUM
FACTORY_CALENDAR_ID = FABKL
IMPORTING
WORKINGDAY_INDICATOR = WORKDAY_FLAG
EXCEPTIONS
CALENDAR_BUFFER_NOT_LOADABLE = 1
CORRECT_OPTION_INVALID = 2
DATE_AFTER_RANGE = 3
DATE_BEFORE_RANGE = 4
DATE_INVALID = 5
FACTORY_CALENDAR_NOT_FOUND = 6
OTHERS = 7.

CASE SY-SUBRC.
WHEN 1.
RAISE CALENDAR_BUFFER_NOT_LOADABLE.
WHEN 2.
RAISE CORRECT_OPTION_INVALID.
WHEN 3.
RAISE DATE_AFTER_RANGE.
WHEN 4.
RAISE DATE_BEFORE_RANGE.
WHEN 5.
RAISE DATE_INVALID.
WHEN 6.
RAISE FACTORY_CALENDAR_NOT_FOUND.
ENDCASE.

IF WORKDAY_FLAG IS INITIAL.
DAYS = DAYS - 1.
ENDIF.

ENDWHILE.

RESULT_DATE = DATUM.

Reward all helpfull answers

Regards

Pavan

Message was edited by:

Pavan praveen

Message was edited by:

Pavan praveen

Hi

Actually i had a requirement in which i have to check the amount for every three days.

<b>Example:</b> It has to check for every three consecutive days such as

monday, tuesday, wednesday.......

tuesday,wednesay,thursday

wednesay,thursday,friday

in which i have to omit 2nd and 4th saturdays and also public holidays..

While performing this it has to check If the amount is greater than three crore then it has to fire an mail automatically. Firing an mail if the amount is greater is not a big issue but the problem is how to compare three consecutive days????? how to omit the 2nd & 4th saturdays and also public holidays???

Regards

Krishna

9 REPLIES 9
Read only

Former Member
0 Likes
1,373

any replies plzzzzzzzzzzzzz

Read only

0 Likes
1,373

any one reply me

Read only

0 Likes
1,373

Use the function module HOLIDAY_GET to get the list of holidays.

Use the function modules HOLIDAY_CALENDAR_GET and FACTORY_CALENDAR_GET to get your holiday and factory calendars.

Please mark points if the solution was useful.

Regards,

Manoj

Read only

0 Likes
1,373

But how to check for the three consecutive days any coding part plz sample

Read only

0 Likes
1,373

Pass the date range you want to check for holidays to the function module HOLIDAY_GET and it will return you the list of holidays between that range in an internal table. Read the table and you will get to know the list of holidays.

Please mark points if the solution was useful.

Regards,

Manoj

Read only

0 Likes
1,373

any sample coding plz for my requirement

Read only

Former Member
0 Likes
1,373

Hi,

Factory calender has been set in your sap system?

if yese use this function module BKK_CHECK_HOLIDAY.

[<i>b]regards

Debjani

Rewards point for helpful answer</b></i>

Read only

Former Member
0 Likes
1,373

Hi,

create a z table which will store last mail sent date.

check laterst mail sent date.

for saturdays check this link:

u can get holidays with FM HOLIDAY_GET.

then

create a program and fit this logic in that and schedule this program to rum on every day on a particular time . chek all dates and if it meets ur requiremetn send a mail using FM SO_DOCUMENT_SEND_API1

Hope this will help u.

Jogdand M B

Read only

Former Member
0 Likes
1,374

Hi

Check this sample code

YOu can write your own FM with the following code



TABLES: T001W.

DATA: WORKDAY_FLAG(1) TYPE C.

CLEAR: T001W, RESULT_DATE.

* Check whether base date is required to be included
IF INCLUDE_BASE <> SPACE.
DATUM = DATUM - 1.
ENDIF.

* Get the Factory calender ID if not supplied
IF FABKL IS INITIAL.
SELECT SINGLE * FROM T001W WHERE WERKS = WERKS.
FABKL = T001W-FABKL.
ENDIF.

* Make sure you have atleaset a day for calculation.
IF DAYS = 0.
DAYS = 1.
ENDIF.

WHILE DAYS > 0.

DATUM = DATUM + 1.

CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
DATE = DATUM
FACTORY_CALENDAR_ID = FABKL
IMPORTING
WORKINGDAY_INDICATOR = WORKDAY_FLAG
EXCEPTIONS
CALENDAR_BUFFER_NOT_LOADABLE = 1
CORRECT_OPTION_INVALID = 2
DATE_AFTER_RANGE = 3
DATE_BEFORE_RANGE = 4
DATE_INVALID = 5
FACTORY_CALENDAR_NOT_FOUND = 6
OTHERS = 7.

CASE SY-SUBRC.
WHEN 1.
RAISE CALENDAR_BUFFER_NOT_LOADABLE.
WHEN 2.
RAISE CORRECT_OPTION_INVALID.
WHEN 3.
RAISE DATE_AFTER_RANGE.
WHEN 4.
RAISE DATE_BEFORE_RANGE.
WHEN 5.
RAISE DATE_INVALID.
WHEN 6.
RAISE FACTORY_CALENDAR_NOT_FOUND.
ENDCASE.

IF WORKDAY_FLAG IS INITIAL.
DAYS = DAYS - 1.
ENDIF.

ENDWHILE.

RESULT_DATE = DATUM.

Reward all helpfull answers

Regards

Pavan

Message was edited by:

Pavan praveen

Message was edited by:

Pavan praveen