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

ALV to XML format

Former Member
0 Likes
841

Hi all,

My requirement is to download the ALV output into XML based on the variant.

For example: If my ALV displays 3 fields in the output,only those field's information should be displayed in the downloaded XML file.

Your suggestions would be really valuable.

Thanks..

Hi all,

My requirement is to download the ALV output into XML based on the variant.

For example: If my ALV displays 3 fields in the output,only those field's information should be displayed in the downloaded XML file.

Your suggestions would be really valuable.

Thanks..

3 REPLIES 3
Read only

alex_cook
Active Participant
0 Likes
746

Howdy,

To determine what changes to the variant have been made, you need to get the frontend fieldcatalog of the ALV so that you know which fields are hidden etc (method CL_GUI_ALV_GRID->GET_FRONTEND_FIELDCATALOG). You then also have to check which entries have been filtered out (method CL_GUI_ALV_GRID->GET_FILTERED_ENTRIES).

Once you have the field catalog you will have to do some dynamic programming to build your XML, particularly to skip over the columns that are hidden.

Hope this helps to get you started.

Cheers

Alex

Read only

Former Member
0 Likes
746

What kind of dynamic programming? Could you please give me an example?

Thanks

Read only

0 Likes
746

For example say your ALV output table is gt_output, and the frontend field catalog is gt_fcat:



FIELD-SYMBOLS: <field> type any.

loop at gt_output assigning <output>.

  loop at gt_fcat assigning <fcat> where tech eq abap_false and no_out eq abap_false. "Ignore hidden entries
      assign component <fcat>-fieldname of structure <output> to <field>.
      "Now write the field to your XML structure.
  endloop.
endloop.

Alternatively you can build the output into an internal table with a key-value pair eg FIELDNAME and VALUE and then use a Simple transformation to convert to XML - personally this might be a better way to go if you know transformations.

Cheers

Alex

Edited by: Alex Cook on Jan 4, 2011 4:51 PM

Tidied up code - XML write isn't working