Mark BOM components with 1 where BOM's Stop Explode is marked as 1

CREATE TABLE [dbo].[ItemStopExplosion](
[Item] [nvarchar](10) NOT NULL,
[BOM] [nvarchar](5) NOT NULL,
[LevelNumber] [int] NOT NULL,
[LineNumber] [int] NOT NULL,
[StopExplode] [int] NOT NULL
) ON [PRIMARY]
GO
INSERT INTO [dbo].[ItemStopExplosion]
(Item,BOM,LevelNumber,LineNumber,StopExplode)
VALUES
('A','YES',1,1,0),
('B','YES',2,2,0),
('C','NO',2,3,1),
('D','NO',2,4,0),
('E','YES',1,5,0),
('F','NO',2,6,0),
('G','NO',2,7,0),
('H','YES',2,8,1),
('I','NO',3,9,0),
('J','NO',3,10,0),
('K','NO',3,11,0),
('L','NO',2,12,0);
Hi,
I've a sql query question and I hope some one could help me, could be as simple as using a CTE or something else but I cant get this one.
For the above mentioned data, whenever an Item has BOM=Yes and Stop Explode=1, I need to mark the sub-parts as stop explode (i.e. 1) as well. The catch is,
once the level of the items reach the same value as the BOM that initiated the process, the marking should stop. So for example in the above scenario, the final result would look like this. 
Any ideas?

