ALV display using dynamic field catalog and dynamic internal table

hi ,
please guide me for ALV display using dynamic field catalog and dynamic internal table.
Thank you.

Hi Rahul,
maybe thread dynamic program for alv is helpful for you. More information about the [SAP List Viewer (ALV)|http://help.sap.com/saphelp_nw70/helpdata/EN/5e/88d440e14f8431e10000000a1550b0/frameset.htm]. Also have a look into the example programs SALV_DEMO_TABLE*.
Regards Rudi

Similar Messages

  • ALV report using the field catalog

    which is the quickest way to generate an ALV report using the field catalog merge.  without needing to build the field catalog manually .
    is it easier to create a structure and passe it in the field catalog merge .  if yes can i have an example plzzzz

    hI
    Supports the creation of the field catalog for the ALV function modules
    based either on a structure or table defined in the ABAP Data
    Dictionary, or a program-internal table.
    The program-internal table must either be in a TOP Include or its
    Include must be specified explicitly in the interface.
    The variant based on a program-internal table should only be used for
    rapid prototyping since the following restrictions apply:
    o Performance is affected since the code of the table definition must
    always be read and interpreted at runtime.
    o Dictionary references are only considered if the keywords LIKE or
    INCLUDE STRUCTURE (not TYPE) are used.
    If the field catalog contains more than 90 fields, the first 90 fields
    are output in the list by default whereas the remaining fields are only
    available in the field selection.
    If the field catalog is passed with values, they are merged with the
    'automatically' found information.
    Below is an example ABAP program which will populate a simple internal table(it_ekpo) with data and
    display it using the basic ALV grid functionality(including column total). The example details the main
    sections of coding required to implement the ALV grid functionality:
                             Data declaration
                             Data retrieval
                             Build fieldcatalog
                             Build layout setup
    *& Report  ZDEMO_ALVGRID                                               *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic requirement for this demo is to display a number of       *
    *& fields from the EKKO table.                                         *
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.        "Display column total
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
    *            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
    *            i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
    *            IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
    *            is_variant              = z_template
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 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.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL

  • ALV Display - Error in field catalog

    Hi ,
    I am facing a problem in ALV... Field catalot is not getting populated... I am getting a message field catalog not found...
    Can anyone please help me....... <URGENT DOES NOT EXIST HERE>...
    I am enclosing my code also.. please go thourh it and help it....
    REPORT ZINVENTORY
          LINE-SIZE  120
           LINE-COUNT 64.
          MESSAGE-ID Z2
          NO STANDARD PAGE HEADING..
    type-pools : slis.
    Tables                                                               *
    tables: zasset,
            anla,
            itob,
            equi.
    data: v_repid LIKE sy-repid.
    Selection Screen                                                     *
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001 .
    SELECT-OPTIONS : S_bukrs FOR anla-bukrs OBLIGATORY ,
                     S_kostl FOR itob-kostl .
    SELECTION-SCREEN : END OF BLOCK B1 .
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
    PARAMETERS: p_screen RADIOBUTTON GROUP gr1,
                p_list RADIOBUTTON GROUP gr1 DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK b2.
    Internal Tables                                                      *
    types: BEGIN OF ty_zasset, " occurs 0,
             equnr  like zasset-equnr,
             ANLN1 LIKE zasset-ANLN1, " Asset number
             ANLN2 LIKE zasset-ANLN2, " Sub Asset number
             BUKRS LIKE zasset-BUKRS, " Company Code
             KOSTL  like zasset-kostl,
             SCANNEDBY type zasset-scannedby,
             SCANNINGDATE type zasset-SCANNINGDATE,
             SCANNINGTIME type zasset-scanningtime,
             UPDATEDATE   type zasset-updatedate,
             UPDATETIME type zasset-updatetime,
           END OF ty_zasset.
    DATA: wa_zasset   TYPE ty_zasset.
    DATA: it_zasset TYPE TABLE OF ty_zasset with header line..
    types: BEGIN OF ty_zasset1, " occurs 0,
            equnr  TYPE equi-equnr,
             ANLN1 LIKE anla-ANLN1, " Asset number
             ANLN2 LIKE anla-ANLN2, " Sub Asset number
             BUKRS LIKE anla-BUKRS, " Company Code
             ernam like anla-ernam,
             erdat like anla-erdat,
            KOSTL  like anlz-kostl,
            SCANNEDBY type zasset-scannedby,
            SCANNINGDATE type zasset-SCANNINGDATE,
            SCANNINGTIME type zasset-scanningtime,
            UPDATEDATE   type zasset-updatedate,
            UPDATETIME type zasset-updatetime,
           END OF ty_zasset1.
    DATA: wa_zasset1   TYPE ty_zasset1.
    DATA: it_zasset1 TYPE TABLE OF ty_zasset1 with header line..
    types: BEGIN OF ty_zasset2, " occurs 0,
             equnr  like itob-equnr,
             ANLNr LIKE itob-ANLNr, " Asset number
             ANLuN LIKE itob-ANLuN, " Sub Asset number
             BUKRS LIKE itob-BUKRS, " Company Code
             timbi like itob-timbi,
             kostl like itob-kostl,
            KOSTL  like anlz-kostl,
            SCANNEDBY type zasset-scannedby,
            SCANNINGDATE type zasset-SCANNINGDATE,
            SCANNINGTIME type zasset-scanningtime,
            UPDATEDATE   type zasset-updatedate,
            UPDATETIME type zasset-updatetime,
           END OF ty_zasset2.
    DATA: wa_zasset2   TYPE ty_zasset2.
    DATA: it_zasset2 TYPE TABLE OF ty_zasset2 with header line..
    types: begin of ty_final , "occurs 0,
            equnr like itob-equnr,
            anln1 like anla-anln1,
            anln2 like anla-anln2,
            bukrs like anla-bukrs,
           ernam
           erdat
            kostl like itob-kostl,
            end of ty_final.
    DATA: wa_final   TYPE ty_final.
    DATA: it_final TYPE TABLE OF ty_final with header line..
    *DATA: it_zasset TYPE TABLE OF ty_zasset.
    *data: it_zasset1 type table of ty_zasset1.
    *data:wa_zasset type ty_zasset.
    *data:wa_zasset1 type ty_zasset1.
    Flags and Variables                                                 *
    DATA : F_ERROR.                   " Flag for No Data
    *pop field cat for f7
    data: V_SYREPID LIKE SY-REPID,
          IT_FLDCAT type slis_t_fieldcat_alv , "with header line,
          wa_fldcat   type slis_fieldcat_alv.
    *DATA : IT_FLDCATS TYPE SLIS_T_FIELDCAT_ALV.
    data: itab_events type slis_t_event,
          wa_events   type slis_alv_event.
    *data: wa_layout type slis_layout_alv.
    DATA : IT_COMMENTS TYPE SLIS_T_LISTHEADER,
           WA_COMMENTS TYPE SLIS_LISTHEADER.
    DATA : IT_SORTINFO TYPE SLIS_T_SORTINFO_ALV,
           WA_SORTINFO TYPE SLIS_SORTINFO_ALV.
    Initialization                                                       *
    initialization.
      SY-REPID = V_REPID.
    At Selection Screen                                                  *
    AT SELECTION-SCREEN.
      PERFORM validation.
    Start Of Selection                                                   *
    start-of-selection.
    perform select_data.
    IF P_LIST = 'X'.
    perform get_field_catalog.
    PERFORM MODIFYFIELDCAT.
    perform get_events.
    perform write_comments.
    perform grid_display.
    *perform list_display.
    ENDIF.
    IF sy-subrc = 0.
       IF p_list = 'X'.
       loop at it_final.
       perform get_events.
       endloop.
       endif.
       endloop.
       else.
    *endif.
    End Of Selection                                                     *
    END-OF-SELECTION.
    *perform display_Recorsds.
    *loop at zasset.
    *&      Form  validation
          text
    -->  p1        text
    <--  p2        text
    FORM validation.
    *Local variables.
      DATA:
            lv_bukrs type anla-bukrs,
            lv_kostl type itob-kostl,
            lv_anln1 TYPE anla-anln1,        "MAterial Number
            lv_anln2 TYPE anla-anln2.
    *Validation for company code
      if not s_bukrs is initial.
        select single bukrs from anla
               into lv_bukrs
               where bukrs in s_bukrs.
        if sy-subrc <> 0.
    *Message used : Invalid company code.
        endif.
      endif    .
    Validation for cost center
      if not s_kostl is initial.
        select single kostl from itob
               into lv_kostl
               where kostl in s_kostl.
        if sy-subrc <> 0.
    *Message used : Invalid company code.
        endif.
      endif  .
    ENDFORM.                    " validation
    *&      Form  display
          text
    -->  p1        text
    <--  p2        text
    FORM display.
      write :/15 it_final-anln1,
      it_final-anln2,
                sy-vline.
    *-bukrs,
           it_zasset-anln1.
    ENDFORM.                    " display
    *&      Form  get_field_catalog
          text
    -->  p1        text
    <--  p2        text
    FORM get_field_catalog.
    *REFRESH IT_FLDCAT.
    *CLEAR IT_FLDCAT.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = V_REPID
       I_INTERNAL_TABNAME           = 'IT_FINAL'
       I_INCLNAME                   = V_REPID
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
      CHANGING
        CT_FIELDCAT                  = IT_FLDCAT
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " get_field_catalog
    *&      Form  get_events
          text
    -->  p1        text
    <--  p2        text
    FORM get_events.
      WA_COMMENTS-TYP = 'H'.
      WA_COMMENTS-KEY = 'THIS IS THE HEADING.'.
      WA_COMMENTS-INFO = 'LIST OF SALES ORDERS'.
      APPEND WA_COMMENTS TO IT_COMMENTS.
    ENDFORM.                    " get_events
    *&      Form  grid_display
          text
    -->  p1        text
    <--  p2        text
    FORM grid_display.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                =
      I_BUFFER_ACTIVE                   = ' '
       I_CALLBACK_PROGRAM                = v_repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
       I_CALLBACK_TOP_OF_PAGE            = 'FIRST PAGE'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
       I_GRID_TITLE                      =  'LIST OF FLIGHT DETAILS'
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       IT_FIELDCAT                       =  it_fldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
      IT_EVENTS                         =  itab_events
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      IT_ALV_GRAPHICS                   =
      IT_ADD_FIELDCAT                   =
      IT_HYPERLINK                      =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
      IT_EXCEPT_QINFO                   =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = it_final
    EXCEPTIONS
       PROGRAM_ERROR                     = 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.
    ENDFORM.                    " grid_display
    *&      Form  write_comments
          text
    -->  p1        text
    <--  p2        text
    FORM write_comments.
      WA_COMMENTS-TYP = 'H'.
      WA_COMMENTS-KEY = 'THIS IS THE HEADING.'.
      WA_COMMENTS-INFO = 'LIST OF SALES ORDERS'.
      APPEND WA_COMMENTS TO IT_COMMENTS.
    ENDFORM.                    " write_comments
    *&      Form  select_data
          text
    -->  p1        text
    <--  p2        text
    FORM select_data.
      clear: it_zasset, it_zasset[].
      select  equnr "bukrs
              anln1
              anln2
              bukrs
              KOSTL
              SCANNEDBY
              SCANNINGDATE
              SCANNINGTIME
              UPDATEDATE
              UPDATETIME
              into table it_zasset "(g_anln1,g_anln2)
              from zasset
              where bukrs = zasset-bukrs..
          and   kostl = zasset-kostl.
      if sy-subrc = 0.
        sort it_zasset by anln1 anln2.
      endif.
    append it_zasset.
      clear it_zasset1.
      select
             equnr
              anln1
              anln2
              bukrs
              ernam
              erdat
             bukrs
             KOSTL
             SCANNEDBY
             SCANNINGDATE
             SCANNINGTIME
             UPDATEDATE
             UPDATETIME
              into table it_zasset1 "(g_anln1,g_anln2)
              from  anla
             where bukrs = it_zasset-bukrs.
      WHERE BUKRS IN S_BUKRS.
    and   kostl = anla-kostl.
      if sy-subrc = 0.
        select equnr
               anlnr
               anlun
               bukrs
               timbi
               kostl
               into table it_zasset2
               from itob
               for all entries in it_zasset1
              where bukrs = it_zasset1-bukrs
               WHERE   anlnr = it_zasset1-anln1.
      endif.
      APPEND IT_ZASSET1.
      IF SY-SUBRC = 0.
    *loop at it_zasset1 into wa_zasset1.
    loop at it_ZASSET1 into wa_zasset1.
    move wa_zasset1-bukrs to wa_final-bukrs.
        move wa_zasset1-anln1 to wa_final-anln1.
        move wa_zasset1-anln2 to wa_final-anln2.
    append wa_final to it_final.
    endloop.
    ENDIF.
    sort it_final.
    *LOOP AT IT_FINAL.
    *ENDLOOP.
    *ENDIF.
    *if sy-subrc = 0.
    *loop at it_zasset into wa_asset.
    *read table it_zasset into wa_asset with key anln2 = wa_asset-anln2
    *binary search.
    *read table it_final into wa_final with key anln2 = wa_final-anln2
    *binary search.
    *if wa_asset-anln2 = wa_final-anln2.
    *write : / 'error'.
    *endif.
    If sy-subrc <> 0.
       f_error = 'X'.
       write :  'No data Exists for the given selection in FA table'.
    else.
       loop at it_final.
         perform display.
       endloop.
    records exits in anla table also.
    endif.
    ENDFORM.                    " select_data
    *&      Form  MODIFYFIELDCAT
          text
    -->  p1        text
    <--  p2        text
    FORM MODIFYFIELDCAT.
      LOOP AT IT_FLDCAT INTO WA_FLDCAT.
         CASE WA_FLDCAT-FIELDNAME.
            WHEN 'EQUNR'.
    WA_FLDCAT-COL_POS = 1.
              WA_FLDCAT-SELTEXT_L = 'aSSET'.
            WHEN 'ANLN1'.
            wa_FLDCAT-KEY = 'X'.
              WA_FLDCAT-COL_POS = 5.
              WA_FLDCAT-SELTEXT_L = 'aSSET'.
            WHEN 'ANLN2'.
              WA_FLDCAT-KEY = 'X'.
              WA_FLDCAT-COL_POS = 6.
            wa_FLDCAT-HOTSPOT = 'X'.
            WHEN 'BUKRS'.
              WA_FLDCAT-CURRENCY = 'INR'.
             WA_FLDCAT-SYMBOL = 'X'.
          ENDCASE.
        MODIFY IT_FLDCAT FROM WA_FLDCAT.
    *IT_FLDCAT-fieldname   = 'EQUNR'.
    IT_FLDCAT-seltext_m   = 'DOCUM_TYPE'.
    IT_FLDCAT-col_pos     = 1.
    IT_FLDCAT-outputlen   = 10.
    IT_FLDCAT-emphasize   = 'X'.
    IT_FLDCAT-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
    append IT_FLDCAT TO IT_FLDCAT.
    IT_FLDCAT-fieldname   = 'ANLN1'.
    IT_FLDCAT-seltext_m   = 'DOCUM_TYPE'.
    IT_FLDCAT-col_pos     = 1.
    IT_FLDCAT-outputlen   = 10.
    IT_FLDCAT-emphasize   = 'X'.
    IT_FLDCAT-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
    append IT_FLDCAT TO IT_FLDCAT.
      ENDLOOP.
    ENDFORM.                    " MODIFYFIELDCAT
    *&      Form  list_display
          text
    -->  p1        text
    <--  p2        text
    *FORM list_display.
    *CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BUFFER_ACTIVE                = ' '
      I_CALLBACK_PROGRAM             = V_SYREPID
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = 'FRM_USER_COMMAND'
      I_STRUCTURE_NAME               =
      IS_LAYOUT                      = wa_layout
      IT_FIELDCAT                    = IT_FLDCAT
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = 'A'
      IS_VARIANT                     =
      IT_EVENTS                      = ITAB_EVENTS
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
    TABLES
       T_OUTTAB                       = IT_FINAL
    EXCEPTIONS
      PROGRAM_ERROR                  = 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.
    *ENDFORM.                    " list_display
    Edited by: Craig Cmehil on Jul 18, 2008 10:01 AM

    The problem is with this...
    types: begin of ty_final , "occurs 0,
    equnr like itob-equnr,
    anln1 like anla-anln1,
    anln2 like anla-anln2,
    bukrs like anla-bukrs,
    ernam
    erdat
    kostl like itob-kostl,
    end of ty_final.
    DATA: wa_final TYPE ty_final.
    DATA: it_final TYPE TABLE OF ty_final with header line.
    when you are using Fieldcatalog merge you have to avoid using the TYPES Declaration of the internal table.
    Instead of that you can do this
    data: begin of it_final occurs 0,
    equnr like itob-equnr,
    anln1 like anla-anln1,
    anln2 like anla-anln2,
    bukrs like anla-bukrs,
    ernam
    erdat
    kostl like itob-kostl,
            end of it_final.

  • Field symbols and delete internal table.

    Hi,
    I wish to implement <fs> in this case:
    LOOP AT intable ASSIGNING <fs> WHERE condition
    IF condition1.
        DELETE intable
    ANDLOOP
    I know that if the condition1 is verified, the <fs> will be unassigned but in this case I lose the loop.
    Any Idea? ... Or is it impossible to handle?
    Thanks in advance.
    Regards,
         Giovanni

    If you know the standard table name in the start routine , then you can create a dynamic structure after adding a field flag, then you can use that as 
      call function 'LVC_FIELDCATALOG_MERGE'
        exporting
          i_structure_name = p_table
        changing
          ct_fieldcat      = i_fcat
        exceptions
          others           = 1.
      if sy-subrc = 0.
        loop at i_fcat assigning <fcat>.
          <fcat>-tabname = p_table.
          <fcat>-fieldname = 'FLAG'
          ....  " after giving other attributes for the flag field
         append <fcat> to i_fcat.  
        endloop.
        call function 'LVC_FIELDCAT_COMPLETE'
          changing
            ct_fieldcat = i_fcat
          exceptions
            others      = 1.
      endif.
      call method cl_alv_table_create=>create_dynamic_table
        exporting
          it_fieldcatalog = i_fcat
        importing
          ep_table        = i_content.
      if sy-subrc = 0.
        assign i_content->* to <fs>.
      endif.

  • Field catalog required between internal table

    Hi firneds
    My ALV output showing the data like this
    Consinee consine state Quantity Amount unit.
    xyz           delhi              10          10.20  UA
    xyz           delhi              20          10.20  UA
    xyz           delhi              30          10.20  UA
    xyz           delhi              15          10.20  UA
    Total                                             40.80
    xyz           delhi              10          10.20  UA
    xyz           delhi              20          10.20  UA
    xyz           delhi              30          10.20  UA
    xyz           delhi              15          10.20  UA
    Total                                             40.80
    here if i down load to excel it is showing same but want to like this
    Consinee consine state Quantity Amount unit.
    xyz           delhi              10          10.20  UA
    xyz           delhi              20          10.20  UA
    xyz           delhi              30          10.20  UA
    Total                                             40.80
    Consinee consine state Quantity Amount unit.
    xyz           delhi              10          10.20  UA
    xyz           delhi              20          10.20  UA
    xyz           delhi              30          10.20  UA
    Total                                             40.80
    Every total after the column header shuold repeate how can i achieve this
    REgards
    RK

    you can jsut pass these texts of header as data to those lines after total..
    but is the TOTAL coming form SUBTOTAL fucntionality or its a row inserted by you!!!

  • Dynamic internal table and dynamic field catalog

    hi
    i need to decide the number of fields of the internal table at runtime
    and then need to pass value to this internal table.
    then i need to create the field catalog for this internal table (so here
    field catalog is also dynamic) to display in alv.
    how to achieve this dynamic internal table creation and dyanmic field catalog generation

    Hi Ajay,
      U can use the below code to create a dynamic internal table.
    *adding the field names only once for the dynamic table     .
          MOVE 'PRCTR' TO gw_component-name.
          gw_component-type ?= cl_abap_elemdescr=>get_string( ).
          INSERT gw_component INTO TABLE gt_components.
          MOVE 'RCNTR' TO gw_component-name.
          gw_component-type ?= cl_abap_elemdescr=>get_string( ).
          INSERT gw_component INTO TABLE gt_components.
          MOVE 'RACCT' TO gw_component-name.
          gw_component-type ?= cl_abap_elemdescr=>get_string( ).
          INSERT gw_component INTO TABLE gt_components.
          MOVE 'RYEAR' TO gw_component-name.
          gw_component-type ?= cl_abap_elemdescr=>get_string( ).
          INSERT gw_component INTO TABLE gt_components.
          MOVE 'YTDBAL' TO gw_component-name.
          gw_component-type ?= cl_abap_elemdescr=>get_string( ).
          INSERT gw_component INTO TABLE gt_components.
          MOVE 'OBAL' TO gw_component-name.
          gw_component-type ?= cl_abap_elemdescr=>get_string( ).
          INSERT gw_component INTO TABLE gt_components.
    *get structure descriptor -> GR_STRUCTDESCR
              gr_structdescr ?= cl_abap_structdescr=>create( gt_components ).
    create work area of structure GR_STRUCTDESCR -> GR_WA
              CREATE DATA gr_wa TYPE HANDLE gr_structdescr.
              ASSIGN gr_wa->* TO <gw_wa>.
    determine key components -> GT_KEYS
              MOVE lv_value1 TO gw_key-name.
              INSERT gw_key INTO TABLE gt_keys.
    create descriptor for internal table -> GR_TABLEDESCR
              gr_tabledescr ?= cl_abap_tabledescr=>create( p_line_type  = gr_structdescr
                                                           p_table_kind = cl_abap_tabledescr=>tablekind_hashed
                                                           p_unique     = abap_true
                                                           p_key        = gt_keys
                                                           p_key_kind   = cl_abap_tabledescr=>keydefkind_user ).
    create internal table -> GR_ITAB
              CREATE DATA gr_itab TYPE HANDLE gr_tabledescr.
              ASSIGN gr_itab->* TO <gt_itab>.
              CREATE DATA gr_itab LIKE STANDARD TABLE OF <gw_wa>.
              ASSIGN gr_itab->* TO <gt_sttab>.
    Now u r internal table named <gt_sttab> has been created with fields like RCNTR, PRCTR,RACCT, RYEAR etc whatever the field u need u can go ahead and create dynamically.
    then by using the table <gt_sttab> u can create u r field catalog.
    Regards,
    Rose.

  • Build field catalog for dynamic data objects

    Hi
    Could you please tell me how to build a field catalog (ooops alv)  for an internal table which is a dynamic data object.
      TYPES: BEGIN OF t_addsubty,
             subty TYPE subty,
             pernr TYPE persno,
             END OF t_addsubty.
      TYPES: ty_addsubty type t_addsubty occurs 1.
    i have data object using these
            CREATE DATA dref3 TYPE (g_type1).
            ASSIGN dref3->* TO <fs_dp>.
    where g_type1 refers a data type which i defined in the program. g_type1 = ty_addsubty. 
    now <fs_dp> refers to an internal table.
    now i want to build a field catalog for this internal table.
    In my program <fs_dp> structure is not always the same. i.e now it is ty_addsubty but for some other conditions the structure is different.
    please help me out.
    regards
    badri

    Here some piece of code, which shows how it works:
    <SNIP>
    type-pools:
         abap.
    DATA:
      lr_tabledescr          TYPE REF TO cl_abap_tabledescr,
      lr_structdescr     TYPE REF TO cl_abap_structdescr.
    field-symbols:
      <lw_component>     type abap_compdescr_tab.
    TYPES:
         BEGIN OF t_addsubty,
              subty TYPE subty,
              pernr TYPE persno,
         END OF t_addsubty.
    TYPES:
         ty_addsubty type t_addsubty occurs 1.
    CREATE DATA dref3 TYPE (g_type1).
    ASSIGN dref3->* TO <fs_dp>.
    lr_tabledescr ?= cl_abap_tabledescr=>describe_by_data( <fs_dp> ).
    assert condition lr_tabledescr is bound.
    lr_structdescr ?= lr_tabledescr->get_table_line_type( ).
    loop at lr_structdescr->components assigning <lw_component>.
    *     do whatever you want with the information about
    *     the components of the structure
    endloop.
    </SNIP>
    Do not forget to reward points...

  • Creation of Sorted and Standard and Hashed Internal Tables ..

    Hi ..
    Pls  specify me.. how to create .. sorted ,Standard and Hashed Internal Tables...
    pls give me  the full code  regarding ...this ..
    Thnks

    Standard tables
    This is the most appropriate type if you are going to address the individual table entries using the index. Index access is the quickest possible access. You should fill a standard table by appending lines (ABAP APPEND statement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command). The access time for a standard table increases in a linear relationship with the number of table entries. If you need key access, standard tables are particularly useful if you can fill and process the table in separate steps. For example, you could fill the table by appending entries, and then sort it. If you use the binary search option with key access, the response time is logarithmically proportional to the number of table entries.
    Sorted tables
    This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.
    Hashed tables
    This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index. The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for processing large amounts of data.
    Special Features of Standard Tables
    Unlike sorted tables, hashed tables, and key access to internal tables, which were only introduced in Release 4.0, standard tables already existed several releases previously. Defining a line type, table type, and tables without a header line have only been possible since Release 3.0. For this reason, there are certain features of standard tables that still exist for compatibility reasons.
    Standard Tables Before Release 3.0
    Before Release 3.0, internal tables all had header lines and a flat-structured line type. There were no independent table types. You could only create a table object using the OCCURS addition in the DATA statement, followed by a declaration of a flat structure:
    DATA: BEGIN OF <itab> OCCURS <n>,
    <fi> ...
    END OF <itab>.
    This statement declared an internal table <itab> with the line type defined following the OCCURS addition. Furthermore, all internal tables had header lines.
    The number <n> in the OCCURS addition had the same meaning as in the INITIAL SIZE addition from Release 4.0. Entering ‘0’ had the same effect as omitting the INITIAL SIZE addition. In this case, the initial size of the table is determined by the system.
    The above statement is still possible in Release 4.0, and has roughly the same function as the following statements:
    TYPES: BEGIN OF <itab>,
    <fi> ...,
    END OF <itab>.
    DATA <itab> TYPE STANDARD TABLE OF <itab>
    WITH NON-UNIQUE DEFAULT KEY
    INITIAL SIZE <n>
    WITH HEADER LINE.
    In the original statement, no independent data type <itab> is created. Instead, the line type only exists as an attribute of the data object <itab>.
    Standard Tables From Release 3.0
    Since Release 3.0, it has been possible to create table types using
    TYPES <t> TYPE|LIKE <linetype> OCCURS <n>.
    and table objects using
    DATA <itab> TYPE|LIKE <linetype> OCCURS <n> WITH HEADER LINE.
    The effect of the OCCURS addition is to construct a standard table with the data type <linetype>. The line type can be any data type. The number <n> in the OCCURS addition has the same meaning as before Release 3.0. Before Release 4.0, the key of an internal table was always the default key, that is, all non-numeric fields that were not themselves internal tables.
    The above statements are still possible in Release 4.0, and have the same function as the following statements:
    TYPES|DATA <itab> TYPE|LIKE STANDARD TABLE OF <linetype>
    WITH NON-UNIQUE DEFAULT KEY
    INITIAL SIZE <n>
    WITH HEADER LINE.
    They can also be replaced by the following statements:
    Standard Tables From Release 4.0
    When you create a standard table, you can use the following forms of the TYPES and DATA statements. The addition INITIAL SIZE is also possible in all of the statements. The addition WITH HEADER LINE is possible in the DATA statement.
    Standard Table Types
    Generic Standard Table Type:
    TYPES <itab> TYPE|LIKE STANDARD TABLE OF <linetype>.
    The table key is not defined.
    Fully-Specified Standard Table Type:
    TYPES <itab> TYPE|LIKE STANDARD TABLE OF <linetype>
    WITH NON-UNIQUE <key>.
    The key of a fully-specified standard table is always non-unique.
    Standard Table Objects
    Short Forms of the DATA Statement :
    DATA <itab> TYPE|LIKE STANDARD TABLE OF <linetype>.
    DATA <itab> TYPE|LIKE STANDARD TABLE OF <linetype>
    WITH DEFAULT KEY.
    Both of these DATA statements are automatically completed by the system as follows:
    DATA <itab> TYPE|LIKE STANDARD TABLE OF <linetype>
    WITH NON-UNIQUE DEFAULT KEY.
    The purpose of the shortened forms of the DATA statement is to keep the declaration of standard tables, which are compatible with internal tables from previous releases, as simple as possible. When you declare a standard table with reference to the above type, the system automatically adopts the default key as the table key.
    Fully-Specified Standard Tables:
    DATA <itab> TYPE|LIKE STANDARD TABLE OF <linetype>
    WITH NON-UNIQUE <key>.
    The key of a standard table is always non-unique.
    Internal table objects
    Internal tables are dynamic variable data objects. Like all variables, you declare them using the DATA statement. You can also declare static internal tables in procedures using the STATICS statement, and static internal tables in classes using the CLASS-DATA statement. This description is restricted to the DATA statement. However, it applies equally to the STATICS and CLASS-DATA statements.
    Reference to Declared Internal Table Types
    Like all other data objects, you can declare internal table objects using the LIKE or TYPE addition of the DATA statement.
    DATA <itab> TYPE <type>|LIKE <obj> WITH HEADER LINE.
    Here, the LIKE addition refers to an existing table object in the same program. The TYPE addition can refer to an internal type in the program declared using the TYPES statement, or a table type in the ABAP Dictionary.
    You must ensure that you only refer to tables that are fully typed. Referring to generic table types (ANY TABLE, INDEX TABLE) or not specifying the key fully is not allowed (for exceptions, refer to Special Features of Standard Tables).
    The optional addition WITH HEADER line declares an extra data object with the same name and line type as the internal table. This data object is known as the header line of the internal table. You use it as a work area when working with the internal table (see Using the Header Line as a Work Area). When you use internal tables with header lines, you must remember that the header line and the body of the table have the same name. If you have an internal table with header line and you want to address the body of the table, you must indicate this by placing brackets after the table name (<itab>[]). Otherwise, ABAP interprets the name as the name of the header line and not of the body of the table. You can avoid this potential confusion by using internal tables without header lines. In particular, internal tables nested in structures or other internal tables must not have a header line, since this can lead to ambiguous expressions.
    TYPES VECTOR TYPE SORTED TABLE OF I WITH UNIQUE KEY TABLE LINE.
    DATA: ITAB TYPE VECTOR,
    JTAB LIKE ITAB WITH HEADER LINE.
    MOVE ITAB TO JTAB. <- Syntax error!
    MOVE ITAB TO JTAB[].
    The table object ITAB is created with reference to the table type VECTOR. The table object JTAB has the same data type as ITAB. JTAB also has a header line. In the first MOVE statement, JTAB addresses the header line. Since this has the data type I, and the table type of ITAB cannot be converted into an elementary type, the MOVE statement causes a syntax error. The second MOVE statement is correct, since both operands are table objects.
    plz reward if useful

  • Reg: field names of an Internal table

    Hi all,
    I'd like to display all the field names of the internal table or a structure.
    I want it very urgent.
    Use ful answers will be awarded greatly.
    Thanks in advance.
    Jagan Mohan.

    Hi Jagan,
      Use the below code.
    TYPE-POOLS: SYDES.
    DATA: TD TYPE SYDES_DESC.
    DATA: BEGIN OF WA OCCURS 0,
           CONTINUE     TYPE C,
           NAME(15)     TYPE C,
          END OF WA.
    TYPES:BEGIN OF STR1,
            NUM(3) TYPE N,
            NAME(20) TYPE C,
          END OF STR1.
    *DATA: ITAB LIKE T247 OCCURS 0 WITH HEADER LINE.
    *DATA: ITAB TYPE STR1 OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF ITAB OCCURS 0,
           NUM(3) TYPE N,
           NAME(20) TYPE C,
          END OF ITAB.
    DESCRIBE FIELD ITAB INTO TD.
    WA[] = TD-NAMES[].
    LOOP AT WA.
      IF WA-NAME = SY-REPID.
        DELETE WA.
        CONTINUE.
      ENDIF.
      SEARCH WA-NAME FOR '-'.
      IF SY-SUBRC = 0.
        DELETE WA.
        CONTINUE.
      ENDIF.
      SEARCH WA-NAME FOR '='.
      IF SY-SUBRC = 0.
        DELETE WA.
        CONTINUE.
      ENDIF.
    ENDLOOP.
    LOOP AT WA.
      WRITE: / WA-NAME.
    ENDLOOP.

  • Reg: Dynamic Field catalog in ALV

    Hi ,
    Can any one guide me to build a dynamic field catalog in ALV report?
    Below is the format which i expect..........
    Material    |     Plant1    |    Plant2    |    Plant3    | ....................|    Plant 20      |
    Qty
    Val
    Qty
    Val
    Qty
    Val
    Qty
    Val
    The plant 1 to 20 has to be brought dynamically as headings from T001W table. (Horizontally populate)
    Below each plant i need sub-headings "QTY" and "VAL".                                  (Horizontally populate)
    List of Materials should be brought vertically from MARA table.                          (Vertically populate)
    Can anyone suggest how to bring out this format for populating data accordingly into the o/p format?
    Ur help will be appreciated.
    Thanks,
    K.S.Kannan

    your part of the code is present in routine
    perform dynamic_table.
    *& Report ZCS_NAC_MAT_CHARACTERISTICS
    2/ Description ...: Business requirement is to get all materials
    without any characteristic values maintained in SAP
    which are given in the selection screen.
    REPORT znac_material_char.
    TYPE-POOLS : abap,
    slis.
    TABLES : kssk,
    klah,
    mara,
    makt,
    cabn,
    t134,
    t023.
    DATA : i_fieldcat TYPE slis_t_fieldcat_alv ,
    wa_fieldcat TYPE slis_fieldcat_alv.
    DATA : w_layout TYPE slis_layout_alv.
    DATA : st_layout TYPE slis_layout_alv.
    DATA : t_header TYPE slis_t_listheader,
    w_header TYPE slis_listheader.
    TYPES : BEGIN OF ty_cabn,
    atinn TYPE cabn-atinn,
    atnam TYPE cabn-atnam,
    END OF ty_cabn.
    DATA : i_cabn TYPE STANDARD TABLE OF ty_cabn WITH HEADER LINE.
    DATA : w_cabn LIKE i_cabn.
    TYPES : BEGIN OF ty_ausp,
    objek TYPE ausp-objek,
    atinn TYPE ausp-atinn,
    klart TYPE ausp-klart,
    END OF ty_ausp.
    DATA : i_ausp TYPE STANDARD TABLE OF ty_ausp WITH HEADER LINE.
    DATA : w_ausp LIKE i_ausp.
    TYPES : BEGIN OF ty_mara,
    matnr TYPE mara-matnr,
    mtart TYPE mara-mtart,
    matkl TYPE mara-matkl,
    prdha TYPE mara-prdha,
    mstae TYPE mara-mstae,
    mstde TYPE mara-mstde,
    END OF ty_mara.
    DATA : i_mara TYPE STANDARD TABLE OF ty_mara WITH HEADER LINE.
    DATA : w_mara LIKE i_mara.
    DATA : i_mara_temp TYPE STANDARD TABLE OF ty_mara WITH HEADER LINE.
    DATA : w_mara_temp LIKE i_mara_temp.
    TYPES :BEGIN OF ty_data,
    atnam TYPE cabn-atnam,
    atinn TYPE cabn-atinn,
    objek TYPE ausp-objek,
    klart TYPE ausp-klart,
    matnr TYPE mara-matnr,
    maktx TYPE makt-maktx,
    mtart TYPE mara-mtart,
    matkl TYPE mara-matkl,
    prdha TYPE mara-prdha,
    mstae TYPE mara-mstae,
    mstde TYPE mara-mstde,
    END OF ty_data.
    DATA : i_data TYPE STANDARD TABLE OF ty_data WITH HEADER LINE.
    DATA : w_data LIKE i_data.
    DATA : i_class TYPE STANDARD TABLE OF sclass WITH HEADER LINE.
    DATA : w_class LIKE i_class.
    DATA : i_class_temp TYPE STANDARD TABLE OF sclass WITH HEADER LINE.
    DATA : w_class_temp LIKE i_class_temp.
    DATA : i_objdata TYPE STANDARD TABLE OF clobjdat WITH HEADER LINE.
    DATA : w_objdata LIKE i_objdata.
    TYPES : BEGIN OF ty_objdata_temp.
    TYPES: matnr TYPE mara-matnr.
    TYPES: maktx TYPE makt-maktx.
    INCLUDE STRUCTURE clobjdat.
    TYPES : prdha TYPE mara-prdha.
    TYPES : mstde TYPE mara-mstde.
    TYPES : END OF ty_objdata_temp.
    DATA : i_objdata_temp TYPE STANDARD TABLE OF ty_objdata_temp WITH HEADER LINE.
    DATA : w_objdata_temp LIKE i_objdata_temp.
    FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
    <fs_dyntable>,
    <fs_fldval> TYPE ANY.
    DATA: t_newtable TYPE REF TO data,
    t_newline TYPE REF TO data,
    fs_fldcat TYPE slis_t_fieldcat_alv,
    t_fldcat1 TYPE lvc_t_fcat,
    wa_it_fldcat TYPE lvc_s_fcat,
    wa_colno(2) TYPE n,
    wa_flname(30) TYPE c.
    DATA: fieldname(20) TYPE c.
    DATA: fieldvalue(40) TYPE c.
    DATA: index(3) TYPE c,
    v_time(60) TYPE c.
    DATA: wa_cat LIKE LINE OF fs_fldcat.
    CONSTANTS : c_nac TYPE klah-class VALUE 'NAC',
    c_klart TYPE ausp-klart VALUE '001',
    c_check TYPE c VALUE 'X' .
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (28) text-001 .
    SELECT-OPTIONS: s_atnam FOR cabn-atnam NO INTERVALS OBLIGATORY. " Characteristic name
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK b1 .
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    SELECT-OPTIONS: s_matnr FOR mara-matnr. " material Number
    SELECT-OPTIONS: s_mtart FOR mara-mtart. " material type
    SELECT-OPTIONS: s_matkl FOR mara-matkl. " material type
    SELECT-OPTIONS: s_mstae FOR mara-mstae. " X-Plant material status
    PARAMETERS : s_date LIKE sy-datum OBLIGATORY DEFAULT sy-datum . " date
    SELECTION-SCREEN END OF BLOCK b2 .
    AT SELECTION-SCREEN ON s_atnam.
    SELECT SINGLE * FROM cabn WHERE atnam IN s_atnam.
    IF sy-subrc 0.
    MESSAGE text-003 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON s_matnr.
    SELECT SINGLE * FROM mara WHERE matnr IN s_matnr.
    IF sy-subrc 0.
    MESSAGE text-004 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON s_mtart.
    SELECT SINGLE * FROM t134 WHERE mtart IN s_mtart.
    IF sy-subrc 0.
    MESSAGE text-005 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON s_matkl.
    SELECT SINGLE * FROM t023 WHERE matkl IN s_matkl.
    IF sy-subrc 0.
    MESSAGE text-006 TYPE 'E'.
    ENDIF.
    START-OF-SELECTION.
    PERFORM get_data.
    PERFORM get_data_keydate.
    PERFORM material_all_charname.
    PERFORM get_classification.
    PERFORM dynamic_table.
    *& Form dynamic_table
    text
    --> p1 text
    <-- p2 text
    FORM dynamic_table.
    PERFORM fieldcatalog.
    PERFORM dynamic_table_create.
    PERFORM final_data.
    PERFORM final_fieldcatalog.
    PERFORM layout_build.
    PERFORM grid_display.
    ENDFORM. " fieldcat
    *& Form layout_build
    text
    FORM layout_build .
    st_layout-zebra = c_check.
    st_layout-no_vline = ''.
    st_layout-colwidth_optimize = c_check.
    st_layout-detail_popup = c_check.
    st_layout-detail_initial_lines = c_check.
    st_layout-detail_titlebar = text-021.
    ENDFORM. " layout_build
    *& Form alv_top_of_page
    text
    FORM alv_top_of_page.
    REFRESH t_header.
    CLEAR t_header.
    w_header-typ = 'H'. "H=Header, S=Selection, A=Action
    w_header-key = ' '.
    w_header-info = text-019.
    APPEND w_header TO t_header.
    CONCATENATE sy-datum4(2) '-' sy-datum6(2) '-' sy-datum0(4) ' / ' sy-uzeit0(2) ':' sy-uzeit2(2) ':' sy-uzeit4(2) INTO v_time.
    w_header-typ = 'S'. "H=Header, S=Selection, A=Action
    w_header-key = text-020.
    w_header-info = v_time.
    APPEND w_header TO t_header.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = t_header.
    ENDFORM. "alv_top_of_page
    *& Form grid_display
    text
    --> p1 text
    <-- p2 text
    FORM grid_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    i_callback_top_of_page = 'ALV_TOP_OF_PAGE'
    it_fieldcat = fs_fldcat
    is_layout = st_layout
    i_default = c_check
    i_save = 'A'
    it_events = v_events[]
    TABLES
    t_outtab = <t_dyntable>.
    ENDFORM. " grid_display
    *& Form FINAL_FIELDCATALOG
    text
    --> p1 text
    <-- p2 text
    FORM final_fieldcatalog .
    wa_cat-fieldname = text-009.
    wa_cat-seltext_m = text-015.
    wa_cat-outputlen = 18.
    APPEND wa_cat TO fs_fldcat.
    wa_cat-fieldname = text-011.
    wa_cat-seltext_m = text-016.
    wa_cat-outputlen = 40.
    APPEND wa_cat TO fs_fldcat.
    LOOP AT s_atnam.
    CLEAR wa_cat.
    wa_cat-fieldname = s_atnam-low.
    wa_cat-seltext_m = s_atnam-low.
    wa_cat-outputlen = '15'.
    APPEND wa_cat TO fs_fldcat.
    ENDLOOP.
    wa_cat-fieldname = text-012.
    wa_cat-seltext_m = text-017.
    wa_cat-outputlen = 18.
    APPEND wa_cat TO fs_fldcat.
    wa_cat-fieldname = text-013.
    wa_cat-seltext_m = text-018.
    wa_cat-outputlen = 8.
    APPEND wa_cat TO fs_fldcat.
    ENDFORM. " FINAL_FIELDCATALOG
    *& Form FIELDCATALOG
    text
    --> p1 text
    <-- p2 text
    FORM fieldcatalog .
    wa_it_fldcat-fieldname = text-009.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 18.
    APPEND wa_it_fldcat TO t_fldcat1.
    wa_it_fldcat-fieldname = text-011.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 40.
    APPEND wa_it_fldcat TO t_fldcat1.
    LOOP AT s_atnam.
    CLEAR wa_it_fldcat.
    wa_it_fldcat-fieldname = s_atnam-low.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 30.
    APPEND wa_it_fldcat TO t_fldcat1.
    ENDLOOP.
    wa_it_fldcat-fieldname = text-012.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 18.
    APPEND wa_it_fldcat TO t_fldcat1.
    wa_it_fldcat-fieldname = text-013.
    wa_it_fldcat-datatype = text-014.
    wa_it_fldcat-intlen = 8.
    APPEND wa_it_fldcat TO t_fldcat1.
    ENDFORM. " FIELDCATALOG
    *& Form DYNAMIC_TABLE_CREATE
    text
    --> p1 text
    <-- p2 text
    FORM dynamic_table_create .
    Create dynamic internal table and assign to FS
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = t_fldcat1
    IMPORTING
    ep_table = t_newtable.
    ASSIGN t_newtable->* TO <t_dyntable>.
    Create dynamic work area and assign to FS
    CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
    ASSIGN t_newline->* TO <fs_dyntable>.
    ENDFORM. " DYNAMIC_TABLE_CREATE
    *& Form FINAL_DATA
    text
    --> p1 text
    <-- p2 text
    FORM final_data .
    LOOP AT i_objdata_temp INTO w_objdata_temp.
    *assign w_objdata_temp-matnr to <fs_dyntable>.
    AT NEW matnr.
    wa_flname = text-009.
    fieldvalue = w_objdata_temp-matnr.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    ENDAT.
    wa_flname = text-011.
    fieldvalue = w_objdata_temp-maktx.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    wa_flname = w_objdata_temp-atnam.
    fieldvalue = w_objdata_temp-ausp1.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    wa_flname = text-012.
    fieldvalue = w_objdata_temp-prdha.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    wa_flname = text-013.
    fieldvalue = w_objdata_temp-mstde.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    AT END OF matnr.
    APPEND <fs_dyntable> TO <t_dyntable>.
    ENDAT.
    ENDLOOP.
    ENDFORM. " FINAL_DATA
    *& Form GET_CLASSIFICATION
    text
    --> p1 text
    <-- p2 text
    FORM get_classification .
    LOOP AT i_data INTO w_data.
    SELECT SINGLE * FROM klah WHERE class = c_nac.
    IF sy-subrc = 0.
    IF w_data-mstde >= klah-vondt.
    CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
    EXPORTING
    class = c_nac
    classtext = c_check
    classtype = c_klart
    clint = 0
    features = c_check
    language = sy-langu
    object = w_data-objek
    TABLES
    t_class = i_class
    t_objectdata = i_objdata
    EXCEPTIONS
    no_classification = 1
    no_classtypes = 2
    invalid_class_type = 3
    OTHERS = 4.
    LOOP AT i_class INTO w_class.
    MOVE w_class TO w_class_temp.
    APPEND w_class_temp TO i_class_temp.
    ENDLOOP .
    LOOP AT s_atnam.
    READ TABLE i_objdata INTO w_objdata WITH KEY atnam = s_atnam-low.
    IF sy-subrc = 0.
    MOVE w_data-matnr TO w_objdata_temp-matnr.
    MOVE w_data-maktx TO w_objdata_temp-maktx.
    MOVE-CORRESPONDING w_objdata TO w_objdata_temp.
    MOVE w_data-prdha TO w_objdata_temp-prdha.
    MOVE w_data-mstde TO w_objdata_temp-mstde.
    APPEND w_objdata_temp TO i_objdata_temp.
    ENDIF.
    ENDLOOP.
    ENDIF.
    ENDIF.
    ENDLOOP.
    ENDFORM. " GET_CLASSIFICATION

  • DIfference between Reusable FM for ALV display and ALV display using class

    Hi,
    Is there any difference between alv display using Resuable FM and ALV display using classes except the later one uses OO concept.??
    One mere thing i want to clarify is that is there any difference exist between REUSE_ALV_GRID_DISPLAY and REUSE_ALV_LIST_DISPLAY? If so, then let me know.
    It could be easier to understand me if yuo give scenario where these FM comes into picture
    Regards,
    Parag

    Hi,
    (1) REUSE_ALV_LIST_DISPLAY
    Display an ALV list as per parameters defined in the function call
    (2) REUSE_ALV_GRID_DISPLAY
    Display an ALV grid as per parameters defined in the function call
    (3) REUSE_ALV_COMMENTARY_WRITE
    List header information is output according to its type. The output information is put in an internal table. Output attributes are assigned to each line via the TYP field.This module outputs formatted simple header information at TOP-OF-PAGE.
    (4) REUSE_ALV_HIERSEQ_LIST_DISPLAY
    This module outputs two internal tables as a formated hierarchical-sequential list.
    (5) REUSE_ALV_VARIANT_F4
    Display variant selection dialog box.
    (6) REUSE_ALV_VARIANT_EXISTENCE
    Checks whether a display variant exists.
    Other Useful Link :
    Customize ALV grid layout at run time
    Download ALV grid Control Tutorial
    Understand ALV report ( Just Copy and paste )
    Dynamic selection on ALV at run time
    Dynamic selection on ALV at run time
    Regards
    Kiran

  • Are field symbols and Dynamic internal tables consistant?

    Hi,
    Are field symbols and Dynamic internal tables
    always consistent?
    In my program I m creating a dynamic itab and assignig values to it using <FS>, sometimes the program fails to execute assign <Fs> statement...
    this happens once in 3 to 4 runs
    any solution...
    I have proper clear and refresh statements in program.
    Thanks,
    Hardik

    Anurag,
    Thanks for a quick reply. Here I am sending a small piece of my code.
    MOVE-CORRESPONDING OUTTAB TO DYNTAB.
          CLEAR IT_UDATE.
          CLEAR : T_KBETR .
          READ TABLE IT_UDATE WITH KEY UDATE = OUTTAB-UDATE.
          CONCATENATE 'DYNTAB-KBETR' IT_UDATE-CO_POS INTO T_KBETR.
          ASSIGN (T_KBETR) TO <FS> .
          SUBRC5 = SY-SUBRC .
          IF SUBRC5 = 0 .
              <FS> =  OUTTAB-KBETR .
          ENDIF .
    read statement will always return CO_POS .
    while debuging this code a few times
    <b>ASSIGN (T_KBETR) TO <FS> .</b>
    returns sy-subrc = 4
    and that was leading the program to short dump earlier.
    now, as I have a check DYNTAB-KBETR holds no value on display.
    this happens very few times. (most of the times report is displaying desired output)
    Thanks,
    Hardik

  • How do I define Field-Catalog and Event-Catalog in OOPs ALV

    Hi All,
    This is the piece of the code on which I'm working upon. This program is giving an exception "No Field-Catalog Found". 
    I'm new to OOPs ALV. Could anybody please tell me how to define the field-catalog and event-catalog in this.
    module PBO output.
          IF g_custom_container IS INITIAL.
              CREATE OBJECT g_custom_container EXPORTING CONTAINER_NAME = 'CCCONTAINER'.
              CREATE OBJECT g_grid             EXPORTING I_PARENT       = g_custom_container.
          CALL METHOD g_grid->set_table_for_first_display
              EXPORTING I_STRUCTURE_NAME = 'IT_MATERIAL'
                        is_layout = layout
              CHANGING IT_OUTTAB         = gt_it_material.
          ENDIF.
      endmodule.
    Regards,
    Saurabh

    hi,
    chk this sampl ceode.
    TYPE-POOLS: slis.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    TABLES : zmpets_shipactiv, zmpets_chargebk, zmpets_shiphdr.
    DATA : BEGIN OF int_crb OCCURS 0,
           sel TYPE char1,
           icon TYPE icon_d,
           pernr LIKE zmpets_cil-pernr,
           vorna LIKE pa0002-vorna,
           movreason LIKE zmpets_shiphdr-movreason,
           shipdocnum LIKE zmpets_chargebk-shipdocnum,
           createdon LIKE zmpets_chargebk-createdon,
           chargeamount LIKE zmpets_chargebk-chargeamount,
           version LIKE zmpets_shipactiv-version,
           activity LIKE zmpets_shipactiv-activity,
           vendor LIKE zmpets_shiphdr-vendor,
          smtp_addr LIKE adr6-smtp_addr,
           empperid LIKE zmpets_167doc-empperid,
           celltab TYPE lvc_t_styl,
           END OF int_crb.
    DATA : int_crb_ver LIKE int_crb OCCURS 0 WITH HEADER LINE.
    DATA : int_crb_mail LIKE int_crb OCCURS 0 WITH HEADER LINE.
    DATA : int_shipactiv LIKE zmpets_shipactiv OCCURS 0 WITH HEADER LINE.
    DATA: gt_fieldcatalog TYPE lvc_t_fcat.
    DATA : wf_flag TYPE i.
    DATA : wf_res TYPE c.
    DATA : wf_tabix TYPE sy-tabix.
    DATA: BEGIN OF int_sin OCCURS 0,
          shipdocnum LIKE zmpets_chargebk-shipdocnum,
            shipdocnum LIKE zmpets_shipactiv-petsdocnumber,
          END OF int_sin.
    DATA: objpack   LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    DATA: objhead   LIKE solisti1 OCCURS 1 WITH HEADER LINE.
    DATA: objbin    LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: objtxt    LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: reclist   LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
    DATA: doc_chng  LIKE sodocchgi1.
    DATA: tab_lines LIKE sy-tabix.
    DATA l_num(3).
    DATA: ok_code            LIKE          sy-ucomm,
          w_repid            LIKE          sy-repid,
          wl_sno             TYPE          i         VALUE 0,
          w_max              TYPE          i         VALUE 100,
          wf_layout          TYPE          lvc_s_layo,
          cont_on_main       TYPE          scrfname   VALUE  'GRID_CONTROL',
          cont_on_dialog     TYPE          scrfname   VALUE 'GRID_CONTROL',
          grid1              TYPE          REF TO cl_gui_alv_grid,
          grid2              TYPE          REF TO cl_gui_alv_grid,
          custom_container1  TYPE          REF TO cl_gui_custom_container,
          custom_container2  TYPE          REF TO cl_gui_custom_container,
          event_receiver     TYPE          REF TO lcl_event_receiver,
          lt_exclude         TYPE          ui_functions,
          ls_celltab         TYPE          lvc_s_styl,
          lt_celltab         TYPE          lvc_t_styl.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-001.
    PARAMETERS : p_cash AS CHECKBOX.
    SELECTION-SCREEN END OF BLOCK b3.
    PERFORM fieldcatalog_init USING gt_fieldcatalog[].
    Selection-Screen----
    SELECTION-SCREEN  BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
    SELECT-OPTIONS:s_chdate FOR zmpets_chargebk-createdon,
                   s_pernr FOR zmpets_shiphdr-pernr,
                   s_mvrsn FOR zmpets_shiphdr-movreason,
                   s_sin FOR zmpets_chargebk-shipdocnum NO INTERVALS
    NO-EXTENSION.
    SELECTION-SCREEN  END OF BLOCK b1.
    PERFORM f_clear_fields.
    CALL SCREEN 100.
          CLASS lcl_event_receiver DEFINITION
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_toolbar
            FOR EVENT toolbar OF cl_gui_alv_grid
                IMPORTING e_object e_interactive,
        handle_user_command
            FOR EVENT user_command OF cl_gui_alv_grid
                IMPORTING e_ucomm.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
          CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_toolbar.
    § 2.In event handler method for event TOOLBAR: Append own functions
      by using event parameter E_OBJECT.
        DATA: ls_toolbar  TYPE stb_button.
    append a separator to normal toolbar
        CLEAR ls_toolbar.
        MOVE 3 TO ls_toolbar-butn_type.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
    new button -
        MOVE 'PROCESSED' TO ls_toolbar-function.
        MOVE icon_execute_object TO ls_toolbar-icon.
        MOVE 'Process the Record'(110) TO ls_toolbar-quickinfo.
        MOVE ' Process '(200) TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar
      METHOD handle_user_command.
    § 3.In event handler method for event USER_COMMAND: Query your
      function codes defined in step 2 and react accordingly.
        DATA: lt_rows TYPE lvc_t_row.
        CASE e_ucomm.
          WHEN 'PROCESSED'.
            CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
                     EXPORTING
                      defaultoption        = 'N'
      textline1     = 'Do you want to process the selected documents?'
              TEXTLINE2            = ' '
                       titel                = 'Process Documents'
              START_COLUMN         = 25
              START_ROW            = 6
              CANCEL_DISPLAY       = 'X'
                    IMPORTING
                      answer               = wf_res.
    *--IF THE USER CONFIRMS 'YES',
            IF wf_res = 'J'.
              PERFORM f_modify_activity.
              CALL METHOD grid1->refresh_table_display.
           PERFORM SENDINGMAIL.
            ENDIF.
        ENDCASE.
      ENDMETHOD.                           "handle_user_command
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    MODULE pbo_100 OUTPUT
    MODULE pbo_100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      w_repid = sy-repid.
      IF custom_container1 IS INITIAL.
    *get the data from charge back table
        PERFORM select_table_chb.
    create a custom container control for our ALV Control
        CREATE OBJECT custom_container1
            EXPORTING
                container_name = cont_on_main
            EXCEPTIONS
                cntl_error = 1
                cntl_system_error = 2
                create_error = 3
                lifetime_error = 4
                lifetime_dynpro_dynpro_link = 5.
        IF sy-subrc NE 0.
    add your handling, for example
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = w_repid
              txt2  = sy-subrc
              txt1  = 'The control could not be created'(510).
        ENDIF.
        CREATE OBJECT grid1
                  EXPORTING i_parent = custom_container1.
    Set a titlebar for the grid control
        wf_layout-grid_title = 'Charge Back'(100).
    allow to select multiple lines
        wf_layout-sel_mode = 'C'.
        wf_layout-stylefname = 'CELLTAB'.
    Exclude all edit functions in this example since we do not need them:
        PERFORM exclude_tb_functions CHANGING lt_exclude.
        CALL METHOD grid1->set_table_for_first_display
                   EXPORTING
                I_BUFFER_ACTIVE               =
                I_CONSISTENCY_CHECK           =
                I_STRUCTURE_NAME              =
                IS_VARIANT                    =
                I_SAVE                        =
                I_DEFAULT                     = 'X'
                     is_layout                     = wf_layout
                IS_PRINT                      =
                IT_SPECIAL_GROUPS             =
                  it_toolbar_excluding          = lt_exclude
                IT_HYPERLINK                  =
                IT_ALV_GRAPHICS               =
              CHANGING
                it_outtab                     = int_crb[]
                it_fieldcatalog               = gt_fieldcatalog.
        CREATE OBJECT event_receiver.
        SET HANDLER event_receiver->handle_user_command FOR grid1.
        SET HANDLER event_receiver->handle_toolbar FOR grid1.
        CALL METHOD grid1->set_toolbar_interactive.
      ENDIF.                               "IF grid1 IS INITIAL
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = grid1.
    ENDMODULE.                    "pbo_100 OUTPUT
    MODULE pai_100 INPUT
    MODULE pai_100 INPUT.
      CASE ok_code.
        WHEN 'EXIT'.
          PERFORM f_clear_fields.
          LEAVE PROGRAM.
        WHEN 'CANCEL'.
          PERFORM f_clear_fields.
          LEAVE TO SCREEN 0.
        WHEN 'BACK'.
          PERFORM f_clear_fields.
          LEAVE TO SCREEN 0.
      ENDCASE.
      CLEAR ok_code.
    ENDMODULE.                    "pai_100 INPUT
    **&      Form  select_table_chb
          text
    FORM select_table_chb.
      IF p_cash = 'X'.
    *Consider the pending documents also.
    *get the documents which are not processed yet,
    *Doctype -> 06 = Charge Back document type.
        SELECT zmpets_shiphdrpernr pa0002vorna
         zmpets_shiphdrmovreason zmpets_chargebkshipdocnum
         zmpets_chargebkcreatedon zmpets_chargebkchargeamount
         zmpets_shipactivversion zmpets_shipactivactivity
    zmpets_shiphdr~vendor
       adr6~smtp_addr
    zmpets_167doc~empperid
                 INTO CORRESPONDING FIELDS OF TABLE int_crb_ver
                 FROM zmpets_chargebk
                 JOIN zmpets_shiphdr
               ON zmpets_chargebkshipdocnum = zmpets_shiphdrshipdocno
                 JOIN zmpets_shipactiv
         ON zmpets_chargebkshipdocnum = zmpets_shipactivpetsdocnumber
                 JOIN pa0002
                 ON zmpets_shiphdrpernr = pa0002pernr
                    JOIN lfa1
                    ON lfa1lifnr = zmpets_shiphdrvendor
                    JOIN adr6
                    ON adr6addrnumber = lfa1adrnr
                 JOIN zmpets_167doc
                 ON zmpets_167docpernr = pa0002pernr
                           WHERE zmpets_shipactiv~doctype = '06'
                        zmpets_shipactiv~activity NE '30'
                      ZMPETS_CHARGEBK~CREATEDON IN s_chdate
                      AND ZMPETS_SHIPHDR~pernr IN s_pernr
                      AND ZMPETS_SHIPHDR~MOVREASON IN s_mvrsn
                      AND ZMPETS_CHARGEBK~SHIPDOCNUM IN s_sin
                           AND zmpets_chargebk~loekz NE 'X'
                           AND zmpets_shipactiv~loekz NE 'X'
                           AND zmpets_shiphdr~loekz NE 'X'.
        IF sy-subrc <> 0.
    *Message is 'No Pending Documents Available.'.
          MESSAGE s196(zm050).
        ELSE.
          LOOP AT int_crb_ver.
    *Not yet processed. set to red
            int_crb_ver-icon = '@0A@'.
            MODIFY int_crb_ver.
          ENDLOOP.
          PERFORM f_filter_data_pending.
        ENDIF.
      ELSE.
    *Get the document details from pa0002,zmpets_shipactiv,ZMPETS_CHARGEBK
    *table.
    *Consider document type as '01'  during the selection.
    *Doctype -> 06 = Charge Back document type.
        SELECT zmpets_shiphdrpernr pa0002vorna zmpets_shiphdr~movreason
        zmpets_chargebkshipdocnum zmpets_chargebkcreatedon
    zmpets_chargebkchargeamount zmpets_shipactivversion
    zmpets_shipactivactivity zmpets_shiphdrvendor
    *adr6~smtp_addr
    zmpets_167doc~empperid
                 INTO CORRESPONDING FIELDS OF TABLE int_crb_ver
                 FROM zmpets_chargebk
                 JOIN zmpets_shiphdr
                 ON zmpets_chargebkshipdocnum = zmpets_shiphdrshipdocno
                 JOIN zmpets_shipactiv
           ON zmpets_chargebkshipdocnum = zmpets_shipactivpetsdocnumber
                 JOIN pa0002
                 ON zmpets_shiphdrpernr = pa0002pernr
                JOIN lfa1
                    ON lfa1lifnr = zmpets_shiphdrvendor
                    JOIN adr6
                    ON adr6addrnumber = lfa1adrnr
                     JOIN zmpets_167doc
                     ON zmpets_167docpernr = pa0002pernr
                           WHERE zmpets_chargebk~createdon IN s_chdate
                           AND zmpets_shiphdr~pernr IN s_pernr
                           AND zmpets_shiphdr~movreason IN s_mvrsn
                           AND zmpets_chargebk~shipdocnum IN s_sin
                          AND zmpets_shipactiv~activity NE '30'
                           AND zmpets_shipactiv~doctype = '06'
                           AND zmpets_chargebk~loekz NE 'X'
                           AND zmpets_shipactiv~loekz NE 'X'
                           AND zmpets_shiphdr~loekz NE 'X'.
        IF sy-subrc <> 0.
    *Message is 'No Charge Back Documents Available.'.
          MESSAGE s201(zm050).
        ELSE.
          PERFORM f_filter_data.
        ENDIF.
      ENDIF.
    ENDFORM.                    "select_table_chb
    *&      Form  UPDATE_RECORDS
          text
    -->  p1        text
    <--  p2        text
    FORM update_records TABLES p_et_index_rows
                                    STRUCTURE lvc_s_row.
      DATA: ls_selected_line LIKE lvc_s_row,
              lf_row_index TYPE lvc_index.
      LOOP AT p_et_index_rows INTO ls_selected_line.
        lf_row_index = ls_selected_line-index.
      ENDLOOP.
    ENDFORM.                    " UPDATE_RECORDS
    **&      Form  fieldcatalog_init
          text
         -->P_GT_FIELDCATALOG[]  text
    FORM fieldcatalog_init  USING lt_fieldcatalog TYPE lvc_t_fcat.
      DATA: ls_fieldcatalog TYPE lvc_s_fcat.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'SEL'.
      ls_fieldcatalog-tabname  = 'INT_CRB'.
      ls_fieldcatalog-datatype = 'C'.
      ls_fieldcatalog-col_pos  = 1.
      ls_fieldcatalog-edit     = 'X'.
      ls_fieldcatalog-reptext  = 'Select for Processing'.
      ls_fieldcatalog-coltext  = 'Select for Processing'.
      ls_fieldcatalog-seltext  = 'Select for Processing'.
      ls_fieldcatalog-tooltip  = 'Select for Processing'.
      ls_fieldcatalog-checkbox = 'X'.
      ls_fieldcatalog-key = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'ICON'.
      ls_fieldcatalog-tabname   = 'INT_CRB'.
      ls_fieldcatalog-datatype  = 'CHAR'.
      ls_fieldcatalog-col_pos    = 2.
      ls_fieldcatalog-intlen     = '4'.
      ls_fieldcatalog-reptext   =  'Status'.
      ls_fieldcatalog-coltext   =  'Status'.
      ls_fieldcatalog-seltext   =  'Status'.
      ls_fieldcatalog-tooltip   =  'Status'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'PERNR'.
      ls_fieldcatalog-tabname   = 'INT_CRB'.
      ls_fieldcatalog-datatype  = 'NUMC'.
      ls_fieldcatalog-col_pos   = 2.
      ls_fieldcatalog-intlen    = '8'.
      ls_fieldcatalog-reptext   =  'Employee Number'.
      ls_fieldcatalog-coltext   =  'Employee Number'.
      ls_fieldcatalog-seltext   =  'Employee Number'.
      ls_fieldcatalog-tooltip   =  'Employee Number'.
      ls_fieldcatalog-key = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname  = 'VORNA'.
      ls_fieldcatalog-tabname    = 'INT_CRB'.
      ls_fieldcatalog-col_pos    =  3 .
      ls_fieldcatalog-datatype   = 'CHAR'.
      ls_fieldcatalog-outputlen      = '20'.
      ls_fieldcatalog-reptext    = 'Employee Name'.
      ls_fieldcatalog-coltext    = 'Employee Name'.
      ls_fieldcatalog-seltext    = 'Employee Name'.
      ls_fieldcatalog-tooltip    = 'Employee Name'.
    ls_fieldcatalog-key      = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname  = 'MOVREASON'.
      ls_fieldcatalog-tabname    = 'INT_CRB'.
      ls_fieldcatalog-col_pos    =  4.
      ls_fieldcatalog-datatype   = 'NUMC'.
      ls_fieldcatalog-outputlen  = '10'.
      ls_fieldcatalog-reptext    = 'Move Reason'.
      ls_fieldcatalog-coltext    = 'Move Reason'.
      ls_fieldcatalog-seltext    = 'Move Reason'.
      ls_fieldcatalog-tooltip    = 'Move Reason'.
    ls_fieldcatalog-key      = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'SHIPDOCNUM'.
      ls_fieldcatalog-tabname   = 'INT_CRB'.
      ls_fieldcatalog-datatype  = 'NUMC'.
      ls_fieldcatalog-outputlen = '10'.
      ls_fieldcatalog-col_pos   =  5.
      ls_fieldcatalog-reptext   = 'Shipping Document Number'.
      ls_fieldcatalog-coltext   = 'Shipping Document Number'.
      ls_fieldcatalog-seltext   = 'Shipping Document Number'.
      ls_fieldcatalog-tooltip   = 'Shipping Document Number'.
    ls_fieldcatalog-key = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'CREATEDON'.
      ls_fieldcatalog-tabname   = 'INT_CRB'.
      ls_fieldcatalog-col_pos   = 6.
      ls_fieldcatalog-datatype  = 'DATS'.
      ls_fieldcatalog-outputlen = '8'.
      ls_fieldcatalog-reptext   = 'Created On'.
      ls_fieldcatalog-coltext   = 'Created On'.
      ls_fieldcatalog-seltext   = 'Created On'.
      ls_fieldcatalog-tooltip   = 'Created On'.
    ls_fieldcatalog-DO_sum      = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'CHARGEAMOUNT'.
      ls_fieldcatalog-tabname   = 'INT_CRB'.
      ls_fieldcatalog-col_pos   = 7.
      ls_fieldcatalog-datatype  = 'CURR'.
      ls_fieldcatalog-outputlen = '13'.
      ls_fieldcatalog-reptext   = 'Charge Back Amount'.
      ls_fieldcatalog-coltext   = 'Charge Back Amount'.
      ls_fieldcatalog-seltext   = 'Charge Back Amount'.
      ls_fieldcatalog-tooltip   = 'Charge Back Amount'.
    ls_fieldcatalog-DO_sum      = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
    ENDFORM.                    "fieldcatalog_init
    *&      Form  f_modify_activity
    Modify the activity to 79 in zmpets_shipaciv table.
    -->  p1        text
    <--  p2        text
    FORM f_modify_activity .
      REFRESH int_crb_mail.
      int_crb_mail[] = int_crb[].
    *All the document number which is to be processed is stored in
    *the internel table 'INT_SIN'.
      LOOP AT int_crb INTO int_crb.
        IF int_crb-sel ='X'.
          MOVE int_crb-shipdocnum TO int_sin.
          APPEND int_sin.
          CLEAR int_sin.
    *Removing the processed documents.
          DELETE int_crb.
        ENDIF.
        CLEAR int_crb.
      ENDLOOP.
    *Get the details from shipactiv table.
      IF int_sin[] IS NOT INITIAL.
        SELECT * FROM zmpets_shipactiv
            INTO TABLE int_shipactiv
              FOR ALL ENTRIES IN int_sin
                    WHERE petsdocnumber = int_sin-shipdocnum.
    *Modify the activity code, version, actual date and last changed date.
        SORT int_shipactiv BY petsdocnumber version DESCENDING.
        CLEAR wf_tabix.
        LOOP AT int_shipactiv.
          wf_tabix = sy-tabix.
          AT NEW petsdocnumber.
            READ TABLE int_shipactiv INDEX wf_tabix.
            int_shipactiv-activity = '030'.
            int_shipactiv-version = int_shipactiv-version + 1.
            int_shipactiv-actdate = sy-datum.
            int_shipactiv-lastchangedby = sy-uname.
            int_shipactiv-lastchangedt = sy-datum.
    *Modify the data base table
            MODIFY zmpets_shipactiv FROM int_shipactiv.
          ENDAT.
          CLEAR int_shipactiv.
          AT LAST.
    *Message is 'Data Processed Successfully.'.
            MESSAGE s203(zm050).
          ENDAT.
        ENDLOOP.
    *-send mail to the vendor and employee that the shipment is cleared for
        LOOP AT int_crb_mail WHERE sel = 'X'.
          PERFORM f_send_mail.
        ENDLOOP.
        REFRESH int_crb_mail.
       CALL SELECTION-SCREEN 1000.
      ELSE.
    *Message is 'No Data Selected for Processing.'.
        MESSAGE s200(zm050).
      ENDIF.
    ENDFORM.                    " f_modify_activity
    *&      Form  f_clear_fields
          text
    -->  p1        text
    <--  p2        text
    FORM f_clear_fields .
      CLEAR int_crb.
      CLEAR int_crb_ver.
      CLEAR int_sin.
      REFRESH int_crb.
      REFRESH int_crb_ver.
      REFRESH int_sin.
      CLEAR int_shipactiv.
      REFRESH int_shipactiv.
      CLEAR wf_flag.
      CLEAR wf_tabix.
    ENDFORM.                    " f_clear_fields
    *&      Form  f_filter_data
          text
    -->  p1        text
    <--  p2        text
    FORM f_filter_data .
    *Take the latest Version Data.
    *take all the activities, including the activity '30'.
    then put the details in internal table 'INT_CRB'.
      SORT int_crb_ver BY shipdocnum version DESCENDING.
      CLEAR wf_tabix.
      CLEAR int_crb.
      REFRESH int_crb.
      LOOP AT int_crb_ver.
        wf_tabix = sy-tabix.
        AT NEW shipdocnum.
          READ TABLE int_crb_ver INDEX wf_tabix.
          MOVE-CORRESPONDING int_crb_ver TO int_crb.
          APPEND int_crb.
          CLEAR int_crb.
        ENDAT.
      ENDLOOP.
      IF int_crb[] IS INITIAL.
    *Message is 'No Records Available.'.
        MESSAGE s202(zm050).
      ELSE.
        CLEAR wf_tabix.
        LOOP AT int_crb.
          wf_tabix = sy-tabix.
          REFRESH lt_celltab.
          ls_celltab-fieldname = 'SEL'.
          IF int_crb-activity = '030'.
            ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
    *status becomes green. ie processed
            int_crb-icon = '@08@'. "Green
          ELSE.
            ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
    *status set to red. ie not yet processed
            int_crb-icon = '@0A@'. "Red
          ENDIF.
          INSERT ls_celltab INTO TABLE lt_celltab.
          INSERT LINES OF lt_celltab INTO TABLE int_crb-celltab.
          MODIFY int_crb INDEX wf_tabix.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " f_filter_data
    *&      Form  f_filter_data
          text
    -->  p1        text
    <--  p2        text
    FORM f_filter_data_pending.
    *Take the latest Version Data.
    *take all the activities, including the activity '30'.
    *then filter it with out the activities '30' and having the lastest
    *version. then put the details in internal table 'INT_CRB'.
      SORT int_crb_ver BY shipdocnum version DESCENDING.
      CLEAR wf_tabix.
      CLEAR int_crb.
      REFRESH int_crb.
      LOOP AT int_crb_ver.
        wf_tabix = sy-tabix.
        AT NEW shipdocnum.
          READ TABLE int_crb_ver INDEX wf_tabix.
          IF int_crb_ver-activity NE '030'.
            MOVE-CORRESPONDING int_crb_ver TO int_crb.
            APPEND int_crb.
            CLEAR int_crb.
          ENDIF.
        ENDAT.
      ENDLOOP.
      IF int_crb[] IS INITIAL.
    *Message is 'No Records Available.'.
        MESSAGE s202(zm050).
      ENDIF.
    ENDFORM.                    " f_filter_data_pending
    *&      Form  EXCLUDE_TB_FUNCTIONS
          text
         <--P_LT_EXCLUDE  text
    FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
      DATA ls_exclude TYPE ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
      APPEND ls_exclude TO pt_exclude.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  f_send_mail
          text
    -->  p1        text
    <--  p2        text
    FORM f_send_mail .
    *store the vendor name, vendor email id , employee name and employee
    *email id in the internal table int_crb
    Creation of the document to be sent
      CLEAR doc_chng.
      REFRESH objpack.
      REFRESH objhead.
      REFRESH  reclist.
      REFRESH objtxt.
    File Name
      doc_chng-obj_name = 'SHIPMENT'.
    Mail Subject
      CONCATENATE 'Shipment Document No.' int_crb_mail-shipdocnum
      'Cleared.'
      INTO doc_chng-obj_descr SEPARATED BY ' '.
    Mail Contents
      objtxt-line = 'Hi,'.
      APPEND objtxt.
      objtxt-line = ' '.
      APPEND objtxt.
      CONCATENATE 'Shipment Document Number ' int_crb_mail-shipdocnum
    ' cleared for move.' INTO objtxt-line SEPARATED BY ' '.
      APPEND objtxt.
      objtxt-line = ' '.
      APPEND objtxt.
      CLEAR  objtxt.
      objtxt-line = 'Regards '.
      APPEND objtxt.
      objtxt-line = ' '.
      APPEND objtxt.
      objtxt-line = 'SAP '.
      APPEND objtxt.
      CLEAR  objtxt.
      APPEND objtxt.
      DESCRIBE TABLE objtxt LINES tab_lines.
      READ TABLE objtxt INDEX tab_lines.
      doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN(
    objtxt ).
    Creation of the entry for the compressed document
      CLEAR objpack-transf_bin.
      objpack-head_start = 1.
      objpack-head_num = 0.
      objpack-body_start = 1.
      objpack-body_num = tab_lines.
      objpack-doc_type = 'RAW'.
      APPEND objpack.
    Completing the recipient list
    target recipent
      CLEAR reclist.
      reclist-receiver = int_crb_mail-empperid. "employee email ID
      "wf_empperid.
      reclist-express  = 'X'.
      reclist-rec_type = 'U'.
      APPEND reclist.
    copy recipents
    CLEAR reclist.
    reclist-receiver = 'anversha.shahul@'."int_crb_mail-smtp_addr
    reclist-express  = 'X'.
    reclist-rec_type = 'U'.
    reclist-copy     = 'X'.
    APPEND reclist.
    Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = doc_chng
        TABLES
          packing_list               = objpack
          object_header              = objhead
       contents_bin               = objbin
          contents_txt               = objtxt
          receivers                  = reclist
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      COMMIT WORK.
      SUBMIT rsconn01
                    WITH mode = 'INT'
                    WITH output = ' '
                      AND RETURN.
    ENDFORM.                    " f_send_mail
    rgds
    anver
    pls mark hlpful answers

  • Sum for Dynamic Fields in a Dynamic Table with Field Symbol

    Hi All,
    I currently have an report which I am looking to update with some totals.  The information is currently output in an ALV which is fed data from a dynamic table defined with a field symbol.  The modification that needs to be applied is a summation per currency code where each of the fields to be summed is a dynamically named field at runtime.  I am now just looking to see if anyone has any recommendations on how to obtain these totals it would be appreciated.  I have no problem doing the leg work in piecing the solution together but am just stuck on which approach I should be investigating here.  I have looked into several options but do to the fact that the totals are for dynamic fields in a dynamic table and it is a field symbol I am having some difficulties thinking of the easiest approach to obtain these totals.
    Below is a simple sample of what the report currently looks like and what we are looking to add.
    ====================================================================================
    As-Is Report:
    DETAILED DATA ALV
    Company Code  |  Plant  |  2006 Total  |  2007 Total  |  2008 Total |  CURRENCY
    0001          |   ABCD  |    1,500     |    1,200     |    1,700    |    USD
    0001          |   BCDE   |    2,300     |    4,100     |    3,600    |    GBP
    0003          |   DBCA  |    3,200     |    1,600     |    6,200    |    USD
    Addition 1:
    TOTALS PER CURRENCY
    Currency                |  2006 Total  |  2007 Total  |  2008 Total |
    USD              |    4,700     |    2,800     |    7,900    |
    GBP                       |    2,300     |    4,100     |    3,600    |
    Addition 2:
    CONVERSIONS TO USD
                                          |  2006 Curr   |  2006 USD    |  2008 Curr   |  2006 USD   |
    USD                       |  4,700 USD   |  4,700 USD   |  7,900 USD  |  7,900 USD  |
    GBP   (1.5GBP/1 USD)    |  2,300 GBP   |  1,150 USD   |  2,300 GBP  |  1,800 USD  |
    ====================================================================================
    Any recommendations will be appreciated.

    Hi,
    We cannot use the key word SUM in the loop at assigning statement.
    The way i see is
    When  you are creating the first dynamic internal table , create one more with  the structure below:
    Currency | 2006 Total | 2007 Total | 2008 Total |
    Then while populating the data into first itab,also move the contents to the second itab using collect statement.

  • How to download alv grid output(with field catalog) into excel file format

    Hi all,
    How to download alv grid output(with field catalogs) into excel file format and same file has to download to application server.
    Please help.
    Regards,
    Satya.

    Hi,
    On list where alv is displayed, select export icon( green color -> ),select spread sheet.
    This will display records in Excel sheet.

Maybe you are looking for

  • Full package name?

    All, I am very new to Javadoc. I would like to know how (if possible) to eliminate the full package name from any descriptions. For example, if I have a method that returns a Hashtable, the Javadoc that gets generated looks like this: public static j

  • Iphone 5c clock not working

    ive tried restoring it, and resetting it completly. its been like this for a couple days now. i have even tried setting the time manully.. it works until i lock my screen, when i go to unlock it its still at the same time as when i locked it. please

  • I dont understand this, Lenovo Outlets vs Lenovo Shop

    I'm here to buy a Thinkpad T430. The issue is, I'm currently located in Pakistan, and the way I would buy a lenovo is through a friend in the UnitedStates. Now I would love to get an idea of how much a new T430 would cost me, because on the same webs

  • Update Failed - AAM will not update my CC apps

    I have tried uninstalling, reinstalling, and just don't know what else to do. I've been trying to update my CC apps. It tells me everything is up to date which is not true at all. After Effects has a new update and it does not see it from the applica

  • How to activate form with full license

    I bought the .99 license for Adobe forms, created a form, tested it and it works. I thne bought the full license, but don't know how to activat emy form with it. When I test the form now, it just says that the form is not available and see my adminis