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: 

Assign type Conflict

Former Member
0 Kudos

FIELD-SYMBOLS: <l_table> TYPE STANDARD TABLE  ,

                <l_field> TYPE ANY.

     READ TABLE gt_itab ASSIGNING <l_field>. "with table key pernr =  <l_table>-pernr.

LOOP at gt_itab.

check <l_field> is assigned.

ASSIGN <l_field> TO <l_table>. -------- I get runtime this line

ENDLOOP.

Note: My gt_itab (interna table) and <l_field> are loaded.

8 REPLIES 8

Abhijit74
Active Contributor
0 Kudos

Hello,

Instead of FIELD-SYMBOLS: <l_table> TYPE STANDARD TABLE  ,

Make it FIELD-SYMBOLS: <l_table> TYPE Any  .

Thanks & Regards,

Abhijit

thanga_prakash
Active Contributor
0 Kudos

Hello Burak,

It is very clear from the runtime error that there is type conflict.

Change the declaration of <l_table> as below.


FIELD-SYMBOLS: <l_table> TYPE STANDARD TABLE  ,

Regards,

Thanga

0 Kudos

My code already like this.  What should be type of <l_table> ?

Former Member
0 Kudos

Hi, A type conflict would happen when structures of <l_field> and <l_itab> do not match in the run time.

For ASSIGN <l_field> TO <l_table> this statement to execute successfully, <l_field> must be of table type, however, it seems that it is of a structure type rather than a table type.

Kindly check and make changes accordingly.

I hope this will fix your issue.

Thanks

Mohit

thanga_prakash
Active Contributor
0 Kudos

Hello Burak,

Sorry typo error. Declare like below.

FIELD-SYMBOLS: <l_table> TYPE any.


Regards,

Thanga

matt
Active Contributor
0 Kudos

1. FIELD-SYMBOLS: <l_table> TYPE STANDARD TABLE.

2.                <l_field> TYPE ANY.

3. READ TABLE gt_itab ASSIGNING <l_field>. "with table key pernr =  <l_table>-pernr.

4. LOOP at gt_itab.

5.   check <l_field> is assigned.

6.   ASSIGN <l_field> TO <l_table>. -------- I get runtime this line

7. ENDLOOP.

Once step 3 is complete, <l_field> is either assigned or not assigned. It's status will not now change. The means the check at step 5 is unnecessarily within the loop. This would be better.

1. FIELD-SYMBOLS: <l_table> TYPE STANDARD TABLE.

2.                <l_field> TYPE ANY.

3. READ TABLE gt_itab ASSIGNING <l_field>. "with table key pernr =  <l_table>-pernr.

4. IF <l_field> IS ASSIGNED.

5.   LOOP at gt_itab.

6.     ASSIGN <l_field> TO <l_table>. -------- I get runtime this line

7.   ENDLOOP.

8. ENDIF.

Given the typing of <l_table> and <l_field>, line 6 makes zero sense. You can't assign a component of a line of table to a table field symbol. I think you don't understand ASSIGN.

Without knowing what you intend your program to do - and what you've supplied looks incomplete, I cannot help you further. I suggest that you read the abap help on ASSIGN, and look for examples of how to use it with internal tables.

Former Member
0 Kudos


Burak YILDIZ wrote:

ASSIGN <l_field> TO <l_table>. -------- I get runtime this line

Thats not the way to use the ASSIGN statement. I am not sure what do u exactly want to do here.

You cannot assign a structure field symbol to a table field symbol.

READ TABLE into reads one record so the loop is not used properly. If u want to read all the records from it_tab with the key pernr and insert it into <l_table> you could use :

FIELD-SYMBOLS: <l_table> TYPE STANDARD TABLE  ,

                <l_field> TYPE ANY.

LOOP at gt_itab ASSIGNING  <l_field>. "with table key pernr =  <l_table>-pernr.

APPEND <l_field> TO <l_table>.

ENDLOOP.

it will load all the fields from gt_itab to <l_table> having the key u specified.

0 Kudos

Hello All,

Im getting an error for the same but didn't declare <i_table> bcz Im generating ALV report for the DDIC tables.

FIELD-SYMBOLS: type STANDARD TABLE.

  ASSIGN FS_TAB->* TO .

Thanks,

Vivek