Skip to Content

Create a work area field symbol for dynamic table

Hello Gurus,

I have the next code sequence in a class method:

itablref type ref to data,

itablref_line type ref to data,

<itabl> type standard table,

<witabl> type any,

CALL METHOD MB51READ->MB51OUTPUT

RECEIVING

TABLE_OUT = itablref.

ASSIGN itablref->* to <itabl>.

create data itablref_line like line of <itabl>.

assign itablref_line->* to <witabl>.

LOOP AT <itabl> assigning <witabl>.

READ TABLE imseg into <wimseg> INDEX sy-tabix.

Error >>>>> <witabl>-wempf = <wimseg>-wempf.

MODIFY <itabl> FROM <witabl> TRANSPORTING wempf WHERE mblnr = <witabl>-mblnr.

ENDLOOP.

It is not working, the error is: The data object <witabl> has no structure and therefor no component called "WEMPF".

I want only OO programming !!!!!!

I will reward points !!!!!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Feb 21, 2008 at 11:57 AM

    Try

    FIELD-SYMBOLS: <l_wempf> TYPE ANY.
    ...
    LOOP AT <itabl> ASSIGNING <witabl>.
      ...  
      ASSIGN COMPONENT 'WEMPF' OF STRUCTURE <witabl> TO <l_wempf>.
      <l_wempf> = <wimseg>-wempf.
      ...
    ENDLOOP. 

    Though this is more efficient:

    FIELD-SYMBOLS: <l_wempf> TYPE ANY.
    ...
    ASSIGN COMPONENT 'WEMPF' OF STRUCTURE <witabl> TO <l_wempf>.
    LOOP AT <itabl> INTO <witabl>.
      ...  
      <l_wempf> = <wimseg>-wempf.
      ...
    ENDLOOP. 

    matt

    Add a comment
    10|10000 characters needed characters exceeded

    • 1) With LOOP AT ASSIGNING, there's no need for a modify. The field-symbols point to the position in memory. When you change the work area, you are changing the row in memory.

      2) You can't use MODIFY... WHERE with a dynamic table.

      3) And even if you could, you'd want to modify from the workarea - <witabl> - not the field <field>.

      4) 'WEMPF' is required - not 'wempf'.

      matt

  • Posted on Feb 21, 2008 at 12:31 PM

    Hello Ioan

    I guess the problem lies here:

    > LOOP AT <itabl> assigning <witabl>.

    > READ TABLE imseg into <wimseg> INDEX sy-tabix.

    > Error >>>>> <witabl>-wempf = <wimseg>-wempf.

    > MODIFY <itabl> FROM <witabl> TRANSPORTING wempf WHERE mblnr = <witabl>-mblnr.

    > ENDLOOP.

    >

    FIELD-SYMBOLS: <wimseg>  TYPE imseg.
    
    LOOP AT <itabl> ASSIGNING <witabl>.
      READ TABLE imseg ASSIGNING <wimseg>  INDEX syst-tabix.  " !!!
      
      ASSIGN COMPONENT 'WEMPF' OF STRUCTURE <witabl> TO <ld_wempf>.
      <ld_wempf> = <wimseg>-wempf.  " modifies <itabl> entry with index syst-tabix.
    ENDLOOP.
    

    I must admit that I do not really understand what this (strange) LOOP is doing.

    Regards

    Uwe

    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.