Internal table structure/ALV Problem

Hello, Im new to ABAP (third day) so careful explination would be greatly appreciated.
So I'm trying to display two tables together that I've joined into an ALV.  Im creating an internal table to hold the information that I want to display from the join I created. 
When I call my alv set_table_for_first_display I need to specify i_structure_name.  Right now im using the name of my internal table, but I dont know if im doing this right.  When I run my program i get an error NO_FIELDCATALOG_AVAILABLE.  After searching many other posts i think its because my internal table doesnt have a structure, but im not sure.
Here is my code, thanks in advance!:
CLASS application DEFINITION.
  PUBLIC SECTION.
    METHODS: constructor,
       read_data IMPORTING l_DAUAT TYPE AFPO-DAUAT,
       fill_list.
  PRIVATE SECTION.
    DATA: BEGIN OF tbljoin,
            AFPO_AUFNR TYPE AFPO-AUFNR,
            AFPO_DAUAT TYPE AFPO-DAUAT,
            AFPO_DGLTP TYPE AFPO-DGLTP,
            AFPO_DGLTS TYPE AFPO-DGLTS,
            AFPO_OBJNP TYPE AFPO-OBJNP,
            AFPO_XLOEK TYPE AFPO-XLOEK,
            AFKO_GLTRP TYPE AFKO-GLTRP,
    END OF tbljoin,
   afpo_tab TYPE TABLE OF afpo,
    join_tab LIKE STANDARD TABLE OF TBLJOIN,
    container TYPE REF TO cl_gui_custom_container,
    alv_list TYPE REF TO cl_gui_alv_grid.
ENDCLASS.
*Class Implementations
CLASS application IMPLEMENTATION.
  METHOD read_data.
    Select: POAUFNR PODAUAT PODGLTP PODGLTS POOBJNP POXLOEK
KO~GLTRP
    FROM afpo as po INNER JOIN AFKO as KO
      on POAUFNR = KOAUFNR
    INTO TABLE join_tab
    where dauat = l_dauat.
  ENDMETHOD.
  METHOD constructor.
    CREATE OBJECT container
        EXPORTING container_name = 'LIST_AREA'.
    CREATE OBJECT alv_list
        EXPORTING i_parent = container.
      CALL METHOD alv_list->set_table_for_first_display
        EXPORTING i_structure_name = 'JOINTAB'
        CHANGING it_outtab = join_tab.
  ENDMETHOD.
  METHOD fill_list.
    CALL METHOD alv_list->refresh_table_display.
  ENDMETHOD.
ENDCLASS.
DATA: object_ref TYPE REF TO application.
*Screens Interfaces
TABLES: AFPO, AFKO.
*Processing Blocks called by the Runtime Environment             *
*Event Block START-OF-SELECTION
START-OF-SELECTION.
  CREATE OBJECT object_ref.
  CALL SCREEN 100.
*Dialog Module PBO
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN_100'.
  CALL METHOD object_ref->fill_list.
ENDMODULE.
*Dialog Module PAI
MODULE user_command_0100 INPUT.
  IF sy-ucomm = 'BACK' OR
     sy-ucomm = 'EXIT' OR
     sy-ucomm = 'CANCEL'.
    LEAVE PROGRAM.
  ELSE.
    CALL METHOD object_ref->read_data
        EXPORTING l_dauat = afpo-dauat.
  ENDIF.
ENDMODULE.

Hi Nathan,
Fieldcatalog has important role in ALV .U missed that one .Go through these steps.
<b>1</b>.
Define ur Fieldcatalog table like this .
DATA:
  i_field   TYPE lvc_t_fcat,
  w_field   TYPE lvc_s_fcat.
<b>2</b>.
Build like this
FORM build_fieldcatalog_tab .
  DATA :pos TYPE i VALUE 1.
  CLEAR: w_field,i_field[],pos.
  w_field-col_pos   = pos  + 1.
  w_field-fieldname = 'MATNR' .
  w_field-tabname   = 'I_MARC' .
  w_field-scrtext_m = 'Material' .
  APPEND w_field TO i_field.
  CLEAR w_field.
  w_field-col_pos   = pos  + 1.
  w_field-fieldname = 'WERKS' .
  w_field-tabname   = 'I_MARC' .
  w_field-scrtext_m = 'Plant' .
  APPEND w_field TO i_field.
  CLEAR w_field.
ENDFORM.
<b>3</b>.
Pass through this method
<b>  CALL METHOD alv_grid->set_table_for_first_display</b>
    EXPORTING
     I_BUFFER_ACTIVE               =
     I_BYPASSING_BUFFER            =
     I_CONSISTENCY_CHECK           =
     i_structure_name              = 'MARA'
     IS_VARIANT                    =
     I_SAVE                        =
     I_DEFAULT                     = 'X'
       is_layout                     = w_layout
     IS_PRINT                      = w_print
     IT_SPECIAL_GROUPS             =
     IT_TOOLBAR_EXCLUDING          =
     IT_HYPERLINK                  =
     IT_ALV_GRAPHICS               =
     IT_EXCEPT_QINFO               =
    CHANGING
