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

Generically typed data reference variable giving dump

Former Member
0 Likes
846

Hi

Could you please help me to understand the following behavior of data reference variable:

Case 1:

DATA: ls_flight TYPE sflight,

      lr_flight TYPE REF TO data.

FIELD-SYMBOLS: <lfs_flight> TYPE sflight.

ls_flight-carrid = 'AA'.

ls_flight-connid = '2157'.

GET REFERENCE OF ls_flight INTO lr_flight.

ASSIGN lr_flight->* TO <lfs_flight>.

Case 2:

TYPES: BEGIN OF ty_vbap,

        vbeln TYPE vbap-vbeln,

        posnr TYPE vbap-posnr,

       END OF ty_vbap.

DATA: it_vbap TYPE STANDARD TABLE OF ty_vbap,

      dref TYPE REF TO data.

FIELD-SYMBOLS: <fs_vbap> TYPE ty_vbap

SELECT vbeln posnr FROM VBAP INTO TABLE it_vbap UP TO 10 ROWS.


GET REFERENCE OF it_vbap INTO dref

ASSIGN dref->* TO <fs_vbap>.

Here CASE 1 is executing as expected while CASE 2 is giving dump for ASSIGN dref->* TO <fs_vbap>.  I do not really understand why CASE2 is giving dump( exception : ASSIGN_TYPE_CONFLICT, You attempted to assign a field to a typed field symbol, but the field does not have the required type).

Is user defined types played a role here? or Am I missing something obvious ?

1 ACCEPTED SOLUTION
Read only

PeterJonker
Active Contributor
0 Likes
715

In the first assignment field symbol and data are a structure. In the second assignment you try to assign a table to a structure.

Change the code as follows:

TYPES: BEGIN OF ty_vbap,

        vbeln TYPE vbap-vbeln,

        posnr TYPE vbap-posnr,

       END OF ty_vbap,

tt_vbap type standard table of ty_vbap.

data it_vbap type tt_vbap.

FIELD-SYMBOLS: <fs_vbap> TYPE tt_vbap

2 REPLIES 2
Read only

PeterJonker
Active Contributor
0 Likes
716

In the first assignment field symbol and data are a structure. In the second assignment you try to assign a table to a structure.

Change the code as follows:

TYPES: BEGIN OF ty_vbap,

        vbeln TYPE vbap-vbeln,

        posnr TYPE vbap-posnr,

       END OF ty_vbap,

tt_vbap type standard table of ty_vbap.

data it_vbap type tt_vbap.

FIELD-SYMBOLS: <fs_vbap> TYPE tt_vbap

Read only

0 Likes
715

I think sometimes my mind works  in a mysterious way.

I am feeling bad for myself to post such a silly question. Lack of experience might be the reason.

Anyhow, thanks for the response.