I want to allocate balance qty in sql.....

Please help me…
I want to allocate balance qty in sql.....
I have data like below table and expected answer in column EDIT_UP_TO_EXEPECTED_ANS.
I want to edit data with validation of next process executed qty.
for example in row 3rd and 4th PROCESS_EXECUTE_QTY is ORDER_VRNO wise is 100 i.e.
100+0=100 and i want to allocated this qty in 1st and 2nd row i.e. 75,25 i.e. 75+25=100
because first process CUTTING of jobcard_no J113Y-1004 is 75 and next process done is 100 order_vrno wise
so i want to allocated 100 in 75,100 i.e. 75,25 total should be next process execute qty i.e. 100
SLNO
JOBCARD_NO
ORDER_VRNO
PROCESS_CODE
PROCESS_EXECUTE_QTY
EDIT_UP_TO_EXPECTED_ANS
1
J113Y-1004
P113Y-56
CUTTING
75
75
2
J113Y-1005
P113Y-56
CUTTING
100
25
1
J113Y-1004
P113Y-56
DRILLING
100
85
2
J113Y-1005
P113Y-56
DRILLING
0
0
1
J113Y-1004
P113Y-56
PUNCHING
15
15
2
J113Y-1005
P113Y-56
PUNCHING
0
0
1
J113Y-1004
P113Y-56
FORMING
0
0
2
J113Y-1005
P113Y-56
FORMING
0
0
Table script ....
with t as
(select 1 SLNO,'J113Y-1004' jobcard_no,'P113Y-56' ORDER_VRNO,'CUTTING' PROCESS_CODE,75 PROCESS_EXECUTE_QTY, 75 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
UNION ALL
select 2 SLNO,'J113Y-1005' jobcard_no,'P113Y-56' ORDER_VRNO,'CUTTING' PROCESS_CODE,100 PROCESS_EXECUTE_QTY, 25 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
UNION ALL
select 1 SLNO,'J113Y-1004' jobcard_no,'P113Y-56' ORDER_VRNO,'DRILLING' PROCESS_CODE,100 PROCESS_EXECUTE_QTY,85 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
UNION ALL
  select 2 SLNO,'J113Y-1005' jobcard_no,'P113Y-56' ORDER_VRNO,'DRILLING' PROCESS_CODE,0 PROCESS_EXECUTE_QTY,0  EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
  UNION ALL
  select 1 SLNO,'J113Y-1004' jobcard_no,'P113Y-56' ORDER_VRNO,'PUNCHING' PROCESS_CODE,15 PROCESS_EXECUTE_QTY, 15 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
  UNION ALL
  select 2 SLNO,'J113Y-1005' jobcard_no,'P113Y-56' ORDER_VRNO,'PUNCHING' PROCESS_CODE,0 PROCESS_EXECUTE_QTY, 0 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
    UNION ALL
  select 1 SLNO,'J113Y-1004' jobcard_no,'P113Y-56' ORDER_VRNO,'FORMING' PROCESS_CODE,0 PROCESS_EXECUTE_QTY, 0 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
  UNION ALL
  select 2 SLNO,'J113Y-1005' jobcard_no,'P113Y-56' ORDER_VRNO,'FORMING' PROCESS_CODE,0 PROCESS_EXECUTE_QTY, 0 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL)
SELECT SLNO,JOBCARD_NO,ORDER_VRNO,PROCESS_CODE,PROCESS_EXECUTE_QTY,EDIT_UP_TO_EXEPECTED_ANS FROM T
i am using
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
version.
thanks.