<b>     it_outtab                     = i_marc</b>
<b>     it_fieldcatalog               = i_field</b>
     IT_SORT                       =
     IT_FILTER                     =
  EXCEPTIONS
    invalid_parameter_combination = 1
    program_error                 = 2
    too_many_lines                = 3
    OTHERS                        = 4
<b>4</b>.
You should remove
<b>i_structure_name = 'JOINTAB'</b>
y should use this when u pass single table data display.
I hope that it helps u .
<b>Thanks,
Venkat.O</b>

Similar Messages

  • Can we get the data from two internal tables in ALV.

    hi friends i would like to display the data using two internal tables using alv grid.please guide me.

    Hi,
    ALV would be having a specific layout say :
    MATNR
    MAKTX
    QTY
    Now, if you have two internal tables, then do they have a different structure. If they have different structures, then what kind of ALV layout you expect. The ALV output should be as per the structure of 1st or 2nd internal table.
    If both internal table have same layout, then populate the data from 2nd internal table into 1st internal table and pass the 1st internal table ( it will have data of both internal tables) to ALV.
    Best regards,
    Prashant

  • 'ALSM_EXCEL_TO_INTERNAL_TABLE' internal table to ALV

    Hi,
    I have a problem regarding 'ALSM_EXCEL_TO_INTERNAL_TABLE' internal table to ALV.
    I have this code.
    DATA:
          t_itab like ALSMEX_TABLINE occurs 0 with header line,
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    filename = p_fname
    i_begin_col = 1
    i_begin_row = 1
    i_end_col = 4
    i_end_row = 6
    TABLES
    intern = t_itab
    EXCEPTIONS
    inconsistent_parameters = 1
    upload_ole = 2
    OTHERS = 3.
    IF sy-subrc = 0.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_STRUCTURE_NAME   = 'ALSMEX_TABLINE'
           TABLES
                T_OUTTAB           = t_itab.
    I got an output of
    ROW  COLUMN   c
    1           1             TestData
    1           2             TestData
    2           1             TestData
    2           2             TestData

    Hi Christian Gajo ,
    Check the below code.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = P_FILE
        i_begin_col                   = '1'
        i_begin_row                   = '1'
        i_end_col                     = '5'
        i_end_row                     = '10'
      tables
        intern                        =  IEXCEL
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3.
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-SGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    END-OF-SELECTION.
    SORT IEXCEL BY ROW COL.
    LOOP AT IEXCEL.
        CASE IEXCEL-COL.
           WHEN 1.
             WA_CUST_GLACC-PARVW = IEXCEL-VALUE.
           WHEN 2.
             WA_CUST_GLACC-KUNNR = IEXCEL-VALUE.
           WHEN 3.
             WA_CUST_GLACC-MATNR = IEXCEL-VALUE.
           WHEN 4.
             WA_CUST_GLACC-SAKNR = IEXCEL-VALUE.
           WHEN 5.
             WA_CUST_GLACC-TXT50 = IEXCEL-VALUE.
         ENDCASE.
    AT END OF ROW.
            WA_CUST_GLACC-MANDT = SY-MANDT.
         APPEND WA_CUST_GLACC TO GT_CUST_GLACC.
         CLEAR WA_CUST_GLACC.
    ENDAT.
    CLEAR IEXCEL.
    ENDLOOP.
    Edited by: mukesh kumar on Nov 7, 2008 7:53 AM

  • Change internal table structure dynamically

    Dear Experts , I have a requirement to add an attribute to already declared internal table which is declared in standard SAP code, is it possible to change internal table structure dynamically.
    my internal table is of type merel_t_grid2 which is standard table type in SAP , now I want to add an attribute of type  LVC_T_STYL in my internal table so that I can modify the cell property of ALV grid.
    I cant append LVC_T_STYL in standard structure because enhancement category of merel_t_grid2 is of type char and not deep
    my internal table contains data to be displayed in ALV.
    please help

    Dear Experts , I have a requirement to add an attribute to already declared internal table which is declared in standard SAP code, is it possible to change internal table structure dynamically.
    my internal table is of type merel_t_grid2 which is standard table type in SAP , now I want to add an attribute of type  LVC_T_STYL in my internal table so that I can modify the cell property of ALV grid.
    I cant append LVC_T_STYL in standard structure because enhancement category of merel_t_grid2 is of type char and not deep
    my internal table contains data to be displayed in ALV.
    please help

  • Determining internal table structure dynamically

    Hi,
    I have a number of internal tables in my program which I declare using types. As an example:
    TYPES: begin of ty_hierarchy,
                   control_id(6)   type c,
                   node_id(10)     type c,
                   node_name       type bezei40,
                   material        type matnr,
                   node_level      type prodh_stuf,
                   node_parent(10) type c,
                end of ty_hierarchy.
    DATA: it_hierarchy type ty_hierarchy occurs 0.
    Further down my program I need to determine the structure of internal table IT_HIERARCHY dynamically. Because I have a number of internal tables, I need to determine which internal table is being processed. Therefore it's important that I know the structure of the table that I'm currently processing.
    I am aware of CL_ABAP* classes and functions like GET_COMPONENT_LIST. However because I have declared my tables using the TYPE statement the method/function cannot read my table structure correctly. If I changed my declaration to be as below, the method/function work! However I don't want to do this as I use field symbols to reference my internal tables and need to use the TYPE statement.
    DATA: begin of ty_hierarchy,
                   control_id(6)   type c,
                   node_id(10)     type c,
                   node_name       type bezei40,
                   material        type matnr,
                   node_level      type prodh_stuf,
                   node_parent(10) type c,
                end of ty_hierarchy.
    DATA: begin of it_hierarchy occurs 0.
                 include structure ty_hierarchy
    DATA: end of it_hierarchy.
    Does anyone know on how I can determine my  internal table structure dynamically but still keeping my internal table declarations using TYPE statement?
    Any help would be greatly appreciated with reward points .....
    Thanks
    Liam

    Hello Liam
    Both the ABAP-OO as well as the FM-based approach described by Eswar work well with your way of defining the itabs. I described three different ways how to get the structure of your itab dynamically:
    - directly using the itab
    - using a field symbol
    - using a data reference
    REPORT  zus_sdn_dynamic_itabs.
    TYPE-POOLS: abap.
    TYPES: BEGIN OF ty_hierarchy,
    control_id(6) TYPE c,
    node_id(10) TYPE c,
    node_name TYPE bezei40,
    material TYPE matnr,
    node_level TYPE prodh_stuf,
    node_parent(10) TYPE c,
    END OF ty_hierarchy.
    DATA:
      gs_hierarchy    TYPE ty_hierarchy,
      it_hierarchy    TYPE ty_hierarchy OCCURS 0.
    DATA:
      gt_comp         TYPE abap_compdescr_tab,
      gs_comp_a       LIKE LINE OF gt_comp,
      gd_type         TYPE abap_typekind,
      gs_comp    TYPE rstrucinfo,
      it_comp TYPE TABLE OF rstrucinfo.
    DATA:
      go_struct    TYPE REF TO cl_abap_structdescr,
      go_table     TYPE REF TO cl_abap_tabledescr,
      gdo_data     TYPE REF TO data.
    FIELD-SYMBOLS:
      <gt_itab>    TYPE table.
    START-OF-SELECTION.
      GET REFERENCE OF it_hierarchy INTO gdo_data.
      ASSIGN gdo_data->* TO <gt_itab>.
    * (1) Describe directly by using the itab
    *  go_table  ?= cl_abap_structdescr=>describe_by_data( it_hierarchy ).
    * (2) Describe indirectly by using field symbol
    *  go_table  ?= cl_abap_structdescr=>describe_by_data( <gt_itab> ).
    * (3) Describe by data reference to itab
      go_table  ?= cl_abap_structdescr=>describe_by_data_ref( gdo_data ).
      go_struct ?= go_table->get_table_line_type( ).
      WRITE: / 'ABAP-OO Version:'.
      gt_comp = go_struct->components.
      LOOP AT gt_comp INTO gs_comp_a.
        WRITE: / gs_comp_a-name,
                 gs_comp_a-length,
                 gs_comp_a-type_kind,
                 gs_comp_a-decimals.
      ENDLOOP.
      SKIP 2.
      CALL FUNCTION 'GET_COMPONENT_LIST'
        EXPORTING
          program    = sy-repid
          fieldname  = 'GS_HIERARCHY'
        TABLES
          components = it_comp.
      WRITE: / 'Function Module Version:'.
      LOOP AT it_comp INTO gs_comp.
        WRITE: / gs_comp-compname,
                 gs_comp-level,
                 gs_comp-leng,
                 gs_comp-type,
                 gs_comp-olen,
                 gs_comp-decs.
      ENDLOOP.
    END-OF-SELECTION.
    Regards
      Uwe

  • Dynamic internal table structure

    pl. give the solution to create dynamically internal table structure with respective of different table.

    Hi and welcome to the SDN,
    this topic is more related to abap, but anyway:
    data: l_tabname(30) type c value 'MARA',
          ref_data type ref to data.
    field-symbols: <fs_tab> type table.
    create data ref_data type standard table of (l_tabname).
    assign ref_data->* to <fs_tab>.
    Now <fs_tab> is a internal table with structure of table mara.
    Hope this helps!
    regards
    Siggi

  • Field catalog for internal table in ALV

    In my program the internal table consists many fields from various tables and structure doesn't belong to a single data table.
    In order to get output in ALV grid following FM has been used
    REUSE_ALV_GRID_DISPLAY
    for field catalog the fields are defined specifically.
      l_fieldcat-fieldname  = 'VBELN'.
      l_fieldcat-outputlen  = 10.
      l_fieldcat-seltext_l  = 'Billing doc'.
      l_fieldcat-no_zero = 'X'.
      l_fieldcat-hotspot = 'X'.
      append l_fieldcat to p_fieldtab.
    ..............and so on for all the fields.
    Just wanted to know is there any other method to display all the fields of this internal table automatically so each field is not specified specifically.
    anya

    Hi
    Try this instead:
    *& Form  create_fieldcatalog
    * Create a field catalogue from any internal table
    *      -->PT_TABLE     Internal table
    *      -->PT_FIELDCAT  Field Catalogue
    FORM  create_fieldcatalog
           USING     pt_table     TYPE ANY TABLE
           CHANGING  pt_fieldcat  TYPE lvc_t_fcat.
      DATA:
        lr_tabdescr TYPE REF TO cl_abap_structdescr
      , lr_data     TYPE REF TO data
      , lt_dfies    TYPE ddfields
      , ls_dfies    TYPE dfies
      , ls_fieldcat TYPE lvc_s_fcat
      CLEAR pt_fieldcat.
      CREATE DATA lr_data LIKE LINE OF pt_table.
      lr_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ).
      lt_dfies = cl_salv_data_descr=>read_structdescr( lr_tabdescr ).
      LOOP AT lt_dfies
      INTO    ls_dfies.
        CLEAR ls_fieldcat.
        MOVE-CORRESPONDING ls_dfies TO ls_fieldcat.
        APPEND ls_fieldcat TO pt_fieldcat.
      ENDLOOP.
    ENDFORM.                    "create_fieldcatalog

  • How to display Internal Table in ALV?

    Hi all,
    can anyone teach me the simple way to insert my internal table records to ALV by providing me the sample codes from the start of declaration to the end? Below is how i define my internal table:
    DATA: DOM_NAME(40) TYPE C,
           P_TABLE(40) TYPE C.
    TYPES: BEGIN OF ITAB6,
           FIELDNAME TYPE DD03M-FIELDNAME,
    END OF ITAB6.
    P_TABLE = 'ABC'
    DOM_NAME = 'TRY'
    DATA: ITAB6 TYPE STANDARD TABLE OF ITAB6 WITH HEADER LINE.
        SELECT FIELDNAME FROM DD03M INTO TABLE ITAB6 WHERE TABNAME = P_TABLE AND
        DOMNAME = DOM_NAME.
    Hope that anyone can just start the part of alv from the continuation of my codes. cus i went through others thread but it seem to be confusing me. thx! hope to get replies asap.

    hai
    copy this program and past in to the wk bench....(se38)
    thn execute  it...
    REPORT ZALVTEST2_RNJ .
    *ABAP LIST VIEWER
    This is a basic ALV with the followings:-
    - Page Heading
    - Page No
    - Sub-Total
    - Grand Total
    *REPORT ZALV.
    TYPE-POOLS: SLIS.
    DATA: G_REPID LIKE SY-REPID,
    GS_PRINT            TYPE SLIS_PRINT_ALV,
    GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
    GT_EVENTS           TYPE SLIS_T_EVENT,
    GT_SORT             TYPE SLIS_T_SORTINFO_ALV,
    GS_LAYOUT           TYPE SLIS_LAYOUT_ALV,
    GT_FIELDCAT         TYPE SLIS_T_FIELDCAT_ALV,
    FIELDCAT_LN LIKE LINE OF GT_FIELDCAT,
    COL_POS TYPE I.
    DATA: BEGIN OF ITAB,
      FIELD1(5) TYPE C,
      FIELD2(5) TYPE C,
      FIELD3(5) TYPE P DECIMALS 2,
    END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 0.
      INCLUDE STRUCTURE ITAB.
    DATA: END OF ITAB1.
    DATA: BEGIN OF ITAB_FIELDCAT OCCURS 0.
      INCLUDE STRUCTURE ITAB.
    DATA: END OF ITAB_FIELDCAT.
    Print Parameters
    PARAMETERS:
                P_PRINT  AS CHECKBOX DEFAULT ' ', "PRINT IMMEDIATE
                P_NOSINF AS CHECKBOX DEFAULT 'X', "NO SELECTION INFO
                P_NOCOVE AS CHECKBOX DEFAULT ' ', "NO COVER PAGE
                P_NONEWP AS CHECKBOX DEFAULT ' ', "NO NEW PAGE
                P_NOLINF AS CHECKBOX DEFAULT 'X', "NO PRINT LIST INFO
                P_RESERV TYPE I.                  "NO OF FOOTER LINE
    INITIALIZATION.
    G_REPID = SY-REPID.
    PERFORM PRINT_BUILD    USING GS_PRINT.      "Print PARAMETERS
    START-OF-SELECTION.
    TEST DATA
    MOVE 'TEST1' TO ITAB1-FIELD1.
    MOVE 'TEST1' TO ITAB1-FIELD2.
    MOVE '10.00' TO ITAB1-FIELD3.
    APPEND ITAB1.
    MOVE 'TEST2' TO ITAB1-FIELD1.
    MOVE 'TEST2' TO ITAB1-FIELD2.
    MOVE '20.00' TO ITAB1-FIELD3.
    APPEND ITAB1.
    DO 50 TIMES.
      APPEND ITAB1.
    ENDDO.
    END-OF-SELECTION.
    PERFORM BUILD.
    PERFORM EVENTTAB_BUILD CHANGING GT_EVENTS.
    PERFORM COMMENT_BUILD  CHANGING GT_LIST_TOP_OF_PAGE.
    PERFORM CALL_ALV.
    FORM BUILD.
    DATA FIELD CATALOG
    Explain Field Description to ALV
    DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME = 'FIELD1'.
    FIELDCAT_LN-TABNAME   = 'ITAB1'.
    *FIELDCAT_LN-NO_OUT    = 'X'.  "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
    FIELDCAT_LN-KEY       = ' '.   "SUBTOTAL KEY
    FIELDCAT_LN-NO_OUT    = ' '.
    FIELDCAT_LN-SELTEXT_L = 'HEAD1'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME = 'FIELD2'.
    FIELDCAT_LN-TABNAME   = 'ITAB1'.
    FIELDCAT_LN-NO_OUT    = 'X'.
    FIELDCAT_LN-SELTEXT_L = 'HEAD2'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME     = 'FIELD3'.
    FIELDCAT_LN-TABNAME       = 'ITAB1'.
    FIELDCAT_LN-REF_FIELDNAME = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
    FIELDCAT_LN-REF_TABNAME   = 'MSEG'.  "<- REF TABLE IN THE DICTIONNARY
    FIELDCAT_LN-NO_OUT        = ' '.
    FIELDCAT_LN-DO_SUM        = 'X'.   "SUM UPON DISPLAY
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    DATA SORTING AND SUBTOTAL
    DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
    CLEAR GS_SORT.
    GS_SORT-FIELDNAME = 'FIELD1'.
    GS_SORT-SPOS      = 1.
    GS_SORT-UP        = 'X'.
    GS_SORT-SUBTOT    = 'X'.
    APPEND GS_SORT TO GT_SORT.
    CLEAR GS_SORT.
    GS_SORT-FIELDNAME = 'FIELD2'.
    GS_SORT-SPOS      = 2.
    GS_SORT-UP        = 'X'.
    *GS_SORT-SUBTOT    = 'X'.
    APPEND GS_SORT TO GT_SORT.
    ENDFORM.
    FORM CALL_ALV.
    ABAP List Viewer
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = G_REPID
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    I_STRUCTURE_NAME = 'ITAB1'
    IS_LAYOUT =  GS_LAYOUT
    IT_FIELDCAT = GT_FIELDCAT[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
      IT_SORT = GT_SORT[]
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
      IT_EVENTS = GT_EVENTS[]
    IT_EVENT_EXIT =
      IS_PRINT = GS_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 = ITAB1
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2.
    ENDFORM.
    HEADER FORM
    FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.
    CONSTANTS:
    GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
    *GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = LT_EVENTS.
      READ TABLE 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 LT_EVENTS.
      ENDIF.
    define END_OF_PAGE event
    READ TABLE LT_EVENTS WITH KEY NAME =  SLIS_EV_END_OF_PAGE
                             INTO LS_EVENT.
    IF SY-SUBRC = 0.
      MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
      APPEND LS_EVENT TO LT_EVENTS.
    ENDIF.
    ENDFORM.
    FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
      DATA: GS_LINE TYPE SLIS_LISTHEADER.
      CLEAR GS_LINE.
      GS_LINE-TYP  = 'H'.
      GS_LINE-INFO = 'HEADER 1'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
      CLEAR GS_LINE.
      GS_LINE-TYP  = 'S'.
      GS_LINE-KEY  = 'STATUS 1'.
      GS_LINE-INFO = 'INFO 1'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
      GS_LINE-KEY  = 'STATUS 2'.
      GS_LINE-INFO = 'INFO 2'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
    CLEAR GS_LINE.
    GS_LINE-TYP  = 'A'.
    GS_LINE-INFO = 'ACTION'.
    APPEND GS_LINE TO  GT_TOP_OF_PAGE.
    ENDFORM.
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
      WRITE: SY-DATUM, 'Page No', SY-PAGNO LEFT-JUSTIFIED.
    ENDFORM.
    FORM END_OF_PAGE.
      WRITE at (sy-linsz) sy-pagno CENTERED.
    ENDFORM.
    PRINT SETTINGS
    FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.
      LS_PRINT-PRINT              = P_PRINT.  "PRINT IMMEDIATE
      LS_PRINT-NO_PRINT_SELINFOS  = P_NOSINF. "NO SELECTION INFO
      LS_PRINT-NO_COVERPAGE       = P_NOCOVE. "NO COVER PAGE
      LS_PRINT-NO_NEW_PAGE        = P_NONEWP.
      LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF. "NO PRINT LIST INFO
      LS_PRINT-RESERVE_LINES      = P_RESERV.
    ENDFORM.
    *END OF ZALV PROGRAM
    regard
    nawa

  • Subtotals in dynamic internal table using alv grid

    hi experts i have created one dynamic table.  The requirement is to display the subtotals in the output using reuse_alv_grid.
    Dynamic itab (field-symbols) and ALV event BEFORE_LINE_OUTPUT
    the above is the thread related and could any one please provide the sample code for this task.
    can any one post the solution for that.
    rewards points will be awarded.
    khazi

    * ASSINING STRUCTURE FOR FILD CATLOGS
    DATA: DYN_TABLE    TYPE REF TO DATA,
          DYN_LINE     TYPE REF TO DATA,
          LS_FIELDCAT TYPE LVC_S_FCAT,
          LT_FIELDCAT TYPE LVC_T_FCAT.
      LOOP AT LT_DMTAB INTO LS_DMTAB.
        CLEAR LS_FIELDCAT.
        LS_FIELDCAT-FIELDNAME = LS_DMTAB-SDATE .
        LS_FIELDCAT-DATATYPE  = 'DEC'.
        LS_FIELDCAT-INTTYPE   = 'P'.
        LS_FIELDCAT-INTLEN    = '16' .
        LS_FIELDCAT-DECIMALS  = '03'.
        LS_FIELDCAT-JUST      = 'C'.
        APPEND LS_FIELDCAT TO LT_FIELDCAT.
      ENDLOOP.
    *& For grouping the table rows for Under Line
      LS_FIELDCAT-FIELDNAME = 'ULFIELD' .
      LS_FIELDCAT-DATATYPE  = 'INT'.
      LS_FIELDCAT-INTTYPE   = 'P'.
      LS_FIELDCAT-INTLEN    = '2' .
      LS_FIELDCAT-DECIMALS  = ''.
      APPEND LS_FIELDCAT TO LT_FIELDCAT.
      "* Create dynamic internal table and assign to Field-Symbol
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = LT_FIELDCAT
        IMPORTING
          EP_TABLE        = DYN_TABLE.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      ASSIGN DYN_TABLE->* TO <LT_AREA_F>.
      "* Create dynamic work area and assign to Field Symbol
      CREATE DATA DYN_LINE LIKE LINE OF <LT_AREA_F>.
      ASSIGN DYN_LINE->* TO <LS_AREA_F>.
    You check in Field cat level you will get  Check Sub total field will exist
    Thanks and regards
    Jogu

  • Passing dynamic internal table into ALV

    I have made one ALV report where i had created one button 'GENERATE'.  ON CLICKING THIS BUTTON the data in the ALV report is downloaded to excel file.
    i have used this:-
    CALL METHOD cl_gui_frontend_services=>file_save_dialog
        EXPORTING
          window_title         = l_title
          default_extension    = 'XLS'
          initial_directory    = 'C:\'
        CHANGING
          filename             = filename
          path                 = path
          fullpath             = fullpath
          user_action          = user_action
        EXCEPTIONS
          cntl_error           = 1
          error_no_gui         = 2
          not_supported_by_gui = 3
          OTHERS               = 4.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
    Check which button is pressed
      IF user_action <> cl_gui_frontend_services=>action_ok.
        EXIT.
      ENDIF.
    Download error data collected from the internal table
      CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          filename                = fullpath
          filetype                = 'ASC'
          write_field_separator   = '#'
         codepage                = '4103'
         write_bom               = c_true
        CHANGING
          data_tab                = gi_final
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          not_supported_by_gui    = 22
          error_no_gui            = 23
          OTHERS                  = 24.
    If selection is successful
      IF sy-subrc EQ 0.
        MESSAGE s004 . " File  created successfully
      ELSE.
        MESSAGE i005 . " File is not created successfully
      ENDIF.
    In the table i have passed the internal table . this is working fine.
    <b>But,
    The problem is if i want to display the data in diferent layout based on selection screen criteria the data downloaded are same as default layout.
    how to pass a dynamic internal table in the
    CALL METHOD cl_gui_frontend_services=>gui_download</b>

    Hi    ,
    here is the Program for  Download  
    REPORT yrs_download_transport_request.
    PARAMETERS:
      p_reqest TYPE trkorr OBLIGATORY,
      p_folder(255) TYPE c LOWER CASE, p_sepr OBLIGATORY.
    DATA:
      folder TYPE string,
      retval LIKE TABLE OF ddshretval WITH HEADER LINE,
      fldvalue LIKE help_info-fldvalue,
      transdir TYPE text255,
      filename(255),
      trfile(20) TYPE c,
      datatab TYPE TABLE OF text8192 WITH HEADER LINE,
      len TYPE i,
      flen TYPE i.
    TYPE-POOLS: sabc, stms, trwbo.
    INITIALIZATION.
      CONCATENATE sy-sysid 'K*' INTO p_reqest.
      IF sy-opsys = 'Windows NT'.
        p_sepr = ''.
      ELSE.
        p_sepr = '/'.
      ENDIF.
    *  CALL FUNCTION 'WSAF_BUILD_SEPARATOR'
    *       IMPORTING
    *            separator                  = p_sepr
    *       EXCEPTIONS
    *            separator_not_maintained   = 1
    *            wrong_call                 = 2
    *            wsaf_config_not_maintained = 3
    *            OTHERS                     = 4.
    *  IF sy-subrc NE 0.
    *    MESSAGE s001(00)
    *      WITH
    *      'Unable to find out the separator symbol for the system.'(011).
    *  ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_reqest.
      DATA:
        tt_system TYPE TABLE OF tmscsys WITH HEADER LINE,
        es_selected_request TYPE trwbo_request_header,
        es_selected_task TYPE trwbo_request_header,
        iv_organizer_type TYPE trwbo_calling_organizer,
        is_selection TYPE trwbo_selection.
      iv_organizer_type = 'W'. is_selection-reqstatus = 'R'.
      CALL FUNCTION 'TR_PRESENT_REQUESTS_SEL_POPUP'
        EXPORTING
          iv_organizer_type   = iv_organizer_type
          is_selection        = is_selection
        IMPORTING
          es_selected_request = es_selected_request
          es_selected_task    = es_selected_task.
      p_reqest = es_selected_request-trkorr.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.
      DATA: title TYPE string.
      title = 'Select target folder'(005).
      CALL METHOD cl_gui_frontend_services=>directory_browse
        EXPORTING
          window_title    = title
        CHANGING
          selected_folder = folder
        EXCEPTIONS
          cntl_error      = 1
          error_no_gui    = 2
          OTHERS          = 3.
      CALL FUNCTION 'CONTROL_FLUSH'
        EXCEPTIONS
          cntl_system_error = 1
          cntl_error        = 2
          OTHERS            = 3.
      p_folder = folder.
    AT SELECTION-SCREEN ON p_reqest.
      DATA: request_info TYPE stms_wbo_request,
            request_infos TYPE stms_wbo_requests.
      REFRESH request_infos.
      CALL FUNCTION 'TMS_MGR_READ_TRANSPORT_REQUEST'
        EXPORTING
          iv_request                 = p_reqest
          iv_header_only             = 'X'
        IMPORTING
          et_request_infos           = request_infos
        EXCEPTIONS
          read_config_failed         = 1
          table_of_requests_is_empty = 2
          system_not_available       = 3
          OTHERS                     = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CLEAR request_info.
      READ TABLE request_infos INTO request_info INDEX 1.
      IF sy-subrc NE 0
      OR request_info-e070-trkorr IS INITIAL.
        MESSAGE e398(00) WITH 'Request'(006) p_reqest 'not found'(007).
      ELSEIF request_info-e070-trstatus NE 'R'.
        MESSAGE e398(00)
        WITH 'You must release request'(008)
             request_info-e070-trkorr
             'before downloading'(009).
      ENDIF.
    START-OF-SELECTION.
      folder = p_folder.
      CONCATENATE p_reqest+3(7) '.' p_reqest(3) INTO trfile.
      CALL FUNCTION 'RSPO_R_SAPGPARAM'
        EXPORTING
          name   = 'DIR_TRANS'
        IMPORTING
          value  = transdir
        EXCEPTIONS
          error  = 0
          OTHERS = 0.
      PERFORM copy_file USING 'cofiles' trfile.
      trfile(1) = 'R'.
      PERFORM copy_file USING 'data' trfile.
      trfile(1) = 'D'.
      PERFORM copy_file USING 'data' trfile.
    * FORM copy_file *
    * --> SUBDIR * * --> FNAME *
    FORM copy_file USING subdir fname.
      DATA:
        auth_filename TYPE authb-filename,
        gui_filename TYPE string.
      CONCATENATE transdir subdir fname
        INTO filename
        SEPARATED BY p_sepr.
      REFRESH datatab.
      CLEAR flen.
      auth_filename = filename.
      CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
        EXPORTING
          activity         = sabc_act_read
          filename         = auth_filename
        EXCEPTIONS
          no_authority     = 1
          activity_unknown = 2
          OTHERS           = 3.
      IF sy-subrc <> 0.
        FORMAT COLOR COL_NEGATIVE.
        WRITE: / 'Read access denied. File'(001),
                  filename.
        FORMAT COLOR OFF. EXIT.
      ENDIF.
      OPEN DATASET filename FOR INPUT IN BINARY MODE.
      IF sy-subrc NE 0.
        FORMAT COLOR COL_TOTAL.
        WRITE: / 'File open error'(010), filename.
        FORMAT COLOR OFF. EXIT.
      ENDIF.
      DO.
        CLEAR len.
        READ DATASET filename INTO datatab LENGTH len.
        flen = flen + len.
        IF len > 0. APPEND datatab. ENDIF.
        IF sy-subrc NE 0.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET filename.
      CONCATENATE p_folder '' fname INTO gui_filename.
      CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          bin_filesize            = flen
          filename                = gui_filename
          filetype                = 'BIN'
        CHANGING
          data_tab                = datatab[]
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          OTHERS                  = 24.
      IF sy-subrc = 0.
        WRITE: / 'File'(002), filename, 'downloaded. Length'(003), flen.
      ELSE.
        FORMAT COLOR COL_NEGATIVE.
        WRITE: / 'File download error. Filename:'(004), filename.
        FORMAT COLOR OFF.
      ENDIF.
    ENDFORM. "copy_file
    Reward  points if it is usefull....
    Girish

  • Rows missing in ALV output compared to internal table (was "ALV issue")

    Hi guys,
    I am getting an ALV for 70 rows whereas the internal table I am passing has 120 rows.
    Any idea why I could be facing this issue.Has anyone ever faced something similar?
    Thanks,
    Chirantan
    Moderator message: please use more descriptive subject lines for your posts.
    Edited by: Thomas Zloch on May 9, 2011 9:51 AM

    BY default, maximum number of coulmns displayed in ALV is 90.
    You can increase it by setting the parameter NO_OUT as initial for the remaining fields in their field catalog.
    Please check below sample code:
    "Build Field catalog using structure of QALS
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = sy-repid
          i_structure_name       = 'QALS'
        CHANGING
          ct_fieldcat            = g_t_fcat   " Internal table contains more than 90 fields
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
    "Only first 90 fields will be displayed in output. So, set NO_OUT as initial for remaining fields.
    LOOP AT g_t_fcat INTO g_r_fcat WHERE no_out = 'X'.
      g_r_fcat-no_out = ''.   " Set NO_OUT as initial
      MODIFY g_t_fcat FROM g_r_fcat INDEX sy-tabix TRANSPORTING no_out.
    ENDLOOP.

  • Two Internal Tables for ALV Grid

    Hi Gurus,
    I have a little problem here. I have a report to display cost of production. The rows is about 50 displaying amount in dollars (currency fields). I have this in ALV Grid. But my problem is that the last 4 lines of the report are not currency fields like the others, they are quantity fields.
    How can i go about to display this last 4 lines in this ALV Grid. They are from different internal tables off course because of the data type.
    In short. I just want to display these 2 internal tables in an ALV Grid.
    Thanks in Advance.

    Hi,
    u can use ALV Block list to display 2 ALV.
    Reffer to the below code.
    DATA: v_layout TYPE slis_layout_alv.
      DATA: ls_print TYPE slis_print_alv.
      PERFORM build_fieldcatalog.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          i_callback_program             = sy-repid
    *     I_CALLBACK_PF_STATUS_SET       = ' '
    *     I_CALLBACK_USER_COMMAND        = ' '
    *     IT_EXCLUDING                   =
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                        = v_layout
          it_fieldcat                      = it_fcat_nlei
          i_tabname                        = 'IT_NLEI_ALV'
          it_events                        = it_event_nlei
    *     IT_SORT                          =
    *     I_TEXT                           = ' '
        TABLES
          t_outtab                         = it_nlei_alv
        EXCEPTIONS
          program_error                    = 1
          maximum_of_appends_reached       = 2
          OTHERS                           = 3.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                        = v_layout
          it_fieldcat                      = it_fcat_vbrp
          i_tabname                        = 'IT_VBRP_ALV'
          it_events                        = it_event_vbrp
    *     IT_SORT                          =
    *     I_TEXT                           = ' '
        TABLES
          t_outtab                         = it_vbrp_alv
       EXCEPTIONS
         program_error                    = 1
         maximum_of_appends_reached       = 2
         OTHERS                           = 3.
      ls_print-no_print_selinfos  = 'X'.   " Display no selection infos
      ls_print-no_print_listinfos = 'X'.   " Display no listinfos
      ls_print-reserve_lines      = 2.     " Lines reserved for end of page
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
        EXPORTING
    *     I_INTERFACE_CHECK             = ' '
          is_print                      = ls_print
    *     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        =
       EXCEPTIONS
         program_error                 = 1
         OTHERS                        = 2

  • Regarding passing of the modified data back to internal table form alv

    Hi,
       My requirement is i hav a fld in my alv grid checkbox which iam checking when i output the list on the alv grid and I hav to execute an action on all the checked rows the poblem is even iam checking the checkbox it is not being passed back to internal table.I hav used methods to create and display alv grid.This is really urgent can anyone provide any inf on this .
    Thanks and Regards,
    Rajashree

    Hello Tathagata,
    I have a similar problem.
    I need to react on a change of an input-field of the
    grid-control.
    When i call the method "->check_changed_data"
    i allways get e_valid == 'X'.
    The problem is, i have to react in any case, when the
    user presses <ENTER> and if the user has changed
    a field-entry, i have to read additional data
    and store it into the internal datarow of
    the grid-table.
    I have'nt found an event like "ON DATA CHANGED" ...
    How can i solve this problem.
    Thank You very much in advance
    Michael

  • How to create Dynamic Internal table in ALV?

    Hi all,
    I have to create a ALV report based on dynamic internal table. The requirement is that when I enter the months in my selection screen I should get the data relevant to those many months only. For eg if in selection I have given January to March, I should get an ALV output with columns from January to March only.
    Please help me with the coding part as I find it a bit confusing.
    Please reply immediately.
    Regards,
    Bhavani.

    Hi BHAVANI,
    first you have to prapare a field catalog [(see this)|http://help.sap.com/saphelp_470/helpdata/en/52/5f060de02d11d2b47d006094192fe3/frameset.htm]
    and than you can use a Method cl_alv_table_create=>create_dynamic_table
    I hope that help a little.
    Regards Bogdan

  • Req : to capture the filter data in internal table  from ALV

    hi friends..
    i have an requirement, plz guide me to solve this..
    let consider in alv grid i m displaying 10 data(10 rows)
    by using filter let assume now i m getting 5 rows (from the 10 rows).
    i want to capture these 5 rows in an internal table..
    plz giude me to resolve this..
    thanks in advance
    by
    selva

    Hi
    u can think to do this programatically.
    1 add one button on alv tool bar say capture.
    2. filetr the requiredd rows .
    3. seelct all filterd rows.
    4. say capture.
    5.At user command write a code to get the selcted alv rows
    in different internal table.
    6 you can use  FM get_selected_rows for this purpose.

Maybe you are looking for