Move a variable to a component of a field-symbol structure ???

I have a field symbol <fs_struc> that's typed as a structure from the dictionary.
I want to move a variable to a particular component of this structure, and I've put the name of his component in another field symbol <fs_comp>.
1) Why doesn't the following syntax work?
ASSIGN variable TO <fs_struc>-<fs_comp>
(Note that there's a hyphen between <fs_struc> and <fs_comp>)
2) What is the correct syntax to do this ?
Thanks.

Hi David,
1) If you've assigned <fs_comp> to a field in a structure, then you have the memory address of the component within the structure.  This is why the syntax does not work, because <fs_comp> contains the reference already to the structure (eg. <fs_comp> =  structure-field, while <fs_field>-<fs_comp> =  structure-structure-field).  You can instead use:
ASSIGN variable TO <fs_comp>, if <fs_comp> was already assigned to a field of a structure.
2) If your scenario is that you don't know the field of the structure you want to assign in advance, you can try something like the following.  Snippet just shows how you can dynamically assign a field of a structure to another field symbol.
data: ls_kna1 type kna1.
data: lv_comp_name(5) type c value 'NAME1'.
data: o_data type ref to data.
field-symbols: <fs_data> type kna1.
field-symbols: <fs_comp> type any.
ls_kna1-name1 = 'Testing'.
CREATE DATA o_data TYPE (lv_comp_name).
      ASSIGN o_data->* TO <fs_comp>.
assign ls_kna1 to <fs_data>.
ASSIGN COMPONENT lv_comp_name OF STRUCTURE <fs_data> TO <fs_comp>.
write: <fs_comp>

