Providing date back based on number interval

Below is a SQL example of what I'm trying to accomplish. The parameter I will be using is what days are available to work on in the format of (0,1,1,1,1,1,0).
The first number represents Sunday and the last is Saturday. If the day has a 0 you have to skip that date, but if the date has a 1 you can use that date. Therefore if the data contained a 0 for Monday if would have to skip Monday when adding days. I can figure out how to put the SQL together to skip Saturday and Sundays but can't figure out how to use the (0,1,1,1,1,1,0) format to determine if work is allowed.
Here is the SQL function I'm using as concept which I need help on how to incorporate it.
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
CREATE OR REPLACE Function custom_add_days
(start_date_in date, days_in number)
return date
IS
v_counter number;
v_new_date date;
v_day_number number;
BEGIN
/* This routine will add a specified number of days (ie: days_in) to a date (ie: start_date). */
/* It will skip all weekend days - Saturdays and Sundays */
v_counter := 1;
v_new_date := start_date_in;
/* Loop to determine how many days to add */
while v_counter <= days_in
loop
/* Add a day */
v_new_date := v_new_date + 1;
v_day_number := to_char(v_new_date, 'd');
/* Increment counter if day falls between Monday to Friday */
if v_day_number >= 2 and v_day_number <= 6 then
v_counter := v_counter + 1;
end if;
end loop;
RETURN v_new_date;

Sorry didn't see your last post again. Changed your query a bit once again.
SQL> CREATE OR REPLACE FUNCTION custom_add_days (
  2     start_date_in   DATE,
  3     work_days       VARCHAR2,
  4     days_in         NUMBER
  5  )
  6     RETURN DATE
  7  IS
  8     v_counter          NUMBER;
  9     v_new_date         DATE;
10     v_day_number       NUMBER;
11     v_loop_counter     NUMBER := 0;
12     work_days_status   NUMBER;
13  BEGIN
14  /* This routine will add a specified number of days (ie: days_in) to a date (ie: start_date). *
15  /* It will skip all weekend days - Saturdays and Sundays */
16     v_counter := 1;
17     v_new_date := start_date_in;
18     v_loop_counter := to_number(to_char(start_date_in, 'D'));
19   
20  /* Loop to determine how many days to add */
21     WHILE v_counter <= days_in
22     LOOP
23  /* Add a day */
24        v_new_date := v_new_date + 1;
25        v_day_number := TO_NUMBER(TO_CHAR (v_new_date, 'd'));
26        v_loop_counter := v_loop_counter + 1;
27        work_days_status :=
28           TO_NUMBER (SUBSTR (REPLACE (work_days, ','),
29                              CASE
30                                 WHEN MOD (v_loop_counter, 7) = 0
31                                    THEN 7
32                                 ELSE MOD (v_loop_counter, 7)
33                              END,
34                              1
35                             )
36                     );
37  /* Increment counter if day falls between Monday to Friday */
38        IF  work_days_status = 1
39        THEN
40           v_counter := v_counter + 1;
41        END IF;
42       
43     END LOOP;
44 
45     RETURN v_new_date;
46  END;
47  /
Function created.
SQL> SELECT CUSTOM_ADD_DAYS(sysdate, '1,0,1,1,1,0,1', 3) FROM Dual
  2   /
CUSTOM_AD
05-JUL-09
1 row selected.
SQL>  SELECT CUSTOM_ADD_DAYS(sysdate, '1,0,1,1,1,0,0', 2) FROM Dual
  2   /
CUSTOM_AD
05-JUL-09
1 row selected.
SQL> Hope this helps.
Regards,
Jo
Edited by: Joice John on Jul 1, 2009 7:44 AM

