Hi friends i have doubt on select statement

hi friends, i am using one ztable which contains around 60 fields. i would like to consider in to itab around 52 fields. for this i am using "select * from ztable into itab....". can u please suggest me how can i improve by selecting all the fields and without reducing performance.

Declare as below:
Select-options: s_matnr FOR mara-matnr.
Data: Begin of itab.
  INCLUDE STRUCTURE mara.
Data: End of itab.
Clear itab.
Refresh itab.
Select * from mara
         into table itab
         where matnr = s_matnr.
if sy-subrc = 0.
SORT itab.
endif.
OR if you are selecting based on some internal table then use
FO ALL ENTRIES IN itab1.
Hope this helps you, it will also improve your performance.
Reward points and close the thread else revert back.

Similar Messages

  • Hi friends i have doubt on collect statement.

    i have some problem with matnr which is repeating no.of times. so i tried using collect and selected some of the fields to collect. Now i need to collect those collected elements in to internal table and need to display those fields in an ouput. for example.
    loop at sumtab.
    matnr type s886-matnr,
    avg1 type p decimals 3,
    total type p decimals 3,
    endloop.
    and now using loop  i am collecting. these fields using my itab.
    loop at itab.
    move-corresponding itab to sumtab.
    collect sumtab.
    clear sumtab.
    endloop.
    ***here itab contains no.of other fields like qty,stock etc.
    so after here i am using ALV to display the itab.
    my problem is how to make SUMTAB fields tobe moved in itab.

    Hi Kalyan,
       The collect statement works like this . (ex)
    data: begin of itab occurs 0,
          name(10) type c,
          value(4) type n,
          end of itab.
    itab-name = 'JACK'.
    itab-value = 100.
    append itab.
    itab-name = 'PAT'.
    itab-value = 200.
    append itab.
    itab-name = 'JACK'.
    itab-value = 200.
    append itab.
    sort itab.
    loop itab.
    collect itab.
    write: / itab-name, itab-value.
    endloop.
    <b>o/p:</b>
    JACK 300
    PAT  200

  • I have doubt in Read statement

    Hi All.
    I have doubt in Read statement .i need to convert following select statement  as read statement .how can i change help me.
    IF p_field1 IS  INITIAL
         AND p_field2 IS INITIAL
         AND p_field3 IS INITIAL
         AND p_field4 IS INITIAL
         AND p_field5 IS INITIAL.
        SELECT *
              FROM zdbt
               INTO TABLE itab
               WHERE field5 = p_field5
               ORDER BY PRIMARY KEY.
        IF sy-subrc <> 0.
          MESSAGE s035.
        ENDIF.
      ENDIF.
    regards,
    Jay.

    hi
    The READ statement is as below:
    When u have a table already with values and to improve the performance u need to use this.
    Reading Lines of Tables
    To read a single line of any table, use the statement:
    READ TABLE <itab> <key> <result>.
    For the statement to be valid for any kind of table, you must specify the entry using the key and
    not the index. You specify the key in the <key> part of the statement. The <result> part can
    specify a further processing option for the line that is retrieved.
    If the system finds an entry, it sets SY-SUBRC to zero, if not, it takes the value 4, as long as it is
    not influenced by one of the possible additions. If the internal table is an index table, SY-TABIX
    is set to the index of the line retrieved. If the table has a non-unique key and there are duplicate
    entries, the first entry is read.
    Thanks
    Shiva

  • Doubt about Select statement.

    Hi folks!!
                 I have a few doubts about the select statements, it may be a silly things but its useful for me.
    what is   difference between below statment.
    1)SELECT * FROM TABLE.
    2)SELECT SINGLE * FROM TABLE
    3)SELECT SINGLE FROM TABLE.
    Hope i will get answer,thanks in advance.
    Regards
    Richie..

    Hi,
    try this and if possible use sap help.i mean place the cursor on select and press F1.
                 Types of select statements:
    1.     select * from ztxlfa1 into table it.
                 This is simple select statement to fetch all the data of db table into internal table it.
       2.   select * from ztxlfa1 into table it where lifnr between 'V2' and 'V5'.
            Thisis using where condition between v2 and v5.
      4. select * from ztxlfa1 where land1 = 'DE'. "row goes into default table work Area
      5. select lifnr land1 from ztxlfa1
            into corresponding fields of it   "notice 'table' is omitted
             where land1 = 'DE'.
              append it.
               endselect.
         Now data will go into work area. and then u will add it to internal table by     
            append statement.
      6.   Table 13.2 contains a list of the various forms of select as it is used with internal tables and their relative efficiency. They are in descending order of most-to-least efficient.
    Table 13.2  Various Forms of SELECT when Filling an Internal Table
    Statement(s)                                   Writes To
    select into table it                                    Body
    select into corresponding fields of table it   Body
    select into it                                    Header line
    select into corresponding fields of it           Header line
    7. SELECT VBRK~VBELN
           VBRK~VKORG
           VBRK~FKDAT
           VBRK~NETWR
           VBRK~WAERK
           TVKOT~VTEXT
           T001~BUKRS
           T001~BUTXT
        INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
        FROM VBRK
        INNER JOIN TVKOT ON VBRKVKORG = TVKOTVKORG
        INNER JOIN T001 ON VBRKBUKRS = T001BUKRS
        WHERE VBELN IN DOCNUM AND VBRK~FKSTO = ''
       AND VBRK~FKDAT in date.
    Select statement using inner joins for vbrk and t001 and tvkot table for this case based on the conditions
    8. SELECT T001W~NAME1 INTO  TABLE IT1_T001W
    FROM T001W INNER JOIN EKPO ON T001WWERKS = EKPOWERKS
    WHERE EKPO~EBELN = PURORD.
    here selecting a single field into table it1_t001winner join on ekpo.
    9. SELECT BUKRS LIFNR EBELN FROM EKKO INTO CORRESPONDING FIELDS OF IT_EKKO WHERE     EBELN IN P_O_NO.
    ENDSELECT.
    SELECT BUTXT   FROM T001 INTO  IT_T001 FOR ALL ENTRIES IN IT_EKKO WHERE BUKRS = IT_EKKO-BUKRS.
    ENDSELECT.
    APPEND IT_T001.
    here I am using for all entries statement with select statement. Both joins and for all entries used to fetch the data on condition but for all entries is the best one.
    10. SELECT AVBELN BVTEXT AFKDAT CBUTXT ANETWR AWAERK INTO TABLE ITAB
                 FROM  VBRK AS A
                 INNER JOIN TVKOT AS B ON
                 AVKORG EQ BVKORG
                 INNER JOIN T001 AS C ON
                 ABUKRS EQ CBUKRS
                 WHERE  AVBELN IN BDOCU AND AFKSTO EQ ' ' AND B~SPRAS EQ
                 SY-LANGU
                 AND AFKDAT IN BDATE AND AVBELN EQ ANY ( SELECT VBELN FROM
                VBRP WHERE VBRP~MATNR EQ ITEMS ).
        Here we are using sub query in inner join specified in brackets.
    Thanks,
    chandu.

  • Doubt on Select Statement

    HI Friends,
    i have a requirement to select matnr,werks and mmsta from marc table.where i have input of matnr and mmsta.
    The matnr in the marc table having 2 werks with different mmsta.
    i was asked to select matnr not having mmsta 40.
    but in marc table there is same matnr with two mmsta 37 and 40.
    i want a select statement which should not pick matnr having 40.
    my select statement was
    select matnr werks mmsta into itab from marc
    where matnr in fpso_matnr and mmsta in fpso_mmsta.
    this does not work for the above condition.
    please suggest me a correct statement..
    Thanks,
    Gokul

    select matnr werks mmsta into itab from marc
    where matnr in fpso_matnr and mmsta in fpso_mmsta
       and mmsta NE 40.
    ill this not work ?
    MARC is plant data.. so I guess u need to give werks also...
    Edited by: jackandjay on Dec 19, 2007 12:02 PM

  • Simple doubt in select statement

    hi all,
    Although this is a very simple ques.
    Can u pl tell me why i m not getting the value into v_adrnr ?
    Chk the following code.
    V_VBELN  = '0080000001'.
      SELECT SINGLE ADRNR
             FROM VBPA
             INTO V_ADRNR
             WHERE VBELN = V_VBELN
             AND   PARVW = 'BP'.
    i have cheked the table vbpa for the above mentioned conditions.I can see the
    value for adrnr in database as 0000022741.
    But while i run the above code i cant see value on v_adrnr.
    Pl help.

    First PARVW has a domain with a conversion routine based on table TPAUM so "BP" is internal code "RE"
    Use CONVERSION_EXIT_PARVW_INPUT
    CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
      EXPORTING
        input = V_PARVW
      IMPORTING
        output = V_PARVW.
    Second
    Have you defined V_VBELN with reference to the element VBELN, char 10 with conversion Alpha
    Then it should work
    Regards

  • Doubt in select statement

    Hi :
    How can i join aufnr , arbei , ismnw since there is no common key field between arbei and aufnr , ismnw.
    I am able to join aufnr and ismnw based on aufnr, because im trying to pull data based on aufnr , but when i went to se84 and tried to chk tables for arbei...only one table HIKO has all these fields but there is no data in that.
    SELECT aaufnr aauart b~arbei INTO CORRESPONDING FIELDS OF TABLE it_tab
    FROM aufk AS a
    INNER JOIN plpo AS b ON awerks = bwerks
    INNER JOIN iloa AS d ON abukrs = dbukrs
    *06/18
    INNER JOIN afko AS e ON aaufnr = eaufnr
    WHERE a~auart IN s_auart
    AND a~auart NE 'PM04'
    AND a~auart NE 'PM09'
    AND a~werks = 'M600'
    AND d~tplnr = 'PB-PRO-S01-BY02-MIL'
    AND d~abckz IN s_abckz
    AND a~erdat IN s_date.
    SELECT SINGLE ismnw INTO v_ismnw FROM afru
    WHERE aufnr = v_aufnr.
    it_tab-ismnw = v_ismnw.
    with my first select statment do i get unique values for arbei?
    i would appreciate if any one can help me on this.
    Thanks.
    Raghu

    Everybody's question is important.
    All you have to do is edit your original question and it will pop to the top.
    If you ask the same question twice, somebody may spend a lot of time trying to answer your question only to find that someone else answered it a long time before.
    Rob

  • I have doubt in Selection Screen

    Hi all.
    I was created Dialogue screen as  a initial screen 9000. after that i changed 1000 as initial screen (Selection screen),Moved 9000 as second screen,i have some application tool bar in selection screen 1000.it is displaying when iam execute my program without transaction code.but it does not display when i execute programe by Transaction code,i was given  screen no 1000 for t-code.
    Regards,
    Jay

    Hi Jay,
    Although i am not fully clear of the situation..please try the following suggestions that may prove useful..
    1) for dummy sake try creating a new Tcode with dialog (option 1) again and see it you can achieve the desired output by running it...if not you can delete the new tcode you have created
    Reason : Creating a fresh Tcode may put an end to your problem because i guess that you may have created the tcode first and reassigned the screens later......
    2)  try the "set PF status"  code written in the module...if possible debugg in the Tcode and direct execute version marking the "Set PF status" as break point..
    I am sure you can come up with something there...
    ReAson : Last resort of any ABAPer is the debugger...
    Regards
    BX
    "Happy New Year"

  • Hi friends i have doubt in dialog programming.

    i am desiging the screen using table control. which is suppose to accept unit of measure as 'car' means carton, kg, and so on. so if i enter numerics it should not accept. can anybody tell me how  can i restrict the user to enter only alphanumerics. thanks in advance.

    Hello,
    U can use the system table field ABCDE for checking if it has only alphabets.
    system field == SY-ABCDE
    Regards
    Anurag

  • Hi friends i have doubt on set cursor.

    i am using dialog programming. here in the first text field i am auto generating the number, so user should only suppose to enter the values for other repective fields only.but in execution the cursor is positioning at the first field. it should start from the second and so on.
    i tried using SET CURSOR FIELD F2. but tbe result is same. please provide me guidence on this.

    Hi,
    In the PBO of the dialog module,write the following code :
    SET CURSOR FIELD `FIELD2`.
    Remember the FIELD2 is the name assigned to the textbox of the screen.
    Best regards,
    Prashant
    PS : Please reward all helpful answers

  • Index not being used in Select statement

    Friends
    I have the following SQL statement:
    SELECT
    a.acct,
    a.date_field,
    UPPER(b.feegroup) feegrp,
    SUM (a.fee1) fee1,
    SUM (a.fee2) fee2,
    SUM (a.fee3) fee3
    FROM table1 a, table2 b
    WHERE 1 = 1
    AND a.fee_id = b.fee_id
    GROUP BY a.acct, a.date_field, b.feegroup;
    Both the tables have index on fee_id column. When I run the explain plan for this statement, I am getting the following output:
    Operation | Option | Object Name | Position
    SELECT STATEMENT | | | 560299
    HASH | GROUP BY| |1
    TABLE ACCESS | FULL| table2 | 1
    TABLE ACCESS | FULL| table1 | 2
    Why Oracle is not using the index?
    Edited by: darshilm on Dec 10, 2009 3:56 PM

    The proposed plan is the optimal according to your current conditions in the "where clause" where you have only the equality join condition and therefore the CBO can use HASH JOIN. Using any kind of index access would just increase the amount of required work unless you would add some very restrictive conditions which will select rows from relatively small amount of blocks. Here I have to mention that what really counts in the CBO cost calculation is the amount of blocks accessed and not the number of rows. The "currency" for I/O in Oracle is a block and not a row. CBO always uses an assumption that there is nothing in the buffer cache and it will have to perform a physical read for every block.
    How many blocks will actually be accessed depends on the data distribution. It can happen that every single row that you have to retrieve resides in a different block and although you access only 1000 rows out of a million row table you would have to visit almost every block of that table. For such a situation a FULL TABLE SCAN is the best access path and Oracle will use multiblock I/O for that. On the other side you can have those 1000 rows only in a few blocks and then the index access would be the most appropriate one. For index access Oracle uses single block I/O. Usually the actual situation is somewhere between this two extreme situations. But you can run some tests by yourself and see when an index access will be replaced by a full table scan while you will make your predicates less selective.
    HTH, Joze
    Co-author of the forthcoming book "Expert Oracle Practices"
    http://www.apress.com/book/view/9781430226680
    Oracle related blog: http://joze-senegacnik.blogspot.com/
    Blog about flying: http://jsenegacnik.blogspot.com/
    Blog about Building Ovens, Baking and Cooking: http://senegacnik.blogspot.com

  • If statement in select statement alias

    I have the following select statement. It has the alias Survivors, Deaths and "All Cases". Is it posible to use :P_LANGUAGE variable to say that -- IF :P_LANGUAGE = FRENCH THEN alias are Survivants for survivors, Décès for Deaths, Tous_les_cas for All Cases. Please advise
    SELECT ALL T_NTR_MULTIBAR.CAT, T_NTR_MULTIBAR.NUM_CASES_LEFTBAR AS Survivors,
    T_NTR_MULTIBAR.NUM_CASES_MIDDLEBAR AS Deaths, T_NTR_MULTIBAR.NUM_CASES_RIGHTBAR AS "All Cases"
    FROM T_NTR_MULTIBAR
    WHERE INSTANCE_NUM = :P_INSTANCENUM
    order by ORDERS

    You may not be able to add this condition inside the SQL Statement. But you can add this condition outside the statement, if you're using PL/SQL...
    IF :p_language = french THEN
    SELECT ALL t_ntr_multibar.cat,
      t_ntr_multibar.num_cases_leftbar AS survivors,
      t_ntr_multibar.num_cases_middlebar AS deaths,
      t_ntr_multibar.num_cases_rightbar AS "All Cases"
    ELSE
    END IF;

  • Increase performance of the following SELECT statement.

    Hi All,
    I have the following select statement which I would want to fine tune.
      CHECK NOT LT_MARC IS INITIAL.
      SELECT RSNUM
             RSPOS
             RSART
             MATNR
             WERKS
             BDTER
             BDMNG FROM RESB
                          INTO TABLE GT_RESB 
                          FOR ALL ENTRIES IN LT_MARC
                          WHERE XLOEK EQ ' '
                          AND MATNR EQ LT_MARC-MATNR
                          AND WERKS EQ P_WERKS
                          AND BDTER IN S_PERIOD.
    The following query is being run for a period of 1 year where the number of records returned will be approx 3 million. When the program is run in background the execution time is around 76 hours. When I run the same program dividing the selection period into smaller parts I am able to execute the same in about an hour.
    After a previous posting I had changed the select statement to
      CHECK NOT LT_MARC IS INITIAL.
      SELECT RSNUM
             RSPOS
             RSART
             MATNR
             WERKS
             BDTER
             BDMNG FROM RESB
                          APPENDING TABLE GT_RESB  PACKAGE SIZE LV_SIZE
                          FOR ALL ENTRIES IN LT_MARC
                          WHERE XLOEK EQ ' '
                          AND MATNR EQ LT_MARC-MATNR
                          AND WERKS EQ P_WERKS
                          AND BDTER IN S_PERIOD.
      ENDSELECT.
    But the performance improvement is very negligible.
    Please suggest.
    Regards,
    Karthik

    Hi Karthik,
    <b>Do not use the appending statement</b>
    Also you said if you reduce period then you get it quickly.
    Why not try dividing your internal table LT_MARC into small internal tables having max 1000 entries.
    You can read from index 1 - 1000 for first table. Use that in the select query and append the results
    Then you can refresh that table and read table LT_MARC from 1001-2000 into the same table and then again execute the same query.
    I know this sounds strange but you can bargain for better performance by increasing data base hits in this case.
    Try this and let me know.
    Regards
    Nishant
    > I have the following select statement which I would
    > want to fine tune.
    >
    >   CHECK NOT LT_MARC IS INITIAL.
    > SELECT RSNUM
    >          RSPOS
    > RSART
    >          MATNR
    > WERKS
    >          BDTER
    > BDMNG FROM RESB
    >                       INTO TABLE GT_RESB 
    > FOR ALL ENTRIES IN LT_MARC
    >                       WHERE XLOEK EQ ' '
    > AND MATNR EQ LT_MARC-MATNR
    >                       AND WERKS EQ P_WERKS
    > AND BDTER IN S_PERIOD.
    >  
    > e following query is being run for a period of 1 year
    > where the number of records returned will be approx 3
    > million. When the program is run in background the
    > execution time is around 76 hours. When I run the
    > same program dividing the selection period into
    > smaller parts I am able to execute the same in about
    > an hour.
    >
    > After a previous posting I had changed the select
    > statement to
    >
    >   CHECK NOT LT_MARC IS INITIAL.
    > SELECT RSNUM
    >          RSPOS
    > RSART
    >          MATNR
    > WERKS
    >          BDTER
    > BDMNG FROM RESB
    > APPENDING TABLE GT_RESB
    >   PACKAGE SIZE LV_SIZE
    >                     FOR ALL ENTRIES IN LT_MARC
    >   WHERE XLOEK EQ ' '
    >                     AND MATNR EQ LT_MARC-MATNR
    >   AND WERKS EQ P_WERKS
    >                     AND BDTER IN S_PERIOD.
    > the performance improvement is very negligible.
    > Please suggest.
    >
    > Regards,
    > Karthik
    Hi Karthik,

  • Short dump with a select statement

    I have the following select statement (I have also inluded my data statement(s)) and I get a short dump.  The error is as follows:
    <b>What happened?                                                                 
        Error in ABAP application program.                                                                               
    The current ABAP program "ZPARTNER" had to be terminated because one of the
        statements could not be executed.                                                                               
    This is probably due to an error in the ABAP program.                                                                               
    Following a SELECT statement, the data read could not be placed in AN      
        the output area.                                                           
        A conversion may have been intended that is not supported by the           
        system, or the output area may be too small.                                                                               
    Error analysis                                                                 
        An exception occurred. This exception will be dealt with in more detail    
        below. The exception, assigned to the class 'CX_SY_OPEN_SQL_DB', was not   
         caught, which                                                             
         led to a runtime error. The reason for this exception is:                 
        The data read during a SELECT access could not be inserted into the        
        target field.                                                              
        Either conversion is not supported for the target field's type or the      
        target field is too short to accept the value or the data are not in a     
        form that the target field can accept          </b>                            
    it_adrc TYPE TABLE OF adrc,
          wa_adrc LIKE LINE OF it_adrc,
    SELECT addrnumber name1 street city1 region post_code1 tel_number
      FROM adrc INTO TABLE it_adrc
      FOR ALL ENTRIES IN it_detail
      WHERE addrnumber = it_detail-adrnr.
    Regards,
    Davis

    If you only need the fields mentioned in the select query, then follow this:
    TYPES: BEGIN OF ADRC_TYPE,
         ADDRNUMBER LIKE ADRC-ADDRNUMBER,
         NAME1        LIKE ADRC-NAME1,
         STREET        LIKE ADRC-STREET,
         CITY        LIKE ADRC-CITY,
         REGION        LIKE ADRC-REGION,
         POST_CODE1 LIKE ADRC-POST_CODE1,
         TEL_NUMBER LIKE ADRC-TEL_NUMBER,
           END OF ADRC_TYPE,
           ADRC_T_TYPE TYPE TABLE OF ADRC_TYPE.
    DATA: IT_ADRC TYPE ADRC_T_TYPE WITH HEADER LINE.
    IF NOT IT_DETAIL[] IS INITIAL.
    SELECT addrnumber name1 street city1 region post_code1 tel_number
      FROM adrc INTO TABLE it_adrc
      FOR ALL ENTRIES IN it_detail
      WHERE addrnumber = it_detail-adrnr.
    ENDIF.
    Thanks,
    SKJ

  • How to use SET ID in select statement of SQ02

    Hi,
    I have a infoset, where for one of my Zfield, i have writen a select statement in order to get my ouput.
    if aufk-aufnr = 'XYZ'.
      select sum( FKBTR ) from fmifiit into zfmifiit
      where fikrs = aufk-kokrs
      and fipex IN capex
      and wrttp NE '51'.
    endif.
    For the above statement, i have created (with 10 single values, table name FMCI, field name FIPEX)  a SET id named CAPEX and used with IN operator.
    But when i generating the infoset i am getting error like below
    The IN operator with "CAPEX" is followed neither by an internal table nor by a value list
    I was using IN opeartor for set ids during validation / substitutions, where if i have to validate multiple single values.
    What to do here?
    Regards,
    Srinu

    [OPEN-SQL|http://help.sap.com/abapdocu_70/en/ABENOPEN_SQL_GENERAL.htm] set of statement, [SELECT|http://help.sap.com/abapdocu_70/en/ABAPWHERE.htm] statement, [WHERE|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP.htm] addition requires a selection table (type range, [WHERE - IN seltab |http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_SELTAB.htm]) of parameter and not a set. We are in Abap here, not in a Customizing screen
    You have to convert the set to a selection table in an ABAP coding before using it in a SELECT statement.
    (Check FM like G_SET_TREE_IMPORT to import definition of set (values and intervals) and map them to a select-table, or ask a developper to perform it, look at G_SET_TREE_IMPORT -> select statement)
    Regards,
    Raymond

Maybe you are looking for

  • Terminination Page Hangs and cpu spikes when hit submit

    Hi ,     Could you please help me trouble shooting on the below issues.               Req :                     Convert "Termination Reason"(message Choice to Message LOV) on TerminiationPG so that Additional Description can be show to the manager be

  • Error -- ISO8859_1 Not Supported in Weblogic 6.1 SP2

    I've installed Weblogic 6.1 Service Pack 2 on Solaris 8, and when I go to install and deploy and applications (including the Petstore Demo) I get an error message which says 'ISO8859_1 is not supported'. If I stop and then restart the Weblogic Server

  • N95 8GB SOUND CLIPS TRANSFER?

    Hi! Does anyone know how one can transfer sound clips (i.e.: recordings made with the N95 from it to other devices?) and what sort of files would these be? I cannot use the Nokia PC Suite - it won't install because my version of Windows XP is the ori

  • How can I retrieve iTunes of a lost iPod touch?

    How can I retrieve iTunes of a lost iPod touch?

  • How to view the lyric on iphone?

    Do you know how to view the lyric on ipone?