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

Sending internal table data to Application server using XML format

former_member308418
Participant
4,364

Dear All,

Good day.

I am trying to send data from my internal table to the application server in XML format. I have used CALL TRANSFORMATION for this purpose. My report is generating XML data but when I am trying to put that XML file in XML Validator, I am getting errors like data is broken and going to another line. So, users actually cannot use that data. Please tell me a way to solve this from my end.

Here is my piece of code for the conversion.

DATA : itab TYPE swbhtmltable,

lv_xml_result TYPE string,

lv_file TYPE string.

CALL FUNCTION 'SWA_STRING_TO_TABLE'
EXPORTING
character_string = lv_xml_result
IMPORTING
character_table = itab.

OPEN DATASET lv_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT itab INTO DATA(wa).
TRANSFER wa-linedata TO lv_file.
ENDLOOP.

CLOSE DATASET lv_file.

1 ACCEPTED SOLUTION
Read only

Gourab_Dey
Product and Topic Expert
Product and Topic Expert
3,982

Hi Ferdaus,

The issue basically due to the line break. So, we will not use the function module "SWA_STRING_TO_TABLE", rather will transfer the XML string, which will ensure there will not be any line split.

DATA : itab TYPE swbhtmltable,
lv_xml_result TYPE string,
lv_file TYPE string.
"Start of comment by Gourab
*CALL FUNCTION 'SWA_STRING_TO_TABLE'
*EXPORTING
*character_string = lv_xml_result
*IMPORTING
*character_table = itab.
"End of comment by Gourab
OPEN DATASET lv_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
"Start of comment by Gourab
*LOOP AT itab INTO DATA(wa).
*TRANSFER wa-linedata TO lv_file.
*ENDLOOP.
"End of comment by Gourab
"Start of addition by Gourab
TRANSFER lv_xml_result TO lv_file.
"End of addition by Gourab

CLOSE DATASET lv_file.

Alternately, the third party application which is reading the file can also remove the new line character before validation.

Thanks,

Gourab

10 REPLIES 10
Read only

Gourab_Dey
Product and Topic Expert
Product and Topic Expert
3,982

Hi Ferdaus,

Did you try downloading the data to your local system to make sure the transformation is correct? Also what is the length of the internal table line?

Thanks,

Gourab

Read only

0 Likes
3,982

Hi Gourab,

Thanks for your reply. Internal table line has a length of char255. Did you mean to convert from my transported xml file to internal table again ?

Read only

former_member308418
Participant
0 Likes
3,982

Dear Sandra Rossi,

Thanks for the prompt reply. The error says as below. Also, I am attaching my file here. Please check.text.txt

Read only

Gourab_Dey
Product and Topic Expert
Product and Topic Expert
3,982

The error you are getting is due to new line character. There are couple of line break.

Read only

Gourab_Dey
Product and Topic Expert
Product and Topic Expert
0 Likes
3,982

See the attached file, I have removed the line break and tested with XML validator, it passed the validation.

xmltxt.txt
Read only

Gourab_Dey
Product and Topic Expert
Product and Topic Expert
3,982
Can you please do one thing. Dont split the string into table. Write the string directly to AL11 and see how it's working.Also, how you are seeing the generated file? Are you downloading from AL11. If so, dont use tcode "CG3Y". Becuase CG3Y has length constrain of 255 i guess. So, if you wish to download the data from AL11, create a new report program and read the dataset and download to local file.Let us know if this works.Thanks,Gourab
Read only

0 Likes
3,982

Dear Gourab,

I am not splitting the string into table. But the structure SWBHTMLINE has data type of 255 char length. Is there any other FM to do the same? Another thing is that, I am working with third party . I dont know how they are fatching data from server. But from their end they complained of the line breaking error. I can create a new report program for my clarity but it will be of no use for the other party software.

Read only

Sandra_Rossi
Active Contributor
3,982

I see in your file that you have copied the file from the output of AL11. You must not do that (because of line breaks as explained by Gourab). You must create a program to download the file from the application server to user's laptop or anywhere else.

Read only

Gourab_Dey
Product and Topic Expert
Product and Topic Expert
3,983

Hi Ferdaus,

The issue basically due to the line break. So, we will not use the function module "SWA_STRING_TO_TABLE", rather will transfer the XML string, which will ensure there will not be any line split.

DATA : itab TYPE swbhtmltable,
lv_xml_result TYPE string,
lv_file TYPE string.
"Start of comment by Gourab
*CALL FUNCTION 'SWA_STRING_TO_TABLE'
*EXPORTING
*character_string = lv_xml_result
*IMPORTING
*character_table = itab.
"End of comment by Gourab
OPEN DATASET lv_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
"Start of comment by Gourab
*LOOP AT itab INTO DATA(wa).
*TRANSFER wa-linedata TO lv_file.
*ENDLOOP.
"End of comment by Gourab
"Start of addition by Gourab
TRANSFER lv_xml_result TO lv_file.
"End of addition by Gourab

CLOSE DATASET lv_file.

Alternately, the third party application which is reading the file can also remove the new line character before validation.

Thanks,

Gourab

Read only

3,982

Thanks Gourab. I have sent data as per this idea and found no error.

Best regards,

Ferdaus.