Similar Messages

  • Provide brings back the actual date , different to the table content

    Hi,
    I´m not a developer, but must do that part now in my company.
    We have a 46C with actual packages.
    In a customer report I have to add 2 fields to an output.
    It selects from PNP and provides data like follows:
    GET PERNR.
      PROVIDE * FROM P0000
    FROM P0001
    FROM P0002
    FROM P0006
    FROM P0007
    FROM P0013
    FROM P0016
    FROM P0053
        BETWEEN PN-BEGDA
            AND PN-ENDDA.
    That worked fine.
    Now I liked to set 2 fields with contents of IT 0000 (table PA0000):
        IF P0000-MASSG = '01'.            " MA aktuell im Vorruhestand ?
         TRANS-BEGVORRST = P0000-BEGDA.
         TRANS-ENDVORRST = P0000-ENDDA.
        ENDIF.
    At debugging I can see, that the requested fields from P0000 are set to the actual date, not to the value I can select from table or shown in the SAP transaction.
    All other fields from PA0000 are matching the row I expect, but not the date fields
    Any idea?

    Hi,
    That is the behavior of PROVIDE statement. If you combine (JOIN) several tables (P0001, P0002, etc) together, it will give you all the intersected dates.
    For example, in two tables itab1 and itab2, the respective columns col1 and col2 are interval limits of type i. The filling of the internal tables results in the following intervals (rows two and three):
    |   Itab1 Int1    |     |Itab1 Int2 |     |
    |        |      Itab2 Int1       |        |
    |  |          ... BETWEEN ...             |
    |  | i1  |   i2   | i3  |   i4   |i5|     |  <<<< This is the result
    Regards,
    Lim...
    Edited by: Ruslim Chang on Apr 17, 2009 11:26 AM

  • Running data providers based on other data provider results in webi

    Hi,
    Thank you all; this is a great place to look for answers whenever you stumble in BO.
    I got a specific requirement for a Webi report. The report should display the associated metrics only when the total surveyed members are greater than 25, if not, N/A.
    This requirement happens to be a new add on for the already existing report; the report was built with multiple providers, in which one of the providers gives the total surveyed members.
    Is there any way that we can control the rest of the data providers based on the first data provider output. I donu2019t want to run the rest of the data providersu2014 as there are too many, and each takes quite a bit of timeu2014 if the surveyed members are less than or equal to 25.
    We are on XI3.1 Sp3
    Thanks in advance.

    Thanks for the quick response!
    Vills u2013 Is it query from the results functionality that you are talking about? I tried this approach, but as I am using the measure in the filter of the 2nd data provider (total members > 25),and the resulting SQL is not getting parsed.
    Waveryu2014 The report filter that I tried to use is not working. Can you please give me some more details how to use it?
    As I would like to leverage the existing report, which perfectly works for the total members> 25 logic, I was asked to find a way to not to run the rest of the data providers to save db resources, provided if the total mbrs participated in the survey from the first data provider <25.
    Is there any way that we can embed some case statement in the other data providers to make them run or throw an error message depending on member count?
    To give some more understanding, I want to provide you the screen shots of the queries, but I am unable to paste those screen shots here .
    Essentially I am looking for is there any way to use one data provideru2019s output as a trigger for the rest of the data providers?

  • How to get data back from an action ?

    Hello,
    Would it be possible to get data back from an action (out of the question EO_MESSAGE & ET_FAILED_KEY )?
    For example we got an order with order positions and we need a "function" to e.g. count all positions. Because of Performance the function should not be processed each time the order is changed, read or a position is added. Instead the function should be processed only if it was called explicitly.
    Is it possible to create a kind of action which is actually counting all entries and export the number of them?
    How to mark a parameter in is_parameters as exporting?
    Is this just done by (naming-) convention?
    What is the preferred way to have “methods” with returning/exporting values?
    Regards,
    Lorenz

    Hello Lorenz,
    As you have already figured out , the Action API provides you with only the messages and failed keys if any.
    Post action execution , you can always execute a retrieve or retrive by association , to get the latest buffer snapshot , which of course would include the changes that you have made in your action.
    If you want to ensure that users have explict control on execution of your "fucntion", then of course , you should model it as an action on the BO.
    The parameter is_parameters is an IMPORTING parameter. You CANNOT use it to export anything back from the action. For importing ,  you can of course have any structure to use as the is_paramaters , which you model as the action parameter structure which modelling your BO action.
    From an external entity the only way to interact with a BO is by consuming the BO services and you are bound by the BOBF standard interfaces. Any and all data you require needs to be modelled as node attributes ( persistent or transient ) and fetched using the RETRIEVE, RETRIEVE_BY_ASSOCIATION or QUERY services.
    Regards,
    Indranil.

  • ITunes was unable to load provider data from Sync Services

    Hello,
    My itunes says : "iTunes was unable to load provider data from Sync Services", when i connect my iphones.
    My iphones sync fine on my other computer.
    This problem occurred when formatting my pc from work.
    And this problem prevents me only sync tab "info" (contacts, calendar and Outlook). This does not prevent me to synchronize other tabs.
    I already tried to reinstall itunes, and the diagnostic option.
    Thanks in advance.

    This problem has been ongoing since 9.2 came out ... i.e. quite some time.
    I uninstalled and then removed all traces off Apple applications, then reinstalled back to the prior version and ran with no problems.
    When I upgraded to V4 iPhone software I had to upgrade again and ran into the same problem.
    Upgrading from Outlook 2000 to Outlook 2003 was of no benefit.
    I have purchased Sync2, set up a gmail account and sync over wireless from Outlook to gamil, then from gamil to iPhone.
    This only does calendar and contacts (haven't found a solution for notes) but waiting for Apple to sort this will probably see you old and gray.
    Good luck.

  • Sort all the Records in Data manager based on Update Date

    How to sort the reocrds in Data Manager based on Date or something ?
    And also I have three records for a same customer in ( for three different company codes ) and when I search for this customer with the Customer number then it is showing three records , but when I search with Update Date then no records are fetched ...what is the reason ?

    If you make a field as type "Time Stamp" in your data model using the MDM Console, make sure that the option Sort Index is set to Normal.  If this is the case, whenever a record is updated in the repository, the date will be updated.  If the sort index is normal, then MDM will allow you to sort the records based on the date and time by which they were updated.  You can do this by finding your time stamp field in the MDM data manager and clicking on it.  If there is an up and down arrow next to the name of your field, it means it can be sorted.  Also, to answer your other question, you can definitely search based on date.  Use the Free-Form Search on the left hand side of the data manager at the bottom of the screen.  Simply select a date, and it will show you all the records updated on that date.

  • Importing XML Data Back into the Form

    I have a form that shows several subforms based on the selections the user has made while filling in the form. This is working quite well but when I import the XML data back into the form it doesn't show the subforms that have been used.
    Is there an easy way to change this?
    Thanks in advance!
    Emma

    Actually the issue may actually have to do with the fact that the connections aren't bound, but I haven't seen the data.
    I have some fairly complex forms that include both subforms and instances, have an XSD embedded and export as XML. When I import the data, everythi
    Now, that being said...
    Are your subforms "hidden" and you opt to display them upon selection of a radio button for example, or do you SetInstances()? If you're using visible=TRUE or FALSE, that may also cause some issues.
    Try this -- on Form:ready try this code:
    if(this.rawValue == "on"){ //this radio button 1
    _subform1.setInstances(1);
    _subform2.setInstances(0);
    _subform3.setInstances(0);
    else if(this.rawValue == "on"){ //this radio button 1
    _subform1.setInstances(0);
    _subform2.setInstances(1);
    _subform3.setInstances(0);
    else if(this.rawValue == "on"){ //this radio button 1
    _subform1.setInstances(0);
    _subform2.setInstances(0);
    _subform3.setInstances(1);
    else { // this is fisrt time open -- i sometimes had issues with subforms being visible on first entry
    _subform1.setInstances(0);
    _subform2.setInstances(0);
    _subform3.setInstances(0);
    Then on:Click essentially copy most of the code you put in form:ready
    if(this.rawValue == "on"){ //this radio button 1
    _subform1.setInstances(1);
    _subform2.setInstances(0);
    _subform3.setInstances(0);
    else if(this.rawValue == "on"){ //this radio button 1
    _subform1.setInstances(0);
    _subform2.setInstances(1);
    _subform3.setInstances(0);
    else if(this.rawValue == "on"){ //this radio button 1
    _subform1.setInstances(0);
    _subform2.setInstances(0);
    _subform3.setInstances(1);
    Of course this will go on top of your radio button group.
    If you are exporting to XML, it will make your life a whole lot easier, by the way, to import an XSD and bind your nodes, especially as your forms and data start to get more complex.
    Finally, you may also know this but -- unless you have Forms Server, any user that wants to export the data or import the data will need to have at least full Acrobat Professional. If you want people to be able to save data in the form but import/export isn't that important, they will need to have full Acrobat.
    I hope that helps a bit. Good luck!
    Lisa

  • Failed to fetch data provider data. (LO 26306)

    Hi,
    We have created a webi report, which is having a date prompts.
    The same webi report, we have used in xelsius using a live office connection.
    In Xelsius, We have checked the box 'refresh on load', under usage tab.
    When we run the xelsius dashboard, we are getting an "Failed to fetch data provider data. (LO 26306)".
    Can anyone please help. why this error is getting. Is it because of prompts which are there in webi report.
    Basically, our requirement is when the user runs the dashboard, prompts should be displayed. User will enter the prompts and based on that, dash board should get display.
    Regards
    Ramesh Ganji

    See SAP Note 1440129.
    Symptom
    Change the Live Office documentation to clearly state that before importing a Live Office document within Xcelsius the Live Office document has to be opened in Excel and the 'Refresh All objects' triggered.  If this step is not done and the Excel file is saved without prior refresh the error 'Failed to fetch data provider data (LO 26306) in Xcelsius is raised (when previewing the model)
    Environment
    Live Office 3.1
    Xcelsius 2008
    Cause
    The information is not stated in the official documentation.
    Resolution
    The issue has been identified and logged under Problem Report ID ADAPT01374107
    Keywords
    01374107, ADAPT, ADAPT01374107, LO, 26306, LO 26306, LiveOffice

  • How do I read my wave form data back from an LVM file?

    I collected a waveform and saved it using the LVM file format. I would like to read the waveform back into labview and display it with its timestamp and assigned name. The only way I could read the data back into Labview was to convert it to a number array. I figured if you could write a waveform and save all its data, you should be able to read it back rather easily. I've included my LVM file and two simple programs. The program I'm using is much larger, but these two programs are representative of what I'm trying to accomplish.
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    Write To LVM.vi ‏96 KB
    Read From LVM.vi ‏67 KB
    Test Data_08-12-11_1252.txt ‏29 KB

    Hi Knoebel,
    To display the waveform data, you'll need to change a couple things.
    1. Open the "Convert from Dynamic Data" vi and change the Conversion to have a resulting data type of 1D array of waveform, as this is the datatype you are writing with the "Write To LVM.vi"  Currently you are converting to an array of scalars here, which is why you are losing timestamp data.
    2. Open the "Read from Measurement File" express VI and Change the Time Stamps to be Absolute (date and time) rather than relative. 
    3. If you want to display the timestamp on the waveform graph, pull up the properties window for the Waveform graph and change the Display Format to be Absolute Time for the X-axis and then check the Scales tab to be sure you have unchecked Ignore waveform timestamp on x-axes
    After making the change to convert from dynamic data type to 1D array of waveform you can also probe the wire going into the waveform graph to check the t0 and dt values of the waveform as you read from file.
    Lastly, if you look at the Write to LVM.vi block diagram, you will see a little red coercion dot between the waveform data wire and the Write to Measurement File data input terminal.  It would be better to use the "Convert to Dynamic Data" express VI to make this conversion.
    Hope this helps!
    Sherrie 

  • FI:where to maintain the data of "Group account number"?

    Hi.When I use the T-CODE FS00 to create G/L account,the sap require me to Make an entry in field "Group account number".But when I press F4 on the field "Group account number",the sap tell me there is no values.So I need to maintain the data of "Group account number".But I don't know where to maintain the data of "Group account number".So I need someone give me the T-CODE or some advice.Thanks so much.

    Hi,
    You have activated group account number. If you have any grp account number of your company please provide the group company account number.
    Else if you dont want to give group account number
    In T-code: OB13 remove group chart of accounts from your chart of accounts
    Best Regards
    Ashish Jain
    Message was edited by:
            Ashish Bohara

  • HT1386 Error message when trying to sync .. "unable to load provider data from sync services

    When trying to sync I phone ... I get an error message saying  Unable to load provider data from sync services ....
    I have removed and re-installed I tunes and still get this message ..
    Thanks for any help !

    Thanks Joy
    I did try that and it eventually went to backing up.  however, after 2 Hrs the bar hadn't moved any ..

  • Delete Duplicate rows in Data Package based on selection

    Hello experts,
    I have the data coming from Oracle using DB_Connect. The data has duplicate order no. I need to delete the duplicate rows in the data package based selection before updating the data target.
    I am thinking of writing this in updaterule start routine. I would greatly appreciate any sample code on selective deletion of data package rows.
    Thanks a lot!
    Sri

    Nagesh,
    Thanks for your reply.
    Do I need write this in Update Start routine?
    Another thing the order number field is coming from source system. Currently we are not mapping/assingning to InfoObject. In other words we are not seding order no to data target.
    In my query can I write something like this...
    DELETE ADJACENT DUPLICATES FROM DATA_PACKAGE COMPARING DATA_Package-OrderNo
    Thanks a lot!
    Sri

  • Generic Data source based on Infoset

    Hi,
    I have a Generic data source based on Infoset. i need hostorical data from this data source, when i extract it is given me only current data. Infoset based on PNPCE logical database, in the Infoset query (ECC6) when i select "All" it gives all data, but when i extract with RSA3 with perticular personal number it just give me 1 record,
    Please help me to fix this problem.
    Thanks

    i think you mean to get data relevant to a date. have you setup the begda/enda as selection parameters in the generic datasource? that would be the only aside from a custom  program to first fetch the data and then send it to bi.
    with the dates, you can pull it with the relevant date range setup in the infopackage

  • Loading BPC data back to BW for reporting.

    Hi All,
           We are in NW BPC 7.5 and the tool is not matching up to the drill-down reporting capabilities of BW so we need to pull the plan data back to BW for Plan/Actual reporting. I am interested in knowing about the best practice to achieve this.
    1. Flat Files dump and loads - not acceptable as it beats the purpose of NW based BPC.
    2. BW ETL - I understand the technical names of BPC Application Cube change after optimiztion and between Dev Q and Prod so ETL would need constant changes.
    Any other options / recommendations ?
    Regards
    Anupam

    I agree with Ethan's reply as being the preferred route.  But regarding your original question and the option of using ETL.  Keep in mind that the only way the InfoCube might change when full optimization is run is IF there are more than 13 dimensions in the application.  Otherwise, BW assigns each characteristic to its own BW dimension (of which there are possible 16 with 3 being predefined).  So if you have an application with less than 13 dimensions and you feel this will be stable, then you can probably safely go ahead and build an ETL process directly against the BPC cube without risk that it will be impacted by optimization.
    Best regards,
    [Jeffrey Holdeman|http://wiki.sdn.sap.com/wiki/display/profile/Jeffrey+Holdeman]
    SAP Labs, LLC
    BusinessObjects Division
    Americas Applications Regional Implementation Group (RIG)

  • User-Provided Data: Scrubbing & Displaying Thereof

    I'm in the middle of completely rebuilding an old application from the ground up and wanted to get some feedback on user-provided data and security, see what new methods people are using, and get some general feedback. With past applications I've always made use of CFQUERYPARAM on my database transactions, verified the proper length of all data provided by the user, and ran each form field through a custom tag that, rather harshly, checked for characters commonly used within SQL injection strings and cross-site scripting attacks. This time around I'd like to maintain, if not increase the security of my application when it comes to user-provided data, but at the same time not hinder or upset users by blocking just so many "suspect" characters.
    Of course about half of the user data I get can be scrubbed easily enough: E-Mail addresses, passwords, telephone numbers.
    Where I've run into problems in the past is the more free-form fields such as names, addresses, search criteria, and "comments" boxes, all which could easily have characters such as ', /, %, --, and the like. In the past I've judged these and many other characters harshly but I wonder if I've been too harsh?
    So, I'm curious to hear some opinions on the much-discussed topic of SQL injection and XSS and how it relates to user-provided data.
    What characters are you checking for in user data? How do you go about handling them? Escape them? Remove them? Generate an error to the user?
    Some things I've heard in the past that I'm curious if people do:
    01) htmleditformat() every piece of user data as it is outputted as text within a page.
    02) htmleditformat() every piece of user data as it is inserted into the database. An issue with this is that as htmleditformat() translates characters into lengthy ASCII strings and often extends user input beyond the MAXLENGTH of the given form/database field, and the customer won't understand why.

    Some reccomendations:
    1. Continue use of CFQUERYPARAM and data length/type verification.  This should keep you safe from SQL injection.
    2. Use HtmlEditFormat for output only.  Using HtmlEditFormat for input will cause a problem if the text is ever consumed by an application that doesn't understand HTML entities.
    3. Use a whitelist/blacklist specific to the data you are collecting.  For example, I think you can safely assume that a first name won't contain angle brackets. 
    4. Take a look at the Portcullis project.  From RIA Forge: "Portcullis is a CFC based url,form,cookie filter to help protect against SQL Injection and XSS (Cross Site Scripting) attacks."
    http://portcullis.riaforge.org/
    5. Tell the user when you're going to replace/escape their input with something else.  This will keep your site user friendly.

Maybe you are looking for

  • SetPromptsFailed Error while running Deskireport in Infoview

    Hi all, I have migrated a 5.1.7 deski report to XI - R3 deski and it successfully gets refreshed in Deski environment. When I export the XI R3 report to the CMC, I'm not able to refresh the report. It throws the error as "Set Prompts Failed Error. Th

  • Disk Utility won't burn a .cdr image to DVD – why and what do I do?

    I've burned DVDs before and I've had success with my MB Pro.  I know the steps and use this support article as a refresher each time to assure I'm following all the steps.  Yesterday and today I've tried to burn 2 different .cdr images made with Disk

  • Oracle shutdown or initialization in progress

    Dears! I have installed 9iAS+8.1.7 on the same machine.9iAS & database was working.For any reason we changed the IP address of the machine and restart the machine.Again we change the IP address to the original one when 9iAS+database was installed,aga

  • Where is the folder containing installation package to bonjour.msi located

    having issues downloading itunes v10.5.1. on Windows XP. Error message The feature you are trying to use is on a network resource that is unavailable. Enter an alternative path to a folder containing the installation package Bonjour.msi. Where do I f

  • Multi-condition Dynamic actions

    Is it possible to have multi-condition dynamic actions e.g. hide field A if field B is null and field C is set to 'ABC'