Generating sequence for group by condition
I have a table with the Name Table_Depts.
SQL> DESC Table_depts
Name varchar2(10)
Deptno number(5)
Loc varchar2(10)
SQL> Select * from Table_depts;
NAME ---- Sale
DEPTNO ---- null
LOC --- boston
NAME ---- Sale
DEPTNO ---- null
LOC --- boston
NAME ---- Purchase
DEPTNO ---- null
LOC --- boston
NAME ---- Admin
DEPTNO ---- null
LOC --- NewJS
NAME ---- Admin
DEPTNO ---- null
LOC --- boston
NAME ---- Admin
DEPTNO ---- null
LOC --- Mums
Note that Deptno is null. I want to update deptno column.
NAME ---- Sale
DEPTNO ---- 1
LOC --- boston
NAME ---- Sale
DEPTNO ---- 2
LOC --- boston
NAME ---- Purchase
DEPTNO ---- 1
LOC --- boston
NAME ---- Admin
DEPTNO ---- 1
LOC --- NewJS
NAME ---- Admin
DEPTNO ---- 2
LOC --- boston
NAME ---- Admin
DEPTNO ---- 3
LOC --- Mums
That means For sale we have (deptno 1 and 2) and
for Purchase we have (deptno 1)
and for Admin we have (deptno 1,2,3)
This output this based on group by of names and
the deptno is sequencely updates... but it again starts
when it gets new name that is (Sale have 1,2,3) and
(purchase have 1) and so on...
Thanks and regards
Sarfaraz Enayat
what for is MERGE here?
simple update is enough:Here is the reason for MERGE. Please note the numbers printed bold:
merge into x
using (select id
, deptno
, row_number() over (partition by name order by loc) rn
from x
) r
on (r.id = x.id)
when matched
then
update set deptno = rn
when not matched then
insert values (null,null,null,null)
call count cpu elapsed disk query current rows
Parse 1 0.00 0.01 0 0 0 0
Execute 1 0.01 0.00 0 6 7 6
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.01 0.02 0 6 7 6
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 9833
Rows Row Source Operation
2 MERGE
6 VIEW
6 HASH JOIN OUTER
6 VIEW
6 WINDOW SORT
6 TABLE ACCESS FULL X
6 TABLE ACCESS FULL X
update x
set deptno =
( select rn
from ( select t.*
, row_number() over (partition by name order by id) rn
from x t
) tt
where tt.id = x.id
call count cpu elapsed disk query current rows
Parse 1 0.01 0.00 0 0 0 0
Execute 1 0.00 0.00 0 21 14 6
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.01 0.00 0 21 14 6
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 9833
Rows Row Source Operation
0 UPDATE
6 TABLE ACCESS FULL OBJ#(2716057)
6 VIEW
36 WINDOW SORT
36 TABLE ACCESS FULL OBJ#(2716057)
********************************************************************************You can imagine what the numbers are for larger tables ...
Regards,
Rob.
Similar Messages
-
How to set required for group of condition type in the same condition class
Hello,
we have a group of condition type with the same condition class B, the last one have been set, and all of others will be inactive.
but we don't set any required for all the condition types in pricing control, so if user don't set any of them, the sales order or billing is still saved. that is a risk.How can i fix it? Thanks.
SophieHello,
incompletion log is not available in invoices.
You have different options:
- activate a validation in FI when the Billing document is released into accounting, so that te release into accounting is not allowed if the invoice amount is zero;
- define a subtotal in the pricing procedure as sum of the pricing conditions of your group, then develop a custom routine to be assigned in the formula "CalType" (field T683S-KOFRM) where an error should be raised if the amount of the subtotal is zero (use as an example formula 48);
Best regards,
Andrea -
Access Sequence For Import PO Conditions
Hi,
As in case of import PO we have to add Excise condition seperately with customr vendor ID as per our regular process while maaking IMport PO we are adding 3 common condition JCV1, JECV, J1CV and after selecting those condition we are entring the tax % and then custom vendor ID for those three condition i want to make condition record lik e when user create a import PO for import PO our document type is IM and if compnay code is MS10 when user select condition JCV1 automatically from the condition record system should pick the tax % and the vednor . so how to do it,
as first w= i have to create the condition table then that table have to assign to a assecc sequext and then that assescc sequence have to be assign to condition type so in condition table which filed to be select , I am not getting filed for PO doc, type and condition type from inmaintian condition table fileds .
regards,
zafarsorry i thought u talking about document number
u will have to do development for that
eithere u do
The following development steps have to be realized before starting with the field catalog extension:
??? Create data elements
??? Create Append Structure ZAKOMPAZ
??? Add Append Structure to KOMP and KOMG
The fields have to exist in table KOMG, KOMK, or KOMP.
or
To use your own fields for the price determination process, you must extend the communication structure table (KOMK, KOMP or KOMG where the KOMG Table represents the sum of KOMK and KOMP and contains all the fields that can be used in price determination). New fields entered in KOMK and/or KOMP are adopted in the structure KOMG automatically. There have been two enhancements that you should look at when you would like to append KOMK or KOMP as detailed hereunder -
1) In respect of KOMK - Use Function Module EXIT_SAPLMEKO_001 (User Exit LMEKO001) which includes ZXM06U14.
2) In respect of KOMP - Use Function Module EXIT_SAPLMEKO_002 (User Exit LMEKO002) which includes ZXM06U15.
hope this helps -
How to create the Access sequence for the Vendor+material+plant combination
Hi all
Please let me know How to create the Access sequence for the Vendormaterialplant combination..
Whats the use? What its effect in purhcase and taxe..
brief me pleaseHi,
you are asked to maintain the access sequence for the tax condition for which you are putting 7.5%.
goto OBQ1 or img..financial accounting new...global settings.... taxes on sales and purchases ......basic settings.....
find the tax condition type. see in it which access sequence is attached.
if there is none then use JTAX used for taxes in India.
or you can create the similar one for your.
to create the same goto OBQ2.
new entry or copy JTAX.
and assign the access sequence to condition type.
this will resolve your problem if you just need to assign the access sequence.
regards,
Adwait Bachuwar -
Why we cant have access sequence for header condition ?
hi ,
i have one query in pricing.
Can we assign access sequence for header condition ? if yes how ?
if not why ? please explainHi there,
It is always possible to have work around to solve issue without refer to OSS to change any programming coding.
We want to have a freight charge appear on each sales order automatically according to some condition. Most of the time, this freight charge is a flat rate (if it is depend on qty or value, then we're so easy to set it in item level).
In order to do so, we'll have one assumption. The item line number of sales order is auto running number, like 10, 20 and etc created by system and not manually input.
Then we create a pricing condition type like other discount or charge in ITEM LEVEL with your selected condition like customer, sales office, country and etc. However, remember to add the sales item line as part of the condition of this pricing condition.
Update the pricing procedure and create price condition record with say "10" for the sales item line. Since you'll have line number 10 for all sales order as first line (no mater it is a free of charge item or not). This new condition will generate a "freight cost" in the pricing procedure. And it is only apply to first line, therefore, we only get once of this charge for one order.
Hope this is your case and it works with ours.
Michael -
Urgent please .. condition found without access sequence for payment terms
Dear All,
I am seeing the pricing analysis. there is a condition type for which a value is found and it gave me certain payment terms. but when I tried to see the condition record, I am unable to find it.
Message says ''The cash discount condition amount is not determined using condition technology, but directly from the terms of payment table"
Please help in understading the meaning of these messge.
When I looked at condition type, access sequence in not assigned.
Thank You.
Regards
venkat
Edited by: venkat Kumbham on Apr 28, 2008 3:09 PMHi Venkat,
We do not maintain an access sequence for cash discount. Its determined from the terms of payment defined by finance ( check Spro - Financial Accounting>Accounts Receivable and Accounts Payable>Business Transactions> Incoming invoice/Crdit Memos>Maintain Terms of Payment )
Eg: 14 days 2%, 30 net
You can select the relevent Terms of payment in the customer master.
You will see the cash discount when you do the billing.
Hope its clear...
Rgds,
sapdt -
How to return the newly generated sequence id for an INSERT statement
A record is to be inserted into a table with a sequence for the primary key. The newly inserted sequence value is to returned on successful insertion. Is it possible to do all this in a single statement (say executeUpdate or any other) using java.sql.* ?
E.g.: - A student record is to be inserted into the STUDENT table. There is a sequence (by name Student_ID_SEQ) on the primary key Student_ID. Student_ID_SEQ.nextval will generate the new sequence id which will be provided as input to the SQL statement (say statement.executeUpdate) along with other student attribute values. On insertion the created sequence id should be returned. And all this should happen in a single statement (single call to database). Stored Procedures can accomplish this. But is this feasible without the use of Stored Procedures?
Thanks.a better aproach is to generate the auto key on the
database side, not on the application side.That's his problem - since the database is supplying the key for the new record his application which executed the SQL has no way to identify the record that was just added. I just create the key on the app server and accept the likelihood of overlap (which is extremely small).
Here is a more technical explanation:
Table Person
ID,
Name,
Phone Number,
Age
}The field ID is an autonumber, and all other fields are not unique.
Now, when this code executes:
PreparedStatement pst = conn.prepareStatement("Insert Into Person (Name, Phone Number, Age) Values ?, ?, ?");
pst.setString(1, "John");
pst.setString(2, "405-444-5555");
pst.setInt(3, 44);
pst.executeUpdate();How can the app determine the ID of the person just added since no query is possible which is guaranteed to select just the record that was inserted?
Since I am generally against Stored Procedures I would develop a way to insure that your keys were unique and generate them inside the app server. -
Sequence number for group of values in column
I need to create a sequnece number in a column starting from 5 and incremented by 5, based on values presenet in first column. If the value in first column changes then the sequence should start again with 5 and increment by 5.
for example: I want to generate the following output
Cat_code Seq_No
1001 5
1001 10
1001 15
1001 20
2001 5
2001 10
2001 15
3001 5
3001 10
4001 5
4001 10
4001 15
4001 20
5001 5
6001 5
7001 5
7001 10
7001 15
7001 20
7001 25
So if the cat_code changes, the sequence number should again start from 5 and should be generate sequence number until the cat_code changes again.
any help apreciated.
Thanks
RahulHi, Rahul,
You can use the analytic ROW_NUMEBR function to generate the numbers, like this:
SELECT cat_code
, 5 * ROW_NUMBER () OVER ( PARTITION BY cat_code
ORDER BY NULL
) AS seq_no
FROM table_x
ORDER BY cat_code
, seq_no
;You must use an analytic ORDER BY clause when you call ROW_NUMBER. If you don't really care about the order, then you can ORDER BY a constant, but you still need the analytic ORDER BY clause. -
How to generate the batch number for group of records
Hi All,
requirement: i have created one sequence to generate the batch numbers.i have to get the nextval of the sequence for batch number (this column is not part of the table. its dynamic column/alias column) only for every 50000 records of a table.
detail description:
for example, if i have 10 records in a table. And, if i want to generate the batch number for every 2 records, then the output should look like belo.
batch-number qty
1 10
1 20
2 30
2 40
3 50
3 60
4 70
4 80
5 90
5 100
Please help me on this. Please let me know if you need more info.one more update on the above request. this has to be done using SQL query only.
-
How to generate Sequence Diagrams for existing code
Hi,
I have a web application written in Java/Jsp's. I am looking to generate sequence diagrams automatically for the existing source code using this tool. I am not sure if this is possible using this tool. Can some one please explain me if that is possible using this IDE tool? If so can you please let me know how this can be done?
Any response is greatly appreciated.
Thanks in advance.
VijayHi,
Yes, you can reverse engineer operations and create sequence diagrams using Java Studio Enterprise.
Just right-click on the operation in the UML model that has the source file associated with it, and select "Create Diagram from Selected elements" or "Reverse Engineer Operation".
Thanks! -
Scale type D for group conditions
Hi all,
I am creating a new group condition and am trying to make it scale type D - graduated-to-interval scale. However because this is a group condition, SAP is giving me an error (Scale type 'D' cannot be used for group condition 'X').
What is the best solution to this?
I would like to give discounts based on:
Sales quantity:
1-100 = 15% off
101-200 = 25%
201-300 = 35%
301-400 = 45%Hello
This is b'coz your condition type with active Group condition Indicator. That means, here the system calculates the basis for the scale value from more than one item in the document.
So, the scale D maintain in Scale basis for those condition type, does not go with it and throws an Error.
Thus, if you want to scale functionality for condition type with group condition indicators use GrpCond.routine to maintain routine.
Routine number for creating group key identifies a routine that calculates the basis for the scale value when a group condition occurs in pricing.
For instance.
Check routine 3-Mat.Pricing Group. This is an example of a structure of group key formula. A structure of group key formula can be used to influence the basis the system uses when reading the scale of a group condition. The formula is assigned to a group condition type in customizing.
Formula '3' adds up the quantities / values of all of the line items in the sales document that have the same material pricing group (field KONDM) as the current sales document line item.
A company defines a particular discount (condition type Z001) with scales based on weight. When a sales order line item is priced that is eligible for the Z001 discount, the user would like the system to read the scale with not just the weight of the current line item, but the combined weight of all items in the sales document that have the same material pricing group as the current line item. To accomplish this, the user defines condition type Z001 as a group condition and assigns structure of group key formula '3' to it in customizing.
I hope this assist you.
Thanks & Regards
JP -
Which Access sequence will use for sales tax condition type for TAXINN
hi.,
which Access sequence will use for sales tax condition type for TAXINN procedure.pls give one example (Access sequence) and give fields.
Because i couldnot create the condition record,the system not accepted for tax indicator.
Regards.,
lakshmananWe also got the same problem with our client and escalated it to SAP.
they advised to use the access sequence <b>JIND</b> which consists of condition tables in the order given below
<b><u><i>Step Condn Table</i></u>
10 354
20 355
30 40</b>
Attach this to your condition types.
Rewards if it helps.
Regards,
Anbu -
How to Force JHS do not generate navigation cases for Groups?
Hello
I have already seen "Overwrite faces-config and navigation rules " property for Group in JhsApp deff .But It does not work .How Force JHS do not generate navigation cases for Groups? and another question is that how can I customize navigation case generation in JheadStart?
ThanksHi,
You are right: the navigation rules in the main faces-config file are overwritten, even if you uncheck these flags. Here is the solution:
If you want to preserve some of the navigation rules in the main faces config: alter the velocity template for faces-config. You can only switch off the entire generation of faces-config.xml; not individual parts.
If you want to add a special navigation rule: add it to the group faces config file.
If you want to preserve post-generation changes to the group faces config file: uncheck 'generate controller group?' or put it in the templates for that group.
Note: the flag 'Overwrite Faces-Config beans and Navigation Rules?' has become obsolete, you should only use 'Generate Controller Group?'.
Regards,
Evert-Jan de Bruin
JHeadstart Team -
Help needed to generate new target group for contacts from BP Target Group
In CRM 5.0, we have a functionality in which say we have created a target group (T1) for 10 BPu2019s (organization) and each of these BPu2019s have one or more contact persons associated to them. Now if I want to create a target group for all these contact persons associated to the 10 BPu2019s, in CRM 5.0 I have the option to right click on the target group (T1) and then I get an option u201C generate new target group from contactsu201D. By doing so another target group for all the contacts associated to those BPu2019s will be generated. I am not able to find out the similar option in CRM 2007 (web UI) where in I can create target group for contacts associated to BPu2019s (organization). There should be some work around for this requirement.
Please let me know how to achieve this requirement.
Thanks,
udayaHi udaya,
we're also using that functionality in CRM 5.0. I think it would be worth a combined OSS message to get this functionality back in standard if it isn't there.
Best regards
Gregor -
How to generate a number sequence for a column of a Z*table?
Hi ,
How to generate a number sequence for a column of a Z*table?
plz guide me.
thanks
Albert1) Use SNRO for defining a number range.
2) Use FM NUMBER_GET_NEXT for getting the next number with object, sub object etc..
See one example below.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = c_01
object = c_z_prd_code
* QUANTITY = '1'
subobject = p_vkorg
* TOYEAR = '0000'
* IGNORE_BUFFER = ' '
IMPORTING
number = in_prd_code
* QUANTITY =
* RETURNCODE =
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8
3) You may write these code in main program of the table maintinence
rgds,
TM.
Maybe you are looking for
-
Drop Down List in ALV with Event handler
Hi All , I have created an ALV grid with a dropdown as one of the columns. This all works fine, except that I want to be able to react to a change in the value of each line's dropdown the next column values should change according to the user selecti
-
Mac mini won't boot - keyboard shortcuts don't work
Older Intel Mac Mini that I use as an entertainment / movie center. Leopard. I did a software update recently, but somehow botched it and interrupted the process. Ever since then, it won't start up correctly. It chimes, disk powers up, but then it ge
-
XSQL with jdk1.2.2 - javai.dll error
I successfully used the xsqlCommandLine utility with jdk1.1.7. When I try with jdk1.2.2, I get an error that javai.dll is not in the path. If I put javai.dll from the 1.1.7/jre/bin in my path, the xsqlCommandLine process runs without end, as if windo
-
SAP certification and Job opportunity.
Hi , Could any one suggest me any certification that can be completed in less than 6 months and can provide opportunity to get job? Actually I completed my B.Com and then Master of Computer Applications (MCA) in 2004. I got offer from Satyam in camp
-
30 second counter for detecting peaks
Hello, I want to count number of peaks detected in a 30sec interval from a pulse signal acquired using DAQ.I made this programme and in this each second is almost taking 12 sec's more as compared to the real clock second.As a total it taking more tha