Internal table events

hai ,
     how  i can use  internal table events in ALV's please send me example code
      also .

Hi Sathish,
According you your query, You want to display the data in Hierarchical format. I am attaching the code of hierarchical format. You just create a Z report and test this report. So that can solve your problem easily with the help of this code.
REPORT BALVHD01 NO STANDARD PAGE HEADING.
ALV
TYPE-POOLS: SLIS.
DB-Table
TABLES: SCARR, SPFLI.
Includes
INCLUDE .
CONSTANTS:
GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
      GS_LAYOUT   TYPE SLIS_LAYOUT_ALV,
      GS_KEYINFO  TYPE SLIS_KEYINFO_ALV,
      GT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV,
      GT_EVENTS   TYPE SLIS_T_EVENT.
Data to be displayed
DATA: BEGIN OF GT_SPFLI OCCURS 0.
        INCLUDE STRUCTURE SPFLI.
DATA:
      BOX,
      WERT(4) TYPE P,
      LIGHTS.
DATA: END OF GT_SPFLI.
DATA: BEGIN OF GT_SCARR OCCURS 0.
        INCLUDE STRUCTURE SCARR.
DATA: BOX,
      LIGHTS.
DATA: END OF GT_SCARR.
DATA: G_REPID LIKE SY-REPID.
DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
Report Selections
SELECT-OPTIONS CARRID FOR SCARR-CARRID.
SELECTION-SCREEN SKIP 1.
Parameters
PARAMETERS: P_MAXROW TYPE I DEFAULT 50.
SELECTION-SCREEN SKIP 1.
Variante
SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE TEXT-064.
PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.
SELECTION-SCREEN END OF BLOCK 0.
Layout
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-060.
PARAMETERS:
            P_ZEBRA AS CHECKBOX DEFAULT ' ',
            P_NOCOLH AS CHECKBOX DEFAULT ' ',
            P_COLOPT AS CHECKBOX DEFAULT ' ',
            P_KEYHOT AS CHECKBOX DEFAULT ' ',
            P_NOINPT AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN END OF BLOCK A.
SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-061.
PARAMETERS:
            P_LIGHTN  RADIOBUTTON GROUP LIG ,
            P_LIGHTH  RADIOBUTTON GROUP LIG ,
            P_LIGHTI  RADIOBUTTON GROUP LIG ,
            P_LIGHTC AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN END OF BLOCK B.
SELECTION-SCREEN BEGIN OF BLOCK C WITH FRAME TITLE TEXT-062.
PARAMETERS:
            P_TOTONL AS CHECKBOX DEFAULT ' ',
            P_TOTEXT(60),
            P_STTEXT(60).
SELECTION-SCREEN END OF BLOCK C.
SELECTION-SCREEN BEGIN OF BLOCK D WITH FRAME TITLE TEXT-063.
PARAMETERS:
            CHCKBOXN  RADIOBUTTON GROUP BOX ,
            CHCKBOXH  RADIOBUTTON GROUP BOX ,
            CHCKBOXI  RADIOBUTTON GROUP BOX ,
          P_GROUPB AS CHECKBOX DEFAULT ' ',
            P_DETPOP AS CHECKBOX DEFAULT 'X',
            P_GROUPS AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN END OF BLOCK D.
DATA:       G_BOXNAM TYPE SLIS_FIELDNAME VALUE  'BOX',
            P_F2CODE LIKE SY-UCOMM       VALUE  '&ETA',
            P_LIGNAM TYPE SLIS_FIELDNAME VALUE  'LIGHTS',
            G_SAVE(1) TYPE C,
            G_TABNAME_HEADER TYPE SLIS_TABNAME,
            G_TABNAME_ITEM   TYPE SLIS_TABNAME,
            G_DEFAULT(1) TYPE C,
            G_EXIT(1) TYPE C,
            GX_VARIANT LIKE DISVARIANT,
            G_VARIANT LIKE DISVARIANT.
INITIALIZATION.
  G_REPID = SY-REPID.
  G_TABNAME_HEADER = 'GT_SCARR'.
  G_TABNAME_ITEM   = 'GT_SPFLI'.
define keyinfo
  CLEAR GS_KEYINFO.
  GS_KEYINFO-HEADER01 = 'CARRID'.
  GS_KEYINFO-ITEM01   = 'CARRID'.
  GS_KEYINFO-HEADER02 = SPACE.
  GS_KEYINFO-ITEM02   = 'CONNID'.
  PERFORM E01_FIELDCAT_INIT  USING GT_FIELDCAT[].
  PERFORM E03_EVENTTAB_BUILD USING GT_EVENTS[].
  PERFORM E04_COMMENT_BUILD  USING GT_LIST_TOP_OF_PAGE[].
  PERFORM E07_SP_GROUP_BUILD USING GT_SP_GROUP[].
Schalter Varianten benutzerspezifisch/allgemein speicherbar setzen
Set Options: save variants userspecific or general
  G_SAVE = 'A'.
  PERFORM VARIANT_INIT.
Get default variant
  GX_VARIANT = G_VARIANT.
  CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
       EXPORTING
            I_SAVE     = G_SAVE
       CHANGING
            CS_VARIANT = GX_VARIANT
       EXCEPTIONS
            NOT_FOUND  = 2.
  IF SY-SUBRC = 0.
    P_VARI = GX_VARIANT-VARIANT.
  ENDIF.
Process on value request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
  PERFORM F4_FOR_VARIANT.
PAI
AT SELECTION-SCREEN.
  PERFORM PAI_OF_SELECTION_SCREEN.
START-OF-SELECTION.
  PERFORM SELECTION.
END-OF-SELECTION.
  PERFORM E05_LAYOUT_BUILD USING GS_LAYOUT.     "wg. Parameters
Call ABAP/4 List Viewer
  CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
       EXPORTING
            I_CALLBACK_PROGRAM       = G_REPID
          I_CALLBACK_PF_STATUS_SET = ' '
          I_CALLBACK_USER_COMMAND  = ' '
            IS_LAYOUT                = GS_LAYOUT
            IT_FIELDCAT              = GT_FIELDCAT[]
          IT_EXCLUDING             =
            IT_SPECIAL_GROUPS        = GT_SP_GROUP[]
          IT_SORT                  =
          IT_FILTER                =
          IS_SEL_HIDE              =
          I_SCREEN_START_COLUMN    = 0
          I_SCREEN_START_LINE      = 0
          I_SCREEN_END_COLUMN      = 0
          I_SCREEN_END_LINE        = 0
          i_default                = g_default
            I_SAVE                   = G_SAVE
            IS_VARIANT               = G_VARIANT
            IT_EVENTS                = GT_EVENTS[]
          IT_EVENT_EXIT            =
            I_TABNAME_HEADER         = G_TABNAME_HEADER
            I_TABNAME_ITEM           = G_TABNAME_ITEM
            IS_KEYINFO               = GS_KEYINFO
          IS_PRINT                 =
     IMPORTING
          E_EXIT_CAUSED_BY_CALLER  =
       TABLES
            T_OUTTAB_HEADER          = GT_SCARR
            T_OUTTAB_ITEM            = GT_SPFLI.
      FORM E01_FIELDCAT_INIT                                        *
