Select only records where column values are not all equal to zero

Hi everyone, this seems so easy but it's got me stumped on finding a clean, easy way to accomplish this. I'm sure when someone responds, I'll kick myself. So, assume the following is what I've got:
with mytable as (
select 'Type 1' as itemtype, 'JAN' as monthname, 0 as theval from dual union all
select 'Type 1' as itemtype, 'FEB' as monthname, 1 as theval from dual union all
select 'Type 1' as itemtype, 'MAR' as monthname, 5 as theval from dual union all
select 'Type 1' as itemtype, 'APR' as monthname, 1 as theval from dual union all
select 'Type 1' as itemtype, 'MAY' as monthname, 4 as theval from dual union all
select 'Type 1' as itemtype, 'JUL' as monthname, 0 as theval from dual union all
select 'Type 1' as itemtype, 'AUG' as monthname, 0 as theval from dual union all
select 'Type 1' as itemtype, 'SEP' as monthname, 1 as theval from dual union all
select 'Type 1' as itemtype, 'OCT' as monthname, 7 as theval from dual union all
select 'Type 1' as itemtype, 'NOV' as monthname, 1 as theval from dual union all
select 'Type 1' as itemtype, 'DEC' as monthname, 2 as theval from dual union all
select 'Type 2' as itemtype, 'JAN' as monthname, 0 as theval from dual union all
select 'Type 2' as itemtype, 'FEB' as monthname, 0 as theval from dual union all
select 'Type 2' as itemtype, 'MAR' as monthname, 0 as theval from dual union all
select 'Type 2' as itemtype, 'APR' as monthname, 0 as theval from dual union all
select 'Type 2' as itemtype, 'MAY' as monthname, 0 as theval from dual union all
select 'Type 2' as itemtype, 'OCT' as monthname, 0 as theval from dual union all
select 'Type 2' as itemtype, 'NOV' as monthname, 0 as theval from dual union all
select 'Type 2' as itemtype, 'DEC' as monthname, 0 as theval from dual
select
  itemtype,
  sum (case monthname when 'JAN' then theval else 0 end) as JAN,
  sum (case monthname when 'FEB' then theval else 0 end) as FEB,
  sum (case monthname when 'MAR' then theval else 0 end) as MAR,
  sum (case monthname when 'APR' then theval else 0 end) as APR,
  sum (case monthname when 'MAY' then theval else 0 end) as MAY,
  sum (case monthname when 'JUN' then theval else 0 end) as JUN,
  sum (case monthname when 'JUL' then theval else 0 end) as JUL,
  sum (case monthname when 'AUG' then theval else 0 end) as AUG,
  sum (case monthname when 'SEP' then theval else 0 end) as SEP,
  sum (case monthname when 'OCT' then theval else 0 end) as OCT,
  sum (case monthname when 'NOV' then theval else 0 end) as NOV,
  sum (case monthname when 'DEC' then theval else 0 end) as DEC
from mytable
group by itemtype
order by itemtypeI need an outer query around this one or something that will only select "Type 1"... i.e., if all of the months are each equal to zero, don't include the record in the result set.
Summing them to get a total of zero is not an option, as I could have -15 and +15 in different columns, in which case, that record would need to be displayed.
Something as simple as... "where not (oct = 0 and nov = 0 and dec = 0...) at the end is all I seem to need. I've thought about adding a case clause for each column, but that doesn't seem very efficient. Ideas?
Thanks in advance!
Mark
Edit... I know the following will work using the MINUS operator, but my real query is really huge, and I don't want to have to write it twice...
{code}
select
itemtype,
sum (case monthname when 'JAN' then theval else 0 end) as JAN,
sum (case monthname when 'FEB' then theval else 0 end) as FEB,
sum (case monthname when 'MAR' then theval else 0 end) as MAR,
sum (case monthname when 'APR' then theval else 0 end) as APR,
sum (case monthname when 'MAY' then theval else 0 end) as MAY,
sum (case monthname when 'JUN' then theval else 0 end) as JUN,
sum (case monthname when 'JUL' then theval else 0 end) as JUL,
sum (case monthname when 'AUG' then theval else 0 end) as AUG,
sum (case monthname when 'SEP' then theval else 0 end) as SEP,
sum (case monthname when 'OCT' then theval else 0 end) as OCT,
sum (case monthname when 'NOV' then theval else 0 end) as NOV,
sum (case monthname when 'DEC' then theval else 0 end) as DEC
from mytable
group by itemtype
minus
select
itemtype,
jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec
from (
select
itemtype,
sum (case monthname when 'JAN' then theval else 0 end) as JAN,
sum (case monthname when 'FEB' then theval else 0 end) as FEB,
sum (case monthname when 'MAR' then theval else 0 end) as MAR,
sum (case monthname when 'APR' then theval else 0 end) as APR,
sum (case monthname when 'MAY' then theval else 0 end) as MAY,
sum (case monthname when 'JUN' then theval else 0 end) as JUN,
sum (case monthname when 'JUL' then theval else 0 end) as JUL,
sum (case monthname when 'AUG' then theval else 0 end) as AUG,
sum (case monthname when 'SEP' then theval else 0 end) as SEP,
sum (case monthname when 'OCT' then theval else 0 end) as OCT,
sum (case monthname when 'NOV' then theval else 0 end) as NOV,
sum (case monthname when 'DEC' then theval else 0 end) as DEC
from mytable
group by itemtype
where ( oct = 0 and nov = 0 and dec = 0 and jan = 0 and feb = 0 and mar = 0
and apr = 0 and may = 0 and jun = 0 and jul = 0 and aug = 0 and sep = 0
order by itemtype
{code}
Edit again... Ok, I guess I'm answering my own question here, but I think using a WITH clause to write the main query once and then selecting * from it twice using the MINUS operator in between where the second query has where (oct = 0, etc.) is what I need. If anyone else has better suggestions, please do let me know! Here's the pseudo logic for what I've come up with so far...
{code}
WITH mainquery as (select everything)
select * from mainquery
minus
select * from mainquery where (oct = 0, nov = 0, etc...)
{code}
Thanks again!
Mark
Edited by: user455268 on Mar 1, 2012 7:13 PM
Edited by: user455268 on Mar 1, 2012 7:16 PM

Hi,
You can do that with a HAVING clause:
select
  itemtype,
  sum (case monthname when 'JAN' then theval else 0 end) as JAN,
  sum (case monthname when 'FEB' then theval else 0 end) as FEB,
  sum (case monthname when 'MAR' then theval else 0 end) as MAR,
  sum (case monthname when 'APR' then theval else 0 end) as APR,
  sum (case monthname when 'MAY' then theval else 0 end) as MAY,
  sum (case monthname when 'JUN' then theval else 0 end) as JUN,
  sum (case monthname when 'JUL' then theval else 0 end) as JUL,
  sum (case monthname when 'AUG' then theval else 0 end) as AUG,
  sum (case monthname when 'SEP' then theval else 0 end) as SEP,
  sum (case monthname when 'OCT' then theval else 0 end) as OCT,
  sum (case monthname when 'NOV' then theval else 0 end) as NOV,
  sum (case monthname when 'DEC' then theval else 0 end) as DEC
from mytable
group by itemtype
HAVING      MIN (theval)     != 0
OR      MAX (theval)     != 0
order by itemtype
;If the values are all 0, then the MIN and the MAX will both be 0.
If either the MIN or the MAX is not 0, then the values are not all 0.
This assumes that the combination (itemtype, monthname) is unique, as it is in your sample data.
If that's not the case, start with a subquery that GROUPs BY itemtype, monthname, so that, when you get to the main query, that combination will be unique.

Similar Messages

  • Possible Bug: Rows & Column values are not honoured in panel form layout

                      <af:panelFormLayout id="pfl10"
                                                                                    binding="#{backingBeanScope.backing_AssemblyStarts.pfl10}"
                                                                                    rows="1" maxColumns="4"
                                                                                    fieldWidth="66%" labelWidth="34%">
    Even after Running, saving, deploying it shows the same 4 rows...
    I wanted to include image as well... how to insert image in the question ? I drag and drop image on this editor, but it did not allow me to submit the question.
    Here is the image I uploaded on google drive...
    https://docs.google.com/file/d/0B7Po4hB-u4BgS3ExWG5YdjRIS1E/edit?usp=sharing
    Thanks
    Rahul

    It is confirmed now...... I checked that this "Panel Form Layout" does not work on popup. It does not change rows and columns at all..... !!!!
    It works fine on the normal page... but not on the popup.
    Is it Bug or it is shortcoming of 'panel form layout' ???
    Anybody listening ??  anybody faced this earlier ???
    Thanks
    Rahul

  • Genres are not all adding to ipod 7 on synching

    I am new to ipod nano.  I have downloaded music onto my pc using itunes.  I connected ipod and synched.  However not all genres eg easy listening appear on my ipod.  Please advise.

    Hi,
    You can do that with a HAVING clause:
    select
      itemtype,
      sum (case monthname when 'JAN' then theval else 0 end) as JAN,
      sum (case monthname when 'FEB' then theval else 0 end) as FEB,
      sum (case monthname when 'MAR' then theval else 0 end) as MAR,
      sum (case monthname when 'APR' then theval else 0 end) as APR,
      sum (case monthname when 'MAY' then theval else 0 end) as MAY,
      sum (case monthname when 'JUN' then theval else 0 end) as JUN,
      sum (case monthname when 'JUL' then theval else 0 end) as JUL,
      sum (case monthname when 'AUG' then theval else 0 end) as AUG,
      sum (case monthname when 'SEP' then theval else 0 end) as SEP,
      sum (case monthname when 'OCT' then theval else 0 end) as OCT,
      sum (case monthname when 'NOV' then theval else 0 end) as NOV,
      sum (case monthname when 'DEC' then theval else 0 end) as DEC
    from mytable
    group by itemtype
    HAVING      MIN (theval)     != 0
    OR      MAX (theval)     != 0
    order by itemtype
    ;If the values are all 0, then the MIN and the MAX will both be 0.
    If either the MIN or the MAX is not 0, then the values are not all 0.
    This assumes that the combination (itemtype, monthname) is unique, as it is in your sample data.
    If that's not the case, start with a subquery that GROUPs BY itemtype, monthname, so that, when you get to the main query, that combination will be unique.

  • Qualifier values are not part of a qualified lookup record

    Hi
         I am getting the exception "Qualifier values are not part of a qualified lookup record" when I serach for a record in the Qualified table. The Table has both Qualfier and non-Qualifier fields, but all are of type display fields.
    My question is If the filed is of type Qualifier then is it mandatory that it should be non-display Field?
    if  not can any one suggest me to get the record.
    If we make Qualifier fields as NON-Dispaly fields in repository then it is working fine.
    Here with I am providing the code
                   Search serarch = new Search(repoSchemaCmd.getRepositorySchema().getTable("QT_NOTES").getId());
                   serarch.addSearchItem(new FieldSearchDimension(repoSchemaCmd.getRepositorySchema().getFieldId("QT_NOTES","USER_PMF_ID")),new TextSearchConstraint("test", TextSearchConstraint.EQUALS));
                   ResultDefinition rd =new ResultDefinition(repoSchemaCmd.getRepositorySchema().getTable("QT_NOTES").getId());
                   //Returns the array of IDs for all display fields associated with the table
                   rd.setSelectFields(repoSchemaCmd.getRepositorySchema().getTableSchema("QT_NOTES").getDisplayFieldIds());
                   RetrieveLimitedRecordsCommand retrievedRecords =new RetrieveLimitedRecordsCommand(conn);
                   retrievedRecords.setSession(userSessionID);
                   retrievedRecords.setSearch(serarch);
                   //retrievedRecords.setIds(RID);
                   retrievedRecords.setResultDefinition(rd);
                   try {
                        retrievedRecords.execute();
                   } catch (CommandException e) {
                        throw new CommandException(e);
    Regards,
    Sandeep.

    Hi Sandeep
    I have a similar problem, would like to know what is the resolution to this issue.
    Regards
    Dilip

  • After doing the recording for transaction fpcj, the values are not being se

    after doing the recording for transaction fpcj, the values are not being sent to the g/l.

    HI,
      When you are recording.. you might be creating the values... ensure that they are updated into the GL before u write program. I doubt you might have missed the save ..
    Thanks
    Mahesh

  • Copying is incomplete because specified condition record key values are not

    Hi All
    The User wanted to create new condition records by copying the existing condition records.
    For the same, I have maintained coping rule for condition.
    After that when I am trying to copy the existing condition record, I am faced with an error
    "copying is incomplete because specified condition record key values are not compatible"
    Please help me to solve this error. This of severty HIGH.
    PLEASE GIVE ME AN IMMEDIATE SOLN
    THANKS
    Kumar

    Hi, Is the source key combination same as target key combination? seems like that's the issue.
    Regards
    RS.

  • (XSRWLD06) A column value is not a valid member of its target dimension

    We are facing a strange issue that all the records gets rejected when attempted to load the cube. The error message is - (XSRWLD06) A column value is not a valid member of its target dimension
    This cube is simple and has only one dimension and one measure. The dimension has only 2 records and mapping appears to be correct.
    Really confused and unable to find the cause of the problem. Pls can you help
    Query used to populate the dimension
    ==========
    SELECT DISTINCT /*+ bypass_recursive_check */ T1."ACCFLAG_DESC" ALIAS_3, T1."ACCFLAG_DESC" ALIAS_4, T1."ACCFLAG_DESC" ALIAS_5, NULL ALIAS_6, 3 ALIAS_7 FROM NEDDWOWNER."OWNERSHIP_ACCOUNTS" T1 WHERE (T1."ACCFLAG_DESC" IS NOT NULL) UNION SELECT DISTINCT /*+ bypass_recursive_check */ T2."ACCFLAG_DESC" ALIAS_8, CAST (NULL AS VARCHAR2 (60) ) ALIAS_9, T2."ACCFLAG_DESC" ALIAS_10, NULL ALIAS_11, 0 ALIAS_12 FROM NEDDWOWNER."OWNERSHIP_ACCOUNTS" T2 WHERE (T2."ACCFLAG_DESC" IS NOT NULL) ORDER BY 1 ASC NULLS LAST
    ===========
    Query used to populate the cube
    ==========
    SELECT /*+ bypass_recursive_check cursor_sharing_exact no_expand no_rewrite */ T5_ACCFLAG_DESC ALIAS_13, SUM(T8_ES_CBSCCO_AJ_GBP) ALIAS_14 FROM ( SELECT /*+ no_rewrite */ T1."OWA_SEQ_ID" T8_OWA_SEQ_ID, T1."ES_CBSCCO_AJ_GBP" T8_ES_CBSCCO_AJ_GBP FROM NEDDWOWNER."VW_ACCOUNTS_MON_CUB_LOAD" T1 ) T8, ( SELECT /*+ no_rewrite */ T1."OWA_SEQ_ID" T5_OWA_SEQ_ID, T1."ACCFLAG_DESC" T5_ACCFLAG_DESC FROM NEDDWOWNER."OWNERSHIP_ACCOUNTS" T1 ) T5 WHERE (T8_OWA_SEQ_ID = T5_OWA_SEQ_ID) GROUP BY (T5_ACCFLAG_DESC) ORDER BY T5_ACCFLAG_DESC ASC NULLS LAST
    ===========
    Rejected Record
    Consumption 0
    Production 0
    Error:
    (XSRWLD06) A column value is not a valid member of its target dimension.

    Hi - This is still unanswered. Will the datatype of the source column mapped to the member and the fact table create the problem? As we are in the middle of evaluating different OLAP products, any inputs on the issue, will be really helpful...

  • Grand total values are not matching with Detail report

    Report has grand totals and when I drill to the detail report, grand total values are NOT matching with parent report totals, I did some analysis but I'm clueless on this issue.
    Please provide your thoughts and insight on this issue..
    Thanks

    is your summary and detail reports hitting different facts, like summary hitting aggregate and detail report hitting it's corresponding detail level fact..?
    if then,
    From Front-end:
    Fix the filter values in detail report that are passing from master report then try delete each columns then check the grand total. If you found your values is matching by deleting particular column then you need to investigate what is the issue around with that dimension table..
    From Database side:
    1. check first aggregate table has proper aggregate data of it's detail..
    2. Take the detail report obiee generated query and try to comment each dimension table and it's corresponding joins to the facts, (before, this delete all the dimensional columns and other measures from select statement and put only that measure where you are getting wrong value, so that you need not to comment all the select and group by columns which saves your time.. ). Need to check by commenting each dimensional wid and it's table from clause, if you found that values is matching then there is some problem with wid columns data population in your ETL.
    Is that BI-Apps project?
    btw, whtz ur name?

  • Values are not populating...

    After selecting the data from LOV the values are not populating in the respective fields.
    i've checked the 'LOV' no problem in that,but im think below coding have a problem.
    declare
         b boolean;
    begin
         :global.job:=null;
         clear_form(no_validate);     
         b:=show_lov('view');
         :GLOBAL.ADDNEW1:=0;
    --     go_block('JOB_CARD_MAIN');
         GO_ITEM('JOB_CARD_MAIN.BRANCH_CODE');
         set_block_property('job_card_main',default_where,'job_no='||chr(39)||:job_card_main.job_no||chr(39));
         execute_query(no_validate);------after this line get execute the values get disappear from the field
         insert into da.mylog(username,tname,mdate,oper) values(user(),'Job Creation',sysdate,'S');
         commit;
    end;
    Pls help..

    Which trigger do you have this code in? I'm guessing it is a Key-ListVal trigger.
    Have you tested the WHE RE clause in SQL*Plus to ensure it returns a record set? Most likely, the query returns no rows which could explain why the block is empty. Also, why are you clearing the entire Form instead of just the JOB_CARD_MAIN data block? Perhaps you should try:
    Go_Block('JOB_CARD_MAIN');
    Clear_Block(NO_VALIDATE);Also, the EXECUTE_QUERY built-in does not have a NO_VALIDATE parameter. It only supports the following parameters:
    ALL_RECORDS
    FOR_UPDATE
    or the combination of the two (ALL_RECORDS,FOR_UPDATE). It also allows you to set the Locking mechinism by passing the parameter NO_WAIT.
    Just a suggestion, try your query in SQL*Plus to make sure it produces a record set and Comment out all the extra stuff in your code and only keep the SHOW_LOV, CLEAR_BLOCK, SET_BLOCK_PROPERTY and EXECUTE_QUERY to see if a row is returned. If yes, then add the rest of your code back one line at a time.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Stcok type H values are not added into report

    Hello all,
    I am facing problem with inventory management.
    Here we have nearly 15 plants.  10 are already there and 5 are newly added in the last month.
    For the previous 10 plants we are getting the valuated stock perfectly, but i am checking for the remaining 5 new plants data is mismatching.
    while comparing the values from R/3 (MB5B) to the BW query values are different.  So i have checked the contents of Cube.
    There i found a pecular thing that some records having Movement type 641 and Stock Type H. These values are not getting cumulated in the report.  Only these values are coming for the new 5 plants.
    I have already checked the Snotes 589024, 417703.
    Please suggest me how to overcome from this issue.
    Regards
    Sankar

    Hi,
    Thanks for your reply.
    As I already said Stock type is defined as same as the previous plants.  But still we are not able to get the data in the query.
    In the cube level I am able to see the data, but when we are going for the report then we are not getting the values which are present in the cube where Stock Type is H.
    Please suggest on ths.
    Regards
    Sankar

  • Concatenating column values does not work (in SQLplus)

    I entered the following command in SQLplus and expected to get a string where all column values are (comma) concatenated:
    select ''||username||','||'' from dba_users;
    Unfortunatly instead of
    SYSTEM,SYS,ANONYMOUS,XDB,.....
    all users were listed in a column of a result table.
    How else can I concat them as intended
    Peter

    Hi,
    That's called "String Aggregation".
    Starting in Oracle 11.2, the function LISTAGG does that.
    AskTom:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402
    shows several different ways to do it, for versions 9 and up.
    I recommend the first one, the user-defined function STRAGG, which is similar to LISTAGG, and which you can copy from that page.
    Once you have STRAGG installed, your query is simply
    SELECT    STRAGG (username)     AS all_usernames
    FROM      dba_users
    ;On Oracle 10 (and up) you may have a similar function, WM_CONCAT (owned by WMSYS), already installed.
    WM_CONCAT is not documented, so you may not want to use it in your Production applications.
    Another good site concerning String Aggregation is
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    If you're wondering why your original query didn't do what you hoped:
    SELECT  ...
    FROM    table_x;(withoiut a WHERE clause or any other clauses) is guaranteed to produce on row of output for every row in table_x. It doesn't matter what is in the SELECT clause; there will always be one output row fro every original row.

  • Column Heading are not displayed in ALV Report using CL_SALV_DISPLAY?

    Hi,
       I am using CL_SALV_DISPLAY class to display data. I Created an Internal Table Dynamically based fieldcatalog which was prepared based data at run time. When i displayed data using CL_SALC_DISPALY data is display in output but column headings are not displayed.
    can anyone suggest me how to display heading in ALV using CL_SALV_DISPLAY class, My code is
          CLASS lcl_report DEFINITION
    CLASS lcl_report DEFINITION.
      PUBLIC SECTION.
        METHODS:
          display  IMPORTING l_table  TYPE string
                             l_fcat   TYPE string.
    ENDCLASS.                    "lcl_report DEFINITION
          CLASS lcl_report IMPLEMENTATION
    CLASS lcl_report IMPLEMENTATION.
      METHOD display.
        DATA: gr_table   TYPE REF TO cl_salv_table.
        DATA: gr_columns TYPE REF TO cl_salv_columns_table,
              gr_column  TYPE REF TO cl_salv_column_table,
              ls_fcat    TYPE slis_fieldcat_alv.
        DATA: gr_display TYPE REF TO cl_salv_display_settings.
        DATA: l_o_functions TYPE REF TO cl_salv_functions_list,
              l_field    TYPE string.
        FIELD-SYMBOLS : <fs_table>    TYPE STANDARD TABLE,
                        <ft_fcat>     TYPE STANDARD TABLE.
    Get the ALV object refering to the output table
        ASSIGN (l_table) TO <fs_table>.
        ASSIGN (l_fcat)  TO <ft_fcat>.
        TRY.
            cl_salv_table=>factory(
              IMPORTING
                r_salv_table = gr_table
              CHANGING
                t_table      = <fs_table> ).
          CATCH cx_salv_msg.                                "#EC NO_HANDLER
        ENDTRY.
    Add basic default functionality in the ALV report
    Functions
        l_o_functions = gr_table->get_functions( ).
        l_o_functions->set_all( abap_true ).
        gr_columns = gr_table->get_columns( ).
        gr_columns->set_headers_visible( abap_true ).
    Display the list
        gr_table->display( ).
      ENDMETHOD.                    "extract
    ENDCLASS.                    "lcl_report IMPLEMENTATION
    *& start-of-selection declaration
    START-OF-SELECTION.
      PERFORM :
      get store codes
        get_storecodes    USING      p_stfile
                          CHANGING   it_t001w,
      fetching mard data
        read_mard_data,
      preparing fieldcatalog for Final Data
        create_filedcat   USING      it_t001w
                                     it_site
                          CHANGING   it_fieldcat,
      preparing structure & internal table for Final Data
        create_final_table_structure  USING  it_fieldcat,
      prepare output data
        prepare_final_data.
    *& end-of-selection declaration
    END-OF-SELECTION.
      PERFORM :
      display data
        display_data    USING l_table
                              l_fcat.
    *&      Form  get_storecodes
    FORM get_storecodes  USING    p_p_stfile
                         CHANGING p_it_t001w  LIKE it_t001w[].
      DATA  :
    internal table for RAW
      lt_raw    TYPE truxs_t_text_data,
      rs_site   LIKE LINE OF rt_site,
      l_index   LIKE sy-tabix.
      FIELD-SYMBOLS :
    field symbol for it_t001w
      <fs_t001w>   LIKE LINE OF p_it_t001w.
    calling function module to get Stores Data from File
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
          i_line_header        = 'X'
          i_tab_raw_data       = lt_raw
          i_filename           = p_p_stfile
        TABLES
          i_tab_converted_data = p_it_t001w[]
        EXCEPTIONS
          conversion_failed    = 1
          OTHERS               = 2.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      SORT p_it_t001w BY werks.
      CLEAR rs_site.
      rs_site-sign   = 'I'.
      rs_site-option = 'EQ'.
      rs_site-low    = p_dccode.
      APPEND rs_site TO rt_site.
      IF it_t001w[] IS NOT INITIAL.
        LOOP AT p_it_t001w ASSIGNING <fs_t001w>.
          l_index   = sy-tabix.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = <fs_t001w>-werks
            IMPORTING
              output = <fs_t001w>-werks.
          MODIFY p_it_t001w FROM <fs_t001w> INDEX l_index.
          IF <fs_t001w>-werks GE s_site-low AND <fs_t001w>-werks LE s_site-high.
          append site to ranges
            CLEAR rs_site.
            rs_site-sign   = 'I'.
            rs_site-option = 'EQ'.
            rs_site-low    = <fs_t001w>-werks.
            APPEND rs_site TO rt_site.
            CONTINUE.
          ENDIF.
        ENDLOOP.
        SORT p_it_t001w BY werks.
        SORT rt_site.
      ENDIF.
    ENDFORM.                    " get_storecodes
    *&      Form  create_final_table_structure
    FORM create_filedcat   USING    p_it_t001w      LIKE it_t001w[]
                                    p_it_site       LIKE it_site[]
                           CHANGING p_it_fieldcat   LIKE it_fieldcat[].
      FIELD-SYMBOLS :
    field symbol for p_it_t001w
      <fs_t001w>     LIKE LINE OF p_it_t001w,
    field symbol for p_it_site
      <fs_site>      LIKE LINE OF p_it_site.
      DATA :
    fieldname
      l_fieldname    TYPE slis_fieldname,
    workarea for site ranges
      rs_site        LIKE LINE OF rt_site.
      CLEAR : l_fieldname, rs_site.
      l_fieldname    = p_dccode.
      PERFORM
    prepare fieldcatalog
      build_fieldcatalog USING :   'MTART'      'CHAR'        '5'  ,
                                   'MTBEZ'      'CHAR'        '25' ,
                                   'MATKL'      'CHAR'        '6'  ,
                                   'WGBEZ'      'CHAR'        '20' ,
                                   'MATNR'      'CHAR'        '18' ,
                                   'MAKTX'      'CHAR'        '30' ,
                                    l_fieldname 'CHAR'        '17' .
    create header for excel
      PERFORM create_excel_header USING  : 'Division',
                                           'Divsion Description',
                                           'MC Code',
                                           'MC Description',
                                           'Article',
                                           'Article Description',
                                            l_fieldname.
    loop for creating fieldcatalog
      LOOP AT it_site ASSIGNING <fs_site>.
        READ TABLE it_t001w ASSIGNING <fs_t001w> WITH KEY werks = <fs_site>-werks
                                                                  BINARY SEARCH.
        IF sy-subrc = 0           AND <fs_t001w> IS ASSIGNED AND
           <fs_site> IS ASSIGNED  AND <fs_site>-stock GT 0.
          CLEAR : l_fieldname, rs_site.
          l_fieldname    = <fs_site>-werks.
        prepare fieldcatalog
          PERFORM build_fieldcatalog USING : l_fieldname    'CHAR'   '17'.
        create header for excel
          PERFORM create_excel_header USING  l_fieldname  .
          CONTINUE.
        ENDIF.
      ENDLOOP.
      l_fcat  = 'it_fieldcat[]'.
    ENDFORM.                    " create_final_table_structure
    *&      Form  build_fieldcatalog
    FORM build_fieldcatalog  USING    p_fieldname      TYPE slis_fieldname
                                      p_datatype       TYPE datatype_d
                                      p_length         TYPE intlen.
      DATA : ls_fieldcat    LIKE LINE OF it_fieldcat.
      CLEAR  : ls_fieldcat.
      ls_fieldcat-fieldname   = p_fieldname.
      ls_fieldcat-datatype    = p_datatype.
      ls_fieldcat-intlen      = p_length.
      APPEND ls_fieldcat TO it_fieldcat.
    ENDFORM.                    " build_fieldcatalog
    *&      Form  create_final_table_structure
    FORM create_final_table_structure  USING    p_it_fieldcat.
    Create dynamic internal table and assign to FS
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fieldcat
        IMPORTING
          ep_table        = t_table.
      ASSIGN t_table->*  TO <ft_final>.
    ENDFORM.                    " create_final_table_structure
    *&      Form  create_excel_header
    FORM create_excel_header  USING    p_p_fieldname.
      DATA : ls_header  LIKE LINE OF it_header.
      CLEAR ls_header.
      ls_header-col_name  = p_p_fieldname.
      APPEND ls_header TO it_header.
    ENDFORM.                    " create_excel_header
    *&      Form  prepare_final_data
    FORM prepare_final_data .
      DATA          : l_matnr       LIKE g_matnr,
                      l_werks       LIKE g_werks,
                      l_index       LIKE sy-tabix.
      FIELD-SYMBOLS : <fs_mard>     LIKE LINE OF it_mard.
    Getting No. of Lines in IT_MARD internal table
      DESCRIBE TABLE it_mard LINES g_lines.
      LOOP AT it_mard ASSIGNING <fs_mard>.
        l_index    = sy-tabix.
        IF l_matnr IS INITIAL.
          l_matnr  = <fs_mard>-matnr.
          CLEAR : l_werks.
          l_werks    = <fs_mard>-werks.
          UNASSIGN : <fs_value>, <fs_final>.
        Create dynamic work area and assign to FS
          CREATE DATA t_line LIKE LINE OF <ft_final>.
          ASSIGN t_line->*   TO <fs_final>.
          ASSIGN COMPONENT 'MATNR'  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>        = <fs_mard>-matnr.
          ASSIGN COMPONENT l_werks  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>        = <fs_value> + <fs_mard>-labst.
        getting Article Type,MC & its Descriptions
          PERFORM get_other_data    USING     l_matnr
                                              l_werks.
        ELSEIF l_matnr <> <fs_mard>-matnr.
          APPEND <fs_final> TO <ft_final>.
          CLEAR l_matnr.
          l_matnr  = <fs_mard>-matnr.
          CLEAR : l_werks.
          l_werks    = <fs_mard>-werks.
          UNASSIGN : <fs_value>, <fs_final>.
        Create dynamic work area and assign to FS
          CREATE DATA t_line LIKE LINE OF <ft_final>.
          ASSIGN t_line->*   TO <fs_final>.
          ASSIGN COMPONENT 'MATNR'  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>        = <fs_mard>-matnr.
          ASSIGN COMPONENT l_werks  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>        = <fs_value> + <fs_mard>-labst.
        getting Article Type,MC & its Descriptions
          PERFORM get_other_data    USING     l_matnr
                                             l_werks.
        ELSE.
          CLEAR : l_werks.
          l_werks    = <fs_mard>-werks.
          ASSIGN COMPONENT l_werks  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>        = <fs_value> + <fs_mard>-labst.
        ENDIF.
        IF l_index = g_lines.
          APPEND <fs_final> TO <ft_final>.
        ENDIF.
      ENDLOOP.
      l_table  = '<ft_final>[]'.
    ENDFORM.                    " prepare_final_data
    *&      Form  get_other_data
    FORM get_other_data  USING    p_l_matnr
                                  p_l_werks.
      FIELD-SYMBOLS : <fs_mara>     LIKE LINE OF it_mara,
                      <fs_t023t>    LIKE LINE OF it_t023t,
                      <fs_t134t>    LIKE LINE OF it_t134t,
                      <fs_makt>     LIKE LINE OF it_makt.
      READ TABLE it_mara ASSIGNING <fs_mara> WITH KEY matnr = p_l_matnr.   " BINARY SEARCH.
      IF sy-subrc = 0 AND <fs_mara> IS ASSIGNED.
        ASSIGN COMPONENT 'MTART'  OF STRUCTURE <fs_final> TO <fs_value>.
        <fs_value>        = <fs_mara>-mtart.
        ASSIGN COMPONENT 'MATKL'  OF STRUCTURE <fs_final> TO <fs_value>.
        <fs_value>        = <fs_mara>-matkl.
        READ TABLE it_makt  ASSIGNING <fs_makt>  WITH KEY matnr =  <fs_mara>-matnr   BINARY SEARCH.
        IF sy-subrc = 0 AND <fs_makt> IS ASSIGNED.
          ASSIGN COMPONENT 'MAKTX'  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>        = <fs_makt>-maktx.
        ENDIF.
        READ TABLE it_t023t ASSIGNING <fs_t023t> WITH KEY matkl = <fs_mara>-matkl  BINARY SEARCH.
        IF sy-subrc = 0 AND <fs_t023t> IS ASSIGNED.
          ASSIGN COMPONENT 'WGBEZ'  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>      = <fs_t023t>-wgbez.
        ENDIF.
        READ TABLE it_t134t ASSIGNING <fs_t134t> WITH KEY mtart = <fs_mara>-mtart  BINARY SEARCH.
        IF sy-subrc = 0 AND <fs_t134t> IS ASSIGNED.
          ASSIGN COMPONENT 'MTBEZ'  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>      = <fs_t134t>-mtbez.
        ENDIF.
      ENDIF.
    ENDFORM.                    " get_other_data
    *&      Form  display_data
          text
    FORM display_data  USING    p_l_table
                                p_l_fcat.
      DATA:
    Variable for Object Creation
      o_report TYPE REF TO lcl_report.
      CREATE OBJECT o_report.
      o_report->display( EXPORTING l_table = p_l_table
                                   l_fcat  = p_l_fcat ).
    ENDFORM.                    " display_data

    I don't know how to read the code you pasted or I would have checked this myself.
    Do your fields in the internal table reference dictionary objects or elementary types? If not using dictionary types, the column names will be blank by default. If you can't change your fields to be dictionary types, you can try this to change the column names:
    I made a method inside my local class to add the names:
            call method set_colname
              EXPORTING iv_tab = alv_tab
                        iv_colid = 'xxxx'  "fieldname from the table
                        iv_stxt = text-t54
                        iv_mtxt = text-t55
                        iv_ltxt = text-t55.
    METHOD set_colname .
      data:
              alv_cols type REF TO cl_salv_columns_table,
              alv_col type REF TO cl_salv_column.
      TRY .
    *... Change fieldnames
            call METHOD iv_tab->get_columns RECEIVING value = alv_cols.
            call method alv_cols->get_column EXPORTING columnname = iv_colid RECEIVING value = alv_col.
            IF iv_stxt <> ''.
              CALL METHOD alv_col->set_short_text EXPORTING value = iv_stxt.
            ENDIF.
            IF iv_mtxt <> ''.
              CALL METHOD alv_col->set_medium_text EXPORTING value = iv_mtxt.
            ENDIF.
            IF iv_ltxt <> ''.
              CALL METHOD alv_col->set_long_text EXPORTING value = iv_ltxt.
            ENDIF.
       CATCH cx_salv_not_found.
      ENDTRY.
    ENDMETHOD. "set_colname

  • Delete records from tableA which are not in tableB

    Table A contains milions of records which is the best way to delete records from tableA which are not in tableB
    delete from tableA where empno not in (select empno from tableb)
    or
    delete from tableA where empno not exists (select empno from tableb
    where b.empno=a.empno)
    any help

    Hi
    If you can do this, do with this:
    create table tableC
    as select a.*
    from tableA a,
    (select empno from tableA
    minus
    select empno from tableB) b
    where a.empno = b.empno;
    drop table tableA;
    rename table tableC to tableA;
    Ott Karesz
    http://www.trendo-kft.hu

  • Screen values are not retained in Tcode BP, onclick of SAVE button

    Hi,
    In Tcode BP, I am selecting a Role with the Business Partner number. COMPANY CODE Push button on the Top is Enabled and Click on that.
    Enter the Company Code and provide the Account management tab by providing Reconciliation Acct 120113, Sort key as 035, Planning Group as E1. Go to Payment Transaction Tab, Enter the Payment terms as Z003, check Record payment history. Now, Click on SAVE Button on the TOP.
    The issue is that, The screen values are not retained in the Payment terms tab and Customer is not Created after saving of a BP Number which is related to a Customer.
    Regards,
    Deepthi.

    OSS Note 1254214 is applied and it is solved.

  • Parameter values are not showing in in the Organization Parameter form

    We have done a setup for an Inventory Organization.
    Everything was working fine.
    Values were showing everywhere.
    We have lot of transactions done in the org also.
    But suddenly yesterday when I was trying to open the Organization Parameter form for that specific organization, the form came up as blank and in the bottom the error is Query caused no records.
    I have checked data is there in the base table mtl_parameters.
    Value is coming for other organizations. Only one specific organization is having this issue.
    Even in Examine, I have taken the last query run on that form and ran the same in back end database, I can see all values are there in the database.
    But in frontend screen the values are not showing. even organization code also not showing.
    Navigation is: Inv Super user --> Setup --> Organization --> Parameter

    Have you checked Organization Access to ensure that no one restricted that org?
    Or shipping grants and roles?
    I think there are quite a few places that you can restrict access.

Maybe you are looking for

  • How to install SQL server 2008 express on Windows server 2008 R2 standard OS

    Hi, I have Windows server 2008 R2 Standard edition (64-bit) and trying to install SQL server 2008 express edition since I do not have SQL server 2008. When I install it I am unable to see Management Studio so I am trying to install management studio

  • How to load a .bmp image

    I'm using jdk1.4 and full-screen mode and I want to load an image but I don't manage to do it. how can I do it?

  • Problem importing packages via ICE??

    Hello, I am running Portal 6.0 on Windows Server. For one of the business package that is to be implemented in my Portal, i have to deploy two files as a pre-requisite that are associated with SAP Note 660777(https://service.sap.com/sap/support/notes

  • Unable to install upgrade

    After about 15 minutes of installing, updating, removing old files, etc, I get an error message "invalid drive F" All my iTunes are on drive G. Please help Joe

  • Errors integrating ABap system in SLD and PI

    Dears, I need informations about how to include an Abap system to the SLD , installaed on a different machine, and to make it available for the communication with a PI system. It's a silly question but I'm quite confused about the step should be perf