Just a guess  ( with some data changed and an order column added)
with t as
(select 1 SLNO,'J113Y-1004' jobcard_no,'P113Y-56' ORDER_VRNO,'CUTTING' PROCESS_CODE,1 ord,75 PROCESS_EXECUTE_QTY,0 EDIT_UP_TO_EXEPECTED_ANS      FROM DUAL UNION ALL
select 2,'J113Y-1005','P113Y-56','CUTTING',1,100,0 FROM DUAL UNION ALL
select 1,'J113Y-1004','P113Y-56','DRILLING',2,85,0 FROM DUAL UNION ALL
select 2,'J113Y-1005','P113Y-56','DRILLING',2,0,0 FROM DUAL UNION ALL
select 1,'J113Y-1004','P113Y-56','PUNCHING',3,15,0 FROM DUAL UNION ALL
select 2,'J113Y-1005','P113Y-56','PUNCHING',3,0,0 FROM DUAL UNION ALL
select 1,'J113Y-1004','P113Y-56','FORMING',4,0,0 FROM DUAL UNION ALL
select 2,'J113Y-1005','P113Y-56','FORMING',4,0,0 FROM DUAL
SLNO
JOBCARD_NO
ORDER_VRNO
PROCESS_CODE
ORD
PROCESS_EXECUTE_QTY
EDIT_UP_TO_EXEPECTED_ANS
1
J113Y-1004
P113Y-56
CUTTING
1
75
0
2
J113Y-1005
P113Y-56
CUTTING
1
100
0
1
J113Y-1004
P113Y-56
DRILLING
2
85
0
2
J113Y-1005
P113Y-56
DRILLING
2
0
0
1
J113Y-1004
P113Y-56
PUNCHING
3
15
0
2
J113Y-1005
P113Y-56
PUNCHING
3
0
0
1
J113Y-1004
P113Y-56
FORMING
4
0
0
2
J113Y-1005
P113Y-56
FORMING
4
0
0
SELECT SLNO,JOBCARD_NO,ORDER_VRNO,PROCESS_CODE,ord,PROCESS_EXECUTE_QTY,
       case when slno = 2
            then PROCESS_EXECUTE_QTY - lag(PROCESS_EXECUTE_QTY ) over (order by ord,slno)
            else PROCESS_EXECUTE_QTY
       end EDIT_UP_TO_EXEPECTED_ANS
  from (SELECT SLNO,JOBCARD_NO,ORDER_VRNO,PROCESS_CODE,ord,
               case when slno = 2
                    then first_value(process_execute_qty) over (order by ord,slno desc)
                    else PROCESS_EXECUTE_QTY
               end PROCESS_EXECUTE_QTY,
               EDIT_UP_TO_EXEPECTED_ANS
          FROM T
order by ord,slno
SLNO
JOBCARD_NO
ORDER_VRNO
PROCESS_CODE
ORD
PROCESS_EXECUTE_QTY
EDIT_UP_TO_EXEPECTED_ANS
1
J113Y-1004
P113Y-56
CUTTING
1
75
75
2
J113Y-1005
P113Y-56
CUTTING
1
100
25
1
J113Y-1004
P113Y-56
DRILLING
2
85
85
2
J113Y-1005
P113Y-56
DRILLING
2
100
15
1
J113Y-1004
P113Y-56
PUNCHING
3
15
15
2
J113Y-1005
P113Y-56
PUNCHING
3
100
85
1
J113Y-1004
P113Y-56
FORMING
4
0
0
2
J113Y-1005
P113Y-56
FORMING
4
100
100
Regards
Etbin

Similar Messages

  • To calaculate running balance in an sql

    how to calaculate running balance in an sql
    my values like
    Decription debit credit      balance
    Opening          10000          10000
    id-1      1000          11000
    id-2 500               10500
    id-3          1500          12000
    etc
    Please help me for this sql

    I want running balance for seperate a/c alsoYou have been supplied with the resorces to do this yourself (with a little application on your part), you have also been supplied with one bespoke solution to your problems. A very small alteration to the existing code that you were spoon fed, will solve your issue. Several of the pages on the link that I posted will perform exactly what you need to do, with nothing more than table and column name changes. Have a read of at least one, you will be able to get the answer on your own. And if not, post back with what you attempted and we will help you understand better.

  • J2I6 - Balance Qty in Stock

    Dear Sir`s,
    Will anybody tell me how the Balance Qty in Stock ( 14 th no Column ) in the J2I6 Report (T-Code ) coming ?
    From where system pick the value ?
    I tried to see in MMBE but it is not matching .
    Thanks & Regards ,
    Ganesh

    Hi,
    1. "Manage Item Cost per Warehouse" is not checked?
    2. Moving Average is the valuation method?
    3. You ran the report for especifically warehouse?
    1. no, is checked
    2. no, FIFO
    3. yes, for one warehouse (every item is only in one warehouse anyway)
    I filed it with SAP but unfortunately they did not respond yet. Guess we just have to live with it.

  • Balance qty report

    Hi gurus,
    Is there any report for open sales orders balance qty..
    Regards,
    VSN

    Hello VSN
    you could use report VA05 , to get a list of open sales order. you can get varety of information regarding the open quantity
    you get the order qnt, delivered qnt , status -delivered , partially delivered
    you can check the status from the report and get a overview analysis
    Hope this helps
    Thanks
    akasha

  • I want to use the SQL Toolkit of NI and SQL Server as my databasis on a server. Do I need to install a client in each computer I want to handle the data into SQL tables or I need only a ODBC driver?

    I want to use the SQL Toolkit of NI and SQL Server as my databasis on a server. Do I need to install a client in each computer I want to handle the data into SQL tables or I need only a ODBC driver?

    You only need the ODBC driver on each computer. If you are distributing the SQL Toolkit app as an executable and do not install the whole toolkit on each computer, you'll need the SQL Toolkit support files. This is about a dozen files. You can get the list at http://digital.ni.com/public.nsf/websearch/b814be005f9da9258625658700550c75?OpenDocument.

  • Balance Qty for inbound

    Hi All,
    Can we find the inbound  qty balance pending for migo in sap.Is there any table which will store the balance qty of inbound.
    Thanks in advance
    Basu

    Hi experts,
    Please help.

  • I want to query oracle database from sql server can anyone tell steps 2 fo

    i want to query oracle database from sql server can anyone tell steps 2 followed
    i tried with linked servers but it is throwing errors can anyone hepl in this regard
    The operation could not be performed because the OLE DB provider 'MSDAORA' was unable to begin a distributed transaction.
    OLE DB error trace [OLE/DB Provider 'MSDAORA' ITransactionJoin::JoinTransaction returned 0x8004d01b].

    First of all - you are in the wrong forum.
    Look either for the Database general or search for Transparant / Heterogenous Gateways.
    cu
    Andreas

  • I want to query oracle database from sql server can anyone tell steps 2 fol

    i want to query oracle database from sql server can anyone tell steps 2 followed
    i tried with linked servers but it is throwing errors can anyone hepl in this regard
    The operation could not be performed because the OLE DB provider 'MSDAORA' was unable to begin a distributed transaction.
    OLE DB error trace [OLE/DB Provider 'MSDAORA' ITransactionJoin::JoinTransaction returned 0x8004d01b].

    First of all - you are in the wrong forum.
    Look either for the Database general or search for Transparant / Heterogenous Gateways.
    cu
    Andreas

  • To include a new field " Balance Qty" in the VA05

    My requirement is to add a field called "Balance qty" in the VA05 (List of sales order).

    Hi,
    You have a demo for this note in this link with another field: http://sap.ittoolbox.com/groups/technical-functional/sap-log-sd/modifying-oss-message-350068-to-include-po-date-field-304733
    For your requirement, my suggestion is:
    - Search only for sales order with the right status (VBUP-LFSTA or VBUP-WBSTA).
    - After, search in the table VBFA the deliveries for this SO. Be careful with performance, so try note 185530.
    - Newly, check the status for delivery (VBUP-WBSTA if I'm right), and then in the new field you can solve the balance qty.
    Of course, if you don't know ABAP you need an ABAPer.
    I hope this helps you,
    Regards,
    Eduardo

  • Want to connect as sysdba in sql*plus

    Hi everybody,
    Greetings...
    I want to connect as sysdba in sql*plus, because i'm trying to install oracle Apex in my system.
    Could you please anybody.

    sqlplus sys/password as sysdbaor
    sqlplus / as sysdbawith OS authentication enabled

  • Change the confirmed qty to allocate that qty to other

    Hi Gurus help please...
    My requirement is to change the confirmed qty to allocate that qty to other sales order.
    The scenario is as below.
    It is multilevel assembly  process under  MTO. We work on different  sales order (different material and quantity) same time. For each sales order there are corresponding production orders for each work center. In initial level  we assemble certain material say X which can be used either for Sales order A or sales order B.
    Even though it is planned to use item  X manufactured and quantity confirmed under sales order A only for final assembly for A, it is alternatively used for A and B.  
    Since this decision is taken just before Final assembly time to time, we need to change the confirmed quantity allocated to one sales order to another each time.
    Is there any provision for backward integration so  that, Corresponding to the quantity confirmation done in final assembly , The quantity is auto adjusted in initial level of assembly?
    For example: We certify X 10 numbers under A and 5 numbers under B purchase order. But we utilize 10 for B and 5 for A in final assembly.
    How to make changes in confirmed quantity of initial assembly. ( certain cases it is serial number parts, in some other cases, it is having just material number and quantity.)
    Is ther any solution under COGI,COHV  or is to be addressed by BAPI

    Hi,
    As rightly said by Mr. yang you have to make it collective by keeping the Ind/Coll indicator in MRP4 View of material Master as 2.
    This will make your stock as collective and your stock will be considered as per strategy 10.
    There is only one issue you cannot retain the identity of sales order to which it is assigned to.also one it is made as collective then its child items (if any will also Become Collective.) i.e You will cut the link from there for further child items.
    Regards,
    Mandar

  • I want to make party leder using sql server

    i want to make party leder using sql server

    What do you mean by "party leder"?
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Difference in closing Balance qty in Inventory Cube and R3 T-code MB5B

    Dear All
    In evaluations of the 0OIC_C03 Infocube and corresponding reports in R/3 with transaction MB5B/MB51 suggest incorrect data extraction. The difference is in the initial stoock uploeaded . I found transaction in the PSA of 2LIS_03_BX which are not there in the MB5B/MB51.When I run the Query I found a certain qty in the Closing Balance but the same can not be traced in MB5B. The closing balances is the differnce in the qty of Mvt. Type 541 and 542. The closing balance is apearing against the calday but not against the posting date. Moreever the closing balance is apearing against Calday 30/07/2008 whereas we have gone live on 01/08/2008 and uploaded the initial stock on 31/08/2008.
    Dinesh Sharma

    Dear All
    In evaluations of the 0OIC_C03 Infocube and corresponding reports in R/3 with transaction MB5B/MB51 suggest incorrect data extraction. The difference is in the initial stoock uploeaded . I found transaction in the PSA of 2LIS_03_BX which are not there in the MB5B/MB51.When I run the Query I found a certain qty in the Closing Balance but the same can not be traced in MB5B. The closing balances is the differnce in the qty of Mvt. Type 541 and 542. The closing balance is apearing against the calday but not against the posting date. Moreever the closing balance is apearing against Calday 30/07/2008 whereas we have gone live on 01/08/2008 and uploaded the initial stock on  31/08/2008.
    Dinesh Sharma

  • How to get balance qty. of delivery in del. doc.

    Dear Friends,
    S.O's qty=100
    Delivery doc. added qty=50
    Now if i will open delivery doc.
    shall i get information like.
    ordered=100
    Delivered=50
    Balance to deliver=50
    Regards,
    MAhesh.

    Hi
    In S.O u will get two fields in Form settings like Delivered Qty and Open QTy( Yet to deliver), u can use this in ur so.
    In Delivery u will get two fields in FS like QTY to Ship , Ordered qty.
    Giri

  • Want to connect Oracle 11g from SQL Navigator on Windows

    Hi brothers,
    I'm a new ora man, and having a issue need your help.
    I installed Ora 11g on linux (Ubuntu 8.10) and SQL Navigator 11g on WindowsXP. Now, I want to use SQL Navigtor to connect database server. I tried many times but it still fails with me. I read some articles on Internet but they were not useful to me.
    Here is some information about my system.
    Linux : 192.168.0.82
    Windows : 192.168.0.230
    (+I can ping from Windows to Linux+)
    $ lsnrctl stat
    LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 03-APR-2009 16:18:15
    Copyright (c) 1991, 2007, Oracle.  All rights reserved.
    Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
    STATUS of the LISTENER
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 11.1.0.6.0 - Production
    Start Date                03-APR-2009 08:33:41
    Uptime                    0 days 7 hr. 44 min. 34 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Log File         /u01/app/oracle/diag/tnslsnr/kimngoc-desktop/listener/alert/log.xml
    Listening Endpoints Summary...
    +(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=kimngoc-desktop)(PORT=1521)))+
    Services Summary...
    Service "intrepid" has 1 instance(s).
    Instance "intrepid", status READY, has 1 handler(s) for this service...
    Service "intrepidXDB" has 1 instance(s).
    Instance "intrepid", status READY, has 1 handler(s) for this service...
    Service "intrepid_XPT" has 1 instance(s).
    Instance "intrepid", status READY, has 1 handler(s) for this service...
    The command completed successfully
    $ps -afe | grep -i listener
    oracle    5383     1  0 08:33 ?        00:00:00 /u01/app/oracle/product/11.1.0/orasample/bin/tnslsnr LISTENER -inherit
    oracle   19705  6600  0 16:23 pts/0    00:00:00 grep -i listener
    Pls help solve this problem if you can.

    download SqlDeveloper from OTN.
    it allows you to connect to remote databases without extra drivers
    BTW, there is a SqlDeveloper forum here on OTN, might be helpful
    SQL Developer

Maybe you are looking for

  • I tunes crashes ca 10 seconds after starting it, what to do?

    This is the error log, I don't have a clue what it means but you probably do. Process:         iTunes [293] Path:            /Applications/iTunes.app/Contents/MacOS/iTunes Identifier:      com.apple.iTunes Version:         10.7 (10.7) Build Info:    

  • Batch Renaming with Counter

    I am trying to do batch renaming with a counter. Unfortunately every time I try to use a counter, it stays the same number. For example/ I have two clips that I want to rename Ceremony 1 and Ceremony 2. When I do the batch renaming, the clips change

  • Can you watch this video and respond? (environment)

    I read a lot of Bee Jay posts regarding environment and external devices. Maybe my bad English, i have difficulty to understanding completely. Please http://www.youtube.com/user/dandini90

  • How can i change the 'open in' options in an app?

    hi, I have a lot of apps on my ipad and many of them allow me to edit and change document, presentations and PDFs.  It appears that only 10 are listed but i cannot work out how to alter the list that appears - is this a possibility at all?  I want to

  • Upgraded to 10.4.9, afterwhich 3rd party software won't open.

    After I upgraded to 10.4.9 from 10.4.8 on my iMac G4 I receive msgs as follows: APPLICATION LAUNCH FAILURE. The application "Word" could not be launched because of a shared library error: "2<Microsoft Word><CarbonLib><CFMPriv_CarbonSound>" the same h