Find Case 1 and Case 2

Hi,
An order will have both Case 1 and case 2 types.
Case 1 :One ordered_item_id has multiple package _id which we call Ship Alone
Case 2: One package_id has multiple ordered_item_id which we call Normal
Requirement: I will give packing_id or ordered_item_id and how do I find out whether that packing_id
will fall in Case 1 or Case 2.
Sample Data:  *Ship Alone*
              Ordered_item_id  Ord_quantity         Packing_Id           packing_quantity
                  5858                 3              102,103,104        1,1,1          
              *Normal*
              Packing_Id        packing_quantity       Ordered_item_id    Ord_quantity            
            110                    2                           5111                 2
           110                    3                            5112                3
           110                    1                            5113                1
           110                    1                             5114               1                    I have tried this code but it is not giving me expected result.
       CURSOR c_count     
  IS
       SELECT oi.ordered_item_id
                 ,oi.quantity_ordered
                  ,SUM(pd.quantity)
                  ,COUNT(packing_id)
                    FROM  ordered_items oi
          ,packing_details pd
       WHERE oi.ordered_item_id = pd.ordered_item_id
         AND   oi.ordered_item_id = v_ordered_item_id
               GROUP BY  oi.ordered_item_id
                              ,oi.quantity_ordered;     
     OPEN c_count;
        LOOP
        FETCH c_count
      INTO ord_itm_id
               ,order_qty
              ,package_qty
              ,count_pack_per_item ;
       EXIT WHEN c_count%NOTFOUND;
       IF count_pack_per_item =1 THEN
--ddooo something
SELECT  COUNT(*)
      INTO v_shipalone_count
FROM packing_details pd
           ,packing p
WHERE pd.ordered_item_id = ord_itm_id
    AND p.packing_id       = pd.packing_id
   AND p.status           = 'C';     
  If (count_pack_per_item > 1) AND (v_shipalone_count >= 1)  THEN            
--do somethingthis is not complete code but the part which i trying to get the result
Suupose I give packing_id 103 then it should say it will come in Case 1.
Thanks in advance.
Sandy
Edited by: sandy162 on Jun 4, 2009 3:34 PM
Edited by: sandy162 on Jun 4, 2009 3:40 PM

Thanks as you said Select are woking perfectly fine and seleting cases proeprly but I have problem how to implemet
those selects in my code.. here is my code and at step 6 & 7 im finding out ship_alone or normal case.
Please help me to resolve it.
--Stpe 5  find out number of packages in given order
     SELECT count(*)
       INTO package_count
       FROM packing
      WHERE client         = v_client
         AND order_number = v_order_number
                     AND status IN ('A','C');
--Step 5a. If only one package for a given Order UPDATE Order status = 'B' else Order status will remain 'S'--
     IF package_count = 1 THEN
       UPDATE orders
            SET status = 'B'
        WHERE order_number = v_order_number
                       AND client       = v_client;
     END IF;
-- -Step 5b. for all Orders (single or multiple packages) UPDATE ordered_items SET status = 'B'---     
        UPDATE ordered_items
           SET status = 'B'
                 WHERE client  = v_client
                    AND ordered_item_id   = v_ordered_item_id;
     IF package_count > 1 THEN
--Step 6. Check ordered_item_id count and packing_id count in given order_number
   OPEN c_count;
      LOOP
       FETCH c_count
      INTO ord_itm_id
           ,order_qty
           ,package_qty
           ,count_pack_per_item ;
       EXIT WHEN c_count%NOTFOUND;
--Step 6a. package has one/multiple order items       
       IF count_pack_per_item =1 THEN
           cmn_backorder_pkg.create_new_backorder (ordrec);  -- Create backorder from backordered items for ordrec.order_number.
     END IF;
---Step 6b. Ship-alone means order item has multiple pacakges
     SELECT COUNT(*)
                   INTO v_shipalone_count
       FROM packing_details pd
                          ,packing p
                WHERE pd.ordered_item_id = ord_itm_id
         AND p.packing_id          = pd.packing_id
         AND p.status                = 'C';     
