Assign Type conflict with field symbols

I have two tables tab1 & tab2, want to assign field values from tab1 to tab2 suing field symbols. Deatils are :
TYPES: BEGIN OF ty_tab1,
    item1   TYPE char20,
    item2   TYPE char20,
    val1 type i,
    val2 type i,
END OF ty_tab1,
BEGIN OF ty_tab2,
    item1 TYPE char20,
    item2 TYPE char20,
END OF ty_tab2.
DATA: it_tab1 TYPE TABLE OF ty_tab1,
            it_tab2 TYPE TABLE OF ty_tab2.
  FIELD-SYMBOLS <fs_tab1> TYPE ty_tab1.
                 <fs_tab2t> type ty_tab2.
  LOOP AT it_tab1 assigning <fs_tab1>.
    READ TABLE it_tab2  assigning <fs_tab2> WITH KEY item1 = <fs_tab1>-item1
                                                                                item2 = <fs_tab1>-item2.
    IF sy-subrc EQ 0.
      ASSIGN COMPONENT 'ITEM1' OF STRUCTURE <fs_tab1> TO <fs_tab2>.
     ASSIGN COMPONENT 'ITEM2' OF STRUCTURE <fs_tab1> TO <fs_tab2>.
    endif.
endloop.
Getting error msg
You attempted to assign a field to a typed field symbol, but the field does not have the required type.         
whats the reason of error.
Edited by: Matt on May 27, 2011 8:59 AM - added  tags

Taken from example dump
A new value is to be assigned to the field "...", although this field is
entirely or partly protected against changes.
The following are protected against changes:
- Character literals or numeric literals
- Constants (CONSTANTS)
- Parameters of the category IMPORTING REFERENCE for functions and
methods
- Untyped field symbols not yet assigned a field using ASSIGN
- TABLES parameters if the actual parameter is protected against changes
- USING reference parameters and CHANGING parameters for FORMs, if the
actual parameter is protected against changes and
- Accesses using field symbols if the field assigned using ASSIGN is
protected (or partially protected, e.g. key components of an internal
table with the type SORTED or HASHED TABLE) against changes
- Accesses using references, if the field bound to the reference is
protected (or partially protected) against changes
- External write accesses to READ-ONLY attributes,
- Content of a shared object area instance accessed using a shared lock
(ATTACH_FOR_READ).
You likely fall in one of these cases. Check each and if still unsure please share your code so we can reproduce the error.
Regards
Marcin