-->  E01_LT_FIELDCAT                                               *
FORM E01_FIELDCAT_INIT USING E01_LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
  DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'DISTANCE'.
  LS_FIELDCAT-TABNAME      = G_TABNAME_ITEM.
  LS_FIELDCAT-NO_OUT       = 'X'.
  LS_FIELDCAT-NO_SUM       = 'X'.
  LS_FIELDCAT-SP_GROUP = 'A'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'DISTID'.
  LS_FIELDCAT-TABNAME      = G_TABNAME_ITEM.
  LS_FIELDCAT-NO_OUT       = 'X'.
  LS_FIELDCAT-NO_SUM       = 'X'.
  LS_FIELDCAT-SP_GROUP = 'A'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'CARRID'.
  LS_FIELDCAT-TABNAME      = G_TABNAME_ITEM.
  LS_FIELDCAT-TECH         = 'X'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'FLTYPE'.
  LS_FIELDCAT-TABNAME      = G_TABNAME_ITEM.
  LS_FIELDCAT-NO_OUT       = 'X'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
          I_PROGRAM_NAME         =
            I_INTERNAL_TABNAME     = G_TABNAME_HEADER
            I_STRUCTURE_NAME       = 'SCARR'
          I_CLIENT_NEVER_DISPLAY = 'X'
       CHANGING
            CT_FIELDCAT            = E01_LT_FIELDCAT[].
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
          I_PROGRAM_NAME         =
            I_INTERNAL_TABNAME     = G_TABNAME_ITEM
            I_STRUCTURE_NAME       = 'SPFLI'
          I_CLIENT_NEVER_DISPLAY = 'X'
       CHANGING
            CT_FIELDCAT            = E01_LT_FIELDCAT[].
Nachbessern!!!
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME    = 'CARRID'.
LS_FIELDCAT-TABNAME      = G_TABNAME_HEADER.
LS_FIELDCAT-REF_FIELDNAME = 'CARRID'.
LS_FIELDCAT-REF_TABNAME   = 'SCARR'.
LS_FIELDCAT-KEY           = 'X'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
geht am Anfang nicht !!!!
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-COL_POS       = 99.
  LS_FIELDCAT-FIELDNAME    = 'WERT'.
  LS_FIELDCAT-TABNAME      = G_TABNAME_ITEM.
  LS_FIELDCAT-REPTEXT_DDIC = 'Wert'(070).
  LS_FIELDCAT-OUTPUTLEN    = 4.
  LS_FIELDCAT-DATATYPE    = 'CURR'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
ENDFORM.
      FORM E02_DATA_ADD                                             *
FORM E02_DATA_ADD TABLES E02_LT_SPFLI STRUCTURE GT_SPFLI
                         E02_LT_SCARR STRUCTURE GT_SCARR.
  LOOP AT E02_LT_SPFLI.
    IF SY-TABIX > 10.
      E02_LT_SPFLI-BOX  = 'X'.
      E02_LT_SPFLI-LIGHTS = '3'.
    ELSE.
      IF SY-TABIX = 1.
        E02_LT_SPFLI-LIGHTS = '2'.
      ELSE.
        E02_LT_SPFLI-LIGHTS = '1'.
      ENDIF.
    ENDIF.
    E02_LT_SPFLI-WERT = SY-TABIX MOD 5.
    MODIFY E02_LT_SPFLI.
  ENDLOOP.
  LOOP AT E02_LT_SCARR.
    IF SY-TABIX > 10.
      E02_LT_SCARR-BOX  = 'X'.
      E02_LT_SCARR-LIGHTS = '3'.
    ELSE.
      IF SY-TABIX = 1.
        E02_LT_SCARR-LIGHTS = '2'.
      ELSE.
        E02_LT_SCARR-LIGHTS = '1'.
      ENDIF.
    ENDIF.
    MODIFY E02_LT_SCARR.
  ENDLOOP.
ENDFORM.
      FORM E03_EVENTTAB_BUILD                                       *
-->  E03_LT_EVENTS                                                 *
FORM E03_EVENTTAB_BUILD USING E03_LT_EVENTS TYPE SLIS_T_EVENT.
  DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
            I_LIST_TYPE = 0
       IMPORTING
            ET_EVENTS   = E03_LT_EVENTS.
  READ TABLE E03_LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
                           INTO LS_EVENT.
  IF SY-SUBRC = 0.
    MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
    APPEND LS_EVENT TO E03_LT_EVENTS.
  ENDIF.
ENDFORM.
      FORM E04_COMMENT_BUILD                                        *
-->  E04_LT_TOP_OF_PAGE                                            *
FORM E04_COMMENT_BUILD USING E04_LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
  DATA: LS_LINE TYPE SLIS_LISTHEADER.
Listenüberschrift: Typ H
  CLEAR LS_LINE.
  LS_LINE-TYP  = 'H'.
LS_LINE-KEY:  not used for this type
  LS_LINE-INFO = TEXT-001.
  APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
Kopfinfo: Typ S
  CLEAR LS_LINE.
  LS_LINE-TYP  = 'S'.
  LS_LINE-KEY  = TEXT-050.
  LS_LINE-INFO = TEXT-010.
  APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
  LS_LINE-KEY  = TEXT-051.
  APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
Aktionsinfo: Typ A
  CLEAR LS_LINE.
  LS_LINE-TYP  = 'A'.
LS_LINE-KEY:  not used for this type
  LS_LINE-INFO = TEXT-002.
  APPEND LS_LINE TO  E04_LT_TOP_OF_PAGE.
ENDFORM.
      FORM E05_LAYOUT_BUILD                                         *
<->  E05_LS_LAYOUT                                                 *
FORM E05_LAYOUT_BUILD USING E05_LS_LAYOUT TYPE SLIS_LAYOUT_ALV.
  IF P_LIGHTI = 'X'.
    E05_LS_LAYOUT-LIGHTS_FIELDNAME = P_LIGNAM.
    E05_LS_LAYOUT-LIGHTS_TABNAME   = G_TABNAME_ITEM.
    E05_LS_LAYOUT-LIGHTS_CONDENSE  = P_LIGHTC.
  ENDIF.
  IF P_LIGHTH = 'X'.
    E05_LS_LAYOUT-LIGHTS_FIELDNAME = P_LIGNAM.
    E05_LS_LAYOUT-LIGHTS_TABNAME   = G_TABNAME_HEADER.
    E05_LS_LAYOUT-LIGHTS_CONDENSE  = P_LIGHTC.
  ENDIF.
  IF P_LIGHTN = 'X'.
    CLEAR E05_LS_LAYOUT-LIGHTS_FIELDNAME.
    CLEAR E05_LS_LAYOUT-LIGHTS_TABNAME.
    CLEAR E05_LS_LAYOUT-LIGHTS_CONDENSE.
  ENDIF.
  IF CHCKBOXN = 'X'.
    E05_LS_LAYOUT-BOX_FIELDNAME = SPACE.
    E05_LS_LAYOUT-BOX_TABNAME   = SPACE.
  ENDIF.
  IF CHCKBOXH = 'X'.
    E05_LS_LAYOUT-BOX_FIELDNAME     = G_BOXNAM.
    E05_LS_LAYOUT-BOX_TABNAME       = G_TABNAME_HEADER.
  ENDIF.
  IF CHCKBOXI = 'X'.
    E05_LS_LAYOUT-BOX_FIELDNAME     = G_BOXNAM.
    E05_LS_LAYOUT-BOX_TABNAME       = G_TABNAME_ITEM.
  ENDIF.
  E05_LS_LAYOUT-HEADER_TEXT       = TEXT-071.
  E05_LS_LAYOUT-ITEM_TEXT         = TEXT-072.
  E05_LS_LAYOUT-DEFAULT_ITEM      = 'X'.
  E05_LS_LAYOUT-F2CODE            = P_F2CODE.
  E05_LS_LAYOUT-ZEBRA          = P_ZEBRA.
  E05_LS_LAYOUT-COLWIDTH_OPTIMIZE = P_COLOPT.
  E05_LS_LAYOUT-NO_INPUT          = P_NOINPT.
  E05_LS_LAYOUT-NO_COLHEAD        = P_NOCOLH.
  E05_LS_LAYOUT-TOTALS_TEXT       = P_TOTEXT.
  E05_LS_LAYOUT-SUBTOTALS_TEXT    = P_STTEXT.
  E05_LS_LAYOUT-TOTALS_ONLY       = P_TOTONL.
  E05_LS_LAYOUT-KEY_HOTSPOT       = P_KEYHOT.
  E05_LS_LAYOUT-DETAIL_POPUP      = P_DETPOP.
  E05_LS_LAYOUT-GROUP_CHANGE_EDIT = P_GROUPS.
