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

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.

  • 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

  • Create Table Control using Dynamic Internal Table.

    Hi,
       I have requirement in which I will create a Dynamic Internal Table and then I need to create a Table Control Using that Internal Table. Now this can't be done using Screen Editor as it requires a pre-defined internal table or a DDIC Object.
      Please Help.

    This should be correct answer(I am not author of code below):
    REPORT ztablemaintace NO STANDARD PAGE HEADING.
    TYPE-POOLS: rsds.
    DATA: is_x030l TYPE x030l,
    it_dfies TYPE TABLE OF dfies,
    is_dfies TYPE dfies,
    it_fdiff TYPE TABLE OF field_dif,
    is_fdiff TYPE field_dif.
    DATA: w_selid TYPE rsdynsel-selid,
    it_tables TYPE TABLE OF rsdstabs,
    is_tables TYPE rsdstabs,
    it_fields TYPE TABLE OF rsdsfields,
    it_expr TYPE rsds_texpr,
    it_ranges TYPE rsds_trange,
    it_where TYPE rsds_twhere,
    is_where TYPE rsds_where,
    w_active TYPE i.
    DATA: it_content TYPE REF TO data,
    it_modif TYPE REF TO data,
    it_fcat TYPE lvc_t_fcat.
    DATA: w_okcode TYPE sy-ucomm.
    FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
    <ntab> TYPE STANDARD TABLE.
    * Macros
    DEFINE table_error.
      message e398(00) with 'Table' p_table &1.
    END-OF-DEFINITION.
    DEFINE fixed_val.
      is_fdiff-fieldname = is_dfies-fieldname.
      is_fdiff-fixed_val = &1.
      is_fdiff-no_input = 'X'.
      append is_fdiff to it_fdiff.
    END-OF-DEFINITION.
    * Selection screen
    SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME.
    PARAMETERS: p_table TYPE tabname OBLIGATORY "table
    MEMORY ID dtb
    MATCHCODE OBJECT dd_dbtb_16.
    SELECTION-SCREEN: BEGIN OF LINE,
    PUSHBUTTON 33(20) selopt USER-COMMAND sel,
    COMMENT 55(15) selcnt,
    END OF LINE.
    SELECTION-SCREEN: SKIP.
    PARAMETERS: p_rows TYPE i. "rows
    SELECTION-SCREEN: END OF BLOCK b01,
    SKIP,
    BEGIN OF BLOCK b02 WITH FRAME.
    PARAMETERS: p_displ TYPE c AS CHECKBOX. "display
    SELECTION-SCREEN: END OF BLOCK b02.
    * Initialization
    INITIALIZATION.
      MOVE '@4G@ Filter records' TO selopt.
    * PBO
    AT SELECTION-SCREEN OUTPUT.
      IF w_active IS INITIAL.
        CLEAR: selcnt.
      ELSE.
        WRITE w_active TO selcnt LEFT-JUSTIFIED.
      ENDIF.
    * PAI
    AT SELECTION-SCREEN.
      IF p_table NE is_x030l-tabname.
        CALL FUNCTION 'DDIF_NAMETAB_GET'
          EXPORTING
            tabname   = p_table
          IMPORTING
            x030l_wa  = is_x030l
          TABLES
            dfies_tab = it_dfies
          EXCEPTIONS
            OTHERS    = 1.
        IF is_x030l IS INITIAL.
          table_error 'does not exist or is not active'.
        ELSEIF is_x030l-tabtype NE 'T'.
          table_error 'is not selectable'.
    *    ELSEIF is_x030l-align NE 0.
    *      table_error 'has alignment - cannot continue'.
        ENDIF.
    * Default values for system fields
        REFRESH: it_fdiff.
        is_fdiff-tabname = p_table.
        LOOP AT it_dfies INTO is_dfies.
          IF is_dfies-datatype = 'CLNT'.
            fixed_val sy-mandt.
          ELSEIF is_dfies-rollname = 'ERDAT'
          OR is_dfies-rollname = 'ERSDA'
          OR is_dfies-rollname = 'AEDAT'
          OR is_dfies-rollname = 'LAEDA'.
            fixed_val sy-datum.
          ELSEIF is_dfies-rollname = 'ERTIM'
          OR is_dfies-rollname = 'AETIM'.
            fixed_val sy-uzeit.
          ELSEIF is_dfies-rollname = 'ERNAM'
          OR is_dfies-rollname = 'AENAM'.
            fixed_val sy-uname.
          ENDIF.
          CALL FUNCTION '/SAPDMC/DATAELEMENT_GET_TEXTS'
            EXPORTING
              name        = is_dfies-rollname
            IMPORTING
              text_middle = is_dfies-reptext
            EXCEPTIONS
              not_found   = 1
              OTHERS      = 2.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
          MODIFY it_dfies FROM is_dfies.
      ENDLOOP.
    * Prepare free selection on table
      REFRESH it_tables.
      is_tables-prim_tab = p_table.
      APPEND is_tables TO it_tables.
      CLEAR: w_selid.
    ENDIF.
    IF sy-ucomm = 'SEL'.
      IF w_selid IS INITIAL.
    * Init free selection dialog
        CALL FUNCTION 'FREE_SELECTIONS_INIT'
          EXPORTING
            expressions  = it_expr
          IMPORTING
            selection_id = w_selid
            expressions  = it_expr
          TABLES
            tables_tab   = it_tables
          EXCEPTIONS
            OTHERS       = 1.
      ENDIF.
    * Display free selection dialog
      CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
        EXPORTING
          selection_id            = w_selid
          title                   = 'Selection'
          status                  = 1
          as_window               = 'X'
        IMPORTING
          expressions             = it_expr
          field_ranges            = it_ranges
          number_of_active_fields = w_active
        TABLES
          fields_tab              = it_fields
        EXCEPTIONS
          OTHERS                  = 1.
    ENDIF.
    * Start of processing
    START-OF-SELECTION.
      PERFORM f_create_table USING p_table.
      PERFORM f_select_table.
      PERFORM f_display_table.
    * FORM f_create_table *
    FORM f_create_table USING in_tabname.
      FIELD-SYMBOLS: <fcat> TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = in_tabname
        CHANGING
          ct_fieldcat      = it_fcat
        EXCEPTIONS
          OTHERS           = 1.
      IF sy-subrc = 0.
    *   Complete field catalog
        LOOP AT it_fcat ASSIGNING <fcat>.
          <fcat>-tabname = in_tabname.
        ENDLOOP.
        CALL FUNCTION 'LVC_FIELDCAT_COMPLETE'
          CHANGING
            ct_fieldcat = it_fcat
          EXCEPTIONS
            OTHERS      = 1.
      ELSE.
        WRITE: 'Error building field catalog'.
        STOP.
      ENDIF.
    * Create dynamic table for data
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fcat
        IMPORTING
          ep_table        = it_content.
      IF sy-subrc = 0.
        ASSIGN it_content->* TO <itab>.
      ELSE.
        WRITE: 'Error creating internal table'.
        STOP.
      ENDIF.
    * Create dynamic table for modif
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fcat
        IMPORTING
          ep_table        = it_modif.
      IF sy-subrc = 0.
        ASSIGN it_modif->* TO <ntab>.
      ELSE.
        WRITE: 'Error creating internal table'.
        STOP.
      ENDIF.
    ENDFORM.                    "f_create_table
    * FORM f_select_table *
    FORM f_select_table.
      IF w_active = 0.
        SELECT * FROM (p_table)
        INTO CORRESPONDING FIELDS OF TABLE <itab>
        UP TO p_rows ROWS.
      ELSE.
    * Selection with parameters
        CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_WHERE'
          EXPORTING
            field_ranges  = it_ranges
          IMPORTING
            where_clauses = it_where.
        READ TABLE it_where INTO is_where WITH KEY tablename = p_table.
        SELECT * FROM (p_table)
        INTO CORRESPONDING FIELDS OF TABLE <itab>
        UP TO p_rows ROWS
        WHERE (is_where-where_tab).
      ENDIF.
      IF sy-dbcnt = 0.
        WRITE: 'No record selected'.
        STOP.
      ENDIF.
    ENDFORM.                    "f_select_table
    * FORM f_display_table *
    FORM f_display_table.
      DATA: l_answer TYPE c,
      l_eflag TYPE c.
      CLEAR: w_okcode.
      REFRESH: <ntab>.
    * Display table contents
      CALL FUNCTION 'STC1_FULLSCREEN_TABLE_CONTROL'
        EXPORTING
          header       = p_table
          tabname      = p_table
          display_only = p_displ
          endless      = 'X'
          no_button    = space
        IMPORTING
          okcode       = w_okcode
        TABLES
    *      nametab      = it_dfies
          table        = <itab>
    *      fielddif     = it_fdiff
          modif_table  = <ntab>
        EXCEPTIONS
          OTHERS       = 1.
      IF sy-subrc = 0.
        IF p_displ IS INITIAL AND w_okcode = 'SAVE'.
    * Confirm update
          CALL FUNCTION 'POPUP_TO_CONFIRM'
            EXPORTING
              titlebar              = p_table
              text_question         = 'Do you want to update table ?'
              default_button        = '2'
              display_cancel_button = ' '
            IMPORTING
              answer                = l_answer
            EXCEPTIONS
              OTHERS                = 1.
          IF l_answer = '1'.
    * Apply modifications
            IF NOT <ntab>[] IS INITIAL.
              PERFORM f_add_system USING space.
              MODIFY (p_table) FROM TABLE <ntab>.
              IF sy-subrc NE 0.
                l_eflag = 'X'.
              ENDIF.
            ENDIF.
    * Apply deletions
            IF l_eflag IS INITIAL.
              REFRESH: <ntab>.
              CALL FUNCTION 'STC1_GET_DATA'
                TABLES
                  deleted_data = <ntab>
                EXCEPTIONS
                  OTHERS       = 1.
              IF NOT <ntab>[] IS INITIAL.
                DELETE (p_table) FROM TABLE <ntab>.
                IF sy-subrc NE 0.
                  ROLLBACK WORK.
                  l_eflag = 'X'.
                ENDIF.
              ENDIF.
            ENDIF.
    * Apply creations
            IF l_eflag IS INITIAL.
              REFRESH: <ntab>.
              CALL FUNCTION 'STC1_GET_DATA'
                TABLES
                  new_data = <ntab>
                EXCEPTIONS
                  OTHERS   = 1.
              IF NOT <ntab>[] IS INITIAL.
                PERFORM f_add_system USING 'X'.
                INSERT (p_table) FROM TABLE <ntab>.
                IF sy-subrc NE 0.
                  ROLLBACK WORK.
                  l_eflag = 'X'.
                ENDIF.
              ENDIF.
            ENDIF.
            IF l_eflag IS INITIAL.
              COMMIT WORK.
              MESSAGE s261(53).
            ELSE.
              MESSAGE s075(3i).
              PERFORM f_select_table.
            ENDIF.
          ENDIF.
    * Display table again
          PERFORM f_display_table.
        ENDIF.
      ENDIF.
    ENDFORM.                    "f_display_table
    * FORM f_add_system *
    FORM f_add_system USING new TYPE c.
      FIELD-SYMBOLS: <irec> TYPE ANY,
      <upd> TYPE ANY.
      LOOP AT it_fdiff INTO is_fdiff.
        READ TABLE it_dfies INTO is_dfies
        WITH KEY fieldname = is_fdiff-fieldname.
        LOOP AT <ntab> ASSIGNING <irec>.
          ASSIGN COMPONENT is_fdiff-fieldname OF STRUCTURE <irec> TO <upd>.
          IF is_dfies-datatype = 'CLNT'.
            <upd> = sy-mandt.
          ELSE.
            CASE is_dfies-rollname.
              WHEN 'AENAM'.
                <upd> = sy-uname.
              WHEN 'AEDAT' OR 'LAEDA'.
                <upd> = sy-datum.
              WHEN 'AETIM'.
                <upd> = sy-uzeit.
              WHEN OTHERS.
            ENDCASE.
          ENDIF.
        ENDLOOP.
      ENDLOOP.
    ENDFORM.                    "f_add_system

  • 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

  • Control break statements in internal tables

    explain the concept of at end of in internal example with siutable example.

    AT END OF f.
    Effect
    f is a sub-field of an internal table or extract dataset (EXTRACT) which is being processed with LOOP, i.e. the variants 1 and 2 only make sense within a LOOP.
    Both "AT NEW f." and "AT END OF f. " introduce processing blocks which are concluded by " ENDAT.".
    These processing blocks are processed whenever the contents of a field f or a sub-field defined before f change as a result of processing with LOOP. "AT NEW f." begins a new group of (table) lines with the same contents as the field f while "AT END OF f." concludes such a group.
    Within the AT ... ENDAT processing of internal tables, all argument fields following f are filled with "*".
    Examples
    1. AT for sub-fields of an internal table
    DATA: BEGIN OF COMPANIES OCCURS 20,
            NAME(30),
            PRODUCT(20),
            SALES TYPE I,
          END   OF COMPANIES.
    LOOP AT COMPANIES.
      AT NEW NAME.
        NEW-PAGE.
        WRITE / COMPANIES-NAME.
      ENDAT.
      WRITE: / COMPANIES-PRODUCT, COMPANIES-SALES.
      AT END OF NAME.
        SUM.
        WRITE: / COMPANIES-NAME, COMPANIES-SALES.
      ENDAT.
    ENDLOOP.
    Check this , this is Quoted from SAP help.
    Regards
    Vijay

  • 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

  • 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.

  • Reg:Submit statement Return Internal Table

    Hi Team,
    I have a query to return the internal table from the called program via SUBMIT statement to the calling statement ??
    Example : Thing is that consider reports A and B , Report B is getting called from report A where in B we have one internal table full of data that i need to pull to report A and there i need to process it.
    How can i achieve this?
    Please let me know the possible ways.
    Karthik.S

    Hi karthik,
    SUBMIT .... AND RETURN EXPORTING LIST TO MEMORY.
    Then use FM LIST_FROM_MEMORY.
    Thanks,
    Anil

  • Reg: Collect statement in internal table

    Hi,
       Can any one tell me wether we can use the collect statement in an internal table which has no header line
    if it can be used can anyone please send me a sample snippet
    Thanks In ADVANCE
    Guhapriyan Subrahmanyam

    Hi Guhapriyan,
    I have used the collect statement in the way as shown..
    DATA : BEGIN of I_ALLOCATIONS OCCURS 0,
            PSPNR LIKE PRPS-PSPNR,
            PSPID LIKE PROJ-PSPID,
            PSPHI LIKE PRPS-PSPHI,
            POST1 LIKE PROJ-POST1,
            ZZLOB LIKE PROJ-ZZLOB,
            WERKS LIKE PROJ-WERKS,
            SOBID LIKE HRP1001-SOBID,
            OBJID LIKE HRP1001-OBJID,
            BEGDA LIKE HRP1001-BEGDA,
            ENDDA LIKE HRP1001-ENDDA,
            PROZT LIKE HRP1001-PROZT,
            LOB   LIKE HRP1000-STEXT,
            TEMP  TYPE P decimals 2,
            TYPE(3),
            ZROLE LIKE PA0001-ZROLE,
            HOLID TYPE P decimals 2,
            LEAVE TYPE P decimals 2,
            DAYS  TYPE P decimals 2,
           END of I_ALLOCATIONS.
    DATA:  I_ALLOCATION LIKE I_ALLOCATIONS OCCURS 0 WITH HEADER LINE.
    ************Populate I_ALLOCATIONS **************
    LOOP AT I_ALLOCATIONS.
        COLLECT I_ALLOCATIONS INTO I_ALLOCATION.
    ENDLOOP.
    Actually i had requirement like u, but this one is rather simple...
    Get the required data in an I_Table which dont require Header line..
    Later on collect this particular I_Table in other I_Table1 with the Header Line...
    Regards,
    Abhishek

  • Two collect statement from internal table

    Dear Experts,
    I want populate values to two internal tables from a internal table.
    can i use two collect statement for different internal table from a single internal table.
    advise please.
    Thanks in advance.
    R.Rajendran

    hi there....
    well u can very well use this thing.....
    use the two colect statements inside the loop which u will use  to read the records of the input table.
    hope it helps.
    do reward if it does.

  • EXPORT STATEMENT fro INTERNAL TABLE VALUES

    Hi,
    From one program I am calling my program using SUBMIT statement.
    In the subprogram, I will be doing som process.If I get any error message I am storing in an internal table.
    This internal table has to come to the main program.
    So that I will create an Idoc in main program for all the error messages.
    For this I am using EXPORT IMPORT statements.
      wa_idoc_msg-type = text-003.
      wa_idoc_msg-id =  'ZLES'.
      wa_idoc_msg-number = '477'.
      append wa_idoc_msg to t_idoc_msg.
      clear wa_idoc_msg.
      exit.
      export (T_IDOC_MSG) to memory id 'T_IDOC_MSG'.
    Now In this export line, I am getting error as ZLES not able to recognize.
    Help required for this issue.

    Hi,
    Check the below link
    http://www.sap-img.com/abap/difference-between-sap-and-abap-memory.htm
    Regards,
    nagaraj

  • GET statement and internal table

    Hi community,
    I use the GET statement and I want to use some older code segments.
    I read somewhere that I can use the result of GET like an internal table.
    So I tried to get the content of bsid into my internal table it_bsid. But that doesn't seem to work.
    Do you have any advice in this?
    I wanted to do the following:
    TABLES:
            KNA1,
            BSID,
            BKPF.
    DATA:
          it_bsid TYPE TABLE OF bsid WITH HEADER LINE,
          is_bsid LIKE LINE OF it_bsid,
    GET bsid.
    LOOP AT bsid.
      APPEND it_bsid.
    ENDLOOP.
    -or-
    GET bsid.
    LOOP AT bsid INTO is_bsid.
      APPEND is_bsid TO it_bsid.
    ENDLOOP.
    But in both cases I get an error.
    ' "VERSION ... ." expected after "BSID" '
    Do you know what is the reason for that?
    Regards
    Tobias
    Edited by: Tobias Oelschlaeger on Feb 29, 2008 4:18 PM

    Hi Tobias,
    first you have to assign a logical database which has BSID to your program (in program attributes).
    Then GET is the event triggered by the next BSID record according to your selection. You can not LOOP here but you may append to an internal table. This table may be processed using LOOP in the END-OF-SELECTION event.
    Read some documentation about LDB [Logical Databases|http://help.sap.com/erp2005_ehp_01/helpdata/en/f0/ca4584260211d28a430000e829fbbd/content.htm] - it may help to understand the concept of this obsolete technique.
    Regards,
    Clemens

  • 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.

  • 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

Maybe you are looking for