Query in Optimal Coding - Assigning INT TAB to FIELD SYMBOLS dynamically.

TABLES: tkesk.
DATA: itkesk type table of tkesk.
DATA: BEGIN of itab_RP occurs 11,
tabname type string,
END of itab_RP.
DATA : wa_rp like line of itab_Rp,
wa_onemore like line of itkesk.
FIELD-SYMBOLS: <fs> LIKE itkesk.
ITAB_RP-tabname = 'ITKESK'.
APPEND ITAB_RP.
LOOP at ITAB_RP into wa_rp.
<i><b>*How to assign the table itkesk to the field symbol
*which is available in wa_rp dynamically instead of assigning it directly)</b></i>
*ASSIGN wa_rp-tabname to <fs>.
ASSIGN itkesk to <fs>.
   LOOP at <fs> into wa_onemore.
   WRITE : 'hi'.
   endloop.
ENDLOOP.

Is this even possible ?
Thanks
Mark

Similar Messages

  • Error in assigning *VBAP to a field-symbol...

    Hello Experts,
    I am currently writing my code in a given user-exit in VA01. My problem is,
    I want to assign the value '*VBAP' to a given field-symbol which has a type of
    ANY. The problem is, it says that the value must be a C,N. etc.
    Hope you can help me guys. Thank you and take care!

    can you please paste the piece of code here ...

  • 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

  • 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

  • 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

  • Dump GETWA_NOT_ASSIGNED while assigning value to a field symbol

    LOOP AT <table> INTO <struct>.
        CLEAR l_uom.
        lf_fieldname = '<struct>-UOM'.
        ASSIGN (lf_fieldname) TO <uom>.
        l_uom  = <uom> .
    ENDLOOP.

    I need to put the contents of lf_fieldname into <uom>.......when lf_fieldname is <struct>-UOM.....
    so
    assign lf_fieldname to <uom> is of no use...........and hence v use
    assign (lf_fieldname) to <uom>
    my problem is since i dont knw till the run time if UOM field is present in the table or not, and whn it's not, no mem_area is referenced in the bkgrnd and hence i get an error...........i need to knw if v have a provision to chk if (lf_fieldname) has ne value or not....
    Please help....:)
    Regards,
    Aparna.

  • Field symbol has not yet been assigned. ???

    Dear Experts ,
    W hen i tried to execute my program this error appears :
    Short text
        Field symbol has not yet been assigned.
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "SAPLSLVC" had to be terminated because it has
        come across a statement that unfortunately cannot be executed.
    Error analysis
        You attempted to access an unassigned field symbol
        (data segment 32821).
        This error may occur if
        - You address a typed field symbol before it has been set with
          ASSIGN
        - You address a field symbol that pointed to the line of an
          internal table that was deleted
        - You address a field symbol that was previously reset using
          UNASSIGN or that pointed to a local field that no
          longer exists
        - You address a global function interface, although the
          respective function module is not active - that is, is
          not in the list of active calls. The list of active calls
          can be taken from this short dump.
    and Here is my CODE :
    *& Report  ZPO
    Report  ZPO1.
    type-pools slis.
      PARAMETERS : PO_Doc like EKBE-EBELN DEFAULT '4800000007'.
      PARAMETERS : Plant TYPE WERKS DEFAULT '1000'.
      PARAMETERS : PO_ORG TYPE EKORG DEFAULT ''.
      data TtlS type mara-wesch .
      data TtlH type mara-wesch .
      data Ttl type mara-wesch .
      data ZEKBE type TABLE OF EKBE.
      data ZEKBER type EKBE.
      data ZEKPO type TABLE OF EKPO.
      data ZEKPOR type EKPO.
      data ZEKKOR TYPE EKKO.
      data ZNAME1F type LFA1-LIFNR.
      data ZWGBEZF TYPE T023T-WGBEZ.
      data i type n.
      data counter type n.
    types : begin of SBAGDS,
      Serial Type n, "Purchase Order
      EBELN like EKKO-EBELN, "Purchase Order
      MATNR like EKPO-MATNR, "Material
      TXZ01 like EKPO-TXZ01, "Short Text
      MATKL like EKPO-MATKL, "Material Group
      WGBEZ like T023T-WGBEZ, "Material Group Desc"
      SUBMI like EKKO-SUBMI, "GPM
      CHARG like EKBE-CHARG, "Batch
      LIFNR like EKKO-LIFNR, "Vendor
      NAME1 like LFA1-NAME1, "Vendor Name
      RECV like mara-wesch, "Received Quantity
      REVR like mara-wesch, "Reversed Quantity
      DELV like mara-wesch, "Delivered Quantity
    end of SBAGDS .
    DATA : BAGDS TYPE SBAGDS OCCURS 0 WITH HEADER LINE.
    data Struc like BAGDS.
    data: gr_table like BAGDS OCCURS 0 WITH HEADER LINE.
    data: gt_fieldcat type slis_t_fieldcat_alv, gt_outtab type SBAGDS occurs 0 with header line.
    INITIALIZATION.
    i = 0.
    counter = 0 .
    perform field_cat_init using gt_fieldcat[].
    FORM field_cat_init using rt_fieldcat type slis_t_fieldcat_alv.
    data: ls_fieldcat type slis_fieldcat_alv,
             pos type i value 1.
    clear LS_FIELDCAT.
    *Column 1
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'Serial'.
    ls_fieldcat-SELTEXT_L      = 'Serial'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 2
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'EBELN'.
    ls_fieldcat-SELTEXT_L      = 'Purchase Order'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 3
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'MATNR'.
    ls_fieldcat-SELTEXT_L      = 'Material'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 4
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'TXZ01'.
    ls_fieldcat-SELTEXT_L      = 'Short Text'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 5
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'MATKL'.
    ls_fieldcat-SELTEXT_L      = 'Material Group'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 6
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'WGBEZ'.
    ls_fieldcat-SELTEXT_L      = 'Material Group Desc'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 7
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'SUBMI'.
    ls_fieldcat-SELTEXT_L      = 'GPM'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 8
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'CHARG'.
    ls_fieldcat-SELTEXT_L      = 'Batch'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 9
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'LIFNR'.
    ls_fieldcat-SELTEXT_L      = 'Vendor'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 10
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'NAME1'.
    ls_fieldcat-SELTEXT_L      = 'Vendor Name'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 11
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'RECV'.
    ls_fieldcat-SELTEXT_L      = 'Received Quantity'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 12
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'REVR'.
    ls_fieldcat-SELTEXT_L      = 'Reversed Quantity'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 13
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'DELV'.
    ls_fieldcat-SELTEXT_L      = 'Delivered Quantity'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    endform.
    START-OF-SELECTION.
           select SINGLE * from EKKO into ZEKKOR where EBELN = PO_DOC.
           select SINGLE * from EKPO into ZEKPOR where EBELN = PO_DOC.
           select SINGLE NAME1 from LFA1 into ZNAME1F where LIFNR = ZEKKOR-LIFNR.
    *         ' Buliding Structure
              Struc-EBELN = ZEKPOR-EBELN.
              Struc-SUBMI = ZEKKOR-SUBMI.
              Struc-LIFNR = ZEKKOR-LIFNR.
              Struc-Name1 = ZNAME1F.
           select * from EKPO into TABLE ZEKPO where EBELN = PO_Doc and WERKS = plant.
           LOOP at ZEKPO into ZEKPOR.
               select SINGLE WGBEZ from T023T into ZWGBEZF  WHERE MATKL = ZEKPOR-MATKL .
               counter = counter + 1.
    *         ' Buliding Structure
              Struc-Serial = counter.
              Struc-MATNR = ZEKPOR-MATNR.
              Struc-TXZ01 = ZEKPOR-TXZ01.
              Struc-MATKL = ZEKPOR-MATKL.
              Struc-WGBEZ = ZWGBEZF.
    *          Calcualting Debit transactions from PO History
               select * from EKBE into table ZEKBE where EBELN = PO_Doc and MATNR = ZEKPOR-MATNR and  EBELP = ZEKPOR-EBELP and BWART NOT LIKE '' and SHKZG = 'S'.
               LOOP AT ZEKBE INTO ZEKBER.
                   TtlS = TtlS + ZEKBER-MENGE.
               ENDLOOP.
    *          ' Buliding Structure
               Struc-CHARG = ZEKBER-CHARG.
               Struc-RECV = TtlS.
               Ttl = TtlS.
               clear TtlS.
    *         Calcualting Credit transactions from PO History
             select * from EKBE into table ZEKBE where EBELN = PO_Doc and MATNR = ZEKPOR-MATNR and  EBELP = ZEKPOR-EBELP and BWART NOT LIKE '' and SHKZG = 'H'.
               LOOP AT ZEKBE INTO ZEKBER.
                   TtlH = TtlH + ZEKBER-MENGE.
               ENDLOOP.
    *          ' Buliding Structure
               Struc-REVR = TtlH.
    *          Calculating Total Delivered
               Ttl = Ttl - TtlH.
               clear TtlH.
    *          ' Buliding Structure
               Struc-DELV = Ttl.
               clear Ttl.
    *      Writtng ITAB
           APPEND Struc to BAGDS.
           ENDLOOP.
    *      Reading ITAB
    *       WRITE : / , 'ITAB Begin : '    .
    *       loop at  BAGDS into Struc.
    *         counter = counter + 1.
    *         write : /,'Serial : ',counter.
    *         write : / ,'PO : ',Struc-EBELN.
    *         write : / ,'Vendor : ',Struc-LIFNR.
    *         write : / ,'Vendor Name : ',Struc-NAME1.
    *         write : / ,'Material : ',Struc-MATNR.
    *         write : /,'Short Text: ',Struc-TXZ01.
    *         write : / ,'Model : ',Struc-MATKL.
    *         write : / ,'Model Desc : ',Struc-WGBEZ.
    *         write : /,'GPM : ',Struc-SUBMI.
    *         write : /,'Lot : ',Struc-CHARG.
    *         write : /,'Received : ',Struc-RECV.
    *         write : /,'Reversed : ',Struc-REVR.
    *         write : /,'Delivered : ',Struc-DELV,/,/,/.
    *       ENDLOOP.
    * Call ALV Grid Viewer
    *BREAK-POINT.
    gr_Table[] = BAGDS[].
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
            EXPORTING
                 I_STRUCTURE_NAME   = 'SBAGDS'
                 IT_FIELDCAT          = gt_fieldcat[]
            TABLES
                 T_OUTTAB                  = gr_Table.
    Please Advise
    Edited by: Sap Sap on Jul 27, 2009 12:18 PM
    Edited by: Sap Sap on Jul 27, 2009 12:22 PM
    Edited by: Sap Sap on Jul 27, 2009 12:22 PM

    Hi,
    The problem seems to be in your ALV grid display.
    The reason must be your field catalog.
    Just check your fieldcatalog.
    The value in the fieldname field of the fieldcatalog should be same as the fieldname in your internal table and should be in capital letters.
    Probably you must have mistyped some field.
    Kinldy check.
    Regards,
    Ankur Parab

  • RUn time error while  saving po    Field symbol has not yet been assigned.

    Hi Experts,
    I am getting abap dump while saving PO in ME21N  plz seee the below dump  plzzzzzzzzzzzzzzzzzzzzz help me
    Runtime Errors         GETWA_NOT_ASSIGNED
    Date and Time          19.06.2009 11:24:46
    Short dump has not been completely stored (too big)
    Short text
         Field symbol has not yet been assigned.
    What happened?
         Error in the ABAP Application Program
         The current ABAP program "SAPLKKBL" had to be terminated because it has
         come across a statement that unfortunately cannot be executed.
    What can you do?
         Note down which actions and inputs caused the error.
         To process the problem further, contact you SAP system
         administrator.
         Using Transaction ST22 for ABAP Dump Analysis, you can look
         at and manage termination messages, and you can also
         keep them for a long time.
    Error analysis
         You attempted to access an unassigned field symbol
         (data segment 106).
         This error may occur if
         - You address a typed field symbol before it has been set with
           ASSIGN
         - You address a field symbol that pointed to the line of an
           internal table that was deleted
        - You address a field symbol that was previously reset using
          UNASSIGN or that pointed to a local field that no
          longer exists
        - You address a global function interface, although the
          respective function module is not active - that is, is
          not in the list of active calls. The list of active calls
          can be taken from this short dump.
    How to correct the error
        If the error occures in a non-modified SAP program, you may be able to
        find an interim solution in an SAP Note.
        If you have access to SAP Notes, carry out a search with the following
        keywords:
        "GETWA_NOT_ASSIGNED" " "
        "SAPLKKBL" or "LKKBLF99"
        "GEN_FIELD_OUT2"
        If you cannot solve the problem yourself and want to send an error
        notification to SAP, include the following information:
        1. The description of the current problem (short dump)
           To save the description, choose "System->List->Save->Local File
        (Unconverted)".
        2. Corresponding system log
           Display the system log by calling transaction SM21.
           Restrict the time interval to 10 minutes before and five minutes
        after the short dump. Then choose "System->List->Save->Local File
    (Unconverted)".
    3. If the problem occurs in a problem of your own or a modified SAP
    program: The source code of the program
       In the editor, choose "Utilities->More
    Utilities->Upload/Download->Download".
    4. Details about the conditions under which the error occurred or which
    actions and input led to the error.
    em environment
    SAP-Release 700
    Application server... "gplqty"
    Network address...... "128.12.0.19"
    Operating system..... "Windows NT"
    Release.............. "5.2"
    Hardware type........ "8x AMD64 Level"
    Character length.... 16 Bits
    Pointer length....... 64 Bits
    Work process number.. 0
    Shortdump setting.... "full"
    Database server... "GPLQTY"
    Database type..... "MSSQL"
    Database name..... "GPQ"
    Database user ID.. "gpq"
    Char.set.... "C"
    SAP kernel....... 700
    created (date)... "Aug 4 2008 02:33:25"
      create on........ "NT 5.2 3790 Service Pack 1 x86 MS VC++ 14.00"
      Database version. "SQL_Server_8.00 "
      Patch level. 172
      Patch text.. " "
      Database............. "MSSQL 7.00.699 or higher, MSSQL 8.00.194"
      SAP database version. 700
      Operating system..... "Windows NT 5.0, Windows NT 5.1, Windows NT 5.2, Windows
       NT 6.0"
      Memory consumption
      Roll.... 16192
      EM...... 16759360
      Heap.... 0
      Page.... 237568
      MM Used. 12036016
      MM Free. 530432
    er and Transaction
      Client.............. 410
      User................ "SAP_SUPPORT"
      Language key........ "E"
      Transaction......... "ME21N "
      Transactions ID..... "9E955CDE97CBF1648B4C001A64C7B85A"
      Program............. "SAPLKKBL"
      Screen.............. "SAPLKKBL 0500"
      Screen line......... 3
    Information on where terminated
        Termination occurred in the ABAP program "SAPLKKBL" - in "GEN_FIELD_OUT2".
        The main program was "RM_MEPO_GUI ".
        In the source code you have the termination point in line 2908
        of the (Include) program "LKKBLF99".
    Source Code Extract
    Line  SourceCde
    2878       else.
    2879         assign <fs11> to <field>.
    2880         gs_fc = gs_sfc11.
    2881       endif.
    2882     when 012.
    2883       if gs_out_flags-slave ne 'X'.
    2884         assign <fm12> to <field>.
    2885         gs_fc = gs_mfc12.
    2886       else.
    2887         assign <fs12> to <field>.
    2888         gs_fc = gs_sfc12.
    2889       endif.
    2890     when 013.
    2891       if gs_out_flags-slave ne 'X'.
    2892         assign <fm13> to <field>.
    2893         gs_fc = gs_mfc13.
    2894       else.
    2895         assign <fs13> to <field>.
    2896         gs_fc = gs_sfc13.
    2897       endif.
    2898     when 014.
    2899       if gs_out_flags-slave ne 'X'.

    Hi,
    this error occurs when you try to address a field-symbol before it has been assigned to a field or
    the assignment has failed.
    Use following code to remove this dump
    Assign <mara-matnr> to <fs>.
    if sy-subrc <> 0.
      Error Message.
    Endif.
    Hope it helps,
    Raj

  • How to assign ranges ( select-option)to field symbol

    Hi ,
    I have following scenario
    ranges : r_test1 for agr_1251,
                 r_test2 for agr_1251.
    In runtime i am getting which range i have to populate in a field v_rname.for now let it me v_rname  = 'r_test2'
    i want to assign (v_rname ) to <field -symbol> ie is range to field symbol.
    and i want to update the <field -symbol>-sign ='I'
                                        <field -symbol>-LOW ='some value'
                                        append <field -symbol>.
    This is the logic i want to follow,  for this how should i have to declare the field symbol ? I couldn't assign a range to field symbol . Please help me.
    thanks
    Murali

    Try this
    FIELD-SYMBOLS : <field_symbol>  TYPE ANY TABLE.
    ASSIGN (v_rname) to <field_symbol>.
    <field -symbol>-sign ='I'
    <field -symbol>-LOW ='some value'
    append <field -symbol>.
    This should work because your range is a table.
    Hope this helps you.

  • Dynamic assign in field symbols

    dynamic assign in field symbols

    Hi,
    DYNAMIC ASSIGN:
    If you do not know the name of the field that you want to assign to the field symbol when you write a program, you can use a dynamic ASSIGN statement:
    ASSIGN (<f>) TO <FS>.
    This statement assigns the field whose name is contained in the field <f> to the field symbol <FS>. You cannot use offset and length in a dynamic ASSIGN.
    At runtime, the system searches for the corresponding data object in the following order:
    If the ASSIGN statement is in a procedure, the system searches first in its local data.
    If it cannot find the object in the local data (or if the ASSIGN statement is not in a procedure), it then looks in the local data of the program.
    If the field does not exist in the global data of the program, the system looks in the table work areas declared with the TABLES statement in the main program of the current program group. A program group consists of a main program and all of the programs that are loaded into the same internal session as a result of other program calls.
    If the search is successful and a field can be assigned to the field symbol, SY-SUBRC is set to 0. Otherwise, it is set to 4, and the field symbol remains unchanged. For security reasons, you should always check the value of SY-SUBRC after a dynamic ASSIGN to prevent the field symbol pointing to the wrong area.
    Searching for the field in this way slows down the program. You should therefore only use the dynamic ASSIGN statement when absolutely necessary. If you know when you create the program that you want to assign a table work area to the field symbol, you can also use the following variant of the dynamic ASSIGN statement:
    ASSIGN TABLE FIELD (<f>) TO <FS>.
    The system then only searches within the table work areas in the main program of the current program group for the data object that is to be assigned to the field symbol. This addition is forbidden in ABAP Objects, since the latter does not support table work areas.
    Suppose we have three programs. The main program:
    REPORT demo_field_symbols_dynami_as_1.
    TABLES sbook.
    sbook-fldate = sy-datum.
    PERFORM form1 IN PROGRAM demo_form1.
    The other two programs are:
    REPORT demo_form1.
    FORM form1.
      PERFORM form2 IN PROGRAM demo_form2.
    ENDFORM.
    and
    REPORT demo_form2.
    FORM form2.
      DATA name(20) TYPE c VALUE 'SBOOK-FLDATE'.
    FIELD-SYMBOLS <fs> TYPE ANY.
      ASSIGN (name) TO <fs>.
      IF sy-subrc EQ 0.
        WRITE / <fs>.
    ENDIF.
    ENDFORM.
    The output looks something like this:
    02.06.1998
    The program group in the internal session now consists of the programs DEMO, MYFORMS1 and MYFORMS2. The field symbol <FS> is defined in MYFORMS2. After the dynamic ASSIGN statement, it points to the component FLDATE of the table work area SBOOK declared in the main program DEMO.
    REPORT demo_field_symbols_dynami_as_2 .
    TABLES sbook.
    DATA: name1(20) TYPE c VALUE 'SBOOK-FLDATE',
          name2(20) TYPE c VALUE 'NAME1'.
    FIELD-SYMBOLS <fs> TYPE ANY.
    ASSIGN TABLE FIELD (name1) TO <fs>.
    WRITE: / 'SY-SUBRC:', sy-subrc.
    ASSIGN TABLE FIELD (name2) TO <fs>.
    WRITE: / 'SY-SUBRC:', sy-subrc.
    The output is:
    SY-SUBRC:      0
    SY-SUBRC:      4
    In the first ASSIGN statement, the system finds the component FLDATE of the table work area SBOOK and SY-SUBRC is set to 0. In the second ASSIGN statement, the system does not find the field NAME1 because it is declared by the DATA statement and not by the TABLES statement. In this case, SY-SUBRC is set to 4.
    Reference: http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb38d5358411d1829f0000e829fbfe/content.htm
    reward points if helpful.
    Regards,
    Ramya

  • Checking whether field-symbol from another program is assigned?

    Hi all
    I'm attempting to access a FS from another program.
    As the FS can be assigned, or unassigned within that program, how do I checked for that in my calling program?
    e.g. calling program;
    FIELD-SYMBOLS: <fs> TYPE STANDARD TABLE.
    DATA: lv_var(40) type c.
    lv_var = '(ZTGT_PROG)<read_fs>'.
    ASSIGN (lv_var) TO <fs>.   " statement might dump...

    Hi
    Go through this doc and use 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.
    Related
    ASSIGN, DATA
    Additional help
    Declaring Field Symbols
    Reward points if useful
    Regards
    Anji

  • 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

  • Error while trying to run Bex Query -------- Field symbol is not assigned.

    Hello Every body,
    I am facing the following error after giving some value in Selection screen and trying to run the Bex Query
    ERROR : Field symbol is not assigned.
    Thanks in advance,
    Praveen

    can u plz give details of variables, what it is build on and the value u r inputing,
    also is thr any dump.
    double click on the error message it shows u. it will give u the detailed error message. post that too

  • SAP MII 14.0 SP5 Patch 11 - Error has occurred while processing data stream Dynamic Query role is not assigned to the Data Server

    Hello All,
    We are using a two tier architecture.
    Our Corp server calls the refinery server.
    Our CORP MII server uses user id abc_user to connect to the refinery data server.
    The user id abc_user has the SAP_xMII_Dynamic_Query role.
    The data server also has the checkbox for allow dynamic query enabled.
    But we are still getting the following error
    Error has occurred while processing data stream
    Dynamic Query role is not assigned to the Data Server; Use query template
    Once we add the SAP_xMII_Dynamic_Query role to the data server everything works fine. Is this feature by design ?
    Thanks,
    Kiran

    Thanks Anushree !!
    I thought that just adding the role to the user and enabling the dynamic query checkbox on the data server should work.
    But we even needed to add the role to the data server.
    Thanks,
    Kiran

  • XPATH Database Query Syntax in an Assign

    Trying to get an XPATH Database query to work by assigning the Input variable value in a simple BPEL Process to my query condition. I keep getting invalid XPATH errors. I cannot seem to figure out how get write it out.
    Here is what I have:
    <from expression="orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')"/>
    Here is my error:
    Error(30): [Error ORABPEL-10039]: invalid xpath expression [Description]: in line 30 of "C:\OraBPELPM_1\integration\jdev\jdev\mywork\BPELws\ReadDB\ReadDB.bpel", xpath expression "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')" specified in <from> is not valid, because XPath query syntax error. Syntax error while parsing xpath expression "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')", at position "80" the exception is Expected: ). Please verify the xpath query "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')" which is defined in BPEL process. . [Potential fix]: Please make sure the expression is valid.
    Any help?
    Thanks!!!

    Ok. I have figured out how to place the condition (variable value) inside a concatentated string. So my final result is the actual XPATH Query-Database statement. But the problem is it is being returned as a String. How can I turn that final string into the XPATH expression I need? I suspect another <COPY> block could pull this off but I am not sure how to do it.
    Here is my code:
    <process name="QueryBuild" targetNamespace="http://xmlns.oracle.com/QueryBuild" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:ns1="http://www.w3.org/2001/XMLSchema" xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:client="http://xmlns.oracle.com/QueryBuild" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
    <partnerLinks>
    <partnerLink name="client" partnerLinkType="client:QueryBuild" myRole="QueryBuildProvider"/>
    </partnerLinks>
    <variables>
    <variable name="inputVariable" messageType="client:QueryBuildRequestMessage"/>
    <variable name="outputVariable" messageType="client:QueryBuildResponseMessage"/>
    <variable name="QueryText" type="ns1:string"/>
    </variables>
    <sequence name="main">
    <receive name="receiveInput" partnerLink="client" portType="client:QueryBuild" operation="process" variable="inputVariable" createInstance="yes"/><!-- Generate reply to synchronous request -->
    <assign name="Assign_1">
    <copy>
    <from expression="concat(&quot;orcl:query-database('select ename from emp where empno = &quot;, bpws:getVariableData('inputVariable','payload','/client:QueryBuildProcessRequest/client:input'), &quot;,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL)'&quot;)"/>
    <to variable="QueryText"/>
    </copy>
    <copy>
    <from variable="QueryText"/>
    <to variable="outputVariable" part="payload" query="/client:QueryBuildProcessResponse/client:result"/>
    </copy>
    </assign>
    <reply name="replyOutput" partnerLink="client" portType="client:QueryBuild" operation="process" variable="outputVariable"/>
    </sequence>
    </process>

Maybe you are looking for

  • Display of PHP files in Dreamweaver

    After updating to Dreamweaver 8.0.2, I'm finding that I can't view php files in either the Split or Design modes. It will only appear in the code mode and won't let me select a browser to display either. Any suggestions?

  • Credit block at delivery creation

    Hello  all, we  have  following  scenario: We  perfrom  Credit check at delivery creation  and  if the  customer  is  over  100 %  of  the  limit the  user  is  not  able  to save  the  delivery  note....Fine so  far... Then  they  release  via  VKM3

  • "Approver Not Found"

    Hi all, In purchasing, though i am able to get the approval done for Standard Purchase Order and Requisition through the respective hierarchy, I am unable to do so the same for Blanket and Planned Purchase Order. Further, The Hierarchy as define in H

  • HT1977 asking to authorized and deauthorized my computer to be accessed, and why?

    I am very much concern asking my Iphone 5C to authorized and deauthorized my computer to be accessed. I bought the device for my concerned in order to be concievable enjoying all programs, sofwares and etc. on the above-mentioned cellphone the follow

  • Enlarging pictures in  Picture section

    I have a picture in the Pictures section. I can only hit the + button to enlarge it. How do I highlight the part I want enlarged and save that enlargement? Thanks, Mike