‎2009 Oct 22 3:55 PM
Hellow ABAPers,
I wish to download the file to application server in binary mode. When I tried to do it, it is converting into # symbols like below:
_________________________________
#<#?#x#m#l# #v#e#r#s#i#o#n#=#"#1#.#0#"# #e#n#c#o#d#i#n#g#=#"#U#T#F#-#8#"#?#># # # # # # # # # # # # # # # # # # # # # # #<#F#i#n#a#n#c#e#-#R#e#q#
____________________________________
Piece of code for the same is :
OPEN DATASET LV_TBFILE FOR OUTPUT IN BINARY MODE.
LOOP AT PT_XML INTO WA_XML.
TRANSFER WA_XML-LINE TO LV_TBFILE.
ENDLOOP.
CLOSE DATASET LV_TBFILE.
Is it possible to see the output in proper format in binary mode (without ###symbols)?
Please help.
Regards
Ramesh.
‎2009 Oct 22 5:24 PM
Hi,
Try this,
loop at pt_xml.
replace all occurences of CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB in pt_xml-line with space.
modify pt_xml.
endloop.
OPEN DATASET LV_TBFILE FOR OUTPUT IN BINARY MODE.
LOOP AT PT_XML INTO WA_XML.
TRANSFER WA_XML-LINE TO LV_TBFILE.
ENDLOOP.
CLOSE DATASET LV_TBFILE.
Vikranth
‎2009 Oct 23 8:16 AM
Hi Vikranth,
I have used your code. But still it is not coming.
Am I doing any mistake?
Regards
Ramesh.
‎2009 Oct 22 6:54 PM
Hi Ramesh,
Which application do you use to view the file? E.g. if you view the files via AL11 SAP will replace any control characters with the "#" sign. So if you haven't looked at the file in a hex editor yet, I'd download it and do that. (The output looks almost like some encoding issue, because the XML seems to claim UTF-8, which should be one byte per character for ASCII symbols, not two bytes as it seems in your output...)
Also, what's the definition of your table PT_XML?
Regards, harald
‎2009 Oct 23 8:06 AM
Hi harald,
Thanks for your replay.
My internal table declaration is like below:
-
TYPES: BEGIN OF TY_XML,
LINE TYPE CHAR120,
END OF TY_XML.
-
and also, Yes... I am actually passing the xml data to this internal table for downloading. If I download it in text mode, the data would be like as below in AL11(showing only few lines of data)....
-
Directory: /usr/sap/FED/iface/coop/outbox
Name: CAPUTPFIN2009-08-20005.txt
<?xml version="1.0" encoding="UTF-8"?>
<Finance-Request xmlns:mbc="http://cfs.coop/Messaging/Batch/Common"
xmlns:mtg="http://www.origostandards.com/schema/mtg/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:cfs.coop:Finance Finance-Request-v1-1.xsd" xmlns="urn:cfs.coop:Finance" >
<Header>
<mbc:DocumentId>CAPUTPFIN2009-08-20005.txt</mbc:DocumentId>
<mbc:CreationDate>2009-09-05T16:22:31.000</mbc:CreationDate>
<mbc:Description>Finance File</mbc:Description>
<mbc:NumberOfRecords>000005</mbc:NumberOfRecords>
<mtg:initiator_id>UT</mtg:initiator_id>
<mbc:SourceSystem>UTP</mbc:SourceSystem>
<mbc:DateRange>
<mbc:FromDate>2009-07-24T00:00:00.000</mbc:FromDate>
<mbc:ToDate>2009-08-20T00:00:00.000</mbc:ToDate>
</mbc:DateRange>
</Header>
<Details>
<DetailRecord>
<TransactionNumber>000001</TransactionNumber>
<BusinessClass>UT</BusinessClass>
<ProductCode>3211</ProductCode>
<TransactionDate>2009-08-20</TransactionDate>
-
Could you please advice, how can we forward to resolve this issue now?
Thanks in advance.
Regards
Ramesh.
‎2009 Oct 23 8:09 AM
Why do you download that in binary mode? In Binary mode no character translation is taken place due to different codepages.
‎2009 Oct 23 8:15 AM
Hi,
It is the client's requirement. After downloading the file to application server, third party system will pick this file (their requirement is... the file should be in binary format).
Regards
Ramesh.
‎2009 Oct 23 8:33 AM
Yes, and the result using binary format is tha what you can see: no character translation between codepages.
And to be honest: the cleint cant see how it is written. At least all files are binary files, the difference betweend binary and text files are just made by humans, nithing else.
So if the file is ok written in tect mode write it in text mode and dont care about the client.
‎2009 Oct 28 3:41 AM
Hi Ramesh
Looking at your output file there really is no reason to write this as a binary file. In general one would expect that an XML file is actually a text file (after all, XML files are supposed to be human readable). So I agree with Rainer, don't use the BINARY file feature, instead write your file as a text file:
OPEN DATASET lv_tbfile IN TEXT MODE FOR OUTPUT ENCODING UTF-8.Note that this doest not mean that you ignore your client's requirements. Basically your client expects a file in a certain format. So I'd create the XML file using the text mode feature and then provide this to your client. If they can parse the file and it looks good to them, it's correct (regardless if they label it binary or not). Remember, often people use different terminologies and what they label binary might not be what we as developers would call a binary file...
Best wishes, harald