12-15-2011 9:03 AM
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?
12-15-2011 9:11 AM
Hi,
You use a deep structure where you can have a table inside your structure as u need it.
12-15-2011 9:11 AM
Hi,
You use a deep structure where you can have a table inside your structure as u need it.
12-15-2011 9:18 AM
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'.
12-15-2011 9:28 AM
Hi,
You can use Table type to achieve this..
Thanks & Regards,
Kiran
12-15-2011 9:31 AM
12-15-2011 9:34 AM
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 ?
12-15-2011 9:40 AM
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
12-15-2011 9:30 AM
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
12-15-2011 9:42 AM
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.
12-15-2011 10:53 AM
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
12-15-2011 12:42 PM
- 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
12-15-2011 2:08 PM