Field-symbols v/s Object references in OO-ABAP

Hi,
can anyone please tell me what is the difference between using field-symbols and object references in OO ABAP? Is there a specific need for field-symbols now that we have references?
Thanks.
Shakul.

Hi ,
Please note that both Field symbols & Object References are different .
You can use Field symbols during the following situations
1) When you want to modify the value of internal table, the field symbol would be useful since you do not have to use any Modify statement as in case of work area. The Field symbol works as a pointer and any changes to the field symbol will directly affect the value of the internal table
2) Make sure that you do not reassign the field symbol within a Loop iteration
3) Field symbols are useful when you work with dynamic internal tables ( tables whose structure is determined during run time)
4) After Read an internal table ( Read itab...) into a Field symbol, make sure you do a Sy-subrc check or check if the field symbol is assigned.IF not this will give you a run time error
You can use Object References while creating an object to a class. They are instances of a class.
Thanks,
Chakram Govindarajan

Similar Messages

  • FieldStrings, field-symbols and matchcode objects

    Hi,
    Can u explain and give 1 example of each....
    1. fieldstring
    2. fieldsymbol
    3. matchcode object.
    Thanks,
    Nidhi

    FIELD-SYMBOLS . Its first component is assigned to the field symbol. GET REFERENCE is then used to get a reference to the second component not the structured data object in dref2. It is dereferenced without casting.
    Ref link:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
    https://forums.sdn.sap.com/click.jspa?searchID=-1&messageID=3068811
    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
    Matchcodes are defined in two stages in Abap/4 Dictionary:
    1) The revelant table and fields are stipulated in matchcode object. A matchcode object describes the set of all possible search paths for a search item.
    2) One or more matchcode ID can be defined for a matchcode object. A matchcode ID describes a special search path for a search term.The fields or combination of fields via which the search is to take place is defined in the matchcode ID.
    Matchcodes are replaced by SEARCH HELPs in latest versions
    see the doc
    1) Elementary search helps describe a search path. The elementary search help must define where the data of the hit list should be read from (selection method), how the exchange of values between the screen template and selection method is implemented (interface of the search help) and how the online input help should be defined (online behavior of the search help).
    2) Collective search helps combine several elementary search helps. A collective search help thus can offer several alternative search paths.
    3)An elementary search help defines the standard flow of an input help.
    4) A collective search help combines several elementary search helps. The user can thus choose one of several alternative search paths with a collective search help.
    5)A collective search help comprises several elementary search helps. It combines all the search paths that are meaningful for a field.
    6)Both elementary search helps and other search helps can be included in a collective search help. If other collective search helps are contained in a collective search help, they are expanded to the level of the elementary search helps when the input help is called.
    CREATION:
    Go to SE11 Tcode
    select search help
    give the 'z' search help name and create
    select the selection method ur table name eg : 'mara'
    dialog module 'display value immediately'.
    add the field whatever u want and lpos = 1 and spos = 1 and check import and export parameter.
    where left position when displaying and spos = search position
    and then save and activate ..
    See the links:
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee38446011d189700000e8322d00/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee45446011d189700000e8322d00/content.htm
    https://forums.sdn.sap.com/click.jspa?searchID=3173469&messageID=2176485
    https://forums.sdn.sap.com/click.jspa?searchID=3173469&messageID=3601619
    pls go through this for search help creation
    http://help.sap.com/saphelp_nw2004s/helpdata/en/41/f6b237fec48c67e10000009b38f8cf/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee2b446011d189700000e8322d00/content.htm
    Search Help Exits:
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee52446011d189700000e8322d00/content.htm
    http://www.sapdevelopment.co.uk/dictionary/shelp/shelp_exit.htm
    https://forums.sdn.sap.com/click.jspa?searchID=4390517&messageID=1712818
    Collective search help Combine several elementary search helps. A collective search help thus can offer several alternative search paths.
    A Collective search help provides alternative search
    Paths by combining elementary search helps.
    Only one search help can be attached to a field, table or data element. Several search paths are therefore attached with a collective search help.
    A collective search help also has interface parameters like
    an elementary search help.
    Like an elementary search help, a collective search help has an interface of IMPORT and EXPORT parameters with which the search help exchanges data. Using this interface, the collective search help can be attached to fields, tables and data elements exactly like an elementary search help.
    Parameter assignment needs to be done for each of the
    Included search helps.
    When you define a collective search help, there are no components for describing the dialog behavior and data selection; instead the included search helps are listed here. You must assign the parameters of the collective search help to the interface parameters of the included search help for each inclusion.
    User may choose the tab and thus the elementary
    search maethod.
    When we execute the search help SCUSTOM, we are confronted with a dialog which gives us an option of either restricting
    By 1)Search for customer according to booking
    2)Search for customer according to name.
    These are effectively the elementary search helps (SCUSTOM_BOOK and SCUSTOM_NAME) which have been included in the collective search help SCUSTOM.
    HOT KEY
    The hot key is used to select the elementary search help from the collective search help and to enter the restrictions in the dialog box for restricting values directly from the entry field. If the user often searches for values using the same search help, this procedure can save time.
    Steps to create a Collective Search Help
    1)Enter the search help name and click on create.
    2)Choose Collective search help radio button option as the search help type.
    3)Enter the search help parameters.
    4)Instead of the selection method, we enter the included
    search helps for the collective search help.
    5)We need to assign parameters for each of the included
    search helps.
    6)Complete the parameter assignment by clicking on the push button
    7)Collective search help offers the user to obtain F4 help
    using any of the included search helps.
    Field string is nothing but the group of fields
    You can call it as Structure also
    example:
    types: begin of x_str
    kunnr type kunnr,
    lifnr type lifnr,
    name1 type name1,
    land1 type land1,
    end of x_str.
    this stores one record at run time.
    Reward points,
    shakir

  • Field Symbol Assignment

    Hi,
    I have a doubt regarding the field symbol assignment.
    In my program, I have logic as below.
    <b>  W_1STCNTFLD = 'E_INV_AGING_STRU-PDISCCNTP1'.
      W_2NDCNTFLD = 'E_INV_AGING_STRU-PDISCCNTP2'.
      ASSIGN (W_1STCNTFLD) TO <FS1>.
      ASSIGN (W_2NDCNTFLD) TO <FS2>.</b>
    While debugging, when I see the values of the Field Symbols <b><FS1></b> and <b><FS2></b> after assignment, they are <b>0, 0</b>. Why is it like that..?
    In general, what does a Field Symbol hold..? the value of the variable being assigned or the Memory location of that variable..?
    When I remove the paranthesis while assigning like below,
      <b>ASSIGN W_1STCNTFLD TO <FS1>.</b>
    it is storing the value of the variable(<b>E_INV_AGING_STRU-PDISCCNTP1</b>) to <b><FS1></b> instead of '0'.
    And what is the difference between   <b>ASSIGN (W_1STCNTFLD) TO <FS1></b> and   <b>ASSIGN W_1STCNTFLD TO <FS1></b>..? I mean, when we put paranthesis to the variable and when we remove the paranthesis.
    Please clarify my doubts. Thanks in advance.
    Thanks & Regards,
    Paddu.

    when you use the paranthesis,(W_1STCNTFLD) actually equals to ('E_INV_AGING_STRU-PDISCCNTP1'),and the 'E_INV_AGING_STRU-PDISCCNTP1' must be the label of a data object,it can't be a string!
    please refer to the following document(coming from sap abap keywords document):
    Alternative 2
    ... [TABLE FIELD] (name)
    Alternative 3
    ... oref->(attr_name)
    Alternative 4
    ... {class|(class_name)}=>{attr|(attr_name)}
    Effect
    There are three dynamic variants for mem_area, where the storage area is not specified directly, but as the content of character/type data objects enclosed within parentheses.
    In the first variant (name), the label in name is built exacltly like the direct specification. When the statement is executed, the content of name must be the label of a data object that can contain offset/length specifications, strucuture component selectors, and component selectors for the assignment of attributes in classes or objects (since Release 6.10). The content of name must be specified in uppercase letters.
    The optional addition TABLE FIELD before (name) is only possible outside of classes. This addition limits the search area - where the data object specified in (name) is searched for (see below) - to the interface work areas for the current program group declared using TABLES. If TABLE FIELD is specified, casting_spec and range_spec cannot be specified explicitly.
    If the label in name is a field symbol or a form parameter with an unstructured type, components can be addressed, as of Release 6.10, through structure component selectors. The components must exist when the statement is executed.
    The second variant oref->(attr_name) is a special case of the first variant for the assignment of an instance attribute to a field symbol - where the object reference variable oref is specified statically. The label of the attribute is specified dynamically in the character-type field attr_name and must not be specified in uppercase letters.
    The third variant {class|(class_name)}=>{name|(attr_name)} is a special case of the first variant for the assignment of a static attribute to a field symbol where the class name class and the name of the attribute name can be specified both directly and dynamically in character-type fields class_name or attr_name. The contents of attr_name and class_name do not have to be in uppercase letters. If the class name is specified dynamically and the attribute is specified directly, no offset/length specifications can be made for the attribute.
    If a data object is specified dynamically, this is searched for in accordance with the following hierarchy.
    Within the local data objects of the current procedure
    Within the attributes, visible in a method, of the actual class, where , in instance methods, the self reference me-> is set explicitly before the label
    Within the global data of the current program
    Within the interface work areas of the main program of the current program group declared with TABLES
    Within the attributes of the object to which oref refers, if the label has the expression oref-> (as of Release 6.10)
    Note
    Only for internal use can the label in name also have the form (PROG)DOBJ, whereby PROG is the name of an ABAP program and DOBJ is the name of a global data object of this program. If the program PROG is loaded during execution of the statement ASSIGN in the same internal mode as the current program is loaded, the data object (PROG)DOBJ in this program is searched for and the field symbol points to this data object after successful assignment.
    Example
    Dynamic access to an attribute of an object (Dynamic Access) through a field symbol.
    CLASS c1 DEFINITION.
      PUBLIC SECTION.
        METHODS m1 IMPORTING oref TYPE REF TO object
                             attr TYPE string.
    ENDCLASS.
    CLASS c1 IMPLEMENTATION.
      METHOD m1.
        FIELD-SYMBOLS <attr> TYPE ANY.
        ASSIGN oref->(attr) TO <attr>.
        WRITE <attr> ...
      ENDMETHOD.
    ENDCLASS.

  • ABAP Objects v/s Field Symbols

    Hi,
    My query is:
    In ABAP Objects, reference variables can be assigned to each other.
    We can also assign the reference variable to a field symbol.
    Does that mean, that we can achieve the same functionality(like accessing a method of the class) using the field-symbols?
    If so, why not use field-symbols instead of objects? What are the other differences?
    Please provide your opinions.
    Regards
    s.a.k

    Hi,
    We can have any number of Field Symbols refering to One Variable or Object, but all these Field symbols refer to same memory location they donto have individual memory locations.
    Where are in Object, if diffrent objected are created refreing to one object all the objects have diffrent memory locations.
    Read the documentation of Field symbols and ABAP Objects you will get the clear diffrene.
    Regards,
    Kumar M.

  • Reg: Field Symbol and Data Reference

    Hi,
    What is the difference Between a FieldSymbol and Data Reference.
    could anyone explain with an example the difference.
    The Link I am Going Through ---> [SAP HELP|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm]
    I couldnt get a clear idea
    regards

    Hi,
    In ABAP/4 programs, field symbols are placeholders for existing fields. A field symbol does not physically reserve space for a field, but points to a field, which is not known until runtime of the program. Field symbols are comparable to the concept of pointers as used in the programming language C. In ABAP/4, however, there is no real equivalent to pointers in the sense of variables, which contain a memory address and can be used without the content operator. You can only work with the data object to which a field symbol points.
    uF076     Concept of Field Symbols
    Sometimes you only know which field you want to process, and how you want to process it, at runtime.
    For this purpose, you can create field symbols in your program. At runtime, you can assign real fields to such field symbols. All operations, which you have programmed with the field symbol, are then carried out with the assigned field. After successful assignment, there is no difference in ABAP/4 whether you reference the field symbol or the field itself.
    Field symbols can point to any data object in ABAP/4 and to structures defined in the ABAP/4 Dictionary.
    You can create field symbols either without or with type specifications. In the first case, the field symbol adopts all the attributes of the assigned field. In the second case, the system checks during the assignment process whether the assigned field matches the type of the field symbol. Whichever applies, you must first assign a field to your field symbol before you can work with it in your program.
    Field symbols provide some features that make them very flexible:
    uF071     You can specify the offset and length of the assigned field as variables.
    uF071     You can assign field symbols to other field symbols and even specify offset and length there.
    uF071     Assignments to field symbols may extend beyond field boundaries. This allows effective access to regularly stored data.
    uF071     You can force a field symbol to be of a different type and to have a different number of decimal places than the assigned field.
    uF071     Field symbols may have a structure that you can use to point to individual components of structures.
    Since you can assign data objects to field symbols which may not be known 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. Therefore, you should use field symbols only in cases where you are absolutely sure of what you are doing, or if there are no other ABAP/4 statements you can use to solve your problem. The advantage of field symbols is that they can improve response times in some cases.
    uF076     Defining Field Symbols
    uF0D8     Defining Field Symbols for Internal Fields
    To define a field symbol for an internal data object, use the FIELD-SYMBOLS statement as follows:
    Syntax-
    FIELD-SYMBOLS <FS> [<type>].
    This statement defines a field symbol <FS>.
    for data reference follow this link
    http://help.sap.com/saphelp_nw04s/helpdata/en/14/11e70b0c5c11d3b9350000e8353423/frameset.htm
    Regards,
    Flavya

  • 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

  • Modify DB by single field using Field Symbol

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

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

  • Obtain List of Field Symbols Declared and Assigning from ITAB DATA

    Hi Gurus,
    3 simple problems (apparently , appreciate responses.
    Problem 1
    How to get the list of names of <field-symbols> of type table declared in an abap program?
    Problem 2
    Create DATA "XXXX" TYPE TABLE OF ty_fcat. Where "XXX" name is obtained from an internal table with data names...Can i use the read the statement on the internal table and creat the DATA?
    Problem 3
    Matching the name of the field-symbol obtained from the abap program with a "name" stored in an ITAB. If the name matches do the following:-
      CREATE DATA 'XXXX' TYPE TABLE OF ty_fcat. (remember 'XXXX' is obtained by reading internal table.
      ASSIGN 'XXXX->* TO <ITAB> (obtained from the abap program)
    Appreciate guidance on this matter. thank you!!!! God Bless!
    Edited by: Salman Akram on Sep 27, 2010 4:03 PM
    Edited by: Rob Burbank on Sep 27, 2010 2:59 PM

    Hi Salman,
    1) Once you assign some table to your field symbol, its dynamic type will be the same as the table assigned.
    So you use the same approach as described in your last thread.
    "suppose you have a table assigned to <tab>
    "describe it by name
    lr_tabdescr ?= cl_abap_typedescr=>describe_by_data( <tab> ).
    lr_strucdescr ?= lr_tabdescr->GET_TABLE_LINE_TYPE( ).
    "and get its line type components
    it_components = lr_strucdescr->get_components( ).
    loop at it_components.
    "show all component names
      write: it_components-name.
    endloop.
    2) This statement has such form
    data lr_data type ref to data.
    CREATE DATA lr_data TYPE ...
    In here lr_data must be data reference  (no its name). TYPE can be provided dynamically in form of ('SOME_DDIC_TYPE'). So in your case this statement is not correct. You can't provide lr_data dynamically.
    So this one you will have to elaborate a bit in order we could understand what you want to achieve.
    3) Here I totally don't know what you mean. I think this relates somehow to first two points. So please tell us what is the requirement from the scratch, maybe this will shed more light on your issue.
    BTW: Please post such questions in ABAP General as this is not DDIC related issue.
    Regards
    Marcin

  • Field-Symbols usage

    I have this internal table with more than 8 lacs of records. This table is looped inside to fetch some other data from a database table.
    I am losing the performance because of all this looping. Can anyone tell me how to use field-symbols in this case. I have gone through some documentation on field-symbols. Can anyone tell if the below one is correct.
    data: begin of struct,
          field1,
          field2,
          field3,
          end of struct.
    field-symbols <itab> like struct.
    assign struct to <itab>.
    loop at <itab>.
    <itab>-field1=....
    <itab>-field2=....
    further processing using <itab>....
    endloop.
    If this is not true, whats the way one use the field-symbols when we want to loop?
    thanks

    Hi,
    As others have said, you can use field-symbols as your header in your itab. This will give you improved performance because the data that you are currently looping will not be moved from itab to the header/work area. It will point directly to that record in your itab so lesser memeory is required. Also, using field-symbols is needed when creating programs using ABAP OO. Below is an example:
    data: it_spfli type table of spfli.
    field-symbols: <fs_spfli> like line of it_spfli.
    select * from spfli into table it_spfli.
    loop at it_spfli assigning <fs_spfli>.
    endloop.
    Hope this helps...
    P.S. Please award points for useful answers.

  • Assigning object reference values to field symbols

    Okay.......has anyone out there figured out how to assign the reference value of an object (you know the value you see in the debugger for example: .........to a field symbol.
    I know there has to be a way and was wondering if anyone has successfully achieved this. Its easy to assign a memory area to a field symbol if its an itab like this below:
    field-symbols: <fs>.
    data: v_fieldname(20) type c.
    v_fieldname = '(SAPLMEREQ)MARA'.
    assign (v_fieldname) to <fs>.
    This shouldn't be impossible with code like:
    field-symbols: <fs> type ref to object.
    data: v_ref(100) type c.
    v_ref = '{O:666*\FUNCTION-POOL=MEREQ\CLASS=LCL_REQ_ITEM_STATE}'.
    assign (v_ref) to <fs>.
    I just know that the code above doesn't work....
    Any suggestions? And please......no questions about "why" or "what do I want to accomplish?" .....
    Mike

    Hello Michael
    I assume you have not yet seen the following links:
    ABAP OO - MEREQ (Purchase Req) - Protected Attributes
    [Accessing the Inacessible - Local Classes within Global Classes|https://wiki.sdn.sap.com/wiki/display/ABAP/AccessingtheInacessible-LocalClasseswithinGlobalClasses]
    Regards
      Uwe

  • Field symbols in objects

    Hi Guys
    I am using a field sym in the foll way and iam getting a dump.
    ls_fcat = mod_fcat( ls_fcat ).
    method mod_fcat.
       field-SYMBOLS: <l> like line of rt.
        LOOP AT rt ASSIGNING <l>.
          CASE <l>-fieldname.
            WHEN 'VALUE_CONTRACT_E'.
            CLEAR: <l>-ref_field,<l>-ref_table.
            <l>-coltext   = text-h01. <l>-SCRTEXT_L = text-h01.
            <l>-SCRTEXT_M = text-h02. <l>-SCRTEXT_S = text-h02.
            WHEN OTHERS.
          ENDCASE.
        ENDLOOP.
      ENDMETHOD.
    endmethod.
    When the control goes to clear it gives me a dump.I dont understand why coz iam already assignin <l> at every loop pass.
    Please help!!
    Thanks

    Hi Guys
    This is the error i get
    A new value is to be assigned to the field "<L>", 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).
    Thanks

  • Field symbols in Object Oriented ALV

    Hi Friends....Can somebody explain me what is the significance of field symbols in OO ALV. Why it is assigned to Field catalog. Also explain me the basic steps to do Object Oriented ALV. Thanks in advance...

    Hi Satyesh,
    Field symbols are symbolic names to which a memory area can be assigned during program runtime. A field symbol can be used instead of data objects at operand positions of statements.
    Please go through this following code.  This uses field symbols for OO ALV.
      LCL_TABLE_DISPLAY DEFINITION
    CLASS lcl_table_display DEFINITION.
      PUBLIC SECTION.
        TYPE-POOLS: abap, slis.
        CLASS-METHODS: display_list IMPORTING in_data TYPE STANDARD TABLE,
                       display_grid IMPORTING in_data TYPE STANDARD TABLE.
        METHODS: constructor IMPORTING in_data TYPE STANDARD TABLE
                             EXCEPTIONS casting_error
                                        empty_fieldcat.
        METHODS: output_list,
                 output_grid.
        METHODS: set_table_name   IMPORTING in_tabname  TYPE any,
                 set_alv_title    IMPORTING in_title    TYPE any,
                 set_alv_settings IMPORTING in_settings TYPE any,
                 set_alv_layout   IMPORTING in_layout   TYPE any,
                 set_alv_event    IMPORTING in_name     TYPE any
                                            in_form     TYPE any.
      PRIVATE SECTION.
        CLASS-DATA: g_table_object TYPE REF TO lcl_table_display.
        TYPES: BEGIN OF ty_defin,
                 fieldname     TYPE fieldname,
                 ref_tabname   TYPE tabname,
                 ref_fieldname TYPE fieldname,
               END OF ty_defin.
        DATA: g_repid  TYPE repid,
              g_struc  TYPE tabname,
              g_table  TYPE tabname.
        DATA: gt_data  TYPE REF TO data.
        DATA: g_title  TYPE lvc_title,
              gt_fcat  TYPE slis_t_fieldcat_alv,
              gs_sett  TYPE lvc_s_glay,
              gs_layo  TYPE slis_layout_alv,
              gt_evnt  TYPE slis_t_event.
        DATA: gt_defin TYPE TABLE OF ty_defin,
              g_level  TYPE tabname.
        METHODS: output_table IMPORTING data TYPE REF TO data
                                        mode TYPE c,
                 fill_fieldcat IMPORTING repid TYPE repid
                                         struc TYPE tabname
                                CHANGING fcat  TYPE slis_t_fieldcat_alv
                              EXCEPTIONS no_definition,
                 get_definition IMPORTING repid TYPE repid
                                          struc TYPE tabname
                                 CHANGING abap  TYPE rsfb_source,
                 recursive_definition IMPORTING repid TYPE repid
                                       CHANGING abap  TYPE rsfb_source,
                 map_structure IMPORTING source TYPE any
                                CHANGING destin TYPE any.
    ENDCLASS.
      LCL_TABLE_DISPLAY IMPLEMENTATION
    CLASS lcl_table_display IMPLEMENTATION.
      Display table in ALV list
      METHOD display_list.
        IF NOT g_table_object IS INITIAL.
          FREE: g_table_object.
        ENDIF.
        CREATE OBJECT g_table_object EXPORTING in_data = in_data.
        CALL METHOD g_table_object->output_list.
      ENDMETHOD.
      Display table in ALV grid
      METHOD display_grid.
        IF NOT g_table_object IS INITIAL.
          FREE: g_table_object.
        ENDIF.
        CREATE OBJECT g_table_object EXPORTING in_data = in_data.
        CALL METHOD g_table_object->output_grid.
      ENDMETHOD.
      Create table display
      METHOD constructor.
        DATA: ls_data TYPE REF TO data.
        DATA: ob_desc TYPE REF TO cl_abap_structdescr.
        DATA: l_absol TYPE char200,
              l_repid TYPE repid,
              l_struc TYPE tabname.
        FIELD-SYMBOLS: <table> TYPE STANDARD TABLE,
                       <struc> TYPE ANY.
      Get data and store it into attribute
        CREATE DATA me->gt_data LIKE in_data.
        ASSIGN me->gt_data->* TO <table>.
        <table> = in_data.
      Get global data definition
        CREATE DATA ls_data LIKE LINE OF <table>.
        ASSIGN ls_data->* TO <struc>.
        CATCH SYSTEM-EXCEPTIONS assign_casting_illegal_cast = 1.
          ob_desc ?= cl_abap_typedescr=>describe_by_data( <struc> ).
        ENDCATCH.
        IF sy-subrc = 1.
          RAISE casting_error.
        ENDIF.
      Get program name and main type used to define table
        l_absol = ob_desc->absolute_name.
        SPLIT l_absol AT '\TYPE=' INTO l_repid l_struc.
        SHIFT l_repid UP TO '='.
        SHIFT l_repid.
        CHECK l_struc NP '%_*'.
        IF me->g_repid NE l_repid
        OR me->g_struc NE l_struc.
        Set attributes
          me->g_repid = l_repid.
          me->g_struc = l_struc.
          me->g_table = l_struc.
          REPLACE 'TY' WITH 'WT' INTO me->g_table.
        Field catalog
          CALL METHOD fill_fieldcat EXPORTING repid = l_repid
                                              struc = l_struc
                                     CHANGING fcat  = me->gt_fcat.
          IF me->gt_fcat IS INITIAL.
            RAISE empty_fieldcat.
          ENDIF.
        ENDIF.
      ENDMETHOD.
      Output list
      METHOD output_list.
        CALL METHOD output_table EXPORTING data = me->gt_data
                                           mode = 'L'.
      ENDMETHOD.
      Output grid
      METHOD output_grid.
        CALL METHOD output_table EXPORTING data = me->gt_data
                                           mode = 'G'.
      ENDMETHOD.
      Output table
      METHOD output_table.
        DATA: ls_vari TYPE disvariant.
        FIELD-SYMBOLS: <table> TYPE STANDARD TABLE.
        ASSIGN me->gt_data->* TO <table>.
      Get default user variant
        ls_vari-report = me->g_repid.
        ls_vari-username = sy-uname.
        CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
             EXPORTING
                  i_save     = 'U'
             CHANGING
                  cs_variant = ls_vari
             EXCEPTIONS
                  OTHERS     = 0.
      Display table contents
        IF mode = 'G'.
          CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
               EXPORTING
                    i_callback_program = me->g_repid
                    i_grid_title       = me->g_title
                    i_grid_settings    = me->gs_sett
                    is_layout          = me->gs_layo
                    it_fieldcat        = me->gt_fcat
                    i_save             = 'U'
                    is_variant         = ls_vari
                    it_events          = me->gt_evnt
               TABLES
                    t_outtab           = <table>
               EXCEPTIONS
                    OTHERS             = 0.
        ELSE.
          CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
               EXPORTING
                    i_callback_program = me->g_repid
                    is_layout          = me->gs_layo
                    it_fieldcat        = me->gt_fcat
                    i_save             = 'U'
                    is_variant         = ls_vari
                    it_events          = me->gt_evnt
               TABLES
                    t_outtab           = <table>
               EXCEPTIONS
                    OTHERS             = 0.
        ENDIF.
      ENDMETHOD.
      Fill field catalog
      METHOD fill_fieldcat.
        DATA: lt_abap   TYPE TABLE OF rssource.
        DATA: ls_defin  TYPE ty_defin.
        DATA: lt_dfies  TYPE TABLE OF dfies,
              ls_dfies  TYPE dfies,
              ls_dd04v  TYPE dd04v,
              ls_dd01v  TYPE dd01v,
              l_flong   TYPE dfies-lfieldname,
              l_dname   TYPE dfies-domname.
        DATA: ls_fcat   TYPE slis_fieldcat_alv,
              ls_fcat2  TYPE slis_fieldcat_alv.
        DATA: l_index   TYPE i,
              l_nbfld   TYPE i.
        FREE: me->gt_defin.
      Process data definition
        CALL METHOD get_definition EXPORTING repid = repid
                                             struc = struc
                                    CHANGING abap  = lt_abap.
      Process sub levels if required
        CALL METHOD recursive_definition EXPORTING repid = repid
                                          CHANGING abap  = lt_abap.
        IF me->gt_defin IS INITIAL.
          RAISE no_definition.
        ENDIF.
        LOOP AT me->gt_defin INTO ls_defin.
          CLEAR: ls_fcat.
          MOVE-CORRESPONDING ls_defin TO ls_fcat.
        Retrieve info about this field
          FREE: ls_dfies, ls_dd04v, ls_dd01v, l_dname.
          l_flong = ls_fcat-ref_fieldname.
          SET LOCALE LANGUAGE 'E'.
          TRANSLATE: ls_fcat-ref_tabname   TO UPPER CASE,
                     ls_fcat-ref_fieldname TO UPPER CASE,
                     l_flong               TO UPPER CASE.
          IF NOT ls_fcat-ref_tabname IS INITIAL.
          Try to get info about field in table
            CALL FUNCTION 'DDIF_FIELDINFO_GET'
                 EXPORTING
                      tabname        = ls_fcat-ref_tabname
                      fieldname      = ls_fcat-ref_fieldname
                      lfieldname     = l_flong
                 IMPORTING
                      dfies_wa       = ls_dfies
                 EXCEPTIONS
                      not_found      = 1
                      internal_error = 2
                      OTHERS         = 3.
            IF sy-subrc = 0.
              MOVE-CORRESPONDING ls_dfies TO ls_fcat.
              ls_fcat-fieldname = ls_defin-fieldname.
              MOVE: ls_dfies-keyflag   TO ls_fcat-key,
                    ls_dfies-scrtext_m TO ls_fcat-seltext_l,
                    ls_dfies-domname   TO l_dname.
            ENDIF.
          ELSE.
          Try to get info about structure
            ls_defin-ref_tabname = ls_defin-ref_fieldname.
            CALL FUNCTION 'DDIF_FIELDINFO_GET'
                 EXPORTING
                      tabname   = ls_defin-ref_tabname
                 TABLES
                      dfies_tab = lt_dfies
                 EXCEPTIONS
                      OTHERS    = 0.
            IF NOT lt_dfies IS INITIAL.
            Process fields of this structure
              LOOP AT lt_dfies INTO ls_dfies.
                CLEAR: ls_fcat.
                MOVE-CORRESPONDING ls_dfies TO ls_fcat.
                CONCATENATE ls_defin-fieldname ls_fcat-fieldname
                       INTO ls_fcat-fieldname
                  SEPARATED BY '-'.
                MOVE ls_dfies-keyflag TO ls_fcat-key.
                MOVE ls_dfies-scrtext_m TO ls_fcat-seltext_l.
                ls_fcat-tabname = me->g_table.
                CLEAR: ls_fcat-col_pos,
                       ls_fcat-offset.
                IF ls_fcat-ref_tabname IS INITIAL.
                  ls_fcat-ddictxt = 'L'.
                ENDIF.
              Display Yes/No fields as checkboxes
                IF ls_dfies-domname = 'XFELD'.
                  ls_fcat-checkbox = 'X'.
                ENDIF.
              Add field to field catalog
                APPEND ls_fcat TO fcat.
              ENDLOOP.
            ELSE.
            Try to get info about data element
              CALL FUNCTION 'DDIF_DTEL_GET'
                   EXPORTING
                        name          = ls_fcat-ref_fieldname
                        langu         = sy-langu
                   IMPORTING
                        dd04v_wa      = ls_dd04v
                   EXCEPTIONS
                        illegal_input = 1
                        OTHERS        = 2.
              IF sy-subrc = 0.
                MOVE-CORRESPONDING ls_dd04v TO ls_fcat.
                MOVE: ls_dd04v-scrtext_m TO ls_fcat-seltext_l,
                      ls_dd04v-domname   TO l_dname.
              ELSE.
              Finally try to get info about domain
                CALL FUNCTION 'DDIF_DOMA_GET'
                     EXPORTING
                          name          = ls_fcat-ref_fieldname
                          langu         = sy-langu
                     IMPORTING
                          dd01v_wa      = ls_dd01v
                     EXCEPTIONS
                          illegal_input = 1
                          OTHERS        = 2.
                IF sy-subrc = 0.
                  MOVE-CORRESPONDING ls_dd01v TO ls_fcat.
                  MOVE: ls_dd01v-ddtext  TO ls_fcat-seltext_l,
                        ls_dd01v-domname TO l_dname.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDIF.
        Table name must be internal table containing data
          ls_fcat-tabname = g_table.
        No offset
          CLEAR: ls_fcat-offset.
        Default text is stored in long text
          IF ls_fcat-ref_tabname IS INITIAL.
            ls_fcat-ddictxt = 'L'.
          ENDIF.
        Display Yes/No fields as checkboxes
          IF l_dname = 'XFELD'.
            ls_fcat-checkbox = 'X'.
          ENDIF.
        Add field to field catalog
          APPEND ls_fcat TO fcat.
        ENDLOOP.
      Link between fields
        DESCRIBE TABLE fcat LINES l_nbfld.
        LOOP AT fcat INTO ls_fcat.
          IF sy-tabix NE l_nbfld.
            l_index = sy-tabix + 1.
            READ TABLE fcat INTO ls_fcat2 INDEX l_index.
            IF sy-subrc = 0.
              IF ls_fcat-datatype = 'CURR'.
              Currency unit
                IF ls_fcat2-datatype = 'CUKY'.
                  ls_fcat-cfieldname = ls_fcat2-fieldname.
                  ls_fcat-ctabname   = ls_fcat2-tabname.
                  MODIFY fcat FROM ls_fcat.
                ELSE.
                  LOOP AT fcat INTO ls_fcat2
                               FROM l_index
                              WHERE datatype = 'CUKY'.
                  First currency unit after field
                    ls_fcat-cfieldname = ls_fcat2-fieldname.
                    ls_fcat-ctabname   = ls_fcat2-tabname.
                    MODIFY fcat FROM ls_fcat.
                    EXIT.
                  ENDLOOP.
                  IF sy-subrc NE 0.
                  No currency unit after field, try before
                    READ TABLE fcat INTO ls_fcat2
                                WITH KEY datatype = 'CUKY'.
                    IF sy-subrc = 0.
                      ls_fcat-cfieldname = ls_fcat2-fieldname.
                      ls_fcat-ctabname   = ls_fcat2-tabname.
                      MODIFY fcat FROM ls_fcat.
                    ENDIF.
                  ENDIF.
                ENDIF.
              ENDIF.
              IF ls_fcat-datatype = 'QUAN'.
              Quantity unit
                IF ls_fcat2-datatype = 'UNIT'.
                  ls_fcat-cfieldname = ls_fcat2-fieldname.
                  ls_fcat-ctabname   = ls_fcat2-tabname.
                  MODIFY fcat FROM ls_fcat.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDMETHOD.
      Get definition of type from code source
      METHOD get_definition.
        DATA: l_strng TYPE rssource,
              ls_abap TYPE rssource,
              l_fdpos TYPE i,
              l_first TYPE i,
              l_lastr TYPE i.
        DATA: lt_incl TYPE TABLE OF repid,
              ls_incl TYPE repid.
      Get program code
        READ REPORT repid INTO abap.
        CHECK sy-subrc EQ 0.
      Get first line of definition
        CONCATENATE 'BEGIN OF' struc INTO l_strng
                                SEPARATED BY space.
        LOOP AT abap INTO ls_abap.
          IF ls_abap CS l_strng.
            l_fdpos = strlen( l_strng ) + sy-fdpos.
            IF ls_abap+l_fdpos(1) CA ', "'.
              l_first = sy-tabix.
              EXIT.
            ENDIF.
          ENDIF.
        ENDLOOP.
        IF l_first IS INITIAL.
        Table is defined in an include
          CALL FUNCTION 'RS_GET_ALL_INCLUDES'
               EXPORTING
                    program    = repid
               TABLES
                    includetab = lt_incl
               EXCEPTIONS
                    OTHERS     = 1.
          IF sy-subrc = 0.
            LOOP AT lt_incl INTO ls_incl.
            Try to find definition in this include
              READ REPORT ls_incl INTO abap.
              LOOP AT abap INTO ls_abap.
                IF ls_abap CS l_strng.
                  l_fdpos = strlen( l_strng ) + sy-fdpos.
                  IF ls_abap+l_fdpos(1) CA ',. "'.
                    l_first = sy-tabix.
                    EXIT.
                  ENDIF.
                ENDIF.
              ENDLOOP.
              IF NOT l_first IS INITIAL.
                EXIT.
              ENDIF.
            ENDLOOP.
          ENDIF.
        ENDIF.
      Get last line of definition
        CONCATENATE 'END OF' struc INTO l_strng
                              SEPARATED BY space.
        LOOP AT abap INTO ls_abap.
          IF ls_abap CS l_strng.
            l_fdpos = strlen( l_strng ) + sy-fdpos.
            IF ls_abap+l_fdpos(1) CA ',. "'.
              l_lastr = sy-tabix - l_first.
              EXIT.
            ENDIF.
          ENDIF.
        ENDLOOP.
      Keep only relevant code lines
        IF l_first LE 0
        OR l_lastr LE 0.
          REFRESH abap.
        ELSE.
          DELETE abap TO l_first.
          DELETE abap FROM l_lastr.
        ENDIF.
      ENDMETHOD.
      Get definition of type recursively
      METHOD recursive_definition.
        DATA: lt_token TYPE TABLE OF stokex,
              ls_token TYPE stokex,
              lt_state TYPE TABLE OF sstmnt,
              ls_state TYPE sstmnt.
        DATA: ls_defin TYPE ty_defin,
              l_reffld TYPE fieldname.
        DATA: lt_recu  TYPE TABLE OF rssource.
      Retrieve tokens
        SCAN ABAP-SOURCE abap
                  TOKENS INTO lt_token
              STATEMENTS INTO lt_state.
        LOOP AT lt_state INTO ls_state.
          CLEAR: ls_defin.
        Field name
          READ TABLE lt_token INTO ls_token
                             INDEX ls_state-from.
          ls_defin-fieldname = ls_token-str.
        Reference type
          READ TABLE lt_token INTO ls_token
                             INDEX ls_state-to.
          l_reffld = ls_token-str.
        Check if this type is defined in program
          FREE: lt_recu.
          CALL METHOD get_definition EXPORTING repid = repid
                                               struc = l_reffld
                                      CHANGING abap  = lt_recu.
          IF lt_recu IS INITIAL.
            IF NOT g_level IS INITIAL.
             CONCATENATE g_level ls_defin-fieldname INTO ls_defin-fieldname
                                                           SEPARATED BY '-'.
              CONDENSE ls_defin-fieldname.
            ENDIF.
            IF l_reffld CS '-'.
              SPLIT l_reffld AT '-'
                           INTO ls_defin-ref_tabname
                                ls_defin-ref_fieldname.
              IF ls_defin-ref_tabname = 'SY'.
                ls_defin-ref_tabname = 'SYST'.
              ENDIF.
            ELSE.
              ls_defin-ref_fieldname = ls_token-str.
            ENDIF.
            APPEND ls_defin TO me->gt_defin.
          ELSE.
          Process sub levels
            IF me->g_level IS INITIAL.
              me->g_level = ls_defin-fieldname.
            ELSE.
              CONCATENATE me->g_level ls_defin-fieldname INTO me->g_level
                                                 SEPARATED BY '-'.
            ENDIF.
            CALL METHOD recursive_definition EXPORTING repid = repid
                                              CHANGING abap  = lt_recu.
            IF me->g_level CS '-'.
              SHIFT me->g_level RIGHT UP TO '-'.
              SHIFT me->g_level RIGHT.
              SHIFT me->g_level LEFT DELETING LEADING space.
            ELSE.
              CLEAR: me->g_level.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDMETHOD.
      Set table name
      METHOD set_table_name.
        me->g_table = in_tabname.
      ENDMETHOD.
      Set title
      METHOD set_alv_title.
        me->g_title = in_title.
      ENDMETHOD.
      Set settings
      METHOD set_alv_settings.
        CALL METHOD map_structure EXPORTING source = in_settings
                                   CHANGING destin = me->gs_sett.
      ENDMETHOD.
      Set layout
      METHOD set_alv_layout.
        CALL METHOD map_structure EXPORTING source = in_layout
                                   CHANGING destin = me->gs_layo.
      ENDMETHOD.
      Add event
      METHOD set_alv_event.
        DATA: ls_evnt TYPE slis_alv_event.
        ls_evnt-name = in_name.
        ls_evnt-form = in_form.
        COLLECT ls_evnt INTO gt_evnt.
      ENDMETHOD.
      Map fields from incoming structure into attribute
      METHOD map_structure.
        DATA: ob_desc  TYPE REF TO cl_abap_structdescr,
              ls_compo TYPE abap_compdescr.
        FIELD-SYMBOLS: <field> TYPE ANY,
                       <struc> TYPE ANY.
        ob_desc ?= cl_abap_typedescr=>describe_by_data( destin ).
        LOOP AT ob_desc->components INTO ls_compo.
          ASSIGN COMPONENT ls_compo-name OF STRUCTURE source TO <field>.
          IF <field> IS ASSIGNED.
            ASSIGN COMPONENT ls_compo-name OF STRUCTURE destin TO <struc>.
            CATCH SYSTEM-EXCEPTIONS conversion_errors = 1.
              MOVE <field> TO <struc>.
            ENDCATCH.
            UNASSIGN <field>.
          ENDIF.
        ENDLOOP.
      ENDMETHOD.
    ENDCLASS.
    PLZ REWARD POINTS

  • ABAP field symbols and PERL reference variables to unnamed arrays.

    Rob -
    Please do NOT delete this post even though it contains this link:
    ABAP field symbols and PERL reference variables to unnamed arrays.
    to a question I posted in the Scripting Languages forum.
    It's a question that should be of interest to ABAP programmers, and they may miss if they don't frequent the SL forum ...
    Thanks for your forbearance here (in advance, of course) ...
    Best
    djh
    Edited by: Rob Burbank on Jul 11, 2011 1:26 PM

    If interested, please reply in the original thread. We don't want multiple conversations at cross purposes do we?
    Rob

  • How to keep Field symbol reference

    HI ALL ,
    I have method with that assign field symbol on it and I want to keep the reference of it ,
    does it impossible ?
    For instance
    ASSIGN cs_structure TO <ls_structure>. "both are type any and are always structure with fields f1...fn
        assign_request(
          EXPORTING
            is_fields = ls_fields
            ev_out    = es_field "F2
          CHANGING
            cs_str  = <ls_structure>
    es_field = '1'
    Here I have method that in the method I always need to return  field from the structure  (es_field - I dont know how to define it
    type any or type ref to data )
    my question is assume in <ls_structure>  I have field called F2 and I want to receive it but to keep the reference i.e.
    if i do after the method call es_field = '1' the field F2 on structure <ls_structure>  will contain '1'.
    There is a way to do that ?
    Regards
    Joy

    HI Naimesh
    I already try to define es_field as type ref to data but the issue is that for instance
    field symbol  <lv_field> type any.
    ASSIGN cs_structure TO <ls_structure>.
    inside the method assign_request I am doing ...
    ASSIGN COMPONENT 'F2'  OF STRUCTURE cs_str TO <lv_field>.
    GET REFERENCE OF <lv_field> INTO ev_out.
    call to the method
        assign_request(
          EXPORTING
            is_fields = ls_fields
            ev_out    = es_field 
          CHANGING
            cs_str  = <ls_structure>
    and after the method assign_request
    ASSIGN es_field->* to <lv_field>.
    <lv_field> = '1.'
    Now I except that cs_structure and <ls_structure> that have field F2 you see that value '1' but its not working ,
    what i miss here ?
    Regards
    joy

  • Delete Reference for  field symbol

    Hi
    i have thes code
    FUNCTION Z_DEMO.
    *"*"Local Interface:
    *"  IMPORTING
    *"     REFERENCE(INCLUDE_STRUCTURE) TYPE  TABNAM
    *"  TABLES
    *"      DATA_PACKAGE_TA
      DATA: it_data       TYPE REF TO data.
      FIELD-SYMBOLS: <fs_itab>         TYPE STANDARD TABLE.
      CREATE DATA it_data TYPE STANDARD TABLE OF (INCLUDE_STRUCTURE).
      ASSIGN it_data->* TO <fs_itab>.
      assign  DATA_PACKAGE_TA[] to <fs_it_dp>.
      sort <fs_itab> by ('COSTCENTER') ('CALMONTH') ('CURRENCY').
      delete adjacent duplicates
        from <fs_itab>
        comparing  ('COSTCENTER') ('CALMONTH') ('CURRENCY').
    (1)   Its workes good but it delete lines from DATA_PACKAGE_TA also how i can delete just from
           the field symbol <fs_itab> and keep the itab without change  ????
    (2) How I can build an another itab like DATA_PACKAGE_TA ??????
    Thanks and regardes .

    hi!
    instead of:
    assign  DATA_PACKAGE_TA[] to <fs_itab>.
    just do like this:
    <fs_itab>[] =  DATA_PACKAGE_TA[].
    then you can delete from <fs_itab> without deleting the other internal table.
    Bye,
    Andrew83.
    Hope this help you.

Maybe you are looking for

  • Inline display of error message for a regular expression validation

    Hi All, I am using ApexLib in my application. I am using regular expression validation for some of the items. Those validation will happen when the button is pressed and the message will be displayed as per the error. But, I want the errors to be dis

  • My page is not loading correctly after server work? Help?

    A couple of days ago I was having issues uploading files to my webserver and come to find out, they were working on something on their end.  So okay.  But now, certain pages on my website are not loading correctly.  These are not necessarily pages I

  • Cumilitave salary for next hire date

    plz help me regarding this In a single select query display ename, job, sal, hiredate, no of days between next hire within the department. thnak you

  • Package synonym not working

    I'm calling a PL/SQL package from my APEX application. I created a synonym for the package as follows: create or replace synonym apex_ebs.dcrd_inv_common for dcrd_inv_common; However, i'm getting an error: 1 error has occurred •ORA-06550: line 10, co

  • Posting video filmed in landscape mode to Facebook

    If I film a video in landscape mode on my iPhone 5, and try to post it to Facebook, the video posts in portrait mode, so that the entire video is sideways.  Is there something different that I should be doing with the video on my phone to have it pos