Dynamic ALV and cl_abap_structdescr Create method

Hi
In the process of creation of Dynamic ALV, as I have char_name and char_descr fields, I have to use char_descr as column header of ALV because char_name which has entries something like DVS_******(that do not make any sense to user). I am facing 2 problems here using the scenario above.
1. char_descr contains characters like '[', ']', ' /', '.', space which are invalid characters for method cl_abap_structdescr=>create(). How to handle scenario like this?
2. assign (lv_value) to <value>.
        if sy-subrc = 0.
          <value> = ls_bapi_char_value-charvalue.
          if <value> is assigned.
            move ls_bapi_char_value-charvalue to <value>.
where-> concatenate '<table_dyn_wa>-' ls_bapi_char-char_descr into lv_value
               <value> type any
              <table_dyn_wa>- is dynamic table with structure created with cl_abap_tabledescr=>create( p_line_type = stru_type )
with above code for few fields data is being assigned and for few sy-subrc = 4. The table from where I am reading the field contains char_name associated with it and not char_descr. For the fields whose char_name and char_descr matches exactly, ALV displays data for it.
How to resolve the issue so that I could get all the data?
Let me know if further details are needed.
Thanks, in advance
Trupti
Edited by: TRUPTI KALLURWAR on Jul 9, 2010 7:08 PM

