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

How to create dynamicaly a structure that consists of couple of structures

Hello ABAP experts 😊

I have a structure STRUC1 that consists of fields F1, F2, F3. I would like to create a structure STRUC2 that would have N number (defined in a program) of STRUC1 in a line, i.e. STRUC2 consists of fields F1, F2, F3, F1, F2, F3, F1, F2, F3, ... (N times).

Conceptually I need something like this:

DATA: BEGIN OF STRUC1,

F1 TYPE TYPE_1,

F2 TYPE TYPE_2,

F3 TYPE TYPE_3,

END OF STRUC1.

DATA: BEGIN OF STRUC2.

DO N TIMES. "<---

INCLUDE STRUCTURE STRUC1.

ENDDO. "<---

DATA END OF STRUCALV.

I know that in the last DATA statements indicated with "<--- are not proper but I wanted just to show you my idea.

I appreciate any help. Thanks in advance. Regards

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Jun 17, 2008 at 10:15 AM

    hi,

    i dont think u can create a structure with repetative fields.

    so there is no point of N number.

    u can create like this.

    DATA: BEGIN OF STRUC1,

    F1 TYPE TYPE_1,

    F2 TYPE TYPE_2,

    F3 TYPE TYPE_3,

    F11 TYPE TYPE_1,

    F21 TYPE TYPE_2,

    F31 TYPE TYPE_3,

    END OF STRUC1.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 10:19 AM

    Hi

    Data : Struc2

    Include struc1

    include struc1

    end struc2.

    Thats all you can do

    😊

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 10:23 AM

    Hi

    Ur idea is good. But we cannot do so. Because u can have a unique field with field name which will be different but with sam e type.

    what is the need of having same field N number of times and

    putting it in structure.

    Think about it.

    -Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 10:23 AM

    Hi,

    Is there any requirement to generate the structure based on the selection screen input .

    if there any then there are many programs avialable on net which shows how to create dynamic internal table structure.

    If any issues you can get back to me.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      The requirement is that I need an ALV output for employee hierarchy. In short, user puts a personal number of top manager in a selection screen. A program selects his employees that can be managers also. Those managers can also have employees and so on. The program do such a selects until it reaches a bottom of the hierarchy. For simplification, lets say that we collect only personal numbers of employees and need to output it this way in ALV:

      M0__M01

      ________M011

      ________M012

      _____________E0121

      _____________E0122

      ____M02

      ________M021

      ____M03

      M0 - top manager

      M01,M02,M03 - managers under M0

      M011, M012 - managers under M01

      M021 - manager under M02

      E0121, E0122 - employees under M012

      _____ - empty cells

      So, I need to pass to ALV procedure a table consisting of a few fields for personal number.

      And this is my problem 😔 Could you advice?

      Regards

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.