Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

It cannot reference the dynamic internal table in memory as an object.

former_member213436
Participant
0 Kudos

Hi,

I am getting the syntax error in the second select. I guest it cannot reference the dynamic internal table in memory as an object.

The internal table contains different fields from multiple tables and it gets created OK. Then the first select within the loop executes OK allowing me to read the multiple tables in ITABLES.



* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = ifc
    IMPORTING
      ep_table        = dy_table.

***OK, the dynamic tables is created here
  assign dy_table->* to <dyn_table>.

* Create dynamic work area and assign to FS
  create data dy_line like line of <dyn_table>.
  assign dy_line->* to <dyn_wa>.

loop at ITABLES.

***OK, no syntax errors in this select here
  select * appending corresponding fields of table <dyn_table>
             from (ITABLES-TABNAME).

endloop.

data: ikonp like konp occurs 0 with header line.

***NOT OK, there is syntax errors
  select * into table ikonp
  from KONP for all entries in <dyn_table>
  where knumh = <dyn_table>-knumh.

Some of the tables in ITABLES are pooled tables which does not allow me to use INNER JOINS. Therefore I need a second select in order to read the pricing table KONP.

Thanks in advance for any hint.

4 REPLIES 4

Former Member
0 Kudos

Hi Abel,

You must be getting the syntax error that <dyn_table> does not contain the field knumh.

try putiing the entire where clause in a char type variable say wa_char and then use in ur query as

where (wa_char) .. it may work..


concatenate 'knumh' '=' '<dyn_table>-knumh' INTO wa_char SEPARATED BY SPACES.

SELECT ... from konp...
where (wa_char).

Revert if it doesnt work.

former_member222860
Active Contributor
0 Kudos

Hi,

use this

data: v_where type string.

v_where = '& = & '.
REPLACE '&' WITH 'knumh' INTO v_where.
REPLACE '&' WITH  '<dyn_table>-knumh' INTO v_where.

select * into table ikonp
  from KONP for all entries in <dyn_table>
  where (v_where).

0 Kudos

Hi Mahesh,

Could you please explain why

v_where = '& = & '.

REPLACE '&' WITH 'knumh' INTO v_where.

REPLACE '&' WITH '<dyn_table>-knumh' INTO v_where.

will not result in knumh = knumh ... !!!!!

0 Kudos

Hi Ankesh,

My code gives:

knumh = <dyn_table>-knumh

thanks