Skip to Content
author's profile photo Former Member
Former Member

how can I declare a table inside of a structure?

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?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    Posted on Dec 15, 2011 at 09:11 AM

    Hi,

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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • Posted on Dec 15, 2011 at 02:08 PM

    Take a look at this blog series: [ Do you really know everything about typing?|Do you really know everything about typing?]

    I learned A LOT about typing with it!

    Regards,

    Mauricio

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 15, 2011 at 09: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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 15, 2011 at 09: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.
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 15, 2011 at 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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 15, 2011 at 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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.