‎2006 Dec 15 7:21 AM
hi!
the requirement is: date,customers and sales order are the selection parameters for excecuting the report. now the requirement is that this report is executed monthly on the 1st working day of the every month and seclection screen should show the date as date of the 1st working day of that month when ever that report's screen is opened for exectution.
regards
alka
‎2006 Dec 15 7:26 AM
U can do the coding in INITIALIZATION event.
U have to use factory calender....there is function module to get factory calender based on the input date....
‎2006 Dec 15 7:26 AM
U can do the coding in INITIALIZATION event.
U have to use factory calender....there is function module to get factory calender based on the input date....
‎2006 Dec 15 7:28 AM
Hi ,
What you can do is in the INITIALIZATION event write the code for the same.
and since you want the first working day , so you need to know the factory calender ID , once you know that use the FM DATE_CONVERT_TO_FACTORYDATE , to check whether a day is working day or not .
So start from 1'st of the month and try this FM to check if it is a working day or not , else move to next date.
Regards
Arun
Message was edited by:
Arun R
‎2006 Dec 15 7:29 AM
Hi Alka
declare a variable as type sy-datum.
In the initialization event.
get the sy-datum in the variable and using the offset change the last 2 digits of the variable to 01.
and then use that variable in ur selection screen as default value.
‎2006 Dec 15 7:29 AM
Hi,
I dont think there is any direct way to get that date,
but with some calculations with FM DATE_CHECK_WORKINGDAY you will get that.
Regards,
Amit
‎2006 Dec 15 7:43 AM
Alka,
u can use FM DATE_CONVERT_TO_FACTORYDATE and check if it is working day or not.
‎2006 Dec 15 7:54 AM
confirm this .
<b>the date is being picked up on plant level or company code .</b>
for this the field has to go through a chk on the factory calender id ..
TFACD .
what is the calender id associated with it ( plant/company code ) u need to confirm this before writing a code.
check the entry T001W-FABKL for the plant and see what is the calender id it is referring to .
<b> is date in ur query a parameter?</b>
regards,
vijay
Message was edited by:
Vijay
‎2006 Dec 15 8:03 AM
Hi,
Initialization.
p_date = sy-datum.
concatenate sy-datum0(4) p_date4(2) '01' into p_date.
use fm date_check_working_day as suggested.
If p_date is not working day,try adding p_date = p_date + 1.
Then check again using fm.
‎2006 Dec 15 8:40 AM
hi ,
the missing link ( of ur calender id ) u did not mail us back u will have to find this if not now but by the end of ur application.
When ever u r making a check on working day u need to specify for what calender id .
here is a sample code for ur understanding .
REPORT ZVIJ2 .
DATA : V_DATE LIKE SY-DATUM.
parameters :p_date like sy-datum .
**first working day of the month .
Initialization. " u need to put ur code over here.
data : cdat like sy-datum.
cdat = sy-datum. "YYYYMMDD
CDAT+6(2) = '01'. "RESET THE MONTH TO FIRST DATE
PERFORM GET_FIRST_WRK_DAY.
* write:/ 'First working day ' , v_date.
p_date = v_date.
form GET_FIRST_WRK_DAY.
CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
EXPORTING
date = cdat
factory_calendar_id = 'US'
message_type = 'I'
EXCEPTIONS
DATE_AFTER_RANGE = 1
DATE_BEFORE_RANGE = 2
DATE_INVALID = 3
DATE_NO_WORKINGDAY = 4
FACTORY_CALENDAR_NOT_FOUND = 5
MESSAGE_TYPE_INVALID = 6
OTHERS = 7
.
IF SY-SUBRC EQ 0.
v_date = cdat.
ELSE.
add 1 to cdat.
perform GET_FIRST_WRK_DAY.
ENDIF.
endform. " GET_FIRST_WRK_DAYp_date parameter is automatically populated with the first working day .
this will chk for the first hit of the working day for that particular calid.
execute this for ur understanding .
-
Here 's the link u have to check in the FM u need to pass CALID factory calender id.
so for reference sake im using for US (usa) , i have hard quoted it but u need to pass it as a parameter from t001W-fabkl.
so here u need to give the country u r referring to as the parameter.
<b>this is the vital link to ur query .</b>
Example say may 1 of 2006 is working day in usa but for china it is a holiday .
so reference to calid will look for the application of the working calender.
so in order to fetch this simply do
DATA: calid LIKE tfacd-ident.
SELECT SINGLE fabkl INTO calid FROM t001w
WHERE werks " = the missing link. "
and pass this calid to ur Fm insted of hard quoted value as shown.
regards,
vijay
‎2006 Dec 15 8:50 AM
To keep things simple,
We can do it without changing the code of the program.
Save a variant and change the attributes.
For doing so, follow as below:
1. Go the selection-screen
2. Click on save
3. In the next screen give name and description for the variant
4. Select the check box under 'L- Selection Varable' corresponding to the date parameter.
5. Now click on selection-variables from the application toolbar
6. Click on Icon under 'D' in the next screen
7. Click on Arrow pointing down beside the parameter
8. From the list that pops up, select "First day of current month".
9. Save twice
Now select the variant to see that the first date of the current month has come to the variable.
Try practising this approach as this helps especially while scheduling the jobs...
Kind Regards
Eswar
‎2006 Dec 19 2:36 AM