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

ABAP TYPE REF TO data to XML

Former Member
0 Likes
1,050

Hi,

Suppose I have a variable A type ref to data which refers to variable B type some_itab

Calling call transformation id source root = a would give an empty XML. The id transformation seem to be able to resolve elementary types, defined structures and references, but it somehow can't resolve generic references to structures.

Any ideas?

1 ACCEPTED SOLUTION
Read only

alejandro_bindi
Active Contributor
0 Likes
884

Not at the system now but I think you should do this using a field symbol:


DATA: gr_a TYPE REF TO DATA.
FIELD-SYMBOLS: <lt_a> TYPE STANDARD TABLE.

* Assuming table is already created and referenced by GR_A...
ASSIGN gr_a->* TO <lt_a>.
CHECK sy-subrc = 0.
CALL TRANSFORMATION id SOURCE = <lt_a>...

5 REPLIES 5
Read only

Former Member
0 Likes
884

It seems like the variable 'B' has to be created such that 'some_itab' is in the heap instead of the stack (ie, B type ref to some_itab. create B. instead of B type some_itab.)

Anyone know if this is an actual restriction of call transformation and why?

Read only

alejandro_bindi
Active Contributor
0 Likes
885

Not at the system now but I think you should do this using a field symbol:


DATA: gr_a TYPE REF TO DATA.
FIELD-SYMBOLS: <lt_a> TYPE STANDARD TABLE.

* Assuming table is already created and referenced by GR_A...
ASSIGN gr_a->* TO <lt_a>.
CHECK sy-subrc = 0.
CALL TRANSFORMATION id SOURCE = <lt_a>...

Read only

0 Likes
884

Hi Alejandro,

Thanks for the solution. I have a potentially n00b follow up question.

We may not be able to dereference the variables because we would like to assemble a bunch of these generic reference variables into another internal table on which the call transformation will be called. The challenge for us is not to transform a single internal table but to transform an internal table of tables. Building the second internal table with reference variables made in my previously mentioned method works. I'm not sure if it's possible to construct a table of field symbols.

Am I on wrong assumptions? Thanks!

Read only

0 Likes
884

If I get it right, you have an internal table with line type: TYPE REF TO data. Each of those references point to an "item" internal table.

You can´t "construct" an internal table of field symbols. A solution I see is to transform one "item" table at a time, looping the wrapping internal table. And finally group the resulting XMLs into a single one, using the iXML library (this shouldn't be too difficult).

Regards

Read only

0 Likes
884

Thanks for the info. We ended up building a internal table of strings (XML) because we needed other info to be associated with the XMLs so it suited our needs.