Similar Messages

  • Run Time: type conflicts in field symbol

    In this statement i am getting run time error : assign component.
    type conflicts in field symbol
    FIELD-SYMBOLS:
        <fs_tab> TYPE ANY table,
         <wa_tab> TYPE ANY,
         <fs_field> type crmd_orderadm_h.
    DATA:      w_data    TYPE REF TO data.
    CREATE DATA w_data TYPE STANDARD TABLE OF (c_tabname) WITH NON-                     UNIQUE DEFAULT KEY.
        ASSIGN w_data->* TO <fs_tab>.
    SELECT * FROM (c_tabname)
              INTO CORRESPONDING FIELDS OF TABLE <fs_tab>
      LOOP AT <fs_tab> ASSIGNING <wa_tab>.
          DO.
            ASSIGN COMPONENT sy-index OF STRUCTURE <wa_tab> TO <fs_field>.
    *Writeing: fs_field here*
    Enddo.

    FIELD-SYMBOLS: <fs_field> type crmd_orderadm_h.
    <fs_field> type any.
    i cannot pass "
      lv_header_guid =    <fs_field>-guid.
    complete code as follows.
      LOOP AT <fs_tab> ASSIGNING <wa_tab>.
          DO.
            ASSIGN COMPONENT sy-index OF STRUCTURE <wa_tab> TO <fs_field>.
    *i am assining fs_field-guid here. Thats why i am taking this field symbol as type "crmd_orderadm_h"*
    *bold* * <fs_field>-guid.*bold**
            lv_header_guid =    <fs_field>-guid.
            iv_header_guid = lv_header_guid.
            REFRESH: lt_header_guid.
            INSERT iv_header_guid INTO TABLE lt_header_guid.
            REFRESH: im_orderadm_h,im_text.
            CALL FUNCTION 'CRM_ORDER_READ'
              EXPORTING
                it_header_guid       = lt_header_guid
              IMPORTING
                et_orderadm_h        = im_orderadm_h
                et_text              = im_text
              EXCEPTIONS
                document_not_found   = 1
                error_occurred       = 2
                document_locked      = 3
                no_change_authority  = 4
                no_display_authority = 5
                no_change_allowed    = 6
                OTHERS               = 7.
            IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            ENDIF.
          ENDDO.

  • Type Conflict In Field Symbol

    Hi All,
    We were doing a report to read all major infotypes and displaying the relevant data. It was working fine  until we included Personal data (Infotype 0002).
    We used a field symbol of type any and pnnnn type prelp. It was working fine. But when we included details from PA0002, it is throwing a runtime error stating type conflict between field symbol and pnnnn. (We used pnnnn[] = <f>.
    Note: We are using ECC 6.0 and the program is Unicode enabled
    Kind Regards
    Hari Sankar M

    Hi Prince,
    Yes. You need to change the declaration as follows.
    Field symbols:<wa_ext> TYPE ANY,
                          <f_zname> TYPE any.
    Data: lv_zname type sname.
    ASSIGN COMPONENT 86 OF STRUCTURE <wa_ext> TO <f_zname>.
    lv_zname = <f_zname>.
    Try the above mentioned code. I think this should work.
    Best Regards,
    Ram.

  • How to dynamically assign type to a field-symbol?

    Hi,
    I have two fields in one table, one for field name and one for table name.  These can be fields in different
    tables. I need to fetch value of this field in that table. So the type of this variable can change dynamically.
    I am trying to assign type of this field dynamically to a field-symbol. I have to use this field symbol in a
    select statement.  Currently it is showing a dumb, as the field type is dec7.  For some other types it is
    working fine.
    Regards,
    Sunil

    Hi all,
    I have the same problem.
    I tried with your helps but i can't fix them.
    A message is raised "Field <fs_bet> unknown" when i used code below
    FIELD-SYMBOLS: <fs_bet> TYPE any.
    DATA: c_bet TYPE string.
    DATA it_0008 type STANDARD TABLE OF pa0008 WITH HEADER LINE.
    DO 40 TIMES.
      CONCATENATE 'BET0' index into c_bet.
      ASSIGN (c_bet) to <fs_bet> CASTING TYPE pad_amt7s  .
      select * from pa0008 into it_0008
         where <fs_bet> = '1000'
         and pernr = 32.
         append it_0008.
      ENDSELECT.
    ENDDO.
    Please help me to solve it.
    Thanks so much,
    Sophie Tran

  • 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

  • Type conflict with ASSIGN in program CL_WD_ADOBE_SERVICES==========CP

    I am trying to display an interactive Adobe Form in the webdynpro for abap.
    But i'm getting this error:
    The following error text was processed in system AED : Type conflict with ASSIGN in program CL_WD_ADOBE_SERVICES==========CP .
    The error occurred on application server AIERD_AED_00 and in work process 1 .
    The termination type was: RABAX_STATE
    The ABAP call hierarchy was:
    Method: NODE_2_DDIC of program CL_WD_ADOBE_SERVICES==========CP
    Method: DATASOURCE_2_FM_PARAMS of program CL_WD_ADOBE_SERVICES==========CP
    Method: CREATE_PDF_DDIC of program CL_WD_ADOBE_SERVICES==========CP
    Method: CREATE_PDF of program CL_WD_ADOBE_SERVICES==========CP
    Method: IF_NW7_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/CADOBE==================CP
    Method: IF_NW7_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/CADOBE==================CP
    Method: IF_NW7_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/C8STANDARD==============CP
    Method: IF_NW7_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/C8STANDARD==============CP
    Method: IF_NW7_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/C7STANDARD==============CP
    Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program CL_WDR_VIEW_ADAPTER===========CP
    Is there any problem with some Adobe config or somewhere a mistake in my code.

    Follow this thread
    [Displaying a Smartform as PDF in WDA;
    Thanks
    Siva

  • Type conflict with ASSIGN in program in Release time(ESS)

    Hi All,
    On clicking on the link "Release Working Time Data" from EP While releasing working time below exception is being thrown.
    com.sap.tc.webdynpro.modelimpl.dynamicrfc.WDDynamicRFCExecuteException: Type conflict with ASSIGN in program SAPLHRXSS_CAT_WEBDYNP., error key: RFC_ERROR_SYSTEM_FAILURE
         at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClassExecutable.execute(DynamicRFCModelClassExecutable.java:101)
         at com.sap.xss.hr.cat.release.blc.FcCatRelease.rfcExecute(FcCatRelease.java:494)
         at com.sap.xss.hr.cat.release.blc.FcCatRelease.rfcDoInit(FcCatRelease.java:424)
         at com.sap.xss.hr.cat.release.blc.FcCatRelease.onInit(FcCatRelease.java:377)
         at com.sap.xss.hr.cat.release.blc.wdp.InternalFcCatRelease.onInit(InternalFcCatRelease.java:274)
         at com.sap.xss.hr.cat.release.blc.FcCatReleaseInterface.onInit(FcCatReleaseInterface.java:194)
         at com.sap.xss.hr.cat.release.blc.wdp.InternalFcCatReleaseInterface.onInit(InternalFcCatReleaseInterface.java:166)
         at com.sap.xss.hr.cat.release.blc.wdp.InternalFcCatReleaseInterface$External.onInit(InternalFcCatReleaseInterface.java:258)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent$FPM.attachComponentToUsage(FPMComponent.java:922)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent$FPM.attachComponentToUsage(FPMComponent.java:891)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent$FPMProxy.attachComponentToUsage(FPMComponent.java:1084)
         at com.sap.xss.hr.cat.release.vac.entry.VcCatReleaseEntry.onInit(VcCatReleaseEntry.java:270)
         at com.sap.xss.hr.cat.release.vac.entry.wdp.InternalVcCatReleaseEntry.onInit(InternalVcCatReleaseEntry.java:174)
         at com.sap.xss.hr.cat.release.vac.entry.VcCatReleaseEntryInterface.onInit(VcCatReleaseEntryInterface.java:189)
    Pls help to resolve the isuue
    Thanks,
    JB

    Hard closed

  • Type conflict with ASSIGN in BADI for Virtual Key Figures

    We get the below error dump in ST22 when executing BEx queries that contain virtual key figures.
    error message - 'Type conflict with ASSIGN in
    program "ZCL_IM_THR_RSR_OLAP_BADI======CP".'
    We have a BADI implementation that calculates few virtual key figures included in some infocubes & multiproviders. The error would arise if we execute two queries (containing common Virtual Key figures) one after the other without closing the first query.
    We found a note "Note 1237689 - Virtual chars. and key figures in input-ready querys" that could be relevant to our issue and wanted to apply this note but unfortunately the note is only applicable to SAPKW70016 to SAPKW70018 and we are support pack 15.
    Can you please advise what the problem could be/suggest corrections for the same.

    Hi Kulmohan,
    Did you fix your issue? We are facing the same issue. Could you please let me know if you have any solution for this issue,
    Thank you,
    Mike

  • To Modify a field value with field symbols

    we had a requirement like we are getting in a floating point value in a field of an IDoc segment like 12.327- .Here if we see that the negative sign is after the floating point value and if we try to insert this into a database then it will throw out an error.Before inserting the value we need to covert the incoming value in the form -12.327.
    I used the field symbols inorder to get the values and to change them.
    But iam not able to modify the internal table from the new value.
    Here is my sample code.
    DATA: IT_MBEW TYPE TABLE OF MBEW,
          WA_MBEW TYPE MBEW,
          IT_DFIES TYPE TABLE OF DFIES,
          WA_DFIES TYPE DFIES,
          IT_DD03L TYPE TABLE OF DD03L,
          WA_DD03L TYPE DD03L,
          L_FIELD TYPE VALUE,
          WA_VALUE TYPE mbew,
          L_MBEW TYPE DDOBJNAME VALUE 'MBEW'.
    FIELD-SYMBOLS: <FS1> TYPE ANY.
    FIELD-SYMBOLS: <FS3> TYPE ANY.
    FIELD-SYMBOLS: <FS2> TYPE ANY.
    SELECT * INTO CORRESPONDING FIELDS OF TABLE IT_MBEW
      FROM MBEW  WHERE MATNR = '000000000000100110'.
    LOOP AT IT_MBEW INTO WA_MBEW.
      WA_MBEW-SALK3 = - 354471.
      MODIFY IT_MBEW FROM WA_MBEW.
    ENDLOOP.
    To call the FM inorder to get the fieldnames for MBEW table
    CALL FUNCTION 'DDIF_FIELDINFO_GET'
      EXPORTING
        TABNAME              = L_MBEW
        FIELDNAME            = ' '
       LANGU                = SY-LANGU
        LFIELDNAME           = ' '
       ALL_TYPES            = ' '
        GROUP_NAMES          = ' '
        UCLEN                =
      IMPORTING
        X030L_WA             =
        DDOBJTYPE            =
        DFIES_WA             =
        LINES_DESCR          =
    TABLES
       DFIES_TAB            = IT_DFIES
        FIXED_VALUES         =
    EXCEPTIONS
       NOT_FOUND            = 1
       INTERNAL_ERROR       = 2
       OTHERS               = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    SELECT TABNAME FIELDNAME DATATYPE POSITION INTO CORRESPONDING FIELDS OF TABLE
             IT_DD03L FROM DD03L
             WHERE TABNAME = 'MBEW'
             AND   DATATYPE = 'CURR'
             ORDER BY POSITION ASCENDING.
    *LOOP AT IT_MBEW INTO WA_MBEW.
    LOOP AT IT_MBEW assigning <fs1>.
    ASSIGN WA_MBEW TO <FS1>.
    do.
      LOOP AT IT_DD03L INTO WA_DD03L.
        READ TABLE IT_DFIES INTO WA_DFIES WITH  KEY FIELDNAME = WA_DD03L-FIELDNAME
                                          DATATYPE = WA_DD03L-DATATYPE.
        IF SY-SUBRC = 0.
          ASSIGN WA_DFIES-FIELDNAME TO <FS2>.
          ASSIGN COMPONENT SY-TABIX OF STRUCTURE <FS1> TO <FS3>.
          MOVE <FS3> TO L_FIELD.
          CONDENSE L_FIELD.
          CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
            CHANGING
              VALUE = L_FIELD.
          IF SY-SUBRC = 0.
            ASSIGN L_FIELD TO <FS3>.
                    MODIFY ITMBEW INDEX SY-TABIX FROM <FS3>._    
    ENDIF.
        ENDIF.
      ENDLOOP.
    *enddo.
    ENDLOOP.
    The Modify statement is not working.....Plesae help me in this regard.
    Thanks
    Srinivas

    Hello.
    When you write,
    LOOP AT it_mbew ASSIGNING <fs1>.
    ENDLOOP.
    you don't need to use statements:
    ASSIGN WA_MBEW TO <FS1>
    nor
    MODIFY it_mbew
    after that.
    If you just write:
    LOOP AT it_mbew ASSIGNING <fs1>.
      <fs1>-field1 = 'A'.
      <fs1>-field2 = 'B'.
    ENDLOOP.
    all records of it_mbew will have field1 = 'A' and field2 = 'B'.
    The point is, statement LOOP assigning <fs1> will make the field symbol to became a pointer to the records of the internal table. So, if you change the field symbol, you are changing the internal table already.
    Regards.
    Valter Oliveira.

  • Dynamic Internal table with field symbol

    I made the report where the user enters two different tables and two fields that are to be compared.
    Eg. If I enter (MARA & NAME1) and (MARC & NAME2) , I wish to compare all the entries of Mara-name1 against all entries in Marc-name2.
    <u>The code I need to write is:</u>
    DATA:
      gdo_data      TYPE REF TO data.
    DATA:
      gdo_data1      TYPE REF TO data.
    FIELD-SYMBOLS:
      <gt_itab>     TYPE table,
        <wa> LIKE <gt_itab>,                        "<gt_itab>,
      <gs_entry>    TYPE ANY.
    FIELD-SYMBOLS:
      <gt_itab1>     TYPE table,
        <wa1> LIKE <gt_itab>,                        "<gt_itab>,
      <gs_entry1>    TYPE ANY.
    PARAMETERS:
      p_table    TYPE tabname,            "    DEFAULT 'KNA1',
      p_fld      TYPE fieldname.          "  DEFAULT 'KUNNR'.
    PARAMETERS:
      p_table1    TYPE tabname,            "    DEFAULT 'KNA1',
      p_fld1      TYPE fieldname.
    DATA: var TYPE fieldname.
    var = p_fld.
    DATA: var1 TYPE fieldname.
    var1 = p_fld1.
    START-OF-SELECTION.
      CREATE DATA gdo_data TYPE TABLE OF (p_table).
      ASSIGN gdo_data->* TO <gt_itab>.
      CREATE DATA gdo_data1 TYPE TABLE OF (p_table1).
      ASSIGN gdo_data1->* TO <gt_itab1>.
      SELECT * FROM (p_table) INTO CORRESPONDING FIELDS OF TABLE <gt_itab>.
      SELECT * FROM (p_table1) INTO CORRESPONDING FIELDS OF TABLE <gt_itab1>.
    <b>  LOOP AT <gt_itab> ASSIGNING <gs_entry>.
        READ TABLE <gt_itab1> ASSIGNING <gs_entry1>
             WITH KEY (var1) = <gt_itab>-(var).
        IF sy-subrc EQ 0.
          MESSAGE 'Success' TYPE 'S'.
        ENDIF.
      ENDLOOP.</b>
    END-OF-SELECTION.
    But the portion in bold is creating error: <b><gt_itab> is a table without a header lineand therefore has no component called "".</b>
    please help.

    Hi Amit
    Try like this
    LOOP AT <gt_itab> ASSIGNING <gs_entry>.
    READ TABLE <gt_itab1> ASSIGNING <gs_entry1>
    WITH KEY (var1) = <b><gs_entry></b>-(var).
    IF sy-subrc EQ 0.
    MESSAGE 'Success' TYPE 'S'.
    ENDIF.
    ENDLOOP.
    Regards,
    Atish

  • Problem with field-symbol values not updating

    H i ,
          I have following piece of code :
    Assigning Dynamic Table to Field Symbol
        ASSIGN ist_dyn_table->* TO <gs_dyn_table>.
    *   Creating Structure for dynamic table
        CREATE DATA gs_dyn_line LIKE LINE OF <gs_dyn_table>.
    *   Creating line type for the Dynamic Values
        ASSIGN gs_dyn_line->* TO <gs_line>.
    *   Populating values in the dynamic table
        LOOP AT ist_pwcl_main INTO wa_pwcl_main.
          ASSIGN COMPONENT gc_fld_werks OF STRUCTURE <gs_line> TO <gs_field>.
       1   IF sy-subrc EQ 0.
       2        <gs_field> = wa_pwcl_main-werks.
       3      ENDIF.
       5  IF <gs_field> IS ASSIGNED.
       6     <gs_field> = wa_pwcl_main-vbeln.
          ENDIF.
      7 IF <gs_field> IS ASSIGNED.
      8  <gs_field> =  wa_pwcl_main-posnr.
          ENDIF.
       IF <gs_field> IS ASSIGNED.
            <gs_field> = wa_pwcl_main-quant.
          ENDIF.
    on debugging  at line 2 <gs_filed> contains the value of werks .
    but at line 6 <gs_field> contains value of vbeln as 0 and at 8 of posnr as 0 .
    What can be the problem ? Other values are getting assigned properly .
    Plz help ...
    Regards .

    Hi,
    Assigning Dynamic Table to Field Symbol
        ASSIGN ist_dyn_table->* TO <gs_dyn_table>.
      Creating Structure for dynamic table
        CREATE DATA gs_dyn_line LIKE LINE OF <gs_dyn_table>.
      Creating line type for the Dynamic Values
        ASSIGN gs_dyn_line->* TO <gs_line>.
      Populating values in the dynamic table
        LOOP AT ist_pwcl_main INTO wa_pwcl_main.
          ASSIGN COMPONENT gc_fld_werks OF STRUCTURE <gs_line> TO <gs_field>.
       1   IF sy-subrc EQ 0.
       2        <gs_field> = wa_pwcl_main-werks.
       3      ENDIF.
       5  IF <gs_field> IS ASSIGNED.
       6     <gs_field> = wa_pwcl_main-vbeln.
          ENDIF.
      7 IF <gs_field> IS ASSIGNED.
      8  <gs_field> =  wa_pwcl_main-posnr.
          ENDIF.
       IF <gs_field> IS ASSIGNED.
            <gs_field> = wa_pwcl_main-quant.
          ENDIF.
    Based on your coding above, <gs_field> has been assigned with data type 'WERKS' (i'd assume component gc_fld_werks found from structure <gs_line> is a plant typed), which is a CHAR(4) data type.
    Meaning, if <gs_field> is assigned with Plant type value, e.g. <gs_field> = '1000', field symbol <gs_field> will contain 4 character only.
    At line 6, if wa_pwcl_main-vbeln = '0000201000', <gs_field> is only capturing '0000' only. This is also happened to line 8.
    However, it looks like that <gs_field> is getting over-write if ASSIGNED statement returns SY-SUBRC = 0.
    Hope this helps.
    Regards,
    Patrick

  • Problem with FIELD SYMBOL upgrading from 46c to ECC6.0

    Hi people... i'm having big trouble making an upgrade from 4.6c to ECC6.0 with this portion of code of Z's programm.
    In the line
    ASSIGN (w_field) TO <fs_field>.
    i don't see any assigment, so <fs_field> remains empty, when enters into firts IF conditions it is TRUE, then go into second IF condition, it is FALSE, and finally assing
    <fs_field> = '/'.
    , at this point i have a DUMP telling me MOVE_TO_LIT_NOTALLOWED_NODATA
    I'm try any way of definition, assigment, but always i have a DUMP.
    Someone can give a hand with this issue!
    Thanks in advance!!!
    This is the full code from the FORM with the problem.
    *       FORM GRABA                                        *
    *  -->  VALUE(P_TABLE)                                  *
    FORM graba USING value(p_table) TYPE c.
      DATA:
        w_field(60),
        w_dd03l  TYPE dd03l.
      FIELD-SYMBOLS <fs_field>.
      CLEAR w_flag.
      CASE p_table.
        WHEN 'BGR00'.
          d_bgr00-group  = w_batin.
          d_bgr00-mandt  = sy-mandt.
          d_bgr00-usnam  = sy-uname.
          d_bgr00-xkeep  = 'X'.
          d_bgr00-nodata = '/'.
          d_bgr00-stype = 0.
          TRANSFER d_bgr00 TO w_fname.
        WHEN 'BBKPF'.
          LOOP AT gt_dd03l INTO w_dd03l WHERE tabname EQ p_table.
            CONCATENATE
                'd_'
                w_dd03l-tabname
                w_dd03l-fieldname
              INTO w_field.
            ASSIGN (w_field) TO <fs_field>.
            IF <fs_field> IS INITIAL OR <fs_field> EQ '/'.
              IF w_dd03l-fieldname EQ 'TBNAM'.
                <fs_field> = p_table.
              ELSE.
                <fs_field> = '/'.
              ENDIF.
            ELSE.
              w_flag = 'X'.
            ENDIF.
          ENDLOOP.
          TRANSFER d_bbkpf TO w_fname.
        WHEN 'BBSEG'.
          LOOP AT gt_dd03l INTO w_dd03l WHERE tabname EQ p_table.
            CONCATENATE
                'd_'
                w_dd03l-tabname
                w_dd03l-fieldname
              INTO w_field.
            ASSIGN (w_field) TO <fs_field>.
            IF <fs_field> IS INITIAL OR <fs_field> EQ '/'.
              IF w_dd03l-fieldname EQ 'TBNAM'.
                <fs_field> = p_table.
              ELSE.
                <fs_field> = '/'.
              ENDIF.
            ELSE.
              w_flag = 'X'.
            ENDIF.
          ENDLOOP.
          TRANSFER d_bbseg TO w_fname.
      ENDCASE.
    ENDFORM.
    Edited by: Matt on Dec 15, 2008 5:03 PM - Made subject more informative

    Gentlemen:
    The problem around this statement:
    ASSIGN (w_field) TO <fs_field>
    is explained as follows:
    1. In ABAP language, there are two ways for assigning a new value to a field-symbol.
    - Sentence: ASSIGN (values) TO <my_field_symbol>.
      In this case, the <my_field_symbol> receives from (w_field) the data type and value content of this variable. So, we keep that a FSymbol is assigned and, at the same time, receives an initial value.
    - Sentence: <my_field_symbol> = '/' or <my_field_symbol> = my_var.
      In this way, we only pass the content of the variable next to = sign. But before this, the field-symbol must had been assigned (using ASSIGN statement), in another case, the compiler raises an exception.
    Following the example of Federico... I think he tried to assign a field like this (please, supose the program imports the structure of a database table with a standard function, into a internal table which is looped by the work area w_field ):
    - If w_field contains 'BKPF-WERKS', so sentence ASSIGN will affect the field symbol, passing to this the data type and current content of table field BKPF-WERKS.
    - If w_field contains 'BKPF-.INCLUDE': *the column .INCLUDE obviously is not associated with a data type... so our statement ASSIGN... TO... never pass any data type or value to our field-symbol. So that, this field is never initialized properly, and when inmmediately you try to execute something like this: <my_field_symbol> = '/', the game (program) is over.. XD
    I hope this post was helpful for anyone...
    Best Regards!!
    RRG
    ABAPer(u) - EVOLution

  • Problem with field-symbols in UNICODE conversion

    Hi all.
    I'm in a UNICODE conversion project and I have a problem with a program that uses field-symbols.
    DATA: BEGIN OF wa_data_aux,
            mandt LIKE zindices-mandt,
            kschl LIKE zindices-kschl,
            datab LIKE zindices-datab,
            valor LIKE zindices-valor,
            descripcion LIKE zindices-descripcion,
            ernam LIKE zindices-ernam,
            erdat LIKE zindices-erdat,
            waers LIKE zindices-waers,
          END OF wa_data_aux.
    FIELD-SYMBOLS:
                   <fs2>  TYPE ANY,
                   <fs3>  LIKE wa_data_aux.
              <fs2> = <fs3>.
    This assignment results in a DUMP.
    Can anybody help me to solve this problem?
    Thanks!!

    TYPES: BEGIN OF wa_data_aux,
              mandt TYPE mandt,
              kschl TYPE kschl,
              erdat TYPE d,
              waers TYPE waers,
          END OF wa_data_aux.
    DATA: w_aux TYPE wa_data_aux.
    FIELD-SYMBOLS:
    <fs2> TYPE ANY,
    <fs3> TYPE wa_data_aux.
    w_aux-mandt = '300'.
    ASSIGN w_aux TO <fs3>.
    ASSIGN <fs3> TO <fs2>.
    WRITE : / <fs2>.
    GBY.

  • Dynamically table read / write with field symbols

    Hi,
    I like to read dynamically from a table via field symbols. The reading part is working.
    But now I like to do some changes on the entry and then write it to another table with a similar structure.
    I use SAP 4.6c
    There I have two problems:
    1. At the statement I get a dump:
    <l_sysid> = sy-sysid.
    --> Field symbol has not yet been assigned.
    I think that the problem is somewhere around
    assign <table_to> to <wa_to>.
    2. the data change inside the loop. There I like to add the sysid to the target-wa and then copy the source-wa it to the new target-wa to append it to the target table.
    But this does not work. What kind of code do I need? The "move-correspondig" is not correct.
    --> see code around
    loop at <table_from> assigning <wa_from>.
    Below you can find my code. The problem is within the last loop-statement.
    FUNCTION Z_MIG_COPY_TABLE.
    *"*"Lokale Schnittstelle:
    *"  IMPORTING
    *"     REFERENCE(I_TABNAME_FROM) TYPE  TABNAME
    *"     REFERENCE(I_TABNAME_TO) TYPE  TABNAME
    *"     REFERENCE(I_KOMP_TRANS) LIKE  ZS_KOMP_TRANS STRUCTURE
    *"        ZS_KOMP_TRANS OPTIONAL
    *"  TABLES
    *"      I_SELCON STRUCTURE  ZS_SELCON
    *"  EXCEPTIONS
    *"      NOT_FOUND
    *"      OTHERS
    * zeilenweiser Aufbau Tabelle I_SELCON z.B.:
    * bukrs = 3011
    * AND
    * bstyp = 'F'
    * I_KOMP_TRANS
    * dient zur Uebersetzung von alt/neu, z.B. bei LIFNR
    * der angegebene Funktionsbaustein wird genutzt,
    * um den neuen Wert der übergebenen Komponente zu ermitteln
    * Angabe z.B.:
    * LIFNR
      DATA: dref       TYPE REF TO data,
            dref_to    TYPE REF TO data,
            i_alv_cat  TYPE TABLE OF lvc_s_fcat,
            ls_alv_cat LIKE LINE OF i_alv_cat,
            i_alv_cat_to  TYPE TABLE OF lvc_s_fcat,
            ls_alv_cat_to LIKE LINE OF i_alv_cat.
      DATA: BEGIN OF itab OCCURS 0.
    *        INCLUDE STRUCTURE dntab.
              INCLUDE structure DFIES.
      DATA: END OF itab.
      DATA: BEGIN OF itab_to OCCURS 0.
    *        INCLUDE STRUCTURE dntab.
              INCLUDE structure DFIES.
      DATA: END OF itab_to.
      FIELD-SYMBOLS: <table_from>   TYPE ANY TABLE.
      FIELD-SYMBOLS: <table_to>     TYPE Standard TABLE.
      FIELD-SYMBOLS: <wa_from>      TYPE ANY.
      FIELD-SYMBOLS: <wa_to>        TYPE ANY.
      FIELD-SYMBOLS: <l_komp>       TYPE ANY.
      FIELD-SYMBOLS: <l_sysid>      TYPE ANY.
      Data: l_alt type ELIFN.
      Data: l_neu type ELIFN.
      CALL FUNCTION 'DDIF_NAMETAB_GET'
           EXPORTING
                TABNAME   = i_tabname_from
           TABLES
                DFIES_TAB = itab
           EXCEPTIONS
                NOT_FOUND = 1
                OTHERS    = 2.
      IF SY-SUBRC = 1.
        raise not_found.
      elseif sy-subrc = 2.
        raise others.
      ENDIF.
      LOOP AT itab .
        ls_alv_cat-fieldname = itab-fieldname.
        ls_alv_cat-ref_table = i_tabname_from.
        ls_alv_cat-ref_field = itab-fieldname.
        APPEND ls_alv_cat TO i_alv_cat.
      ENDLOOP.
    * build internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
          EXPORTING
            it_fieldcatalog = i_alv_cat
          IMPORTING
            ep_table = dref.
      ASSIGN dref->* TO <table_from>.
      CALL FUNCTION 'DDIF_NAMETAB_GET'
           EXPORTING
                TABNAME   = i_tabname_to
           TABLES
                DFIES_TAB = itab_to
           EXCEPTIONS
                NOT_FOUND = 1
                OTHERS    = 2.
      IF SY-SUBRC = 1.
        raise not_found.
      elseif sy-subrc = 2.
        raise others.
      ENDIF.
      LOOP AT itab_to.
        ls_alv_cat_to-fieldname = itab_to-fieldname.
        ls_alv_cat_to-ref_table = i_tabname_to.
        ls_alv_cat_to-ref_field = itab_to-fieldname.
        APPEND ls_alv_cat_to TO i_alv_cat_to.
      ENDLOOP.
    *  break-point.
    * build internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
          EXPORTING
            it_fieldcatalog = i_alv_cat_to
          IMPORTING
            ep_table = dref_to.
      ASSIGN dref_to->* TO <table_to>.
    *Select Ursprungstabelle mit Selektionsbedingungen
      SELECT * FROM (i_tabname_from) up to 5 rows
        INTO CORRESPONDING FIELDS OF TABLE <table_from>
        where (i_selcon).
    *  break-point.
    *Aufbau interne Tabelle mit eventuell geänderten Feldern
      assign <table_to> to <wa_to>.
      if not I_KOMP_TRANS is initial.
        loop at <table_from> assigning <wa_from>.
          assign component I_KOMP_TRANS-KOMP
            of structure <wa_from> to <l_komp>.
          CALL FUNCTION I_KOMP_TRANS-FUBA
               EXPORTING
                    I_KOMP = I_KOMP_TRANS-KOMP
                    I_ALT  = <l_komp>
               IMPORTING
                    E_NEU  = <l_komp>.
          break-point.
          assign component 'SYSID' of structure <wa_to> to <l_sysid>.
          <l_sysid> = sy-sysid.
    *      move-corresponding <wa_from> to <wa_to>.
          append <wa_to> to <table_to>.
        endloop.
    *    break-point.
    *Speichern der ausgelesenen Daten in Zieltabelle
        MODIFY (i_tabname_to) FROM TABLE <table_to>.
        if sy-subrc <> 0.
          MESSAGE E001(ZMESSAGES) WITH i_tabname_to.
    *   Fehler beim Modify von Tabelle '&'.
        endif.
      else.
    *Speichern der ausgelesenen Daten in Zieltabelle
        MODIFY (i_tabname_to) FROM TABLE <table_from>.
        if sy-subrc <> 0.
          MESSAGE E001(ZMESSAGES) WITH i_tabname_to.
    *   Fehler beim Modify von Tabelle '&'.
        endif.
      endif.
      commit work.
      if sy-subrc <> 0.
        MESSAGE E002(ZMESSAGES) WITH i_tabname_to.
    *   Fehler beim Commit von Tabelle '&'.
      endif.
    *  break-point.
    ENDFUNCTION.
    Thanks a lot for any hints.
    Regards
    Tom

    Hi,
    Answers below.
    1) For this...you assigning an internal table to a work area...
    assign <table_to> to <wa_to>.
    This should solve the problem..
    * Create the target work area..
    DATA: new_line  TYPE REF TO data.
    CREATE DATA new_line LIKE LINE OF <table_to>.
    ASSIGN new_line->* TO <wa_to>.
    Now the target work area is created..
    2) For the second one...
    ************New code
       FIELD-SYMBOLS: <FS>,<FS1>.
    ************New code End.
       loop at <table_from> assigning <wa_from>.
          assign component I_KOMP_TRANS-KOMP
            of structure <wa_from> to <l_komp>.
          CALL FUNCTION I_KOMP_TRANS-FUBA
               EXPORTING
                    I_KOMP = I_KOMP_TRANS-KOMP
                    I_ALT  = <l_komp>
               IMPORTING
                    E_NEU  = <l_komp>.
          break-point.
          assign component 'SYSID' of structure <wa_to> to <l_sysid>.
          <l_sysid> = sy-sysid.
    ************New code
          LOOP AT itab .
             ASSIGN COMPONENT itab-fieldname of structure <WA_FROM> TO <FS>.
             CHECK SY-SUBRC = 0.
             ASSIGN COMPONENT itab-fieldname of structure <WA_TO> TO <FS1>.
             CHECK SY-SUBRC = 0.
    * Move from source to target.
             <FS1> = <FS>.
          ENDLOOP.
    ************New code End
          append <wa_to> to <table_to>.
        endloop.
    Thanks
    Naren

  • Dynamic select with field symbols

    Hi guys,
    I have 2 tables.
    First table is the popup fields using fm popup_get_values:
    tab1-tabname
    tab1-fieldname
    tab1-value
    Second table is the input fields to be displayed in the popup box:
    tab2-transactno
    tab2-docno
    tab2-customer
    tab2-postdate
    etc... (it has many fields)
    Let's say currently i loop at tab2 and assign each value of the individual fields to a variable each:
    loop at tab2
    v_transactno = tab2-transactno
    v_docno = tab2-docno
    etc...
    endloop.
    My question is how do i assign each variable to the popup fields according to the fieldname so that it can get its corresponding value correctly?
    How can this be done dynamically?
    Can the loop above be done dynamically as well coz it has alot of fields to cater for?
    Please help me solve this problem. Futher similar examples would be much appreciated as well.
    Thank you very much!

    Hi
    see the concept of field sysmbols and do accordingly
    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.
    Regards
    Anji

Maybe you are looking for

  • BT Cloud - such slow uploads

    I recently upgraded to unlimited BB, partly because I wanted 50GB on BT Cloud. However it has taken literally weeks to upload about 20GB of files. I think this is just because uploads are very slow on regular broadband. Perhaps they are faster with f

  • Freezing and shutting down

    My iPhone 3GS shuts down after around 2 minutes during a call. It stays shut down with a frozen apple logo on the screen for 2 - 3 minutes, then re-boots. How do I cure it? Ive tried updating and restoring, yet nothing works.

  • Photoshop cc 2014 crashes on close every time

    Every time I quit photoshop it crashes.

  • How to pull Roles and Policies from backend using SQL query in OIA

    Hello, I have Roles and Policies defined in OIA with mapping each other and there is no direct extract report from OIA Web console. Is there any oracle SQL query by which we can get the data and filter the Policies based on the role ? Note: We have o

  • Still hesitating...

    So... I'm still not sure which one would be the best option for me between these two : A macbook (+external monitor keyboard and mouse for my home) or a Macbook Pro for everything. I won't be using the extra power from the MBP, but I will definitely