Count Index Internal Table or Select Statement

Hi All,
I wish to index and display my internal table. How do i do this? for example in my Internal Table I have the following data:-
Material-----Plant--Index
ABCD1--  1000--
1
ABCD1--  1000--
2
ABCD1--  1000--
3
ABCD2--  1000--
1
ABCD2--  1000--
2
Basically based on the unique values in Material and Plant an Index is generated? does that make sense?
Thanks
Adeel

Hi Guys,
Tried them it doesn't seem to work. I might try a different approach. i have the following loop.
What i am trying to do is bring the last price of an entry from itab and storing this in itab. Example
*Material----
Price----
Previous Price*
ABC1  -
£10----
£0 (as this is the first record)
ABC1  -
£30----
£10
ABC2  -
£15----
£30 *<----
ERROR*
ABC2  -
£45----
£15
So basically it is working exactly how i want it apart from when there is a new Material it isn't clearing the previous price even though there is no previous price....does that make sense? I was thinking of doing something via counting etc... but you guys might know an easier solution. Code is below how can i clear the previous price using the example above.
Please note this code does exactly what i want apart from clearing the previous price if it doesn;t exist.
LOOP AT itab.
  MOVE sy-tabix TO chnge.        " sy-tabix counts no of records.
  IF sy-tabix > 1.
    w_num = sy-tabix.
    w_num = w_num - 1.
  MOVE konp-kbetr TO itab-price.
  ENDIF.
ENDLOOP.