---Step 7a Ship alone Order items has already one/more package cancelled
  If (count_pack_per_item > 1) AND (v_shipalone_count >= 1)  THEN
        UPDATE ordered_items oi
              SET oi.quantity_ordered = order_qty+package_qty
         WHERE ordered_item_id     = ord_itm_id ;
------step 7b Canceling Ship Alone package for first time      
   ELSE
       OPEN c_back_order;
       LOOP
          FETCH c_back_order
          INTO ordrec;
          EXIT WHEN c_back_order%NOTFOUND;
--Step 8a: Adjust original order items quantity --
      p_new_qty :=  (order_qty - package_qty);
          UPDATE ordered_items oi
                SET oi.QUANTITY_ORDERED = p_new_qty
           WHERE ordered_item_id = ord_itm_id;
    ---Step 8b: adjust packing detail quantity
            v_tran        := 'U';
            v_line_status := 'S';
            v_new_qty     := p_new_qty;
            OPEN c_adj_item (v_order_number, v_client);
            LOOP
              FETCH c_adj_item INTO itemrec;
              EXIT WHEN c_adj_item%NOTFOUND;
                .l              
         END LOOP;
         CLOSE c_back_order;  --c_back_order
       Thanks
Sandy

Similar Messages

  • Some downloaded apps are oriented sideways when my iPad is sideways in my Zaggfolio keyboard case and I cannot find any way to rotate my iPad screen so the App appears vertically

    Some downloaded apps are oriented sideways, because my iPad is sideways in my Zaggfolio keyboard case, and I cannot find any way to rotate the apps so they are vertical when my iPad is horizontal in my Zaggfolio case.  I sent a question to the app developers and one of them responded that I had asked a good question and they would consider it on their next update.  Does that mean that I have to remove my iPad from my keyoard case every time I want to use those apps.  This issue is only happening on some apps.  Also, my iPad is not in the locked position.

    You can lock the rotation with the little slider switch located under your volume toggle. however locking rotation is an 'all or nothing' proposition. you can't choose the portrait or landscape in a 'per app' basis.
    In addition there are some apps that don't rotate.
    When I use an app that wants to be in portrait with my zagg folio I just turn it and hold it that way. the lack of ease of rotation is the oen major downfall of that case.

  • HT6346 I have lost my Case and Repair ID.How can I find it ?

    I have lost my Case and Repair ID.How can I find it ? The e-mail has been dealeted .how can I find my Case and Repair ID ???!!!

    Call someone where you got the repair ID and ask them. We have no way of knowing.

  • Hallo ladies and gentleman, my iPod nano (6 Gen.) has been stolen, is there any chance to find it, in case it is connected with a computer?t

    Hallo ladies and gentleman, my iPod nano (6. Gen.) has been stolen, is there any chance to find it, in case it is connected with a computer?
    serial number is: DC*******DW6
    <Edited By Host>

    call them, tell them you NEED a new battery installed, and they need to tell you when they can do it.  That is their job to help you! Give pushback if necessary.

  • Case Management - Table to find out relation between Case and Activity

    Hi.
    I do search the SDN for the same quesiton, I found one but it was not answered by a single person. So let me ask it again:
    I am working on an interface in CRM that will create the activity and link it to the open case.
    I can get the existing case GUID and information from table CRMD_CMG_CASE_AT .
    I can get the GUID as a return parameter when activity will be created using BAPI.
    But how can I link the activity to the case.
    1. Which table is having relation between both case and activity?
    2. What class or BAPI will be used to link created activity to existing case?
    Thanks in advance.
    Hitesh

    done

  • PLs. find link between a case and its activities?

    Hi ,
    I need a function module or a table relation  in order to make a link between a case and its activities.
    and also want to know the relation between *crmd_orderadm_h-guid with SCMGRECP01-PHIO_ID. *
    Please help me .

    Hi,
    you can try vice versa
    CRMD_CMG_CASE_AT-CASE_GUID = SCMG_T_CASE_ATTR-CASE_GUID
    SCMG_T_CASE_ATTR-EXT_KEY =  CRMD_ACTIVITY_H-EXTERN_ACT_ID 
    CRMD_ACTIVITY_H-GUID =
    CRMD_ORDERADM_H-GUID
    Regards,
    Sumeet

  • My iphone 5s isn't turning on and its not charging. i have my legit charger that came with my phone and after 6 months it stopped working, i even have a charging case and that wont charge i. I tried cleaning it but still nothing! some please help

    A few days after i've updated to iOS 8.1.1 my iphone 5s died and isn't turning on and its not charging. i have my legit charger that came with my phone and after 6 months it stopped working, i even have a charging case and that wont charge it. I google searched the problem and tried cleaning the charging port but still nothing! some please help

    Please make a Genius Appointment and take it in for service.
    If your iPod Touch, iPhone, or iPad is Broken
    Apple does not fix iDevices. Instead, they exchange yours for a refurbished or new replacement depending upon the age of your device and refurbished inventories. On rare occasions when there are no longer refurbished units for your older model, they may replace it with the next newer model.
    ATTN: Beginning July 2013 Apple Stores are now equipped to do screen repairs/replacements in-house on iPhone 5 and 5C. In some cases while you wait. According to Apple this is the beginning of equipping Apple Stores with the resources needed to do most repairs for iPhones, iPads, and iPod Touches that would not require major replacements. Later in the year the services may be extended as Apple Stores become equipped and staffed with the proper repair expertise. So, if you need a screen repaired or a broken screen replaced or have your stuck Home button fixed, call your local Apple Store to see if they are now doing these in-house.
    You may take your device to an Apple retailer for help or you may call Customer Service and arrange to send your device to Apple:
    Apple Store Customer Service at 1-800-676-2775 or visit online Help for more information.
    To contact product and tech support: Contacting Apple for support and service - this includes international calling numbers.
    You will find respective repair costs in the appropriate link:
    iPod Service Support and Costs
    iPhone Service Support and Costs
    iPad Service Support and Costs
    There are third-party firms that do repairs on iDevices, and there are places where you can order parts to DIY if you feel up to the task:
    1. iResq or Google for others.
    2. Buy and replace screen yourself: iFixit

  • HT1665 I have the iPhone 4S and would like to purchase docking device6. I have the Otter Box Camo case and would like to know which dock will work with the case ON. Thank you.

    I have the iPhone 4S and would like to purchase a docking device.  I have the Otter Box Camo case and would like to know which dock will work with the
    case ON.   Thank you.

    it might be better to contact otterbox to find out from them what they made it compatible with. 

  • I have an 8 year old eMac G3. It will not start up. I need to erase it before putting it in recycling. Apple refuses to open the case and warns me that I will be shocked if I even try. They say no way to erase hard drive. They say use a hammer. Any ideas?

    I have an 8 year old eMac G3. It will not start up. I need to erase it before putting it in recycling. Apple refuses to open the case and warns me that I will be shocked if I even try. They say no way to erase hard drive. They say use a hammer. Any ideas?

    Hi, no eMacs had G3s, only G4s. Is it maybe an iMac G3?
    If you don't know the model, find the Serial# & use it on one of these sites, but don't post the Serial# here...
    http://www.chipmunk.nl/klantenservice/applemodel.html
    http://www.appleserialnumberinfo.com/Desktop/index.php
    How to find the serial number of your Apple hardware product...
    http://support.apple.com/kb/HT1349
    http://www.ifixit.com/Device/eMac

  • Where can I find a camera case for my iPod touch 4g?

    I have found many cases for the iPhone 4/4S that are camera cases but I don't have an iPhone. I'm looking to find a camera case for my iPod touch 4th generation.

    I've found cases for the iPhone that have little 8x zoom lens and cases that can attach a DSLR lens to your iPhone. I'm trying to find one for my iPod touch but cant find any.
    Yeah I've checked the apple store. Unless they just added it today I can't find one.

  • Cases and Accessories for 5G iPods

    Ok, so ever since I purchased my Black 60GB iPod I started reading about how easily it scratched and realized I needed to get a case for it immediately. I was also surprised to discover that my old iTrip and other top docking accessories no longer worked with the 5G iPods. So I began to research my options for cases and accessories, and here's what I came across:
    This is a silicone case from zCover that seems to be the only 5G specific case that is available and shipping now.
    http://www.zcover.com/zCoverProduct_iPod_G5Original.htm
    Here are 6 different options for cases offered by Speck sometime in mid-November.
    http://www.speckproducts.com/for-video.html
    Tunewear has several different options available for the 5G's. The silicone case (ICEWEAR 5G) can be found here: http://www.tunewear.com/english/product/icewear_5g/index.html
    The wallet-sized leather case (PRIE TUNEWALLET 5G) can be found here: http://www.tunewear.com/english/product/tunewallet_5g/
    And finally the leather case with belt clip and hook (PRIE Ambassador) can be found here: http://www.tunewear.com/english/product/ambassadoripod5g/index.html
    All of these cases are shipping sometime in November and all come included with Tunewear's TUNEFILM 5G which can also be purchased separately, found here: http://www.tunewear.com/english/product/tunefilm_5g/index.html
    Another leather case option is being offered by difusi. Here is their VideoValet case, stated to be shipping sometime this week: http://www.difusi.tv/hardware/casemini/videovalet.html
    Since most of these cases haven't been released yet, I decided to fashion my own case for the time being. This option will probably only work for those of you who purchased the 60 GB iPods, because the 30GB 5G's are significantly thinner than their 20GB and 30GB 3G and 4G counterparts. But anyway, I purchased a cheap silicone case for a 20GB iPod from Best Buy (you can probably find one anywhere that sells iPod accessories for around $10-$15) and a pack of PDA screen protectors. Since the height and width of the new iPods are exactly the same (the thickness or depth of the new 60GB is close enough to the 20GB and 30GB 4G's) and the click wheel and dock connector seem to be in the same place, it was only the screen size that needed to be adjusted. So I cut the case to make the entire screen visible, used a small amount of heat with a lighter to melt the cut edges firm, and then cut a screen protector to fit. This is a crude option, but it has worked for me so far and I don't have a scratch on it yet.
    As for other accessories available, allabouttheaccessories.com has nearly all accessories that are currently available and compatible with the 5G video capable iPods listed here: http://www.allabouttheaccessories.com/index.asp?PageAction=VIEWCATS&Category=193
    As most of you know, the current incarnations of Griffin's t fit in the older case. Obviously the edges of the iTrip, perhaps the most popular FM transmitter for the iPod, are not compatible with the new 5G iPods. For some reason, Apple did away with the external power port on top of the new iPods, and therefore it is unlikely that there will be any accessories, including iTrip, iTalk, remotes, etc. that will dock on top of the iPod. Instead, most will use the dock connector port on the bottom of the iPod, which isn't all bad and actually offers some benefits. Griffin's new iTrip that will use this port can be found here: http://www.griffintechnology.com/products/itrip30/techspecs.php And with a simple mini USB to standard USB cable, you can charge your iPod using a number of car chargers that use the USB cable (including Griffin's PowerJolt of course).
    Anyway, hope this post helps those of you searching for new stuff for your 5G iPods. Despite the criticism I've read, this device is a huge step for iPods and has a ton of potential. Sure there are a few things that need to get worked out, but the bottom line is they've added all t

    I did a quick search on Best Buy and came up with the following...
    http://www.bestbuy.com/site/searchpage.jsp?_dyncharset=ISO-8859-1&_dynSessConf=&id=pcat17071&type=pa...
    I'm sure you can do the same on Google with the rest of the web.

  • Cant find a silicone case for my zen please help does anyone know of

    [size="+2"]I?cant find a silicone case for my creative ZEN not a ZEN micro but a 20gb ZENMessage Edited by stink on 03-23-200602:5 AM

    I am not sure if this is what you're looking for. But I love the flexiskin I purchased for my Zen Sleek. I have found that it is definitely helping to keep dust out of the screen and protecting the Sleek. Here is a link of what I purchased:
    http://www.amazon.com/gp/product/B000CC7KRM/03-242852-3357458?%5Fencoding=UTF8&v=glance&n=72282

  • Flex Cube - Deposits and CASA documentation

    Flex Cube - Deposits and CASA documentation: someone could help me to find documentation and information about CA SA and Deposits Flex CUbe MOdule ? Thanks.

  • More effecient way of using Decode and CASE

    Is it possible to use both case and decode together? I feel I have too many decode and I am not sure how to write this in a more efficient way.
    I would really appreciate any help.
    Thank you so much in advance!!!
    SELECT  Person_ID,Work_ID,
        CASE WHEN NBR = 1 THEN
                MIN(DECODE(NBR, 1, field1)) aug_one_field1;
                MIN(DECODE(NBR, 1, field2)) aug_one_field2;
                MIN(DECODE(NBR, 1, field3)) aug_one_field3;
                MIN(DECODE(NBR, 1, field4)) aug_one_field4;
                MIN(DECODE(NBR, 1, field5)) aug_one_field5;
                MIN(DECODE(NBR, 1, field6)) aug_one_field6;
        CASE WHEN NBR = 2 THEN
                MIN(DECODE(NBR, 2, field1)) aug_two_field1;
                MIN(DECODE(NBR, 2, field2)) aug_two_field2;
                MIN(DECODE(NBR, 2, field3)) aug_two_field3;
                MIN(DECODE(NBR, 2, field4)) aug_two_field4;
                MIN(DECODE(NBR, 2, field5)) aug_two_field5;
                MIN(DECODE(NBR, 2, field6)) aug_two_field6;
        CASE WHEN NBR = 3 THEN
                MIN(DECODE(NBR, 3, field1)) aug_three_field1;
                MIN(DECODE(NBR, 3, field2)) aug_three_field2;
                MIN(DECODE(NBR, 3, field3)) aug_three_field3;
                MIN(DECODE(NBR, 3, field4)) aug_three_field4;
                MIN(DECODE(NBR, 3, field5)) aug_three_field5;
                MIN(DECODE(NBR, 3, field6)) aug_three_field6;
        CASE WHEN NBR = 4 THEN
                MIN(DECODE(NBR, 4, field1)) aug_four_field1;
                MIN(DECODE(NBR, 4, field2)) aug_four_field2;
                MIN(DECODE(NBR, 4, field3)) aug_four_field3;
                MIN(DECODE(NBR, 4, field4)) aug_four_field4;
                MIN(DECODE(NBR, 4, field5)) aug_four_field5;
                MIN(DECODE(NBR, 4, field6)) aug_four_field6;
    END
       FROM (SELECT Person_ID,Work_ID, NBR
                   fiel1, field2, field3,field4,field5, field6,
                  FROM field_rep
       GROUP BY Person_ID,Work_ID

    Thanks alot John and Frank.
    John to answer your question, I just felt the 24 or more decode will slow down the systems performance, hence I was trying to find a better way to do it.
    Frank
    This is a sample data but I want it pivoted hence the reason for using the decode. I have oracle 10g. These are sample data
    Person_id work_id NBR      field1     field2     field3     field4 field5 field6
    1       ao334   1     1/2/2009   1/9/2010     block_A        HH       55667      1
    1       ao334   2     5/2/2011   9/9/2013     block_Z        HL       11111      3
    1       ao334   2     1/2/2009   1/9/2010     block_A        HH       22222      1
    1       ao334   4     1/2/2009   1/9/2010     block_A        HH       zzzzz      7
    1       z5521   1     10/5/2006  12/31/2012     block_C        SS       33322      1
    1       z5521   2     1/2/2009   1/9/2010     block_C        SS       21550      1
    1       z5521   3     1/2/2009   1/9/2010     block_R        SS       10000      1
    1       z5521   4     1/2/2009   1/9/2010     block_D        SS       99100      5
    1       z5521   5     1/2/2009   1/9/2010     block_P        SS       88860      1
    1       z5521   6     1/2/2009   1/9/2010     block_G        SS       99660      8
    1       ob114   1     1/2/2009   1/9/2010     block_A        HH       52333      1
    1       ob114   2     1/2/2009   1/9/2010     block_A        HH       88888      1Output will look like this
    Person_id work_id  aug_one_field1 aug_one_field2 aug_one_field3 aug_one_field4 aug_one_field5 aug_one_field6 aug_two_field1 aug_two_field2 aug_two_field3 aug_two_field4 aug_two_field5  aug_two_field6
    1       ao334        1/2/2009       1/9/2010       block_A       HH             55667          1              5/2/2011       9/9/2013       block_Z        HL                      11111          3

  • Unable to find matching navigation case from view ID.  Error 404

    Hi All,
    I basically wanted to jumpstart my ADF exploration so I am following the tutorial at this link. [http://www.oracle.com/technetwork/developer-tools/jdev/ccset22-all-099343.html]
    Everything looks good but when I click the Edit Button, I am encountering an error. What I did was I change the logging mechanism into a FINER in my WLS and from the logs,
    it prints below messages.
    <NavigationHandlerImpl> <getViewId> "JSF1013: Unable to find matching navigation case from view ID '/orders-flow/editOrders' for outcome 'save' and action 'save'
    <ViewHandlerImpl> <executePageToBuildView> About to execute view /orders-flow/editOrders
    <ViewHandlerImpl> <executePageToBuildView> Before dispacthMessage to viewId /orders-flow/editOrders
    <ViewHandlerImpl> <executePageToBuildView> After dispacthMessage to viewId /orders-flow/editOrdersI checked out the taskflow and it is basically calling a task-flow-return component.
    I followed everything but I cant make this example work... Any idea why? I checked out the DB and I notice that it has commited my Edit Transaction but I am getting a 404 on my page. Please help. Thanks.

    Hi Frank,
    I think I got the save control flow case.
    Can you help me check please if I miss something? I uploaded my project at this link. [http://www.4shared.com/file/QFcofTfj/BrowseEditApp.html]
    I am quite not sure if I miss something but I have done this project twice already but got the same result.
    Thanks
    Edited by: Marky on 13.4.2011 5:59

Maybe you are looking for

  • How does my entire family share one account?

    I have a wife and 2 kids. How can we all share the same library on our iPhones and iPads without having to share the exact same songs, apps., etc..  For example, if my son downloads a song, I want it to go into the "main" library, but I don't necessa

  • Can I buy a prepaid SIM card for my unlocked iPhone 4S?

    I have an unlocked iPhone 4S purchased in Costa Rica where I live. I'll be visiting Michigan in July and August and would like to use the iPhone while there. Can I buy a prepaid and rechargeable SIM to install in the phone while there? If yes, what's

  • Screen sharing across internet

    I had set up my Mac for screen sharing with Lion and was able to share the screen to another Mac on the local network, or VNC across the internet. Upgraded to Mountain Lion and screen sharing continued to work both locally and remote. Moved to Maveri

  • My bluetooth has disappeared from my MacBook. How do I install again?

    my bluetooth has disappeared from my MacBook. How do I install again?

  • Multiple Hierarchies in Dimension

    Hi All, I have a scenario, where I need to design a dimension with multiple hierarchies, is there a best practice on this ? I have about 6 hierarchy in one dimension. Could any share some idea and thoughts. Thasnks Zan