Skip to Content

Field symbol problem

Dear all,

I am facing a problem wherein i want to modify <FS_DYN_TABLE> from <FS_DYN_TABLE_TEMP>.It is getting modified,i.e the column for which i want it modified is getting modified but remaining values of that corresponding row are not being displayed.

my declaration for above two are as follows:-

FIELD-SYMBOLS: <FS_DYN_TABLE> TYPE STANDARD TABLE,"Dynamic table

<FS_DYN_TABLE_TEMP> TYPE ANY ,.Temporary Dynamic table

My syntax was

MODIFY <FS_DYN_TABLE> FROM <FS_DYN_TABLE_TEMP> INDEX W_INDEX TRANSPORTING PERCN.

If i give

MODIFY <FS_DYN_TABLE> FROM <FS_DYN_TABLE_TEMP> TRANSPORTING PERCN ,it gives an error saying :-

"The specified type has no structure and therefore no component called

"PERCN". component called "PERCN".

How to resolve this problem?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 10:48 AM

    Hi,

    I think you need to deference <FS_DYN_TABLE_TEMP>, <FS_DYN_TABLE> as follows:

    FIELD-SYMBOLS: <FS_DYN_TABLE> TYPE STANDARD TABLE,"Dynamic table

    <FS_DYN_TABLE_TEMP> TYPE ANY ,.Temporary Dynamic table

    DATA: dref TYPE REF TO DATA.

    Create data dref type (your table structure).

    Assign dref->* to <FS_DYN_TABLE_TEMP>.

    Similarly you need to deference(assign structure) for <FS_DYN_TABLE>.

    Thanks and regards,

    S. Chandra Mouli.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi

      What you need to do actually is having got your structure

      then ASSIGN COMPONENT 'XXXXX' of structure <dyn_wa> to <fs1>.

      then fill <fs1> with your value

      repeat for all components of the structure you want to modify.

      then modify <dyn_table> from <dyn_wa> index nnn where nnn is the line you want to modify.

      Another easier way of course is to have a work area defined as your structure

      in my example above I have wa_elements type s_elements.

      now I can easily modify the dynamic itab as follows

      READ TABLE <dyn_table> INDEX e_row INTO wa_elements..

      wa_elements-viewed = 'V'.

      MODIFY <dyn_table> FROM wa_elements INDEX e_row.

      cheers

      jimbo

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 10:45 AM

    I'm not sure how to "untangle" your code, but here's a snippet using dynamic tables as an example.

    1) define your itab structure e.g

    TYPES: BEGIN OF s_elements,

    tabname TYPE dd02l-tabname,

    tabclass TYPE dd02l-tabclass,

    as4user TYPE dd02l-as4user,

    as4date TYPE dd02l-as4date,

    as4time TYPE dd02l-as4time,

    viewed(1) TYPE c.

    TYPES: END OF s_elements.

    data: my_line type s_elements.

    2) some data for getting the structure

    DATA: LR_RTTI_STRUC type ref to CL_ABAP_STRUCTDESCR,

    zog LIKE LINE OF lr_rtti_struc->components,

    zogt LIKE TABLE OF zog .

    3) get the structure as follows

    lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( my_line ).

    zogt[] = lr_rtti_struc->components.

    4) Create the field catalog for your dynamic table - you need this so we can reference the individual fields by name

    data WA_IT_FLDCAT type LVC_S_FCAT ,

    IT_FLDCAT type LVC_T_FCAT .

    LOOP AT zogt INTO zog.

    CLEAR wa_it_fldcat.

    wa_it_fldcat-fieldname = zog-name .

    wa_it_fldcat-datatype = zog-type_kind.

    wa_it_fldcat-inttype = zog-type_kind.

    wa_it_fldcat-intlen = zog-length.

    wa_it_fldcat-decimals = zog-decimals.

    wa_it_fldcat-coltext = zog-name.

    wa_it_fldcat-lowercase = 'X'.

    APPEND wa_it_fldcat TO it_fldcat .

    ENDLOOP.

    5) now we can create a dynamic table based on our data structure

    data: dy_table type ref to DATA;

    CALL METHOD cl_alv_table_create=>create_dynamic_table

    EXPORTING

    it_fieldcatalog = it_fldcat

    IMPORTING

    ep_table = dy_table.

    5) let's now populate this table

    data: dy_line TYPE REF TO data.

    field-symbols:

    <dyn_table> TYPE STANDARD TABLE,

    <dyn_wa>.

    ASSIGN dy_table->* TO <dyn_table>.

    CREATE DATA dy_line LIKE LINE OF <dyn_table>.

    ASSIGN dy_line->* TO <dyn_wa>.

    SELECT *

    FROM dd02l

    INTO CORRESPONDING FIELDS OF TABLE <dyn_table>

    WHERE tabname LIKE 'ZHR%'.

    you will now find <dyn_table> contains all the fields by name as defined in your original structure (s_elements in the above example).

    Read the table into a work area having the same structure as your dynamic itab e.g READ TABLE <dyn_table> INDEX e_row INTO wa_elements.

    You can then refer to individual elements such as wa_elements-tabname.

    To update the dynamic table for example simply update the work area and then modify the table from the work area.

    For example

    wa_elements-viewed = 'V'.

    MODIFY <dyn_table> FROM wa_elements INDEX e_row.

    Cheers

    jimbo

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 05, 2007 at 01:00 PM

    You cannot use this syntax, since <FS_DYN_TABLE> is dynamic and the system doesn't know it's structure before runtime.

    You should assign the component you need to an another field symbol, using:

    ASSIGN COMPONENT 'PERCN' OF STRUCTURE <FS_DYN_TABLE_TEMP> TO <FS_PERCN>.
    

    Now you have the value in the new FS, and can check the value.

    When modifyng the table, you can use dynamic component specification using a character-type variable (such as comp_name TYPE C LENGTH 20), which should contain the name of the component, like this:

    comp_name = 'PERCN'.
    MODIFY <FS_DYN_TABLE> FROM <FS_DYN_TABLE_TEMP> TRANSPORTING (comp_name).
    

    Note that modify, if a runtime error occurs, triggers a non-catchable exceptions, so do your tries!

    Hope this helps,

    Roby.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.