Similar Messages

  • Dynamic internal table from SELECT - statement ?

    Hi, is it possible to define an internal table just after a select statement is executed so that this internal table holds all the data that come back from the statement ?
    thanks in advance,

    Check the link -
    Re: Create Dynamic internal table
    Regards,
    Amit

  • Using Internal table in select queries

    Hi All,
    In the below mentioned code, i am reading an internal table and using the GUID i am fetching values from the database table and populating another internal table.
    SELECT  BUT000~PARTNER AS RESP_GROUP
          FROM BUT000 INTO CORRESPONDING FIELDS OF TABLE itab_Partner
          FOR ALL ENTRIES IN itab_PartnerGUID
          WHERE BUT000~PARTNER_GUID = itab_PartnerGUID-GUID.
    This code statement doesn't give any syntax error. But if i have to return values say from the itab as well as database table... then should it be something like...
    SELECT  itab_PartnerGUID-GUID as GUID
                   BUT000~PARTNER AS RESP_GROUP
          FROM BUT000 INTO CORRESPONDING FIELDS OF TABLE itab_Partner
          FOR ALL ENTRIES IN itab_PartnerGUID
          WHERE BUT000~PARTNER_GUID = itab_PartnerGUID-GUID.
    This statement throws an error saying "Unknown column name itab_PartnerGUID-GUID; not determined until runtime' .... what is the issue? can't i use the internal table that way? what is the right syntax to get the results.... please help....
    Ramya G

    Wow.. Chandrashekar.... that was an amazing catch in the code... you are rite.. when i am equating itab_PartnerGUID-GUID to BUT000PARTNER_GUID, i can as well use the BUT000PARTNER_GUID.... makes complete sense.....
    but there's a problem, its a mistake in the query.... the query shd actuall be this:
    SELECT <b>itab_PartnerGUID-GUID as GUID</b> 
         BUT000~PARTNER AS RESP_GROUP
    FROM BUT000 INTO CORRESPONDING FIELDS OF TABLE itab_Partner
    FOR ALL ENTRIES IN itab_PartnerGUID
    WHERE BUT000~PARTNER_GUID = <b>itab_PartnerGUID-PARTNER_GUID.</b>
    the internal table itab_PartnerGUID has 2 fields GUID and PARTNERGUID... in the where condition of the query i need to use PARTNERGUID, but in select i need to return GUID... how shd i do it? please help...

  • Filtering internal table using select-option values

    Hi,
    I got an internal table with select-option values. for eg.  it_perno with the values  I  BT    000160    000170.
    Now i got another second internal table which is have the person number. Now i need to filter this second internal table based on the values from the select option table. my question is
    i can collect all the values from 160 to 170 in a separate table by looping over the select option table. and then based on the values filter the second internal table person number.
    But what would be the case if the select option contains both intervals and multiple options. For eg.
    I BT 000160      000170.
    I EQ 000185.
    So can you suggest any good solution, that based on this select option table i need to filter the second internal table Person number.
    Thanks in advance.
    Regards,
    anbu.

    Hi,
    Can you not use the select-options in the Select query while populating the internal table.
    SELECT pernr FROM pa0000 INTO it_tab WHERE pernr IN s_pernr.
    If you cannot do this and you do not want to delete the unwanted entries, then you can use the WHERE clause in the LOOP statement to process the specific entries required:
    LOOP AT it_tab INTO wa_tab WHERE pernr IN s_pernr.
    Regards,
    Aparna Alashe.

  • Using plsql tables in select statement of report query

    Hi
    Anyone have experience to use plsql table to select statement to create a report. In otherwords, How to run report using flat file (xx.txt) information like 10 records in flat files and use this 10 records to the report and run pdf files.
    thanks in advance
    suresh

    hi,
    u can use the utl_file package to do that using a ref cursor query in the data model and u can have this code to read data from a flat file
    declare
    ur_file utl_file.file_type;
    my_result varchar2(250);
    begin
    ur_file := UTL_FILE.FOPEN ('&directory', '&filename', 'r') ;
    utl_file.get_line(ur_file, my_result);
    dbms_output.put_line(my_result);
    utl_file.fclose(ur_file);
    end;
    make sure u have an entry in ur init.ora saying that your
    utl_file_dir = '\your directory where ur files reside'
    cheers!
    [email protected]

  • FETCHING VALUES IN MULTI RECORD BLOCK FROM ANOTHER TABLE USING SELECT STATEMENT.

    Hi,
    I have one multi record block in which i want to fetch values
    (more then one record) from another table using select statement
    IN KEY NEXT ITEM.I am getting following error.
    ORA-01422: exact fetch returns more than requested number of rows
    Thanks in advance.

    In your case I see no reason to use non-database block and to try to populate it from a trigger with a query, instead of using the default forms functionality where you can associate the block and the fields with table, create where clause using bind variables and simply use execute_query() build-in to populate the block. The power of the forms is to use their build-in functionality to interact with the database.
    Also, you can base your block on a query, not on a table and you dynamically change this query using set_block_property() build-in. You can use any dynamic queries (based on different data sources) and you simply need to control the column's data type, the number of the columns and their aliases. Something like creating inline views as a block data source.
    However, you can replace the explicit cursor with implicit one like
    go_block('non_db_block_name');
    first_record();
    FOR v_tab IN (SELECT *
    FROM tab
    WHERE col_name = :variable)
    LOOP
    :non_db_block_name.field1 := v_tab.col1;
    :non_db_block_name.field2 := v_tab.col2;
    next_record();
    END LOOP;

  • How to fill internal table with selection screen field.

    Hi all,
    i am new to sap . pls tell me how to fill internal table with selection screen field.

    Hi,
    Please see the example below:-
    I have used both select-options and parameter on the selection-screen.
    Understand the same.
    * type declaration
    TYPES: BEGIN OF t_matnr,
            matnr TYPE matnr,
           END OF t_matnr,
           BEGIN OF t_vbeln,
             vbeln TYPE vbeln,
           END OF t_vbeln.
    * internal table declaration
    DATA : it_mara  TYPE STANDARD TABLE OF t_matnr,
           it_vbeln TYPE STANDARD TABLE OF t_vbeln.
    * workarea declaration
    DATA : wa_mara  TYPE t_matnr,
           wa_vbeln TYPE t_vbeln.
    * selection-screen field
    SELECTION-SCREEN: BEGIN OF BLOCK b1.
    PARAMETERS : p_matnr TYPE matnr.
    SELECT-OPTIONS : s_vbeln FOR wa_vbeln-vbeln.
    SELECTION-SCREEN: END OF BLOCK b1.
    START-OF-SELECTION.
    * I am adding parameter value to my internal table
      wa_mara-matnr = p_matnr.
      APPEND wa_mara TO it_mara.
    * I am adding select-options value to an internal table
      LOOP AT s_vbeln.
        wa_vbeln-vbeln =  s_vbeln-low.
        APPEND  wa_vbeln TO  it_vbeln.
      ENDLOOP.
    Regards,
    Ankur Parab

  • Check the range of values of an internal table with the statement IN

    Hi,
    I'd like to know how to check if the current contents of a field are in the set described by an internal table.
    I know I have to use the statement <b>IN</b>, but I don't know exactly how to define the internal table. In my case, I have a single field (<i>tipo_doc</i>) in my internal table which stores 4 different values: C, I, K, L.
    I want to use the statement <b>IN</b> as shown next:
    SELECT * FROM VBFA APPENDING CORRESPONDING FIELDS OF TABLE it_flujo_docs WHERE ( VBELN = it_total_fact-vbeln )
                          AND ( VBTYP_V <b>IN</b> itab).
    Then I'd like to know how the internal table <i>itab</i> should be defined. It should be something like this I think, but it doesn't work:
    DATA: BEGIN OF itab OCCURS 0,
            tipo_doc LIKE zpedidos-tipo_doc,
            tipo_doc-sign = 'I',
            tipo_doc-option = 'EQ',
            tipo_doc-low = C,
            tipo_doc-high = L,
        END OF it_tipo_doc_ped.
    I'd appreciate if someone could tell me the proper way to define it.
    Thanks in advance,
    Gerard

    Hi,
    Please follow this.
    RANGES R_VBTYP FOR VBFA-VBTYP_V.
    R_VBTYP-SIGN = 'I'.
    R_VBTYP-OPTION = 'EQ'.
    R_VBTYP-LOW = 'C'.
    CLEAR R_VBTYP-HIGH.
    APPEND R_VBTYP.
    Do the same for value 'I', 'K' and 'L'.
    Now in the SELECT statement replace the following
    VBTYP_V IN itab
    with
    VBTYP_V IN R_VBTYP.
    Thanks
    Vinod

  • If empty internal table in select for all entries what is the result?

    In select all entries statement , if empty internal table is there then  what is the result.

    Hello,
    If the table is empty then it will select all the records table....
    To aviod this u have check the body of the itab.
    If not itab[] is intial.
    select * ....
    endif.
    I useful reward.
    Vasanth

  • Problem in creaing the logical tables by SELECT statement

    Hi,
    I have created logical tables in the physical layer of the OBIEE tool by "select statement". Connection Pool is set up properly for the repository. Rows of the tables are updating properly by clicking to the "Update Row Count" but when I am clicking to the "View Data" it shows the following error
    [nQSError:17001] Oracle Error code:936, message: ORA-00936:missing expression at OCI call OCIStmtExecute.
    [nQSError:17010]SQL statement preparation failed.
    Also for some tables data is coming properly by clicking to the "View Data" .
    I'm stack in this point and cannot move forward. Please, help me guys.
    Thanks
    Sandeep

    Hi
    I also face same type of error. Just do one thing Change the call interface OCI 10g to ODBC 3.5 and on Feature tab click revert to default.
    I think that will work properly.
    Best of Luck
    Thanks
    SIddhartha P

  • Record count in internal table

    i want to know record count for the records stored in
    internal table.
    do we have any system field to display record count?

    Hi,
    Try this:
    Data: count_lines type i.
    describe table my_table lines count_lines.
    Regards,
    Arjan

  • Performance problem(ANEA/ANEP table) in Select statement

    Hi
    I am using below select statement to fetch data.
    Does the below where statement have performance issue?
    can you Pls suggest.
    1)In select of ANEP table, i am not using all the Key field in where condition. will it have performance problem?
    2)does the order of where condition should be same as in table, if any one field order change also will have effect performance
    SELECT bukrs                           
             anln1                          
             anln2                          
             afabe                          
             gjahr                        
             peraf                         
             lnran                         
             bzdat                          
             bwasl                        
             belnr                         
             buzei                         
             anbtr                       
             lnsan                         
        FROM anep
        INTO TABLE o_anep
        FOR ALL ENTRIES IN i_anla
       WHERE bukrs = i_anla-bukrs          
         AND anln1 = i_anla-anln1          
         AND anln2 = i_anla-anln2          
         AND afabe IN s_afabe              
         AND bzdat =< p_date                
         AND bwasl IN s_bwasl.              
      SELECT bukrs      
             anln1      
             anln2      
             gjahr      
             lnran       
             afabe      
             aufwv       
             nafal   
             safal       
             aafal      
             erlbt    
             aufwl      
             nafav    
             aafav     
             invzv   
             invzl      
        FROM anea
        INTO TABLE o_anea
        FOR ALL ENTRIES IN o_anep
       WHERE bukrs = o_anep-bukrs    
         AND anln1 = o_anep-anln1    
         AND anln2 = o_anep-anln2    
         AND gjahr = o_anep-gjahr    
         AND lnran = o_anep-lnran   
         AND afabe = o_anep-afabe.
    Moderator message: Please Read before Posting in the Performance and Tuning Forum
    Edited by: Thomas Zloch on Aug 9, 2011 9:37 AM

    1. Yes. If you have only a few primary keys in youe WHERE condition that does affect the performance. But some times requirement itself may be in that way. We may not be knowing all the primary keys to given them in WHER conditon. If you know the values, then provide them without fail.
    2. Yes. It's better to always follow the sequence in WHERE condition and even in the fields being fetched.
    One important point is, whenever you use FOR ALL ENTRIES IN, please make sure that the itab IS NOT INITIAL i.e. the itab must have been filled in. So, place the same conditin before both the SELECT queries like:
    IF i_anla[] IS NOT INITIAL.
    SELECT bukrs                           
             anln1                          
             anln2                          
             afabe                          
             gjahr                        
             peraf                         
             lnran                         
             bzdat                          
             bwasl                        
             belnr                         
             buzei                         
             anbtr                       
             lnsan                         
        FROM anep
        INTO TABLE o_anep
        FOR ALL ENTRIES IN i_anla
       WHERE bukrs = i_anla-bukrs          
         AND anln1 = i_anla-anln1          
         AND anln2 = i_anla-anln2          
         AND afabe IN s_afabe              
         AND bzdat =< p_date                
         AND bwasl IN s_bwasl.              
    ENDIF.
    IF o_anep[] IS NOT INITIAL.
      SELECT bukrs      
             anln1      
             anln2      
             gjahr      
             lnran       
             afabe      
             aufwv       
             nafal   
             safal       
             aafal      
             erlbt    
             aufwl      
             nafav    
             aafav     
             invzv   
             invzl      
        FROM anea
        INTO TABLE o_anea
        FOR ALL ENTRIES IN o_anep
       WHERE bukrs = o_anep-bukrs    
         AND anln1 = o_anep-anln1    
         AND anln2 = o_anep-anln2    
         AND gjahr = o_anep-gjahr    
         AND lnran = o_anep-lnran   
         AND afabe = o_anep-afabe.
    ENDIF.

  • Using Nested Table in Select Statement

    Hi all ,
    Can i use the PL/SQL nested table or Varray
    in the select statement as a normal table joined with other database tables.
    i.e.
    I have a nested table NT_1 in PL/SQL proc
    i have to use this NT_1 in the select statement as
    select xxx from
    tab_1,
    tab_2,
    NT_1
    where
    < some conditional joins >.
    Please help me in this regard.
    regds
    Dhananjaya.H

    you can not use a varray as part of a SQL Statement in order to build joins.
    Can you explain better what do you want to do ?
    Joel P�rez

  • Moving internal table to another internal table using ASSIGN statement.

    Hi,
    We have a requirement to move an internal table form one program(SAPMV60A) to the internal table of the include(RV61B9xx) using the following statement.
    [  xvbrp is a internal table in SAPMV60A.  ]
    ASSIGN ('(SAPMV60A)xvbrp')  TO <ls_xvbrp>.
    We tried all the combinations for declaring <ls_xvbrp> as table.
    It is going to dump in our system,
    " Type conflict with ASSIGN in program "SAPLV61B ".".
    Your efforts will be rewarded with points.
    Thanks in Advance,
    Warm Regards,
    Baburaj

    Hi
    If you declare your field-symbols as table you should use []
    FIELD-SYMBOLS: <ls_xvbrp> TYPE TABLE.
    ASSIGN ('(SAPMV60A)xvbrp[]') TO <ls_xvbrp>.
    else
    FIELD-SYMBOLS: <ls_xvbrp> TYPE ANY.
    ASSIGN ('(SAPMV60A)xvbrp') TO <ls_xvbrp>.
    But I believe in this case you'll assign the header line of xvbrp.
    Max

  • Create table as select statement.

    Hello Oracle Gurus,
    I am trying to create a table using select * from other table.
    The procedure that I am following is this:-
    I have a temp table whose signature is on commit delete rows.
    I insert records in this table.
    when I do select * from temp_table,perm_table I get some rows.
    then I try to create a result_table using this
    CREATE TABLE result_table
    AS SELECT * FROM temp_table,perm_table;
    I see the table in created but number of records in 0. Can anyone please explain where commit takes place while sequence in this query occurs.
    Thanks
    Edited by: user10696492 on Nov 10, 2009 8:47 AM

    Create table statement is a ddl - so an implicit commit is performed before the create statement begins. The implicit commit will delete all the rows from the temp table. If it is feasible change the definition of the temp table to on commit preserve rows.

Maybe you are looking for

  • Connection problems between desktop and Palm

    I used to be able to HotSync with my computer, but it stopped working. I thought it might be the cable, but I have gotten a new one and the connection is still not established when I try to HotSync. The computer doesn't seem to be recognizing the Pal

  • Jukebox Zen firmware fai

    Zen's os system was mistakenly erased and now I can only get into rescue mode. WinXP connects to the Zen but I am unable to load new firmware. Firmware update tries to install but after a minute or so I get a "firmware upgrade failed!" message? I hav

  • Mac Mail deleting emails too soon

    Hi everyone, I have Mac Mail setup to delete all emails after one month, this includes the Sent, Junk, and Trash.  However Mail is only keeping one week's worth.  I use iCloud as my sole email account.  This issue has been occuring for a few months n

  • Screen exit for FBL3N

    hi, i need screen exit for FBL3N

  • Cant up date to 6.0

    But I want it updated on my I PHONE