Application Development 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: 

Pretty printing to a xml file created by abap code.

Jimmy21
Participant
0 Kudos

Hi guys.

I created a XML file into the FB03 Tcode using an internal table type SOLI with XML content, I used the next FM:

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  EXPORTING
    buffer                = my_text64
  tables
    binary_tab            = it_content.

Convert my binary content:

CALL FUNCTION 'SO_CONVERT_CONTENTS_BIN'
    EXPORTING
      it_contents_bin = it_content
    IMPORTING
      et_contents_bin = it_content.

Get folder:

CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
    EXPORTING
      region                = 'B'                 
    IMPORTING
      folder_id             = wa_fol_id
    EXCEPTIONS
      communication_failure = 1
      owner_not_exist       = 2
      system_failure        = 3
      x_error               = 4
      OTHERS                = 5.

Insert the object:

CALL FUNCTION 'SO_OBJECT_INSERT'
      EXPORTING
        folder_id                  = wa_fol_id
        object_type                = 'EXT'
        object_hd_change           = wa_obj_data
      IMPORTING
        object_id                  = wa_obj_id
      TABLES
        objhead                    = ltd_objhead
        objcont                    = it_content

And finally attached to BO (FB03)

CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT'
     EXPORTING
        obj_rolea      = wa_target_bo
        obj_roleb      = wa_note
        relationtype   = 'ATTA'

When I open my XML file don't have format like a XML, how I can to put pretty printer like this, without iXML?

<?xml version="1.0"?>
<Company>
  <CompanyName>SAP</CompanyName>
  <Employee Type="FT">
     <EmployeeName>James</EmployeeName>
     <EmployeeNumber>007</EmployeeNumber>
  </Employee>
</Company>

And my XML file display characters like this:

1 REPLY 1

kiran_k8
Active Contributor
0 Kudos

Jimmy,

Check the below mentioned blog by Ralf and see if you can get any lead...

https://blogs.sap.com/2017/01/31/pretty-printing-json-with-call-transformation/

K.Kiran.