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: 

Declaration of WA for Table Type

Former Member
0 Kudos
1,299

Hi,

I am trying to append a structure data to a table type.

For example:

I have a Table Type called ZTABLE_TYPE of Line Type ZSTRUCTURE.

In my program, my declaration is as below:


DATA itab TYPE STANDARD TABLE OF ZTABLE_TYPE.
DATA work_area TYPE ZSTRUCTURE.

work_area-field1 = 'abc'
work_area-field2 = '123'
APPEND work_area TO itab.

However, when I try to activate, I received a syntax error:

"WORK_AREA" cannot be converted to the line type of "ITAB".

Can I get some help on whether I have declared wrongly, or is there a more appropriate way to append data into a table type.

Thanks!

1 ACCEPTED SOLUTION

Former Member
0 Kudos
327

Hi,

Try the below code.

DATA itab TYPE ZTABLE_TYPE.

DATA work_area TYPE ZSTRUCTURE.

work_area-field1 = 'abc'

work_area-field2 = '123'

APPEND work_area TO itab.

Hope it helps.

Regards

Shruti

6 REPLIES 6

Former Member
0 Kudos
327

Hi Adrian ,

Go for the below declaration

DATA itab TYPE STANDARD TABLE OF ZTABLE_TYPE.
        work_area TYPE ZTABLE_TYPE
 
(or)

DATA itab TYPE STANDARD TABLE OF ZSTRUCTURE..
        work_area TYPE ZSTRUCTURE.  

0 Kudos
327

Thanks Shruti, Santosh and Vijetasap for your help and explanation. Works now.

Prasath and Harsh, sorry I should have explained this in my initial post, but I couldn't declare both the same as I was using the table type as an export parameter for a function. Thanks for the help anyways.

former_member217316
Contributor
0 Kudos
327

Hi Adrian

The TYPE of Work Area as well as the internal table should be the same either ZSTRUCTURE or ZTABLE_TYPE.

Hope this helps.

Harsh

Former Member
0 Kudos
328

Hi,

Try the below code.

DATA itab TYPE ZTABLE_TYPE.

DATA work_area TYPE ZSTRUCTURE.

work_area-field1 = 'abc'

work_area-field2 = '123'

APPEND work_area TO itab.

Hope it helps.

Regards

Shruti

Former Member
0 Kudos
327

Hi,

Declare like this:

DATA itab TYPE ZTABLE_TYPE.

DATA work_area TYPE ZSTRUCTURE.

work_area-field1 = 'abc'

work_area-field2 = '123'

APPEND work_area TO itab.

This is because ZTABLE_TYPE is already a table type. So you need not mention "type table of" in your declaration part.

Thanks and Regards,

Santosh Kumar Mukka.

Former Member
0 Kudos
327

Firstly ZTABLE_TYPE, is it a database table ora table type.

If its a table type then you need to declare it as:-

Data : itab type ZTABLE_TYPE.

and if its a database table then declare:

Data: itab type tbale of ZTABLE_TYPE.