Passing Field Symbols in FM

Hi Friends,
                        In my FM, i want to pass field symbol back to my main program for further use. How can i achieve the same.
                        In my source code section of FM,
FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
               <fs_dyntable>,
               <fs_fldval> TYPE ANY,
               <fs_col1>,<fs_col2>.
  DATA : t_newtable TYPE REF TO data,t_newline  TYPE REF TO data,t_fldcat TYPE lvc_t_fcat.
  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog           = t_fldcat
    IMPORTING
      ep_table                  = t_newtable
    EXCEPTIONS
      generate_subpool_dir_full = 1
      OTHERS                    = 2.
  ASSIGN t_newtable->* TO <t_dyntable>.
  CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
i want to pass <t_dyntable> back to my prg but i am not getting how to pass it and where to write it.
Please guide me.
Thanks and Regards,
Gaurav

Hi Naimesh,
                        Thanks for the reply.
                         Finally i understood what you guys wanted me to do.I did exactly the same but the problem remains the same.
                         when my control get back to subroutine it works fine, i mean upto
ASSIGN r_dyntab->* TO <t_dyntable>
,it works fine.But when the control gets over from FM and process the next statement 
clear <t_dyntable>.
then the  <t_dyntable> says it is not yet assigned. I want to access  <t_dyntable> as main dynamic table for further process.
i have added code for your reference.
Thanks and Regards,
Gaurav
Report Zcallingprg. 
DATA : t_newtable TYPE REF TO data,t_newline  TYPE REF TO data,t_fldcat TYPE lvc_t_fcat.
  DATA : wa_it_fldcat TYPE lvc_s_fcat,wa_colno(2) TYPE n,wa_flname(5) TYPE c,G_DISCONT.
  data : num2(2).
  DATA: rest TYPE i.
  DATA: task(8) TYPE c value '1'.
  FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
               <fs_dyntable>,
               <fs_fldval> TYPE ANY,
               <fs_col1>,<fs_col2>.
DO 100 TIMES.
  rest = sy-index MOD 36.
  IF rest = 0.
    task = task + 1.
  ENDIF.
CALL FUNCTION 'ZTEST_NEW_TASK' STARTING NEW TASK task
  EXPORTING
    num2          = 2.
ENDDO.
  clear <t_dyntable>.
FORM get_dyn_tab CHANGING r_dyntab TYPE REF TO data.
ASSIGN r_dyntab->* TO <t_dyntable>.
ENDFORM.
code of FM
CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog           = t_fldcat
    IMPORTING
      ep_table                  = r_newtab
    EXCEPTIONS
      generate_subpool_dir_full = 1
      OTHERS                    = 2.
*ASSIGN r_newtab->* TO <t_dyntable>.
PERFORM get_dyn_tab(ztemp5) USING r_newtab.

