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

[ECC6] Inserting data from internal table (deep structure) into db table

Former Member
0 Likes
904

Hi experts,

I have a problem when inserting data from IT using deep structure into a database table. Please help:

I have one database table with 2 columns ZTest (col1, col2). Col1 is key.

In my program I have a deep structure t_screen using table type lvc_t_scol:

In 4.6c systems, the INSERT statement works well but it does not work in ECC6 systems.


DATA: BEGIN OF t_screen OCCURS 0,
        rec_count(3) TYPE n,
        col1 LIKE ZTest-col1,
        col2 LIKE ZTest-col2.
DATA: ct TYPE lvc_t_scol.
DATA: END   OF t_screen.
 
t_screen-col1 = 'test1'.
t_screen-col2 = 'test1'.
APPEND t_screen.
 
t_screen-col1 = 'test2'.
t_screen-col2 = 'test2'.
APPEND t_screen.
 
INSERT ZTest FROM TABLE t_screen ACCEPTING DUPLICATE KEYS.

Currently I have an idea using a temporary internal table with the same structure as ZTest. Use MOVE-CORRESPONDING statement to move data from t_screen table to temporary table before inserting --> It worked. But do you have any ideas without using temporary table?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
650

HI,

Check the below code...

DATA: BEGIN OF t_screen OCCURS 0,
        rec_count(3) TYPE n,
        col1 LIKE ZTest-col1,
        col2 LIKE ZTest-col2.
DATA: ct TYPE lvc_t_scol.
DATA: END   OF t_screen.
 
DATA  it_ct TYPE lvc_t_scol,
           ct_line LIKE LINE OF it_ct.

ct_line-FNAME = 'FNAME1'.
ct_line-color  = 'COLOR1'.
APPEND CT_linE to IT_CT.

ct_line-FNAME = 'FNAME2'.
ct_line-color  = 'COLOR2'.
APPEND CT_linE to IT_CT.

t_screen-col1 = 'test1'.
t_screen-col2 = 'test1'.
t_screen-ct[] = IT_CT[].
APPEND t_screen.

REFRESH IT_CT.

ct_line-FNAME = 'FNAME3'.
ct_line-color  = 'COLOR3'.
APPEND CT_linE to IT_CT.

ct_line-FNAME = 'FNAME4'.
ct_line-color  = 'COLOR4'.
APPEND CT_linE to IT_CT.
 
t_screen-col1 = 'test2'.
t_screen-col2 = 'test2'.
t_screen-ct[] = IT_CT[].
APPEND t_screen.
 
INSERT ZTest FROM TABLE t_screen ACCEPTING DUPLICATE KEYS.

3 REPLIES 3
Read only

Former Member
0 Likes
651

HI,

Check the below code...

DATA: BEGIN OF t_screen OCCURS 0,
        rec_count(3) TYPE n,
        col1 LIKE ZTest-col1,
        col2 LIKE ZTest-col2.
DATA: ct TYPE lvc_t_scol.
DATA: END   OF t_screen.
 
DATA  it_ct TYPE lvc_t_scol,
           ct_line LIKE LINE OF it_ct.

ct_line-FNAME = 'FNAME1'.
ct_line-color  = 'COLOR1'.
APPEND CT_linE to IT_CT.

ct_line-FNAME = 'FNAME2'.
ct_line-color  = 'COLOR2'.
APPEND CT_linE to IT_CT.

t_screen-col1 = 'test1'.
t_screen-col2 = 'test1'.
t_screen-ct[] = IT_CT[].
APPEND t_screen.

REFRESH IT_CT.

ct_line-FNAME = 'FNAME3'.
ct_line-color  = 'COLOR3'.
APPEND CT_linE to IT_CT.

ct_line-FNAME = 'FNAME4'.
ct_line-color  = 'COLOR4'.
APPEND CT_linE to IT_CT.
 
t_screen-col1 = 'test2'.
t_screen-col2 = 'test2'.
t_screen-ct[] = IT_CT[].
APPEND t_screen.
 
INSERT ZTest FROM TABLE t_screen ACCEPTING DUPLICATE KEYS.

Read only

0 Likes
650

Hi Kodarapu,

Thanks for your reply.

The problem is not because of lacking sample data.

The problem is syntax error when I compile the following code in ECC6 system.

INSERT ZTest FROM TABLE t_screen ACCEPTING DUPLICATE KEYS.

Message as follow:

The work area (or internal table) "T_SCREEN" is not flat, or contains reference or internal tables as components. components. components. components. components.

Sorry for my unclear description.

Edited by: Khanh Nguyen on May 13, 2009 12:14 PM

Read only

0 Likes
650

Hi

There are a large number of stataments couldn't be supported in unicode system and so it doesn't allow to do it in ECC 6.

U need to delete the deep structure from your defination:

DATA: BEGIN OF t_screen OCCURS 0,
        rec_count(3) TYPE n,
        col1 LIKE ZTest-col1,
        col2 LIKE ZTest-col2.
DATA: ct TYPE lvc_t_scol. "<-------- Error is here
DATA: END   OF t_screen.

So u need to use a structure like this to update your table:

DATA: BEGIN OF T_ZTEST OCCURS 0,
        rec_count(3) TYPE n,
        col1 LIKE ZTest-col1,
        col2 LIKE ZTest-col2.
DATA: END   OFT_ZTEST.

Max