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

write XML file in application server

Former Member
0 Likes
4,054

Experts,

I'm using a transformation to generate a xml file:

CALL TRANSFORMATION zdatafechomes

SOURCE ficheiroexecucao = gt_source[]

RESULT XML xml_result.

It's working fine. But i'm having problems in putting the "xml_result" (it's a type xtring) into the application server.

Anyone knows how to do it ? Transaction cg3z it's different because the file comes from C:

Best Regards,

Mário.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,647

Hello Mario

I do not see why the following logic should not work:


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_XML_XSTRING_APPLSERVER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZUS_SDN_XML_XSTRING_APPLSERVER.

DATA:
  gd_dsn            type string,
  gd_xstring        type xstring,
  gt_kna1           type STANDARD TABLE OF kna1.

start-of-selection.

  select * from kna1 into table gt_kna1 up to 10 rows.

  BREAK-POINT.

  call TRANSFORMATION id
    source itab = gt_kna1
    result xml = gd_xstring.

    gd_dsn = '/tmp/xml_as_xstring.file'.

    open DATASET gd_dsn for OUTPUT in BINARY MODE.
    check ( syst-subrc = 0 ).

    TRANSFER gd_xstring to gd_dsn.

    CLOSE DATASET gd_dsn.

end-of-SELECTION.

Regards

Uwe

4 REPLIES 4
Read only

former_member723628
Active Participant
0 Likes
1,647

Mário,

Since your result data object "xml_result" is of xstring type you may take this approach

1. Convert this into unicode string using function HR_KR_XSTRING_TO_STRING

2. Convert string into standard table using function HR_EFI_CONVERT_STRING_TO_TABLE.

3. Write contents of this table to application server using OPEN DATASET and TRANSFER statement.

Hope this works.

Regards,

Gajendra

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,648

Hello Mario

I do not see why the following logic should not work:


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_XML_XSTRING_APPLSERVER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZUS_SDN_XML_XSTRING_APPLSERVER.

DATA:
  gd_dsn            type string,
  gd_xstring        type xstring,
  gt_kna1           type STANDARD TABLE OF kna1.

start-of-selection.

  select * from kna1 into table gt_kna1 up to 10 rows.

  BREAK-POINT.

  call TRANSFORMATION id
    source itab = gt_kna1
    result xml = gd_xstring.

    gd_dsn = '/tmp/xml_as_xstring.file'.

    open DATASET gd_dsn for OUTPUT in BINARY MODE.
    check ( syst-subrc = 0 ).

    TRANSFER gd_xstring to gd_dsn.

    CLOSE DATASET gd_dsn.

end-of-SELECTION.

Regards

Uwe

Read only

0 Likes
1,647

Uwe,

There is no reason why your approach would not work. I agree that yours is a better approach provided opening the file in Binary Mode suffices Mario's requirements.

The solution that I proposed would work for unicode program when file needs to be opened in text mode.

Regards,

Gajendra

Read only

Former Member
0 Likes
1,647

Hello Uwe and Gajendra,

The problem is solved, the sample code povided by Uwe it's working fine. I gave points to both of u.

Now if i want to read a xml file from application server, and populate a internal table using the transformation , how can it be done ? Do you have a sample code?

Ex.

CALL TRANSFORMATION zdatafechomes

SOURCE XML xml_result (this info comes from application server)

RESULT ficheiroexecucao = gt_source.

Best regards and thanks for your help.

MR.