E05_LS_LAYOUT-GROUP_BUTTONS     = P_GROUPB.
  E05_LS_LAYOUT-GROUP_BUTTONS     = SPACE.
ENDFORM.
      FORM E07_SP_GROUP_BUILD                                       *
-->  E07_LT_SP_GROUP                                               *
FORM E07_SP_GROUP_BUILD USING E07_LT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV.
  DATA: LS_SP_GROUP TYPE SLIS_SP_GROUP_ALV.
  CLEAR  LS_SP_GROUP.
  LS_SP_GROUP-SP_GROUP = 'A'.
  LS_SP_GROUP-TEXT     = TEXT-005.
  APPEND LS_SP_GROUP TO E07_LT_SP_GROUP.
ENDFORM.
      FORM SELECTION                                                *
FORM SELECTION.
  SELECT * FROM SCARR INTO CORRESPONDING FIELDS OF TABLE GT_SCARR
                                              WHERE CARRID IN CARRID.
  SELECT * FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE GT_SPFLI
                                              UP TO P_MAXROW ROWS
                                              WHERE CARRID IN CARRID.
  LOOP AT GT_SCARR.
    READ TABLE GT_SPFLI WITH KEY CARRID = GT_SCARR-CARRID.
    IF SY-SUBRC NE 0.
      DELETE GT_SCARR.
    ENDIF.
  ENDLOOP.
  PERFORM E02_DATA_ADD TABLES GT_SPFLI GT_SCARR.
ENDFORM.
      FORM TOP_OF_PAGE                                              *
FORM TOP_OF_PAGE.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
       EXPORTING
            IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
ENDFORM.
      FORM F4_FOR_VARIANT                                           *
FORM F4_FOR_VARIANT.
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
       EXPORTING
            IS_VARIANT          = G_VARIANT
            I_SAVE              = G_SAVE
            I_TABNAME_HEADER    = G_TABNAME_HEADER
            I_TABNAME_ITEM      = G_TABNAME_ITEM
          it_default_fieldcat =
       IMPORTING
            E_EXIT              = G_EXIT
            ES_VARIANT          = GX_VARIANT
       EXCEPTIONS
            NOT_FOUND = 2.
  IF SY-SUBRC = 2.
    MESSAGE ID SY-MSGID TYPE 'S'      NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ELSE.
    IF G_EXIT = SPACE.
      P_VARI = GX_VARIANT-VARIANT.
    ENDIF.
  ENDIF.
ENDFORM.
*&      Form  PAI_OF_SELECTION_SCREEN
      text
FORM PAI_OF_SELECTION_SCREEN.
  IF NOT P_VARI IS INITIAL.
    MOVE G_VARIANT TO GX_VARIANT.
    MOVE P_VARI TO GX_VARIANT-VARIANT.
    CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
         EXPORTING
              I_SAVE     = G_SAVE
         CHANGING
              CS_VARIANT = GX_VARIANT.
    G_VARIANT = GX_VARIANT.
  ELSE.
    PERFORM VARIANT_INIT.
  ENDIF.
ENDFORM.                               " PAI_OF_SELECTION_SCREEN
*&      Form  VARIANT_INIT
      text
-->  p1        text
<--  p2        text
FORM VARIANT_INIT.
  CLEAR G_VARIANT.
  G_VARIANT-REPORT = G_REPID.
ENDFORM.                               " VARIANT_INIT
Thanks and Best Regards,
Vijay

