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: 

how can I declare a table inside of a structure?

Former Member
0 Kudos

Hi,

I would like to have a table inside of a structure.

The following code is what I tried:

DATA: s_f800komp TYPE zppdru_f800komp. "saved structure in repository

Data: lt_documentfiles LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.

types: lt_documentfiles type standard table of bapi_doc_files2 WITH DEFAULT KEY .

Types: Begin of s_data_f800komp ,

docfiles type lt_documentfiles.

include structure s_f800komp .

Types: End of s_data_f800komp.

Data: s_data_f800komp type s_data_f800komp.

Data: t_data_f800komp type standard table of s_data_f800komp with header line.

If I now try to assign the table ...

s_data_f800komp-docfiles = lt_documentfiles.

I get a syntax error: "The type of s_data_f800komp-docfiles is not konvertable into the type of lt_documentfiles."

Can anyone give me a clue?

1 ACCEPTED SOLUTION

pradeep_grandhi
Active Participant
0 Kudos

Hi,

You use a deep structure where you can have a table inside your structure as u need it.

11 REPLIES 11

pradeep_grandhi
Active Participant
0 Kudos

Hi,

You use a deep structure where you can have a table inside your structure as u need it.

0 Kudos

I'm really sorry, but I don't understand what to do or change.

Can you provide me some lines of code?

My data declarations are in form correct (no syntax error), but my code is not working.

I thought, that I declared a 'deep structure'.

0 Kudos

Hi,

You can use Table type to achieve this..

Thanks & Regards,

Kiran

0 Kudos

Or use google on 'define deep structure'.

0 Kudos

If I try

Types: Begin of s_data_f800komp ,

docfiles type table of lt_documentfiles.

include structure s_f800komp .

Types: End of s_data_f800komp.

I get a syntax error: inside of structures no generic type definitions allowed.

Couldn't you explain me how to create a deep structure with table type by giving my an example ?

0 Kudos

Hello friend,

Your same code but with few changes.

Use this code

DATA: s_f800komp TYPE zppdru_f800komp. "saved structure in repository

TYPES: lt_documentfiles TYPE STANDARD TABLE OF bapi_doc_files2 WITH DEFAULT KEY .

DATA: lt_documentfiles type lt_documentfiles. "LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.

TYPES: BEGIN OF s_data_f800komp ,

docfiles TYPE lt_documentfiles.

INCLUDE STRUCTURE s_f800komp .

TYPES: END OF s_data_f800komp.

DATA: s_data_f800komp TYPE s_data_f800komp.

DATA: t_data_f800komp TYPE STANDARD TABLE OF s_data_f800komp WITH HEADER LINE.

s_data_f800komp-docfiles = lt_documentfiles.

Its works fine i checked please revert back if you have any queries.

Thanks,

Sri Hari

Edited by: srihari.kumar on Dec 15, 2011 3:13 PM

Former Member
0 Kudos

Hi,

data : itab like kna1 occurs 0 with header line.

Types: Begin of s_data_f800komp ,

docfiles type itab.

include structure kna1 .

Types: End of s_data_f800komp.

I think your syntax is correct but in this statement s_data_f800komp-docfiles = lt_documentfiles. you are assigning 2 diiferent structures . its not possible to assign 2 difff structures.

Edited by: Ravi.Seela on Dec 15, 2011 10:32 AM

pradeep_grandhi
Active Participant
0 Kudos
Types: Begin of MyRec,
             Field1 type c,
             Field2 type c,
       End of MyRec,
       MyRec_Table type Standard table of MyRec,

       Begin of Deep_Record,
             dr_Field1 type Matnr,
             dr_Field2 type MyRec_Table,
             dr_Field3 type Bwart,         
       End of Deep_Record,
       Deep_Table type standard table of Deep_Record.

Former Member
0 Kudos

Dear Knud,

You can refer to the following code:

TYPES: BEGIN OF ty_str,

field1(10) TYPE c,

field2(15) TYPE c,

END OF ty_str.

DATA: int_str TYPE STANDARD TABLE OF ty_str,

wa_str TYPE ty_str.

DATA: BEGIN OF wa_str2,

field3(20) TYPE c,

field4 LIKE int_str,

END OF wa_str2.

DATA: int_str2 LIKE STANDARD TABLE OF wa_str2.

START-OF-SELECTION.

wa_str-field1 = 'field1'.

wa_str-field2 = 'field2'.

APPEND wa_str TO int_str.

wa_str2-field3 = 'field3'.

wa_str2-field4 = int_str[].

APPEND wa_str2 TO int_str2.

LOOP AT int_str2 INTO wa_str2.

WRITE: /10 wa_str2-field3.

LOOP AT wa_str2-field4 into wa_str.

WRITE: /10 wa_str-field1, 30 wa_str-field2.

ENDLOOP.

ENDLOOP.

Best wishes,

Atanu

raymond_giuseppi
Active Contributor
0 Kudos

- Remarks : header line are obsolete

- Question : did you try

s_data_f800komp-docfiles[] = lt_documentfiles[].

(Or remove the header lines, you were assigning the header line to the internal table raising a syntax error)

Regards,

Raymond

Former Member
0 Kudos

Take a look at this blog series: [ |]

I learned A LOT about typing with it!

Regards,

Mauricio