How to check with table for cursor..?
How to check with table for cursor..?
Here I have Table temp_final_plan
Here i want to update if already exit...below is the procedure....
CREATE OR REPLACE PROCEDURE spu_final_profit_plan
AS
-- Constant declarations
ln_errnum number := 0;
-- Variable declarations
ls_errmsg app_errors.err_msg%TYPE;
ls_appmsg app_errors.app_msg%TYPE;
ls_appid app_errors.app_id%TYPE;
-- Cursor declaration for final_update_el
CURSOR cur_final_update_el IS
select '910' ent,
'9127316' center,
post_acct,
sum(avg_mtd_01) sum_avg_mtd_01,
sum(avg_mtd_02) sum_avg_mtd_02,
sum(avg_ytd_01) sum_avg_ytd_01,
sum(avg_ytd_02) sum_avg_ytd_02
from mon_act_cypy
where rec_type = 'A'
and sum_flag = 'D'
and yr = '2008'
and substr(ctr_or_hier, 1, 2) = 'el'
and ent || sub_ent in
(select ent || sub_ent
from ent_ref
where roll_ent || roll_sub_ent = '999100')
group by post_acct
having sum(avg_mtd_01) <> 0
or sum(avg_mtd_02) <> 0
or sum(avg_ytd_01) <> 0
or sum(avg_ytd_02) <> 0;
-- Cursor declaration for final_update
CURSOR cur_final_update IS
select b.plan_ent b_plan_ent,
b.plan_ctr b_plan_ctr,
a.post_acct a_post_acct,
sum(a.avg_mtd_01) sum_avg_mtd_01,
sum(a.avg_mtd_02) sum_avg_mtd_02,
sum(a.avg_ytd_01) sum_ytd_mtd_01,
sum(a.avg_ytd_02) sum_ytd_mtd_02
from mon_act_cypy a,
plan_unit_tbl b
where a.ent || a.ctr_or_hier = b.ent || b.ctr_or_hier
and a.rec_type = 'A'
and a.sum_flag = 'D'
and a.yr = '2008'
and b.hier_tbl_num = '001'
and a.ent || a.sub_ent in
(select ent || sub_ent
from ent_ref
where roll_ent || roll_sub_ent = '999100')
group by b.plan_ent, b.plan_ctr, a.post_acct
having sum(a.avg_mtd_01) <> 0
or sum(a.avg_mtd_02) <> 0
or sum(a.avg_ytd_01) <> 0
or sum(a.avg_ytd_02) <> 0;
-- Begin the procedure body
BEGIN
-- Insert / Update final profit plan for final_update query using cursor
FOR rec_final_update_el IN cur_final_update_el
LOOP
EXIT WHEN rec_final_update_el%NOTFOUND;
IF rec_final_update_el. THEN
UPDATE temp_final_plan
SET sum_avg_mtd_01 = rec_final_update_el.sum_avg_mtd_01,
sum_avg_mtd_02 = rec_final_update_el.sum_avg_mtd_02,
sum_avg_ytd_01 = rec_final_update_el.sum_avg_ytd_01,
sum_avg_ytd_02 = rec_final_update_el.sum_avg_ytd_02,
WHERE ent = rec_final_update_el.ent
AND center = rec_final_update_el.center
AND post_acct = rec_final_update_el.post_acct;
ELSE
INSERT INTO temp_final_plan VALUES(rec_final_update_el.ent,
rec_final_update_el.center,
rec_final_update_el.post_acct,
rec_final_update_el.sum_avg_mtd_01,
rec_final_update_el.sum_avg_mtd_02,
rec_final_update_el.sum_avg_ytd_01,
rec_final_update_el.sum_avg_ytd_02);
END IF;
END LOOP;
-- Insert / Update final profit plan for final_update query using cursor
FOR rec_final_update IN cur_final_update
LOOP
EXIT WHEN rec_final_update%NOTFOUND;
IF rec_final_update. THEN
UPDATE temp_final_plan
SET sum_avg_mtd_01 = rec_final_update.sum_avg_mtd_01,
sum_avg_mtd_02 = rec_final_update.sum_avg_mtd_02,
sum_avg_ytd_01 = rec_final_update.sum_avg_ytd_01,
sum_avg_ytd_02 = rec_final_update.sum_avg_ytd_02,
WHERE ent = rec_final_update.b_plan_ent
AND center = rec_final_update.b_plan_ctr
AND post_acct = rec_final_update.a_post_acct;
ELSE
INSERT INTO temp_final_plan VALUES(rec_final_update.b_plan_ent,
rec_final_update.b_plan_ctr,
rec_final_update.a_post_acct,
rec_final_update.sum_avg_mtd_01,
rec_final_update.sum_avg_mtd_02,
rec_final_update.sum_avg_ytd_01,
rec_final_update.sum_avg_ytd_02);
END IF;
END LOOP;
-- EXCEPTION handling section
EXCEPTION
-- Fire OTHERS Exception case by default
WHEN OTHERS THEN
-- ROLL BACK Transaction, if any failure
ROLLBACK;
ln_errnum := SQLCODE;
ls_errmsg := SUBSTR(SQLERRM, 1, 100);
-- Log the ERRORS into APP_ERRORS table using SPU_LOG_ERRORS procedure
spu_log_errors(ln_errnum, ls_errmsg, ls_appid, ls_appmsg);
-- End of the stored procedure
END spu_final_profit_plan;
[\pre]
I'm not sure what you mean by, 'How to check with table for cursor..?' but I'll offer a comment on your Code Snippet. I think you want to know how to check if a record exists so you know if you need to perform an INSERT or an UPDATE.
Here is a snippet of your code. I'll put my comments in "Comment" style in your code.
-- Insert / Update final profit plan for final_update query using cursor
FOR rec_final_update_el IN cur_final_update_el
LOOP
/* There is no need to test for %NOTFOUND since you are using Cursor FOR Loop!
** This construct automatically exits when the last record is processed. */
EXIT WHEN rec_final_update_el%NOTFOUND;
/* Is this where you would like to know how to Check if the record already exist??
** I asked this because, 'rec_final_update_el.' is not valid syntax. Are you looking for
** an Cursor Attribute or Method you can check here?
** I would suggest a Primary Key or Unique Index on ENT, CENTER, and POST_ACCT
** on the TEMP_FINAL_PLAN table. Then simply perform an INSERT and code an
** Exception to UPDATE when you get a DUP_VAL_ON_INDEX exception. Otherwise,
** you will need to simply run an Implicit or Explicit Cursor to test if the row exists and
** use this return value to determine if you should INSERT or UPDATE. */
IF rec_final_update_el. THEN
UPDATE temp_final_plan
SET sum_avg_mtd_01 = rec_final_update_el.sum_avg_mtd_01,
sum_avg_mtd_02 = rec_final_update_el.sum_avg_mtd_02,
sum_avg_ytd_01 = rec_final_update_el.sum_avg_ytd_01,
sum_avg_ytd_02 = rec_final_update_el.sum_avg_ytd_02,
WHERE ent = rec_final_update_el.ent
AND center = rec_final_update_el.center
AND post_acct = rec_final_update_el.post_acct;
ELSE
INSERT INTO temp_final_plan VALUES(rec_final_update_el.ent,
rec_final_update_el.center,
rec_final_update_el.post_acct,
rec_final_update_el.sum_avg_mtd_01,
rec_final_update_el.sum_avg_mtd_02,
rec_final_update_el.sum_avg_ytd_01,
rec_final_update_el.sum_avg_ytd_02);
END IF;
END LOOP;I hope I've answered your question, but if I haven't please provide more details so we can better understand your request.
Craig...
Similar Messages
-
Dear experts!
Thank you for your attention!
I have studied the SAP SD for half a year, though I still don't know how to check certain table like:
KNVS---customer master shipping data
KNBK---customer master (bank detail)
ADR---address table
ect.
could somebody help me?
Best regard!
TangdarkHi Tang,
SAP SD having lot of tables but i am telling main tables.
VBAK - Sales Document Headerdetailes
VBAP - Sales Document Itemdetailes
VBEK - Sales Document Scheduline data
LIKP - Delivery Header Detailes
LIPS - Deliver Item Detailes
VBRK - Billing Header Data.
VBRP - Billing Item Data.
VBFA - Sales Document Flow
VBUK - Sales document header status data
VBUP - Sales document item status data.......ctc.
Regards
Rajendra -
How to check PSA Table Structure ?
Hi Friends,
Can you pls any one tell me how to find out PSA Table and how to check PSA Table Structure? .Thanks in advance.
Regards,
CSHi Sri,
Goto RSA1 trans> select your DS> right clcik> Manage> you will get a Pop-up with all the PSA requests--> on the top Left you can see the PSA name(Technical name) in the form PSA/BIC/BXXXXXX
PSA & DS structue will be same. Goto RSO2 transaction> Enter your DS name> double click on the extract structure. It will take you to the Extract structure.
(Or) if you know the extract structure name, directly goto Se11 trans & enter the technical name of Extract structure & Display.
Take the screenshot & send it to your TL.
Regards,
Pavan -
How to check small table scan full table scan if we will use index in where clause.
How to check small table scan full table scan if i will use index column in where clause.
Is there example link there i can test small table scan full table if index is used in where clause.Use explain plan on your statement or set autotrace traceonly in your SQL*Plus session followed by the SQL you are testing.
For example
SQL> set autotrace traceonly
SQL> select *
2 from XXX
3 where id='fga';
no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=13 Card=1 Bytes=16
5)
1 0 PARTITION RANGE (ALL) (Cost=13 Card=1 Bytes=165)
2 1 TABLE ACCESS (FULL) OF 'XXX' (TABLE) (Cost=13 Card
=1 Bytes=165)
Statistics
1 recursive calls
0 db block gets
1561 consistent gets
540 physical reads
0 redo size
1864 bytes sent via SQL*Net to client
333 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processed -
How to know the tables for a datasource like 2lis_17_order
Hi,
How to know the tables for a data source like 2lis_17_order, i have checked in Extract structure of that data source, only fields are visible but how will i know that these fields are getting extracted from so and so tables?
pls respond. thanks in advanceHi,
Go to RSO2 at source system, Enter data source and click on display.
if its table based then you can see table name there it self.
if its view based then notedown the view name and go to SE11, provide view and click on display. see joined table names there.
Thanks -
How's this partition table for my server?
How's this partition table for my server? Web/DNS/DHCP/Mail Server.
hdd1: ~8gb total
/boot - 100mb
swap - 1gb
/ - rest of drive
hdd2: ~155gb total
/var - whole drive
This is a Compaq ProLiant 5500 server with 10 drives. Will most things be installed inside /var or what?Zetsumei wrote:Web/DNS/DHCP/Mail Server.
Web = /srv
DNS = /var
DHCP = /var
Mail = Depends which package you use. I use postfix and told it to use /srv
I would half your swap, reduce /var and put the extra space into /srv
Also create a separate /tmp and /home to prevent accidental or deliberate DoS attacks by filling your / partition
Here's what I use on my Web / DNS / FTP server:
Filesystem Size Used Avail Use% Mounted on
/dev/xvda 493M 176M 317M 36% /
/dev/xvdc 31M 674K 29M 3% /boot
/dev/lvmData-home 62M 26M 34M 44% /home
/dev/lvmData-usr 2.0G 848M 1.1G 45% /usr
/dev/lvmData-tmp 496M 20M 451M 5% /tmp
/dev/lvmData-srv 1.5G 769M 667M 54% /srv
/dev/lvmData-var 496M 231M 241M 49% /var
/dev/lvmData-pacman 384M 303M 82M 79% /var/cache/pacman
/dev/lvmData-backup 5.5G 4.6G 565M 90% /mnt/backup -
How to desighn a table for below logic
Hi all,
Could any body help me , how to design a table for below requirements
Ticketing Status
Departure Date/Time
Domestic Point of Sale
International Point of Sale
Yes
Outside of 24 hours
Immediate
Immediate
Yes
Inside of 24 hours
Immediate
Immediate
No
Outside of 24 hours
24 hours after Project review or 20 hours prior to departure, whichever is earlier
72 hours after Projectreview or 20 hours prior to departure, whichever is earlier
No
Inside of 24 hours
4 hours after Projectreview or 4 hours before departure, whichever is earlier; Immediate if within 4 hours
4 hours after Projectreview or 4 hours before departure, whichever is earlier; Immediate if within 4 hoursCREATE TABLE [dbo].[POS_Table](
[POSID] [int] IDENTITY(1,1) NOT NULL,
[Ticketing Status] [varchar](3) NULL,
[Departure Type] [varchar](7) NULL,
[Departure DateTime Hr] [int] NULL,
[POSType] [varchar](15) NULL,
[POSAfterProject Review Hr] [int] NULL,
[PriorToDeparture Hr] [int] NULL,
[Immediate Hr] [int] NULL,
CONSTRAINT [PK_POS_Table] PRIMARY KEY CLUSTERED
[POSID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
The rows will look like as below,
POSID
Ticketing Status
Departure Type
Departure DateTime Hr
POSType
POSAfterProject Review Hr
PriorToDeparture Hr
Immediate Hr
1
Yes
Outside
24
Domestic
0
0
0
2
Yes
Inside
24
Domestic
0
0
0
3
Yes
Outside
24
International
0
0
0
4
Yes
Inside
24
International
0
0
0
5
No
Outside
24
Domestic
24
20
0
6
No
Outside
24
International
72
20
0
7
No
Inside
24
Domestic
4
4
4
8
No
Inside
24
International
4
4
4
Regards, RSingh -
How to check one table exist or not in SAP
Hi, Gurus:
How to check one table exist or not in the SAP.
Thanks,Hi,
Query the table DD02L..
Select single * from DD02L where tabname = 'Your table name'
AND TABCLASS = 'TRANSP'. " For transparent tables.
Thanks
Naren -
How to create internal table for a structure in BSP
hi ,
I have created a Structure in BSP.I want to create an internal table for that Structure. But in my coding ie.
<% data: begin of itab_1 .
include type zuvendstr.
data:end of itab_1.
data wa_str like line of itab_1.
loop at itab_1 into wa_str. %>
<tr>
<td><%=wa_str-name%> </td>
<%endloop.%>
In this zuvendstr is Structure ,wa_str is workarea and itab_1 is an Internal table.But it is showinng an error that itab_1 is unknown.But we cannot define internal tables for an Structure in Page Attributes.So,please resolve how to create internal table for Structure in BSPSHi,
You can define itab_1 like this (assuming zuvendstr is a structure type):
DATA: itab_1 TYPE TABLE OF zuvendstr.
Regards,
Tanguy -
How to check the tables we have created in JDBC??
I have created a table called COFFEE2 in a datasource called temp which is in SQL server...How to check the table values??
i went into administrative tools and odbc cource then i could see the data source i have created but how to see the table??
Can anyone help??
thanxHmm.. not sure that I understand the problem.
Call getConnection on the DataSource, and then execute the select query on the connection.
Kaj -
How to check call duration for total dialled calls (after resting) on a particular day in iphone 4?
Is there a solution like iphone 5, i.e.Settings > Cellular.if the device is unlocked cellular is called mobile
-
How to find an table for storing the employee salary
hi,
how to find an table for storing employee salary .. In which table those details are stored .. Please reply me.
regards,
kumarHi,
You can see the basic salary details from table -pa0008.If you can see the payroll data,then its not stored in transparent table.its in cluster.For viewing that,you can see through transaction code - pc_payresult.
Regards,
Manoj. -
How to find Related Tables for the Tcode given.
How to find Related Tables for the Tcode given. (master data)
Thanks in advance.Hi Sridhar,
Welcome to SDN.
The tables for a given transaction can be seen in the transaction SE80.
First goto SE93.
Give ur Tcode and find the program name.
Now goto SE80. select program in the first dropdown and give the program name in the second box. U can find the list of tables used.
One more way is : use ST05.
and One more is using FM 'get_tables'
Thanks,
Shailaja
Edited by: Shailaja on Jul 11, 2008 12:33 PM -
How to work with otool for pre check app befor submit to app
any body work with otool for pre check app befor submit to app.
Searching in Google, I found these explanations :
Timmy OTool is a graphical front end for the command line tool "OTool". It can be used to examine frameworks, applications, static libraries, plugins, and more.
Like the two others helpers, I can't see any link with this forum theme.
May you take care of forums deicated themes before entering one of them ?
Yvan KOENIG (VALLAURIS, France) jeudi 16 juin 2011 16:27:11
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.7
Please : Search for questions similar to your own before submitting them to the community
To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !
Oops, posted too late -
How to check in Cube for Non cumulative calculation?
Hi All/surendra (Inventory Specialist)
I am now supporting the Inventory cube. I never worked in inventory. I have read all the documents like
a. How to Inventory
b. Surendra's Inventory with 3parts
c. Non cumulative..
But none of the above docs gave me solution how to go ahead to find or compare with R3 for the first time consultants who is handling Inventory..
Can you pls help me resolve the following issues?
1. May I know how actually the NON CUMULATIVE calculation is done for filelds 0VALSTCKVAL and 0VALSTCKQTY and also other KF's like ISSUE and RECEIPT qty, blocked qty, scrap, stck transit etc as I dont see any mapping done in transformation, if it is not done for Inventory, how it is fetched.??
2.Also I wanted to know what are the fields used cumulated for the above fields as I dont see any transformation mapping done for Key Figure and understood all Inventory docs that the KF are not visible as they are NON CUMULATIVE KF's.
3. How to compare the Inventory stock with R3 Material Stocks as when I compare with transaction MC.9, I see the values are totally different?? how and which transactions or tables supposed to be compared? Also we are not 2lis_03_BX in our Inventory. so I am not sure how they loaded the Inventory. Looks I need to redesign, can you tell steps to check and apply if I have initialize to make sure that my data will come correctly??
Thanks a lot for all you help and efforts in advance.The source field for quantities is the field CPQUABU, and for values it is the field CPPVLC.
Explanation for the routine :-
IF ( COMM_STRUCTURE-processkey EQ '000' "Other Receipts
OR COMM_STRUCTURE-processkey EQ '001' "Goods Receipt / Vendor
OR COMM_STRUCTURE-processkey EQ '004' "Material Transfer / Receipt
OR COMM_STRUCTURE-processkey EQ '005' "Stock Adjustment InvD +
OR COMM_STRUCTURE-processkey EQ '006' "Stock Adjustment Other +
OR COMM_STRUCTURE-processkey EQ '010' ) "Receipt from Stock Transfer
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
only stock in transit is considered
AND COMM_STRUCTURE-stocktype CA 'FH'
only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu 0. *
The above part is used for the KF : 0ISSTRANSST - Issue Quantity: Stock in Transit
IF ( COMM_STRUCTURE-processkey EQ '100' "Other Issues
OR COMM_STRUCTURE-processkey EQ '101' "Returns / Vendor
OR COMM_STRUCTURE-processkey EQ '104' "Material Transfer
OR COMM_STRUCTURE-processkey EQ '105' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '106' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '110' ) "Issues from Stock Transfers
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cppvlc 0
see OSS note 630254
AND ( COMM_STRUCTURE-stockcat IS INITIAL OR
( COMM_STRUCTURE-stockcat CA 'EQ' AND
COMM_STRUCTURE-indspecstk CA 'AM' ) ).
result value of the routine
RESULT = COMM_STRUCTURE-cppvlc. *
This part is used for : 0ISSTOTSTCK - Issue Quantity Total Stock
Hope this hepls,
Reg,
Rahul
Maybe you are looking for
-
Image is NULL exception, problems displaying a png file
Hi people, I want to display a simple image using j2me on my siemens sl45i emu. I'm using the following code to load my png 8x8(created with photoshop, 2bpp) image: public void load() try testImage = Image.createImage("res/enemy1.png"); catch (Except
-
Getting INTERNAL_ERROR while updating tasks in OIM
Hi, I have written a custom connector and wrote tasks to update the attributes in the target system. After the approval workflow the user got provisioned to the target system and i am able to update all the attributes like firstname,lastname etc. I h
-
Manual Price Conditions doesn't determine the new exchange rate in billing
Hallo People We are using TAXBRJ in our company and sometimes is used a manual condition to determinate a price. The process is a exportation and is used exchange rate USD to BRL . When we create a billing (VF01) with copy of delivery the exchange ra
-
Problem in configuring my driver for JMS Queues
Hello, I'm working in connecting ODI to Sonic ESB. I have added all the drivers needed to ODI/Drivers and I continue to have an error. After searching in our ESB Doc i finally found why. I have to change a property of my Driver. I have tryied to chan
-
Hi all! I have searched google and this site looking for the solution to this annoying problem to no avail, so I thought perhaps somebody could assist? I cannot drag and drop an image from one application to another. Copy and Paste works fine. Draggi