Similar Messages

  • In webdynpro ,Passing field symbols as values to class methods

    Hi
    Please tell me the ways of accessing database in webdynpro abap(not directly). I am calling Class method for accessing database. As currently I am directly accessing database in my webdynpro application. I have created a class and method for the same.
    In my method I want to use select statement which will return table with values to webdynpro application. So for select statement(Calling Method) I need to use my field symbol values as where in clause .
    Could anyone please help with example code?
    Thanks,
    Ujjwal

    data: in_line type ref to data.
    CREATE DATA in_line LIKE LINE OF <dyn_tab>.
      ASSIGN in_line->* TO <dyn_wa>.
    You can create a data reference and assign it to a field symbol and change the values. direclty passing field symbols is not possible.
    Abhi

  • Passing Field Symbols in subroutines

    Hi all,
    Can any body tell me how to pass field symbols in a suboutine and will that effect orignal value of that symbl if i change it in subroutine.
    Any Help will be awarded.
    <b>Sachin</b>

    Hi
    Field Symbols
    Field symbols are placeholders or symbolic names for other fields. They do not physically reserve space for a field, but point to its contents. A field symbol cam point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.
    Whenever you address a field symbol in a program, you are addressing the field that is assigned to the field symbol. After successful assignment, there is no difference in ABAP whether you reference the field symbol or the field itself. You must assign a field to each field symbol before you can address the latter in programs.
    Field symbols are similar to dereferenced pointers in C (that is, pointers to which the content operator * is applied). However, the only real equivalent of pointers in ABAP, that is, variables that contain a memory address (reference) and that can be used without the contents operator, are reference variables in ABAP Objects.
    All operations programmed with field symbols are applied to the field assigned to it. For example, a MOVE statement between two field symbols moves the contents of the field assigned to the first field symbol to the field assigned to the second field symbol. The field symbols themselves point to the same fields after the MOVE statement as they did before.
    You can create field symbols either without or with type specifications. If you do not specify a type, the field symbol inherits all of the technical attributes of the field assigned to it. If you do specify a type, the system checks the compatibility of the field symbol and the field you are assigning to it during the ASSIGN statement.
    Field symbols provide greater flexibility when you address data objects:
    If you want to process sections of fields, you can specify the offset and length of the field dynamically.
    You can assign one field symbol to another, which allows you to address parts of fields.
    Assignments to field symbols may extend beyond field boundaries. This allows you to address regular sequences of fields in memory efficiently.
    You can also force a field symbol to take different technical attributes from those of the field assigned to it.
    The flexibility of field symbols provides elegant solutions to certain problems. On the other hand, it does mean that errors can easily occur. Since fields are not assigned to field symbols until runtime, the effectiveness of syntax and security checks is very limited for operations involving field symbols. This can lead to runtime errors or incorrect data assignments.
    While runtime errors indicate an obvious problem, incorrect data assignments are dangerous because they can be very difficult to detect. For this reason, you should only use field symbols if you cannot achieve the same result using other ABAP statements.
    For example, you may want to process part of a string where the offset and length depend on the contents of the field. You could use field symbols in this case. However, since the MOVE statement also supports variable offset and length specifications, you should use it instead. The MOVE statement (with your own auxiliary variables if required) is much safer than using field symbols, since it cannot address memory beyond the boundary of a field. However, field symbols may improve performance in some cases.
    check the below links u will get the answers for your questions
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
    http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
    http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
    Syntax Diagram
    FIELD-SYMBOLS
    Basic form
    FIELD-SYMBOLS <fs>.
    Extras:
    1. ... TYPE type
    2. ... TYPE REF TO cif
    3. ... TYPE REF TO DATA
    4. ... TYPE LINE OF type
    5. ... LIKE s
    6. ... LIKE LINE OF s
    7. ... TYPE tabkind
    8. ... STRUCTURE s DEFAULT wa
    The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
    Effect
    This statement declares a symbolic field called <fs>. At runtime, you can assign a concrete field to the field symbol using ASSIGN. All operations performed with the field symbol then directly affect the field assigned to it.
    You can only use one of the additions.
    Example
    Output aircraft type from the table SFLIGHT using a field symbol:
    FIELD-SYMBOLS <PT> TYPE ANY.
    DATA SFLIGHT_WA TYPE SFLIGHT.
    ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
    WRITE <PT>.
    Addition 1
    ... TYPE type
    Addition 2
    ... TYPE REF TO cif
    Addition 3
    ... TYPE REF TO DATA
    Addition 4
    ... TYPE LINE OF type
    Addition 5
    ... LIKE s
    Addition 6
    ... LIKE LINE OF s
    Addition 7
    ... TYPE tabkind
    Effect
    You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
    This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
    In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
    Effect
    Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
    The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
    Example
    Address components of the flight bookings table SBOOK using a field symbol:
    DATA SBOOK_WA LIKE SBOOK.
    FIELD-SYMBOLS <SB> STRUCTURE SBOOK
    DEFAULT SBOOK_WA.
    WRITE: <SB>-BOOKID, <SB>-FLDATE.
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Passing field symbol value to a variable

    Hi All,
    I have a value in Field Symbol declared as   <FS-STATUS> TYPE STANDARD TABLE.
    I want to use the value  <fs-status> -low  in  a case statement.
    For this i think i have to pass the <fs-status> -low  into a variable and then use in case statement.
    Can anyone explain how to pass values in field symbol to variable? Or if this is not possible is there any other solution.
    Thanks in advance.

    Hi ,
    I have give some code sample ; just check ..
    DATA: BEGIN OF line,
             col1(1) TYPE c,
             col2(1) TYPE c VALUE 'X',
           END OF line.
    FIELD-SYMBOLS <fs> LIKE line.
    ASSIGN line TO <fs>.
    MOVE <fs>-col2 TO <fs>-col1.
    WRITE: <fs>-col1, <fs>-col2.
    Or u can check this link :
         http://www.erpgenie.com/abaptips/content/view/401/62/

  • How to pass field symbol or table from one view to another view in abap web dynpro?

    I am creating an Inbound Outbound ALV report in ABAP Web Dynpro. However at selection-screen I have select options and fetching is done at view2. Problem is we can pass parameter using inbound outbound parameters but how to pass internal table or field-symbols from one view to another view? I made use of Assistance Class too but its not very clear to me. Please give me some example or code to sort this problem out.

    I am creating an Inbound Outbound ALV report in ABAP Web Dynpro. However at selection-screen I have select options and fetching is done at view2. Problem is we can pass parameter using inbound outbound parameters but how to pass internal table or field-symbols from one view to another view? I made use of Assistance Class too but its not very clear to me. Please give me some example or code to sort this problem out.

  • Passing field-symbols to a function module

    Hey experts.
    In this scenario I am in the need to pass two buffer fieldsymbols (one contains a string, the other one a table) from my main programm to a function module.
    The main programm handles the user input and double-loops the function call with changing parameters. I cannot initialize the field-symbols within a loop since I'd loose the data. So I need to declare them BEFORE the function call proceeds, get them transfered over to the function module AND I need them saved from one call to the next one.
    Any suggestions ?
    How can I set global parameters available in my main programm and my function module?

    Hi Paul,
    Field symbols never contain data but refer to some existing data objects, so what you need is to copy the latter (string and internal table in your case), and you can define to which data objects the field symbols refer to, at any time. To duplicate a data object, it will depend if they are defined statically or dynamically?
    How can I set global parameters available in my main programm and my function module?
    It's difficult to give you one answer, it may depend on your scenario, you have lots of possibilities, interface work area, global data that is written and read using dedicated procedures, export/import to memory...
    A little excerpt of your code would help.
    BR
    Sandra

  • How to pass field symbol as parameter to a method

    Hi,
    I have a field symbol of type table,also i have a method with parameter (say vbeln), i need to pass the range value in <fs> as the parametrs to the method.,
    How can I acheive this,
    A code snippet eill help me a lot.,
    Thank you.
    Arjun.G

    Hi,
    Example code :
    field-symbols : <fs> type table.
    CALL METHOD cl_gui_frontend_services=>gui_upload
      CHANGING
        data_tab                = <fs>
    *  EXCEPTIONS
    *    file_open_error         = 1
    *    file_read_error         = 2
    *    no_batch                = 3
    *    gui_refuse_filetransfer = 4
    *    invalid_type            = 5
    *    no_authority            = 6
    *    unknown_error           = 7
    *    bad_data_format         = 8
    *    header_not_allowed      = 9
    *    separator_not_allowed   = 10
    *    header_too_long         = 11
    *    unknown_dp_error        = 12
    *    access_denied           = 13
    *    dp_out_of_memory        = 14
    *    disk_full               = 15
    *    dp_timeout              = 16
    *    not_supported_by_gui    = 17
    *    error_no_gui            = 18
    *    others                  = 19
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Remember : parameter should be of type standard table.
    Regards,
    Mohaiyuddin

  • Field symbols values passing as parameter to Methods

    Hi ,
    Can we pass fields symbols as parameter to methods ? I want to use field symbols values in my where in clause in methods, thereafter I want to pass my internal table to calling method.
    Thanks,
    Ujjwal

    Hi,
    I have create an class in which have I have create a method to written a select query to extract value from a table. The table name is passed by user. the select used is:
    select * from (tab) into CORRESPONDING FIELDS OF TABLE data.
    this method has 2 parameter:
    tab of type sting (importing).
    data of type ANY TABLE (exporting).
    and i am using the following code to get the data:
    data:  itab TYPE TABLE OF t578w.
    field-SYMBOLS <ab> TYPE any.
    ASSIGN 'T578W' to <ab>.
    CALL METHOD Z_GET_TABLE_DATA=>GET_TABLE " Z_GET_TABLE_DATA is the class name & GET_TABLE  is method name
        EXPORTING
          tab  = <ab>
        IMPORTING
          data = itab.
    You can code in similar way.
    I hope it helps.
    Regards
    Arjun
    Edited by: Arjun Thakur on Apr 23, 2009 3:16 PM

  • Is it possible to pass a field symbol as parameter from any method of view?

    Hi
    Is it possible to pass a field symbol as an importing parameter to teh globally declared attribute??

    While it is true that you can pass field symbols, they must be fully typed at the time you pass them  and they will be passed by value, not by reference. If you want to pass generically typed variables use a data reference (TYPE REF TO) instead.

  • Need Help in Field Symbol for Dynamically passing  table field value

    Hi All,
    In my internal table I am having data.
    I am dynamically forming table field name and substitute for the another table field name to pass DATA.
    but I am getting the Variable name insted of Value ie Data.
    I am using Field Symbol for this.
    data:
    Field-symbols <TS> type any.
    field1 type string.
    LOOP AT TABLEFIELDS INTO WA_TABLEFIELDS.
                READ TABLE  TEST  WITH KEY NAME = WA_TABLEFIELDS-FIELDNAME.
                IF SY-SUBRC = 0.
                  CONCATENATE 'WA_' WA_TABLEFIELDS-TABNAME '-' WA_TABLEFIELDS-FIELDNAME INTO  Field1.
                  Assign Field1 to <TS>.
                    ALL_VAL-VALUE = <TS>
    "After substituting the <TS>  into ALL_VAL-VALUE  field I need a DATA to be passed but the variable name is appending"*    
             APPEND ALL_VAL.
                ENDIF.
              ENDLOOP.
    kindly how to pass the value into the table.
    Thanks in advance.
    San

    Hi,
    pls assign a break point in
    CONCATENATE 'WA_' WA_TABLEFIELDS-TABNAME '-' WA_TABLEFIELDS-FIELDNAME INTO Field1.
    Assign Field1 to <TS>.
    ALL_VAL-VALUE = <TS>
       " Put a break point here and check for the value in <TS>.
    if <TS> contains value then create a work area for ALL_VAL AND PASS the Field-Symbol to that and then  append thw wa into the table...
    Hope this works out!!
    thanks

  • Can I pass a table using field-symbols to a PERFORM

    Can I pass an internal table using a field-symbol via a PERFORM that is stored in another program.
    For example, I want to pass lt_data using a field-symbol.  If I can do this, please tell me how to define a field-symbol for a table and how I setup the parameters on the FORM.
       perform TEST_FIELD_SYMBOLS in program zadd_data
                      changing lt_data[]
                       if found.
    Thanks.
    Regards,
    Ryan

    Since in ABAP all FORM-paramters are passe call-by reference, it makes imho no difference if u pass a table directly or via a fieldsymbol.
    U can pass a REF TO DATA to a form and then assign it to an FS like shown in the following example.
    TYPES: BEGIN OF s_data,
             data TYPE c,
           END OF s_data,
           s_tab TYPE STANDARD TABLE OF s_data.
    TYPES: r_tab TYPE REF TO data.
    START-OF-SELECTION.
      DATA: t_foo TYPE s_tab.
      DATA: ref_foo TYPE r_tab.
      GET REFERENCE OF t_foo INTO ref_foo.
      PERFORM my_form_fs USING ref_foo.
    FORM my_form_fs USING u_ref TYPE r_tab.
      FIELD-SYMBOLS: <fs> TYPE s_tab.
      DATA: w_tab TYPE s_data.
      ASSIGN u_ref->* TO <fs>.
      w_tab-data = 'X'.
      APPEND w_tab TO <fs>.
    ENDFORM.
    This also works for external performs....
    Best regards,
        Sebastian
    Message was edited by:
            Sebastian Rötzel

  • Passing value from field symbol / variable type ref to data to variable

    hey ,
    DATA: NODE_FLIGHTS TYPE REF TO IF_WD_CONTEXT_NODE.
      DATA: RT_CARRID TYPE REF TO DATA.
      FIELD-SYMBOLS: <FS_CARRID> TYPE TABLE
    .* Retrieve the data from the select option
      RT_CARRID = WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD( I_ID = 'S_WEIGHT).
    Assign it to a field symbol
      ASSIGN RT_CARRID->* TO <FS_CARRID>.
    how can i pass RT_CARRID or <FS_CARRID> to a varible with type vbap-netgrw ( net weight ) ?
    thanks
    ASA

    >
    ASA MOKED wrote:
    > hey ,
    >
    >
    > DATA: NODE_FLIGHTS TYPE REF TO IF_WD_CONTEXT_NODE.
    >   DATA: RT_CARRID TYPE REF TO DATA.
    >   FIELD-SYMBOLS: <FS_CARRID> TYPE TABLE

    > .* Retrieve the data from the select option
    >   RT_CARRID = WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD( I_ID = 'S_WEIGHT).
    > * Assign it to a field symbol
    >   ASSIGN RT_CARRID->* TO <FS_CARRID>.
    create a work area of type <FS_CARRID>.
    field-symbol: <fs_wa> type line of <FS_CARRID>.
    loop at <FS_CARRID> into <fs_wa>.
    lv_netgr = <fs_wa>-netgr.

  • Passing content of field symbol to internal table

    Hi experts,
    I need to pass the content of a field symbol to a internal table. Below is the following structure of the field symbol and internal table. But I'm encountering a short dump:
    TYPES: BEGIN OF fint_frange,
            fieldname    LIKE rsdstabs-prim_fname,
            fieldtype(1) TYPE c,
            selopt_t     TYPE fint_selopt_t,
           END OF fint_frange.
    TYPES: fint_frange_t TYPE fint_frange OCCURS 10.
    CONSTANTS: lc_save_selections(31) TYPE c VALUE '(RFINTITAR)GT_SAVE_SELECTIONS[]',
    FIELD-SYMBOLS: <fs_save_selections> TYPE STANDARD TABLE.
    ASSIGN (lc_save_selections) TO <fs_save_selections>.
    i_save_selections[] = <fs_save_selections>.
    Short dump: You attempted to move one data object to another.
    This is not possible here because the internal tables concerned
    are neither compatible nor convertible.
    Thanks in advance.

    Hi,
    what is ur internal table structure?
    if structure of both field symbol and internal table is not same,
    u can not put equal betwwen them.
    ur  <fs_save_selections> is having one constanat value lc_save_selections.
    and ur assaigning that to an internal table with some structure ......
    so structure is not same for both..........check it once.
    Regards,
    kk.

  • Passing unassigned field symbols to a method

    Hello Gurus,
    I work with a field symbol in a method and after the work is finished i have to use it i my program that i call the method from.
    The problem is that the field symbol gets assigned only in the method so i can`t get the field symbol as a changing parameter in my method because it is not assigned yet.
    I thought that i can return the field symbol from the method after it has been assigned, but i don`t know how. The <fs> is a dynamic itab that i created within the method.
    Can anyone help please ??

    Although already answered this code snippet might make it clearer
    my_line is your data structure  typically  an itab structure.
    For example
    TYPES:  BEGIN OF s_elements,
       tabname  type DD02L-tabname,
       tabclass type dd02l-tabclass,
       as4user  type dd02L-as4user,
       as4date  type dd02l-as4date,
       as4time  type DD02l-as4time,
       viewed(1) type c.
    TYPES: END OF    s_elements.
    Data: my_line            TYPE s_elements.
    1) get the structure of your itab automatically so you can build an FCAT simply for any structure without the horrendous usual coding to manipulate and create FCATS.
    CALL METHOD me->return_structure
           EXPORTING
                my_line = my_line.
    You need to make a table ZOGT data available in the class definition either as an attribute if you are using the class builder SE24 or as DATA in the relevant class section.
    data:
        zog         LIKE LINE OF lr_rtti_struc->components .
    data:
      zogt                    LIKE TABLE OF zog .
    method RETURN_STRUCTURE.
    lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( my_line ).
        zogt[]  = lr_rtti_struc->components.
    endmethod.
    Your structure details are now in table zogt.
    Use this to build an FCAT.
    CALL METHOD me->create_dynamic_fcat
          IMPORTING
                it_fldcat = it_fldcat.
    method CREATE_DYNAMIC_FCAT.
    LOOP AT zogt INTO zog.
          CLEAR wa_it_fldcat.
          wa_it_fldcat-fieldname = zog-name .
          wa_it_fldcat-datatype = zog-type_kind.
          wa_it_fldcat-inttype = zog-type_kind.
          wa_it_fldcat-intlen = zog-length.
          wa_it_fldcat-decimals = zog-decimals.
          wa_it_fldcat-coltext = zog-name.
          wa_it_fldcat-lowercase = 'X'.
          APPEND wa_it_fldcat TO it_fldcat .
        ENDLOOP.
    endmethod.
    Now having got your FCAT you can build your dynamic table.
        CALL METHOD me->create_dynamic_table
          EXPORTING
                it_fldcat = it_fldcat
          IMPORTING
                dy_table        = dy_table.
    (dy_table is defined as ref to data)
    method CREATE_DYNAMIC_TABLE.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
           EXPORTING
                it_fieldcatalog = it_fldcat
           IMPORTING
                ep_table = dy_table.
    endmethod.
    Now populate your dynamic table as per sample code here
    field_symbols:
    <dyn_table>    TYPE  STANDARD TABLE.
    <dyn_wa>.
    data: dy_line            TYPE REF TO data.
    FORM populate_dynamic_itab.
      ASSIGN dy_table->* TO <dyn_table>.
       CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
      SELECT *
            FROM DD02L
            INTO  CORRESPONDING FIELDS OF TABLE <dyn_table>
            WHERE TABNAME LIKE  'ZHR%'.
    ENDFORM.
    Now you can display your grid and process your data.
    CALL METHOD z_object->display_grid
           EXPORTING
             g_outtab = <dyn_table>
             g_fldcat = it_fldcat
             i_gridtitle = i_gridtitle
             i_edit  = i_edit
             i_zebra = i_zebra
           CHANGING
             it_fldcat = it_fldcat
             gt_outtab = <dyn_table>.
    In the Method
    method DISPLAY_GRID.
    GET REFERENCE OF g_outtab INTO g_outtab1.
        GET REFERENCE OF g_fldcat INTO g_fldcat1.
        struct_grid_lset-edit = i_edit.  "To enable editing
        struct_grid_LSET-zebra = i_zebra.
        struct_grid_lset-grid_title = i_gridtitle.
        struct_grid_lset-ctab_fname = 'T_CELLCOLORS'.
        struct_grid_lset-stylefname = 'CELLTAB'.
         CALL METHOD grid1->set_ready_for_input
            EXPORTING
                 i_ready_for_input = '1'.
        CALL METHOD grid1->set_table_for_first_display
           EXPORTING
                 is_layout       = struct_grid_lset
            CHANGING
                 it_outtab       = gt_outtab
                 it_fieldcatalog = it_fldcat.
      ENDMETHOD.
    You can even easily code your own  column names if you so wish in the application program.
    Before calling the method that displays the grid encode the following macro.
    DEFINE col_name.
      read table it_fldcat into  wa_it_fldcat index &1.
      wa_it_fldcat-coltext = &2.
      wa_it_fldcat-outputlen = &3.
      modify it_fldcat from wa_it_fldcat index &1.
    END-OF-DEFINITION.
    Then have a subroutine in your application code something like this
    Form name_columns.
    Here before displaying you can change the field catalog to
    adjust your own column names.
    *col_name  col-nr 'your name' output length.
        col_name 1 'Table name' 30.
        col_name 2 'Table class' 12.
        col_name 3  'Changed By' 12.
        col_name 4  '    On'   12.
        col_name 5  '    At'   8.
        col_name 6  'Act' 3.
      i_gridtitle = 'HR ESS / ITS  ZHR Tables - Double click to display'.
      i_zebra = 'X'.
      i_edit = ' '.
    endform.
    Hope this clears it up a bit.
    Once you get this stuff working you can re-use 99% of the code for almost any structure making the whole process of OO ALV grid applications really simple.
    Yoy only need as well a standard dynpro with a custom container on it (se51).
    Cheers
    jimbo

  • How to pass dynamic name to a field-symbol?

    Hi All,
    I have a requirement like I need to create dynamic internal table with dynamic name. Say like,
    Create a new Table
       CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
         it_fieldcatalog = it_fieldcat_fin[]
        IMPORTING
         ep_table        = new_table.
        IF sy-subrc EQ 0.
    Create a new Line with the same structure of the table.
         ASSIGN new_table->* to <b>(<fs_table>)</b>.
    In the above code, (<fs_table>) is a variable. Actually it is in the loop, so that first time it comes, it has to create an internal table with name as <fs_01>, next time <fs_02> and so on. Hope I am clear.
    Please help me. I am sure that i will mark the helpful answers.

    DATA: DREF TYPE REF TO DATA,WA_REF TYPE REF TO DATA.
    FIELD-SYMBOLS: <TEMP_TAB> TYPE TABLE, <TEMP_WA> TYPE ANY.
    *&      Form  DYNAMIC_TABLE
          text
    -->  p1        text
    <--  p2        text
    FORM DYNAMIC_TABLE.
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = LT_LVCFIELDCAT
        IMPORTING
          EP_TABLE        = DREF.
      ASSIGN dref->*  TO <TEMP_TAB>.
    ENDFORM.                    " DYNAMIC_TABLE
    the above is the procedure to create dynamic internal tables.
    now <TEMP_TAB> points to the contents of the table table in DREF.
    field symbol it self is meant for dynamic.
    then y r u using (<fs_table>).
    when everytime the same fieldsymbol is pointing to new contents, y u need new name everytime?
    i mean as the data is not static, so what is the use of naming a field symbol every time?.
    if u want to store the data in an internal table with a name,
    then u can do like below,
    data: tabname type string, i type i.
    concatenate '<fs_' i into tabname.
    "let i be the variable which stores the internal tables count
    "MOVE <temp_tab> to tabname.

Maybe you are looking for