Application Development and Automation 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: 
Read only

READ TABLE <pointer> ...

Former Member
1,809

Hi there. How can I assign an itab to pointer to have possibility to make operations on pointer (not itab)?

[ I ]


DATA: itab LIKE dbtab OCCURS 0 .
field-symbols: <ritab> type any table .
field-symbols: <rline> type any .

ASSIGN itab TO <ritab> .

it's ok but now ... when I want to ...


READ TABLE <ritab> INTO <rline> INDEX G_arow .

... I receive You cannot use explicit or implicit index operations on tables with

types "HASHED TABLE" or "ANY TABLE". "<RITAB>" has the type "ANY TABLE".

[ II ]


DATA: itab LIKE dbtab OCCURS 0 .
field-symbols: <pointer> type standard table .
field-symbols: <rline> type any .

ASSIGN (itab) TO <pointer> .

the ASSIGN statement returns sy-subrc = 4

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,422

Hi,

change your declaration of

field-symbols: <pointer> type any table .

to

field-symbols: <pointer> type standard table .

Darren

11 REPLIES 11
Read only

Former Member
0 Likes
1,422

make ritab type table not type any table

Read only

Former Member
0 Likes
1,422

Did you try

READ TABLE <ritab> ASSIGNING <rline> INDEX G_arow .

-Aman

Read only

0 Likes
1,422

Also remove the brackets from the itab ...

ASSIGN (itab) TO <pointer> .

isntead to ASSIGN itab TO <pointer> .

regards,

Advait

Read only

Former Member
0 Likes
1,422

there's a mistake in my post but I can't edit it now...

Explanation: <ritab> = <pointer>

<<First post edited by your friendly neighbourhood moderator>>

Read only

Former Member
0 Likes
1,423

Hi,

change your declaration of

field-symbols: <pointer> type any table .

to

field-symbols: <pointer> type standard table .

Darren

Read only

matt
Active Contributor
0 Likes
1,422

INDEX TABLE would be better.

Explanation. something defined with reference to ANY TABLE could be a HASHED table, and that doesn't support indexed operations. SORTED tables and STANDARD tables do. They are referred to generically as INDEX.

matt

Read only

0 Likes
1,422

A)


DATA: itab LIKE zlhist02 OCCURS 0 WITH HEADER LINE .

field-symbols: <pointer> type table .
" OR
field-symbols: <pointer> type standard table .
" OR
field-symbols: <pointer> type any table .

field-symbols: <line> type any .



ASSIGN itab TO <pointer> . " ERROR



READ TABLE <pointer> ASSIGNING <line> INDEX 1 .

"itab" is not type-compatible with field symbol "<POINTER>".

Read only

matt
Active Contributor
0 Likes
1,422

If you hadn't defined ITAB as a table with a header-line, you wouldn't have had the problem.

ASSIGN itab[] TO <pointer> .

Tables with header lines are inherently ambigous - as you've found. Is itab the table or the header-line? In this case, it was the header. Don't use them - they're not allowed in an Object Oriented context anyway. Instead define seperate work areas.

matt

Read only

0 Likes
1,422

Defin your table with the types as you have defined your field symbols POINTER with types.


DATA: itab Type standarad table of zlhist02.

Regards,

Naimesh Patel

Read only

0 Likes
1,422

Naimesh Patel

The problem is that original itab declaration is more complex ...


DATA: BEGIN OFitab OCCURS 0 ...
 ...  field1 ...
 ...  field2 ...
 ...  field3 ...
 ...  ...... ...
 ...  END OF itab .

and I can't change it

Read only

matt
Active Contributor
0 Likes
1,422

>

> The problem is that original itab declaration is more complex ...

> and I can't change it

OK - in that case change the code as I suggested.

matt