Similar Messages

  • ASSIGN Component ... (field symbol stuff)

    Hi,
    I want to validate certain fields (KNA1, BUKRS, KOART, FNAME) which are
    entered by the user in the transaction XK01.  They are being captured in a structure, lets say X_LFA1.
    To validate this fields I am being asked to use field symbols using component assign.
    Can someone tell me how do I do this ?

    Tushar,
    Its still not clear to me what exactly you are trying to do.
    Is it like you just want to see if those fields exist in the table or not? If yes, you can do like this.
    parameter : p_field -- field entered by the user
    data : wa_ztable like ztable.
    field-symbols : <fs_any> type any.
    Assign component p_field of structure wa_ztable to <fs_any>.
    if sy-subrc = 0.
    Success.
    endif.
    Regards,
    Ravi

  • Assign a value to a component of a field-symbol

    Hi,
    I'm struggling with field-symbols, hope someone can help me with this:
    I have two field-symbols:
    - <row> which for example can have structure E1P0002 assigned to it;
    - <row_it> which for example can have stucture P0002 assigned to it.
    Certain components of <row> should be assigned to components of <row_it>. The names of the components differ however. For instance: component STRAS_40 of <row> should be assigned to component STRAS of <row_it>, NAME2_40 of <row> should be assigned to NAME2 of <row_it>, etc.
    Depending on the structures assigned to the field-symbols, these fields are not always available.
    Any ideas how this can be solved?
    Thanks,
    Patrick

    Hi do as follows,
              <row_wa> is the structure of type P0002
    and <row_it> is a field symbol of table type
    and another field symbol <fs> type any.
    if <row>-STRAS_40 is not initial.
    assign component  STRAS of  structure <row_wa> to <fs>.
    <fs> = <row>-STRAS_40 .
    endif.
    if <row>- NAME2_40 is not initial.
    assign component  NAME2 of  structure <row_wa> to <fs>.
    <fs> = <row>-NAME2_40 .
    endif.
    append  <row_wa> to <row_it>.
    Hope this explanation of mine helps you,
    Murthy.

  • Moving a value to a component of a field symbol

    Hi,
    I have a problem with a piece of code comparable to this one:
    FIELD-SYMBOLS:
      <structure_A> TYPE ANY,
      <structure_B> TYPE ANY,
      <component_name> TYPE ANY.
    <component_name> = 'WHATEVER'.
    " <structure_A>-<component_name> = <structure_B>-<component_name>.
    The intention is to copy a value from a component of one structure to the same component of another structure. The crux is that the structures are defined dynamically and the component's name is known during runtime only.
    Assume that the example is well-defined, i. e. all field symbols are initiated with suitable values.
    --Florian

    hi Florian,
    when the structure is only known during run time, you have to ASSIGN each field separately, something like this:
    FIELD-SYMBOLS : <field_A> TYPE ANY,
    <field_B> TYPE ANY.
    ASSIGN COMPONENT 'WHATEVER' OF structure <structure_A> TO <field_A>.
    ASSIGN COMPONENT 'WHATEVER' OF structure <structure_B> TO <field_B>.
    <field_B> = <field_A>.
    you have to repeat the above for each single field you want to copy its value
    hope this helps
    ec

  • How to access system variables in Script Component in data flow task in SSIS

    Hi,
    I am new to SSIS. Can someone tell me how to access system variable in Script Component in SSIS using C# code.
    Thanks

    You can use the System.Environment.GetEnvironmentVariable(...) to read the variables. An example is here:
    http://msdn.microsoft.com/en-us/library/y6k3c7b0.aspx
    Vikash Kumar Singh || www.singhvikash.in

  • How to move a dynamic variable to a FIELD-SYMBOL

    Hello:
    i would like to ask a favor i have been trying to move a dynamic variable to a FIELD-SYMBOL but, when i compile the programm it send a error message that say 'error with assign'.
    The FS is declared like this
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE, <dyn_wa>.
    and then there is a PERFORM that send a dynamic varible and then this variable is asigned to the <dyn_table> and after of this one variable is created like this CREATE DATA wa_dynamic LIKE LINE OF <dyn_table>.
    and finalilly there is a sentences where i trying to send the wa_dynamic to the <dyn_wa>.
    here is where the error appear.
    if you have any tips for this problem i will appreciate.
    thanks a lot
    Definition of FS
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE, <dyn_wa>.
    PERFORM
    Create dynamic internal table and Assign it to Field Symbol
      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 dynamic work area and assign to FS
    CREATE DATA wa_dynamic LIKE LINE OF <dyn_table>.
    ASSIGN wa_dynamic->* TO <dyn_wa>. "HERE IS THE PROBLEM

    How is wa_dynamic defined?
    data: wa_dynamic type ref to data.
    Regards,
    Rich Heilman

  • Accessing the variable in field symbol of nested internal table

    Hi,
    I am unable to access the variable in field symbol.
    The data in field symbol has nested structure. We need to access a variable in nested structure.
    Please find the code below:
          LOOP AT <i_fincorp> into <fs_fincorp>.
            l_madefor = <FS_FINCORP>-data_UI-ZZ0010.
          ENDLOOP.
    datatype of <i_fincorp> is type any table and <fs_fincorp> is type any.
    there is a structure 'data_ui' in <i_fincorp> and we need value of field 'ZZ0010' in data_ui structure.
    But, we are getting syntax error for statement in loop stating "There is no component like 'data_ui' in <fs_fincorp>".
    Can anyone please help me solving this issue.
    Regards,
    Santosh

    So simply access it dynamically
    data: nested_field type c length 50.
    field-symbols <nested_field> type any.
    "build the nested field name dynamically
    concatenate
           'DATA_UI'    "first give structure name
           'ZZ0010'  "then give field name (all in uppercase!)
    into nested_field
    separated by '-'.  "now you have DATA_UI-ZZ0010
    "so assing this nested field
    LOOP AT <i_fincorp> into <fs_fincorp>.
       assign component (nested_field) of structure <fs_fincorp> into <nested_field>. 
    ENDLOOP.
    Regards
    Marcin

  • 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 move field symbol internal table to internal table with header line?

    Dear all,
    hi...hereby i would like to ask how i can move field symbol internal table to a internal table?
    as i know field symbol internal table is without header line..
    so, may i know how to do this....to move field symbol internal table to internal table which consist of header line and field and record will same as field symbol internal table...in additional, my field symbol internal table is dynamic table mean everytime will have flexible columns..?
    Please advise...
    Thanks
    Regard,
    ToToRo.
    Edited by: @ToToRo@ on Aug 20, 2009 6:16 AM

    Hello,
    Try this way:
    If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
    itab = <itab>.
    Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
    Now, you can create <wa> as follow:
    FIELD-SYMBOLS <wa>.
    DATA wa TYPE REF TO DATA.
    CREATE DATA wa TYPE LINE OF <itab>.
    ASSIGN wa->* to <wa>.
    This way your work area is read.
    Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
    Finally you can use that value to load static internal table.
    You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
    Hope this helps!
    Thanks,
    Augustin.
    Edited by: Augustarian on Aug 20, 2009 10:06 AM

  • What are field symbols and field groups.? Have you used "component idx of s

    What are field symbols and field groups.? Have you used "component idx of structure"

    Field Symbols and field groups
    Field Groups / Extracts
    http://help.sap.com/saphelp_46c/helpdata/EN/9f/db9ede35c111d1829f0000e829fbfe/frameset.htm
    Field Symbols
    http://help.sap.com/saphelp_46c/helpdata/EN/fc/eb387a358411d1829f0000e829fbfe/frameset.htm
    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 Groups:
    A field group is a user-defined grouping of characteristics and basic key figures from the EC-EIS or EC-BP field catalog.
    Use
    The field catalog contains the fields that are used in the aspects. As the number of fields grows, the field catalog becomes very large and unclear. To simplify maintenance of the aspects, you can group fields in a field group. You can group the fields as you wish, for example, by subject area or responsibility area. A field may be included in several field groups.
    When maintaining the data structure of an aspect, you can select the field group that contains the relevant characteristics and basic key figures. This way you limit the number of fields offered.
    A field group combines several existing fields together under one name
    like
    FIELD-GROUPS: fg.
    then you can use one insert statement to insert values in fields of field-group.
    INSERT f1 f2 ... INTO fg.
    Field symbols
    If u have experience with 'C', then understand this to be similar to a pointer.
    It is used to reference another variable dynamically. So this field symbol will simply point to some other variable. and this pointer can be changed at runtime.
    FIELD-SYMBOLS <FS>.
    DATA FIELD VALUE 'X'.
    ASSIGN FIELD TO <FS>.
    WRITE <FS>.
    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 Groups:
    A field group is a user-defined grouping of characteristics and basic key figures from the EC-EIS or EC-BP field catalog.
    Use
    The field catalog contains the fields that are used in the aspects. As the number of fields grows, the field catalog becomes very large and unclear. To simplify maintenance of the aspects, you can group fields in a field group. You can group the fields as you wish, for example, by subject area or responsibility area. A field may be included in several field groups.
    When maintaining the data structure of an aspect, you can select the field group that contains the relevant characteristics and basic key figures. This way you limit the number of fields offered.
    Field Groups / Extracts
    http://help.sap.com/saphelp_46c/helpdata/EN/9f/db9ede35c111d1829f0000e829fbfe/frameset.htm
    Field Symbols
    http://help.sap.com/saphelp_46c/helpdata/EN/fc/eb387a358411d1829f0000e829fbfe/frameset.htm

  • How to dynamicaly (with variable) create itab - using field symbols?

    Hi,
    I need to create internal table using variable - field symbols. I think like this, but...
    data: begin of itab occurs 0.
          include structure <b>s_itab</b>.
         end of itab.
    s_itab is variable with structure of dbtab.
    I need to include variable structure table.
    i. e.
    My itab then changes structure according variable s_itab.
    First can be s_itab like table of bseg, second can be s_itab like table of hrp1001. And then I get desired itab.
    Thanks for any ideas. zd.

    Here is a sample program which should show you everything that you need to know about dynamic internal tables.
    report zrich_0002.
    type-pools: slis.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: alv_fldcat type slis_t_fieldcat_alv,
          it_fldcat type lvc_t_fcat.
    type-pools : abap.
    data : it_details type abap_compdescr_tab,
           wa_details type abap_compdescr.
    data : ref_descr type ref to cl_abap_structdescr.
    data: new_table type ref to data,
          new_line  type ref to data,
          wa_it_fldcat type lvc_s_fcat.
    selection-screen begin of block b1 with frame title text .
    parameters: p_table(30) type c.
    selection-screen end of block b1.
    * Get the structure of the table.
    ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
    it_details[] = ref_descr->components[].
    loop at it_details into wa_details.
      clear wa_it_fldcat.
      wa_it_fldcat-fieldname = wa_details-name .
      wa_it_fldcat-datatype = wa_details-type_kind.
      wa_it_fldcat-intlen = wa_details-length.
      wa_it_fldcat-decimals = wa_details-decimals.
      append wa_it_fldcat to it_fldcat .
    endloop.
    * Create dynamic internal table and assign to FS
    call method cl_alv_table_create=>create_dynamic_table
                 exporting
                    it_fieldcatalog = it_fldcat
                 importing
                    ep_table        = new_table.
    assign new_table->* to <dyn_table>.
    * Create dynamic work area and assign to FS
    create data new_line like line of <dyn_table>.
    assign new_line->* to <dyn_wa>.
    * Select Data from table.
    select * into table <dyn_table>
               from (p_table).
    * Write out data from table.
    loop at <dyn_table> into <dyn_wa>.
      do.
        assign component  sy-index  of structure <dyn_wa> to <dyn_field>.
        if sy-subrc <> 0.
          exit.
        endif.
        if sy-index = 1.
          write:/ <dyn_field>.
        else.
          write: <dyn_field>.
        endif.
      enddo.
    endloop.
    Regards,
    Rich Heilman

  • Reg Field-Symbol value trasfer into variable

    Hi,
    I'm using one FIELD-SYMBOL in one of my program. I used this to catch Hotspot Fields in List Report. It catches that required field of BELNR.
    I read the Click event through that FIELD-SYMBOL. Now I used
    DATA: HOTSPOT(18) , "VALUE 'Document No',
          F(18), OFF TYPE I, LIN TYPE I, VAL(40), LEN TYPE I.
    FIELD-SYMBOLS <FS>.
    ASSIGN HOTSPOT TO <FS>.
    WRITE <FS> HOTSPOT COLOR 3 INVERSE ON.
    AT LINE-SELECTION.
    *WINDOW STARTING AT 5 6 ENDING AT 45 20.
    GET CURSOR FIELD F OFFSET OFF
    LINE LIN
    VALUE VAL
    LENGTH LEN.
    data: click_item type bsid-belnr.
    move val to click_item.
    It moves the value into CLICK_ITEM variable. But when I try to run SELECT query with condition BELNR = CLICK_ITEM, query gives no result.
    Can you please point out my fault?
    Thanks.
    Kumar saurav.

    Try using Conversion Routine before the Select Query.
    DATA : T_BELNR TYPE BSID_BELNR.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input         = CLICK_ITEM
    IMPORTING
        OUTPUT        = T_BELNR
    and pass T_BELNR to the where condition.
    Hope this helps.

  • Move-corresponding in table type Field-Symbols

    Hi,
        I have to use one statement in field-symbol similar to "move-corresponding" in normal internal table.Is it possible to use statement similar to "Move-corresponding in field-symbols".
    For Eg:
    Field-symbols <FA_IT> type standard table.
    data:begin of wa_ekk,
       f1 type i,
       f2 type werks_d,
       f4 type posnr,
       end of wa_ekk,
    it_ekk  like standard table of wa_ekk.
    begin of wa_final,
       f1 type i,
       f2 type werks_d,
       f3 type i,
       f4 type n,
    end of wa_final,
    it_final like standard table of wa_final.
    assign it_ekk to <fs_it>.
    Loop at <fs_it>.
    *???????-i dont know how to move the value to it_final
    *---I know I can use assign component statement
    *-to move each field  to the target field
    but for that we need to know the field name or index position of the structure-
    Endloop.
    My requirment is now i want to move the content of <fs_it> into it_final internal table.
    I know that In normal itab we can use "move-corresponding" to move the value from it_ekk to it_final.
    In the same way how to use it in field-symbol concept.
    Requirement:Real time Processing of Internal table
    1) Content of it_ekk:
    f1   f2       f4
    12  1000  0023
    23  2000  0037
    2)After ASSIGN statement:
    Content of <fs_it> is:
    f1   f2       f4
    12  1000  0023
    23  2000  0037
    3)Now I want to move the content of <fs_it> to it_final
    Output of It_final:
    F1   F2    F3    F4
    12  1000   ---    0023
    23  2000   ---    0037
    Regards,
    Vigneswaran S

    Andrey's code is going to work only if you are running it in a non-unicode system.
    See code below for a Unicode system using similar effect to "Move-Corresponding" statement.
    FIELD-SYMBOLS: <fs_ekk> LIKE wa_ekk,
                   <fs_final> LIKE wa_final.
    ASSIGN it_ekk TO <fs_it> .
    LOOP AT <fs_it> ASSIGNING <fs_ekk>.
      ASSIGN <fs_ekk> TO <fs_final> CASTING.
      CLEAR <fs_final>-f3.
      APPEND <fs_final> TO it_final.
    ENDLOOP.
    Hope this solves your problem and please don't forget to reward points.
    Cheers,
    Sougata.

  • Field symbol to move column of one ITAB to row of another ITAB

    Hello , I need some help on this . I have two ITAB's
    Like ITAB1 with 1  field  and
    ITAB2 with say around 100 fields and all the field name are different in ITAB2 .
    Now ITAB1 has 1 column and 100 rows data in it . I want to move all the values from the rows of ITAB1 into next to next fields of ITAB2 on a single row . Like this.
    ITAB1
    1
    2
    3
    5
    I Want to move these five rows to ITAB2  like below
    ITAB 2
    1     2      3      4     5
    Not able to use do varrying as field names of ITAB2 are diff . Also dont want to write a lengthy code for manual field to field movement . Any help . is it possible to get this done using field symbol.
    Thanks
    J

    Solved . Below thing helped me .
    field-SYMBOLS <fs> TYPE any.
    FIELD-SYMBOLS <comp> TYPE ANY.
    ASSIGN wa_it2 to <fs>.    " target ITAB work area
    loop at it1.
      ASSIGN COMPONENT sy-tabix of STRUCTURE <FS> to <comp>.
      <comp> = it1-f1.
    endloop .
    append wa_it2 to it2.
    UNASSIGN : <fs> , <comp> .
    Cheers
    J

  • Using variable with the same name as field name?

    I have a complex proc where I have variables with the same name as field name used on a query. something like this:
    SELECT a.id_table WHERE a.id_table = id_table
    where the last id_table is a parameter sent to the proc:
    declare procedure myproc(id_table int)
    Is there any way or notation to declare the variable inside the query as a variable or I have to use a different name?

    Well, variables are not the only thing you have to change if you want to switch to Oracle.
    Although I don't think it is good practice (to use variable name same as column name), here is one example how you can achieve it using EXECUTE IMMEDIATE and bind variable
    SQL> select deptno, count(1)
      2  from scott.emp
      3  group by deptno;
        DEPTNO   COUNT(1)
            30          6
            20          5
    10 3
    SQL> set serveroutput on
    SQL> declare
      2  deptno varchar2(10);
      3  i number;
      4  begin
      5  deptno:=10;
      6  execute immediate
      7  'select count(1) from scott.emp where deptno=:deptno' into i using deptno;
      8  dbms_output.put_line('OUT ---> '||i);
      9  end;
    10  /
    OUT ---> 3
    PL/SQL procedure successfully completed.
    SQL> Message was edited by:
    tekicora
    Message was edited by:
    tekicora

Maybe you are looking for

  • How do I find documents in DCIM

    I downlauded some documents frpom my pc into the DCIM. How can I find these documents at the ipad?

  • Error -694 Volume Structure???

    Ran tech tool cd and it could not fix volume structure error and showed error -694. Does anyone know what this means? Just archived and reinstalled OSX yesterday to fix a boot up problem, which it did. But now after doing the needed updates - wheneve

  • Navigation buttons and many such icons show up like a add-on bar during start-up

    The icons show up for just a few seconds at the bottom of the browser window. Here is the screenshot http://postimg.org/image/fx7buzsxj/

  • Multiple Intercompany scenario

    Hi experts,  i have a question. Im trying to create an intercompany process. I have seven company codes (A, B, C, D, E, F,G) and each company code has its own Plant (P1, P2, etc) and one sales organization per company code (SO1, SO2, etc) Co. code-->

  • Sub Contractor challan Reconcillation after subsequent adjustment

    Dear Friends, I am sending 1 kg of material to receive back 1kg of material the sub contractor uses .90 kg to make 1 kg of the reqd material. So I do subsequent adjustment after MIGO for under consumption of  0.10kg Now after doing subsequent adjustm