Hello Srikanth,
CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE( ) uses the GENERATE SUBROUTINE POOL technique to create the dynamic internal tables.
And as per the SAP documentation,
In an internal mode, a maximum of 36 temporary subroutine pools may be created.
Source: [http://help.sap.com/abapdocu_702/en/abapgenerate_subroutine_pool.htm]
Btw why are you crating 36 dynamic internal table? That's way too far-fetched even for the RTTC classes
BR,
Suhas

Similar Messages

  • Dynamic ALV and internal table.

    Hi all,
    I have a requirement of creating a dynamic field catelog based on input values in selection screen.
    Example:
    1) When I enter date range, say  20/03/2008 to 25/03/2008 I should have 6 columns in the output for each date with column heading as date itself.
    2) For entering values for these date columns, i need to create an dynamic internal table.(values in the column will be some numbers like 10 on 20/03/2008, 15 on 21/03/2008  etc)
    A rough output format would look like this:
    Component |  20/03/2008  |  21/03/2008 | .....      |25/03/2008
    comp1        |    10            |      15         |             |      5
    comp2        |    20            |      10         |             |     10
    Please let me know how can i achieve this...
    Need it very urgently..
    Regards,
    Dhareppa

    Hi Dhareppa,
    Refer the code below. Its almost on the same line as your requirments.
    REPORT  zglo2fr_master_planing_sedul NO STANDARD PAGE HEADING.
              P  R  O  G  R  A  M    H  E  A  D  E  R                   *
                        ArthroCare Corporation                          *
    Program            : ZGLO2FR_MASTER_PLANING_SEDUL                   *
    Author             : Munvar Basha                                   *
    Creation Date      : 11Mar08                                        *
    Release            : SAP ECC 6.0                                    *
    Request            : D01K904032                                     *
    Description        : Master Schedule Planning                       *
    Change log (Revisions)                                              *
    Author     Date     Request    Description                          *
                             P  R  O  G  R  A  M                        *
                           DATA DECLARATION                             *
    **--Structure to hold matrial & plant combination records.
    TYPES : BEGIN OF ty_marc,
              matnr  TYPE matnr,
              werks  TYPE werks_d,
              dispo  TYPE dispo,
              beskz  TYPE beskz,
              mtart  TYPE mtart,
            END OF ty_marc.
    **--structure to hold MRP LIST Data.
    TYPES : BEGIN OF ty_mrp_list,
              matnr TYPE matnr,
              werks TYPE werks_d,
              maktx TYPE maktx,
              meins TYPE meins,
              mtart TYPE mtart,
              week  TYPE kweek,
              mng01 TYPE mng01,
              delkz TYPE delkz,
            END OF ty_mrp_list.
    **--structure to hold no of weeks.
    TYPES: BEGIN OF ty_week,
             week TYPE kweek,
           END OF ty_week.
    **--structure to hold output data.
    TYPES : BEGIN OF ty_final,
              matnr TYPE matnr,
              werks TYPE werks_d,
              maktx TYPE maktx,
              meins TYPE meins,
              mtart TYPE mtart,
              week  TYPE kweek,
              mng01 TYPE mng01,
            END OF ty_final.
    TYPES : BEGIN OF ty_range,
              sign   TYPE sign,
              option TYPE option,
              low    TYPE sy-datum,
              high   TYPE sy-datum,
            END OF ty_range.
              Definitions of Table types.                               *
    TYPES : ty_marctab TYPE STANDARD TABLE OF ty_marc.
               Definitions of Ranges                                    *
    *RANGES ran_delkz FOR mdez-delkz.
    DATA : i_ran_delkz TYPE RANGE OF  mdez-delkz,
           wa_ran_delkz LIKE LINE OF i_ran_delkz,
           wa_date type ty_range.
               Definitions of internal tables.                          *
    data : i_marc      type standard table of ty_marc,
           i_mrp_list  type standard table of ty_mrp_list,
           i_week      type standard table of ty_week,
           i_final     type standard table of ty_final,
           i_mdps      type standard table of mdps,
           i_mdez      type standard table of mdez,
           i_mdsu      type standard table of mdsu.
               Definitions of work areas for internal tables            *
    DATA : wa_marc     TYPE ty_marc,
           wa_mrp_list TYPE ty_mrp_list,
           wa_week     TYPE ty_week,
           wa_final    TYPE ty_final,
           wa_mt61d    TYPE mt61d,
           wa_mdez     TYPE mdez.
               Definitiions of General variables                        *
    DATA : v_matnr TYPE mara-matnr, " Material Number
           v_mtart TYPE mara-mtart, " Material Type
           v_beskz TYPE marc-beskz, " Procurement Type
           v_werks TYPE marc-werks, " Plant
           v_dispo TYPE marc-dispo. " MRP Controller (Materials Planner)
    DATA : v_mng01 TYPE mng01. "Requirement Quantity
    DATA : v_year  TYPE char4,
           v_week  TYPE char2,
           v_ok_code TYPE sy-ucomm.
               Definitiions of Constants                                *
    CONSTANTS : k_slash TYPE c     VALUE '/',
                k_6     TYPE char8 VALUE '6',
                k_x     TYPE c     VALUE 'X'.
               Definitiions of Field Catlog                             *
    DATA : wa_fieldcat        TYPE lvc_s_fcat,
           i_fieldcat         TYPE lvc_t_fcat,
           v_container        TYPE scrfname VALUE 'CONTAINER_OUTPUT',
           v_custom_container TYPE REF TO cl_gui_custom_container,
           v_grid             TYPE REF TO cl_gui_alv_grid,
           i_gp_table           TYPE REF TO data,
           wa_gp_line            TYPE REF TO data.
    FIELD-SYMBOLS: <gt_table>  TYPE STANDARD TABLE,
                   <gwa_table> TYPE ANY,
                   <l_field>   TYPE ANY,
                   <l_matnr>   TYPE ANY,
                   <l_werks>   TYPE ANY,
                   <l_maktx>   TYPE ANY,
                   <l_meins>   TYPE ANY,
                   <l_mtart>   TYPE ANY.
                 DECLERATIONS FOR SELECTION SCREEN                      *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_matnr FOR v_matnr,
                     s_mtart FOR v_mtart NO INTERVALS,
                     s_beskz FOR v_beskz NO INTERVALS NO-EXTENSION,
                     s_werks FOR v_werks NO INTERVALS NO-EXTENSION
                     OBLIGATORY,
                     s_dispo FOR v_dispo,
                     s_date  FOR sy-datum OBLIGATORY.
    PARAMETERS :     p_dattp   TYPE dattp OBLIGATORY DEFAULT '1'.
    SELECTION-SCREEN END OF BLOCK b1.
               INITIALIZATION EVENT                                     *
    INITIALIZATION.
      CALL FUNCTION '/BEV4/PLPS__ADD_MONTH_TO_DATE'
        EXPORTING
          months  = k_6
          olddate = sy-datum
        IMPORTING
          newdate = wa_date-high.
      wa_date-low = sy-datum.
      wa_date-option = 'EQ'.
      wa_date-sign = 'I'.
      APPEND wa_date to s_date.
               SELECTION SCREEN EVENT                                   *
    **--Validation for Material
    AT SELECTION-SCREEN ON s_matnr.
      PERFORM validate_material.
    **--Validation for Plant
    AT SELECTION-SCREEN ON s_werks.
      PERFORM validate_plant.
                AT SELECTION-SCREEN ENENT                               *
    AT SELECTION-SCREEN.
      IF s_matnr IS INITIAL AND s_dispo IS INITIAL.
        MESSAGE text-002 TYPE 'E'.
      ENDIF.
      IF s_date-low LT sy-datum.
        MESSAGE text-003 TYPE 'E'.
      ENDIF.
                           START-OF-SELECTION EVENT                     *
    START-OF-SELECTION.
    **--refreshing the internal tables
      REFRESH : i_marc,
                i_mrp_list,
                i_week,
                i_final,
                i_mdps,
                i_mdez,
                i_mdsu.
    **--clearing the work areas of internal tables.
      CLEAR : wa_marc,
              wa_mrp_list,
              wa_week,
              wa_final,
              wa_mt61d,
              wa_mdez.
    To get all the matrial(s) and plant combination records
      SELECT a~matnr
             a~werks
             a~dispo
             a~beskz
             b~mtart
             INTO TABLE i_marc
             FROM marc AS a INNER JOIN
                  mara AS b
                  ON a~matnr = b~matnr
             WHERE a~werks IN s_werks AND
                   a~matnr IN s_matnr AND
                   a~dispo IN s_dispo AND
                   a~beskz IN s_beskz AND
                   b~mtart IN s_mtart.
      IF sy-subrc <> 0.
        MESSAGE text-005 TYPE 'S'.
        LEAVE LIST-PROCESSING.
      ENDIF.
      SORT i_marc BY matnr werks.
    Ranges to Filter the MRP list only for the following MRP Elements.
    MRP Elements are : BA, BE, FE, LE and PA
      wa_ran_delkz-sign = 'I'.
      wa_ran_delkz-option = 'EQ'.
      wa_ran_delkz-low = 'BA'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      wa_ran_delkz-low = 'BE'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      wa_ran_delkz-low = 'FE'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      wa_ran_delkz-low = 'LE'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      wa_ran_delkz-low = 'PA'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      LOOP AT i_marc INTO wa_marc.
        CALL FUNCTION 'MD_MRP_LIST_API'
          EXPORTING
            matnr                    = wa_marc-matnr
            werks                    = wa_marc-werks
            sinfg                    = k_x
            inper                    = p_dattp
          IMPORTING
            e_mt61d                  = wa_mt61d
          TABLES
            mdpsx                    = i_mdps
            mdezx                    = i_mdez
            mdsux                    = i_mdsu
          EXCEPTIONS
            mrp_list_not_found       = 1
            material_plant_not_found = 2
            error                    = 3
            OTHERS                   = 4.
        IF sy-subrc = 0.
          LOOP AT i_mdez INTO wa_mdez WHERE dat00 IN s_date AND
                                            delkz IN i_ran_delkz.
            CALL FUNCTION 'DATE_GET_WEEK'
              EXPORTING
                date         = wa_mdez-dat00
              IMPORTING
                week         = wa_mrp_list-week
              EXCEPTIONS
                date_invalid = 1
                OTHERS       = 2.
            IF sy-subrc = 0.
              wa_mrp_list-matnr = wa_mt61d-matnr.
              wa_mrp_list-werks = wa_mt61d-werks.
              wa_mrp_list-maktx = wa_mt61d-maktx.
              wa_mrp_list-meins = wa_mt61d-meins.
              wa_mrp_list-mtart = wa_mt61d-mtart.
              wa_mrp_list-delkz = wa_mdez-delkz.
              wa_mrp_list-mng01 = wa_mdez-mng01.
              APPEND wa_mrp_list TO i_mrp_list.
              CLEAR : wa_mrp_list,
                      wa_mdez.
            ENDIF.
          ENDLOOP.
        ENDIF.
        CLEAR: wa_marc.
      ENDLOOP.
      IF i_mrp_list IS INITIAL.
        MESSAGE text-006 TYPE 'S'.
        LEAVE LIST-PROCESSING.
      ENDIF.
      CLEAR : v_mng01.
      LOOP AT i_mrp_list INTO wa_mrp_list.
        v_mng01 = v_mng01 + wa_mrp_list-mng01.
        AT END OF week.
          wa_final-matnr = wa_mrp_list-matnr.
          wa_final-werks = wa_mrp_list-werks.
          wa_final-maktx = wa_mrp_list-maktx.
          wa_final-meins = wa_mrp_list-meins.
          wa_final-mtart = wa_mrp_list-mtart.
          wa_final-week  = wa_mrp_list-week.
          wa_final-mng01 = v_mng01.
          wa_week-week =   wa_mrp_list-week.
          APPEND : wa_final TO i_final,
                   wa_week  TO i_week.
          CLEAR : v_mng01,
                  wa_final,
                  wa_week.
        ENDAT.
        CLEAR : wa_mrp_list.
      ENDLOOP.
    **-- Populate the Field catalog
      PERFORM populate_fieldcat.
    **--Create table dynamically
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = i_fieldcat
        IMPORTING
          ep_table        = i_gp_table.
      ASSIGN i_gp_table->* TO <gt_table>.
    **--fill table with final output data
      PERFORM fill_table.
      CALL SCREEN 100.
                              SUB ROUTINES                              *
    *&      Form  validate_material                                        *
          Validating Material Number(s)                                  *
    FORM validate_material .
      TYPES : BEGIN OF l_ty_matnr,
               matnr TYPE matnr,
              END OF l_ty_matnr.
      DATA : l_i_matnr TYPE STANDARD TABLE OF l_ty_matnr.
      SELECT matnr
             FROM mara
             INTO TABLE l_i_matnr
             WHERE matnr IN s_matnr.
      IF sy-subrc <> 0.
        MESSAGE text-004 TYPE 'E'.
      ENDIF.
    ENDFORM.                    " validate_material
    *&      Form  validate_plant                                           *
          Validating Plant Number                                        *
    FORM validate_plant .
      DATA : l_v_werks TYPE werks_d.
      SELECT SINGLE werks
                    FROM t001w
                    INTO l_v_werks
                    WHERE werks = s_werks-low.
      IF sy-subrc <> 0.
        MESSAGE e019(zartc) WITH s_werks-low.
      ENDIF.
    ENDFORM.                    " validate_plant
    *&      Form  populate_fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM populate_fieldcat .
      DATA : l_v_colname TYPE char7.
      SORT i_week BY week.
      DELETE ADJACENT DUPLICATES FROM i_week COMPARING week.
      LOOP AT i_week INTO wa_week.
        AT FIRST.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 1.
          wa_fieldcat-fieldname   = 'MATNR'.
          wa_fieldcat-scrtext_l   = text-007.
          wa_fieldcat-scrtext_m   = text-007.
          wa_fieldcat-scrtext_s   = text-007.
          wa_fieldcat-fix_column  = 'X'.
          wa_fieldcat-outputlen   = 18.
          wa_fieldcat-tooltip     = text-007.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 2.
          wa_fieldcat-fieldname   = 'WERKS'.
          wa_fieldcat-scrtext_l   = text-008.
          wa_fieldcat-scrtext_m   = text-008.
          wa_fieldcat-scrtext_s   = text-008.
          wa_fieldcat-fix_column  = 'X'.
          wa_fieldcat-outputlen   = 4.
          wa_fieldcat-tooltip     = text-008.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 3.
          wa_fieldcat-fieldname   = 'MAKTX'.
          wa_fieldcat-scrtext_l   = text-009.
          wa_fieldcat-scrtext_m   = text-010.
          wa_fieldcat-scrtext_s   = text-011.
          wa_fieldcat-tooltip     = text-009.
          wa_fieldcat-outputlen   = 40.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 4.
          wa_fieldcat-fieldname   = 'MEINS'.
          wa_fieldcat-scrtext_l   = text-012.
          wa_fieldcat-scrtext_m   = text-013.
          wa_fieldcat-scrtext_s   = text-014.
          wa_fieldcat-outputlen   = 4.
          wa_fieldcat-tooltip     = text-012.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 5.
          wa_fieldcat-fieldname   = 'MTART'.
          wa_fieldcat-scrtext_l   = text-015.
          wa_fieldcat-scrtext_m   = text-015.
          wa_fieldcat-scrtext_s   = text-016.
          wa_fieldcat-tooltip     = text-015.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
        ENDAT.
        v_year = wa_week-week+0(4).
        v_week = wa_week-week+4(2).
        CONCATENATE v_week k_slash v_year INTO l_v_colname.
        wa_fieldcat-row_pos     = 0.
        wa_fieldcat-col_pos     = 6 + sy-index.
        wa_fieldcat-fieldname   = wa_week-week.
        wa_fieldcat-quantity    = 'X'.
        wa_fieldcat-outputlen   = 18.
        wa_fieldcat-scrtext_l   = l_v_colname.
        wa_fieldcat-tooltip     = l_v_colname.
        APPEND wa_fieldcat TO i_fieldcat.
        CLEAR : wa_fieldcat,
                l_v_colname,
                wa_week.
      ENDLOOP.
    ENDFORM.                    " populate_fieldcat
    *&      Form  fill_table
          text
    -->  p1        text
    <--  p2        text
    FORM fill_table .
    **--Create Work Area Dynamically
      CREATE DATA wa_gp_line LIKE LINE OF <gt_table>.
      ASSIGN wa_gp_line->* TO <gwa_table>.
      DATA : l_v_col TYPE char25,
             l_v_val TYPE char25.
      LOOP AT i_final INTO wa_final.
        l_v_col = wa_final-week.
        ASSIGN COMPONENT l_v_col OF STRUCTURE <gwa_table>
                                           TO <l_field>.
        IF <l_field> IS ASSIGNED.
          l_v_val = wa_final-mng01.
          CONDENSE l_v_val.
          <l_field> = l_v_val.
          clear : l_v_val,
                  l_v_col.
        ENDIF.
        AT END OF matnr.
         READ TABLE   i_final INTO wa_final WITH KEY matnr = wa_final-matnr
                                                              BINARY SEARCH.
          IF sy-subrc = 0.
            ASSIGN COMPONENT 'MATNR' OF STRUCTURE <gwa_table>
                                             TO <l_matnr>.
            IF <l_matnr> IS ASSIGNED.
              <l_matnr> = wa_final-matnr.
            ENDIF.
            ASSIGN COMPONENT 'WERKS' OF STRUCTURE <gwa_table>
                                             TO <l_werks>.
            IF <l_werks> IS ASSIGNED.
              <l_werks> = wa_final-werks.
            ENDIF.
            ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <gwa_table>
                                             TO <l_maktx>.
            IF <l_maktx> IS ASSIGNED.
              <l_maktx> = wa_final-maktx.
            ENDIF.
            ASSIGN COMPONENT 'MEINS' OF STRUCTURE <gwa_table>
                                             TO <l_meins>.
            IF <l_meins> IS ASSIGNED.
              <l_meins> = wa_final-meins.
            ENDIF.
            ASSIGN COMPONENT 'MTART' OF STRUCTURE <gwa_table>
                                             TO <l_mtart>.
            IF <l_mtart> IS ASSIGNED.
              <l_mtart> = wa_final-mtart.
            ENDIF.
            APPEND <gwa_table> TO <gt_table>.
            CLEAR <gwa_table>.
          ENDIF.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " fill_table
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'ZMUNNA'.
      SET TITLEBAR 'MRP'.
      IF v_custom_container IS INITIAL.
        CREATE OBJECT v_custom_container
          EXPORTING
            container_name = v_container.
        CREATE OBJECT v_grid
          EXPORTING
            i_parent = v_custom_container.
        CALL METHOD v_grid->set_table_for_first_display
          CHANGING
            it_outtab       = <gt_table>
            it_fieldcatalog = i_fieldcat.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      v_ok_code = sy-ucomm.
      CLEAR sy-ucomm.
      CASE v_ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
          SET SCREEN 000.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  exit_program
          text
    -->  p1        text
    <--  p2        text
    FORM exit_program .
      CALL METHOD v_custom_container->free.
      CALL METHOD cl_gui_cfw=>flush.
    ENDFORM.                    " exit_program
    Reward points if that helps.
    Manish

  • Dynamic SQL and GRANT CREATE ANY TABLE

    hi gurus,
    i have a dynamic SQL in a procedure where a table will be created from an existing table without data.
    strSQL:='create table ' || strTemp || ' as select * from ' || strArc || ' where 1=2';
    execute immediate strSQL;
    without GRANT CREATE ANY TABLE for the user, *"ORA-01031: insufficient privileges"* error during execution.
    Is there a way to tackle this issue without providing GRANT CREATE ANY TABLE privilige?
    many thanks,
    Charles

    ravikumar.sv wrote:
    The problem is not because of dynamic sql...It probably has something to do with dynamic SQL or, more accurately, dynamic SQL within a stored procedure.
    From a SQL*Plus command prompt, you can create a table if your account has the CREATE TABLE privilege either granted directly to it or granted to a role that has been granted to your account. Most people probably have the CREATE TABLE privilege through a role (hopefully a custom "developer role" that has whatever privileges you grant to users that will own objects but potentially through the default RESOURCE role). That is not sufficient to create tables dynamically via a definer's rights stored procedure. Only privileges that are granted directly to the user, not those granted via a role, are visible in that case.
    I expect that the DBAs are granting the CREATE ANY TABLE privilege directly to the account in question rather than through whatever role(s) are being used which is why that appears to solve the problem.
    Justin

  • Editing values within Dynamic ALV

    Hello All,
    I am currently working on dynamic ALV and want the columns to be editible.
    I have gone through the tutorial
    Link : [https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4c70444a-0801-0010-7688-9e4bd844b783]
    and have created a dynamic Context and a corresponding ALV LIST display. Everything is fine except that i want to be able to edit values within the list and i want this to get populated back into the context.
    I have gone through the tutorial.
    Link : [https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1]
    But i couldn't relate that with the tutorial for dynamic ALV.
    Please help.
    Best Regards,
    Mz

    Hello Lekha,
    I am sorry to say that  the code which you have provided is not working.
    Maybe i am doing something wrong.
    This is the entire code below.
    data lo_interfacecontroller type ref to iwci_salv_wd_table .
    data lo_cmp_usage type ref to if_wd_component_usage.
    data : L_VIEW_CONTROLLER_API type ref to IF_WD_VIEW_CONTROLLER.
    lo_cmp_usage =   wd_this->wd_cpuse_alv( ).
    if lo_cmp_usage->has_active_component( ) is initial.
      lo_cmp_usage->create_component( ).
    endif.
    lo_interfacecontroller =   wd_this->wd_cpifc_alv( ).
      lo_interfacecontroller->set_data(
    *   only_if_new_descr =                 " wdy_boolean
        "r_node_data =
        dyn_node                    " ref to if_wd_context_node
    DATA:
       lo_value type ref to cl_salv_wd_config_table,
         lr_column      TYPE REF TO cl_salv_wd_column,            " Table fo rcolumn ref
         ls_columns     TYPE salv_wd_s_column_ref,                " Structure for column ref
        lt_columns     TYPE salv_wd_t_column_ref,                " Structure for column ref
       lr_input       TYPE REF TO cl_salv_wd_uie_input_field.
    lo_value = lo_interfacecontroller->get_model( ).
    * Get the column ref
      CALL METHOD lo_value->if_salv_wd_column_settings~get_columns
        RECEIVING
          value = lt_columns.
      LOOP AT lt_columns INTO ls_columns.
        lr_column = ls_columns-r_column.
    case ls_columns-id.
    when 'JAN2007'.
            CREATE OBJECT lr_input
              EXPORTING
                value_fieldname = ls_columns-id.
            CALL METHOD lr_column->set_cell_editor
              EXPORTING
                value = lr_input.
    *     Set the read only attribute
            lr_input->set_read_only_fieldname( value = 'FALSE' ).
    endcase.
    endloop.
    L_VIEW_CONTROLLER_API = WD_THIS->WD_GET_API( ).
    L_VIEW_CONTROLLER_API->PREPARE_DYNAMIC_NAVIGATION(
    source_window_name = 'WINDOW1'
    source_vusage_name = 'MAIN_USAGE_0'
    source_plug_name = 'TO_V1'
    target_component_name = 'SALV_WD_TABLE'
    target_component_usage = 'ALV'
    target_view_name = 'TABLE'
    target_plug_name = 'DEFAULT'
    target_embedding_position = 'MAIN/VIEW_CONTAINER'
    WD_THIS->FIRE_TO_V1_PLG( ).
    The part which is entered as per your instructions are given between the asterisk lines.
    Sorry if there are any silly mistakes on my part.
    I have one small doubt regarding the value to be passed for the method lr_input->set_read_only_fieldname. This is a string value. I think that this could be the cause of the error. When i checked the class interface, CL_SALV_WD_UIE_INPUT_FIELD i found that the method set_read_only_fieldname is calling another attribute if_salv_wd_c_table_evt_editor=>set_read_only_fieldname.
    Hope this was useful
    Best Regards,
    Mz

  • How to add Select event in dynamic ALV

    Hi,
    I have created dynamic ALV and now i want to checked the selected row value.
    If in the selected row contain 'A' value then i have to disable the Button given on the screen.
    If in the selected row contain B' value then i have to enable the Button given on the screen.
    How to add the event once I select the row.
    I have done like this . but it is not
    lw_api_2->do_dynamic_navigation(
              source_window_name          = 'ZWDCHHR_EX_TASK_DELE'
              source_vusage_name          = 'ZWDVHHR_EX_TASK_DELE_USAGE_1'
              source_plug_name            = 'TO_ALV'
              target_component_name       = 'SALV_WD_TABLE'
              target_component_usage      = 'ALV_USAGE1'
              target_view_name            = 'TABLE'
              target_plug_name            = 'DEFAULT'
              target_embedding_position   = 'ZWDVHHR_EX_TASK_DELE/VIEW_DELEG_MY_TASKS' ).
      register event handler
        lw_cmp_usage_2->add_event_handler(
           listener        =  lw_api_2
           handler_name    = 'ONSELECT_TAB1'
           controller_name = 'INTERFACECONTROLLER'
           event_name      = 'ON_SELECT' ).
    Thanks and regards
    Amita Gandhi

    Hi Amita,
    You can try fetch the number of the row which was leadselected through R_PARAM->INDEX. (This would be just a normal integer variable. You can try check this out in debugging mode. ) Now you can just read the data of this row from the context node by saying as GET_ATTRIBUTE up on the nodes reference with the index as R_PARAM->INDEX.
    Regards,
    Uday

  • Problem in dynamic alv

    hi,
       i am making a dynamic alv  and i am facing a problem
    i have only one loop in which i perform all the operation
    now i want at end of lot no. which is (prueflos) append in to main table.please solve my problem.
        the code for that loop is as follows.
    loop at t_qamv into w_qamv.
         read table t_qals into w_qals with key prueflos = w_qamv-prueflos.
           if sy-subrc = 0.
          at new prueflos.
             MOVE W_QALS-WERK TO W_MAIN-WERK.
             move w_qals-prueflos to w_main-prueflos.
               SELECT SINGLE NAME1 INTO W_MAIN-NAME1
                 FROM T001W WHERE SPRAS = 'EN'
                   AND WERKS = W_QALS-WERK.
          endat.
           endif.
              v_count = v_Count + 1.
              read table t_qamr into w_qamr with key PRUEFLOS = W_QAls-PRUEFLOS MERKNR = W_QAMV-MERKNR.
                if sy-subrc = 0.
                if w_qamr-merknr = w_qamv-merknr.
                   concatenate 'w_main-f' v_count into v_field.
                    CONDENSE V_FIELD.
                     ASSIGN (v_field) to  <value>.
                      if w_qamr-pruefbemkt is initial.
                        WRITE w_qamr-mittelwert TO v_pak EXPONENT 0 DECIMALS 3.
                       else.
                        write w_qamr-pruefbemkt to v_pak.
                      endif.
                       <value>  =  v_pak.
                 endif.
    endloop.

    Hi Aisurya,
                    Your dynamic node is only refering to TEST_BLOCK. But you have not given any values to the node.
                    You first bind your values (i.e internal table values) using BIND_TABLE method.
                   dyn_node = wd_context->get_child_node( name = 'TEST_BLOCK' ).
                   dyn_node->BIND_TABLE ( itab ).
    Regards,
    Harry

  • Create structure in Dynamic ALV for color and editing cells

    Hi experts,
    I created dynamic ALV . in this i want coloring and editing of cells.
    this can be done by strucutture lvc_t_scol, lvc_t_styl.
    My problem is how to create structure in field catalogue of Dynamic ALV.
    Thanks

    Hello
    I am not sure if you have missed the following part of the coding:
    " Add table type (LVC_T_STYL) as field to structure ==> complex structure
      CLEAR: gs_comp.
      gs_comp-type ?= cl_abap_typedescr=>describe_by_data( celltab ).
      gs_comp-name  = 'CELLTAB'.
      APPEND gs_comp TO gt_components.
      go_sdescr  = cl_abap_structdescr=>create( gt_components ).
      go_tdescr  = cl_abap_tabledescr=>create( go_sdescr ).
      CREATE DATA gdo_handle TYPE HANDLE go_tdescr.
      ASSIGN gdo_handle->* TO <gt_itab>.
    This is exactly your requirement.
    Regards
      Uwe

  • Using Search Help with ALV and Dynamic context node

    The topic subject already describes my situation.
    I have to create, populate and remove context nodes at runtime, and bind them to an ALV, to let user display the data or modify the data. The nodes I create are always typed with a table name, but the table name is of course, dynamic.
    This is all working: what's not working is help for entries inside the ALV; since the table has foreign keys and domains with check tables or fixed values, I expected that search helps were detected and managed by the framework.
    Instead, no help search is displayed except the input help based on data-type of the one "Date" input fields.
    I think I have to work on the dynamic node creation, and not on the ALV itself, since the latter only takes the node/attributes information, but i could be wrong. I tried with both the two following codings:
      CALL METHOD lo_nd_info_root->add_new_child_node
        EXPORTING
          static_element_type          = vs_tabname
          name                         = 'SAMPLE_NODE_NAME'
    *    is_mandatory                 = abap_false
    *    is_mandatory_selection       = abap_false
         is_multiple                  = abap_true
         is_multiple_selection        = abap_false
    *    is_singleton                 = abap_false
          is_initialize_lead_selection = abap_false
          is_static                    = abap_false
        RECEIVING
          child_node_info              = lo_nd_info_data .
    cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
          parent_info = lo_nd_info_root
          node_name = 'SAMPLE_NODE_NAME'
          structure_name = vs_tabname
          is_multiple = abap_true ).
    The result is the same...is there any way to let the ALV know what search helps it has to use, and doesn't force me to manually build a VALUE_SET to be bound on the single attributes? There are many tables, with many fields, and maintaining this solution would be very costly.

    I have checked with method GET_ATTRIBUTE_VALUEHELP_TYPE of interface IF_WD_CONTEXT_NODE_INFO, on an attribute which i know to have a search help (Foreign key of a check table).
    The method returns 'N', that is the constant IF_WD_VALUE_HELP_HANDLER~CO_VH_TYPE_NO_HELP. So, the framework was not able to find a suitable search help.
    Using method GET_ATTRIBUTE_VALUE_HELP of the same interface, on the same attribute, returns me '111', which is constant C_VALUE_HELP_MODE-AUTOMATIC.
    Therefore, the WD framework knows it has to automatically detect a value help, but fails to find one.
    Also, this means in my opinion that the ALV and the dynamic external mapping are not the culprits: since node creation, no help is detected for any attribute but the date. Honestly, I don't have a clue on what's happening.

  • ALV with dynamic columns and description labels in header titles

    Hi everybody,
    I have to implement an ALV whose columns are not defined until runtime. Is it possible to do that in some simple way? Is it necessary to use objects to define this kind of ALV's?
    And another one query, is it possible to add description labels to column headers so that when the user points with the cursor in them he/she gets a little explanation about the detail of the column (for example, description name of the product hierarchy when pointing to the column named with one of the existing hierarchies, i.e 010102102)
    Thanks in advance,

    for your first question check this
    Just check this sample from one of the SAP site
    ABAP Code Sample for Dynamic Table for ALV with Cell Coloring
    Applies To:
    ABAP / ALV Grid
    Article Summary
    ABAP Code Sample that uses dynamic programming techniques to build a dynamic internal table for display in an ALV Grid with Cell Coloring.
    Code Sample
    REPORT zcdf_dynamic_table.
    * Dynamic ALV Grid with Cell Coloring.
    * Build a field catalog dynamically and provide the ability to color
    * the cells.
    * To test, copy this code to any program name and create screen 100
    * as described in the comments. After the screen is displayed, hit
    * enter to exit the screen.
    * Tested in 4.6C and 6.20
    * Charles Folwell - [email protected] - Feb 2, 2005
    DATA:
    r_dyn_table TYPE REF TO data,
    r_wa_dyn_table TYPE REF TO data,
    r_dock_ctnr TYPE REF TO cl_gui_docking_container,
    r_alv_grid TYPE REF TO cl_gui_alv_grid,
    t_fieldcat1 TYPE lvc_t_fcat, "with cell color
    t_fieldcat2 TYPE lvc_t_fcat, "without cell color
    wa_fieldcat LIKE LINE OF t_fieldcat1,
    wa_cellcolors TYPE LINE OF lvc_t_scol,
    wa_is_layout TYPE lvc_s_layo.
    FIELD-SYMBOLS:
    <t_dyn_table> TYPE STANDARD TABLE,
    <wa_dyn_table> TYPE ANY,
    <t_cellcolors> TYPE lvc_t_scol,
    <w_field> TYPE ANY.
    START-OF-SELECTION.
    * Build field catalog based on your criteria.
    wa_fieldcat-fieldname = 'FIELD1'.
    wa_fieldcat-inttype = 'C'.
    wa_fieldcat-outputlen = '10'.
    wa_fieldcat-coltext = 'My Field 1'.
    wa_fieldcat-seltext = wa_fieldcat-coltext.
    APPEND wa_fieldcat TO t_fieldcat1.
    wa_fieldcat-fieldname = 'FIELD2'.
    wa_fieldcat-inttype = 'C'.
    wa_fieldcat-outputlen = '10'.
    wa_fieldcat-coltext = 'My Field 2'.
    wa_fieldcat-seltext = wa_fieldcat-coltext.
    APPEND wa_fieldcat TO t_fieldcat1.
    * Before adding cell color table, save fieldcatalog to pass
    * to ALV call. The ALV call needs a fieldcatalog without
    * the internal table for cell coloring.
    t_fieldcat2[] = t_fieldcat1[].
    * Add cell color table.
    * CALENDAR_TYPE is a structure in the dictionary with a
    * field called COLTAB of type LVC_T_SCOL. You can use
    * any structure and field that has the type LVC_T_SCOL.
    wa_fieldcat-fieldname = 'T_CELLCOLORS'.
    wa_fieldcat-ref_field = 'COLTAB'.
    wa_fieldcat-ref_table = 'CALENDAR_TYPE'.
    APPEND wa_fieldcat TO t_fieldcat1.
    * Create dynamic table including the internal table
    * for cell coloring.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = t_fieldcat1
    IMPORTING
    ep_table = r_dyn_table
    EXCEPTIONS
    generate_subpool_dir_full = 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.
    * Get access to new table using field symbol.
    ASSIGN r_dyn_table->* TO <t_dyn_table>.
    * Create work area for new table.
    CREATE DATA r_wa_dyn_table LIKE LINE OF <t_dyn_table>.
    * Get access to new work area using field symbol.
    ASSIGN r_wa_dyn_table->* TO <wa_dyn_table>.
    * Get data into table from somewhere. Field names are
    * known at this point because field catalog is already
    * built. Read field names from the field catalog or use
    * COMPONENT <number> in a DO loop to access the fields. A
    * simpler hard coded approach is used here.
    ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'ABC'.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'XYZ'.
    APPEND <wa_dyn_table> TO <t_dyn_table>.
    ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'TUV'.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'DEF'.
    APPEND <wa_dyn_table> TO <t_dyn_table>.
    * Color cells based on your criteria. In this example, a test on
    * FIELD2 is used to decide on color.
    LOOP AT <t_dyn_table> INTO <wa_dyn_table>.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    * Get access to internal table used to color cells.
    ASSIGN COMPONENT 'T_CELLCOLORS'
    OF STRUCTURE <wa_dyn_table> TO <t_cellcolors>.
    CLEAR wa_cellcolors.
    wa_cellcolors-fname = 'FIELD2'.
    IF <w_field> = 'DEF'.
    wa_cellcolors-color-col = '7'.
    ELSE.
    wa_cellcolors-color-col = '5'.
    ENDIF.
    APPEND wa_cellcolors TO <t_cellcolors>.
    MODIFY <t_dyn_table> FROM <wa_dyn_table>.
    ENDLOOP.
    * Display screen. Define screen 100 as empty, with next screen
    * set to 0 and flow logic of:
    * PROCESS BEFORE OUTPUT.
    * MODULE initialization.
    * PROCESS AFTER INPUT.
    CALL SCREEN 100.
    * MODULE initialization OUTPUT
    MODULE initialization OUTPUT.
    * Set up for ALV display.
    IF r_dock_ctnr IS INITIAL.
    CREATE OBJECT r_dock_ctnr
    EXPORTING
    side = cl_gui_docking_container=>dock_at_left
    ratio = '90'.
    CREATE OBJECT r_alv_grid
    EXPORTING i_parent = r_dock_ctnr.
    * Set ALV controls for cell coloring table.
    wa_is_layout-ctab_fname = 'T_CELLCOLORS'.
    * Display.
    CALL METHOD r_alv_grid->set_table_for_first_display
    EXPORTING
    is_layout = wa_is_layout
    CHANGING
    it_outtab = <t_dyn_table>
    it_fieldcatalog = t_fieldcat2.
    ELSE. "grid already prepared
    * Refresh display.
    CALL METHOD r_alv_grid->refresh_table_display
    EXPORTING
    i_soft_refresh = ' '
    EXCEPTIONS
    finished = 1
    OTHERS = 2.
    ENDIF.
    ENDMODULE. " initialization OUTPUT

  • ALV report with dynamic columns, and repeated structure rows

    Hey Guys,
    I've done some ALV programming, but most of the reports were straight forward. This one is a little interesting. So here go the questions...
    Q1: Regarding Columns:
    What is the best way to code a report with columns being dynamic. This is one of the parameters the user is going to enter in his input.
    Q2: Regarding Rows:
    I want to repeat a structure(say it contains f1, f2, f3) multiple time in rows. What is the best way to do it? The labels for these fields have to appear in the first column.
    Below is the visual representation of the questions.
    Jan 06  , Feb 06, Mar 06....(dynamic)
       material 1
    Current Stock
    current required
    $Value of stock
       material 2
    Current Stock
    current required
    $Value of stock
       material 3
    Current Stock
    current required
    $Value of stock
    Thanks for your help.
    Sumit.

    Hi Sumit,
    Just check this sample from one of the SAP site
    ABAP Code Sample for Dynamic Table for ALV with Cell Coloring
    Applies To:
    ABAP / ALV Grid
    Article Summary
    ABAP Code Sample that uses dynamic programming techniques to build a dynamic internal table for display in an ALV Grid with Cell Coloring.
    Code Sample
    REPORT zcdf_dynamic_table.
    * Dynamic ALV Grid with Cell Coloring.
    * Build a field catalog dynamically and provide the ability to color
    * the cells.
    * To test, copy this code to any program name and create screen 100
    * as described in the comments. After the screen is displayed, hit
    * enter to exit the screen.
    * Tested in 4.6C and 6.20
    * Charles Folwell - [email protected] - Feb 2, 2005
    DATA:
    r_dyn_table TYPE REF TO data,
    r_wa_dyn_table TYPE REF TO data,
    r_dock_ctnr TYPE REF TO cl_gui_docking_container,
    r_alv_grid TYPE REF TO cl_gui_alv_grid,
    t_fieldcat1 TYPE lvc_t_fcat, "with cell color
    t_fieldcat2 TYPE lvc_t_fcat, "without cell color
    wa_fieldcat LIKE LINE OF t_fieldcat1,
    wa_cellcolors TYPE LINE OF lvc_t_scol,
    wa_is_layout TYPE lvc_s_layo.
    FIELD-SYMBOLS:
    <t_dyn_table> TYPE STANDARD TABLE,
    <wa_dyn_table> TYPE ANY,
    <t_cellcolors> TYPE lvc_t_scol,
    <w_field> TYPE ANY.
    START-OF-SELECTION.
    * Build field catalog based on your criteria.
    wa_fieldcat-fieldname = 'FIELD1'.
    wa_fieldcat-inttype = 'C'.
    wa_fieldcat-outputlen = '10'.
    wa_fieldcat-coltext = 'My Field 1'.
    wa_fieldcat-seltext = wa_fieldcat-coltext.
    APPEND wa_fieldcat TO t_fieldcat1.
    wa_fieldcat-fieldname = 'FIELD2'.
    wa_fieldcat-inttype = 'C'.
    wa_fieldcat-outputlen = '10'.
    wa_fieldcat-coltext = 'My Field 2'.
    wa_fieldcat-seltext = wa_fieldcat-coltext.
    APPEND wa_fieldcat TO t_fieldcat1.
    * Before adding cell color table, save fieldcatalog to pass
    * to ALV call. The ALV call needs a fieldcatalog without
    * the internal table for cell coloring.
    t_fieldcat2[] = t_fieldcat1[].
    * Add cell color table.
    * CALENDAR_TYPE is a structure in the dictionary with a
    * field called COLTAB of type LVC_T_SCOL. You can use
    * any structure and field that has the type LVC_T_SCOL.
    wa_fieldcat-fieldname = 'T_CELLCOLORS'.
    wa_fieldcat-ref_field = 'COLTAB'.
    wa_fieldcat-ref_table = 'CALENDAR_TYPE'.
    APPEND wa_fieldcat TO t_fieldcat1.
    * Create dynamic table including the internal table
    * for cell coloring.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = t_fieldcat1
    IMPORTING
    ep_table = r_dyn_table
    EXCEPTIONS
    generate_subpool_dir_full = 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.
    * Get access to new table using field symbol.
    ASSIGN r_dyn_table->* TO <t_dyn_table>.
    * Create work area for new table.
    CREATE DATA r_wa_dyn_table LIKE LINE OF <t_dyn_table>.
    * Get access to new work area using field symbol.
    ASSIGN r_wa_dyn_table->* TO <wa_dyn_table>.
    * Get data into table from somewhere. Field names are
    * known at this point because field catalog is already
    * built. Read field names from the field catalog or use
    * COMPONENT <number> in a DO loop to access the fields. A
    * simpler hard coded approach is used here.
    ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'ABC'.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'XYZ'.
    APPEND <wa_dyn_table> TO <t_dyn_table>.
    ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'TUV'.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'DEF'.
    APPEND <wa_dyn_table> TO <t_dyn_table>.
    * Color cells based on your criteria. In this example, a test on
    * FIELD2 is used to decide on color.
    LOOP AT <t_dyn_table> INTO <wa_dyn_table>.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    * Get access to internal table used to color cells.
    ASSIGN COMPONENT 'T_CELLCOLORS'
    OF STRUCTURE <wa_dyn_table> TO <t_cellcolors>.
    CLEAR wa_cellcolors.
    wa_cellcolors-fname = 'FIELD2'.
    IF <w_field> = 'DEF'.
    wa_cellcolors-color-col = '7'.
    ELSE.
    wa_cellcolors-color-col = '5'.
    ENDIF.
    APPEND wa_cellcolors TO <t_cellcolors>.
    MODIFY <t_dyn_table> FROM <wa_dyn_table>.
    ENDLOOP.
    * Display screen. Define screen 100 as empty, with next screen
    * set to 0 and flow logic of:
    * PROCESS BEFORE OUTPUT.
    * MODULE initialization.
    * PROCESS AFTER INPUT.
    CALL SCREEN 100.
    * MODULE initialization OUTPUT
    MODULE initialization OUTPUT.
    * Set up for ALV display.
    IF r_dock_ctnr IS INITIAL.
    CREATE OBJECT r_dock_ctnr
    EXPORTING
    side = cl_gui_docking_container=>dock_at_left
    ratio = '90'.
    CREATE OBJECT r_alv_grid
    EXPORTING i_parent = r_dock_ctnr.
    * Set ALV controls for cell coloring table.
    wa_is_layout-ctab_fname = 'T_CELLCOLORS'.
    * Display.
    CALL METHOD r_alv_grid->set_table_for_first_display
    EXPORTING
    is_layout = wa_is_layout
    CHANGING
    it_outtab = <t_dyn_table>
    it_fieldcatalog = t_fieldcat2.
    ELSE. "grid already prepared
    * Refresh display.
    CALL METHOD r_alv_grid->refresh_table_display
    EXPORTING
    i_soft_refresh = ' '
    EXCEPTIONS
    finished = 1
    OTHERS = 2.
    ENDIF.
    ENDMODULE. " initialization OUTPUT
    Regards
    vijay

  • I want  to create dynamic ALV report

    Hi great abapers,
    I want  to create dynamic ALV report.Please help me.
    Regards,
    Billa

    Hi,
    Please check the code below:
    REPORT YMMR_PALLET_OVERVIEW MESSAGE-ID Y_MESSAGE_0001.
    Short description:
    To Display and sum up the Quantity of scanned materials on pallet for*
    each Shipment number for the Packaging Materials. *
    TYPE-POOLS : SLIS.
    TABLES: YYLE0003. " Scanned SSCC No.
    --Structure Declaration--
    Structure for Shipment No. and Date.
    TYPES : BEGIN OF T_VTTK_TAB ,
    TKNUM LIKE VTTK-TKNUM, " Shipment number
    ERDAT LIKE VTTK-ERDAT, " created Date
    END OF T_VTTK_TAB .
    Structure for Shipment No., Packaging Materials and Date.
    TYPES: BEGIN OF T_ITAB2,
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    QUANTITY TYPE P,
    ERDAT LIKE YYLE0003-ERDAT, " created Date
    COUNT TYPE I,
    END OF T_ITAB2.
    Structure for Shipment No. and Packaging Materials.
    TYPES: BEGIN OF T_ITAB3,
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    QUANTITY TYPE P, " Quantity
    END OF T_ITAB3.
    --Internal table Declaration--
    *Internal tables for the above Declared structures
    DATA: G_VTTK_TAB TYPE TABLE OF T_VTTK_TAB,
    G_ITAB5_TAB TYPE TABLE OF T_ITAB2,
    G_ITAB4_TAB TYPE TABLE OF T_ITAB3,
    G_ITAB3_TAB TYPE TABLE OF T_ITAB2. "#EC NEEDED
    *Internal table Holding Shipment No.and quantity
    DATA: BEGIN OF G_TOTAL_TAB OCCURS 0 ,
    TKNUM TYPE YYLE0003-TKNUM, " Shipment number
    QUANTITY TYPE P,
    COUNT TYPE I,
    END OF G_TOTAL_TAB .
    *Internal table for selection screen data
    DATA: BEGIN OF G_SCANDATA_TAB OCCURS 0,
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    EXIDV TYPE EXIDV, " External Handling Unit
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
    END OF G_SCANDATA_TAB.
    DATA: BEGIN OF ST_SCANDATA_TAB,
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    EXIDV TYPE EXIDV, " External Handling Unit
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
    END OF ST_SCANDATA_TAB.
    DATA: BEGIN OF G_SCANDATA_COUNT_TAB OCCURS 0,
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
    COUNT TYPE I,
    END OF G_SCANDATA_COUNT_TAB.
    DATA: L_COUNT TYPE I.
    *Internal table for Packaging Materials and quantity
    DATA: BEGIN OF G_ITAB6_TAB OCCURS 0,
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    QUANTITY TYPE P, " Quantity
    END OF G_ITAB6_TAB.
    *- Field catalog
    DATA: L_ALV_CAT1_TAB TYPE TABLE OF LVC_S_FCAT.
    --Work area Declaration--
    DATA: WA_VTTK TYPE T_VTTK_TAB,
    WA_ITAB3 TYPE T_ITAB2,
    WA_ITAB5 TYPE T_ITAB2,
    WA_ITAB4 TYPE T_ITAB3,
    WA_ITAB1 LIKE G_SCANDATA_TAB,
    WA_ALV_CAT1 LIKE LINE OF L_ALV_CAT1_TAB.
    ----Variable Defnition -
    DATA: G_CUSTOM_CONTAINER_0100 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
    G_ALV_GRID_0100 TYPE REF TO CL_GUI_ALV_GRID,
    G_CONTAINER_0100 TYPE SCRFNAME VALUE 'LIST',
    G_MYLAYOUT TYPE LVC_S_LAYO, "#EC NEEDED
    G_WA TYPE REF TO DATA.
    DATA: G_VAR TYPE I, " No of records
    G_VAR1 TYPE CHAR20. " Variable
    --field symbols Declaration--
    FIELD-SYMBOLS : <F_FS> TYPE TABLE,
    <F_FS3> TYPE ANY,
    <F_FS4> TYPE ANY,
    <F_FS5> TYPE ANY,
    <F_WA> TYPE ANY,
    <F_FS15> TYPE ANY,
    <F_FS16> TYPE SY-DATUM,
    <F_FS2> TYPE T_ITAB2,
    <F_FS6> TYPE ANY,
    <F_FS7> TYPE ANY,
    <F_FS12> TYPE ANY,
    <F_FS13> TYPE ANY.
    --Selection Parameters--
    SELECTION-SCREEN: BEGIN OF BLOCK BLCK01 WITH FRAME TITLE TEXT-000.
    "Select options
    SELECT-OPTIONS :
    S_TKNUM FOR YYLE0003-TKNUM , " Shipment number
    S_YYREF FOR YYLE0003-YY_REFERENCE, " Packing reference
    S_YYREFT FOR YYLE0003-YY_REFTP, " Reference type
    S_EXIDV FOR YYLE0003-EXIDV, " External HU
    S_MATNR FOR YYLE0003-MATNR, " Material number
    S_VBELN FOR YYLE0003-VBELN, " SD number
    S_POSNR FOR YYLE0003-POSNR, " Item number
    S_LGTOR FOR YYLE0003-LGTOR, " Door for Wr Hs No
    S_VHILM FOR YYLE0003-VHILM, " Packaging Mat
    S_YYMEIN FOR YYLE0003-YY_MEINH, " Indicator for UOM
    S_QUANTI FOR YYLE0003-QUANTITY, " Quantity
    S_YCHECK FOR YYLE0003-YYCHECKED, " Destination_door
    S_STATUS FOR YYLE0003-STATUS, " Packing status
    S_STASHI FOR YYLE0003-STATUSSHIPTO, " Status on ship-to
    S_LOADTR FOR YYLE0003-LOADTRUCK, " Load truck
    S_ERDAT FOR YYLE0003-ERDAT , " Date
    S_ERZET FOR YYLE0003-ERZET, " Entry time
    S_AEDAT FOR YYLE0003-AEDAT, " Last changed on
    S_ERNAM FOR YYLE0003-ERNAM, " Name of Person
    S_AEZET FOR YYLE0003-AEZET, " Time last change
    S_AENAM FOR YYLE0003-AENAM. " Name of person
    SELECTION-SCREEN: END OF BLOCK BLCK01.
    --INITIALIZATION--
    INITIALIZATION.
    Clear the variables and workarea
    CLEAR :G_VAR,
    G_VAR1,
    WA_VTTK,
    WA_ITAB3,
    WA_ITAB5,
    WA_ITAB4,
    WA_ITAB1,
    WA_VTTK,
    WA_ITAB3,
    WA_ITAB5,
    WA_ITAB4,
    WA_ITAB1.
    --AT SELECTION-SCREEN--
    AT SELECTION-SCREEN.
    To validate the data entered in selection screen
    PERFORM SUB_VALIDATE.
    --START-OF-SELECTION--
    START-OF-SELECTION.
    *To fetch the data from table yyle0003
    PERFORM GET_INPUT_DATA.
    *To create the Dynamic Field Catalog
    PERFORM GET_FIELDCAT.
    To populate the data to final table
    PERFORM GET_FINAL_DATA.
    MODULE status_0100 OUTPUT *
    MODULE STATUS_0100 OUTPUT.
    *set title bar and PF status.
    SET PF-STATUS 'ZVKS'.
    SET TITLEBAR 'ZVKS'.
    CHECK SY-UCOMM IS INITIAL.
    SORT G_SCANDATA_TAB BY TKNUM VHILM.
    *Create object for Custom container
    CREATE OBJECT G_CUSTOM_CONTAINER_0100
    EXPORTING
    CONTAINER_NAME = G_CONTAINER_0100
    EXCEPTIONS
    CNTL_ERROR = 1
    CNTL_SYSTEM_ERROR = 2
    CREATE_ERROR = 3
    LIFETIME_ERROR = 4
    LIFETIME_DYNPRO_DYNPRO_LINK = 5.
    *Create object for ALV grid
    CREATE OBJECT G_ALV_GRID_0100
    EXPORTING I_PARENT = G_CUSTOM_CONTAINER_0100.
    G_MYLAYOUT-GRID_TITLE = 'Display Scanning data'.
    *Call method for table Display
    CALL METHOD G_ALV_GRID_0100->SET_TABLE_FOR_FIRST_DISPLAY
    CHANGING
    IT_OUTTAB = <F_FS>
    IT_FIELDCATALOG = L_ALV_CAT1_TAB
    EXCEPTIONS
    INVALID_PARAMETER_COMBINATION = 1
    PROGRAM_ERROR = 2
    TOO_MANY_LINES = 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.
    ENDMODULE. " STATUS_0100 OUTPUT
    *& Module USER_COMMAND_0100 INPUT
    User Interaction
    MODULE USER_COMMAND_0100 INPUT.
    CALL METHOD CL_GUI_CFW=>DISPATCH.
    *To exit , back or cancel
    CASE SY-UCOMM.
    WHEN 'EXIT'.
    LEAVE TO SCREEN 0.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    WHEN 'CANCEL'.
    LEAVE PROGRAM.
    WHEN OTHERS.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    *& Form get_input_data
    This sub routine will get the data from yyle0003 table.
    FORM GET_INPUT_DATA.
    CONSTANTS: C_DOT TYPE C VALUE '.',
    C_CHAR TYPE C VALUE 'D'.
    CLEAR G_SCANDATA_TAB.
    Get the data from yyle0003
    SELECT VHILM " Packaging Materials
    EXIDV " External Handling Unit
    TKNUM " Shipment number
    QUANTITY " Quantity
    FROM YYLE0003
    INTO TABLE G_SCANDATA_TAB
    WHERE TKNUM IN S_TKNUM " Shipment number
    AND YY_REFERENCE IN S_YYREF " Packing reference
    AND YY_REFTP IN S_YYREFT " Reference type
    AND EXIDV IN S_EXIDV " External Handling Unit
    AND MATNR IN S_MATNR " Material number
    AND VBELN IN S_VBELN " SD number
    AND POSNR IN S_POSNR " Item number
    AND LGTOR IN S_LGTOR " Door for warehouse No
    AND VHILM IN S_VHILM " Packaging Materials
    AND YY_MEINH IN S_YYMEIN " Indicator for UOM
    AND QUANTITY IN S_QUANTI " Quantity
    AND YYCHECKED IN S_YCHECK " Destination_door
    AND STATUS IN S_STATUS " Packing status
    AND STATUSSHIPTO IN S_STASHI " Status on ship-to
    AND LOADTRUCK IN S_LOADTR " Load truck
    AND ERDAT IN S_ERDAT " Date
    AND ERZET IN S_ERZET " Entry time
    AND AEDAT IN S_AEDAT " Last changed on
    AND ERNAM IN S_ERNAM " Name of Person
    AND AEZET IN S_AEZET " Time last change
    AND AENAM IN S_AENAM. " Name of person
    If VHILM contains any Decimal '.', replace it with D
    LOOP AT G_SCANDATA_TAB.
    REPLACE C_DOT WITH C_CHAR INTO G_SCANDATA_TAB-VHILM.
    IF SY-SUBRC = 0.
    MODIFY G_SCANDATA_TAB TRANSPORTING VHILM.
    ENDIF.
    CLEAR G_SCANDATA_TAB.
    ENDLOOP.
    *To get the Shipment No Creation date from VTTK.
    SELECT TKNUM
    ERDAT
    FROM VTTK
    INTO TABLE G_VTTK_TAB
    WHERE TKNUM IN S_TKNUM.
    SORT G_SCANDATA_TAB BY VHILM EXIDV. "TKNUM VHILM.
    *To get the repeatition of Pacakaging material for each Shipment.
    *--- to find the count of packaging materials under each shipment
    LOOP AT G_SCANDATA_TAB.
    READ TABLE G_SCANDATA_TAB INTO ST_SCANDATA_TAB INDEX SY-TABIX.
    AT END OF EXIDV.
    L_COUNT = L_COUNT + 1.
    MOVE-CORRESPONDING ST_SCANDATA_TAB TO G_SCANDATA_COUNT_TAB.
    G_SCANDATA_COUNT_TAB-COUNT = L_COUNT.
    CLEAR: ST_SCANDATA_TAB, L_COUNT.
    COLLECT G_SCANDATA_COUNT_TAB.
    ENDAT.
    CLEAR : G_SCANDATA_TAB.
    ENDLOOP.
    ENDFORM. " get_input_data
    *& Form sub_validate
    *This subroutine will validate the data eneterd in the selection screen
    FORM SUB_VALIDATE.
    *Varaiable declaration for Shipment number
    DATA: L_TKNUM TYPE YYLE0003-TKNUM."#EC NEEDED " Shipment number
    *- Condition will not qualify all primary key (IDENT)
    SELECT TKNUM FROM YYLE0003 UP TO 1 ROWS
    INTO L_TKNUM "wa_scandata
    WHERE TKNUM IN S_TKNUM " Shipment number
    AND YY_REFERENCE IN S_YYREF " Packing reference
    AND YY_REFTP IN S_YYREFT " Reference type
    AND EXIDV IN S_EXIDV " External Handling Unit
    AND MATNR IN S_MATNR " Material number
    AND VBELN IN S_VBELN " SD number
    AND POSNR IN S_POSNR " Item number
    AND LGTOR IN S_LGTOR " Door for warehouse No
    AND VHILM IN S_VHILM " Packaging Materials
    AND YY_MEINH IN S_YYMEIN " Indicator for UOM
    AND QUANTITY IN S_QUANTI " Quantity
    AND YYCHECKED IN S_YCHECK " Destination_door
    AND STATUS IN S_STATUS " Packing status
    AND STATUSSHIPTO IN S_STASHI " Status on ship-to
    AND LOADTRUCK IN S_LOADTR " Load truck
    AND ERDAT IN S_ERDAT " Date
    AND ERZET IN S_ERZET " Entry time
    AND AEDAT IN S_AEDAT " Last changed on
    AND ERNAM IN S_ERNAM " Name of Person
    AND AEZET IN S_AEZET " Time last change
    AND AENAM IN S_AENAM. " Name of person
    ENDSELECT.
    IF SY-SUBRC <> 0.
    MESSAGE E987 . " No data found for these selection criterias
    ENDIF.
    ENDFORM. " sub_validate
    *& Form get_fieldcat
    Preparing Field catalog
    FORM GET_FIELDCAT.
    DATA: L_REF TYPE REF TO DATA,
    L_I TYPE I. " Variable
    CONSTANTS: C_CENTER TYPE C VALUE 'C'. " Center Justified
    LOOP AT G_SCANDATA_TAB INTO WA_ITAB1.
    MOVE-CORRESPONDING WA_ITAB1 TO WA_ITAB3.
    APPEND WA_ITAB3 TO G_ITAB3_TAB.
    MOVE-CORRESPONDING WA_ITAB1 TO WA_ITAB4.
    COLLECT WA_ITAB4 INTO G_ITAB4_TAB.
    *To sum up the qunatity field for each TKNUM.
    AT END OF TKNUM.
    SUM.
    MOVE WA_ITAB1-TKNUM TO G_TOTAL_TAB-TKNUM.
    MOVE WA_ITAB1-QUANTITY TO G_TOTAL_TAB-QUANTITY .
    APPEND G_TOTAL_TAB.
    CLEAR G_TOTAL_TAB.
    ENDAT.
    CLEAR : WA_ITAB1,
    WA_ITAB3,
    WA_ITAB4.
    ENDLOOP.
    *--- Begin of change - SKR.EXT - EBDK986377
    SORT G_ITAB4_TAB BY TKNUM.
    *--- End of change - SKR.EXT - EBDK986377
    LOOP AT G_ITAB4_TAB INTO WA_ITAB4.
    MOVE-CORRESPONDING WA_ITAB4 TO WA_ITAB5.
    MOVE-CORRESPONDING WA_ITAB4 TO G_ITAB6_TAB.
    *---- to get the count
    READ TABLE G_SCANDATA_COUNT_TAB WITH KEY TKNUM = WA_ITAB5-TKNUM
    VHILM = WA_ITAB5-VHILM.
    IF SY-SUBRC EQ 0.
    WA_ITAB5-COUNT = G_SCANDATA_COUNT_TAB-COUNT.
    ENDIF.
    APPEND WA_ITAB5 TO G_ITAB5_TAB.
    COLLECT G_ITAB6_TAB.
    ENDLOOP.
    CLEAR : WA_ITAB3.
    SORT G_ITAB4_TAB BY TKNUM VHILM.
    DELETE ADJACENT DUPLICATES FROM G_ITAB4_TAB COMPARING VHILM.
    *To get the Number of fields to be displayed
    DESCRIBE TABLE G_ITAB4_TAB LINES G_VAR.
    L_I = '3'.
    *Field catalog
    WA_ALV_CAT1-FIELDNAME = 'TKNUM'(002).
    WA_ALV_CAT1-COL_POS = 1.
    WA_ALV_CAT1-COLTEXT ='ShipmentNo.'.
    APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
    CLEAR : WA_ALV_CAT1.
    WA_ALV_CAT1-FIELDNAME = 'ERDAT'(003).
    WA_ALV_CAT1-COL_POS = 2.
    WA_ALV_CAT1-COLTEXT ='Creation_Date.'(005).
    APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
    CLEAR : WA_ALV_CAT1.
    Create field catalog for each of VHILM
    LOOP AT G_ITAB4_TAB INTO WA_ITAB4.
    IF G_VAR >= 1.
    CONDENSE WA_ITAB4-VHILM NO-GAPS.
    WA_ALV_CAT1-FIELDNAME = WA_ITAB4-VHILM. "l_fieldname.
    WA_ALV_CAT1-COL_POS = L_I.
    WA_ALV_CAT1-COLTEXT = WA_ITAB4-VHILM.
    WA_ALV_CAT1-JUST = C_CENTER. "'C'.
    APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
    CLEAR WA_ALV_CAT1.
    L_I = L_I + 1.
    ENDIF.
    *TOTAL-last column in the field catalog
    AT LAST.
    WA_ALV_CAT1-FIELDNAME = 'TOTAL'(004).
    WA_ALV_CAT1-COL_POS = L_I.
    WA_ALV_CAT1-COLTEXT = 'TOTAL'(004).
    WA_ALV_CAT1-JUST = C_CENTER. " 'C'.
    APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
    CLEAR WA_ALV_CAT1.
    ENDAT.
    SORT L_ALV_CAT1_TAB BY FIELDNAME.
    *Non of the field name should not get repeated
    DELETE ADJACENT DUPLICATES FROM L_ALV_CAT1_TAB.
    ENDLOOP.
    SORT L_ALV_CAT1_TAB BY COL_POS.
    *Creating Dynamic Internal table
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
    EXPORTING
    IT_FIELDCATALOG = L_ALV_CAT1_TAB
    IMPORTING
    EP_TABLE = L_REF.
    Assigning the Dynamic field Catalog to field symbol.
    ASSIGN L_REF->* TO <F_FS>.
    CREATE DATA G_WA LIKE LINE OF <F_FS>.
    ASSIGN G_WA->* TO <F_WA>.
    DELETE ADJACENT DUPLICATES FROM <F_FS> COMPARING ALL FIELDS.
    ENDFORM. " get_fieldcat
    *& Form display_data
    FORM GET_FINAL_DATA.
    *variable declaration
    DATA: L_TOTAL TYPE I, " Row wise total
    L_FILL TYPE I, " Count
    L_TOT TYPE I. " Grand total
    *To get the TOTAL qunatity in the last line of out put.
    LOOP AT G_ITAB6_TAB.
    CLEAR WA_ITAB5.
    WA_ITAB5-TKNUM = 'TOTAL'(004).
    WA_ITAB5-ERDAT = SPACE.
    MOVE-CORRESPONDING G_ITAB6_TAB TO WA_ITAB5 .
    LOOP AT G_SCANDATA_COUNT_TAB WHERE VHILM = G_ITAB6_TAB-VHILM.
    WA_ITAB5-COUNT = WA_ITAB5-COUNT + G_SCANDATA_COUNT_TAB-COUNT.
    ENDLOOP.
    APPEND WA_ITAB5 TO G_ITAB5_TAB.
    CLEAR WA_ITAB5.
    ENDLOOP.
    DESCRIBE TABLE G_ITAB5_TAB LINES L_TOT.
    *>>>>>>>>
    ****To get total qunatity of all TKNUM
    LOOP AT G_TOTAL_TAB .
    L_TOTAL = L_TOTAL + G_TOTAL_TAB-QUANTITY.
    ENDLOOP.
    *>>>>>>>>
    *To assign ERDAT to g_itab5_tab
    LOOP AT G_ITAB5_TAB INTO WA_ITAB5 .
    READ TABLE G_VTTK_TAB INTO WA_VTTK WITH KEY TKNUM = WA_ITAB5-TKNUM.
    IF SY-SUBRC = 0.
    WA_ITAB5-ERDAT = WA_VTTK-ERDAT.
    MODIFY G_ITAB5_TAB FROM WA_ITAB5 TRANSPORTING ERDAT.
    ENDIF.
    ENDLOOP.
    *Assigning value in each field to respective Field symbols.
    LOOP AT G_ITAB5_TAB ASSIGNING <F_FS2>.
    CLEAR G_TOTAL_TAB-QUANTITY.
    ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <F_FS2> TO <F_FS6>.
    ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <F_WA> TO <F_FS7>.
    <F_FS7> = <F_FS6>.
    CONDENSE <F_FS2>-VHILM NO-GAPS.
    ASSIGN COMPONENT 'VHILM' OF STRUCTURE <F_FS2> TO <F_FS3>.
    ASSIGN COMPONENT 5 OF STRUCTURE <F_FS2> TO <F_FS4>.
    MOVE <F_FS3> TO G_VAR1.
    ASSIGN COMPONENT G_VAR1 OF STRUCTURE <F_WA> TO <F_FS5>.
    <F_FS5> = <F_FS4>.
    ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <F_FS2> TO <F_FS16>.
    ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <F_WA> TO <F_FS15>.
    WRITE <F_FS16> TO <F_FS15> .
    Inorder not to display the date '00/00/000',
    if there is no DATE .
    IF ( <F_FS15> CP '00/*' )
    OR ( <F_FS15> CP '00.*' )
    OR ( <F_FS15> CP '00-*' ).
    <F_FS15> = SPACE.
    ELSEIF ( <F_FS15> CO ' / /' )
    OR ( <F_FS15> CO ' . .' )
    OR ( <F_FS15> CO ' - -' ) .
    <F_FS15> = SPACE.
    ENDIF.
    READ TABLE G_TOTAL_TAB WITH KEY TKNUM = <F_FS6>.
    IF SY-SUBRC = 0.
    ASSIGN G_TOTAL_TAB-QUANTITY TO <F_FS12>.
    ASSIGN COMPONENT 'COUNT' OF STRUCTURE <F_FS2> TO <F_FS12>.
    ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <F_WA> TO <F_FS13>.
    <F_FS13> = <F_FS13> + <F_FS12>.
    L_TOTAL = L_TOTAL + <F_FS12>.
    ENDIF.
    L_FILL = L_FILL + 1.
    IF L_FILL = L_TOT.
    ASSIGN L_TOTAL TO <F_FS12>.
    ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <F_WA> TO <F_FS13>.
    <F_FS13> = <F_FS12>.
    ENDIF.
    AT END OF <F_FS2>-TKNUM.
    APPEND <F_WA> TO <F_FS>.
    CLEAR <F_WA>.
    ENDAT.
    ENDLOOP.
    CLEAR: <F_FS6>,
    <F_FS7>,
    <F_WA>.
    *Call the screen where Custom container is defined
    CALL SCREEN 0100.
    ENDFORM. " display_data
    Regards
    Kannaiah

  • Edit and save dynamic alv.

    Hi Experts
    I have created a dynamic table then filled this dynamic table with the help of field symbols and then passed this dynamic table to grid1->set_table_for_first_display and hence the dynamic alv is shown on the screen. Now, can I do something to make this alv editable and store these values in z table. I have tried the method get_changed_cell method, but no help.
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = LT_LVC_CAT
        IMPORTING
          EP_TABLE        = LP_TABLE.
      ASSIGN LP_TABLE->* TO <LT_DATA>.
    *Create structure = structure of the internal table
      CREATE DATA LP_STRUCT LIKE LINE OF <LT_DATA>.
      ASSIGN LP_STRUCT->* TO <HEADER>.
    *  SORT gt_data BY erdat.
    *sort IT_VEWAO by MATNR.
      LOOP AT IT_VEWZO INTO WA_VEWZO.
        AT NEW VKBUR.
          CLEAR <HEADER>.
          ASSIGN COMPONENT 'VKBUR' OF STRUCTURE <HEADER> TO <FIELD>.
          IF SY-SUBRC NE 0.
            EXIT .
          ENDIF.
          <FIELD> = WA_VEWZO-VKBUR.
        ENDAT.
        MOVE WA_VEWZO-PD_HIER  TO L_COL.
        ASSIGN COMPONENT L_COL OF STRUCTURE <HEADER> TO <FIELD>.
        IF SY-SUBRC NE 0.
          EXIT .
        ENDIF.
        <FIELD> = WA_VEWZO-PLAN_QTY.
        CONCATENATE WA_VEWZO-PD_HIER '_AP' INTO WA_VEWZO-PD_HIER .
        MOVE WA_VEWZO-PD_HIER  TO L_COL.
        ASSIGN COMPONENT L_COL OF STRUCTURE <HEADER> TO <FIELD>.
        IF SY-SUBRC NE 0.
          EXIT .
        ENDIF.
        <FIELD> = WA_VEWZO-APROV_QTY.
        AT END OF VKBUR.
          APPEND <HEADER> TO <LT_DATA>.
        ENDAT .
      ENDLOOP.
    CREATE OBJECT CUSTOM_CONTAINER1
             EXPORTING
                  CONTAINER_NAME = 'CUST_CONT'.
      CREATE OBJECT GRID1
              EXPORTING
                  I_PARENT = CUSTOM_CONTAINER1.
      CALL METHOD grid1->REGISTER_EDIT_EVENT
              EXPORTING
                  i_event_id = cl_gui_alv_grid=>mc_evt_modified.
      CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
    *      I_STRUCTURE_NAME = lv_lp_struct
          IS_LAYOUT        = LS_LAYOUT
        CHANGING
    *      IT_SORT          = LT_SORT1
          IT_FIELDCATALOG  = LT_FIELDCAT
          IT_OUTTAB        = <LT_DATA>.

    Hi,
    What help u need?
    to activate the editable field u need to pass the field catalog parameter
    EDIT = 'X'
    Then Edit values in your alv
    and press enter or define any icons in ur alv list useing user command
    check the changed values using the method
    CALL METHOD g_alvgrid1->check_changed_data( ).
    It will help you i think.
    Regards,
    Nandha

  • Create deep structure to disable some cells in Dynamic ALV GRID

    Hi,
    I want to disable some cells in a Dynamic ALV Grid before calling "SET_tABLE_Display" Method.
    I check the BCALV_EDIT_02, where some cells are grayed out by assign the  CL_GUI_ALV_GRID-MC_STYLE_DISABLED  to the field name.
    But I want the same using Field symbol.
    I'm creating Dynamic table and dynamic structure based on the Dynamic field catalog.
    Example: <FT_TAB> TYPE STANDARD TABLE,
                    <FS_TAB> TYPE ANY,            
    DATA: INT_TAB  is my dynamic table values.
    For the INT_TAB internal table, I created dynamic Structure and dynamic field symbol table.
    LOOP AT INT_TAB.
    ASSIGN COMPONENT 'MATNR'  OF STRUCTURE <FS_TAB> TO <F_VALUE>
    <F_VALUE> = INT_TAB-MATNR.
    APPEND <FS_TAB> TO <FT_TAB>
    "Here is the problem occurs, I want to grayed out the MATNR value based on some condition.
    ENDLOOP.
    I would like to set the 'MATNR' value to be grayed out by passing the CL_GUI_ALV_GRID-MC_STYLE_DISABLED.
    and update into <FT_TAB>(       <FT_TAB> structure will have 2 structures)
    Finally the fieldsymbol should have two structure ( <F_TAB> = DYNAMIC STRUCTURE + LVC_S_STYLE )
    Display alv grid by passing <FT_TAB> to set_table_display method.
    Thanks in advance,
    Kumar.

    Hi,
    I am  not sure whether I really understand your request. Let me try to help.
    > Example: <FT_TAB> TYPE STANDARD TABLE,
    >                 <FS_TAB> TYPE ANY,            
    >
    > DATA: INT_TAB  is my dynamic table values.
    >
    >
    > LOOP AT INT_TAB.
    >  ASSIGN COMPONENT 'MATNR'  OF STRUCTURE <FS_TAB> TO <F_VALUE>
    > <F_VALUE> = INT_TAB-MATNR.
    >  APPEND <FS_TAB> TO <FT_TAB>
    Here <FT_TAB> must already be assigned to some internal table with a given (dynamic) structure. Did this happen before this piece of code?
    What I would do is to create a dynamic table (see documentation to CREATE DATA) with MATNR and the STYLE field (LVC_T_STYL). See the documentation for CREATE DATA - creation of internal tables. When collection the field descriptions for that internal table I would also build the field catalogue for the ALV.
    Then assign <FT_TAB> to that newly created internal table, <FS_TAB> to a newly created structure (same as a table line).
    Move the MATNR to component 1 (or component 'MATNR') of the table and fill the style table according to your needs. Then insert the <FS_TAB> into <FT_TAB>.
    Finally call the ALV SET_TABLE... method with your dynamic table and your field catalogue.
    Regards,
    Gerd Rother

  • ALV and dynamic fields

    Hallo colleagues,
    I have to create a dynamic structure and show it within an ALV.
    Therefore I have created my stuctrure like this:
      MOVE 'COMP1' TO gw_component-name.
      gw_component-type ?= cl_abap_elemdescr=>get_string( ).
      INSERT gw_component INTO TABLE gt_components.
      MOVE 'COMP2' TO gw_component-name.
      gw_component-type ?= cl_abap_elemdescr=>get_i( ).
      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>.
    So now I have my dynamic structure, but how i can create a field catalog, which fit into the function module 'REUSE_ALV_FIELDCATALOG_MERGE' and 'REUSE_ALV_LIST_DISPLAY'?
    Any help?
    Thanks in advance
    Irian

    Hi,
    REPORT zmtable LINE-SIZE 255
                   LINE-COUNT 65.
    Program written by Vijay Chaitanya Raju
    Maintain Table dynamicly (Table name is entered on Selection Screen)
    Very powerfull program. Please maintain authorisation access and
    restrict maintenance to Z-tables
    Version 6.20 and up
    (can be used in 4.6C with some modifications to block try - endtry
    and classes)
    Enhanced functionality with dynamic selection screen
    TABLES: sscrfields.                "Fields on selection screens
    TYPE-POOLS rsds.
    DATA ds_clauses TYPE rsds_where.
    DATA: BEGIN OF ifield OCCURS 0,
          fieldname LIKE dd03l-fieldname,
          position  LIKE dd03l-position,
          keyflag   LIKE dd03l-keyflag,
          datatype  LIKE dd03l-datatype.
    DATA: END OF ifield.
    DATA: sl_step    LIKE sy-tabix,
          ss_step    LIKE sy-subrc,
          ss_act(1)  TYPE c,
          sl_lines   LIKE sy-tfill,
          sl_status  LIKE sy-subrc,
          sl_subrc   LIKE sy-subrc,
          sl_update(1) TYPE c,
          sl_mandt(1)  TYPE c,
          len(6)       TYPE n,
          f_value(255) TYPE c,
          sl_datum     LIKE sy-datum,
          sl_uzeit     LIKE sy-uzeit,
          price1(15)   TYPE c,
          price2(15)   TYPE c,
          mess(60)     TYPE c,
          d_stat   LIKE sy-subrc,
          m_stat   LIKE sy-subrc,
          slchar(6) TYPE c.
    DATA: ref_ptr TYPE REF TO cx_root.      "Root class more common
    DATA: text TYPE string.
    DATA: sl_index LIKE sy-tabix.
    DATA: zauth LIKE dd02l-tabname.
    DATA: num TYPE i,
          max_len TYPE i,
          check_len TYPE i,
          sl_sel(1) TYPE c.
    TYPE-POOLS: icon.
    SELECTION-SCREEN.
    SELECTION-SCREEN BEGIN OF LINE.
    text-012 - 'Table Name'
    SELECTION-SCREEN COMMENT 1(25) text-012.
    PARAMETERS: tabname LIKE dd02l-tabname DEFAULT 'ZSCARE'.
    text-003 - 'Selection'
    SELECTION-SCREEN PUSHBUTTON 75(9) text-003 USER-COMMAND sta1.
    SELECTION-SCREEN END OF LINE.
    numrows(text) - 'Max Number of ROWS'
    PARAMETERS: numrows LIKE sy-subrc DEFAULT '100'.
    At Selection-Screen                                                 *
    AT SELECTION-SCREEN.
      CASE sscrfields-ucomm.
        WHEN 'STA1'.
          CLEAR sl_sel.
          CALL FUNCTION 'ZSTAN_SELECTIONS'
            EXPORTING
              tabname         = tabname
            IMPORTING
              ds_clauses      = ds_clauses
            EXCEPTIONS
              table_not_valid = 1
              other_error     = 2
              OTHERS          = 3.
          IF sy-subrc = 0.
            sl_sel = 'X'.
          ENDIF.
      ENDCASE.
    *At Selection-Screen Output                                            *
    AT SELECTION-SCREEN OUTPUT.
      SELECT SINGLE tabname
        INTO tabname
        FROM dd02l
        WHERE tabname  = tabname
          AND as4local = 'A'
          AND ( tabclass = 'TRANSP' OR tabclass = 'POOL'
                OR tabclass = 'CLUSTER' ).
      IF sy-subrc <> 0.
        MESSAGE 'Table is not valid' TYPE 'S'.
        RETURN.
      ENDIF.
    START-OF-SELECTION.
    START-OF-SELECTION.
      DEFINE: acheck.
        zauth = 'ZTABAUTH'.
        select single statu
          into sl_update
          from (zauth)
          where tabname = tabname
            and bname   = sy-uname.
        if sy-subrc <> 0.
          message 'You are not authorized to view this table' type 'S'.
          return.
        endif.
      END-OF-DEFINITION.
      SELECT SINGLE tabname
        INTO tabname
        FROM dd02l
        WHERE tabname  = tabname
          AND as4local = 'A'
          AND ( tabclass = 'TRANSP' OR tabclass = 'POOL'
                OR tabclass = 'CLUSTER' ).
      IF sy-subrc <> 0.
        MESSAGE 'Table is not valid' TYPE 'S'.
        RETURN.
      ENDIF.
      DATA: ptr_itab TYPE REF TO data.
      FIELD-SYMBOLS: <fs_itab> TYPE STANDARD TABLE. "ANY TABLE.
      CREATE DATA ptr_itab TYPE STANDARD TABLE OF (tabname).
      ASSIGN ptr_itab->* TO <fs_itab>.
    For DELETION
      DATA: ptr_itd TYPE REF TO data.
      FIELD-SYMBOLS: <fs_itd> TYPE STANDARD TABLE.
      CREATE DATA ptr_itd TYPE STANDARD TABLE OF (tabname).
      ASSIGN ptr_itd->* TO <fs_itd>.
    For MODIFICATION
      DATA: ptr_itm TYPE REF TO data.
      FIELD-SYMBOLS: <fs_itm> TYPE STANDARD TABLE.
      CREATE DATA ptr_itm TYPE STANDARD TABLE OF (tabname).
      ASSIGN ptr_itm->* TO <fs_itm>.
      DATA: ptr_wtab TYPE REF TO data.
      FIELD-SYMBOLS: <fs_wtab> TYPE ANY.
      CREATE DATA ptr_wtab TYPE (tabname).
      ASSIGN ptr_wtab->* TO <fs_wtab>.
      DATA: itabname(15) TYPE c.
      itabname = '<fs_wtab>'.
    Standard list status with 'SAVE' button
      SET PF-STATUS 'STLI'.
      CLEAR sl_update.
    Maintain authorisation access in table ZTABAUTH
    Key fields:  tabname - Table name
                 bname   = sy-uname - User name
                 statu   = 'X' - maintain
                           ' ' - view
    Check authorisation access
      acheck.
      SELECT fieldname position keyflag datatype
        INTO TABLE ifield
        FROM dd03l
        WHERE tabname = tabname
          AND fieldname NOT LIKE '.INCLU%'
        ORDER BY position.
      FIELD-SYMBOLS: <f1> TYPE ANY.
      DATA: tab_field(60) TYPE c,
            sline LIKE sy-lisel.
      DATA: field_attr LIKE dfies.
      DATA: BEGIN OF tfield_attr OCCURS 0.
              INCLUDE STRUCTURE field_attr.
      DATA: END OF tfield_attr.
      LOOP AT ifield.
        CALL FUNCTION 'G_FIELD_READ'
          EXPORTING
            table      = tabname
            fieldname  = ifield-fieldname
            text_flag  = 'X'
          IMPORTING
            field_attr = field_attr.
        tfield_attr = field_attr.
        APPEND tfield_attr.
      ENDLOOP.
      IF sl_sel = 'X'.
        SELECT *
          FROM (tabname)
          INTO TABLE <fs_itab> UP TO numrows ROWS
          WHERE (ds_clauses-where_tab).
      ELSE.
        SELECT *
          FROM (tabname)
          INTO TABLE <fs_itab> UP TO numrows ROWS.
      ENDIF.
      DESCRIBE TABLE <fs_itab> LINES sl_lines.
    Show two extra lines to allow addition up to 2 new lines
      IF sl_update = 'X'.
        DO 2 TIMES.
          APPEND INITIAL LINE TO <fs_itab>.
        ENDDO.
      ENDIF.
      DATA: info(22) VALUE 'D - Delete, M - Modify'.
      WRITE: / icon_information AS ICON QUICKINFO info.
      WRITE ' '.
      CLEAR check_len.
      LOOP AT tfield_attr.
        IF tfield_attr-datatype = 'CLNT'.
          CONTINUE.
        ENDIF.
        len = tfield_attr-outputlen.
        IF tfield_attr-keyflag = 'X'.
          check_len = check_len + len + 1.
        ENDIF.
        IF tfield_attr-scrtext_m IS NOT INITIAL.
          WRITE: AT (len) tfield_attr-scrtext_m COLOR 1.
        ELSE.
          WRITE: AT (len) tfield_attr-fieldtext COLOR 1.
        ENDIF.
      ENDLOOP.
      CLEAR ss_step.
      CLEAR ss_act.
      LOOP AT <fs_itab> INTO <fs_wtab>.
        IF sy-tabix LE sl_lines.
          ss_step = 1.
        ELSE.
          CLEAR ss_step.
        ENDIF.
    In field SS_STEP put D -  to delete record
                         M -  to modify/add new record
        IF sl_update = 'X'.
          WRITE:/ icon_change AS ICON.
          IF ss_step = 1.
            WRITE:  ss_act INPUT ON.
          ELSE.
            ss_act = 'M'.
            WRITE:  ss_act.
            CLEAR ss_act.
          ENDIF.
        ELSE.
          WRITE:/ icon_display AS ICON.
          WRITE:  ss_act COLOR 2.
        ENDIF.
        LOOP AT ifield.
    Maintain client dependant tables in the same client
          IF ifield-datatype = 'CLNT'.
            sl_mandt = 'X'.
            CONTINUE.
          ENDIF.
          CONCATENATE itabname '-' ifield-fieldname INTO tab_field.
          ASSIGN (tab_field) TO <f1>.
          IF sl_update = 'X'.
            IF ifield-keyflag = 'X' AND ss_step IS NOT INITIAL.
              WRITE: <f1> COLOR 4.
            ELSE.
              WRITE: <f1> INPUT ON.
            ENDIF.
          ELSE.
            IF ifield-keyflag = 'X' AND ss_step IS NOT INITIAL.
              WRITE: <f1> COLOR 4.
            ELSE.
              WRITE: <f1> COLOR 2.
            ENDIF.
          ENDIF.
          UNASSIGN <f1>.
        ENDLOOP.
      ENDLOOP.
    END-OF-SELECTION.
    END-OF-SELECTION.
    AT USER-COMMAND.
    AT USER-COMMAND.
      CASE sy-ucomm.
        WHEN 'SAVE'.
          IF sl_update = 'X'.
            CLEAR: sl_step,
                   sl_status,
                   sl_subrc,
                   <fs_wtab>,
                   d_stat,
                   m_stat,
                   max_len.
            REFRESH <fs_itd>.
            REFRESH <fs_itm>.
            DO.
              IF sl_status <> 0.
                EXIT.
              ENDIF.
              ADD 1 TO sl_step.
              IF sl_subrc <> 0.
                EXIT.
              ENDIF.
              CLEAR ss_step.
              CLEAR ss_act.
              READ LINE sl_step
                   FIELD VALUE ss_act INTO f_value.
              sl_subrc = sy-subrc.
              IF f_value(1) EQ 'D' OR f_value(1) = 'd'.
                ss_step = 1.  "Delete
              ELSEIF f_value(1) EQ 'M' OR f_value(1) = 'm'.
                ss_step = 2.  "Modify
              ELSE.
                CLEAR ss_step.
              ENDIF.
              CHECK sy-lisel(3) = '0Z '.
              IF ss_step GT 0.
                CLEAR sline.
                sline = sy-lisel+5(250).
                max_len = 250.
                CHECK sline(check_len) <> ' '.
                LOOP AT tfield_attr.
                  CONCATENATE itabname '-' tfield_attr-fieldname
                                                  INTO tab_field.
                  ASSIGN (tab_field) TO <f1>.
                  IF tfield_attr-fieldname = 'MANDT'.
                    <f1> = sy-mandt.
                  ELSE.
                    CLEAR f_value.
                    IF max_len LT tfield_attr-outputlen.
                      max_len = 255.
                      ADD 1 TO sl_step.
                      READ LINE sl_step.
                      sline = sy-lisel.
                    ENDIF.
                    f_value = sline(tfield_attr-outputlen).
                    max_len = max_len - tfield_attr-outputlen - 1.
                    IF tfield_attr-inttype = 'D'.
                      IF f_value CO ' 0./-'.
                        CLEAR sl_datum.
                        <f1> = sl_datum.
                      ELSE.
                        CALL FUNCTION 'CONVERT_DATE_INPUT'
                          EXPORTING
                            input                     = f_value
                            plausibility_check        = 'X'
                          IMPORTING
                            output                    = sl_datum
                          EXCEPTIONS
                            plausibility_check_failed = 1
                            wrong_format_in_input     = 2
                            OTHERS                    = 3.
                        IF sy-subrc = 0.
                          <f1> = sl_datum.
                        ELSE.
                          text = 'Invalid Date'.
                          sl_status = 1.
                          EXIT.
                        ENDIF.
                      ENDIF.
                    ELSEIF tfield_attr-inttype = 'T'.
                      IF f_value CO ' 0:'.
                        CLEAR sl_uzeit.
                        <f1> = sl_uzeit.
                      ELSE.
                        CALL FUNCTION 'CONVERT_TIME_INPUT'
                          EXPORTING
                            input                     = f_value
                            plausibility_check        = 'X'
                          IMPORTING
                            output                    = sl_uzeit
                          EXCEPTIONS
                            plausibility_check_failed = 1
                            wrong_format_in_input     = 2
                            OTHERS                    = 3.
                        IF sy-subrc = 0.
                          <f1> = sl_uzeit.
                        ELSE.
                          text = 'Invalid Time'.
                          sl_status = 1.
                          EXIT.
                        ENDIF.
                      ENDIF.
                    ELSEIF tfield_attr-inttype = 'C'.
                      TRANSLATE f_value TO UPPER CASE.
                      <f1> = f_value.
                    ELSE.
                      TRANSLATE f_value USING ', '.
                      CONDENSE f_value NO-GAPS.
                      TRY.
                          <f1> = f_value.
                        CATCH cx_root INTO ref_ptr.
                          text = ref_ptr->get_text( ).
                          sl_status = 1.
                          EXIT.
                      ENDTRY.
                    ENDIF.
                    SHIFT sline BY tfield_attr-outputlen PLACES.
                    SHIFT sline LEFT.
                  ENDIF.
                  UNASSIGN <f1>.
                ENDLOOP.
                IF sl_status = 0.
                  CASE ss_step.
                    WHEN 1.  "Delete
                      ADD 1 TO d_stat.
                      APPEND <fs_wtab> TO <fs_itd>.
                    WHEN 2.  "Modify
                      ADD 1 TO m_stat.
                      APPEND <fs_wtab> TO <fs_itm>.
                  ENDCASE.
                ENDIF.
              ENDIF.
            ENDDO.
            IF sl_status = 0.
              IF d_stat IS NOT INITIAL.
                slchar = d_stat.
                CONCATENATE 'Deleted -' slchar 'record.' INTO text
                  SEPARATED BY space.
                DELETE (tabname) FROM TABLE <fs_itd>.
              ENDIF.
              IF m_stat IS NOT INITIAL.
                slchar = m_stat.
                CONCATENATE text 'Modified -' slchar 'record.' INTO text
                  SEPARATED BY space.
                MODIFY (tabname) FROM TABLE <fs_itm>.
              ENDIF.
              IF d_stat IS INITIAL AND m_stat IS INITIAL.
                MESSAGE 'No changes were done' TYPE 'S'.
              ELSE.
                MESSAGE text TYPE 'S'.
              ENDIF.
              LEAVE.
            ELSE.
              MESSAGE text TYPE 'I'.
              EXIT.
            ENDIF.
          ELSE.
            LEAVE.
          ENDIF.
      ENDCASE.
    *--END--
    Below is Function for a Dynamic Selection Screen
    FUNCTION zstan_selections.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(TABNAME) LIKE  DD02L-TABNAME DEFAULT 'ZSCARE'
    *"  EXPORTING
    *"     VALUE(DS_CLAUSES) TYPE  RSDS_WHERE
    *"  EXCEPTIONS
    *"      TABLE_NOT_VALID
    *"      OTHER_ERROR
      DATA texpr TYPE rsds_texpr.
      DATA twhere TYPE rsds_twhere.
      DATA trange TYPE rsds_trange.
      DATA BEGIN OF qcat.                    "Selections View for
              INCLUDE STRUCTURE rsdsqcat.    "Free Selectoptions
      DATA END OF qcat.
      DATA BEGIN OF tabs OCCURS 10.
              INCLUDE STRUCTURE rsdstabs.
      DATA END   OF tabs.
      DATA BEGIN OF fields OCCURS 10.
              INCLUDE STRUCTURE rsdsfields.
      DATA END   OF fields.
      DATA BEGIN OF efields OCCURS 10.
              INCLUDE STRUCTURE rsdsfields.
      DATA END   OF efields.
      DATA selid LIKE rsdynsel-selid.
      DATA actnum LIKE sy-tfill.
      DATA title LIKE sy-title VALUE 'Selection Screen'.
      DATA: maxnum LIKE sy-subrc VALUE '69'.
      CLEAR    tabs.
      tabs-prim_tab = tabname.
      COLLECT  tabs.
      DATA: position LIKE dd03l-position.
      DATA: keyflag  LIKE dd03l-keyflag.
      CLEAR fields.
      fields-tablename = tabname.
      fields-sign      = 'I'.
      DATA: step LIKE sy-subrc.
      SELECT fieldname keyflag position
        INTO (fields-fieldname, keyflag, position)
        FROM dd03l
        WHERE tabname = tabname
          AND fieldname NOT LIKE '.INCLU%'
          AND datatype NE 'CLNT'
        ORDER BY position.
        ADD 1 TO step.
        CHECK step LE maxnum.
        IF keyflag <> 'X'.
          efields = fields.
          APPEND efields.
        ENDIF.
        APPEND fields.
      ENDSELECT.
      IF sy-subrc <> 0.
        RAISE table_not_valid.
      ENDIF.
      CALL FUNCTION 'FREE_SELECTIONS_INIT'
        EXPORTING
          expressions              = texpr
          kind                     = 'F'
        IMPORTING
          selection_id             = selid
          expressions              = texpr
          where_clauses            = twhere
          field_ranges             = trange
          number_of_active_fields  = actnum
        TABLES
          tables_tab               = tabs
          fields_tab               = fields
          fields_not_selected      = efields
        EXCEPTIONS
          fields_incomplete        = 01
          fields_no_join           = 02
          field_not_found          = 03
          no_tables                = 04
          table_not_found          = 05
          expression_not_supported = 06
          incorrect_expression     = 07
          illegal_kind             = 08
          area_not_found           = 09
          inconsistent_area        = 10
          kind_f_no_fields_left    = 11
          kind_f_no_fields         = 12
          too_many_fields          = 13.
      IF sy-subrc = 0.
        CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
          EXPORTING
            selection_id            = selid
            title                   = title
          IMPORTING
            where_clauses           = twhere
            expressions             = texpr
            field_ranges            = trange
            number_of_active_fields = actnum
          TABLES
            fields_tab              = fields
          EXCEPTIONS
            internal_error          = 01
            no_action               = 02
            no_fields_selected      = 03
            no_tables_selected      = 04
            selid_not_found         = 05.
        IF sy-subrc = 0.
          CLEAR ds_clauses.
          MOVE tabname TO ds_clauses-tablename.
          READ TABLE twhere WITH KEY ds_clauses-tablename INTO ds_clauses.
          IF sy-subrc <> 0.
            RAISE other_error.
          ENDIF.
        ELSE.
          RAISE other_error.
        ENDIF.
      ELSE.
        RAISE other_error.
      ENDIF.
    ENDFUNCTION.
    Regards,
    Shiva

  • Create dynamic internal table with deep structure;cell coloring dynamic ALV

    Hi,
    My requirement is to do cell colouring for a dynamic ALV.
    So I am creating a dynamic internal table using the following method.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = i_fieldcatalog[]
        IMPORTING
          ep_table        = i_output.
    But how do I define field COLORS which should be again an internal table ?
    Is there any other way for cell colouring?
    Putting my problem in another way:
    How do I create a dynamic internal table with one field as another internal table.
    Quick replies are highly appreciated.
    Thanks,
    Nisha Vengal.

    halo Nisha
    Before building the display table . you can add the field in the feild catalog right . This display table gets generated from the field catalog right
    1 Create a global structute say ZEXTEND_FIELDCAT
    2 Have fields like STYLE type lvc_t_styl
                             COLOR type LVC_T_SCOL.
    3 Now you have to extend ur fieldcatalog
      l_fieldcat-fieldname = COLOR'.
      l_fieldcat-ref_field = 'COLOR'.
      l_fieldcat-ref_table = 'ZEXTEND_FIELDCAT'.
      APPEND l_fieldcat TO lt_field_catalog.
      CLEAR l_fieldcat.

Maybe you are looking for

  • Error Determining Smartform - Smartform working in Development but not in Q

    Hello all, I'm currenlty working on a smartform in a development box and it is working as expected after doing the testing in that box but after transporting the change to Q, the new changes are not displayed in the smartform. I already revised the c

  • Variable in Text Caption in Html5

    I am trying to display the contents of a variable on a slide so I am using a text caption.  It works fine on my PC, but on the iPad, where it is using Html5, only the initial value of the variable is being displayed. I've tried delaying when the capt

  • Audio level drop after exporting from FCP to Comp

    my dialnorm at -31db, precompressor compression setting @ none, any other setting i need to look at??

  • Apparent bios bug when there is no video card

    I have a system that shouldn't use a video card. I have tested several KT4V and they all hang when there is no video card, even though the bios is set to "Primary Display: Absent". Any suggestions of a workaround will be highly appreciated. Thanks

  • Bulk insert returns ORA-02291

    When bulk inserting with BindArrayOfStruct when a row fails with ORA-02291 all remaining valid rows fail with the same error. If the invalid row is removed from the array the other rows are inserted. If a row fails with another error all remaining ro