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

Question about dynamic assign a internal table

Former Member
0 Likes
1,073

Pls look at my code:

FIELD-SYMBOLS: <intab> TYPE ANY TABLE.

LOOP AT gt_zbolog.

table = gt_zbolog-ztable.

CONCATENATE 'GT_' gt_zbolog-ztable INTO intab.

ASSIGN (intab) TO <intab>.

SELECT * FROM (table) INTO CORRESPONDING FIELDS OF TABLE <intab>.

.......

ENDLOOP.

when run at this program,show 'ASSIGN_TYPE_CONFLICT' error.

How should I change the code?

1 ACCEPTED SOLUTION
Read only

anversha_s
Active Contributor
0 Likes
1,030

hi,

chk this code.

REPORT zdyn.

PARAMETERS: comp(80).

DATA: dref TYPE REF TO data.

FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE.

CREATE DATA dref TYPE TABLE OF (comp).

ASSIGN dref->* TO <dyn_table>.

SELECT * FROM (comp)

INTO TABLE <dyn_table>.

BREAK-POINT.

rgds

Anver

Pls look at my code:

FIELD-SYMBOLS: <intab> TYPE ANY TABLE.

LOOP AT gt_zbolog.

table = gt_zbolog-ztable.

CONCATENATE 'GT_' gt_zbolog-ztable INTO intab.

ASSIGN (intab) TO <intab>.

SELECT * FROM (table) INTO CORRESPONDING FIELDS OF TABLE <intab>.

.......

ENDLOOP.

when run at this program,show 'ASSIGN_TYPE_CONFLICT' error.

How should I change the code?

6 REPLIES 6
Read only

anversha_s
Active Contributor
0 Likes
1,031

hi,

chk this code.

REPORT zdyn.

PARAMETERS: comp(80).

DATA: dref TYPE REF TO data.

FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE.

CREATE DATA dref TYPE TABLE OF (comp).

ASSIGN dref->* TO <dyn_table>.

SELECT * FROM (comp)

INTO TABLE <dyn_table>.

BREAK-POINT.

rgds

Anver

Read only

0 Likes
1,030

Still, I find the comp can not be internal table in CREATE DATA dref TYPE TABLE OF (comp), for example ,I set comp = 'gt_adrc', it shows CREATE_DATA_UNKNOWN_TYPE.

Read only

0 Likes
1,030

hi jhonson,

pls chk this link.

http://www.sap-img.com/ab030.htm.

you will get a good idea.

rgds

Anver

Read only

Former Member
0 Likes
1,030

Johnson,

first write the select query and after that only u give the loop statement.

eg.

table: vbak.

data: t_vbak like vbak occurs 0 with header line.

select * from vbak into corresponding fields of table t_vbak where ...

like this u have to write.

Read only

Former Member
0 Likes
1,030

Thks to Anversha s !

Read only

Former Member
0 Likes
1,030

Hi Johnson,

you can not assign (intab) directly to field symbol, check the following program.


REPORT  zfs2                          .

PARAMETERs : tabname TYPE dd02l-tabname.
type-pools : slis.
DATA tabref TYPE ref to data.
FIELD-SYMBOLS <fs_table> type  TABLE.

data : lv_fcat type SLIS_T_FIELDCAT_ALV .
  data: lt_fieldcat      type lvc_t_fcat.
  data : ls_fieldcat         type slis_fieldcat_alv.
  data: lp_table_temp    type ref to data.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
 EXPORTING
*   I_PROGRAM_NAME               = sy-repid
*   I_INTERNAL_TABNAME           = lv_tabname
   I_STRUCTURE_NAME             = Tabname
*   I_CLIENT_NEVER_DISPLAY       = 'X'
*   I_INCLNAME                   =
*   I_BYPASSING_BUFFER           =
*   I_BUFFER_ACTIVE              =
  CHANGING
    ct_fieldcat                  = lv_fcat
 EXCEPTIONS
   INCONSISTENT_INTERFACE       = 1
   PROGRAM_ERROR                = 2
   OTHERS                       = 3.
          .

field-symbols: <fs_wa> type any.

data : ls_fcat like line of lt_fieldcat.

loop at lv_fcat into ls_fieldcat.
move-corresponding ls_fieldcat to ls_fcat.
append ls_fcat to lt_fieldcat.
endloop.

  CALL METHOD cl_alv_table_create=>create_dynamic_table
                     EXPORTING it_fieldcatalog = lt_fieldcat
                     IMPORTING ep_table = lp_table_temp.
  ASSIGN lp_table_temp->* TO <fs_table>.


 SELECT * FROM (tabname) INTO TABle <fs_table>  .

break-point.

hope this helps.

Regards,

Kinshuk