Application Development and Automation 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: 
Read only

How to define complex type with table per record?

Former Member
0 Likes
514

Hi,

for one of my tasks I'm dealing with XML export. After short investigation of the postings in the forum I found an acceptable solution:

The issue is that I need an XML file like this:

<plant>

<material>

<purchases>data</purchases>

<purchases>data</purchases>

<purchases>data</purchases>

...

<sales>data</sales>

<sales>data</sales>

<sales>data</sales>

...

</material>

<next material>

...

</next material>

</plant>

So here are the questions:

1. Is it possible (and how) to define such deep structured type where for each record (means material) there is at least 1 internal table connected to that record? That would let me use a record-2-DOM conversion and a standard DOM-2-XML renderer.

2. Could anyone please provide a very simple and short example?

Of course, I could write my own XML renderer and achieve what I need (without using DOM, simply write to file all the desired XML tags while looping at my *nested* tables), but if there is a way to define such a structured type and further to fill it with data, it would help me learn a little bit more about abap opportunities and would save me a bit more time to create a renderer.

Many thanks in advance.

Regards,

Ivaylo Mutafchiev

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
477

Hi,

You can declare deep structure as below

TYPES : BEGIN OF ty_address,

house(10) TYPE c,

street(10) TYPE c,

END OF ty_address.

TYPES : BEGIN OF ty_itab,

name(10) TYPE c,

age TYPE i,

address TYPE ty_address OCCURS 0,

END OF ty_itab.

DATA : i_address TYPE STANDARD TABLE OF ty_address,

i_itab TYPE STANDARD TABLE OF ty_itab.

DATA : wa_address TYPE ty_address,

wa_itab TYPE ty_itab.

CLEAR : wa_address,

wa_itab.

wa_address-house = 'House1'.

wa_address-street = 'Street1'.

APPEND wa_address TO i_address.

wa_address-house = 'House2'.

wa_address-street = 'Street2'.

APPEND wa_address TO i_address.

wa_itab-name = 'Test'.

wa_itab-age = 10.

wa_itab-address[] = i_address[].

APPEND wa_itab TO i_itab.

Also check structure BSPL_GRID_FIELDCAT field CELL_COLOR

Hi,

for one of my tasks I'm dealing with XML export. After short investigation of the postings in the forum I found an acceptable solution:

The issue is that I need an XML file like this:

<plant>

<material>

<purchases>data</purchases>

<purchases>data</purchases>

<purchases>data</purchases>

...

<sales>data</sales>

<sales>data</sales>

<sales>data</sales>

...

</material>

<next material>

...

</next material>

</plant>

So here are the questions:

1. Is it possible (and how) to define such deep structured type where for each record (means material) there is at least 1 internal table connected to that record? That would let me use a record-2-DOM conversion and a standard DOM-2-XML renderer.

2. Could anyone please provide a very simple and short example?

Of course, I could write my own XML renderer and achieve what I need (without using DOM, simply write to file all the desired XML tags while looping at my *nested* tables), but if there is a way to define such a structured type and further to fill it with data, it would help me learn a little bit more about abap opportunities and would save me a bit more time to create a renderer.

Many thanks in advance.

Regards,

Ivaylo Mutafchiev

2 REPLIES 2
Read only

Former Member
0 Likes
478

Hi,

You can declare deep structure as below

TYPES : BEGIN OF ty_address,

house(10) TYPE c,

street(10) TYPE c,

END OF ty_address.

TYPES : BEGIN OF ty_itab,

name(10) TYPE c,

age TYPE i,

address TYPE ty_address OCCURS 0,

END OF ty_itab.

DATA : i_address TYPE STANDARD TABLE OF ty_address,

i_itab TYPE STANDARD TABLE OF ty_itab.

DATA : wa_address TYPE ty_address,

wa_itab TYPE ty_itab.

CLEAR : wa_address,

wa_itab.

wa_address-house = 'House1'.

wa_address-street = 'Street1'.

APPEND wa_address TO i_address.

wa_address-house = 'House2'.

wa_address-street = 'Street2'.

APPEND wa_address TO i_address.

wa_itab-name = 'Test'.

wa_itab-age = 10.

wa_itab-address[] = i_address[].

APPEND wa_itab TO i_itab.

Also check structure BSPL_GRID_FIELDCAT field CELL_COLOR

Read only

0 Likes
477

Simple and perfectly clear.

Thanks a lot!

Ivaylo