[8i] Help with function with parameters (for workday calculation)
Let me start by saying, I've never written a function before, and I don't have access to create a function in my database (i.e. I can't test this function). I'm trying to come up with a function that I can ask my IT department to add for me. I'm hoping someone can take a look at what I've written and tell me if it should work or not, and if this is the right way to go about solving my problem.
I am trying to create a function to do a very simple workday calculation (adding/subtracting a particular number of workdays from a calendar date).
The database I'm working with has a table with the workday calendar in it. Here is a sample table and sample data, representative of what's in my workday calendar table:
CREATE TABLE caln
( clndr_dt DATE,
shop_days NUMBER(5)
CONSTRAINT caln_pk PRIMARY KEY (clndr_dt)
INSERT INTO caln
VALUES (To_Date('01/01/1980','mm/dd/yyyy'),0);
INSERT INTO caln
VALUES (To_Date('01/02/1980','mm/dd/yyyy'),1);
INSERT INTO caln
VALUES (To_Date('01/03/1980','mm/dd/yyyy'),2);
INSERT INTO caln
VALUES (To_Date('01/04/1980','mm/dd/yyyy'),3);
INSERT INTO caln
VALUES (To_Date('01/05/1980','mm/dd/yyyy'),3);
INSERT INTO caln
VALUES (To_Date('01/06/1980','mm/dd/yyyy'),3);
INSERT INTO caln
VALUES (To_Date('01/07/1980','mm/dd/yyyy'),4);
INSERT INTO caln
VALUES (To_Date('01/08/1980','mm/dd/yyyy'),5);
INSERT INTO caln
VALUES (To_Date('01/09/1980','mm/dd/yyyy'),6);
INSERT INTO caln
VALUES (To_Date('01/10/1980','mm/dd/yyyy'),7);
INSERT INTO caln
VALUES (To_Date('01/11/1980','mm/dd/yyyy'),8);
INSERT INTO caln
VALUES (To_Date('01/12/1980','mm/dd/yyyy'),8);
INSERT INTO caln
VALUES (To_Date('01/13/1980','mm/dd/yyyy'),8);
INSERT INTO caln
VALUES (To_Date('01/14/1980','mm/dd/yyyy'),9);The actual table includes from 1/1/1980 though 12/31/2015.
I've written (and validated) this parameter query which does my workday (mday) calculation:
SELECT cal.clndr_dt
FROM CALN cal
SELECT cal.shop_days+:mdays AS new_shop_days
FROM CALN cal
WHERE cal.clndr_dt =:start_date
) a
WHERE cal.shop_days = a.new_shop_days
AND ROWNUM =1
ORDER BY cal.clndr_dt;Based on this query, I've created the following function (and I have no clue if it works or if the syntax is right, etc.):
CREATE OR REPLACE FUNCTION add_mdays
(start_date IN DATE,
mdays IN NUMBER(5))
RETURN DATE
IS
new_date DATE;
BEGIN
SELECT cal.clndr_dt
FROM CALN cal
SELECT cal.shop_days+mdays AS new_shop_days
FROM CALN cal
WHERE cal.clndr_dt =start_date
) a
WHERE cal.shop_days = a.new_shop_days
AND ROWNUM =1
ORDER BY cal.clndr_dt;
RETURN new_date;
END add_mdays; //edit 9:31 AM - noticed I left off this bitI'm also not sure how to have the function handle results that would return a date outside of the date range that is in the table (Before 1/1/1980 or after 12/31/2015--or, another way to look at it is, before the MIN value of caln.clndr_dt or after the MAX value of caln.clndr_dt).
My goal is to be able to use the function in a situation like the following:
First, here's a sample table and data:
CREATE TABLE orders
( ord_no NUMBER(5),
plan_start_dt DATE,
CONSTRAINT orders_pk PRIMARY KEY (ord_no)
INSERT INTO orders
VALUES (1,To_Date('01/08/1980','mm/dd/yyyy'));
INSERT INTO orders
VALUES (2,To_Date('01/09/1980','mm/dd/yyyy'));
INSERT INTO orders
VALUES (3,To_Date('01/10/1980','mm/dd/yyyy'));And here is how I would like to use my function:
SELECT orders.ord_no
, orders.plan_start_dt
, add_mdays(orders.plan_start_dt, -3) AS prep_date
FROM ordersThus, the function would allow me to return, for every order in my orders table, the date that is 3 workdays (mdays) prior to the plan start date of each order.
Am I going about this the right way? Do I need to create a function to do this, or is there a way for me to incorporate my query (that does my mday calculation) into the sample query above (eliminating the need to create a function)?
Thanks much in advance!
Edited by: user11033437 on Feb 2, 2010 8:55 AM
Fixed a couple typos in the last insert statements
Edited by: user11033437 on Feb 2, 2010 9:31 AM (fixed some syntax in the function)
Hi,
Ah, mentioning Oracle 8 and not being able to test your own code makes me nostalgic for the good old days, when you typed your cards, and brought them to a window at the computer center, and waited an hour for the job to run, and then saw the printout to find that you had made a typo.
If you're going to write functions, you really need to test them yourself. Like all code, functions whould be written in baby steps: write a line or two (or sometimes just part of what will later become one line), test, make sure it's running correctly, and repeat.
Ideally, your employer should create a developement schema in a development database for you to use.
You can legally download your own instance of Oracle Express Edition for free; just be careful not to use features that aren't available in the database where the code will be deployed.
You don't need a function to get the results you want:
SELECT o.ord_no
, o.plan_start_dt
, MIN (e.clndr_dt) AS prep_date
FROM orders o
, caln l
, caln e
WHERE l.clndr_dt = o.plan_start_dt
AND e.shop_days = l.shop_days - 3
GROUP BY o.ord_no
, o.plan_start_dt
;This would be more efficient (and a little simpler) if you added a column (let's call it work_day) that identified if each row represented a work_day or not.
For each value of shop_days, exactly 1 row will be marked as a work day.
Then the query might be something like:
SELECT o.ord_no
, o.plan_start_dt
, e.clndr_dt AS prep_date
FROM orders o
, caln l
, caln e
WHERE l.clndr_dt = o.plan_start_dt
AND e.shop_days = l.shop_days - 3
AND e.work_day = 1
;You could use the analytic LAG function to populate the work_day column.
A function would certainly be handy, though perhaps slower.
The function you posted has a few mistakes:
(a) An argument can't be declared as NUMBER (5); just NUMBER.
(b) When you SELECT in PL/SQL, like you're doing, you have to SELECT INTO some variable to hold the results.
(c) ROWNUM is arbitrary (which makes it useless in this problem) unless you are drawing from an ordered sub-query. I don't think you can use ORDER BY in sub-queries in Oracle 8. Use the analytic ROW_NUMBER function instead.
(d) The function must end with an END statement.
Given your current caln table, here's how I would write the function:
CREATE OR REPLACE FUNCTION add_mdays
( start_date IN DATE DEFAULT SYSDATE,
mdays IN NUMBER DEFAULT 1
RETURN DATE
DETERMINISTIC
IS
-- add_mdays returns the DATE that is mdays working days
-- after start_date. (If mdays < 0, the DATE returned
-- will be before start_date).
-- Work days do not include Saturdays, Sundays or holidays
-- as indicated in the caln table.
new_date DATE; -- to be returned
BEGIN
SELECT MIN (t.clndr_dt)
INTO new_date
FROM caln f -- f stands for "from"
, caln t -- t stands for "to"
WHERE f.clndr_dt = TRUNC (start_date)
AND t.shop_days = f.shop_days + TRUNC (mdays)
RETURN new_date;
END add_mdays;
SHOW ERRORSProduction code whould be robust (that includes "idiot-proofing").
Try to foresee what errors people might make in calling your function, and correct for them when possible.
For example, if it only makes sense for start_date to be midnight, or mdays to be an integer, then use TRUNC in the function in case soembody passes a bad value.
Allow for default arguments.
Comment your function. Put all comments within the function (that is, after CREATE and before the final END) so that they will be kept in the data dictionary.
If, given the same arguments, the function always returns the same value, mark it as DETERMINISTIC, for efficiency. This means the system may remember values passed back rather than call the function every time it is told to.
I wish I could mark questions as "Correct" or "Helpful"; you'd get 10 points for sure.
You posted CREATE TABLE and INSERT statements (without even being begged).
You gave a clear description of the problem, including desired results.
The code is nicely formatted and easy to read.
All around, one of the most thoughtful, well-written questions I've seen.
Well done! Keep up the good work!
Edited by: Frank Kulash on Feb 2, 2010 1:10 PM
Added my own version of the function.
Similar Messages
-
PDF Documents with Functional Buttons - Works for IE and FireFox but not for Chrome and Safari
To all,
Good morning. Our institution developed a PDF document with functional buttons for printing and e-mailing. When the document is viewed via Internet Explorer and Firefox, the functional buttons work as expected. However if the document is viewed via Chrome and Safari, the functional buttons do not work. The workaround for those who are using Chrome and Safari, the PDF document needs to be saved to their local drive before the functional buttons work.
Has anyone experienced this issue before? If yes, what was your solution other than the workaround.
Thanks.
Babylon5Here's how to configure your browser to run Adobe Reader: http://helpx.adobe.com/acrobat/using/display-pdf-browser-acrobat-xi.html
-
Function module parameters for L_TO_CREATE_TR
Hi All,
Can someone help me out in using the function module 'L_TO_CREATE_TR'.
What are the necessary import and export parameters along with the table parameters?
If i want to pass IT_TRITE (table) as export parameters, what are the requisite fields that should be populated inthat table structure?
Kindly help me out.
Regards,
MainakHi Mainak,
This is the ABAP and the FM-call:
data LT_TRITE type L03B_TRITE_T.
data WA_TRITE like line of LT_TRITE.
data GV_STORED like VBAPF-QMENGE.
clear: LT_TRITE, WA_TRITE, GV_STORED.
refresh LT_TRITE.
WA_TRITE-TBPOS = GT_LTBP-TBPOS.
WA_TRITE-ANFME = GT_LTBP-MENGE.
WA_TRITE-ALTME = GT_LTBP-MEINS.
WA_TRITE-LETYP = GT_MARA-VHART(3). "3-character storageunittype
concatenate '000000000000' LTAP-NLENR+10(8) into WA_TRITE-NLENR.
"FM L_TO_CREATE_TR wants 20 characters
if GV_DIR = 'N'.
WA_TRITE-NLTYP = '120'.
WA_TRITE-NLPLA = 'OVERDRACHT'.
else.
WA_TRITE-NLTYP = P_NLTYP.
WA_TRITE-NLPLA = P_NLPLA.
endif.
append WA_TRITE to LT_TRITE.
TO aanleggen
clear GT_LTAP_VB.
refresh GT_LTAP_VB.
call function 'L_TO_CREATE_TR'
exporting
I_LGNUM = GC_LGNUM_011 "LGNUM is '011' in my case
I_TBNUM = GT_LTBP-TBNUM
IT_TRITE = LT_TRITE
importing
e_tanum = gv_tanum
tables
T_LTAP_VB = GT_LTAP_VB
exceptions
FOREIGN_LOCK = 1
QM_RELEVANT = 2
TR_COMPLETED = 3
XFELD_WRONG = 4
LDEST_WRONG = 5
DRUKZ_WRONG = 6
TR_WRONG = 7
SQUIT_FORBIDDEN = 8
NO_TO_CREATED = 9
UPDATE_WITHOUT_COMMIT = 10
NO_AUTHORITY = 11
PREALLOCATED_STOCK = 12
PARTIAL_TRANSFER_REQ_FORBIDDEN = 13
INPUT_ERROR = 14
others = 15.
if SY-SUBRC <> 0.
commit work."See FM L_TO_CREATE_TR docu: commit work is needed
perform MELDT_DE_FOUT using SY-MSGID SY-MSGTY SY-MSGNO
SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
else.
<b>plz reward points if helpful or if it solves ur query.</b>
Thanks
Chinmay -
Like Time Series function AGO, but for Future calculations
Hello All,
Is there a time series function that can do the same as AGO but going forward?.
I tried using the same AGO function but adding <<number of periods>> = -1, but that didn't work.
I'm interested on getting daily, monthly or yearly future calculations.
Thanks.
Edited by: PabloC2 on Mar 3, 2009 1:37 PMHi
try this
and in 6th point of blog entry, you may need to put plus symbol to add
http://shivabizint.wordpress.com/2008/09/19/rolling-months-data-for-year-month-prompt-in-obiee/
i didn't check.. but hope it works out -
[8i] Need help with some workday calculations
At the beginning of the month, I got help with a workday calculation in: [8i] Help with function with parameters (for workday calculation)
Now, as it turns out, I was able to locate a function in the database that does what I want, however, it is much slower to use the function than to join two copies of the CALN table (Please see referenced thread for details. I can copy them to this thread if necessary.) I need to verify that the pre-existing function has 'DETERMINISTIC' in it, as I would guess that if it doesn't, it would be much slower than it could be.
But now, I've come across a situation where I have to do multiple workday calculations in the same query--enough that I have to join 6 copies of my CALN table. I can't imagine that is at all efficient. I believe it was Frank K. who said (in the original thread) that if the function was slow, I should consider alternatives. Can anyone help me identify some of those alternatives? I'm definitely at that point now. (This query is one I'm using as the base for a report in Oracle BI, and let's just say it doesn't like my query, even though my syntax appears to be correct, and I would guess that joining 6 copies of one table is at least partly to blame for this).
Note: I'm working with Oracle 8iOK, I finally have some sample data... I tried to make it thorough. I've included data in the CALN table YTD + tomorrow, so that any workday calculations using SYSDATE will work.
CREATE TABLE caln
( clndr_dt DATE NOT NULL
, clndr_yr NUMBER
, shop_day NUMBER
, shop_dt DATE
, shop_wk NUMBER
, shop_yr NUMBER
, shop_days NUMBER
, clndr_days NUMBER
CONSTRAINT caln_pk PRIMARY KEY (clndr_dt)
INSERT INTO caln
VALUES (To_Date('12/23/2009','mm/dd/yyyy'),2009,247,To_Date('12/23/2009','mm/dd/yyyy'),51,2009,7631,10950);
INSERT INTO caln
VALUES (To_Date('01/01/2010','mm/dd/yyyy'),2010,0,To_Date('12/23/2009','mm/dd/yyyy'),52,2009,7631,10959);
INSERT INTO caln
VALUES (To_Date('01/02/2010','mm/dd/yyyy'),2010,0,To_Date('12/23/2009','mm/dd/yyyy'),52,2009,7631,10960);
INSERT INTO caln
VALUES (To_Date('01/03/2010','mm/dd/yyyy'),2010,0,To_Date('12/23/2009','mm/dd/yyyy'),1,2010,7631,10961);
INSERT INTO caln
VALUES (To_Date('01/04/2010','mm/dd/yyyy'),2010,1,To_Date('01/04/2010','mm/dd/yyyy'),1,2010,7632,10962);
INSERT INTO caln
VALUES (To_Date('01/05/2010','mm/dd/yyyy'),2010,2,To_Date('01/05/2010','mm/dd/yyyy'),1,2010,7633,10963);
INSERT INTO caln
VALUES (To_Date('01/06/2010','mm/dd/yyyy'),2010,3,To_Date('01/06/2010','mm/dd/yyyy'),1,2010,7634,10964);
INSERT INTO caln
VALUES (To_Date('01/07/2010','mm/dd/yyyy'),2010,4,To_Date('01/07/2010','mm/dd/yyyy'),1,2010,7635,10965);
INSERT INTO caln
VALUES (To_Date('01/08/2010','mm/dd/yyyy'),2010,5,To_Date('01/08/2010','mm/dd/yyyy'),1,2010,7636,10966);
INSERT INTO caln
VALUES (To_Date('01/09/2010','mm/dd/yyyy'),2010,0,To_Date('01/08/2010','mm/dd/yyyy'),1,2010,7636,10967);
INSERT INTO caln
VALUES (To_Date('01/10/2010','mm/dd/yyyy'),2010,0,To_Date('01/08/2010','mm/dd/yyyy'),2,2010,7636,10968);
INSERT INTO caln
VALUES (To_Date('01/11/2010','mm/dd/yyyy'),2010,6,To_Date('01/11/2010','mm/dd/yyyy'),2,2010,7637,10969);
INSERT INTO caln
VALUES (To_Date('01/12/2010','mm/dd/yyyy'),2010,7,To_Date('01/12/2010','mm/dd/yyyy'),2,2010,7638,10970);
INSERT INTO caln
VALUES (To_Date('01/13/2010','mm/dd/yyyy'),2010,8,To_Date('01/13/2010','mm/dd/yyyy'),2,2010,7639,10971);
INSERT INTO caln
VALUES (To_Date('01/14/2010','mm/dd/yyyy'),2010,9,To_Date('01/14/2010','mm/dd/yyyy'),2,2010,7640,10972);
INSERT INTO caln
VALUES (To_Date('01/15/2010','mm/dd/yyyy'),2010,10,To_Date('01/15/2010','mm/dd/yyyy'),2,2010,7641,10973);
INSERT INTO caln
VALUES (To_Date('01/16/2010','mm/dd/yyyy'),2010,0,To_Date('01/15/2010','mm/dd/yyyy'),2,2010,7641,10974);
INSERT INTO caln
VALUES (To_Date('01/17/2010','mm/dd/yyyy'),2010,0,To_Date('01/15/2010','mm/dd/yyyy'),3,2010,7641,10975);
INSERT INTO caln
VALUES (To_Date('01/18/2010','mm/dd/yyyy'),2010,11,To_Date('01/18/2010','mm/dd/yyyy'),3,2010,7642,10976);
INSERT INTO caln
VALUES (To_Date('01/19/2010','mm/dd/yyyy'),2010,12,To_Date('01/19/2010','mm/dd/yyyy'),3,2010,7643,10977);
INSERT INTO caln
VALUES (To_Date('01/20/2010','mm/dd/yyyy'),2010,13,To_Date('01/20/2010','mm/dd/yyyy'),3,2010,7644,10978);
INSERT INTO caln
VALUES (To_Date('01/21/2010','mm/dd/yyyy'),2010,14,To_Date('01/21/2010','mm/dd/yyyy'),3,2010,7645,10979);
INSERT INTO caln
VALUES (To_Date('01/22/2010','mm/dd/yyyy'),2010,15,To_Date('01/22/2010','mm/dd/yyyy'),3,2010,7646,10980);
INSERT INTO caln
VALUES (To_Date('01/23/2010','mm/dd/yyyy'),2010,0,To_Date('01/22/2010','mm/dd/yyyy'),3,2010,7646,10981);
INSERT INTO caln
VALUES (To_Date('01/24/2010','mm/dd/yyyy'),2010,0,To_Date('01/22/2010','mm/dd/yyyy'),4,2010,7646,10982);
INSERT INTO caln
VALUES (To_Date('01/25/2010','mm/dd/yyyy'),2010,16,To_Date('01/25/2010','mm/dd/yyyy'),4,2010,7647,10983);
INSERT INTO caln
VALUES (To_Date('01/26/2010','mm/dd/yyyy'),2010,17,To_Date('01/26/2010','mm/dd/yyyy'),4,2010,7648,10984);
INSERT INTO caln
VALUES (To_Date('01/27/2010','mm/dd/yyyy'),2010,18,To_Date('01/27/2010','mm/dd/yyyy'),4,2010,7649,10985);
INSERT INTO caln
VALUES (To_Date('01/28/2010','mm/dd/yyyy'),2010,19,To_Date('01/28/2010','mm/dd/yyyy'),4,2010,7650,10986);
INSERT INTO caln
VALUES (To_Date('01/29/2010','mm/dd/yyyy'),2010,20,To_Date('01/29/2010','mm/dd/yyyy'),4,2010,7651,10987);
INSERT INTO caln
VALUES (To_Date('01/30/2010','mm/dd/yyyy'),2010,0,To_Date('01/29/2010','mm/dd/yyyy'),4,2010,7651,10988);
INSERT INTO caln
VALUES (To_Date('01/31/2010','mm/dd/yyyy'),2010,0,To_Date('01/29/2010','mm/dd/yyyy'),5,2010,7651,10989);
INSERT INTO caln
VALUES (To_Date('02/01/2010','mm/dd/yyyy'),2010,21,To_Date('02/01/2010','mm/dd/yyyy'),5,2010,7652,10990);
INSERT INTO caln
VALUES (To_Date('02/02/2010','mm/dd/yyyy'),2010,22,To_Date('02/02/2010','mm/dd/yyyy'),5,2010,7653,10991);
INSERT INTO caln
VALUES (To_Date('02/03/2010','mm/dd/yyyy'),2010,23,To_Date('02/03/2010','mm/dd/yyyy'),5,2010,7654,10992);
INSERT INTO caln
VALUES (To_Date('02/04/2010','mm/dd/yyyy'),2010,24,To_Date('02/04/2010','mm/dd/yyyy'),5,2010,7655,10993);
INSERT INTO caln
VALUES (To_Date('02/05/2010','mm/dd/yyyy'),2010,25,To_Date('02/05/2010','mm/dd/yyyy'),5,2010,7656,10994);
INSERT INTO caln
VALUES (To_Date('02/06/2010','mm/dd/yyyy'),2010,0,To_Date('02/05/2010','mm/dd/yyyy'),5,2010,7656,10995);
INSERT INTO caln
VALUES (To_Date('02/07/2010','mm/dd/yyyy'),2010,0,To_Date('02/05/2010','mm/dd/yyyy'),6,2010,7656,10996);
INSERT INTO caln
VALUES (To_Date('02/08/2010','mm/dd/yyyy'),2010,26,To_Date('02/08/2010','mm/dd/yyyy'),6,2010,7657,10997);
INSERT INTO caln
VALUES (To_Date('02/09/2010','mm/dd/yyyy'),2010,27,To_Date('02/09/2010','mm/dd/yyyy'),6,2010,7658,10998);
INSERT INTO caln
VALUES (To_Date('02/10/2010','mm/dd/yyyy'),2010,28,To_Date('02/10/2010','mm/dd/yyyy'),6,2010,7659,10999);
INSERT INTO caln
VALUES (To_Date('02/11/2010','mm/dd/yyyy'),2010,29,To_Date('02/11/2010','mm/dd/yyyy'),6,2010,7660,11000);
INSERT INTO caln
VALUES (To_Date('02/12/2010','mm/dd/yyyy'),2010,30,To_Date('02/12/2010','mm/dd/yyyy'),6,2010,7661,11001);
INSERT INTO caln
VALUES (To_Date('02/13/2010','mm/dd/yyyy'),2010,0,To_Date('02/12/2010','mm/dd/yyyy'),6,2010,7661,11002);
INSERT INTO caln
VALUES (To_Date('02/14/2010','mm/dd/yyyy'),2010,0,To_Date('02/12/2010','mm/dd/yyyy'),7,2010,7661,11003);
INSERT INTO caln
VALUES (To_Date('02/15/2010','mm/dd/yyyy'),2010,31,To_Date('02/15/2010','mm/dd/yyyy'),7,2010,7662,11004);
INSERT INTO caln
VALUES (To_Date('02/16/2010','mm/dd/yyyy'),2010,32,To_Date('02/16/2010','mm/dd/yyyy'),7,2010,7663,11005);
INSERT INTO caln
VALUES (To_Date('02/17/2010','mm/dd/yyyy'),2010,33,To_Date('02/17/2010','mm/dd/yyyy'),7,2010,7664,11006);
INSERT INTO caln
VALUES (To_Date('02/18/2010','mm/dd/yyyy'),2010,34,To_Date('02/18/2010','mm/dd/yyyy'),7,2010,7665,11007);
INSERT INTO caln
VALUES (To_Date('02/19/2010','mm/dd/yyyy'),2010,35,To_Date('02/19/2010','mm/dd/yyyy'),7,2010,7666,11008);
INSERT INTO caln
VALUES (To_Date('02/20/2010','mm/dd/yyyy'),2010,0,To_Date('02/19/2010','mm/dd/yyyy'),7,2010,7666,11009);
CREATE TABLE ords
( ord_nbr NUMBER NOT NULL
, sub_nbr NUMBER NOT NULL
, ord_stat VARCHAR2(2)
, ord_qty NUMBER
, part_nbr VARCHAR2(5)
CONSTRAINT ords_pk PRIMARY KEY (ord_nbr, sub_nbr)
INSERT INTO ords
VALUES (1,1,'CL',10,'PART1');
INSERT INTO ords
VALUES (1,2,'CL',5,'PART1');
INSERT INTO ords
VALUES (25,1,'CL',15,'PART2');
INSERT INTO ords
VALUES (14,1,'OP',12,'PART3');
INSERT INTO ords
VALUES (33,1,'CL',25,'PART1');
INSERT INTO ords
VALUES (33,2,'CL',15,'PART1');
INSERT INTO ords
VALUES (33,3,'OP',10,'PART1');
INSERT INTO ords
VALUES (7,1,'PL',18,'PART2');
INSERT INTO ords
VALUES (96,1,'PL',10,'PART3');
INSERT INTO ords
VALUES (31,1,'CL',20,'PART2');
CREATE TABLE oops
( ord_nbr NUMBER NOT NULL
, sub_nbr NUMBER NOT NULL
, op_nbr VARCHAR2(4) NOT NULL
, mach_id VARCHAR2(4)
, oper_stat VARCHAR2(2)
, plan_start_dt DATE
, plsu NUMBER
, plrn NUMBER
CONSTRAINT ords_pk PRIMARY KEY (ord_nbr, sub_nbr, op_nbr)
-- NOTE:
-- for the orders with a status of 'CL' or 'PL' in the 'ords' table, I'm not bothering to put
-- in more than two operations (though in reality more would be there) since they should be
-- ignored in the final result anyway
INSERT INTO oops
VALUES (1,1,'0010','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.2);
INSERT INTO oops
VALUES (1,1,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.15);
INSERT INTO oops
VALUES (1,2,'0010','123A','CP',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.2);
INSERT INTO oops
VALUES (1,2,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.15);
INSERT INTO oops
VALUES (25,1,'0005','123A','CP',TO_DATE('01/18/2010','mm/dd/yyyy'),2,0.25);
INSERT INTO oops
VALUES (25,1,'0030','110C','CL',TO_DATE('01/19/2010','mm/dd/yyyy'),4,0.1);
INSERT INTO oops
VALUES (14,1,'0010','127A','CP',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.25);
INSERT INTO oops
VALUES (14,1,'0025','110C','CL',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
INSERT INTO oops
VALUES (14,1,'0040','050C','CP',TO_DATE('01/13/2010','mm/dd/yyyy'),1.3,0.15);
INSERT INTO oops
VALUES (14,1,'0050','220B','WK',TO_DATE('01/14/2010','mm/dd/yyyy'),4,0.25);
INSERT INTO oops
VALUES (14,1,'0065','242B','AV',TO_DATE('01/18/2010','mm/dd/yyyy'),1.5,0.1);
INSERT INTO oops
VALUES (14,1,'0067','150G','NA',TO_DATE('01/19/2010','mm/dd/yyyy'),2,0.1);
INSERT INTO oops
VALUES (14,1,'0100','250G','NA',TO_DATE('01/20/2010','mm/dd/yyyy'),2.1,0.2);
INSERT INTO oops
VALUES (33,1,'0010','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),1.9,0.2);
INSERT INTO oops
VALUES (33,1,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
INSERT INTO oops
VALUES (33,2,'0010','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),1.9,0.2);
INSERT INTO oops
VALUES (33,2,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
INSERT INTO oops
VALUES (33,3,'0010','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),1.9,0.2);
INSERT INTO oops
VALUES (33,3,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
INSERT INTO oops
VALUES (33,3,'0020','220B','NA',TO_DATE('01/12/2010','mm/dd/yyyy'),1.7,0.15);
INSERT INTO oops
VALUES (33,3,'0030','150G','NA',TO_DATE('01/13/2010','mm/dd/yyyy'),1.3,0.05);
INSERT INTO oops
VALUES (33,3,'0055','150G','NA',TO_DATE('01/15/2010','mm/dd/yyyy'),2.1.,0.1);
INSERT INTO oops
VALUES (7,1,'0005','123A','NA',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.2);
INSERT INTO oops
VALUES (7,1,'0030','110C','NA',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.15);
INSERT INTO oops
VALUES (96,1,'0010','127A','NA',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.25);
INSERT INTO oops
VALUES (96,1,'0025','110C','NA',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
INSERT INTO oops
VALUES (31,1,'0005','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),1.9,0.2);
INSERT INTO oops
VALUES (31,1,'0030','110C','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
CREATE TABLE mach
( mach_id VARCHAR2(4) NOT NULL
, desc_short VARCHAR2(9)
, group VARCHAR2(7)
CONSTRAINT ords_pk PRIMARY KEY (mach_id)
INSERT INTO mach
VALUES ('123A','desc here','GROUPH1');
INSERT INTO mach
VALUES ('259B','desc here','GROUPH2');
INSERT INTO mach
VALUES ('110C','desc here','GROUPJ1');
INSERT INTO mach
VALUES ('050C','desc here','GROUPK2');
INSERT INTO mach
VALUES ('220B','desc here','GROUPH2');
INSERT INTO mach
VALUES ('242B','desc here','GROUPH2');
INSERT INTO mach
VALUES ('150G','desc here','GROUPL1');
INSERT INTO mach
VALUES ('250G','desc here','GROUPL2');
INSERT INTO mach
VALUES ('242B','desc here','GROUPH2'); -
BI: Virtual Provider for ECC Report with same selection parameters
Dear all,
I have attached screen shot of ECC report selection screen with contain Material, Plant and Dates. As report is bit complex and I need to use just ITAB (internal table) of it for further use in BEx Query and for Dashboard purposes.
Problem: I need to call this report by creating Virtual Provider in BI so that I get data from ECC at runtime as it is shares report so I can't able to save any data in transparent table as report calculated opening balances at runtime.
It is possible for me by using function module i can get itab by submit return and then create Data Source for it ?
As i make copy of FM ZZRSAX_BIW_GET_SIMPLE i cannot use submit there due to OPEN CURSOR mechanism there.
Kindly anyone suggest how it is possible to call report with same selection parameters for creation of virtual provider.
Please mention if i miss any point in explaining problem.
Feel free to ask for any query.
Many thanks.
Hoping for positive and quick responses.please create 2 reports as given below.-
REPORT ZSZP_00007.
parameters a(5) .
parameters b(5) .
parameters c(5) .
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name = 'A' or screen-name = 'B' .
get parameter id 'aaaaaaaaaaa' field a.
get parameter id 'bbbbbbbbbbb' field B.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
start-of-selection.
your logic
REPORT zszp_00005.
PARAMETERS a(5).
PARAMETERS b(5).
START-OF-SELECTION.
SET PARAMETER ID 'aaaaaaaaaaa' FIELD a.
SET PARAMETER ID 'bbbbbbbbbbb' FIELD b.
your logic
SUBMIT zszp_00007 VIA SELECTION-SCREEN.
i hope this approach will solve your problem.
thanks
Swanand -
Function Point Analysis for SAP BW Projects
Hello All,
Have been assigned a task to come up with Function Point
analysis for SAP BW projects.
Any help will be appreciated.
Thanks,
MainakHi Mainak,
Function Point Analysis is independent of technology, methodology or platform, so there is no function point analysis specific for sap bw, rather you should familiarize with the fundamentals of FPA.
And as you might know, FAP is used to determine whether a given a tool, an environment or a language is more productive when compared to others.
I can send you good links if you can give me your email-id.
Hope this helps...
Thanks,
Raj -
I have been using GRAB to capture screen displays. It has just stopped working since the last OSX Upgrade. Can anyone, please help restore functionality?
Thanks for that. I did as suggested but when I tried again, it still did not work. Another com.apple.Grab.plist appeared in the Library.
I now have the following files in Library
file://localhost/Users/peterpatel/Library/Preferences/com.apple.Grab.LSSharedFil eList.plist
file://localhost/Users/peterpatel/Library/Preferences/com.apple.Grab.LSSharedFil eList.plist.lockfile
file://localhost/Users/peterpatel/Library/Preferences/
file://localhost/Users/peterpatel/Library/Preferences/com.apple.Grab.plist.lockf ile
What do you suggest I do now? -
Question about function with in parameters
Hello,
I have a question about functions with in-parameters. In the HR schema, I need to get the minimum salary of the job_id that is mentioned as an in-parameter.
this is what I am thinking but I dont know if it's correct or not or what should I do next!
create or replace function get_minimum_salary (i_job_id in varchar2)
return number
as
begin
SELECT min_salary INTO min_sal
FROM jobs
where job_id = get_minimum_salary(xy);
RETURN i_job_id;
end get_minimum_salary;
thanks in advance
EDIT
Thanks for your help all.
Is it possible to add that if the i_job_id which is the in type parameter does not have a minimum salary then use the following function to register an error:
create or replace procedure insert_error (i_error_code in number,
i_error_message in varchar2)
as
begin
insert into error_table (error_user, error_date, error_code, error_message)
values (user,sysdate,i_error_code,i_error_message);
end insert_error;
This function is basically to say that an error has occured and to register that error, at the same time I need to print out the error using the dbms_out.put_line.
Any ideas of how to do that?
Thanks again
Edited by: Latvian83 on Jun 1, 2011 5:14 AMHI
I have made little bit changes in ur code. try this
create or replace function get_minimum_salary (i_job_id in varchar2)
return number
as
v_Min_sal jobs.salary%type=0;---- Variable declaration
begin
SELECT min_salary INTO v_ min_sal
FROM jobs
where job_id = i_job_id;
RETURN v_Min_sal;
end get_minimum_salary;
Regards
Srikkanth.M -
Please help me out with the function code of print option in module pool
please help me out with the function code of print option in module pool, along with CASE condition.
regards,
asifHi
you can use the Function module
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = 'LP01' "'Printer name
list_name = 'TEST'
list_text = 'SUBMIT ... TO SAP-SPOOL'
immediately = ' '
line_size = '2000'
no_dialog = 'X' "pass space to Pop screen for Print option
IMPORTING
out_parameters = wa_pri_params
valid = w_valid.
"next call below things
NEW-PAGE PRINT ON NO DIALOG PARAMETERS wa_pri_params.
"and try to Print the values inside the new-page
NEW-PAGE PRINT OFF.
Prabhudas -
I think I need help with driver (software) settings for D110a
I think I need help with driver (software) settings for D110a all-in-one
Product: D110a all-in-one
OS: Windows XP Professional
Error messages: None
Changes before problem appeared: None--new installation
The quality of photo images (mostly JPG files) in printouts is awful even though the files display beautifully on the PC screen. I am using
IrfanView software for displaying/printing. As far as I can tell, IrfanView is not the problem.
When I print the same images on a Deskjet 5150 attached to a different PC also running XP Pro and IrfanView, the quality of the printouts is at
least acceptable, Some would probably say good or very good.
It's dificult to explain in words the problem with the printouts. A picture of really pretty vegetables (squashes, tomatoes, watermelon, etc) comes
out much too red. Moreover, the red, which appears shaded on the screen, seems to be all one shade in the D110a printouts.
Something similar happens to a view of a huge tree in full leaf. On screen, there are subtle variations in the "greenness" of the leaves. In the
printout, all green is the same shade. In the same printout, the trunk of the tree is all a single shade of grey. It isn;t even obvious that the
trunk is a round, solid object.
I liken the effect to audio that disappears entirely when you lower the volume and gets clipped into square waves in even moderately loud passages.
I don't know whether the D110a driver software permits adjusting the parameters that appear to be set incorrectly, and if adjustments are possible,
how I would identify which parameters to adjust, how I would access them, or how I would adjust them. I'm hoping that someone can help. Thanks.
I forgot to mention that I have used the diagnostic application and it tells me that there are no problems.
e-mail me at [email protected]brazzmonkey wrote:
Hi everyone,
I noticed the following message when network starts on my gateway
Warning: This functionality is deprecated.
Please refer to /etc/rc.conf on how to define a single wired
connection, or use a utility such as netcfg.
Then I realized the way network settings should be written in rc.conf has changed. But I can't figure out how this should be done.
Currently, my set up is the following (old way):
INTERFACES=(eth0 eth1)
eth0="dhcp"
eth1="eth1 192.168.0.10 netmask 255.255.255.0 broadcast 192.168.0.255"
ROUTES=(!gateway)
eth0 is on DHCP because the IP is dynamically assigned my ISP.
eth1 has a fix IP because it's on the LAN side.
No problem to use DHCP on eth0 with the new settings.
But for eth1, I don't know what I am supposed to write for gateway.
Wiki isn't clear on that one either, and it looks like many articles still refer to the old way.
Any guidance appreciated, thanks.
brazzmonkey,
you can't define 2 interfaces the old way (even though I saw some tricky workaround somewhere in the forums).
Use, f.e., netcfg:
Comment your old lines.
In /etc/rc.conf insert:
NETWORKS=(Eth0-dhcp Eth1-static)
DAEMONS=(..... !network @net-profiles ....)
In /etc/network.d create 2 files:
First one is named Eth0-dhcp.
Contents:
CONNECTION="ethernet"
DESCRIPTION="Whatever text"
INTERFACE=eth0
HOSTNAME="your hostname"
IP="dhcp"
DHCP_TIMEOUT=15
Second one is named Eth1-static.
Contents:
CONNECTION='ethernet'
DESCRIPTION='whatver'
INTERFACE='eth1'
HOSTNAME='hname'
IP='static'
ADDR='192.168.0.10'
GATEWAY='192.168.0.1' # your gateway IP
DNS=('192.168.0.1') # your DNS server
The names Eth0-dhcp and Eth1-static are not magic. They just must be the same in rc.conf and in /etc/network.d.
Hope it helps.
mektub
PS: netcfg must be installed.
Last edited by Mektub (2011-07-20 14:07:05) -
Help with SMTP class function with authentication
My server is no longer supporting the php mail() functionality. I need to use SMTP class function with authentication in my php code and they suggested this to replace it: http://www.yrhostsupport.com/index.php?/Knowledgebase/Article/View/101/2/smtp-class-functi on-with-authentication-in-php-code
So I tried it, but can't get it to work. This is my test form:
<form method="post" action="forms/sendmail-test2.php" onsubmit="return checkEmail(this);">
<script type="text/javascript" language="JavaScript">
</script>
<fieldset><legend>Info</legend>
<label> Name </label>
<input type="text"
name="name" size="30" maxlength="40"/><br />
<label> <span class="redText">*</span> Email </label>
<input name="email" type="text" size="30" maxlength="40"/>
<br />
<label><span class="redText">*</span> Message </label>
<textarea cols="40" rows="5" name="message" type="text" /></textarea><br />
</fieldset>
<input type="reset" value="Reset" />
<input type=submit value="Submit Form" />
</fieldset>
</form>
This is sendmail-test2.php where the form goes. It won't send unless I comment out the first 10 lines.
<?php
include('Mail.php');
//$to = "[email protected]";
//$name = $_REQUEST['name'] ;
//$email = $_REQUEST['email'] ;
//$message = $_REQUEST['name'] ;
//$headers = "From: $email";
//$subject = " price quote";
//$fields = array();
//$fields{"name"} = "Name";
//$fields{"email"} = "Email";
//$fields{"message"} = "Message";
$recipients = '[email protected]'; //CHANGE
$headers['From'] = '[email protected]'; //CHANGE
$headers['To'] = '[email protected]'; //CHANGE
$headers['Subject'] = 'Test message';
$body = 'Test message';
// Define SMTP Parameters
$params['host'] = 'levy.dnsbox25.com';
$params['port'] = '25';
$params['auth'] = 'PLAIN';
$params['username'] = '[email protected]'; //CHANGE
$params['password'] = 'xxxxxx'; //CHANGE
/* The following option enables SMTP debugging and will print the SMTP
conversation to the page, it will only help with authentication issues. */
$params['debug'] = 'true';
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('smtp', $params);
// Print the parameters you are using to the page
foreach ($params as $p){
echo "$p<br />";
// Send the message
$mail_object->send($recipients, $headers, $body);
?>
It used to work fine when I used
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
But they said I can't use it any more. I'm good with HTML and CSS but I don't know much about php. Thanks for any help integrating a from into this new code!Thanks, bregent. I changed it to this and it sends, but nothing shows up in the body except "Test message". How would I "insert the form fields' 'email' and 'name' and 'message' in the body"?
<?php
include('Mail.php');
$to = "[email protected]";
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['name'] ;
//$headers = "From: $email";
$subject = " price quote";
$fields = array();
$fields{"name"} = "Name";
$fields{"email"} = "Email";
$fields{"message"} = "Message";
$recipients = '[email protected]'; //CHANGE
$headers['From'] = '[email protected]'; //CHANGE
$headers['To'] = '[email protected]'; //CHANGE
$headers['Subject'] = 'Test message';
$body = 'Test message';
$fields = array();
$fields{"name"} = "Name";
$fields{"email"} = "Email";
$fields{"message"} = "Message";
// Define SMTP Parameters
$params['host'] = 'levy.dnsbox25.com';
$params['port'] = '25';
$params['auth'] = 'PLAIN';
$params['username'] = '[email protected]'; //CHANGE
$params['password'] = xxx'; //CHANGE
/* The following option enables SMTP debugging and will print the SMTP
conversation to the page, it will only help with authentication issues. */
$params['debug'] = 'true';
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('smtp', $params);
// Print the parameters you are using to the page
foreach ($params as $p){
echo "$p<br />";
// Send the message
$mail_object->send($recipients, $headers, $body);
?> -
Help with Proper DNS Setup for Leopard Standard Server Setup
Hello All,
Problem Description-
I was reviewing some training today on DNS setup and checking for proper setup with the sudo changeip - checkhostname tool and I seem to have an incorrectly configured DNS setup. So I need some help on correcting it. When I go to the "Server Preferences" tool I cannot log in using apple.ourdomainname.com instead in order to use the tool I have to input localhost as the server name. Now I just thought that the system was broken or something and with the help of my training I now see it's a DNS problem. I thought I had everything proper since I followed the steps of creating proper DNS/RDNS entries with my ISP. Now I am stuck wondering what else isn't working properly due to the DNS issue. Thanks in advance.
Technical Info-
My ISP provides us with 5 static IP's and we have asked them to create entries and verified the setup of apple.ourdomainname.com = x.x.x.x which is one of our public IP's assigned currently assigned to the WAN port of our Apple Airport Extreme. We have also had them create a PTR record which also is present, verified and functional. Our MacMini running 10.5.5 is connected directly to one of the ethernet ports on our Apple Airport Extreme which is our NAT/Firewall for the LAN. So during the setup of the Standard Server install the OS configured the Airport with the required ports for chat/web/vpn. And mobile Mac's can VPN in and gain folder access and web works fine too. We don't use the e-mail portion so I can't say how that works. The server is using the DNS of 10.0.200.1 which is the IP of the Airport and the airport is programmed with the DNS of OpenDNS servers 208.67.222.222 and 208.67.220.220. The reason for this whole long shpeal is that I want to give as much technical background as possible for the best possible help.
Thanks
DMWhat happens when you use 'Localhost' instead of 'localhost' (i.e. capitalizing the 'L')?
-
File with variable structure how to define the FCC parameters for it?
Hi all,
I have a scenario which is File to IDOC
and file structure is in this way
Header:
HDR|ROSS-Daily-Inv|20111104
Data :
INV|01|059EMS|107128|20111104|USD|21703|IN|1| 0.00| 0.00|60-5B-30| 600.00|VIAL|0.00|0.00|EM||NETDUE|CLINIC|Y||490000
TOT|01|059EMS|107128||USD||||0|0
INV|01|EXB001|107130|20111104|USD|02420|IN|1| 823600.00| 823600.00|| 580.00|VIAL|0.00|0.00|||NET30|COMM|N||
TOT|01|EXB001|107130||USD||||823600|823600
Trailer:
TLR| 6| 1382679.00
can any help me defining the Datatype for this structure and FCC parameters
Thanks
SaiHi,
In Sender CC, use content conversion and especially these options:
¤ RecordSet Structure = Header , 1 , Data1 , * , Data2 , * , Footer , 1
¤ Key Field Name = MyKey
¤ Namea.keyFieldValue, to distinguish your different structures (records).
for instance, like that:
Header.keyFieldValue = HDR
Header.fieldName = MyKey , xxxxx, yyyy
Data1.keyFieldValue = INV
Data1.fieldName = MyKey , xxxxx, yyyy
Data2.keyFieldValue = TOT
Data2.fieldName = MyKey , xxxxx, yyyy
Footer.keyFieldValue = TLR
Footer.fieldName = MyKey , xxxxx, yyyy
Otherwise, in SDN with term "recordset" you will find some blogs...
Regards.
Mickael -
Call Plugin-Function with parameters via JavaScript
Hi!
I have following problem: I wrote a plugin for Illustrator CS2 in C++ and now I would like to call a function of the plugin from outside of illustrator (from a JavaScript).
This can be done with the Actionsuite. But how could I then give some parameters to my function?
For example:
In the plugin, I have a function "void myFun(char * test)" and I want to call this function in JavaScript with test="Hello World" for example.
The only possible way right now seems to write parameters into a file and open that file in the plugin to "receive" them.Hi,
Could you send your plugin coding.
Regards,
Maria
Maybe you are looking for
-
How do I include all photo folders in my screensaver?
Prior to upgrading to Mountain Lion, I was able to set multiple folders of photos as my screensaver. Since the upgrade, I am only able to select one folder at a time. How do I get ALL my photos to be used as my screensaver?
-
Bug Report Safari / Taskbar follows into Safari
Hi, I hope my description is correct, respectively understandable. When I start the Safari, the Taskbar above follows with kind of a wipe-effekt into the Safari and disapears then. This happens only when I start the Safari, not when I switch back to
-
HT1937 how do i authorize my computer to get my purchases
hi guys i am trying to put my purchased apps back on my iphone but it keeps telling me i need to authorize the computer through the apps store then store then authorize computer but cnat see where authorize computer is anyo help me please asap.
-
Send a meeting request to Outlook
I currently try to send a meeting request to Outlook and the recipient can open that request and save it in his/her calendar. Unfornately, I haven't succeed. If you have the code that can perform that exact function, I have 15 Duke Dollars for you. T
-
New dedicated computer for Premiere Elements 13 help
I'm in the market for a new laptop or desktop, dedicated to editing videos and photos using Premiere Elements 12, soon to upgrade to version 13. No plans to use Pro version since Elements meets my needs very well. I want to be able to use all tool