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.

Similar Messages

  • 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

  • Moving field-symbol data to an internal table

    Hi
    I have defined a field-symbol
      field-symbols: <fs_table> type standard table.
      Dynamically, I have populated some records in this <fs_table> & now I would like to copy this data into another internal table. I would like to know the best method to declare/create this internal table & to copy the records from <fs_table> to this internal table.
      Thanks,
      Sanjay

    if you know the structure of the reuslt in the first place, instead of dynamic itab you would have created a normal itab.
    do you want the new itab to be same as <l_table> ?
    then that also needs to be dynamically created.
    the best thing possible in you case is.
    field-symbols: <newtab> type any table.
    if <l_table> is assinged.
    assign <l_table> to <newtab>.
    endif .
    if you tell us why you want to move the <l_table> records to another similar itab, may be could come up with suggestion which dosesnt require you to move the data at all
    Raja

  • 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

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

  • 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

  • Modify Syntax on Internal table of type ANY TABLE

    Hi,
    I have declared one internal table which is of type ANY TABLE.
    In the Loop statement, I am trying to Modify that Internal table from WA.
    Then I am getting one Error message
    "You cannot use explicit or implicit index operations on tables with types "HASHED TABLE" or "ANY TABLE". "C_T_DATA" has the type "ANY TABLE".
    Above code I have placed in method of a corresponding Class.
    Can u please advise me on this..How to modify the Intenal table .
    Thanks and Regards,
    K.Krishna Chaitanya.

    Hi Krishna,
    the modify statement is obsolete.
    You can always LOOP AT [itab] ASSIGNING <field-symbol>.
    This makes the loop never slower, depending on the table structure faster or much faster.
    If you know the table structure at run time, you can use a field-symbol of that type. If not, you can use a field-symbol TYPE any. Then you have to assign the components to field-symbol to modify them, i.e.
    field-symbols:
      <table_line> type any,
      <matnr>        type mara-matnr.
    loop at itab assigning  <table_line>.
      assign component 'MATNR' of structure <table_line> to <matnr>.
      clear <matnr>.
    endloop.
    This technique (available more than ten years) works incredibly fast. My estimate is that if SAP would change all the old standard programs that way and use it consequently in the new ones, the whole system would be 20 % faster because myriads of unnecessary copy operations of LOOP INTO would not happen.
    Regards,
    Clemens.

  • Can any one explain me about Field symbols in Genral Reports?

    Can any one explain me about Field symbols in Genral Reports?
    If possible, plz explain me with the code to explain me about the field symbols.
    Regards,
    Krishna Chaitanya

    Syntax
    FIELD-SYMBOLS <fs> { typing | STRUCTURE struc DEFAULT dobj }.
    Extras:
    1. ... typing
    2. ... STRUCTURE struc DEFAULT dobj
    Effect
    The FIELD-SYMBOLS statement declares a field symbol <fs>. The naming conventions apply to the name fs. The angle brackets of the field symbols indicate the difference to data objects and are obligatory. You can declare field symbols in any procedure and in the global declaration section of an ABAP program, but not in the declaration section of a class or an interface. You can use a field symbol in any operand position in which it is visible and which match the typing defined using typing.
    After its declaration, a field symbol is initial - that is, it does not reference a memory area. You have to assign a memory area to it (normally using the ASSIGN statement) before you can use it as an operand. Otherwise an exception will be triggered.
    Addition 1
    ... typing
    Effect
    You can use the addition typing to type the field symbol. The syntax of typing is described under Syntax of Typing. The typing specifies which memory areas can be assigned to the field symbol (see Checking the Typing) and in which operand positions it can be used.
    Note
    You can omit the addition typing outside of methods. In this case, the field symbol has the complete generic type any and is implicitly assigned the predefined constant space during the declaration.
    Addition 2
    ... STRUCTURE struc DEFAULT dobj
    Effect
    If you specify the addition STRUCTURE instead of typing for a field symbol, and struc is a local program structure (a data object, not a data type) or a flat structure from the ABAP Dictionary, this structure is cast for the field symbol <fs>. You have to specify a data object dobj that is initially assigned to the field symbol.
    The field symbol copies the technical attributes of structure struc as if it were completely typed. When you assign a data object using the addition DEFAULT, or later using ASSIGN, its complete data type is not checked in non- Unicode programs. Instead, the system merely checks whether it has at least the length of the structure and its alignment.
    In Unicode programs, we differentiate between structured and elementary data objects. For a structured data object dobj, its Unicode fragment view has to match the one of struc. In the case of an elementary data object, the object must be character-type and flat, and struc must be purely character-type. The same applies to assignments of data objects to field symbols typed using STRUCTURE when using the ASSIGN statement.
    Note
    Field symbols declared using the addition STRUCTURE are a mixture of typed field symbols and a utility for casting structured data types. You should use the additions TYPE or LIKE for the FIELD-SYMBOLS statement to type field symbols, while the addition CASTING of the ASSIGN statement is used for casting.
    Example
    The first example shows the obsolete usage of the addition STRUCTURE.
    DATA wa1 TYPE c LENGTH 512.
    FIELD-SYMBOLS <scarr1> STRUCTURE scarr DEFAULT wa1.
    <scarr1>-carrid = '...'.
    The second example shows the replacement of STRUCTURE with the additions TYPE and CASTING.
    DATA wa2 TYPE c LENGTH 512.
    FIELD-SYMBOLS <scarr2> TYPE scarr.
    ASSIGN wa2 TO <scarr2> CASTING.
    <scarr2>-carrid = '...'.
    Also,
    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.
    Related
    ASSIGN, DATA
    Additional help
    Declaring Field Symbols

  • Modify DB by single field using Field Symbol

    Hi,
      please help me ,actually i have not use the field symbol in any object. i have one requirement ,i have to modify the DB by field STATUS using Field symbol ,
    I am sending u my code so please help me how can i modify DB using field symbol..
              gw_msg3_status1   = k_status1 .
              LOOP AT gi_msg3 INTO gs_msg3.
                gs_msg3-status  = gw_msg3_status1 .
                gs_msg3-issue   = lw_issuno.
           MODIFY gi_msg3 FROM gs_msg3 TRANSPORTING status.
                MODIFY gi_msg3 INDEX sy-tabix FROM gs_msg3 TRANSPORTING issue status.
              ENDLOOP.
    Thanks & Regards,
    Meenakshi

    perform dboperation_table using 'SET' 'BIRTHDT' '=' <fs>.
        perform dboperation_table using 'WHERE' 'PARTNER' '='  <fs>
        perform dboperation_update using 'BUT000'.
    form dboperation_table
    using p_type
          p_var1
          p_var2
          p_var3.
      data: t_l type cmst_str_data.
      data: d_cx_root            type ref to cx_root,
            d_text               type string.
      try.
          clear t_l.
          if p_var3 is not initial.
            t_l = p_var3.
            condense t_l.
            concatenate '''' t_l '''' into t_l.
          endif.
          concatenate p_var1 p_var2 t_l into t_l
          separated by space.
          case p_type.
            when 'SET'.   append t_l to g_s_t.
            when 'WHERE'. append t_l to g_w_t.
          endcase.
        catch cx_root into d_cx_root.
          d_text = d_cx_root->get_text( ).
          message a398(00) with  d_text.
      endtry.
    endform.                    "DBOPERATION_table
    form dboperation_update
    using  p_tabname type zdboperation-tabname.
      data: tabname type bus_table.
      data: d_cx_root            type ref to cx_root,
            d_text               type string.
      try.
          tabname-tabname = p_tabname.
          call function 'ZDBOPERATION_UPDATE'
            in update task
            exporting
              tabname     = tabname
            tables
              where_table = g_w_t
              set_table   = g_s_t.
        catch cx_root into d_cx_root.
          d_text = d_cx_root->get_text( ).
          message a398(00) with  d_text.
      endtry.
    endform.                    "DBOPERATION_update
    Hope it will help you.
    Regards,
    Madan.

  • 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 use field symbols in program

    how to use field symbols can any one explain with example please..
    Regards,
    venki...

    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

  • How to use Field-symbol with dynamic select query

    Can anybody tell me, how to use field-symbols in the dynamic select query.

    FIELD-SYMBOLS <fs> { typing | STRUCTURE struc DEFAULT dobj }.
    1. ... typing
    2. ... STRUCTURE struc DEFAULT dobj
    The FIELD-SYMBOLS statement declares a field symbol <fs>. The name conventions apply to the name fs. The angle brackets of the field symbols indicate the difference to data objects and are obligatory. You can declare field symbols in any procedure and in the global declaration section of an ABAP program, but not in the declaration section of a class or an interface. You can use a field symbol in any operand position in which it is visible and which match the typing defined using typing.
    After its declaration, a field symbol is initial - that is, it does not reference a memory area. You have to assign a memory area to it (normally using the ASSIGN statement) before you can use it as an operand. Otherwise an exception will be triggered.
    eg.
    FIELD-SYMBOLS <fs> TYPE ANY.
    DATA: BEGIN OF line,
            string1(10) VALUE '0123456789',
            string2(10) VALUE 'abcdefghij',
          END OF line.
    WRITE / line-string1+5.
    ASSIGN line-string1+5(*) TO <fs>.
    WRITE / <fs>.
    output:
    56789
    56789
    reward if helpful
    anju

  • 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

  • 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

Maybe you are looking for