Field symbol type problem

Deal All,
i am using field symbol here,while trying to assign the character value into field smybol.
It is generating the error.cannot be converted into number ..so wht should be the type of the field symbol.
field-symbol : <RATING> TYPE ANY.
   CONCATENATE 'wa_final1-f' V_COUNT INTO V_FIELD.
   CONDENSE V_FIELD.
   ASSIGN (V_FIELD) TO <RATING>.
   WRITE WA_FINAL-RATING1 TO V_PAK .
   <RATING> = V_PAK.     "ERROR GENERATING HERE WHILE ASSIGNING VALUE OF V_PAK         TO      <RATING>
VALUE OF V_PAK = 'DME' ( I.E CHARACTER FIELD).
thanks in advance..

field-symbol : <RATING> TYPE ANY.
CONCATENATE 'wa_final1-f' V_COUNT INTO V_FIELD.
CONDENSE V_FIELD.
ASSIGN (V_FIELD) TO <RATING>.
WRITE WA_FINAL-RATING1 TO V_PAK .
UNASSIGN <RATING>.
ASSIGN V_PAK TO <RATING>.
Edited by: vijetasap on Jun 4, 2009 7:11 AM

Similar Messages

  • Field symbol assign problem

    Hi ,
    Please find below code when I tried in version 4.6 code works correctly . but in 6.0 it gives short dump..
    Here.
      FIELD-SYMBOLS : <fs_table> TYPE ANY TABLE.
    FIELD-SYMBOLS : <fs_work_area> TYPE yatsdzz00.
    ASSIGN pr_data_changed->mp_mod_rows->* TO <fs_table>.
    LOOP AT <fs_table> ASSIGNING <fs_work_area>. (In there system gives short dump)
    Thanks in advance.

    Hai,
    Use CASTING or CASTING TYPE (mytype) after LOOP AT <fs_table> ASSIGNING <fs_work_area>.
    ie:
    FIELD-SYMBOLS : <fs_table> TYPE ANY TABLE.
    FIELD-SYMBOLS : <fs_work_area> TYPE yatsdzz00.
    ASSIGN pr_data_changed->mp_mod_rows->* TO <fs_table>.
    LOOP AT <fs_table> ASSIGNING <fs_work_area> <b>CASTING or CASTING TYPE (mytype).</b>
    For more information click the below link:
    http://help.sap.com/saphelp_46c/helpdata/EN/fc/eb35de358411d1829f0000e829fbfe/frameset.htm
    I hope it helps you.
    Reward points if it helps you.
    Regds,
    Rama chary.Pammi

  • Field symbol read problem

    hi masters,
    i have a statement like this.
    MODIFY (p_table) FROM TABLE <ntab>.
    now i have values in <NTAB> so how can i read this can anyone tel me pls?
    thank you,
    pasala.

    Hi pasalabasker,
    this code will help you.
    FIELD-SYMBOLS <lt_any> TYPE ANY TABLE.
    FIELD-SYMBOLS <ls_any> TYPE ANY.
    DATA:
      lr_data TYPE REF TO data,
      ls_mara TYPE mara,
      lt_mara TYPE STANDARD TABLE OF mara.
    SELECT *
      FROM mara
      INTO TABLE lt_mara
      UP TO 10 ROWS.
    ASSIGN ('LT_MARA') TO <lt_any>.
    CREATE DATA lr_data LIKE LINE OF <lt_any>.
    ASSIGN lr_data->* TO <ls_any>.
    LOOP AT <lt_any> ASSIGNING <ls_any>.
      MOVE-CORRESPONDING <ls_any> TO ls_mara.
      WRITE: ls_mara-matnr, /.
    ENDLOOP.
    regards Marcel

  • Field symbol type casting

    Hi
    how can i change the data type of a field symbol at run time..(say Packed  to  char)
    may be it can have a field data  or structure data..
    please help me ..........
    Regards
    albert

    hi
    thank you for your reply
    i am trying to do as follows but i am not getting the expected output
    where do i go wrong.............
    *"*"Local Interface:
    *"  TABLES
    *"      IT_OUT STRUCTURE  THENV OPTIONAL
    DATA: v_date type sy-datum,
               mytype type C.
    FIELD-SYMBOLS: <fs>,
                   <fs1>.
    v_date = sy-datum.
    ASSIGN v_date TO <fs>.
      append <fs> to it_out.
    WRITE / <fs>.      " ---------------->20.09.2011
    ASSIGN v_date TO <fs1> casting TYPE C.
      append <fs1> to it_out.
    WRITE / <fs1>.       " --------------->20110920
    LT_OUT  is having the data as 20110920
                                                                     20110920
    but i expect in date format     20.09.2011
                           20.09.2011

  • Moving Field of  Field Symbols type any.

    Hi all,
    I have  following piece of code
    METHODS : test IMPORTING itab TYPE STANDARD TABLE.
    method test.
    FIELD-SYMBOLS : <fs> TYPE ANY.
    data  : final(100) type c.
    LOOP AT itab ASSIGNING <fs>.
    *Here i want to concatenate the 20 fields of itab or <fs> into *final* for every loop.
    *Can anyone know an easier way in here
    endloop.
    endmethod.
    Thanks

    Hi,
    Can you use the command
    CONCATENATE final <FS> INTO FINAL.
    inside the loop.

  • Field-symbols working

    Hi Friends,
    I am facing some problems with regards to handling of Field-symbols.
    1.  How can we do a move-corresponding like thing with a FIELD_SYMBOL. We have two Field-symbols and both are referring to lines in Internal tables. But there are some less fields in the Second Field-symbol(Work Area i.e. TYPE TABLE) than the First FIELD-SYMBOL(Work Area i.e. TYPE TABLE). I need to move the values in the Second using the First Field-symbol. How can we do this.
    I cannot do an Assign component as I cannot provide the Fieldname in the Second Field-symbol(Work Area).
    2. the Second problem is how can we clear any particular Field in the field-symbol(TYPE TABLE).
    Thanks and Regards,
    Arunava

    Hello Arunava,
    When you declare your field symbols, declare it like this:
    FIELD-SYMBOLS: <fs1> like line of ITAB1,
                   <fs2> like line of ITAB2.
    Then for
    1. After you have assigned the record to corresponding field symbols, you can do this statement
        MOVE-CORRESPONDING <fs1> to <fs2>
    2. You can do like this to clear individual fields
       LOOP AT ITAB1 assigning <fs1>.
          CLEAR <fs1>-field1.
          MODIFY ITAB1.
       ENDLOOP.

  • Copying an  internal table data to a field symbol(only corresponding field)

    Hi,
       Iam having field symbol type standard table which has 4 fields in it already.
    I am having an internal table which has 10 columns in it.
    Now i want to copy the data from internal table to field symbol .But the problem is the fields which are matched in field symbol alone should be copied from the internal table.
    for eg.
    field symbol type table.
    field1.
    field2.
    field3.
    itab type internal table.
    field1
    field2
    field3
    field4
    field5
    field6.
    i want to copy the first 3 fields alone from the internal table itab to the field symbols. Can anyone help me on  how to do this. thanks...
    Regards,
    Rose.

    Hi,
    Chk below example, and match with ur scenario.
    data: begin of itab,
          a , b ,c , d,e,
          end of itab,
          wa like itab,
          jtab like table of itab,
          begin of fsy,
          a, b ,c,
          end of fsy.
    field-symbols:<fs> type any.
         assign fsy to <fs>.
         wa-a = 'x'. wa-b = 'y'. wa-c = 'z'. wa-d = 'r'.
         append wa to jtab.
          loop at jtab into wa.
            move-corresponding wa to <fs>.
          endloop.
    REGARDS,
    SENTHIL KUMAR.S

  • What is field symbols?

    Hi all,
    Can anyone explains what is Fiels symbol and significance of that with examples?
    Thanks
    Shiva

    HI Shiva
    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. (For more information, see Data References).
    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
    To declare a field symbol, use the statement
    FIELD-SYMBOLS <FS> [<type>|STRUCTURE <s> DEFAULT <wa>].
    For field symbols, the angle brackets are part of the syntax. They identify field symbols in the program code.
    If you do not specify any additions, the field symbol <FS> can have data objects of any type assigned to it. When you assign a data object, the field symbol inherits its technical attributes. The data type of the assigned data object becomes the actual data type of the field symbol.
    Note: it is possible to assign reference variables and structured data objects to untyped field symbols. However, the static field symbol is only a pointer to the field in memory, and does not have the complex type attributes of a reference or structured field until runtime. You can only use the field symbol to address the whole field (for example, in a MOVE statement). Specific statements such as CREATE OBJECT <FS> or LOOP AT <FS> are not possible.
    Typing Field Symbols
    The <type> addition allows you to specify the type of a field symbol. When you assign a data object to a field symbol, the system checks whether the type of the data object you are trying to assign is compatible with that of the field symbol. If the types are not compatible or convertible, the system reacts with a syntax or runtime error. If however, you want to assign the type of the field symbol to the data object by means of casting, you must do so explicitly using the ASSIGN statement. The system then treats the assigned data object as if it had the same type as the field symbol.
    You specify the type of a field symbol using the same semantics as for formal parameters in procedures. For <type> you can enter either TYPE <t> or LIKE <f>. You can specify the type either generically or in full. If you specify a generic type, the type of the field symbol is either partially specified or not specified at all. Any attributes that are not specified are inherited from the corresponding data object in the ASSIGN statement. If you specify the type fully, all of the technical attributes of the field symbol are determined when you define it. You can then only assign data objects to it that have exactly the same data type.
    You should always specify a type for each field symbol. If you cannot avoid defining a generic field symbol, make this clear by using an appropriate generic type declaration.
    Generic Type Specification
    The following types allow you more freedom when using actual parameters. The data object only needs to have the selection of attributes specified.
    Typing
    Check for data object
    No type specification
    TYPE ANY
    All types of data object are accepted. The field symbol adopts all of the attributes of the data object.
    TYPE C, N, P, or X
    Only data objects with type C, N, P, or X are accepted. The field symbol adopts the field length and DECIMALS specification (type P) of the data object.
    TYPE TABLE
    The system checks whether the data object is a standard internal table. This is a shortened form of TYPE STANDARD TABLE (see below).
    TYPE ANY TABLE
    The system checks whether the data object is an internal table. The field symbol inherits all of the attributes (line type, table type, key) from the data object.
    TYPE INDEX TABLE
    The system checks whether the data object is an index table (standard or sorted table). The field symbol inherits all of the attributes (line type, table type, key) from the data object.
    TYPE STANDARD TABLE
    The system checks whether the data object is a standard internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    TYPE SORTED TABLE
    The system checks whether the actual parameter is a sorted internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    TYPE HASHED TABLE
    The system checks whether the actual parameter is a hashed internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    If you specify a type generically, remember that the attributes inherited by the field symbol from the program are not statically recognizable in the program. You can, at most, address them dynamically.
    TYPES: BEGIN OF line,
             col1 TYPE c,
             col2 TYPE c,
           END OF line.
    DATA: wa TYPE line,
          itab TYPE HASHED TABLE OF line WITH UNIQUE KEY col1,
          key(4) TYPE c VALUE 'COL1'.
    FIELD-SYMBOLS <fs> TYPE ANY TABLE.
    ASSIGN itab TO <fs>.
    READ TABLE <fs> WITH TABLE KEY (key) = 'X' INTO wa.
    The internal table ITAB is assigned to the generic field symbol <FS>, after which it is possible to address the table key of the field symbol dynamically. However, the static address
    READ TABLE <fs> WITH TABLE KEY col1 = 'X' INTO wa.
    is not possible syntactically, since the field symbol does not adopt the key of table ITAB until runtime. In the program, the type specification ANY TABLE only indicates that <FS> is a table. If the type had been ANY (or no type had been specified at all), even the specific internal table statement READ TABLE <FS> would not have been possible.
    If you adopt a structured type generically (a structure, or a table with structured line type), the individual components cannot be addressed in the program either statically or dynamically. In this case, you would have to work with further field symbols and the method of assigning structures component by component.
    Specifying the Type Fully
    When you use the following types, the technical attributes of the field symbols are fully specified. The technical attributes of the data objects must correspond to those of the field symbol.
    Typing
    Technical attributes of the field symbol
    TYPE D, F, I, or T
    The field symbol has the technical attributes of the predefined elementary type
    TYPE <type>
    The field symbol has the type <type>. This is a data type defined within the program using the TYPES statement, or a type from the ABAP Dictionary
    TYPE REF TO <cif>|DATA
    The field symbol is a reference variable for the class or interface <cif>, or for a data object.
    TYPE LINE OF <itab>
    The field symbol has the same type as a line of the internal table <itab> defined using a TYPES statement or defined in the ABAP Dictionary
    LIKE <f>
    The field symbol has the same type as an internal data object <f> or structure, or a database table from the ABAP Dictionary
    When you use a field symbol that is fully typed, you can address its attributes statically in the program, since they are recognized in the source code. If you fully specify the type of a field symbol as a reference or structured data object, you can address it as you would the data object itself, once you have assigned an object to it. So, for example, you could address the components of a structure, loop through an internal table, or create an object with reference to a field symbol.
    REPORT demo_field_symbols_type .
    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.
    The field symbol <FS> is fully typed as a structure, and you can address its components in the program.
    Attaching a structure to a field symbol
    The STRUCTURE addition forces a structured view of the data objects that you assign to a field symbol.
    FIELD-SYMBOLS <FS> STRUCTURE <s> DEFAULT <f>.
    The structure <s> is either a structured local data object in the program, or a flat structure from the ABAP Dictionary. <f> is a data object that must be assigned to the field symbol as a starting field. However, this assignment can be changed later using the ASSIGN statement.
    When you assign a data object to the field symbol, the system only checks that it is at least as long as the structure. You can address the individual components of the field symbol. It has the same technical attributes as the structure <s>.
    If <s> contains components with type I or F, you should remember the possible effects of alignment. When you assign a data object to a field symbol with a structure, the data object must have the same alignment, otherwise a runtime error may result. In such cases, you are advised to assign such data objects only to structured field symbols, which retain the same structure as the field symbol at least over the length of the structure.
    The STRUCTURE is obsolete; you should no longer use it. Field symbols defined using the STRUCTURE addition are a mixture of typed field symbols and a utility for casting to either local or ABAP Dictionary data types. If you want to define the type of a field symbol, include the TYPE addition in a FIELD-SYMBOLS statement. If you want to use casting, include the CASTING addition in an ASSIGN statement.
    Example using the obsolete STRUCTURE addition:
    DATA: wa(10) VALUE '0123456789'.
    DATA: BEGIN OF line1,
             col1(3),
             col2(2),
             col3(5),
          END OF line1.
    DATA: BEGIN OF line2,
             col1(2),
             col2 LIKE sy-datum,
          END OF line2.
    FIELD-SYMBOLS: <f1> STRUCTURE line1 DEFAULT wa,
                   <f2> STRUCTURE line2 DEFAULT wa.
    WRITE: / <f1>-col1, <f1>-col2, <f1>-col3,
           / <f2>-col1, <f2>-col2.
    Example using the correct syntax (TYPE and CASTING):
    DATA: wa(10) VALUE '0123456789'.
    DATA: BEGIN OF line1,
             col1(3),
             col2(2),
             col3(5),
          END OF line1.
    DATA: BEGIN OF line2,
             COL1(2),
             COL2 LIKE sy-datum,
          END OF line2.
    FIELD-SYMBOLS: <f1> LIKE line1.
    ASSIGN wa TO <f1> CASTING.
    FIELD-SYMBOLS: <f2> LIKE line2.
    ASSIGN wa TO <f2> CASTING.
    WRITE: / <f1>-col1, <F1>-col2, <F1>-col3,
           / <f2>-col1, <F2>-col2.
    In both cases, the list appears as follows:
    012 34 56789
    01 2345/67/89
    This example declares two field symbols to which different structures are attached. The string WA is then assigned to each of them. The output shows that the field symbols assign the strings component by component according to the type of the components.
    Assigning Components of Structures to a Field Symbol
    For a structured data object <s>, you can use the statement
    ASSIGN COMPONENT <comp> OF STRUCTURE <s> TO <FS>.
    to assign one of its components <comp> to the field symbol <FS>. You can specify the component <comp> either as a literal or a variable. If <comp> is of type C or a structure that has no internal tables as components, it specifies the name of the component. If <comp> has any other elementary data type, it is converted to type I and specifies the number of the component. If the assignment is successful, SY-SUBRC is set to 0. Otherwise, it is set to 4.
    This statement is particularly important for addressing components of structured data objects dynamically. If you assign a data object to a field symbol either generically or using casting, or pass it generically (or using casting) to the parameter interface of a procedure, you cannot address its components either statically or dynamically. Instead, you must use the above statement. This allows indirect access either using the component name or its index number.
    DATA: BEGIN OF LINE,
            COL1 TYPE I VALUE '11',
            COL2 TYPE I VALUE '22',
            COL3 TYPE I VALUE '33',
          END OF LINE.
    DATA COMP(5) VALUE 'COL3'.
    FIELD-SYMBOLS: <F1>, <F2>, <F3>.
    ASSIGN LINE TO <F1>.
    ASSIGN COMP TO <F2>.
    DO 3 TIMES.
      ASSIGN COMPONENT SY-INDEX OF STRUCTURE <F1> TO <F3>.
      WRITE <F3>.
    ENDDO.
    ASSIGN COMPONENT <F2> OF STRUCTURE <F1> TO <F3>.
    WRITE / <F3>.
    The output is:
    11         22         33
    33
    The field symbol <F1> points to the structure LINE, <F2> points to the field COMP. In the DO loop, the components of LINE are specified by their numbers and assigned one by one to <F3>. After the loop, the component COL3 of LINE is specified by its name and assigned to <F3>. Note that ASSIGN COMPONENT is the only possible method of addressing the components of <F1>. Expressions such as <F1>-COL1 are syntactically incorrect.
    Regards,
    Laxmi.

  • BPC NW: Field symbol not assigned in BADi as Endroutine

    HI Experts,
    I have a problem when working with BADis as Endroutines in a TransformationFile.
    Guided by the "How To... Use Start and End Routine" I followed the different steps and for the Start Routine everything works fine. My problem is when trying to call the TransformationFile with the Endroutine I get a  GETWA_NOT_ASSIGNED dump telling me that: Field symbol has not yet been assigned.
    I'm using quite the same code as given in the How To. I introduced some checks, but  I did not get any positive results. Can anybody help, please? The How To is made for master data, I assume the error comes from this side, but I can't assure it.
    The code in the Badi is:
    field-symbols:
           type any.
    data: lt_columns type table of string.
    data: lt_column_data type table of string.
    data: lt_message type uj0_t_message.
    data: lt_error_reason type uj0_t_message,
          lv_tabix like sy-tabix.
    data:
          lo_dataref      type ref to data,
          lv_cuenta_asig  type zmap_cuentas-cuenta_asignado.
    Assign importing data reference to field symbol
    assign ir_data->* to  IS ASSIGNED.
    Create work area for importing data
    create data lo_dataref like line of .
    Create new internal table for exporting data
    check .
    Get CUENTA value from custom table or other datasource
    loop at .
    The error occurs when assigning the first pointer.
    By the way, I'm working on BPC 7.5 SP07 for NW.
    Hope someone can help. Thanks very much in advance,
    Àlex

    Hi Kaylan,
    thank you very much for your quick answer.
    Sorry, I think I haven't made quite clear my point.
    I want to use the Endroutine BADi in a Transformation File for Transaction Data, therefor there is no InfoObject directly involved. I use the Transformation File in the Package "Import Transaction Data". The How To I mentioned, and the only one I found that is more or less near to my problem describes how to use Endroutines and BADis for the Import of Master Data.
    Looking at the different tests I have done, as our system team is not giving us a debug user, the dump happens at the assignment of the first field symbol: assign ir_data->* to . Therefor I assume that  ir_data contains no data and this causes the dump.
    My main question is, can I use the code of the mentioned How To for the package "Import Transaction Data" at all? Or do I have to use different tables or table names for this package? How and where do I get them?
    You have an idea? Would be very helpful! Thanks in advance!
    Cheers
    Àlex

  • Transfer WA to a  application file using field symbols

    HI
    i have my final data in a <lt_tab>(field-symbols type table), there are 1 heading and rest of the rows are contents,
    for ex:
    f1 f2 f3 f4 " heading
    1   2   3   4  " contents
    5   6   7   8
    now i want to transfer the same to a file in application server(/tmp), please tell me how to do it, for refrence i m posting the code
    OPEN DATASET filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc NE 0.
        WRITE: 'File cannot be opened.'.
        EXIT.
      ENDIF.
    loop at <lt_tab> into <fs_1>.
    transfer <fs_1> to filename.
      ENDLOOP.
    * Closing the File
      CLOSE DATASET filename.
    now if i do this only 1 value is coming, if by  my example i go it is  'l'

    HI,
    How did you define the fields symbols as? As type any?
    Try to keep a break point at :   transfer <fs_1> to filename : statment in your code and see in <fs_1> if are you getting the entire content that is required  ( 1 2 3 4 " contents ) as per your code?
    If in the field symbol if you are getting only "1" then only 1 will be sent.
    Regards,
    Sravan

  • How to delete a particular record in field symbol

    Hi,
    i am declaring field symbol type any table i, i want delete a particular record in that filed symbol.
    How to do that.

    Hello Himam,
    It is not possible to delete directly from <itab> as it is of generic type.
    But you can do loop at <itab> ASSIGNING <wa> and then you can clear content of <wa> this will delete
    the line from internal table.
    Thanks,
    Augustin.

  • How to define an itab including a field-symbols

    *Please see below code, I define a field-symbols structure <wa>:
    FIELD-SYMBOLS: <wa>   TYPE ANY.
    data: wa type ref to data.
    create data wa type (p_table).
    assign wa-> to <wa>.
    My question is after <wa> get assigned, if I want to define a new internal table or structure which should include <wa>, like below:
    data: begin of itab occurs 0.
    include structure <wa>.
    data: status type c.
    data: end of itab.
    But it doesn't work. How can I do that?
    Thank you very much!

    Hi Yu,
    Just check with this example, u will get a good idea.
    PROGRAM ZMAIN.
      DATA: BEGIN OF STR,
              A VALUE 'a',
              B VALUE 'b',
              C VALUE 'c',
              D VALUE 'd',
            END   OF STR,
            CN(5) VALUE 'D'.
      FIELD-SYMBOLS <FS> TYPE ANY.
      DO 3 TIMES.
        ASSIGN COMPONENT SY-INDEX OF
               STRUCTURE STR TO <FS>.
        IF SY-SUBRC <> 0. EXIT. ENDIF.
        WRITE <FS>.
      ENDDO.
      ASSIGN COMPONENT CN OF STRUCTURE STR TO <FS>.
      WRITE <FS>.
    2.
    TYPES: BEGIN OF comp,
             f1 TYPE string,
             f2 TYPE i,
           END OF comp.
    DATA:  BEGIN OF stru,
             k1 TYPE comp,
             k2 TYPE comp,
             k3 TYPE comp,
             k4 TYPE comp,
           END OF stru.
    FIELD-SYMBOLS: TYPE comp.
    ASSIGN stru-k1 TO RANGE stru.
    DO 4 TIMES.
      ASSIGN INCREMENT 1 TO .
    ENDDO.
    PROGRAM P1MAIN.
      TABLES TRDIR.
      DATA NAME(30) VALUE 'TFDIR-PNAME'.
      FIELD-SYMBOLS <F> TYPE ANY.
      MOVE 'XYZ_PROG' TO TRDIR-NAME.
      PERFORM U IN PROGRAM P1SUB.
      ASSIGN (NAME) TO <F>.
      WRITE <F>.
      CALL FUNCTION 'EXAMPLE'.
    PROGRAM P1SUB.
      TABLES TFDIR.
      FORM U.
        FIELD-SYMBOLS <F> TYPE ANY.
        DATA NAME(30) VALUE 'TRDIR-NAME'.
        ASSIGN TABLE FIELD (NAME) TO <F>.
        WRITE <F>.
        MOVE 'FCT_PROG' TO TFDIR-PNAME.
      ENDFORM.
    FUNCTION-POOL FUN1.
      FUNCTION EXAMPLE.
        DATA NAME(30) VALUE 'TRDIR-NAME'.
        FIELD-SYMBOLS <F> TYPE ANY.
        ASSIGN (NAME) TO <F>.
        IF SY-SUBRC = 0.
          WRITE <F>.
        ELSE.
          WRITE / 'TRDIR-NAME cannot be reached'.
        ENDIF.
      ENDFUNCTION.
    PROGRAM P1MAIN.
      TABLES TRDIR.
      MOVE 'XYZ_PROG' TO TRDIR-NAME.
      CALL FUNCTION 'EXAMPLE'.
    FUNCTION-POOL FUN1.
      FUNCTION EXAMPLE.
        DATA NAME(30) VALUE 'TRDIR-NAME'.
        FIELD-SYMBOLS <FS> TYPE ANY.
        ASSIGN LOCAL COPY OF MAIN
          TABLE FIELD (NAME) TO <FS>.
        IF SY-SUBRC = 0.
          WRITE <FS>.
        ELSE.
          WRITE / 'Cannot find TRDIR-NAME'.
        ENDIF.
      ENDFUNCTION.
    Regards,
    Kumar

  • Dynamic field symbol

    Hello :i would like to ask one favor , how can i define a field symbol, that can recieve a dynamic variable
    segment of code:
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fldcat
        IMPORTING
          ep_table        = it_dynamic.
      ASSIGN it_dynamic->* TO <dyn_table>.
    CREATE DATA wa_dynamic LIKE line of <dyn_table>.
      ASSIGN wa_dynamic->* TO <dyn_wa>. " this one 'wa_dynamic'  i need to sent to <dyn_wa>
    thanks a lot

    HI
    GOOD
    Generic Type Specification
    The following types allow you more freedom when using actual parameters. The data object only needs to have the selection of attributes specified.
    Typing
    Check for data object
    No type specification
    TYPE ANY
    All types of data object are accepted. The field symbol adopts all of the attributes of the data object.
    TYPE C, N, P, or X
    Only data objects with type C, N, P, or X are accepted. The field symbol adopts the field length and DECIMALS specification (type P) of the data object.
    TYPE TABLE
    The system checks whether the data object is a standard internal table. This is a shortened form of TYPE STANDARD TABLE (see below).
    TYPE ANY TABLE
    The system checks whether the data object is an internal table. The field symbol inherits all of the attributes (line type, table type, key) from the data object.
    TYPE INDEX TABLE
    The system checks whether the data object is an index table (standard or sorted table). The field symbol inherits all of the attributes (line type, table type, key) from the data object.
    TYPE STANDARD TABLE
    The system checks whether the data object is a standard internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    TYPE SORTED TABLE
    The system checks whether the actual parameter is a sorted internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    TYPE HASHED TABLE
    The system checks whether the actual parameter is a hashed internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    If you specify a type generically, remember that the attributes inherited by the field symbol from the program are not statically recognizable in the program. You can, at most, address them dynamically.
    TYPES: BEGIN OF line,
             col1 TYPE c,
             col2 TYPE c,
           END OF line.
    DATA: wa TYPE line,
          itab TYPE HASHED TABLE OF line WITH UNIQUE KEY col1,
          key(4) TYPE c VALUE 'COL1'.
    FIELD-SYMBOLS <fs> TYPE ANY TABLE.
    ASSIGN itab TO <fs>.
    READ TABLE <fs> WITH TABLE KEY (key) = 'X' INTO wa.
    The internal table ITAB is assigned to the generic field symbol <FS>, after which it is possible to address the table key of the field symbol dynamically. However, the static address
    READ TABLE <fs> WITH TABLE KEY col1 = 'X' INTO wa.
    is not possible syntactically, since the field symbol does not adopt the key of table ITAB until runtime. In the program, the type specification ANY TABLE only indicates that <FS> is a table. If the type had been ANY (or no type had been specified at all), even the specific internal table statement READ TABLE <FS> would not have been possible.
    If you adopt a structured type generically (a structure, or a table with structured line type), the individual components cannot be addressed in the program either statically or dynamically. In this case, you would have to work with further field symbols and the method of assigning structures component by component.
    Specifying the Type Fully
    When you use the following types, the technical attributes of the field symbols are fully specified. The technical attributes of the data objects must correspond to those of the field symbol.
    Typing
    Technical attributes of the field symbol
    TYPE D, F, I, or T
    The field symbol has the technical attributes of the predefined elementary type
    TYPE <type>
    The field symbol has the type <type>. This is a data type defined within the program using the TYPES statement, or a type from the ABAP Dictionary
    TYPE REF TO <cif>|DATA
    The field symbol is a reference variable for the class or interface <cif>, or for a data object.
    TYPE LINE OF <itab>
    The field symbol has the same type as a line of the internal table <itab> defined using a TYPES statement or defined in the ABAP Dictionary
    LIKE <f>
    The field symbol has the same type as an internal data object <f> or structure, or a database table from the ABAP Dictionary
    When you use a field symbol that is fully typed, you can address its attributes statically in the program, since they are recognized in the source code. If you fully specify the type of a field symbol as a reference or structured data object, you can address it as you would the data object itself, once you have assigned an object to it. So, for example, you could address the components of a structure, loop through an internal table, or create an object with reference to a field symbol.
    REPORT demo_field_symbols_type .
    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.
    The field symbol <FS> is fully typed as a structure, and you can address its components in the program.
    Attaching a structure to a field symbol
    The STRUCTURE addition forces a structured view of the data objects that you assign to a field symbol.
    FIELD-SYMBOLS <FS> STRUCTURE <s> DEFAULT <f>.
    The structure <s> is either a structured local data object in the program, or a flat structure from the ABAP Dictionary. <f> is a data object that must be assigned to the field symbol as a starting field. However, this assignment can be changed later using the ASSIGN statement.
    When you assign a data object to the field symbol, the system only checks that it is at least as long as the structure. You can address the individual components of the field symbol. It has the same technical attributes as the structure <s>.
    If <s> contains components with type I or F, you should remember the possible effects of alignment. When you assign a data object to a field symbol with a structure, the data object must have the same alignment, otherwise a runtime error may result. In such cases, you are advised to assign such data objects only to structured field symbols, which retain the same structure as the field symbol at least over the length of the structure.
    The STRUCTURE is obsolete; you should no longer use it. Field symbols defined using the STRUCTURE addition are a mixture of typed field symbols and a utility for casting to either local or ABAP Dictionary data types. If you want to define the type of a field symbol, include the TYPE addition in a FIELD-SYMBOLS statement. If you want to use casting, include the CASTING addition in an ASSIGN statement.
    Example using the obsolete STRUCTURE addition:
    DATA: wa(10) VALUE '0123456789'.
    DATA: BEGIN OF line1,
             col1(3),
             col2(2),
             col3(5),
          END OF line1.
    DATA: BEGIN OF line2,
             col1(2),
             col2 LIKE sy-datum,
          END OF line2.
    FIELD-SYMBOLS: <f1> STRUCTURE line1 DEFAULT wa,
                   <f2> STRUCTURE line2 DEFAULT wa.
    WRITE: / <f1>-col1, <f1>-col2, <f1>-col3,
           / <f2>-col1, <f2>-col2.
    Example using the correct syntax (TYPE and CASTING):
    DATA: wa(10) VALUE '0123456789'.
    DATA: BEGIN OF line1,
             col1(3),
             col2(2),
             col3(5),
          END OF line1.
    DATA: BEGIN OF line2,
             COL1(2),
             COL2 LIKE sy-datum,
          END OF line2.
    FIELD-SYMBOLS: <f1> LIKE line1.
    ASSIGN wa TO <f1> CASTING.
    FIELD-SYMBOLS: <f2> LIKE line2.
    ASSIGN wa TO <f2> CASTING.
    WRITE: / <f1>-col1, <F1>-col2, <F1>-col3,
           / <f2>-col1, <F2>-col2.
    In both cases, the list appears as follows:
    012 34 56789
    01 2345/67/89
    This example declares two field symbols to which different structures are attached. The string WA is then assigned to each of them. The output shows that the field symbols assign the strings component by component according to the type of the components.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb387a358411d1829f0000e829fbfe/content.htm
    THANKS
    MRUTYUN

  • Assigning value to Field - Symbol ( which is type of internal table field )

    Hi All,
      I am facing problem to assign the value to a field symbol. My requirement is creating a dynamic internal table and populate values into that internal table, so that i can display the values .
      I am having a structure with fields like status , Plant1 name , Plant2 name.....Plant n .
      So i declared an internal table it_tab with this structure.
      I am having one more table which having number of records for Plant1 ,Plant 2 ,....Plant n based on some condition.
      I need to count the number of records for Plant1 and i need to put in the internal table it_tab.
      For this i created field-symbol .
    Here, t_deployment table will have the plants 1,2,3...and
         t_devobject will have some records for these plants.
    LOOP AT T_DEPLOYMENT. 
    clear w_count.
    LOOP AT T_DEVOBJECT WHERE ZDEPLOYMENT = T_DEPLOYMENT-DOMVALUE_L AND
                              ZADSTATUS = '10'.
    w_count = w_count + 1.
    ENDLOOP.
    concatenate 'it_tab-' t_deployment-domvalue_l into var_bet_name.
    assign var_bet_name to <bet_var_name>.
    now my internal table field i.e. it_tab-plant1 came into <bet_var_name> . But i want to assign a value for it.
    at last what i need is it_tab-plant1 = w_count.
    whaterver the w_count has value that needs to assign to it_tab-plant1. But i don't want to assign directly it it_tab-plant1. I want to assign dynamically. Because tommorrow some more plants added to t_deployments , i don't want to make changes to my program. It should take care....w/o changing the program.
    I tried the following statement.
    (<bet_var_name>) = w_count. But its not working.
    Please let me know how i can get this.
    Thanks in Advance.
    Pavan.

    Hi pavan,
    As ur requirement is creating a dynamic internal table,
    try the following way,
    remember the fieldcat should be of type LVC not SLIS.
    BUILD LT_LVCFIELDCAT in a way that, the value from the internal table becomes the fieldname
    ex:-
    loop at it_models INTO WA_MODELS.
        LS_LVCFIELDCAT-FIELDNAME = WA_models-MODEL.
        LS_LVCFIELDCAT-SELTEXT = WA_models-MODEL.
    append ls_lvcfieldcat to lt_lvcfieldcat.
    endloop.
    DATA: DREF TYPE REF TO DATA,WA_REF TYPE REF TO DATA.
    FIELD-SYMBOLS: <TEMP_TAB> TYPE TABLE, <TEMP_WA> TYPE ANY.
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = LT_LVCFIELDCAT
        IMPORTING
          EP_TABLE        = DREF.
      ASSIGN dref->*  TO <TEMP_TAB>.
    now basing on the fieldcatalog <temp_tab> is build.
    NOW FILL <TEMP_TAB>.
    WHILE FILLING, ASSIGN COMPONENT IDX/NAME.....
    this statement will be very usefull.
    i hope this will be help full.
    pls reward the points if it helps u.
    regards
    Hyma

  • Field Symbol -  Assign type conflict.

    Hi, i active successfully my program. This is the code:
    DATA ls_g_oref_appl(21) TYPE C.
    FIELD-SYMBOLS: <fs_appl> TYPE REF TO cl_ftr_mj_appl.
    ls_g_oref_appl = '(SAPLTB4E)g_oref_appl'.
    ASSIGN (ls_g_oref_appl) TO <fs_appl>.
    But when i execute it, i get a dump with this message:
    "ASSIGN_TYPE_CONFLICT : You attempted to assign a field to a typed field symbol,but the field does not have the required type. "
    Also, i get sy-subrc = 0, so the field symbol <fs_appl> has a value assign.
    Any suggestions? I tried by changing the type of the field to ANY, but it didnt compile.
    Thanks for the help,
    Karla

    Hi Daniel, I verified again the type of  g_oref_appl, and it is :  cl_ftr_mj_appl.  I check the top of the include and g_oref_appl is there :
    ' DATA g_oref_appl TYPE REF TO cl_ftr_mj_appl.  '
    Hi, Naren, also i tried with the TYPE ANY, but it doesnt compile.
    I notice this:
      CLASS cl_ftr_mj_appl DEFINITION ABSTRACT.
    Is there a problem with field symbols and abstracts class???
    Thanks for all your help,
    Karla.
    Edited by: Karla Tinoco on Mar 5, 2008 11:46 PM

Maybe you are looking for