‎2021 Jun 29 4:20 PM
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.
‎2021 Jun 30 6:11 AM
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
‎2021 Jun 29 4:32 PM
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
‎2021 Jun 29 5:25 PM
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 ?
‎2021 Jun 29 5:21 PM
Dear Sandra Rossi,
Thanks for the prompt reply. The error says as below. Also, I am attaching my file here. Please check.text.txt
‎2021 Jun 29 5:30 PM
The error you are getting is due to new line character. There are couple of line break.
‎2021 Jun 29 5:33 PM
See the attached file, I have removed the line break and tested with XML validator, it passed the validation.
xmltxt.txt‎2021 Jun 29 5:38 PM
‎2021 Jun 30 4:41 AM
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.
‎2021 Jun 29 6:37 PM
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.
‎2021 Jun 30 6:11 AM
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
‎2021 Jun 30 10:16 AM
Thanks Gourab. I have sent data as per this idea and found no error.
Best regards,
Ferdaus.