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

Similar Messages

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

  • Dynamic internal table and dynamic field catalog

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

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

  • ALV Report dynamically fields i want to display

    Hi experts,
    how to declare dynamical fields in ALV reports not in oops.can i use fieldcat merge function mod for this requirement.pls write the code if possible.

    Hi,
    how to declare dynamical fields in ALV reports not in oops. ? I didnt understand what exactly you mean ? Do you want to build an internal table which is of dynamic in nature ?
    can i use fieldcat merge function mod for this requirement.  No
    pls write the code if possible. No one writes the code here. Paste your code here !! If there any mistakes, any one of the SDNer will let you know !!
    If you want the internal table to be dynamically created, check the following link:
    Re: Dynamic Table with Validation
    Regards
    Kannaiah

  • Fixed and dynamic field headings in field catalog

    i have to develop an ALV Report where certain column headings are fixed and other column heading will be changing from time to time.
    is there any method to do so.
    that is i have to show the report for 3 months and the names of months will be changing in due course.
    Waiting for a reply.
    A.Reshma

    hi,
    you have 4 texts
    SELTEXT_L
    SELTEXT_M
    SELTEXT_S
    and   DDIC_TEXT  (not sure about spelling)
    change this text dynamicly with month of your choice.
    Rgds

  • ALV and Dynpro-Fields

    Hi!
    I've created a dynpro with an ALV-Grid for Data-Overview and a lot of fields on the dynpro to change/insert additional data.
    How can I read data back from the dynpro fields when changing the selected row at the ALV.
    At the time of handling the event, the data entered on the dynpro isn't actual available in my coding.
    Thanks for any hints!
    Peter

    Hi!
    This is the dynpro-logic:
    process before output.
      module status_9210.
      module vorschlag_9210.
      call subscreen g_buch_button
        including sy-repid g_buch_button_subscreen.
    process after input.
      chain.
        field: zhrtv_planzusatz-buch_status,
               zhrtv_planzusatz-buchungscode.
      endchain.
      chain.
        field: zhrtv_planzusatz-betrg,
               zhrtv_planzusatz-waers.
      endchain.
      module save_data_9210.
    The PBO-Coding is just do fill the ALV-Grid and switch some dynpo-fields.
    In the module save_data_9210 the entered data is saved to the corresponding structures.
    Thanks for help!
    Peter

  • Struts and Dynamic Fields of a Form

    Hi all,
    There's a form in a struts based web-application in which some fields will be made according to some variable parameters. I mean number of those text type fields may vary.
    Any idea for building ActionForm class such that fields of that formBean be set automatically? I tried following solution :
    <input type="text" name="varName" value="aaa" >
    <input type="text" name="varName" value="bbb" >
    <input type="text" name="varName" value="ccc" >
    class MyForm extends ..... {
    private String varName[];
    public String[] getVarName() {}
    public void setVarName(String[] varName) {
    this.varName = varName;
    In this case I am able to retrieve correct values in the Action Class. But when the form is populated with the values, it is not showing correct results. The reason behind this is I am unable to bind first text box with varName[0] and second with varName[1]. Please suggest solution.
    Thanks and regards,
    Sneha

    Why don't you create the text boxes dynamically in the jsp?
    <logic:iterate id="beanArray" name="yourBean">
    <input type="text" name='<bean:write name="beanArray" property="beanName"/>' value='<bean:write name="beanArray" property="beanName"/>'>
    </logic:iterate>

  • ALV and Input field

    Dear experts,
    my problem is as follows.
    in my ALV i want to make a column that is only editable with a field help.
    read_only doesn´t work because the field can´t be edited by the field help.
    Can you give me a hint.
    Thanks and best regards
    René

    Hey!
    At first,you need to set entire alv table as editable.
    DATA: LR_CMP_USAGE           TYPE REF TO IF_WD_COMPONENT_USAGE,
            LR_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,
            LR_CONFIG_TABLE        TYPE REF TO CL_SALV_WD_CONFIG_TABLE,
            LR_SALV_SETTINGS       TYPE REF TO IF_SALV_WD_TABLE_SETTINGS,
            LR_COLUMN              TYPE REF TO CL_SALV_WD_COLUMN,
            LR_INPUTFIELD          TYPE REF TO CL_SALV_WD_UIE_INPUT_FIELD,
            LR_TEXTVIEW            TYPE REF TO CL_SALV_WD_UIE_TEXT_VIEW.
      LR_CMP_USAGE = WD_THIS->WD_CPUSE_ALV_GRID( ).
      IF LR_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
        LR_CMP_USAGE->CREATE_COMPONENT( ).
      ENDIF.
      LR_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ALV_GRID( ).
      LR_CONFIG_TABLE = LR_INTERFACECONTROLLER->GET_MODEL( ).
      LR_SALV_SETTINGS ?= LR_CONFIG_TABLE.
      CALL METHOD LR_SALV_SETTINGS->SET_READ_ONLY
        EXPORTING
          VALUE  = ABAP_FALSE.
      LR_COLUMN = LR_CONFIG_TABLE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'LUGGWEIGHT' ).
      CREATE OBJECT LR_INPUTFIELD
        EXPORTING
          VALUE_FIELDNAME = 'LUGGWEIGHT'.
      CALL METHOD LR_INPUTFIELD->SET_READ_ONLY
        EXPORTING
          VALUE  = ABAP_FALSE.
      CALL METHOD LR_INPUTFIELD->SET_ALIGNMENT
        EXPORTING
          value  = CL_WD_ABSTRACT_INPUT_FIELD=>E_ALIGNMENT-CENTER.
      CALL METHOD LR_COLUMN->SET_CELL_EDITOR
        EXPORTING
          VALUE  = LR_INPUTFIELD.

  • Dynamic field in select statment.

    Hello,
    I created a report in which i have two checkboxes in the selection screen. The first checkbox is for the option to bring or not, initial purchase requisitions (BANFN) from EKPO and the second is to bring initial or not, RFQs
    (ANFNR). I want the select statment to have this form:
    select ...
    from ekpo
    into g_table
    where ..
    and dynamic field = " ".
    Can this be done ?
    i tried to put it as a string but it didnt work. (data: dynamic field type string value "EKPO-BANFN")
    P.S i know that it can be by writing the same select code twice.
    I just wonder if this can be done by this way
    \Regards.

    Hey Nick,
    I have more conditions than the one i said before , should all be in the lv_where_clause ?
    check my code.
    DATA: G_CHBFLD type STRING.
    G_CHBFLD = 'P~BANFN = '' " '.
    FORM SELECT_DATA_EKPO_EKKO.
      SELECT  .....
          FROM EKPO AS P INNER JOIN EKKO AS K
            ON PEBELN = KEBELN
              INTO CORRESPONDING FIELDS OF TABLE GT_EKPOEKKO
                WHERE K~EBELN IN S_EBELN
                AND K~AEDAT IN S_AEDAT
                AND K~BSTYP IN S_BSTYP
                and ( G_CHBFLD ) .   -
    > //DEBUGER ")" is not a valid comparison operator. comparison operator.

  • ALV display using dynamic field catalog and dynamic internal table

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

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

  • How to populate field catalogue fields in ALV using  dynamic internal table

    Hi All,
    Please let me know how to populate field catalogue fields in ALV using  dynamic internal table.
    I have created <dyn_table> using code below.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
                     EXPORTING
                       it_fieldcatalog = g_t_ifc
                        it_fieldcatalog = g_t_fieldcat
                     IMPORTING
                        ep_table        = dy_table.
      ASSIGN dy_table->* TO <dyn_table>.
    Create dynamic work area and assign to FS
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
    Now this  <dyn_table>  has fields like idoc no.,creation date ,
    segment field 1, segment field 2 etc..Now idoc no.,creation date  are static fields from table EDIDC. And segment field 1, segment field 2 etc are dynamic fields from table EDSAPPL.
    In my  ALV report I am getting the final layout properly but I am unable to move values to corresponding fields in the final layout shown.Please let me know how to populate these fields from different tables.
    I tried this way but its not working.
    SORT g_t_edid4 BY docnum.
      LOOP AT g_t_edidc INTO g_r_edidc.
        READ TABLE g_t_edid4 into g_r_edid4
                         WITH KEY docnum = g_r_edidc-docnum
                                        BINARY SEARCH.
        IF sy-subrc = 0.
          <dyn_wa> =  g_r_edid4-sdata.
         MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
       CLEAR g_r_edid4.
        ENDIF.
    MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
    APPEND <dyn_wa> TO <dyn_table>.

    You have to assign each field to field symbol and then assign the value to that field symbol and asssign that field symbol to workarea field symbol.
    LOOP AT g_t_edidc INTO g_r_edidc.
    READ TABLE g_t_edid4 into g_r_edid4
    WITH KEY docnum = g_r_edidc-docnum
    BINARY SEARCH.
    IF sy-subrc = 0.
    ASSIGN COMPONENT 'SDATA' OF STRUCTURE <DYN_WA> TO <DYN_FLD>.
    <DYN_FLD> = g_r_edid4-sdata.
    " <dyn_wa> = g_r_edid4-sdata.
    " Assign each fields like this.
    " MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
    CLEAR g_r_edid4.
    ENDIF.
    " MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
    APPEND <dyn_wa> TO <dyn_table>.
    Regards,
    Naimesh Patel

  • Reg: Dynamic Field catalog in ALV

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

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

  • 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

  • Dynamic fields to be displayed in ALV

    Hi All,
    I've a requirement like this.
    I have table type with 10 fields and I use this to display data in ALV.  Now, I need to add few dynamic columns (based on customizing) and show in the same ALV.  Since these fields are dynamic and new fields can also be added in the future, I can not enhance the structure I am using at present.  So, the solution would be to add dynamic columns to the output table that is sent to ALV display.
    Adding fields to field catalogue is not a big ask and I am already done with that.  Moreover, I have tried enhancing the current structure with a field of type DATA and populated it. 
    But, technically, it is a single field and cannot be split into the different new fields at the time of output. 
    How is this possible?  Please provide me with example code also, if you have.
    Thanks in advance,
    Srinath.

    Hi Srinath,
    I for this purpose I use my own solution since a couple of years with success. It was originally developed for ALV functions module. In OO the field catalo has a slightly different structure, nut one can be easily converted into the other using function module (don't remember the name right now).
    Recently I created a class with static functional methods for this:
    METHOD fieldcat_alv .
      TYPE-POOLS:
        sydes.
      DATA:
        lv_desc                               TYPE sydes_desc,
        ls_alv_fieldcat                       TYPE slis_fieldcat_alv,
        lv_longfield                          TYPE dynfnam.
      FIELD-SYMBOLS:
        <typeinfo>                            TYPE sydes_typeinfo,
        <nameinfo>                            TYPE sydes_nameinfo.
      DESCRIBE FIELD it_table INTO lv_desc.                     "#EC *
      LOOP AT lv_desc-types
          ASSIGNING <typeinfo>
          WHERE NOT idx_name IS INITIAL
            AND table_kind IS INITIAL "no entries for deep table like color
            AND back                          = 2. "top-level-entries only.
        READ TABLE lv_desc-names INDEX <typeinfo>-idx_name
          ASSIGNING <nameinfo>.
        CHECK <nameinfo>-name                 <> 'INCLUDE'.
        ls_alv_fieldcat-fieldname             = <nameinfo>-name.
        WHILE NOT <nameinfo>-continue IS INITIAL.
          ADD 1 TO <typeinfo>-idx_name.
          READ TABLE lv_desc-names INDEX <typeinfo>-idx_name
            ASSIGNING <nameinfo>.
          CONCATENATE
            ls_alv_fieldcat-fieldname
            <nameinfo>-name
            INTO ls_alv_fieldcat-fieldname.
        ENDWHILE." not <nameinfo>-continue IS INITIAL.
        READ TABLE lv_desc-names INDEX <typeinfo>-idx_help_id
          ASSIGNING <nameinfo>.
        IF sy-subrc                           = 0.
    * Caution: Help-ID may be Tablename-Fieldname and thus longer
    * than 30 Chars; ls_alv_fieldcat-rollname is 30 Chars only
          ls_alv_fieldcat-rollname            = <nameinfo>-name.
          lv_longfield                        = <nameinfo>-name.
          WHILE NOT <nameinfo>-continue IS INITIAL.
            ADD 1 TO <typeinfo>-idx_help_id.
            READ TABLE lv_desc-names INDEX <typeinfo>-idx_help_id
              ASSIGNING <nameinfo>.
            CONCATENATE
              lv_longfield
              <nameinfo>-name
              INTO lv_longfield.
          ENDWHILE." not lv_desc-continue is initial.
    * help id may be data element or <table>-<field>
          IF lv_longfield CA '-'.
    * get datatype for table field
            CALL METHOD get_rollname_4_tabfield
              EXPORTING
                iv_fieldname    = lv_longfield
              CHANGING
                cs_alv_fieldcat = ls_alv_fieldcat.
          ENDIF." lv_longfield ca '-'.
        ELSE.
    * No Help-ID: Use Fieldname as text
          ls_alv_fieldcat-seltext_s           =
          ls_alv_fieldcat-seltext_m           =
          ls_alv_fieldcat-seltext_l           =
          ls_alv_fieldcat-reptext_ddic        =
          <nameinfo>-name.
        ENDIF." sy-subrc                      = 0.
    * Starting 4.7: get edit mask
        IF NOT <typeinfo>-idx_edit_mask IS INITIAL.
          READ TABLE lv_desc-names INDEX <typeinfo>-idx_edit_mask
            ASSIGNING <nameinfo>.
          ls_alv_fieldcat-edit_mask           = <nameinfo>-name.
          IF NOT <nameinfo>-continue IS INITIAL.
            ADD 1 TO <typeinfo>-idx_edit_mask.
            READ TABLE lv_desc-names INDEX <typeinfo>-idx_edit_mask
              ASSIGNING <nameinfo>.
            CONCATENATE
              ls_alv_fieldcat-edit_mask
              <nameinfo>-name
              INTO ls_alv_fieldcat-edit_mask.
          ENDIF." not <nameinfo>-continue IS INITIAL.
        ENDIF." not <typeinfo>-IDX_EDIT_MASK is initial.
    * assign length, output length and decimals
        ls_alv_fieldcat-intlen                = <typeinfo>-length.
        ls_alv_fieldcat-outputlen             = <typeinfo>-output_length.
        ls_alv_fieldcat-decimals_out          = <typeinfo>-decimals.
        ls_alv_fieldcat-inttype               = <typeinfo>-type.
        APPEND ls_alv_fieldcat TO rt_fieldcat.
        CLEAR:  "prevent anything 2 B  taken for subsequent fields
          ls_alv_fieldcat.
      ENDLOOP." at lv_desc-types where not IDX_NAME is in initial.
    ENDMETHOD.
    Parameters required
        importing
          IT_TABLE type STANDARD TABLE
        returning
          value(RT_FIELDCAT) type SLIS_T_FIELDCAT_ALV .
    and
    method GET_ROLLNAME_4_TABFIELD .
      FIELD-SYMBOLS:
        <dfies>                               TYPE dfies.
      DATA:
        lv_tabname                            TYPE tabname,
         lt_dfies                             TYPE TABLE OF dfies,
        lv_fieldname                          TYPE fieldname.
      SPLIT iv_fieldname AT '-'
        INTO lv_tabname lv_fieldname.
      CLEAR cs_alv_fieldcat-rollname.
      CALL FUNCTION 'DDIF_FIELDINFO_GET'
        EXPORTING
          tabname                             = lv_tabname
          fieldname                           = lv_fieldname
    *   LANGU                                 = SY-LANGU
    *   LFIELDNAME                            = ' '
    *   ALL_TYPES                             = ' '
    * IMPORTING
    *   X030L_WA                              =
    *   DDOBJTYPE                             =
    *   DFIES_WA                              =
    *   LINES_DESCR                           =
       TABLES
         dfies_tab                            =  lt_dfies
    *   FIXED_VALUES                          =
       EXCEPTIONS
         not_found                            = 1
         internal_error                       = 2
         OTHERS                               = 3
      IF sy-subrc                             <> 0.
        MESSAGE ID sy-msgid                   TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        READ TABLE   lt_dfies ASSIGNING <dfies> INDEX 1.
        cs_alv_fieldcat-rollname               = <dfies>-rollname.
    * Und wenn keinerlei Twexte gepflegt sind?
        IF <dfies>-reptext IS INITIAL AND
           <dfies>-scrtext_s IS INITIAL AND
           <dfies>-scrtext_m IS INITIAL AND
           <dfies>-scrtext_l IS INITIAL.
    * No Text: Use Fieldname as text
          cs_alv_fieldcat-seltext_s            =
          cs_alv_fieldcat-seltext_m            =
          cs_alv_fieldcat-seltext_l            =
          cs_alv_fieldcat-reptext_ddic         =
            cs_alv_fieldcat-fieldname.
        ENDIF." <dfies>-reptext IS INITIAL AND
      ENDIF.
    endmethod.
    parameters required
        importing
          IV_FIELDNAME type DYNFNAM
        changing
          value(CS_ALV_FIELDCAT) type SLIS_FIELDCAT_ALV .
    Put this into class Z_CL_UTIL using SE80 and generate field catalog dynamically using statement
    lt_fieldcat = Z_CL_UTIL=>fieldcat_alv( itab ).
    If you have any difficulties with implementation, let me know.
    Regards,
    Clemens Li

  • Runtime error in Dynamic internal table with AMOUNT and Quantity Fields..

    Dear friends,
    I am attempting write a dymanic Select Statement (with joins).
    And the sleect query looks like this..
      SELECT (LT_SEL_LIST)
      INTO CORRESPONDING FIELDS OF
      TABLE <DYN_TABLE>
      FROM (LT_FROM_LIST)
      WHERE (LT_WHERE3).
    Here the into table is a dynamically created internal table..
    which is created by ...this
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = IT_OUTPUT2[]
        IMPORTING
          EP_TABLE        = DY_TABLE.
    the it_output2 contains the the fieldcatlog information of dynamically given fields :-
    like:-
           TABNAME
           FIELDNAME
           DATATYPE
           LENG
           INTTYPE
           ROLLNAME
           DECIMALS
           REFTABLE
           REFFIELD
    i mean the internal table is constructed with reference to all the bove metadata.
    Problem:- This query run fine with all the fields Except AMOUNT AND QUANTITY fields....
    When the selection list contain VBAK-NETWR or MSEG-MENGE..It throws a runtime error.
    "The data read during a SLECT access couldnt be inserted into the target field,either conversion is not supported for
    the target field's type or the target field is too short."
    after this I even tried to construct the dynamic table with CFILEDNAME and QFIELDNAME in the Fieldcatalog.
    so now my fieldcatlog looks like this:---
    LOOP AT IT_DD03L..
      IF IT_DD03L-DATATYPE = 'CURR'.
           TABLEFIELD-CFIELDNAME = IT_DD03L-FIELDNAME .
           ENDIF.
       IF IT_FIELDCAT3-DATATYPE = 'QUAN'.
           TABLEFIELD-QFIELDNAME = IT_DD03L-FIELDNAME .
      ENDIF.
           TABLEFIELD-TABNAME     = IT_DD03L-TABNAME.
           TABLEFIELD-FIELDNAME   = IT_DD03L-FIELDNAME.
           TABLEFIELD-DATATYPE    = IT_DD03L-DATATYPE.
           TABLEFIELD-INTLEN      = IT_DD03L-LENG.
           TABLEFIELD-INTTYPE     = IT_DD03L-INTTYPE .
           TABLEFIELD-ROLLNAME    = IT_DD03L-ROLLNAME.
           TABLEFIELD-DECIMALS    = IT_DD03L-DECIMALS.
           TABLEFIELD-REF_TABLE   = IT_DD03L-REFTABLE.
           TABLEFIELD-REF_FIELD   = IT_DD03L-REFFIELD.
    APPEND TABLEFIELD.
    CLEAR TABLEFIELD.
    ENDLOOP.
    Note:- this is a test code so ignore performance issues...
    Please help me with some code ...to avoid the Runtime erorr.
    Thanks,
    jeevan.

    Hi Jeevan,
    Why are moving only few fields from DD03L table to your field catalog? Why don't you use move-corresponding? The following code works for me in ECC6.0.
    data: it_dd03l type table of dd03l initial size 0,
          ls_dd03l type dd03l,
          lt_fldcat TYPE lvc_t_fcat,
          ls_fldcat TYPE lvc_s_fcat,
          ls_where(72) TYPE c,
          lt_where LIKE TABLE OF ls_where,
          lt_fld LIKE TABLE OF ls_where,
          lt_data_dy TYPE REF TO data.
    field-symbols: <ft_data> TYPE STANDARD TABLE.
    select * into table it_dd03l from dd03l
        where tabname = 'VBAK'
          and ( fieldname = 'VBELN' or fieldname = 'NETWR' ).
    check sy-subrc eq 0.
    loop at it_dd03l into ls_dd03l.
      move-corresponding ls_dd03l to ls_fldcat.
      append ls_fldcat to lt_fldcat.
      move ls_dd03l-fieldname to ls_where.
      append ls_where to lt_fld.
      if ls_dd03l-fieldname = 'VBELN'.
        clear ls_where.
        concatenate ls_dd03l-fieldname ' <> ''''' into ls_where.
        append ls_where to lt_where.
      endif.
    endloop.
    check not lt_fldcat is initial.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
          EXPORTING
            it_fieldcatalog           = lt_fldcat
          IMPORTING
            ep_table                  = lt_data_dy
          EXCEPTIONS
            generate_subpool_dir_full = 1
            OTHERS                    = 2.
        IF sy-subrc <> 0.
          RAISE no_configuration_data.
        ENDIF.
        ASSIGN lt_data_dy->*  TO <ft_data>.
    check sy-subrc eq 0.
    select (lt_fld) from VBAK into corresponding fields of table
        <ft_data>
        where (lt_where).
    Thanks
    Bala

Maybe you are looking for

  • Unable to install Solaris 8 OE patches

    I'm trying to install the Solaris 8 recommended patch cluster on my new Blade 150. I downloaded and unzipped the patch file, dropped into single user mode, and executed the install_cluster script. After asking me if I was ready to continue to install

  • Process Chain/OS Command cp problem

    Hello, I am trying to execute a command similar to the following in an OS command in a process chain: cp /path/filename*.txt /path/filenamexxx.txt I know it's not a permissions problem. This is the error message from the Process Chain Maintenance Log

  • Exportpdf changing email attachment format

    Why does my email atttachements now come through in pdf formatt only since i have subscribed to exportpdf. I subscribed as my scanner will only scann documents in pdf formatt and I am unable to edit them.

  • What CPU is in the N900?

    I seem to recall that it has an ARM chip inside, but I could be wrong. I hope so, as Apple are looking like they want to buy the company, which would cause problems for Nokia and others... Apple Looking to buy ARM If tnis post is a cure to your issue

  • Problem in WMI Service

    Hi Expert, I am facing an issue, I am not able to connect a particular windows 2008 R2 Server from Windows 2008 Server  by using WBEmtest utility. It showing below error, while checked that RPC service is working fine. It's Strange that from windows