Help on custom function...

Hi all
I'm having a problem with this custom function/report posted on TechNet while back for ConfigMgr 2007
http://social.technet.microsoft.com/wiki/contents/articles/7870.sccm-2007-create-report-of-upcoming-maintenance-windows-by-client.aspx
I've made the needed changes according to this blog post:
https://sccmfaq.wordpress.com/2013/08/22/sccm-2012-show-next-effective-maintenance-window/
..but when using maintenance windows that occurs for example 1st tuesday of every 1 months, the function returns the date week ahead. For example now (on 28th of Feb) next maintenance window should be on Tuesday March 3rd, but instead the report is showing
Tuesday March 10th.
Any help on modifying the function would be appreciated, I saw that there comments on the original post about the recurrence type 4 (monthly by weekday as noted here https://msdn.microsoft.com/en-us/library/cc143300.aspx) not working correctly in the function.
It seems that the function now returns the weekday of first full week of the month instead of the correct day.
The function is this:
CREATE FUNCTION [dbo].[SCCM_GetNextServiceWindow](@ScheduleToken AS CHAR(16), @RecurrenceType AS INT) RETURNS @NextServiceWindow TABLE (ScheduleToken CHAR(16), RecurrenceType INT, NextServiceWindow DATETIME, Duration INT, IsGMTTime BIT) AS BEGIN
--1 Occurs on 1/1/2012 12:00 AM 00011A8500080000
--2 Occurs every 3 day(s) effective 1/1/2012 8:00 PM 02811A8040100018
--3 Occurs every 3 week(s) on Saturday effective 1/1/2012 8:00 PM 02811A80401F6000
--3 Occurs every 1 week(s) on Saturday effective 1/1/2012 8:00 PM 02811A80401F2000
--5 Occurs day 2 of every 2 month(s) effective 1/1/2012 8:00 PM 02811A8040288800
--5 Occurs day 31 of every 1 month(s) effective 1/1/2012 8:00 PM 02811A80402FC400
--5 Occurs the last day of every 3 months effective 1/1/2012 8:00 PM 02811A8040280C00
--5 Occurs the last day of every 1 months effective 1/1/2012 8:00 PM 02811A8040280400
--4 Occurs the Third Monday of every 1 month(s) effective 1/1/2012 4:00 AM 00811A9E08221600
--4 Occurs the Last Wednesday of every 1 month(s) effective 1/1/2012 8:00 PM 02811A8040241000
--4 Occurs the Fourth Wednesday of every 1 month(s) effective 1/1/2012 8:00 PM 02811A8040241800
--4 Occurs the Last Monday of every 1 month(s) effective 1/1/2012 8:00 PM 02811A8040221000
--3 Occurs every 1 week(s) on Monday effective 1/1/2012 4:00 AM 00811A9E081A2000
-- http://msdn.microsoft.com/en-us/library/cc143300.aspx [This link is external to TechNet Wiki. It will open in a new window.]
DECLARE @RecurrenceType_NONE INT
, @RecurrenceType_DAILY INT
, @RecurrenceType_WEEKLY INT
, @RecurrenceType_MONTHLYBYWEEKDAY INT
, @RecurrenceType_MONTHLYBYDATE INT
SELECT @RecurrenceType_NONE = 1
, @RecurrenceType_DAILY = 2
, @RecurrenceType_WEEKLY = 3
, @RecurrenceType_MONTHLYBYWEEKDAY = 4
, @RecurrenceType_MONTHLYBYDATE = 5
-- http://msdn.microsoft.com/en-us/library/cc143505.aspx [This link is external to TechNet Wiki. It will open in a new window.]
--DECLARE @RecurrenceType INT; SET @RecurrenceType = @RecurrenceType_WEEKLY
--DECLARE @ScheduleToken CHAR(16); SET @ScheduleToken = '00811A9E081A2000'
DECLARE @ScheduleStartTime INT; SET @ScheduleStartTime = CAST(CONVERT(BINARY(4), LEFT(@ScheduleToken, 8), 2) AS INT)
DECLARE @ScheduleDuration INT; SET @ScheduleDuration = CAST(CONVERT(BINARY(4), RIGHT(@ScheduleToken, 8), 2) AS INT)
-- Duration is in minutes
DECLARE @Duration INT; SET @Duration = @ScheduleStartTime % POWER(2, 6)
-- Calculate the start time
DECLARE @StartTime DATETIME; SET @StartTime = CONVERT(DATETIME, '01/01/1970 00:00:00')
SET @StartTime = DATEADD(YEAR, (@ScheduleStartTime / POWER(2,6)) % POWER(2, 6), @StartTime)
SET @StartTime = DATEADD(MONTH, ((@ScheduleStartTime / POWER(2,12)) % POWER(2, 4)) - 1, @StartTime)
SET @StartTime = DATEADD(DAY, ((@ScheduleStartTime / POWER(2,16)) % POWER(2, 5)) - 1, @StartTime)
SET @StartTime = DATEADD(HOUR, (@ScheduleStartTime / POWER(2,21)) % POWER(2, 5), @StartTime)
SET @StartTime = DATEADD(MINUTE, (@ScheduleStartTime / POWER(2,26)) % POWER(2, 5), @StartTime)
-- Determinte UTC and Flags
DECLARE @IsGMTTime BIT; SET @IsGMTTime = CAST(@ScheduleDuration % POWER(2, 1) AS BIT)
DECLARE @Flags INT; SET @Flags = (@ScheduleDuration / POWER(2,19)) % POWER(2, 3)
-- Calculate the total duration in minutes
SET @Duration = @Duration + ((@ScheduleDuration / POWER(2,22)) % POWER(2, 5)) * 24 * 60 -- DAYS
SET @Duration = @Duration + ((@ScheduleDuration / POWER(2,27)) % POWER(2, 5)) * 60 -- HOURS
DECLARE @Now DATETIME
IF @IsGMTTime = 1 BEGIN
SET @Now = GETUTCDATE()
END ELSE BEGIN
SET @Now = GETDATE()
END
DECLARE @NextMaintenanceWindow DATETIME
IF @RecurrenceType = @RecurrenceType_NONE BEGIN
IF DATEADD(MINUTE, @Duration, @StartTime) > @Now BEGIN
SET @NextMaintenanceWindow = @StartTime
END
END ELSE IF @RecurrenceType = @RecurrenceType_DAILY BEGIN
IF DATEADD(MINUTE, @Duration, @StartTime) > @Now BEGIN
SET @NextMaintenanceWindow = @StartTime
END ELSE BEGIN
-- Calculate the daily interval in minutes
DECLARE @DailyInterval INT
SET @DailyInterval = ((@ScheduleDuration / POWER(2,3)) % POWER(2, 5)) * 24 * 60
SET @DailyInterval = @DailyInterval + ((@ScheduleDuration / POWER(2,8)) % POWER(2, 5)) * 60
SET @DailyInterval = @DailyInterval + (@ScheduleDuration / POWER(2,13)) % POWER(2, 6)
-- Calculate the total number of completed intervals
DECLARE @DailyNumberOfCompletedIntervals INT; SET @DailyNumberOfCompletedIntervals = ROUND(CAST(DATEDIFF(MINUTE, @StartTime, @Now) AS DECIMAL) / @DailyInterval, 0, 0)
-- Calculate the next interval
DECLARE @DailyNextInterval DATETIME; SET @DailyNextInterval = DATEADD(MINUTE, @DailyNumberOfCompletedIntervals * @DailyInterval, @StartTime)
-- Recalc the next interval if the next interval plus the expected duration is in the past
IF DATEADD(MINUTE, @Duration, @DailyNextInterval) < @Now BEGIN
SET @DailyNextInterval = DATEADD(MINUTE, (@DailyNumberOfCompletedIntervals + 1) * @DailyInterval, @StartTime)
END
SET @NextMaintenanceWindow = @DailyNextInterval
END
END ELSE IF @RecurrenceType = @RecurrenceType_WEEKLY BEGIN
DECLARE @WeeklyInterval INT; SET @WeeklyInterval = (@ScheduleDuration / POWER(2,13)) % POWER(2, 3)
DECLARE @WeeklyDoW INT; SET @WeeklyDoW = (@ScheduleDuration / POWER(2,16)) % POWER(2, 3)
-- Adjust the start time to match the next day of week that matches the interval
DECLARE @WeeklyStartTime DATETIME; SET @WeeklyStartTime = DATEADD(DAY, (7 - DATEPART(WEEKDAY, @StartTime) + @WeeklyDoW % 7), @StartTime)
IF DATEADD(MINUTE, @Duration, @WeeklyStartTime) > @Now BEGIN
SET @NextMaintenanceWindow = @WeeklyStartTime
END ELSE BEGIN
-- Calculate the total number of completed intervals
DECLARE @WeeklyNumberOfCompletedIntervals INT; SET @WeeklyNumberOfCompletedIntervals = ROUND(CAST(DATEDIFF(WEEK, @WeeklyStartTime, @Now) AS DECIMAL) / @WeeklyInterval, 0, 0)
-- Calculate the next interval
DECLARE @WeeklyNextInterval DATETIME; SET @WeeklyNextInterval = DATEADD(WEEK, @WeeklyNumberOfCompletedIntervals * @WeeklyInterval, @WeeklyStartTime)
-- Recalc the next interval if the next interval plus the expected duration is in the past
IF DATEADD(MINUTE, @Duration, @WeeklyNextInterval) < @Now BEGIN
SET @WeeklyNextInterval = DATEADD(WEEK, (@WeeklyNumberOfCompletedIntervals + 1) * @WeeklyInterval, @WeeklyStartTime)
END
SET @NextMaintenanceWindow = @WeeklyNextInterval
END
END ELSE IF @RecurrenceType = @RecurrenceType_MONTHLYBYWEEKDAY BEGIN
DECLARE @MonthlyBWWeek INT; SET @MonthlyBWWeek = (@ScheduleDuration / POWER(2,9)) % POWER(2, 3)
DECLARE @MontlhyBWInterval INT; SET @MontlhyBWInterval = (@ScheduleDuration / POWER(2,12)) % POWER(2, 4)
DECLARE @MonthlyBWDoW INT; SET @MonthlyBWDoW = (@ScheduleDuration / POWER(2,16)) % POWER(2, 3)
-- Calculate the total number of completed intervals
DECLARE @MonthlyBWNumberOfCompletedIntervals INT; SET @MonthlyBWNumberOfCompletedIntervals = ROUND(CAST(DATEDIFF(MONTH, @StartTime, @Now) AS DECIMAL) / @MontlhyBWInterval, 0, 0)
IF @MonthlyBWWeek = 0 BEGIN
-- Calculate the next interval
DECLARE @MonthlyBWLDOMNextInterval DATETIME; SET @MonthlyBWLDOMNextInterval = DATEADD(MONTH, @MonthlyBWNumberOfCompletedIntervals * @MontlhyBWInterval, @StartTime)
-- Calculate last day of month
SET @MonthlyBWLDOMNextInterval = DATEADD(DAY, DATEDIFF(DAY, @MonthlyBWLDOMNextInterval, DATEADD(DAY, -1, DATEADD(M, DATEDIFF(MONTH, 0, @MonthlyBWLDOMNextInterval) + 1, 0))), @MonthlyBWLDOMNextInterval)
-- Calculate the last day of the week for the month
SET @MonthlyBWLDOMNextInterval = DATEADD(DAY, -(7 - DATEPART(WEEKDAY, @MonthlyBWLDOMNextInterval) + @MonthlyBWDoW % 7), @MonthlyBWLDOMNextInterval)
IF DATEADD(MINUTE, @Duration, @MonthlyBWLDOMNextInterval) < @Now BEGIN
-- Recalc for the next month interval
SET @MonthlyBWLDOMNextInterval = DATEADD(MONTH, (@MonthlyBWNumberOfCompletedIntervals + 1) * @MontlhyBWInterval, @StartTime)
-- Calculate last day of month
SET @MonthlyBWLDOMNextInterval = DATEADD(DAY, DATEDIFF(DAY, @MonthlyBWLDOMNextInterval, DATEADD(DAY, -1, DATEADD(M, DATEDIFF(MONTH, 0, @MonthlyBWLDOMNextInterval) + 1, 0))), @MonthlyBWLDOMNextInterval)
-- Calculate the last day of the week for the month
SET @MonthlyBWLDOMNextInterval = DATEADD(DAY, -(7 - DATEPART(WEEKDAY, @MonthlyBWLDOMNextInterval) + @MonthlyBWDoW % 7), @MonthlyBWLDOMNextInterval)
END
SET @NextMaintenanceWindow = @MonthlyBWLDOMNextInterval
END ELSE BEGIN
-- Calculate the next interval
DECLARE @MonthlyBWNextInterval DATETIME; SET @MonthlyBWNextInterval = DATEADD(MONTH, @MonthlyBWNumberOfCompletedIntervals * @MontlhyBWInterval, @StartTime)
-- Set the date to the first day of the month
SET @MonthlyBWNextInterval = DATEADD(DAY, -(DAY(@MonthlyBWNextInterval) - 1), @MonthlyBWNextInterval)
-- Set the date to the first day of week in the month
SET @MonthlyBWNextInterval = DATEADD(DAY, (7 - DATEPART(WEEKDAY, @MonthlyBWNextInterval) + @MonthlyBWDoW) % 7, @MonthlyBWNextInterval)
-- Calculate date based on the week number to add
SET @MonthlyBWNextInterval = DATEADD(WEEK, @MonthlyBWWeek-1, @MonthlyBWNextInterval)
IF DATEADD(MINUTE, @Duration, @MonthlyBWNextInterval) < @Now BEGIN
-- Recalc for the next month interval
SET @MonthlyBWNextInterval = DATEADD(MONTH, (@MonthlyBWNumberOfCompletedIntervals + 1) * @MontlhyBWInterval, @StartTime)
-- Set the date to the first day of the month
SET @MonthlyBWNextInterval = DATEADD(DAY, -(DAY(@MonthlyBWNextInterval) - 1), @MonthlyBWNextInterval)
-- Set the date to the first day of week in the month
SET @MonthlyBWNextInterval = DATEADD(DAY, (7 - DATEPART(WEEKDAY, @MonthlyBWNextInterval) + @MonthlyBWDoW % 7), @MonthlyBWNextInterval)
-- Calculate date based on the week number to add
SET @MonthlyBWNextInterval = DATEADD(WEEK, @MonthlyBWWeek-1, @MonthlyBWNextInterval)
END
SET @NextMaintenanceWindow = @MonthlyBWNextInterval
END
END ELSE IF @RecurrenceType = @RecurrenceType_MONTHLYBYDATE BEGIN
DECLARE @MontlhyBDInterval INT; SET @MontlhyBDInterval = (@ScheduleDuration / POWER(2,10)) % POWER(2, 4)
DECLARE @MonthlyBDDoM INT; SET @MonthlyBDDoM = (@ScheduleDuration / POWER(2,14)) % POWER(2, 5)
IF @MonthlyBDDoM = 0 BEGIN
/* This is the last day of month logic */
-- Calculate the total number of completed intervals
DECLARE @MonthlyBDLDOMNumberOfCompletedIntervals INT; SET @MonthlyBDLDOMNumberOfCompletedIntervals = ROUND(CAST(DATEDIFF(MONTH, @StartTime, @Now) AS DECIMAL) / @MontlhyBDInterval, 0, 0)
-- Calculate the next interval
DECLARE @MonthlyBDLDOMNextInterval DATETIME; SET @MonthlyBDLDOMNextInterval = DATEADD(MONTH, @MonthlyBDLDOMNumberOfCompletedIntervals * @MontlhyBDInterval, @StartTime)
-- Calculate last day of month
SET @MonthlyBDLDOMNextInterval = DATEADD(DAY, DATEDIFF(DAY, @MonthlyBDLDOMNextInterval, DATEADD(DAY, -1, DATEADD(M, DATEDIFF(MONTH, 0, @MonthlyBDLDOMNextInterval) + 1, 0))), @MonthlyBDLDOMNextInterval)
-- Recalc the next interval if the next interval plus the expected duration is in the past
IF DATEADD(MINUTE, @Duration, @MonthlyBDLDOMNextInterval) < @Now BEGIN
SET @MonthlyBDLDOMNextInterval = DATEADD(DAY, DATEDIFF(DAY, @MonthlyBDLDOMNextInterval, DATEADD(DAY, -1, DATEADD(M, DATEDIFF(MONTH, 0, DATEADD(MONTH, (@MonthlyBDLDOMNumberOfCompletedIntervals + 1) * @MontlhyBDInterval, @StartTime)) + 1, 0))), @MonthlyBDLDOMNextInterval)
END
SET @NextMaintenanceWindow = @MonthlyBDLDOMNextInterval
END ELSE BEGIN
-- Check to make sure we won't loop forever if more than 31 days some how ends up in the token
IF @MonthlyBDDoM > 31 SET @MonthlyBDDoM = 31
-- Adjust the start time to match the next day of month that matches the interval
DECLARE @MonthlyBDStartTime DATETIME; SET @MonthlyBDStartTime = DATEADD(DAY, (31 - DATEPART(DAY, @StartTime) + @MonthlyBDDoM % 31), @StartTime)
-- This loop is used multiple times to search for the next valid date that falls on the desired day of month
WHILE(DATEPART(DAY, @MonthlyBDStartTime) <> @MonthlyBDDoM) BEGIN
SET @MonthlyBDStartTime = DATEADD(DAY, (31 - DATEPART(DAY, @MonthlyBDStartTime) + @MonthlyBDDoM) % 31, @MonthlyBDStartTime)
END
IF DATEADD(MINUTE, @Duration, @MonthlyBDStartTime) > @Now BEGIN
SET @NextMaintenanceWindow = @MonthlyBDStartTime
END ELSE BEGIN
-- Calculate the total number of completed intervals
DECLARE @MonthlyBDNumberOfCompletedIntervals INT; SET @MonthlyBDNumberOfCompletedIntervals = ROUND(CAST(DATEDIFF(MONTH, @MonthlyBDStartTime, @Now) AS DECIMAL) / @MontlhyBDInterval, 0, 0)
-- Calculate the next interval
DECLARE @MonthlyBDNextInterval DATETIME; SET @MonthlyBDNextInterval = DATEADD(MONTH, @MonthlyBDNumberOfCompletedIntervals * @MontlhyBDInterval, @MonthlyBDStartTime)
WHILE(DATEPART(DAY, @MonthlyBDNextInterval) <> @MonthlyBDDoM) BEGIN
SET @MonthlyBDNextInterval = DATEADD(DAY, (31 - DATEPART(DAY, @MonthlyBDNextInterval) + @MonthlyBDDoM % 31), @MonthlyBDNextInterval)
END
-- Recalc the next interval if the next interval plus the expected duration is in the past
IF DATEADD(MINUTE, @Duration, @MonthlyBDNextInterval) < @Now BEGIN
SET @MonthlyBDNextInterval = DATEADD(MONTH, (@MonthlyBDNumberOfCompletedIntervals + 1) * @MontlhyBDInterval, @MonthlyBDNextInterval)
WHILE(DATEPART(DAY, @MonthlyBDNextInterval) <> @MonthlyBDDoM) BEGIN
SET @MonthlyBDNextInterval = DATEADD(DAY, (31 - DATEPART(DAY, @MonthlyBDNextInterval) + @MonthlyBDDoM % 31), @MonthlyBDNextInterval)
END
END
SET @NextMaintenanceWindow = @MonthlyBDNextInterval
END
END
END
INSERT INTO @NextServiceWindow VALUES (@ScheduleToken, @RecurrenceType, @NextMaintenanceWindow, @Duration, @IsGMTTime)
RETURN
END
Thanks in advance for any suggestions!

What an ungodly amount of the code for the task!
I tried
SELECT * FROM SCCM_GetNextServiceWindow('00811A9E08221600', 4)
Which is said mean "Occurs the Third Monday of every 1 month(s)" and it returned 2015-03-17. Which is a Tuesday. But it is the third Tuesday.
Turns out that I have British settings on that instance, DATEFIRST is 1. If do SET DATEFIRST 7, I get 2015-03-23. Which is a Monday, but the wrong one.
The current setting of DATEFIRST can be detected with @@DATEFIRST, and that would make the code even more complex.
My gut reaction would be to start over and do it all in C#, where at least I don't have to bother about SET DATEFIRST.
Or maybe first inspect that the ScheduleToken is correct. Maybe it is, but to me that is just an incomprehensible hex string.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • Need help in  Custom functions

    Hi all,
    I'm very eager to know about custom function which I never heard in any other BI tools.
    Can any body please explain ,
    How this custom functions work..?
    In which scenarios we will use them?
    Any example to use.
    If you have any documentation regarding this, pls share with us..
    Thank you,
    Krishna PIngali.

    Krishna,
    Custom Functions work just like any other built in function.
    They can be built using CR or Basic syntax.
    They can be very simple or extremely complex.
    The best time to use them (in my opinion) is when you have a lengthy formula that needs to be referenced multiple times... AKA code re-usability...
    A simple example: <Basic Syntax>
    Function AddTwoNumbers (Number1 As Number, Number2 As Number) As Number
    AddTwoNumbers = (Number1 + Number2)
    End Function
    Once the CF has been added to the report, it can be referenced like any other function...
    AddTwoNumbers(4,4)
    The result is 8
    HTH,
    Jason

  • Custom Function Help

    Post Author: edy80y
    CA Forum: Formula
    I have a report with many subreports which all contain the same formula to group teams.When a new team is added i need to update all instances of the formula so they are all up to date.I know of Custom Function so i created one out of the formula in the main report.  The problem im finding is that im unable to use that custom function in the sub reports.Am i wring in thinking that a custom function created in a main report can be used in its sub reports??Am i creating the custom function incorrectly? Heres what i have done:
    Our database has team names that have a prefix of the State they are in such as: Perth - Team Orange Perth - Team Apple Sydney - Team Grape Sydney - Team Pineapple
    At one stage the Teams in Perth had been split into Perth1 and Perth2 resulting in the following records in the database:
    Perth1 - Team Orange Perth - Team Orange
    Because of this i have created a formula that groups teams into sites:
    select Trimleft(mid({team.name},instr({team.name},'-')+1))case 'Team Orange', 'Team Apple': 'Perth'case 'Team Grape', 'Team Pineapple': 'Sydney'default:''
    I use this formula in all reports and subreports and i link by them as well, so if a new team is created (for example Perth - Team Pear) i need toupdate all instances of the formula by adding 'Team Pear' to the Perth case.
    To fix the problem i created a custom function (called 'site') out of the formula above and it created this:
    Funtion (stringvar v1)select Trimleft(mid(v1,instr(v1,'-')+1))case 'Team Orange', 'Team Apple': 'Perth'case 'Team Grape', 'Team Pineapple': 'Sydney'default:''
    Now within that main report i am able to go to the formula editor and when i type site() then wording becomes blue but when i go into a sub report to do the same it doesnt react.
    I hope i have explained my self well enough for you to understand my predicament without boring you.
    Thanks in advance for your help!

    Post Author: edy80y
    CA Forum: Formula
    Hi,
    Thanks for the reply.  Unfortunately it does make things easy for me.  If i add the custom function in the subreport then i will have to updae that as well whenever a new team is created.  I'm looking for a solution where i only have to update the custom function in the main report only and not in the 7 or 8 subreports within it.
    Unless i am doing something wrong.  I basically copied the contecnt of the Custom Function in the main report and then went into the sub report and created a new Custom Function and pasted the code in it.
    Regards,
    Eddie S

  • Help - I need to remove crop marks set in custom function 3

    Hello All, I need help! I set the custom function 3 to the on position, thinking it would just give me lines to show where an 8x10 crop would be ~ I did not realize that it would actually crop all of my images. I shoot raw and I have imported them into lightroom, within lightroom I cannot remove the crop. I tried opening in Canon's software, removed the crop, then saved as a TIFF, but 17 files ended up being corrupt.
    I see that there is a plug in for LR, but it indicates DNG files, not RAW ~ is there a plug in for RAW? Does anyone know a work around that might help me? Thank you.

    You didn't say which Camera you are using except it is a Canon but use this Plugin and see if it works.  It outputs DNG files and does NOT change your original CR2 so you will have to use the DNG in Lightroom to see the full image.  
    Plug-ins for Adobe Photoshop Lightroom | Adobe Labs

  • No red focus confirmation light on my 3 month old 60D. Checked customs functions, HELP

    Hi guys. Title pretty much says it all. Picked my 60D up today and noticed that it will focus (I get the beep), but no focus confirmation (the red square) through the viewfinder. I have tripled checked all settings, cleared custom functions, made sure my CfN III was set to 0 or ON. I'm in one shot mode, using autofocus. PLEASE HELP! Is there a such thing as AF-OFF? I saw this mentioned elsewhere but not on my 60D menus. The photos seem sharp and in focus, just no confirmation for me on the viewfinder. Any advice??

    It sounds like you've hit all the major things to check:
    In AI Servo mode the AF point will never flash to confirm a focus lock like it will in One Shot mode -- AI Servo mode is continuously focusing.
    C Fn. III -3 (Superimposed Display) needs to be set to '0' (on) which is the default.
    The beep and the red-light are normally tied together (unless you disable the beeping).  If you get a beep, the selected AF point will normally flash at the same time.  e.g. if you were in "AI Servo" mode (instead of "One Shot" mode) then you would not get an audible beep or the red AF point flash to indicate which point is focused.  The fact that you get the beep indicates you are in the right mode and it's confirming... but you should ALSO get the red flash unless you disabled it via C Fn. III -3 set to 1.  
    You could try clearing all custom functions and resetting the camera back to factory default state, but if that doesn't work, I suspect it needs service.
    Tim Campbell
    5D II, 5D III, 60Da

  • How to create a custom function module with the records in SAP R/3?

    Hi All,
    How to create a custom function module with the records in SAP R/3? Using RFC Adapter I have to fetch the custom function module records.
    Regards
    Sara

    Hi
    goto se37...here u need to create a function group... then u need to create a function module. inside assign import/export parameters. assign tables/exceptions. activate the same. now write ur code within the function module
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
    Look at the below SAP HELP links, These links will show you the way to create a Function Module
    http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm

  • How to bring the custom function module in WE42?

    Hi,
    I have created a custom function module to post a custom idoc.
    Process code has been created thro WE42 and WE57 is done.
    Still I am not able to see the custom function module in the list (WE42) in order to assign it to process code.
    May i know the reason for this?
    Thanks.
    Thiyagu

    What makes you think that it should be visible in WE42? There is no F4-value help for this and you haven't added it manually yet, right.
    In WE42 you can manually add entries, so that's what I would do.

  • SSRS - Pass Field Value List To Custom Function Assembly And Display Result

    I have written a SQL Server Reporting Services custom function as a C# assembly DLL and added it to my report. The purpose of the function is to search for outlier records in a collection of data. The data is represented as an array of floating point -tuplets
    (float[][]). In a medical patient database, these might be things such as blood pressure, cholesterol, hight, weight, waist measurement, etc.
    Several user input parameters are provided in the report, including numeric seed values for this particular algorithm. One multivalued parameter is a list of the numeric columns to be used as input to the algorithm because, importantly,
    the user can choose any subset of the value columns. I have a tablix that will display columns from the dataset conditionally, based on which of those columns are chosen.
    At this point, there are two issues I'm having difficulty with:
    How do I, in the course of running the report, take just the numeric columns that the user has chosen (ignoring all others in the dataset) and pass them as a float[][] to my custom function? Or is there something in the
    Microsoft.ReportingServices namespace that I should use to query an input dataset and convert it to an array in my C# code?
    How can I present the array subset returned by my custom function in a tablix in the report?
    Note: One thought that occurs to me is that outlier records tablix could be contained in a subreport, but I'm not clear on the logistics of passing dataset field results from a master report to a subreport.
    I envision a final report when run to be similar to the following:
    - Mark Z.

    Hi Mark,
    Sorry for the delay.
    From your description, you want to pass the dataset data to a custom code array, and return the subset of the array, right? In this case, you can use a custom function to add the data to array, and use the a custom function to sort the data base on your
    requirement and then use a function to get the subset of the array. Here are some sample custom code for your reference.
    Add to arryay
    Dim values As System.Collections.ArrayList=New System.Collections.ArrayList()
    Function SetText(ByVal value As Integer) As Integer
        values.Add(value)
        return value
    End Function
    Sort array
    Function Sort()
    Dim i as Integer
    Dim j as Integer
    Dim t as Integer
    Dim n as Integer=values.Count-1
    For i=n To 1 Step-1
     For j=0 To i-1
     if values(j)<values(j+1) Then
        t=values(j)
        values(j)=values(j+1)
        values(j+1)=t
     End if
     Next j
    Next i
    End Function
    Return value.
    Function Rank(ByVal value As Integer)
       return values(value)
    End Function
    Assume that you pass [Weight] field to array, you can use the expression below on the Weight column:
    =Code.SetText(Fields!Weight.Value)
    Then use the expression below to get the values.
    PatientID:=Sort() & Lookup(Code.Rank(0),Fields!Weight.Value,Fields.Patient.Value,"Dataset")
    Height:=Lookup(Code.Rank(0),Fields!Weight.Value,Fields.Height.Value,"Dataset")
    Weight:=Code.Rank(0)
    Hope this helps.
    Regards,
    Charlie Liao
    If you have any feedback on our support, please click
    here.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • How to assign search help for custom cost centre field in SRM 7.0

    Hi Experts!!
    We are currently working in SRM 7.0.As per our business requirement, in account assignment tab we need to use a custom
    cost centre field (ZCOST_CENTRE) instead of standard cost centre field.It is observed that for standard cost centre field there is a standard web-dynpro search-help assigned where it will return the F4 search help values from backend.
    Can any one of you please help me how can I assign the search-help for the custom cost centre field. Is there any FM to call the backend cost centre search help for custom field or any other way how can I achieve this?
    Thanks in advance.
    Regards,
    Kalyani

    kalyani,
    i can see your requirement in below way..
    as it just reads: you need to assign the standard cost center help to a z cost center field in component /SAPSRM/WDC_UI_DO_ACC.. which actually is fetched though the component /SAPSRM/WDC_UI_BACKEND_SH
    so, if you see the component controller of SAPSRM/WDC_UI_DO_ACC you will see the component
    USAGE_SH_F4     /SAPSRM/WDC_UI_BACKEND_SH                        
    USAGE_SH_F4     /SAPSRM/WDC_UI_BACKEND_SH     INTERFACECONTROLLER
    so you can replicate the same functionality for your z field.
    but can you clarify one thing.. why are you going for this z field in place of standard field ?

  • Unable to debug an exit in CALL CUSTOMER FUNCTION 003

    Hi Guys,
    I have an exit EXIT_SAPMV45A_003 that is called by CALL CUSTOMER FUNCTION 003. I had placed a break point at
    CALL CUSTOMER FUNCTION 003 and the debugger stops here but i am unable to debug inside this to reach into
    the code in EXIT_SAPMV45A_003 even after setting the system debugging on & Update debugging
    ON.
    Can someone help me with this?
    thanks
    Dan

    You have to include that Enhancement of that exit in the Project and Activate that project in the CMOD.
    The Enhancement for the exit EXIT_SAPMV45A_003 is V45A0003.
    Create a project in CMOD
    And inclue V45A0003 in the project.
    Activate the Project.
    Now, it will stop at break point.
    Regards,
    Naimesh Patel

  • Error in Including the Custom function in Custom schema ...

    Hi Experts ,
                   I developed a time custom Function through PE04 ,  Z_5RT and included in Custom Schema , ZM04, while executing in PT60 using the schema ZM04 an error coming . Any configuration required to include custom function in a schema .
    Thanks and regards
    Renjith MP

    You are just going to place the custom function in the 'Func' field of schema.
    Check the counry assignment, parameters & finally you have to activate the function. Check T52A0 for correct internal number.
    http://help.sap.com/erp2005_ehp_04/helpdata/EN/96/79bc54b27911d1a5400000e83ddb11/frameset.htm
    Regards
    N Navaneethan
    Edited by: Navaneethan on Dec 15, 2008 4:30 PM

  • Could not find Model while pointing to a custom Function Group

    Hello ,
    I am on EP7.0 ERP05 NW04s and trying to modify ESS Address application  to point to a custom function group rather than the standard one . When I tried to do that by changing the mapping for the ReadInfotype I got certain compilation errors ,I fixed those and then got the following error at runtime:
    com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Couldnt find info for class com.sap.xss.hr.per.us.address.custom_model_custom.Zhrxss_Per_Read_P0006_Us_Input in model com.sap.xss.hr.per.us.address.model.HRXSS_PER_P0006_US@10c7f0a[scope=APPLICATION_SCOPE]
         at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClass.associatedModelClassInfo(DynamicRFCModelClass.java:220)
         at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClass.elementIndexForFrontendName(DynamicRFCModelClass.java:1359)
         at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClass.setAttributeValueAsString(DynamicRFCModelClass.java:664)
         at com.sap.xss.hr.per.us.address.custom_model_custom.Zhrxss_Per_Read_P0006_Us_Input.setInfty(Zhrxss_Per_Read_P0006_Us_Input.java:162)
         at com.sap.xss.hr.per.us.address.fc.wdp.IPublicFcPerAddressUS$IReadInfotypeElement.setInfty(IPublicFcPerAddressUS.java:11824)
         at com.sap.xss.hr.per.us.address.fc.FcPerAddressUS.readRecord(FcPerAddressUS.java:271)
         at com.sap.xss.hr.per.us.address.fc.wdp.InternalFcPerAddressUS.readRecord(InternalFcPerAddressUS.java:692)
         at com.sap.xss.hr.per.us.address.fc.FcPerAddressUSInterface.readRecord(FcPerAddressUSInterface.java:150)
         at com.sap.xss.hr.per.us.address.fc.wdp.InternalFcPerAddressUSInterface.readRecord(InternalFcPerAddressUSInterface.java:230)
         at com.sap.xss.hr.per.us.address.fc.wdp.InternalFcPerAddressUSInterface$External.readRecord(InternalFcPerAddressUSInterface.java:306)
         at com.sap.xss.hr.per.us.address.overview.VcPerAddressUSOverview.onBeforeOutput(VcPerAddressUSOverview.java:267)
         at com.sap.xss.hr.per.us.address.overview.wdp.InternalVcPerAddressUSOverview.onBeforeOutput(InternalVcPerAddressUSOverview.java:275)
         at com.sap.xss.hr.per.us.address.overview.VcPerAddressUSOverviewInterface.onBeforeOutput(VcPerAddressUSOverviewInterface.java:158)
         at com.sap.xss.hr.per.us.address.overview.wdp.InternalVcPerAddressUSOverviewInterface.onBeforeOutput(InternalVcPerAddressUSOverviewInterface.java:140)
         at com.sap.xss.hr.per.us.address.overview.wdp.InternalVcPerAddressUSOverviewInterface$External.onBeforeOutput(InternalVcPerAddressUSOverviewInterface.java:224)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent.callOnBeforeOutput(FPMComponent.java:602)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent.doProcessEvent(FPMComponent.java:568)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent.doEventLoop(FPMComponent.java:437)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent.wdDoInit(FPMComponent.java:195)
         at com.sap.pcuigp.xssfpm.wd.wdp.InternalFPMComponent.wdDoInit(InternalFPMComponent.java:110)
         at com.sap.tc.webdynpro.progmodel.generation.DelegatingComponent.doInit(DelegatingComponent.java:108)
         at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)
         at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)
         at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.init(ClientComponent.java:430)
         at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:362)
         at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.initApplication(ApplicationSession.java:748)
         at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:283)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:759)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:712)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:261)
         at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:46)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    I wonder what's the cause of this ...
    Any help would be highly appreciated.

    Do below things.
    1. Re-import your Model.
    2. Restart your J2ee server
    3. Re-load & Rebuild your project.
    It should work now..
    Raja T
    Message was edited by:
            Armin Reichert

  • Issue with calling custom function in merge command -10g

    Hi,
    I have ran into issue while calling a custom function in merge command.
    It throws error 'Invalid identifier'. Oracle doesnt understand that it is a function and take the function name as column name.
    Since no such collumn name exists, it throws 'Invalid identifier'.
    Interestingly, merge command works fine when it has a oracle function (replace, decode).
    The oracle version is 10.2.0.3
    It is very urgent.
    Any pointers will be helpful.
    Regards,
    Ravi

    I don't have privileges to create dblink, but this is working for me.
    So, i don't think function can be a issue here.
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:01.02
    satyaki>
    satyaki>
    satyaki>create table hist_tab
      2     as
      3       select * from emp
      4       where sal between 2000 and 4000;
    Table created.
    Elapsed: 00:00:00.09
    satyaki>
    satyaki>select * from hist_tab;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO JOB1      DOB
          7844 TURNER     SALESMAN        7698 08-SEP-81       2178          0         30 SALESMAN
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>
    satyaki>update hist_tab
      2     set mgr = 7794;
    1 row updated.
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>commit;
    Commit complete.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>select * from hist_tab;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO JOB1      DOB
          7844 TURNER     SALESMAN        7794 08-SEP-81       2178          0         30 SALESMAN
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>
    satyaki>
    satyaki>
    satyaki>create table tran_tab
      2     as
      3       select * from emp
      4       where sal between 2000 and 7000;
    Table created.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>select * from tran_tab;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO JOB1      DOB
          7844 TURNER     SALESMAN        7698 08-SEP-81       2178          0         30 SALESMAN
          7902 FORD       ANALYST         7566 03-DEC-81    5270.76                    20 ANALYST
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>ed
    Wrote file afiedt.buf
      1  create or replace function fun(c_in number)
      2     return number
      3     is
      4       c_out number(4);
      5     begin
      6       if c_in < 7900 then
      7          c_out := 0;
      8       else
      9         c_out := 1;
    10       end if;
    11       return c_out;
    12*    end;
    13  /
    Function created.
    Elapsed: 00:00:01.00
    satyaki>
    satyaki>merge into hist_tab o
      2  using (
      3     select empno,
      4            ename,
      5            job,
      6            mgr,
      7            hiredate,
      8            sal,
      9            comm,
    10            deptno,
    11            job1,
    12            dob
    13     from (
    14              select k.*,
    15                     rank() over(order by fun(k.empno)) rn
    16              from tran_tab k
    17          )
    18     where rn = 1
    19     ) n
    20  on ( o.empno = n.empno)
    21  when matched then
    22    update set o.ename = n.ename,
    23               o.job = n.job,
    24               o.mgr = n.mgr,
    25               o.hiredate = n.hiredate,
    26               o.sal = n.sal,
    27               o.comm = n.comm,
    28               o.deptno = n.deptno,
    29               o.job1 = n.job1,
    30               o.dob = n.dob
    31  when not matched then
    32    insert(
    33            o.empno,
    34            o.ename,
    35            o.job,
    36            o.mgr,
    37            o.hiredate,
    38            o.sal,
    39            o.comm,
    40            o.deptno,
    41            o.job1,
    42            o.dob
    43          )
    44    values(
    45            n.empno,
    46            n.ename,
    47            n.job,
    48            n.mgr,
    49            n.hiredate,
    50            n.sal,
    51            n.comm,
    52            n.deptno,
    53            n.job1,
    54            n.dob
    55          );
    1 row merged.
    Elapsed: 00:00:00.03
    satyaki>
    satyaki>select * from hist_tab;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO JOB1      DOB
          7844 TURNER     SALESMAN        7698 08-SEP-81       2178          0         30 SALESMAN
    Elapsed: 00:00:00.00
    satyaki>You can check the final output with old output. It is working perfectly - i guess.
    Regards.
    Satyaki De.

  • Search Help for Custom field in Sourcing Cockpit

    Hi SRM Experts,
    I added custom field "rush order" in the Structures as per requirement. I added code in MODIFY_SCREEN function module. Search help is working for "rush order" in Process Purchase Orders (to search PO) and Check Status (Searching Shopping Cart). But it is not working in sourcing cockpit. Please guide or suggest me is there any additional settings or programming is required to have search help for custom fields in Sourcing Cockpit.
    Thanks a lot in advance.
    Thanks,
    Koyya

    Hi SRM Experts,
    Please let me know any suggestion on this issue.
    Thanks a lot in advance.
    Thanks,
    Koyya

  • F4 help for custom table field - to be used when populating data thru SM30

    Hi,
    I have a custom table with 5 fields - say A, B, C, D and E. While populating data to the table through SM30, I need to create a F4 help for the field C. A  custom function module needs to be used.
    I have created a module for the same in the event PROCESS ON VALUE-REQUEST of the function group of the table.
    But the F4 for field C depends on the values put in fields A and B.
    I am not able to get the values of fields A and B from within the module PROCESS ON VALUE-REQUEST.
    Please help me to create the F4 help.

    hii,
    This is the piece of code i have used in one of my SM30 to get f4. mopdify according to ur need and use.
    revert back for further help.
    w_dynpread-fieldname = 'ZSITEDCDATA-SITE'.
      APPEND w_dynpread TO i_dynpread.
      CALL FUNCTION 'DYNP_VALUES_READ'
        EXPORTING
          dyname               = 'SAPLZSITEDCDATA'
          dynumb               = sy-dynnr
          translate_to_upper   = 'X'
        TABLES
          dynpfields           = i_dynpread
        EXCEPTIONS
          invalid_abapworkarea = 1
          invalid_dynprofield  = 2
          invalid_dynproname   = 3
          invalid_dynpronummer = 4
          invalid_request      = 5
          no_fielddescription  = 6
          invalid_parameter    = 7
          undefind_error       = 8
          double_conversion    = 9
          stepl_not_found      = 10
          OTHERS               = 11.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE i_dynpread INTO w_dynpread INDEX 1.
      IF sy-subrc IS INITIAL.
        SELECT land1 FROM t001w
          INTO TABLE i_site
          WHERE werks EQ w_dynpread-fieldvalue.
        IF i_site[] IS NOT INITIAL.
          DATA: lv_line TYPE i.
          CLEAR lv_line.
          DESCRIBE TABLE i_site LINES lv_line.
          IF lv_line GT 1.
            CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
              EXPORTING
                retfield        = 'ZSITEDCDATA-SITE_COUNTRY'
                dynpprog        = 'SAPLZSITEDCDATA'
                dynpnr          = sy-dynnr
                window_title    = 'Site Country'
                value_org       = 'S'
              TABLES
                value_tab       = i_site[]
                return_tab      = i_return
              EXCEPTIONS
                parameter_error = 1
                no_values_found = 2
                OTHERS          = 3.
            IF sy-subrc <> 0.
              MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
            ELSE.
              READ TABLE i_return INTO w_return INDEX 1.
              IF sy-subrc IS INITIAL.
                zsitedcdata-site_country = w_return-fieldval.
              ENDIF.
            ENDIF.
    Thanks ,
    Gaurav

Maybe you are looking for