Similar Messages

  • Report using internal table events

    Hi,
    i have an internal table with  the fields 1. profitcenter 2. company code 3. gl account 4. amount
    for each profit center i need to seggregate accounts based on company code.
    the report should look like the one below.
    please suggest some code using internal table events at new , at end etc. as im not using alv. your help will be rewarded
    regards,
    ravi.
    -Profitcenter-companycodeglaccount-amount---
    -pfcenter1----
    glaccount1-1000---
    glaccount2-2000---
    4444-total--3000---
    glaccount1-4000---
    glaccount2-1000---
    3333-total--5000---
    -profitcentre1*total8000---
    profitcentre2.........

    Hi.
    TYPES: BEGIN OF G_I_DATA,
             PROFIT(4)   TYPE C,
             COMPANY(4)  TYPE C,
             ACCOUNT(10) TYPE C,
             AMOUNT      TYPE P,
           END OF G_I_DATA.
    DATA: G_IT_DATA TYPE TABLE OF G_I_DATA,
          G_WA_DATA TYPE G_I_DATA.
    DATA: G_SUM_COMPANY  TYPE P,
          G_SUM_PROFIT   TYPE P,
          G_AMOUNT       TYPE P.
      G_WA_DATA-PROFIT = '0001'.
      G_WA_DATA-COMPANY = '1111'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
      G_WA_DATA-AMOUNT = 2000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0001'.
      G_WA_DATA-COMPANY = '1111'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
      G_WA_DATA-AMOUNT = 3000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0001'.
      G_WA_DATA-COMPANY = '2222'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
      G_WA_DATA-AMOUNT = 4000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0001'.
      G_WA_DATA-COMPANY = '2222'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
      G_WA_DATA-AMOUNT = 5000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0002'.
      G_WA_DATA-COMPANY = '1111'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
      G_WA_DATA-AMOUNT = 2000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0002'.
      G_WA_DATA-COMPANY = '1111'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
      G_WA_DATA-AMOUNT = 3000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0002'.
      G_WA_DATA-COMPANY = '2222'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
      G_WA_DATA-AMOUNT = 4000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0002'.
      G_WA_DATA-COMPANY = '2222'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
      G_WA_DATA-AMOUNT = 5000.
      APPEND G_WA_DATA TO G_IT_DATA.
      SORT G_IT_DATA BY PROFIT COMPANY ACCOUNT.
      WRITE: /6 'ProfitCenter', 20 'CompanyCode',
              34 'Glaccount', 48 'Amount'.
      WRITE: /6 SY-ULINE(50).
      LOOP AT G_IT_DATA INTO G_WA_DATA.
        AT NEW PROFIT.
          WRITE: /6 G_WA_DATA-PROFIT.
        ENDAT.
        G_AMOUNT = G_WA_DATA-AMOUNT.
        AT NEW ACCOUNT.
          WRITE: /34 G_WA_DATA-ACCOUNT,
                 48  G_AMOUNT.
        ENDAT.
        G_SUM_PROFIT = G_SUM_PROFIT + G_WA_DATA-AMOUNT.
        G_SUM_COMPANY = G_SUM_COMPANY + G_WA_DATA-AMOUNT.
        AT END OF COMPANY.
          WRITE: /20 G_WA_DATA-COMPANY,
                  34 'Totle',
                  48 G_SUM_COMPANY.
          CLEAR G_SUM_COMPANY.
          WRITE: /6 '*******'.
        ENDAT.
        AT END OF PROFIT.
          WRITE: /6 G_WA_DATA-PROFIT,
                  20 'Totle',
                  48 G_SUM_PROFIT.
          CLEAR G_SUM_PROFIT.
          WRITE: /6 '*************************************'.
        ENDAT.
      ENDLOOP.

  • What are the internal table events

    hi experts
    can u help me for this

    Hi ramesh,
    There are basically internal table events are as below...
    at first / endat
    at last / endat
    at new / endat
    at end of / endat
    sum
    on change of / endon
    Use the at first and at last statements to perform processing during the first or last loop pass of an internal table.
    Use the at new and at end of statements to detect a change in a column from one loop pass to the next. These statements enable you to execute code at the beginning and end of a group of records.
    Use the sum statement to calculate totals for the rows of a control level.
    Another statement you can use to perform control break processing is on change of. It behaves in a manner similar to at new.
    on change of differs from at new in the following respects:
    It can be used in any loop construct, not just loop at. For example, it can be used within select and endselect, do and enddo, or while and endwhile, as well as inside get events.
    A single on change of can be triggered by a change within one or more fields named after of and separated by or. These fields can be elementary fields or field strings. If you are within a loop, these fields do not have to belong to the loop.
    When used within a loop, a change in a field to the left of the control level does not trigger a control break.
    When used within a loop, fields to the right still contain their original values; they are not changed to contain zeros or asterisks.
    You can use else between on change of and endon.
    You can use it with loop at it where . . ..
    You can use sum with on change of. It sums all numeric fields except the one(s) named after of.
    Any values changed within on change of remain changed after endon. The contents of the header line are not restored as they are for at and endat.
    <b>Reward Points if it useful....</b>
    Thanks and Regards
    Sreenivasa sharma k.

  • Events in a internal table

    Hello there,
    Can someone tell me if there are any events in a internal table.If yes name them ( i tried looking for them in SCN but could not find any threads relating to it).
    Regards
    Harish

    HI Harish,
    there is not events in internal table..
    but you can declare the internal tables in different ways..
    STANDARD table
    Key access to a standard table uses a linear search. This means that the time required for a search is in linear relation to the number of table entries.
    You should use index operations to access standard tables.
    SORTED table
    Defines the table as one that is always saved correctly sorted.
    Key access to a sorted table uses a binary key. If the key is not unique, the system takes the entry with the lowest index. The runtime required for key access is logarithmically related to the number of table entries.
    HASHED table
    Defines the table as one that is managed with an internal hash procedure
    You can only access a hashed table using the generic key operations or other generic operations ( SORT, LOOP, and so on). Explicit or implicit index operations (such as LOOP ... FROM oe INSERT itab within a LOOP) are not allowed.
    INDEX table
    A table that can be accessed using an index.
    Index table is only used to specify the type of generic parameters in a FORM or FUNCTION. That means that you can't create a table of type INDEX.
    Standard tables and sorted tables are index tables.
    ANY table
    Any table is only used to specify the type of generic parameters in a FORM or FUNCTION. That means that you can't create a table of type ANY.
    Standard, sorted and hashed tables belongs to ANY tables
    Regards,
    Prabhudas

  • Events in internal tables

    what are the events in internal tables...

    Hi
    At new, At first, At end of, At last are called Control break events of internal table
    All this AT NEW, AT FIRST, AT END OF and AT LAST are called control break statements of Internal tables and are used to calculate the TOTALS based on sertain key fields in that internal table
    FIrst to use these statements the ITAB has to be sorted by the key fields on whcih you need the SUM of the fields.
    Some time you will get * when mopving data from this int table to other table using these commands
    so you have to use
    READ TABLE ITAB INDEX SY-TABIX in AT..ENDAT..if you are using other fields between them
    DATA: sflight_tab TYPE SORTED TABLE OF sflight
                      WITH UNIQUE KEY carrid connid fldate,
          sflight_wa  LIKE LINE OF sflight_tab.
    SELECT *
           FROM sflight
           INTO TABLE sflight_tab.
    LOOP AT sflight_tab INTO sflight_wa.
      AT NEW connid.
        WRITE: / sflight_wa-carrid,
                 sflight_wa-connid.
        ULINE.
      ENDAT.
      WRITE: / sflight_wa-fldate,
               sflight_wa-seatsocc.
      AT END OF connid.
        SUM.
        ULINE.
        WRITE: / 'Sum',
                  sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
        SKIP.
      ENDAT.
      AT END OF carrid.
        SUM.
        ULINE.
        WRITE: / 'Carrier Sum',
                  sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
        NEW-PAGE.
      ENDAT.
      AT LAST.
        SUM.
        WRITE: / 'Overall Sum',
                  sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
      ENDAT.
    ENDLOOP.
    <b>
    Reward points for useful Answers</b>
    Regards
    Anji

  • Wt are events of internal tables?

    wt are events of internal tables?
    all helpfull ans will be rewarded

    Hi kishore kumar,
    Yep that's True that Internal tables are not having any events...
    and can be accessed in program by read or loop at statements...
    I think you wanted to know abt the controle break statements which can be used in internal tables...
    The Control-Break Stmts are...
    1. AT NEW.
    2. AT FIRST.
    3. AT LAST.
    4. AT END OF.
    5  ON CHANGE OF.
    See below example for the use of it...
    REPORT ILE_ZCTRL_BRK_STMT.
    TYPES: BEGIN OF G_I_DATA,
    PROFIT(4) TYPE C,
    COMPANY(4) TYPE C,
    ACCOUNT(10) TYPE C,
    AMOUNT TYPE P,
    END OF G_I_DATA.
    DATA: G_IT_DATA TYPE TABLE OF G_I_DATA,
    G_WA_DATA TYPE G_I_DATA.
    DATA: G_SUM_COMPANY TYPE P,
    G_SUM_PROFIT TYPE P,
    G_AMOUNT TYPE P.
    G_WA_DATA-PROFIT = '0001'.
    G_WA_DATA-COMPANY = '1111'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
    G_WA_DATA-AMOUNT = 2000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0001'.
    G_WA_DATA-COMPANY = '1111'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
    G_WA_DATA-AMOUNT = 3000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0001'.
    G_WA_DATA-COMPANY = '2222'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
    G_WA_DATA-AMOUNT = 4000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0001'.
    G_WA_DATA-COMPANY = '2222'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
    G_WA_DATA-AMOUNT = 5000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0002'.
    G_WA_DATA-COMPANY = '1111'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
    G_WA_DATA-AMOUNT = 2000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0002'.
    G_WA_DATA-COMPANY = '1111'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
    G_WA_DATA-AMOUNT = 3000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0002'.
    G_WA_DATA-COMPANY = '2222'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
    G_WA_DATA-AMOUNT = 4000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0002'.
    G_WA_DATA-COMPANY = '2222'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
    G_WA_DATA-AMOUNT = 5000.
    APPEND G_WA_DATA TO G_IT_DATA.
    SORT G_IT_DATA BY PROFIT COMPANY ACCOUNT.
    WRITE: /6 'ProfitCenter', 20 'CompanyCode',
    34 'Glaccount', 48 'Amount'.
    WRITE: /6 SY-ULINE(50).
    LOOP AT G_IT_DATA INTO G_WA_DATA.
    AT NEW PROFIT.
    WRITE: /6 G_WA_DATA-PROFIT.
    ENDAT.
    G_AMOUNT = G_WA_DATA-AMOUNT.
    AT NEW ACCOUNT.
    WRITE: /34 G_WA_DATA-ACCOUNT,
    48 G_AMOUNT.
    ENDAT.
    G_SUM_PROFIT = G_SUM_PROFIT + G_WA_DATA-AMOUNT.
    G_SUM_COMPANY = G_SUM_COMPANY + G_WA_DATA-AMOUNT.
    AT END OF COMPANY.
    WRITE: /20 G_WA_DATA-COMPANY,
    34 'Totle',
    48 G_SUM_COMPANY.
    CLEAR G_SUM_COMPANY.
    WRITE: /6 '*******'.
    ENDAT.
    AT END OF PROFIT.
    WRITE: /6 G_WA_DATA-PROFIT,
    20 'Totle',
    48 G_SUM_PROFIT.
    CLEAR G_SUM_PROFIT.
    WRITE: /6 '*************************************'.
    ENDAT.
    ENDLOOP.
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7

  • Internal table modification in ABAP object event

    Hi Gurus
    I have an internal table displayed using ALV - OOPS concept. THe internal table has 15 rows in my test program but it can go up depending on user inpout.
    I am able to display it . on the screen . One of the fields is editable . It is required that it take input from user and on pressing enter , the value entered in that cell should be subtracted from a total amout displayed in the cell next to it.
    I have used the following code . There are no errors , but nothing happens when I edit it. The screen remains as it is.
    Any help will be very useful
    DATA : ITAB type ITABT occurs 0.
    DATA : itab_w  like line of  itab.
    CLASS LCL_EVENTS_D0100 IMPLEMENTATION.
    METHOD handle_data_changed.
    DATA: ls_good TYPE lvc_s_modi.
    DATA : L_PLANETYPE TYPE ITABT-SEL_QUANT.
    LOOP AT er_data_changed->mt_good_cells INTO ls_good.
          CASE ls_good-fieldname.
    check if column PLANETYPE of this row was changed
            WHEN 'SEL_QUANT'.
              CALL METHOD pr_data_changed->get_cell_value
                 EXPORTING
                   i_row_id = ls_good-row_id
                   i_fieldname = ls_good-fieldname
                 IMPORTING
                   e_value = l_planetype.
          ENDCASE.
          LOOP AT ITAB INTO ITAB_W .
          read table itab into itab_w WITH KEY FINDEX = LS_GOOD-ROW_ID .
          itab_w-f_balquant = itab_w-f_balquant - l_planetype.
          modify itab FROM itab_w .
        endloop.
          ENDLOOP.
    ENDMETHOD.
    ENDCLASS.

    Hi,
    Hi,
    AND also use
    * Module Pai INPUT                                                     *
    * PAI module                                                           *
    module pai input.
      save_ok = ok_code.
      clear ok_code.
      call method grid1->check_changed_data
        importing
          e_valid = v_valid.
    " After this system will automatically update your changed data into
    " internal table t_zthlog
      case save_ok.
        when 'EXIT'.
          perform f_exit_program.
        when 'CANC'.
          perform f_exit_program.
        when 'BACK'.
          perform f_exit_program.
        when 'SAVE'.
          perform f_save_data.
      endcase.
    endmodule.                               " Pai INPUT
    aRs

  • 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

  • Internal table in Excel output with Header and Total

    Hi All,
    I have a selection-screen of a report where there is option to specify the path of a file to be stored in local PC. This Report gives output in ALV format which displays header and total of columns.
    Now, the requirement is, when the user specifies a path for the file in selection screen it should download in the specified location with header and total row into an excel format.
    The issue is, I have the internal table with data without total and header row and the total is getting displayed in the screen through ALV feature. I am not sure, how to give the same output in downloaded excel with header row and total as it is displayed on screen.
    Please let me know, if you have any suggestions.
    Thanks & Regards,
    Anshumita.

    try using TOP OF PAGE event and write the number of records in the header part.
    hope this will help.

  • ALV GRID Report is not showing all records which is in internal table

    hi all,
    have one doubt. please clarify me. ALV Report is working fine since long tiem. But suddenly this report is showing few records only for the given input.   Example:   it_main table have 50 records, but output is showing only 10 records only. (we have not made any modifications in this report).
    temporarily i have given excel output file from it_main table. excel file is showing all records.
    here it_main have all the records. but output is showing few records only. it is not showing any error. i have tested with REUSE_ALV_LIST_DISPLAY function also. but it also showing same results(few records only.)
    please give me some idea.
    FORM display_alv_report.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_buffer_active          = 'X'
          i_callback_program       = sy-repid
          is_layout                = wa_layout
          it_fieldcat              = it_fcat
          it_events                = it_events
          i_save                   = 'A'
          is_variant               = wa_variant
        TABLES
          t_outtab                 = it_main
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
        MESSAGE text-204 " 'Error in Display the list'
        TYPE 'I'.
        LEAVE TO LIST-PROCESSING.
      ENDIF.
    ENDFORM.            .                    "DISPLAY_ALV_REPORT
    Best Regards,
    Srinivas

    hi
    Please study this program and give me suggestions.
    ALV Declaration
    DATA : it_events TYPE slis_t_event,               "ALV event
               it_fcat   TYPE slis_t_fieldcat_alv,        "Field catalog
               it_list_top_of_page TYPE slis_t_listheader,
               c_tabname  TYPE slis_tabname   VALUE 'IT_MAIN'.
    DATA : wa_layout  TYPE slis_layout_alv,
                wa_event   TYPE slis_alv_event,
               wa_fcat    TYPE slis_fieldcat_alv,
               wa_variant TYPE disvariant.
    START-OF-SELECTION.
      PERFORM material_pass.
      PERFORM data_retrieval.
    END-OF-SELECTION.
      PERFORM sub_display_report.
    FORM sub_display_report .
      DATA status(1).
      IF r1 = 'X'.
        PERFORM build_fieldcatalog USING :
          '1'  'ERDAT'     'S.O DATE'             '' '10'  'X',
          '2'  'VBELN'     'SALE ORDER'           '' '10'  'X',
          '3'  'POSNR'     'SALE ITEM'            '' '6'   '',
          '4'  'BSTKD'     'CUSTOMER PO'          '' '35'  '',
          '5'  'BEZEI'     'REASON FOR REJECTION' '' '40'  '',
          '6'  'PLNUM'     'PLANNED ORDER'        '' '10'  '',
          '7'  'AUFNR'     'PROD.ORDER.'          '' '12'  '',
          '8'  'MATNR'     'MATERIAL NUMBER'      '' '18'  '',
          '9'  'MAKTX'     'MATERIAL DESCRIPTION' '' '40'  '',
          '10' 'WERKS'     'PLANT'                '' '4'   '',
          '11' 'KWMENG'    'SALE ORDER QTY'       '' '15'  '',
          '12' 'VRKME'     'UNIT'                 '' '4'   '',
          '13' 'GAMNG'     'PROD.ORDER QTY'       '' '13'  '',
          '14' 'IGMNG'     'CONFIRMED ORDER QTY'  '' '13'  '',
          '15' 'GMEIN'     'UNIT'                 '' '4'   '',
          '16' 'MENGE'     'G.R QUANTITY'         '' '13'  '',
          '17' 'SOBAL'     'S.O BALANCE'          '' '13'  '',
          '18' 'PRDBAL'    'PROD.BALANCE'         '' '13'  '',
          '19' 'GSM'       'GSM'                  '' '4'   '',
          '20' 'SIZE1'     'SIZE1'                '' '10'  '',
          '21' 'SIZE2'     'SIZE2'                '' '10'  ''.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            filename              = pathname
            filetype              = ftype
            append                = 'X'
            write_field_separator = 'X'
          TABLES
            data_tab              = it_mains
          EXCEPTIONS
            file_write_error      = 1.
        IF sy-subrc = 0.
          status = 'S'.
        ELSE.
          status = 'E'.
        ENDIF.
      ELSEIF r2 = 'X' OR r3 = 'X'.
        PERFORM build_fieldcatalog USING :
          '1'  'ERDAT'     'S.O DATE'             '' '10'  'X',
          '2'  'VBELN'     'SALE ORDER'           '' '10'  'X',
          '3'  'POSNR'     'SALE ITEM'            '' '6'   '',
          '4'  'BSTKD'     'CUSTOMER PO'          '' '35'  '',
          '5'  'BEZEI'     'REASON FOR REJECTION' '' '40'  '',
          '6'  'PLNUM'     'PLANNED ORDER'        '' '10'  '',
          '7'  'AUFNR'     'PROD.ORDER.'          '' '12'  '',
          '8'  'MATNR'     'MATERIAL NUMBER'      '' '18'  '',
          '9'  'MAKTX'     'MATERIAL DESCRIPTION' '' '40'  '',
          '10' 'WERKS'     'PLANT'                '' '4'   '',
          '11' 'KWMENG'    'SALE ORDER QTY'       '' '15'  '',
          '12' 'VRKME'     'UNIT'                 '' '4'   '',
          '13' 'GAMNG'     'PROD.ORDER QTY'       '' '13'  '',
          '14' 'IGMNG'     'CONFIRMED ORDER QTY'  '' '13'  '',
          '15' 'GMEIN'     'UNIT'                 '' '4'   '',
          '16' 'MENGE'     'G.R QUANTITY'         '' '13'  '',
          '17' 'SOBAL'     'S.O BALANCE'          '' '13'  '',
          '18' 'PRDBAL'    'PROD.BALANCE'         '' '13'  '',
          '19' 'GSM'       'GSM'                  '' '4'   '',
          '20' 'SIZE1'     'SIZE1'                '' '10'  '',
          '21' 'CUT1'      'CUT1'                 '' '11'  '',
          '22' 'SIZE2'     'SIZE2'                '' '10'  '',
          '23' 'CUT2'      'CUT2'                 '' '11'  '',
          '24' 'SIZE3'     'SIZE3'                '' '10'  '',
          '25' 'CUT3'      'CUT3'                 '' '11'  '',
          '26' 'SIZE4'     'SIZE4'                '' '10'  '',
          '27' 'CUT4'      'CUT4'                 '' '11'  '',
          '28' 'SIZE5'     'SIZE5'                '' '10'  '',
          '29' 'CUT5'      'CUT5'                 '' '11'  '',
          '30' 'SIZE6'     'SIZE6'                '' '10'  '',
          '31' 'CUT6'      'CUT6'                 '' '11'  ''.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            filename              = pathname
            filetype              = ftype
            append                = 'X'
            write_field_separator = 'X'
          TABLES
            data_tab              = it_mainall
          EXCEPTIONS
            file_write_error      = 1.
        IF sy-subrc = 0.
          status = 'S'.
        ELSE.
          status = 'E'.
        ENDIF.
      ENDIF.
      PERFORM build_layout.
      PERFORM build_events.
      PERFORM sub_comment_build USING it_list_top_of_page.
      PERFORM sub_set_variant.
      PERFORM display_alv_report.
      IF status = 'S'.
        MESSAGE 'Excel Output file Downloaded to Given Path' TYPE 'I'.
      ELSE.
        MESSAGE 'Download Not Possible' TYPE 'I'.
      ENDIF.
    ENDFORM.                    " SUB_DISPLAY_REPORT
    FORM BUILD_FIELDCATALOG
    FORM build_fieldcatalog USING  p_col_pos
                                   p_fieldname
                                   p_text
                                   p_datatype
                                   p_outputlen
                                   p_col_freez.
      wa_fcat-row_pos        = '1'.
      wa_fcat-col_pos        = p_col_pos.
      wa_fcat-fieldname      = p_fieldname.
      wa_fcat-tabname        = c_tabname.
      wa_fcat-reptext_ddic   = p_text.
      wa_fcat-datatype       = p_datatype.
      wa_fcat-ddic_outputlen = p_outputlen.
      wa_fcat-key            = p_col_freez.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    FORM build_layout.
      CLEAR: wa_layout.
      wa_layout-window_titlebar   = 'LIST OF GSM WISE OPEN SALE ORDERS'.
      wa_layout-colwidth_optimize = 'X'.
      wa_layout-totals_text       = 'CUMULATIVE'.
    ENDFORM.                    "BUILD_LAYOUT
    *&      Form  BUILD_EVENTS
    FORM build_events.
      CLEAR wa_event.
      REFRESH it_events.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_events
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc = 0.
        READ TABLE it_events INTO wa_event
             WITH KEY name = 'TOP_OF_PAGE'.
        IF sy-subrc EQ 0.
          wa_event-form = 'TOP_OF_PAGE'.
          APPEND wa_event TO it_events.
          CLEAR wa_event.
        ENDIF.
      ENDIF.
    ENDFORM.                    "BUILD_EVENTS
         -->P_IT_LIST_TOP_OF_PAGE  text
    FORM sub_comment_build  USING it_top_of_page TYPE slis_t_listheader.
      DATA ls_line TYPE slis_listheader.
      CLEAR ls_line.
      ls_line-typ = 'H'.
      ls_line-info = str1.
      APPEND ls_line TO it_top_of_page.
      CLEAR ls_line.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
       EXPORTING
         it_list_commentary = t_header[].
    ENDFORM.                    " SUB_COMMENT_BUILD
    *&      Form  SUB_SET_VARIANT
          text
    -->  p1        text
    <--  p2        text
    FORM sub_set_variant .
      CLEAR wa_variant.
      wa_variant-report = sy-repid.
      wa_variant-username = sy-uname.
    wa_variant-variant = c_variant.
    wa_variant-variant = p_layout.
    ENDFORM.                    " SUB_SET_VARIANT
    *&      Form  DISPLAY_ALV_REPORT
    *Display Report Using ALV GRID
    FORM display_alv_report.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_buffer_active          = 'X'
          i_callback_program       = sy-repid
         i_callback_pf_status_set = c_pf_status
         i_callback_user_command  = c_user_command
          is_layout                = wa_layout
          it_fieldcat              = it_fcat
         it_sort                  = it_sort[]
          it_events                = it_events
          i_save                   = 'A'
          is_variant               = wa_variant
        TABLES
          t_outtab                 = it_main
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
        MESSAGE text-204 " 'Error in Display the list'
        TYPE 'I'.
        LEAVE TO LIST-PROCESSING.
      ENDIF.
    ENDFORM.            .                    "DISPLAY_ALV_REPORT
    *ALV Report Header
    FORM top_of_page.
      DATA : t_header TYPE slis_t_listheader WITH HEADER LINE,
             wa_header TYPE slis_listheader,
             t_line LIKE wa_header-info,
             ld_lines TYPE i,
             ld_linesc(10) TYPE c.
      wa_header-typ  = 'H'.
    T_HEADER-INFO = 'LIST OF GSM WISE OPEN SALE ORDERS'.
      wa_header-info = str1.
      APPEND wa_header TO t_header.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = t_header[].
    ENDFORM.                    "TOP_OF_PAGE
    here it_main internal table having all data. but output is showing few records only.
    pl. give some idea.
    Thanks & Regards
    Srinivas.

  • Get data in editable ALV back to internal table without data_changed ev?

    Hi,
       I have an editable ALV using classes to whch I have users the option to edit directly on the screen or upload data from an excel. The event data_changed gets triggered when users edit the table on the screen.
    However when EXCEL is uploaded, I refresh the table display. So, I need a way to get the data from the ALV into a internal table to check which rows were update using the excel and save them into the db table.
    Prakash

    Hi!
    For more information, inspect programs suiting the mask "BCALVEDIT*" and the thread with header "How to make a row of ALV editable " (I know this is some more steps further from your demand but it may be useful) at URL " How to make a row of ALV editable " .
    If you want to study more BC412 "EnjoySAP Controls" may help you.
    *--Serdar

  • Internal table and subtotals

    Hi,
    I want  to display report output like below .
    how can i bulid the internal table means can i hardcode the field1.
    how can i do the subtotals and totals i know the doing subtotals and totals in alv based on some field.
    field1                          field2           field3           field4
    Revenues
    product sales             100               1000           2000
    Contract revenue         200               4500          3000
    total Renues               300               5500          5000
    cost and expenses     
    Cost of sales               10000           5000          6000
    Selling  expenses         5000            2000          1000
    Research expenses      2000            2000          3000
    total expenses             17000           9000          10000
    total                             17300          14500         15000
    Please help regarding this,
    Regards,
    Suresh.

    check this example
    REPORT ZBLOCK_ALV.
    CONSTANTS :
      c_x VALUE 'X'.
    Macro definition
    DEFINE m_fieldcat.
      ls_fieldcat-fieldname = &1.
      ls_fieldcat-ref_tabname = &2.
      ls_fieldcat-tabname = &3.
      append ls_fieldcat to lt_fieldcat.
    END-OF-DEFINITION.
    DEFINE m_sort.
      ls_sort-fieldname = &1.
      ls_sort-up        = c_x.
      append ls_sort to lt_sort.
    END-OF-DEFINITION.
    TYPE-POOLS: slis.                      " ALV Global types
    TYPES:
    1st Table
      BEGIN OF ty_kna1,
        kunnr TYPE kna1-kunnr,             " Customer number
        ernam TYPE kna1-ernam,             " Name of Person who Created
        erdat TYPE kna1-erdat,             " Creation date
        name1 TYPE kna1-name1,             " Name 1                    .
      END OF ty_kna1,
    2nd Table
      BEGIN OF ty_mara,
        matnr TYPE mara-matnr,             " Material number
        ernam TYPE mara-ernam,             " Name of Person who Created
        ersda TYPE mara-ersda,             " Creation date
        mtart TYPE mara-mtart,             " Material type
        matkl TYPE mara-matkl,             " Material group
      END OF ty_mara,
    3rd Table
      BEGIN OF ty_vbak,
        vbeln TYPE vbak-vbeln,             " Sales document
        vkorg TYPE vbak-vkorg,             " Sales organization
        vtweg TYPE vbak-vtweg,             " Distribution channel
        kunnr TYPE vbak-kunnr,             " Sold-to party
        erdat TYPE vbak-erdat,             " Creation date
      END OF ty_vbak.
    DATA:
      gs_layout TYPE slis_layout_alv,
      gt_kna1 TYPE TABLE OF ty_kna1,
      gt_mara TYPE TABLE OF ty_mara,
      gt_vbak TYPE TABLE OF ty_vbak.
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.    "#EC NEEDED
    PARAMETERS p_max(2) TYPE n DEFAULT '02' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    INITIALIZATION.
      v_1 = 'Maximum of records to read'.
    START-OF-SELECTION.
    Read data
      SELECT kunnr ernam erdat name1
        FROM kna1
       UP TO p_max ROWS
        INTO TABLE gt_kna1.
      SELECT matnr ernam ersda mtart matkl
        FROM mara
       UP TO p_max ROWS
        INTO TABLE gt_mara.
      SELECT vbeln vkorg vtweg kunnr erdat
        FROM vbak
       UP TO p_max ROWS
        INTO TABLE gt_vbak.
    END-OF-SELECTION.
      PERFORM f_display_data.
          FORM USER_COMMAND                                             *
    FORM user_command USING u_ucomm     TYPE sy-ucomm
                            us_selfield TYPE slis_selfield.     "#EC CALLED
      DATA:
        ls_vbak TYPE ty_vbak.
      CASE u_ucomm.
        WHEN '&IC1'.                       " Pick
          CASE us_selfield-tabname.
            WHEN 'GT_MARA'.
            WHEN 'GT_KNA1'.
            WHEN 'GT_VBAK'.
              READ TABLE gt_vbak INDEX us_selfield-tabindex INTO ls_vbak.
              IF sy-subrc EQ 0.
                SET PARAMETER ID 'AUN' FIELD ls_vbak-vbeln.
                CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
              ENDIF.
          ENDCASE.
      ENDCASE.
    ENDFORM.                               " USER_COMMAND
          Form  f_display_data
    FORM f_display_data.
      DATA :
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
        ls_sort     TYPE slis_sortinfo_alv,
        lt_sort     TYPE slis_t_sortinfo_alv, " Sort table
        lt_events   TYPE slis_t_event,
        ls_event    TYPE slis_alv_event.
      gs_layout-group_change_edit = c_x.
      gs_layout-colwidth_optimize = c_x.
      gs_layout-zebra             = c_x.
      gs_layout-detail_popup      = c_x.
      gs_layout-get_selinfos      = c_x.
    Build field catalog and sort table
      m_fieldcat  'KUNNR' 'KNA1' 'GT_KNA1'.
      m_fieldcat  'ERNAM' 'KNA1' 'GT_KNA1'.
      m_fieldcat  'ERDAT' 'KNA1' 'GT_KNA1'.
      m_fieldcat  'NAME1' 'KNA1' 'GT_KNA1'.
      m_sort  'KUNNR'.
    Build Event Table
      MOVE        'TOP_OF_PAGE'        TO ls_event-name.
      MOVE        'TOP_OF_PAGE'        TO ls_event-form.
      APPEND ls_event TO lt_events.
      MOVE        'END_OF_LIST'        TO ls_event-name.
      MOVE        'END_OF_LIST'        TO ls_event-form.
      APPEND ls_event TO lt_events.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program      = sy-cprog
          i_callback_user_command = 'USER_COMMAND'
          it_fieldcat             = lt_fieldcat
          is_layout               = gs_layout
          it_events               = lt_events
          it_sort                 = lt_sort
          i_save                  = 'A'
        TABLES
          t_outtab                = gt_kna1.
    ENDFORM.                               " F_DISPLAY_DATA
          FORM top_of_page                                              *
    FORM top_of_page.                                           "#EC CALLED
      ULINE.
      WRITE : sy-uname, sy-title(56) CENTERED, sy-datum.
      ULINE.
    ENDFORM.                               " TOP_OF_PAGE
          FORM End_of_list                                              *
    FORM end_of_list.                                           "#EC CALLED
      DATA :
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
        ls_sort     TYPE slis_sortinfo_alv,
        lt_sort     TYPE slis_t_sortinfo_alv, " Sort table
        lt_events   TYPE slis_t_event,
        ls_event    TYPE slis_alv_event.
    Build field catalog and sort table
      m_fieldcat 'MATNR' 'MARA' 'GT_MARA'.
      m_fieldcat 'ERNAM' 'MARA' 'GT_MARA'.
      m_fieldcat 'ERSDA' 'MARA' 'GT_MARA'.
      m_fieldcat 'MTART' 'MARA' 'GT_MARA'.
      m_fieldcat 'MATKL' 'MARA' 'GT_MARA'.
      m_sort 'MATNR'.
    Build Event Table
      MOVE 'END_OF_LIST'   TO ls_event-name.
      MOVE 'END_OF_LIST_2' TO ls_event-form.
      APPEND ls_event TO lt_events.
      gs_layout-list_append = c_x.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = sy-cprog
          it_fieldcat        = lt_fieldcat
          is_layout          = gs_layout
          it_sort            = lt_sort
          it_events          = lt_events
          i_save             = 'A'
        TABLES
          t_outtab           = gt_mara.
    ENDFORM.                               " END_OF_LIST
          FORM End_of_list_2                                            *
    FORM end_of_list_2.                                         "#EC CALLED
      DATA :
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
        ls_sort     TYPE slis_sortinfo_alv,
        lt_sort     TYPE slis_t_sortinfo_alv, " Sort table
        lt_events   TYPE slis_t_event,
        ls_event    TYPE slis_alv_event.
    Build field catalog and sort table
      m_fieldcat 'VBELN' 'VBAK' 'GT_VBAK'.
      m_fieldcat 'VKORG' 'VBAK' 'GT_VBAK'.
      m_fieldcat 'VTWEG' 'VBAK' 'GT_VBAK'.
      m_fieldcat 'KUNNR' 'VBAK' 'GT_VBAK'.
      m_fieldcat 'ERDAT' 'VBAK' 'GT_VBAK'.
      m_sort 'VBELN'.
    Build Event Table
      MOVE 'TOP_OF_PAGE' TO ls_event-name.
      MOVE 'TOP_OF_PAGE' TO ls_event-form.
      APPEND ls_event TO lt_events.
      gs_layout-list_append = c_x.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = sy-cprog
          it_fieldcat        = lt_fieldcat
          is_layout          = gs_layout
          it_sort            = lt_sort
          it_events          = lt_events
          i_save             = 'A'
        TABLES
          t_outtab           = gt_vbak.
    ENDFORM.                               " END_OF_LIST_2

  • Uploading Excel to Internal Table

    Hi,
      Can anyone please look into the code and suggest me the changes in uploading Excel to Internal Table. Code is as below in OnInputProcessing.
    DATA: event TYPE REF TO CL_HTMLB_EVENT.
    event =
    CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
    DATA: fileUpload TYPE REF TO CL_HTMLB_FILEUPLOAD,
           fcontent type xstring,
           fstring  type string,
                  len TYPE I.
    fileUpload ?= CL_HTMLB_MANAGER=>GET_DATA(
    request = runtime->server->request
    name = 'fileUpload'
    id = 'myFileUpload1').
    len = fileUpload->file_length.
    IF event->id = 'submitButton' AND
        event->event_type = 'click'.
       fileUpload ?=
    CL_HTMLB_MANAGER=>GET_DATA( request = request
                               id = 'myFileUpload1'
                               name = 'fileUpload' ).
       IF ( fileUpload->file_name NE '' ) AND
       ( fileUpload->file_length GT 0 ).
         IF fileUpload->file_content_type
         = 'application/vnd.ms-excel'.
           DATA: content TYPE ZTABLE,
           conv TYPE REF TO CL_ABAP_CONV_IN_CE,
           viewoff TYPE REF TO CL_ABAP_VIEW_OFFLEN,
           it_off TYPE ABAPOFFLENTAB,
           wa_off TYPE ABAPOFFLEN,
           dd_fields TYPE DDFIELDS,
           wa_fields TYPE DFIES.
    data: codepage type CPCODEPAGE.
    CALL FUNCTION 'SCP_CODEPAGE_BY_EXTERNAL_NAME'
    EXPORTING
    external_name       = 'utf-16le'
      KIND                = 'H'
      IMPORTING
      SAP_CODEPAGE        = codepage.
    conv = CL_ABAP_CONV_IN_CE=>CREATE( encoding = '4103'
    endian = 'L'
    input =   fileUpload->file_content
    ignore_cerr = 'X').
           CALL FUNCTION 'TR_NAMETAB_GET'
             EXPORTING
               IV_TABNAME                 = 'ZTABLE'
               IV_GET_LENGTHS_IN_CHARMODE = 'X'
               IV_GET_TEXTS               = ' '
             IMPORTING
               ET_DFIES                   = dd_fields.
            LOOP AT dd_fields INTO wa_fields.
             MOVE wa_fields-offset TO wa_off-ioff.
             MOVE wa_fields-intlen TO wa_off-ilen.
             APPEND wa_off TO it_off.
            ENDLOOP.
           viewoff = CL_ABAP_VIEW_OFFLEN=>CREATE( tab = it_off ).
            call method conv->read( importing data = fstring ).
           fcontent = conv->get_buffer( ).
           call function 'HR_KR_XSTRING_TO_STRING'
               exporting
                   from_codepage = '4103'
                   in_xstring    = fcontent
              importing
                   out_string    = fstring.
          data: input_string type string.
          data: fields  type string_table.
          data: s_table type string_table.
    split fstring at cl_abap_char_utilities=>cr_lf into table s_table.
    field-symbols: <wa_table> like line of s_table.
    loop at s_table assigning <wa_table>.
      split <wa_table> at cl_abap_char_utilities=>HORIZONTAL_TAB into table
    fields.
    endloop.
      endif.
      endif.
      endif.
    thanks in advance,
    anjani.

    Hi anjani,
    it doesn't help much if you just post some code and request changes, if you don't state the kind of problem you are having ... in order to receice helpful replies, you have to give detailed information, what you want to do, what is not working as expected ... so please post more details.
    Meanwhile I recommend doing a search for your excel problem in the forum and also read the excel weblogs from <a href="https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/u/1918">Thomas Jung</a>.
    Regards,
    Max

  • How to keep Internal table after filter in tableview?

    Hi, Im kinda new in BSP, Im an ABAP developer.
    I manage to get info from a SolMan to my internal table using submit importing from memory after clicking a search button and the table is filled.
    The thing is after I execute a filter on any field of the tableView my internal table is not FILTERED, I see the original internal table that I searched.
    I wanna know how can I get the filtered table so if I make a Download to Excel button I want to download the table that Im seeing "filtered" and not the original one.
    Thx
    Edited by: Rodrigo Ariel Giner de la Vega on May 8, 2008 4:41 PM

    Hi Roddy,
    you have probably figured out by now that the tableView filter option only filters which rows are displayed from the itab, is does not actually remove the filtered rows. This makes sense otherwise it would have to rebuilt the itab with each pass to ensure any previously filtered rows are returned if the filter is changed.
    What you can do it access the filter parameters in the OnInputProcessing method of your page. Essentially the HTTP request carries parameters as name/value pairs in either the HTTP header or as form fields. You can get to them like this..
    DATA:
          lt_ffields         TYPE tihttpnvp,
          lt_hfields         type tihttpnvp.
    request->get_header_fields( CHANGING fields = lt_hfields ).
    request->get_form_fields( CHANGING fields = lt_ffields ).
    Where the HTMLB event handling parameters are passed might depend on how you call the HTML form, so have a look in both areas for these parameters. I just did a simple test and they were in the form fields.
    So you can place a button on your screen to trigger your download to Excel and have it call the standard htmlb event processing routines.
    Then when you detect this button has been clicked in the OnInputProcessing method you can apply the tableView filters to the data before you send it to Excel.
    Cheers
    Graham Robbo

Maybe you are looking for

  • New apple tv will not connect

    I have just installed my new apple TV, but I cannot get contact with the apple servers. I'm using a wired network, and it automatically get's IP and DNS, but when I try to upgrade or connect to iTunes, it tell me to try later. I have seen others sugg

  • Authentication and authorization for AD users in UCM11g

    Hi all we are using webcenter content server 11g. I read some where that for 11g users authentication is done in weblogic server environment, mean content server for 11g in now managed by weblogic server only, am i right?. we have successfully integr

  • Read Outlook Email and Get Specific Content from Mail with PowerShell

    Hi Everyone, I would like to get full content value by searching in mail body with PowerShell but I stuck at one place in scripting and would required help from your side. Below is my script with description. #Connecting Outlook with below command $O

  • Agent updates not available after restoring DPM database

    Hi, I am using DPM 2012 R2 which I have recently successfully updated to version 4.2.1297.0 (A hotfix installed to resolve an issue with Rollup 5). I updated 3 agents successfully and planned to do the remaining 8 at a later date.  However after upda

  • Icloud is grayed out so i cant turn on?

    I Skipped activating iCloud during the initial setup. Now after attempting to turn on iCloud, I can't as the sole option is grayed out?