Query statement for internal table

is it possible to use a select statement to select data from an internal table? if yes, can anyone show me the codes to it? thx

Hi Daphne,
You use SELECT statement to read data from database table but not from Internal table.
For reading data from Internal table, you have to use READ statement.
Syntax:
READ TABLE itab { table_key
                | free_key
                | index } result.
Effect of using read statement:
This statement reads a row from internal table itab. You have to specify the row by either naming values table_key for the table key, a free condition free_key or an index index. The latter choice is possible only for index tables. The output result result determines when and where the row contents are read.
If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows.
Reward if usefull
thanks
swaroop

Similar Messages

  • Can we apply select statement on internal table.

    can we apply select statement on internal table.if yes thrn let me know how to do.

    Dear Sachin,
    You cannot use SELECT statement on internal table.
    If you want to select some rows from internal table you can LOOP the table or you can READ the table.
    <u>Please check the following links for your kind reference:</u>
    <b>http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm
    http://www.sap-img.com/ab009.htm
    http://www.itsmarc.com/crs/Clas0302.htm
    http://www.sapdevelopment.co.uk/tips/tips_itab.htm
    http://searchsap.techtarget.com/search/1,293876,sid21,00.html?query=whatisinternaltable&bucket=ALL</b>
    Cheers !
    Moqeeth.

  • How many records are  fetched my query into my internal tables

    Hi
    I am in the debugger, would like to know, how many records are  fetched my query into my internal tables. How do I  find out ?
    thanks
    siva

    Hi,
    Do the following,
    Step 1:
      Fill your internal table with select query.
    Step 2 : Use DESCRIBE statement with LINE addition to get the no of rows in the internal table.
    for further informations, check
    http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3798358411d1829f0000e829fbfe/content.htm
    Regards,
    Anirban

  • Update statement in Internal Table

    Plz tell me the syntax and e.g. of update statement in Internal Table program
    Moderator message: Welcome to SCN, please research yourself before asking basic questions.
    Edited by: Thomas Zloch on Feb 25, 2010 12:47 PM

    Hi,
    Use UPDATE statement , check below description from SAP help.
    UPDATE dbtab FROM TABLE itab. or UPDATE (dbtabname) FROM TABLE itab.
    Effect
    Mass update of several lines in a database table.Here, the primary key for identifying the lines tobe updated and the values to be changed are taken from the lines of theinternal table itab. 
    The system field SY-DBCNT contains the number of updated lines,i.e. the number of lines in the internal table itab which havekey values corresponding to lines in the database table.
    Regards
    L Appana

  • Query related to Internal Table

    Hi ,
          I have a small query related to internal table , can we dump millions of records to an internal .
    The actual requirment is like i need to develop a report in BI side where i have to dump records into an internal table  from PSA tables without filtering .
    Can we do so ....
    or do we have any other option to dump the data to an internal tables .
    need some tips on the same .
    Thanks ,
    VInay.

    Hello Vinay,
    I believe the following extract will give you a brief idea on the size limitations for an internal table.......
    Internal tables are dynamic data objects, since they can contain any number of lines of a particular type. The only restriction on the number of lines an internal table may contain are the limits of your system installation. <u><i>The maximum memory that can be occupied by an internal table (including its internal administration) is 2 gigabytes. A more realistic figure is up to 500 megabytes. An additional restriction for hashed tables is that they may not contain more than 2 million entries.</i></u>
    Hope it proved useful
    Reward if helpful
    Regards
    Byju

  • System Variable For Internal table count

    Can anybody tell me what the system variable for internal table count?
    I just wants to know how many recoreds are there in my internal table ?
    Regards,
    pandu.

    Hi ,
    DESCRIBE TABLE <itab> [LINES <l>] [OCCURS <n>] [KIND <k>].
    If you use the LINES parameter, the number of filled lines is written to the variable <lin>. If parameter, the you use the OCCURS value of the INITIAL SIZE of the table is returned to the variable <n>. If you use the KIND parameter, the table type is returned to the variable <k>: ‘T’ for standard table, ‘S’ for sorted table, and ‘H’ for hashed table.
    using variable
    SY-TFILL
    After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TFILL contains the number of lines in the relevant internal table.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3798358411d1829f0000e829fbfe/content.htm
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Feb 21, 2008 4:53 PM

  • Control statement in internal tables

    hi experts,
    can any body will provide me the control statement of internal table.
                                                               thank you

    Hi,
    check this link
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9f1f35c111d1829f0000e829fbfe/content.htm
    Control Break Statements
    Control break statements are used to create statement blocks which process only specific table lines the LOOP – ENDLOOP block.
    You open such a statement block with the control level statement AT and close it with the control level statement ENDAT. The syntax is as follows:
    Table should be sorted when you use control-break statements
    You can break the sequential access of internal tables by using these statements.
    Syntax:
    At first.
    <Statement block>
    Endat.
    This is the first statement to get executed inside the loop (remember control break statements are applicable only inside the loop)
    So in this block you can write or process those statements which you want to get executed when the loop starts.
    At New carrid.
    Write:/ carrid.
    Endat.
    In this case whenever the new carrid is reached, carrid will be written.
    At End of carrid.
    Uline.
    Endat.
    In this case whenever the end of carrid is reached, a line will be drawn.
    At Last.
    Write:/ ‘Last Record is reached’.
    Endat.
    Processing of statements within this block is done when entire processing of entire internal table is over. Usually used to display grand totals.
    You can use either all or one of the above control break statements with in the loop for processing internal table.
    At end of carrid.
    Sum.
    Endat.
    In above case the statement SUM (applicable only within AT-ENDAT) will sum up all the numeric fields in internal table and result is stored in same internal table variable.
    Regards,
    Sruthi

  • Why using workarea for internal table is better in performance

    Please tell me
    why using workarea for internal table is better in performance

    Hi Vineet ,
      Why would we choose to use an internal table without a header line when it is easier to code one  with a header line?
    it has following reason.
    1)Separate Internal Table Work Area:
         The work area (staging area) defined for the internal table   is not limited to use with just one internal table.
    take ex-
    Suppose you want two internal tables for EMPLOYEE – one to contain all records and one to contain only those records where country = ‘USA’.  You could create both of these internal tables without header lines and use only one work area to load data into both of them. You would append all records from the work area into the first internal table.  You would conditionally append the ‘USA’ records from the same work area into the second internal table.
    2)  Performance Issues:  Using an internal table without a header line is more efficient than one  with a header line
    3) Nested Internal Tables:  If you want to include an internal table within a structure or another   internal table, you must use one without a header line.
    If this one is helpful ,then rewards me
    Regards
    Shambhu

  • Aggregate functions for internal table.

    Hi Gurus,
    I'm just wondering whether we can use aggregate functions for internal table. I wanted to know the max value for a particular column in my internal table. How can I achieve this easily and quickly.
    Thanks,
    David.

    sort the table on which you want the maximum value and read it. Please find below example code.
    TYPES : BEGIN OF ty_mvke,
            matnr TYPE mvke-matnr,
            vkorg TYPE mvke-vkorg,
            vtweg TYPE mvke-vtweg,
           AUMNG type mvke-AUMNG,
            END OF ty_mvke.
    DATA : wa_mvke TYPE ty_mvke,
           it_mvke TYPE STANDARD TABLE OF ty_mvke.
    data : temp_AUMNG type AUMNG.
    START-OF-SELECTION.
      SELECT matnr vkorg vtweg AUMNG FROM mvke INTO
            table it_mvke.
    sort it_mvke by AUMNG.
    read TABLE it_mvke into wa_mvke INDEX 1.
    if sy-subrc = 0.
    move wa_mvke-AUMNG to temp_AUMNG.
    write : temp_AUMNG.
    endif.
    Thanks,
    Sreekala.

  • Extracting the result of a query into a internal table

    Hi,
    Does anyone knows or have an idea how to extract the result of a query into a internal table, is there a function module or BAPI?
    Thanks in advance,
    CK

    So then normally I would use a statment like:
    IFunctionTemplate ftemplate = repository.getFunctionTemplate("<b>BAPI_SALESORDER_GETLIST</b>");
    to call a particluar function, but I tried using
    IFunctionTemplate ftemplate = repository.getFunctionTemplate("<b>BAPI_MDDATAPROVIDERBW_GETCATALOGS</b>");
    and it did not seem to work. I also tried -
    IFunctionTemplate ftemplate = repository.getFunctionTemplate("<b>MDDataProviderBW.GetCatalogs</b>");
    How do I format the function?
    Thanks
    Paul

  • Issue with WRITE statement from Internal Table

    Hi All,
    I have written the below code in a infoset query, the syntax check is ok & when i run the query in debugging mode, i find the internal table being filled with the values & the write statement outputing the values as well.
    But the problem is when i execute the query the output does not show all the lines, instead just displays the last record . What could be the mistake?
    Is it because i have defined Y_EBELN, Y_EBELP & Y_OPENQTY as nodes in the Extras Tab of the infoset & have chosen this for display in my query? How to display the output from my internal table in my query output?
    Hope my problem is clear, await clarification.
    Vivek
    Code
      types:
        Begin of itab,
          wl_ebeln   type eket-ebeln,
          wl_ebelp   type eket-ebelp,
          wl_openqty type eket-menge,
        End of itab.
    Data: il_po type table of itab with header line.
    *Display open PO for materials
      SELECT EKETEBELN EKETEBELP EKETMENGE EKETWEMNG EKET~EINDT
           INTO (Y_EBELN, Y_EBELP, WL_MENGE, WL_WEMNG, Y_EINDT)
        FROM EKET
          INNER JOIN EKPO
             ON EKETEBELN     = EKPOEBELN
              AND EKETEBELP = EKPOEBELP
          INNER JOIN MARD
             ON EKPOMATNR     = MARDMATNR
              AND EKPOWERKS = MARDWERKS
              AND EKPOLGORT = MARDLGORT
        WHERE EKPO~MATNR = MARD-MATNR
          AND EKPO~WERKS = MARD-WERKS
          AND EKPO~LGORT = MARD-LGORT
          AND EKPO~LOEKZ = SPACE
          AND EKPO~ELIKZ = SPACE.
    *Display only still open qty per schedule line
      Y_OPENQTY = WL_MENGE - WL_WEMNG.
      il_po-wl_ebeln = Y_EBELN.
      il_po-wl_ebelp = Y_EBELP.
      il_po-wl_openqty = Y_OPENQTY.
        append il_po.
      ENDSELECT.
    ENDIF.
    Loop at il_po.
      write:/ il_po-wl_ebeln, il_po-wl_ebelp, il_po-wl_openqty.
    endloop.

    Hi Vivek,
      Try it like this.
    Data: Begin of itab,
           lifnr type lfa1-lifnr,
           name1 type lfa1-name1,
           land1 type lfa1-land1,
          End of itab,
          it_lfa1 like table of itab with header line,
          lifnr like lfa1-lifnr,
          name1 like lfa1-name1,
          land1 like lfa1-land1.
    select lifnr name1 land1 into (lifnr, name1, land1)
           from lfa1.
    it_lfa1-lifnr = lifnr.
    it_lfa1-name1 = name1.
    it_lfa1-land1 = land1.
    append it_lfa1.
    endselect.
    loop at it_lfa1.
    write:/ it_lfa1-lifnr, it_lfa1-name1, it_lfa1-land1.
    endloop.
    Note:
    In place of the above select you insert your join select statement. It is working for me.
    You have declared your internal table wrongly. In the internal table instead of TYPE use LIKE, it will work.
    Hope this will work for you.
    Thanks & Regards
    Haritha.

  • SAP QUERY LOOPS AND INTERNAL TABLE

    Hi All, I have a query which i have made. It runs from Table EKPO which has PO details and what I want to do is now via ABAP Code pull through the total of goods receipt for the PO and Line Item into a field. Sounds Easy enough..Problem now,
    The table which contains the GR data is EKBE which agains a PO and Line Item can have many 101 movements and 102 movements so what I want is an ABAP Statent to basically sum up the total of 101 for the PO & LINE ITEMS and then minus this from the total of 102 for the PO & LINE ITEMS and post the result in to this new field I have created.
    I am pretty decent with ABAP Code in Querys I.e Select statements etc but from what I can see i need to create an internal table and do a loop and collect statement but I keep on failing due to not enough knowledge. Please can some one help me with this and provide me with the code and explanation as i would like to understand,
    POINTS WILL BE REWARDED
    Thanks
    Kind Regards
    Adeel Sarwar

    Hi,
    This is the full code i have entered but its not working. Any help would be appreciated. If you could rectify the code and internal tables that would be great.
    Thanks
    TABLES: EKBE.
    DATA: PurO LIKE EKPO-EBELN,
          POLI LIKE EKPO-EBELP.
    *New Table and Vars defined
    DATA:   BEGIN OF IT_EKBE,
              IT_EKBE LIKE EKBE,
            END OF IT_EKBE.
    DATA:  BEGIN OF IT_SUM OCCURS 0,
              EBELN TYPE EBELN,
              EBELP TYPE EBELP,
              DMBTR TYPE DMBTR,
              MENGE TYPE MENGE,
          END OF IT_SUM.
    CLEAR: QTYD.
    MOVE: EKPO-EBELN TO PurO,
          EKPO-EBELP TO POLI.
    SELECT * FROM EKBE INTO IT_EKBE
        WHERE EBELN = PurO
        AND   EBELP = POLI
        AND   BEWTP = 'E'
    LOOP AT IT_EKBE.
      MOVE CORRESPOING IT_EKBE TO IT_SUM.
      IF IT_EKBE-BWART = '102'.
        IT_SUM-DMBTR = IT_SUM-DMBTR * -1.
        IT_SUM-MENGE = IT_SUM-MENGE * -1.
      ENIDF.
      COLLECT IT_SUM.
      CLEAR IT_SUM.
    ENDLOOP.
    ENDSELECT.
    If sy-subrc = 0.
      QTYD = IT_SUM.
    ELSE.
      QTYD = 0.
    ENDIF.

  • Read statement in internal table.

    PLease help me to figure out what a read statement does???
    Please show me through examples how a read statements selects data from a table ,,,puts into internal table & finally we are able to read it through work area????
    thanx... <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Mar 10, 2008 7:27 PM

    Hey saswat ,
       just wanted to give a simplified example of ur query , if not understood please ask
    REPORT  Z_PRGM_TRY_READ NO STANDARD PAGE HEADING.
    TABLES : MARA , MARD.
    SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.
    TYPES : BEGIN OF LT_MARA ,
            MATNR LIKE MARA-MATNR ,
            ERSDA LIKE MARA-ERSDA ,
            MBRSH LIKE MARA-MBRSH ,
            END OF LT_MARA .
    DATA : TT_MARA TYPE STANDARD TABLE OF LT_MARA INITIAL SIZE 0 ,
           WA_MARA TYPE LT_MARA .
    TYPES : BEGIN OF LT_MARD ,
            MATNR LIKE MARD-MATNR ,
            WERKS LIKE MARD-WERKS ,
            LGORT LIKE MARD-LGORT ,
            PSTAT LIKE MARD-PSTAT ,
            END OF LT_MARD.
    DATA : TT_MARD TYPE STANDARD TABLE OF LT_MARD INITIAL SIZE 0 ,
           WA_MARD TYPE LT_MARD.
    TYPES : BEGIN OF LT_FINAL ,
            MATNR LIKE MARA-MATNR ,
            ERSDA LIKE MARA-ERSDA ,
            MBRSH LIKE MARA-MBRSH ,
            WERKS LIKE MARD-WERKS ,
            LGORT LIKE MARD-LGORT ,
            PSTAT LIKE MARD-PSTAT ,
            END OF LT_FINAL .
    DATA : TT_FINAL TYPE STANDARD TABLE OF LT_FINAL INITIAL SIZE 0 ,
            WA_FINAL TYPE LT_FINAL .
    SELECT MARA~MATNR
           ERSDA
           MBRSH
           INTO CORRESPONDING FIELDS OF TABLE TT_MARA FROM MARA WHERE  MARA~MATNR IN S_MATNR .
    SELECT MARD~MATNR
           WERKS
           LGORT
           PSTAT
           INTO CORRESPONDING FIELDS OF TABLE TT_MARD FROM MARD
           FOR ALL ENTRIES IN TT_MARA
           WHERE MATNR = TT_MARA-MATNR.
    LOOP AT TT_MARA INTO WA_MARA.
    READ TABLE TT_MARD INTO WA_MARD WITH KEY MATNR  = WA_MARA-MATNR .
    IF SY-SUBRC = 0.
    WA_FINAL-MATNR = WA_MARA-MATNR .
    WA_FINAL-ERSDA = WA_MARA-ERSDA.
    WA_FINAL-MBRSH = WA_MARA-MBRSH.
    WA_FINAL-WERKS = WA_MARD-WERKS.
    WA_FINAL-LGORT = WA_MARD-LGORT.
    WA_FINAL-PSTAT = WA_MARD-PSTAT.
    APPEND WA_FINAL TO TT_FINAL.
    CLEAR WA_FINAL.
    ENDIF.
    ENDLOOP.
    LOOP AT TT_FINAL INTO WA_FINAL.
    WRITE : / WA_FINAL-MATNR , WA_FINAL-ERSDA , WA_FINAL-MBRSH , WA_FINAL-WERKS ,
               WA_FINAL-LGORT , WA_FINAL-PSTAT.
    ENDLOOP.

  • IMPORT Statement Issue (Internal Table)

    Hi All,
    I am using an IMPORT statement to get all the data from other report's internal table. Now whenever this (the other report's internal table) is changed (for field addition, etc), my report throws a dump. Hence, everytime I have to add these fields in my program as well.
    Is there any way by which I can include the whole internal table of that report in my program just like
    'INCLUDE STRUCTURE VBRK'.
    Thanks in advance

    Hi, CHeck this code related to your problem..This will helpful to you...
    I have done this program earlier..I hope it will helpful to u..
    This programa calling the other program to import the data..
    Check it out...
    *" Tables declarations.................................................
    TABLES:
      spfli.
    *" Type declarations...................................................
    Type declaration of the structure to hold data from table SPFLI     *
    TYPES:
      BEGIN OF type_s_spfli,
        carrid LIKE spfli-carrid,          " Carrier Id
        connid LIKE spfli-connid,          " Connection Number
        cityfrom LIKE spfli-cityfrom,      " City from
        cityto LIKE spfli-cityto,          " City to
        airpfrom LIKE spfli-airpfrom,      " Airport from
        airpto LIKE spfli-airpto,          " Airport to
        countryfr LIKE spfli-countryfr,    " Country from
        countryto LIKE spfli-countryto,    " Country to
      END OF type_s_spfli.
    Data Declaration...................................................*
         Field String To Hold Flight Details Record from SPFLI          *
    DATA
      fs_spfli TYPE type_s_spfli.
    Data Declaration...................................................*
         Internal Table To Hold Flight Details Records from SPFLI       *
    DATA
      t_spfli LIKE STANDARD TABLE OF fs_spfli.
    TYPES:
      BEGIN OF types_s_itab,
        carrid LIKE sflight-carrid,        " Carrier id
        connid LIKE sflight-connid,        " Connection number
        fldate LIKE sflight-fldate,        " Flight date
      END OF types_s_itab.
    Data Declaration...................................................*
         Field String To Hold Flight Details Record from SFLIGHT        *
    DATA
      fs_itab TYPE types_s_itab.
    Data Declaration...................................................*
         Internal Table To Hold Flight Details Records from SFLIGHT     *
    DATA
      t_itab LIKE STANDARD TABLE OF fs_itab.
    *" Type declarations...................................................
    Type declaration of the structure to hold data from table SBOOK     *
    TYPES:
    BEGIN OF type_s_sbook,
       carrid LIKE sbook-carrid,           " Carrier Id
       connid LIKE sbook-connid,           " Connection Number
       fldate LIKE sbook-fldate,           " Flight date
       bookid LIKE sbook-bookid,           " Booking number
       loccuram LIKE sbook-loccuram,       " Local currency
       loccurkey LIKE sbook-loccurkey,
       order_date LIKE sbook-order_date,   " Booking date
    END OF type_s_sbook.
    Data Declaration...................................................*
         Field String To Hold Flight Details Record from BOOK           *
    DATA
      fs_sbook TYPE type_s_sbook.
    Data Declaration...................................................*
         Internal Table To Hold Flight Details Records from SBOOK       *
    DATA
      t_sbook LIKE STANDARD TABLE OF fs_sbook.
    DATA
      w_checkbox.                          " Checkbox
    SELECT-OPTIONS:
      s_carr FOR spfli-carrid.             " Carrier id range
                          START-OF-SELECTION EVENT                      *
    START-OF-SELECTION.
      PERFORM selectq.
                          END-OF-SELECTION EVENT                        *
    END-OF-SELECTION.
      SET PF-STATUS 'YH1314_030502'.
      PERFORM display_basic.
    AT USER-COMMAND.
      PERFORM ucomm.
    *&    Form  selectq
        This subroutine retreive data from SPFLI table
      There are no interface parameters to be passed to this subroutine.
    FORM selectq .
      SELECT carrid                        " Carrier id
             connid                        " Connection number
             cityfrom                      " City from
             cityto                        " City to
             airpfrom                      " Airport from
             airpto                        " Airport to
             countryfr                     " Country from
             countryto                     " Country to
             INTO CORRESPONDING FIELDS OF TABLE t_spfli
             FROM spfli
             WHERE carrid IN s_carr.
    ENDFORM.                               " Selectq
    *&      Form  display_basic
        This subroutine displays data from internal table
      There are no interface parameters to be passed to this subroutine.
    FORM display_basic .
      LOOP AT t_spfli INTO fs_spfli.
        WRITE:
          / w_checkbox AS CHECKBOX,
            fs_spfli-carrid,
            fs_spfli-connid,
            fs_spfli-cityfrom,
            fs_spfli-cityto,
            fs_spfli-airpfrom,
            fs_spfli-airpto,
            fs_spfli-countryfr,
            fs_spfli-countryto.
      ENDLOOP.                             " LOOP AT T-SPFLI INTO...
    ENDFORM.                               " Display_basic
    *&      Form  UCOMM
      This subroutine for at user-command event
      There are no interface parameters to be passed to this subroutine.
    FORM ucomm .
      RANGES :
        r_carr FOR spfli-carrid,
        r_conn FOR spfli-connid,
        r_carrid FOR sflight-carrid,
        r_connid FOR sflight-connid,
        r_fldate FOR sflight-fldate.
      CASE sy-ucomm.
        WHEN 'DISPLAY'.
          DATA:
            lw_lines TYPE i,
            lw_lineno TYPE i VALUE 3.
          DESCRIBE TABLE t_spfli LINES lw_lines.
          DO lw_lines TIMES.
            READ LINE lw_lineno FIELD
                 VALUE w_checkbox   INTO w_checkbox
                       fs_spfli-carrid INTO  fs_spfli-carrid
                       fs_spfli-connid INTO  fs_spfli-connid.
            IF sy-subrc = 0.
              IF w_checkbox = 'X'.
                r_carr-sign = 'I'.
                r_carr-option = 'EQ'.
                r_carr-low = fs_spfli-carrid.
                APPEND r_carr.
                r_conn-sign = 'I'.
                r_conn-option = 'EQ'.
                r_conn-low = fs_spfli-connid.
                APPEND r_conn.
              ENDIF.                       " IF W_CHECKBOX = 'X'
            ENDIF.                         " IF SY-SUBRC = 0
            ADD 1 TO lw_lineno.
          ENDDO.                           " DO LW_LINES TIMES
          SUBMIT yh1314_030502_call
            WITH s_carr IN r_carr
            WITH s_conn IN r_conn
             AND RETURN.
          IMPORT t_itab FROM MEMORY ID 'YH1314'.
          LOOP AT t_itab INTO fs_itab.
            r_carrid-sign = 'I'.
            r_carrid-option = 'EQ'.
            r_carrid-low = fs_itab-carrid.
            APPEND r_carrid.
            r_connid-sign = 'I'.
            r_connid-option = 'EQ'.
            r_connid-low = fs_itab-connid.
            APPEND r_connid.
            r_fldate-sign = 'I'.
            r_fldate-option = 'EQ'.
            r_fldate-low = fs_itab-fldate.
            APPEND r_fldate.
          ENDLOOP.                         " LOOP AT T_ITAB INTO.....
          SELECT carrid                    " Carriee Id
                 connid                    " Connection number
                 fldate                    " Flight date
                 bookid                    " Booking number
                 loccuram                  " Local Currency
                 order_date                " Booking date
             INTO CORRESPONDING FIELDS OF TABLE t_sbook
             FROM sbook
             WHERE carrid IN r_carrid AND
                   connid IN r_connid AND
                   fldate IN r_fldate.
          IF SY-SUBRC NE 0.
            MESSAGE 'NO RECORDS FOUND'(006) TYPE 'S'.
          ENDIF.                           " IF SY-SUBRC NE 0
          LOOP AT t_sbook INTO fs_sbook.
            AT FIRST.
              WRITE: /5 'Carrier Id'(001),
                     20 'Conn Id'(002),
                     35 'Flight date'(003),
                     50 'Book Id'(004),
                     65 'Local Currency'(005).
            ENDAT.                         " AT FIRST
            WRITE: /5 fs_sbook-carrid,
                   20 fs_sbook-connid,
                   35 fs_sbook-fldate,
                   50 fs_sbook-bookid,
                   65 fs_sbook-loccuram CURRENCY fs_sbook-loccurkey.
          ENDLOOP.                         " LOOP AT T_SBOOK INTO.....
      ENDCASE.                             " CASE SY-UCOMM
    ENDFORM.                               " UCOMM
    Regards
    Kiran

  • Doubts with control break statements on internal table loops (AT/ENDAT)

    Hi, i've had a couple of doubts for a long while which I hope someone can clarify today:
    1) I know how to use the AT statements, however, i'm not sure I get correctly what this part of help regarding this commands means:
    <i>"The control level structure with internal tables is static. It corresponds exactly to the sequence of columns in the internal table (from left to right). In this context, the criteria according to which you sort the internal table are unimportant."</i>
    I've always sorted the internal table before the control break and it works that way. For example:
    SORT ITAB BY EBELN EBELP.
    LOOP AT ITAB.
      AT NEW EBELN.
    *   Code for the order header
      ENDAT.
    ENDLOOP.
    If I <b>don't</b> sort the internal table, it doesn't work! (i get dupplicated processing). In the example, if i have more than one register with the same EBELN and they're not consecutive, the header gets processed twice. I really don't get that part of the help text.
    2) I know this: <i>"At the start of a new control level (i.e. immediately after AT), the following occurs in the output area of the current LOOP statement:
    All character type fields (on the right) are filled with "*" after the current control level key.
    All other fields (on the right) are set to their initial values after the current control level key."</i>
    My doubt is: WHY is that this way? Because sometimes (most times) I need those fields INSIDE the statement! So when that happened i've solved it in one of three ways:
    LOOP AT ITAB INTO WA_ITAB.
      WA_ITAB_AUX = WA_ITAB.
      AT NEW FIELD.
        WA_ITAB = WA_ITAB_AUX.
    *   ...Rest of the code for the first register
      ENDAT.
    ENDLOOP.
    LOOP AT ITAB INTO WA_ITAB.
      AT NEW FIELD.
        READ TABLE ITAB INDEX SY-TABIX INTO WA_ITAB.
    *   ...Rest of the code for the first register
      ENDAT.
    ENDLOOP.
    * (Without AT)
    LOOP AT ITAB INTO WA_ITAB.
      IF WA_ITAB-FIELD <> FIELD_AUX.
        FIELD_AUX = WA_ITAB_FIELD.
    *   ...Rest of the code for the first register
      ENDIF.
    ENDLOOP.
    Is there any problem with this way of coding? Can be done better?
    Thank you very much in advance.

    Hi..,
    1)
    See if u sort the table on a field on which u r using AT ENDAT .. then all the records which are having the same value for that field will form a group or those reocrds will be at one place.. so when u sort the table for all the records  AT ENDAT  will get executed onli once..
    If u dont sort this table on this field then all these records will be at different places and in between there may be records with different value for this field.. so this AT ENDAT will get executed for each record !!
    2)
    No u cannot use the Right hand fields of the field in the table .. Because these AT events work as Group based operations... So till that field on which AT ENDAT is working it breaks that record into two groups.. One is the left hand fields including that field.. and right hand fields as another group.. and makes the right hand group as stars ****.  Thats y u can observe that even any one field in the left hand group changes the AT ENDAT will get executed  !!!!
    Hope u understood !!!
    regards,
    sai ramesh

Maybe you are looking for

  • Checking for null value in arraylist

    Hi i have an excel file which i i am reading into an arraylist row by row but not necesarrily that all columns in the row mite be filled. So how do i check for null values in the array list. try                     int cellCount = 0;                 

  • How do I deal with problems during business object construction?

    Hi Everyone. I'm wondering about best practices for program control flow when business objects can't be constructed properly. In my servlet I want to create a new Transaction business object based on the parameters of the HttpServletRequest. transact

  • Print List Archiving

    hi, When i see job log for print list link, i am getting messgae as Print list size exceeds 2 GB limit in spool system. How to reduce the size of print list.

  • Need Help in Workflow - User decision

    I have to pass 5 parameter with this user decision title but they only give 4 parameter options in the user decision step. Is there anyway I can have five parameter place? Please help

  • Using Illustrator CS5 to design for printing on DVDs

    When using a DVD/CD template to do a design to print onto a DVD/CD even though the template shows the circular shapes of both the outer circumfrance and the central hole etc if I paste a square design onto the circular template the design is not rest