CREATE TABLE [dbo].[ItemStopExplosion](
[Item] [nvarchar](10) NOT NULL,
[BOM] [nvarchar](5) NOT NULL,
[LevelNumber] [int] NOT NULL,
[LineNumber] [int] NOT NULL,
[StopExplode] [int] NOT NULL
) ON [PRIMARY]
GO
INSERT INTO [dbo].[ItemStopExplosion]
(Item,BOM,LevelNumber,LineNumber,StopExplode)
VALUES
('A','YES',1,1,0),
('B','YES',2,2,0),
('C','NO',2,3,1),
('D','NO',2,4,0),
('E','YES',1,5,0),
('F','NO',2,6,0),
('G','NO',2,7,0),
('H','YES',2,8,1),
('I','NO',3,9,0),
('J','NO',3,10,0),
('K','NO',3,11,0),
('L','NO',2,12,0);
;with mycte as (
select item, BOM,LevelNumber,LineNumber,StopExplode
, row_number() Over(partition by LevelNumber Order by Item) - row_number() Over(partition by LevelNumber,StopExplode Order by Item) island
from [ItemStopExplosion]
,mycte1 as (
select item, BOM,LevelNumber,LineNumber,StopExplode,sum(island) Over(Order by item) amt from mycte
Select item,BOM,LevelNumber,LineNumber,StopExplode
, sum(Case when BOM='YES' and StopExplode=1 then 1 ELse 0 END) Over(Partition by amt Order by item) NewStopExplode
from mycte1
Order by item
drop table [ItemStopExplosion]

Similar Messages

  • MB26 ,CO27 - goods issue components with serial number?

    Hi ,everyone!
    I know CO27 and MB26 can do goods issue to production order very easily and quickly!
    But It seems CO27 and MB26 can not work well with the component with serial number.
    I aslo know MB1A and MB1B can post goods issue for component with serial number.But in MB1A and MB11 , it is very difficult to can material by material number quickly while doing more then 100 components issue to one production order.
    And for authorization purpose we restrict MIGO not to use goods issue for production order.
    So I want to ask how CO27 and MB26 do goods issue for the component with serial number?
    Or there is another ways to goods issue component with serial number to production order easily,exclude MB1A,MB11 and MIGO?
    Thanks for any reply!

    Hi Vivek     
    We use CO27 for goods issue to production order ,just like MB1A goods issue to production order.
    But in the BOM components of the production orders ,some semi finished products are with  with serial numbers ,so we can not use CO27 or MB26 to issue these components with serial numbers to production orders!

  • Using BC4J Components with different App Servers

    Can we use BC4J with 3rd party Application Servers (WebSphere, Weblogic, iPlanet etc)?
    If so any advantages (Performance, Implementation, installation) in using these components with Oracle iAS?
    Thanks
    null

    BC4J allows different ways of deploying your application.
    1) Local Mode : where your client application and BC4J application are colocated togther and running in the same VM
    2) As a EJB session bean
    3) As a corba server object.
    Using the Local mode deployment option you can deploy the BC4J application to any appservers (weblogic, websphere, iplanet) as long as they have standard VM and if your client application is JSP or Servlet then the appservers need a JSP or Servlet engine.
    In JDeveloper 3.1 you can deploy BC4J applicaiton as EJB session bean to Oracle8i
    In JDeveloper 3.2 ( which will released in next few weeks) you can deploy BC4J application as EJB session bean to Oracle8i , Oracle iAS and weblogic .
    iAS comes preconfigured with BC4J runtime by default
    raghu

  • Using Adobe Photoshop CS2 version 9 and have updated it, but when stacking photos, it comes up with PSD, whereas I want Jpeg, and I change the format to Jpeg and the box then comes up with cannot save as there is a program error. Be very grateful for help

    Using Adobe Photoshop CS2 version 9 and have updated it, but when stacking photos, it comes up with PSD, whereas I want Jpeg, and I change the format to Jpeg and the box then comes up with cannot save as there is a program error. Be very grateful for help with this, please.

    jpg does not support Layers.
    Just to make sure, what exactly do you mean by "stacking photos" and what do you want to achieve thereby?

  • Form with report, where some items in the form have been given values.

    Hi, greetings:
    I have a question that maybe silly but annoying to me. I need to provide a form with report, where some items in the form have been given values automatically, and these items (display only) are supposed to show given values in the form automatically.
    I used the APEX form with report. The update and delete worked well. But I cannot show automatic values when insert. By default APEX insert form makes every item null; I tried to give value for two items: P5212_USERKEY, P5212_DAILY_VER_DATE with process before header, after header, after regions and before footer, and computation, or set values of these two items in the branch when user hit create button (submit). It never worked out, the two items always displayed null value, and when I insert, I got "ORA-01400: cannot insert NULL into ("TBSBI"."DAILYVERPRODNOTE"."USERKEY")", since I have set up constraint in database that these two columns should not be null.
    Could anyone help on this? any suggestion would be appreciated.
    Sam

    If you have made these values 'Display Only' they would by default not save the session state. Accessing the page items will always return NULL. Did you change the 'Save Session State' option to 'Yes'?

  • HT1918 I have several old email addresses and accounts with itunes where the email is no longer working, and i have forgotten my password,  how do i activate the songs?

    I have several old email addresses and accounts with itunes where the email is no longer working, and i have forgotten my password,  how do i activate the songs

    Welcome to the Apple Community.
    The following article(s) may help you.
    Look up your old and forgotten Apple ID

  • When syncing ipod touch with mac, where are my contacts and notes stored on the computer?

    I lost all the notes on my ipod touch..
    When syncing the ipod touch with mac, where are these files stored.
    i.e. contacts and notes?

    It's all stored here.
    User > Library > Application Support > MobileSync > Backup
    Basic troubleshooting steps  
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 
    Got problems with your Apple iDevice-like iPhone, iPad or iPod touch? Try Troubleshooting 101
     In Memory of Steve Jobs 

  • How to create a procedure to output REF CURSOR with any WHERE clause?

    I have an requirement like this: I have huge query which need to reuse in my code more than 10 times. This SQL has about 50 lines. Thing is for those 10 odd times sometimes the WHERE clause changes (columns are the same). So I cannot create a view since SQL is not static.
    I thought of writing a procedure with a WHERE_CLAUSE input para. I output a sys refcursor by adding the where clause. But I can't do it since you cannot add a where clause like that.
    i.e.
    PROCEDURE dynamyic_query (p_where_clause IN VARCHAR2, p_out_query OUT SYS_REFCURSOR ) IS
    BEGIN
      OPEN p_out_query FOR SELECT ......... FROM table WHERE || ' ' || p_where_clause;
    END;The above gives error.
    How to handle a situation like this???? Any help would be greatly appreciated.

    I tried this method:
    I created a table tab_test which has these records:
    TNAME                          TABTYPE    CLUSTERID                                                                                                                                                                  
    ABS_V4_P_ERROR_MESSAGES        TABLE                                                                                                                                                                                  
    ABS_V4_P_ORG_PARAM             TABLE                                                                                                                                                                                  
    ABS_V4_P_PARAMETER             TABLE                                                                                                                                                                                  
    ABS_V4_P_SYS_PARAM             TABLE                                                                                                                                                                                  
    ACCINTERFACE_PARAMETERS        TABLE                                                                                                                                                                                  
    ACCOUNTS                       TABLE                                                                                                                                                                                  
    ACCOUNT_EXTRACT_PERIODS        TABLE                                                                                                                                                                                  
    ACCOUNT_EXTRACT_PERIODS#       TABLE                                                                                                                                                                                  
    ACCOUNT_EXTRACT_PERIODS_1      TABLE                                                                                                                                                                                   Now I create this proc:
    PROCEDURE FORMS_TEXT_DYN_SQL_TEST(p_where_cluase IN VARCHAR2, p_out_cursor OUT SYS_REFCURSOR) IS
      v_stmt VARCHAR2(1000);
    BEGIN
      v_stmt := 'SELECT tname FROM tab_test WHERE tname LIKE ''%ABS_V4%'' AND tabtype = :x';
      OPEN p_out_cursor FOR v_stmt using p_where_cluase;
    END;I create this code block and run it:
    declare
      v_tname varchar2(200);
      out_cursor sys_refcursor;
    begin
      forms_text_dyn_sql_test('TABLE', out_cursor );
      LOOP
        fetch out_cursor INTO v_tname;
        exit when out_cursor%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(v_tname);
      END LOOP;
    end;
    /I get correct output:
    ABS_V4_P_ERROR_MESSAGES
    ABS_V4_P_ORG_PARAM
    ABS_V4_P_PARAMETER
    ABS_V4_P_SYS_PARAMHowever, when I change the proc like this:
    PROCEDURE FORMS_TEXT_DYN_SQL_TEST(p_where_cluase IN VARCHAR2, p_out_cursor OUT SYS_REFCURSOR) IS
      v_stmt VARCHAR2(1000);
    BEGIN
      v_stmt := 'SELECT tname FROM tab_test WHERE tname LIKE ''%ABS_V4%'' AND :y';
      OPEN p_out_cursor FOR v_stmt using p_where_cluase;
    END;And run this code block:
    declare
      v_tname varchar2(200);
      out_cursor sys_refcursor;
    begin
      forms_text_dyn_sql_test(' 1 = 1 ', out_cursor );
      LOOP
        fetch out_cursor INTO v_tname;
        exit when out_cursor%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(v_tname);
      END LOOP;
    end;
    /I get error:
    [1]: (Error): ORA-00920: invalid relational operator ORA-06512: at "ABS.FORMS_TEXT_DYN_SQL_TEST", line 6 ORA-06512: at line 5Looks like you can only put column_name = :z, column_name = :y type values. You cannot it seems replace it with any WHERE CLAUSE????

  • Dynamic select query with dynamic where condition

    Hi all,
    I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.
    Please advice, if there is any other way to achieve this requirement.
    Thanks,
    Sanket Sethi
    Code***************
    PARAMETERS: p_tabnam      TYPE tabname,
                p_selfl1      TYPE edpline,
                p_value       TYPE edpline,
                p_where1      TYPE edpline .
    DATA: lt_where    TYPE TABLE OF edpline,
          lt_sel_list TYPE TABLE OF edpline,
          l_wa_name   TYPE string,
          ls_where    TYPE edpline,
          l_having    TYPE string,
          dref        TYPE REF TO data,
          itab_type   TYPE REF TO cl_abap_tabledescr,
          struct_type TYPE REF TO cl_abap_structdescr,
          elem_type   TYPE REF TO cl_abap_elemdescr,
          comp_tab    TYPE cl_abap_structdescr=>component_table,
          comp_fld    TYPE cl_abap_structdescr=>component.
    TYPES: f_count TYPE i.
    FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
    *                <ls_outtab> TYPE ANY,
                    <l_fld> TYPE ANY.
    struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
    elem_type   ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
    comp_tab = struct_type->get_components( ).
    comp_fld-name = 'F_COUNT'.
    comp_fld-type = elem_type.
    APPEND comp_fld TO comp_tab.
    struct_type = cl_abap_structdescr=>create( comp_tab ).
    itab_type   = cl_abap_tabledescr=>create( struct_type ).
    l_wa_name = 'l_WA'.
    CREATE DATA dref TYPE HANDLE itab_type.
    ASSIGN dref->* TO <lt_outtab>.
    *CREATE DATA dref TYPE HANDLE struct_type.
    *ASSIGN dref->* TO <ls_outtab>.
    * Creation of the selection fields
    APPEND p_selfl1 TO lt_sel_list.
    APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
    ** Creation of the "where" clause
    *CONCATENATE p_selfl1 '= '' p_value ''.'
    *            INTO ls_where
    *            SEPARATED BY space.
    *APPEND ls_where TO lt_where.
    * Creation of the "where" clause
    APPEND p_where1 TO lt_where.
    * Creation of the "having" clause
    l_having = 'count(*) >= 1'.
    * THE dynamic select
    SELECT          (lt_sel_list)
           FROM     (p_tabnam)
           INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>.
    *       WHERE    (lt_where).

    Hi Sanket,
    The above given logic of mine works for you, put the code in the If condition and try-
    just like below:
    IF NOT P_EBELN IS INITIAL.
    lt_where = '& = ''&'' '.
    REPLACE '&' WITH p_ebeln INTO lt_where.
    REPLACE '&' WITH field_value INTO lt_where.
    SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
    FROM (p_tabnam)
    WHERE (lt_where).
    ENDIF.
    thanks\
    Mahesh

  • "create columns with a where clause" in BMM

    Hi All,
    I have a question about OBI EE Meta data layer.
    We have OBIEE sitting on a Data Warehouse with a star schema.
    Our Fact table holds the following fields...
    EmployeeID
    CompanyID
    Measure ID
    Measure Name
    MEASURE
    This is what we have in the physical layer, BMM layer and the presentation layer but I want to be able to "create columns with a where clause"
    So my fact table in the presentation layer would look like this
    Amount Sold
    Unit Cost
    Company Amount
    I thought I could just create a logical column with
    Amount Sold = Measure
    where Measure Name = "Amount Sold"
    But I can't seem to find any to do that.
    Any ideas?
    Thanks

    Or you simply map your measure in the Logical Table source as something like :
    CASE WHEN MEASURE_NAME = 'Amount Sold' THEN MEASURE ELSE 0 END.
    You need to decide if you want the where clause adding in the Logical table source (be careful you will need a seperate LTS for each measure, this will mean more than one SQL being fired when you have more than one measure in the report).
    Or you go with this case method on each measure, be able to have all the measures mapped in 1 LTS, include all those in the report and they will be retrieved by one SQL block.

  • Using SAMPLE with a WHERE clause

    (Oracle 9iR2)
    I am using the SAMPLE keyword in a SELECT statement with a WHERE clause. Is the sample extracted before or after applying the WHERE clause?
    For example, if I have the statement:
    SELECT emp_id FROM employees SAMPLE(10)
    WHERE salary > 50000;
    Does the database first extract a 10% sample of all the rows and then apply the salary filter on the sample (meaning it's possible that no rows are returned even though there are rows with salary > 50000)? Or does it return a 10% sample of the rows that meet the filter condition (meaning rows will always be returned as long as there are rows with salary > 50000)?

    The sample is extracted before the where clause:
    SQL> drop table sample_test;
    Table dropped.
    SQL> create table sample_test (id number, salary number);
    Table created.
    SQL>
    SQL> begin
    2 for i in 1..99 loop
    3 insert into sample_test values (i, 100);
    4 end loop;
    5
    6 insert into sample_test values (100, 1000);
    7 end;
    8 /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> select * from sample_test sample(5)
    2 where salary > 100;
    no rows selected

  • How to make link between xcelsius components with sap data using Web servic

    Hi all,
    I have a doubt regarding connection between Xcelsius components and SAP data.
    I created one Web service using Function module and made a connection between xcelsius and that web service using binding URL. It shows imput and output parameters perfectly.
    But I cant get any idea as to how to connect Xcelsius components with these parameters.
    Can anybody help me out..
    please its urgent.
    Thanks,
    Simadri

    Have you bound your output parameters to ranges of cells? Select the item, then click the icon to the right of the Insert In: box and select the cells.
    Add a spreadsheet component to your chart and bind it to the cells, then preview the model. Do you see the data coming through?
    If you do, then you can click File > Snapshot > Export Excel Data. Then close Preview mode, and import data from spreadsheet and select the sheet you just exported. This gives you real data to work with when designing the dashboard.
    Hope that helps.

  • Loop with dynamic where clause

    hi,
        In a program we need to use a loop into an internal table with a where condition is decided on run time.
    "Select" from database table is using dynamic where clause and it is working fine.
    For the loop part does any one have any idea on this? if we can have dynamic where clause in a loop into internal tab?
    Thanks

    Hi,
    You can't use 'loop where' dynamically  .
    Have you already tried to use Ranges and CHECK statement?
    Like:
    First mount range options;
    Loop at <table>.
    Check using the range.
    endloop.
    Maybe it's works for you !!
    Marcelo Ramos

  • How to use Flex Components with Flash?

    Hi!!
    I found a lot of very useful components in the web, but they are all for  Flex, is it possible to use Flex Components with Flash IDE?
    Thanks !!!
    jenry
    PS: this is one of the components I need to use (a tree with checkbox  nodes)
    http://www.sephiroth.it/file_detail.php?pageNum_comments=30&id=151
    another one:
    http://www.darronschall.com/weblog/2006/09/a-flex-2-checked-tree-control-component.cfm

    Flex components are delivered as SWCs just like Flash components, but the
    SWC format is incompatible with the Flash IDE.
    Also, the default fl.. components in the Flash IDE are incompatible with
    Flex components.
    You should be able to load a Flex SWF into a Flash SWF as long as you aren't
    using fl.. components in the Flash SWF.  If the Flex SWF overlays things
    in your Flash SWF then it might block interaction, but otherwise it
    shouldn't.  I don't think the statement you quoted is true for all
    configurations.
    But loading a Flex SWF into a Flash SWF isn't going to help you use those
    Flex components from your Flash IDE.  Try Flash Builder 4 to build out the
    Flex portion of your application.  I haven't tried it myself, but it I think
    it is supposed to have better integration with Flash.

  • Facing problems in Registering AIA Components with OSB

    Hi all,
    I am trying to implement AIA on OSB for that as an initial step I am trying to Register AIA Components with OSB.
    In this step I am facing problems getting 705 conflicts removing these conflicts manually is a huge task .
    Can anyone suggest me good approach or if any one has removed AIA components jar please share with me.
    Thanks
    Phani

    Hi Madhavi,
    You said:
    OMB+> OMBALTER LOCATION 'TEST_LOCATION' SET PROPERTIES ( HOST, PORT, SERVICE_NAME , SCHEMA, CONNECT_AS_USER,PASSWORD, VERSION, UOID,DATABASE_NAME) \
    VALUES ( '$HOST', $PORT,'$SERVICE', '$TgtDBUser', '$TgtDBUser', 'TgtDBPWD','$
    dbversion','true','$SERVICE');
    Did you leave out the "$"-character for the TgtDBPWD variable in purpose? Could this be the source of your problem?
    Regards,
    Ed

Maybe you are looking for

  • Cisco 3945- boot up fails with no error

    Greetings, Just throwing it out there to see if anyone throw some ideas my way.  I recently sent a working/tested Cisco 3945 ISR router out to a office for redundancy.  Before I did that, I removed WLAN controller and slot module, 1xVWIC2 T1 and 1xVI

  • Safari crashing after most recent update

    Hey there... I'm particularly computer literate, but since I did the update on both my older desktop iMac and my new MacbookPro, when I open up Safari (esp. sites like TMZ, but even the Apple homepage) it just stalls then crashes. Here is the latest

  • Using network data to detect DPI

    "Network transparency cuts both ways. It can be exploited to engage in surveillance of Internet service providers as well as Internet users. In order to better understand DPI use and the scope of its deployment, the project makes use of crowdsourced

  • Simple printing of digits on numeric panel

    HELLO, I am new to lab windows CVI, all I have to do this,just printing number on numeric panel using start and stop button.  but I am not getting desired result  before pressing starting button my timer starts automatically,number displayed  on scre

  • Listing Employee Education and Language Information.

    I'm writing a web application that uses PS to modify employee information, specifically their education and language information. Basically, I'm using a JpmPersonProfile object to get a JpmPersonProfileJpmJpCatTypeJpmJpCritmVwCollection object. Unles