cancel
Showing results for 
Search instead for 
Did you mean: 

Binary file generation

Former Member
0 Kudos

Hi All,

Kindly help me to get the solution for the below requirement:

1> I have to do conversions such as Ascii to Hexadecimal, Little Enidan, Binary Coded Decimal at field level ie at mapping level.

2> Then generate a file of binary type extension as .sad, which should be unreadable.

For example if I open the binary file the below data will display.

"T      {  “3
   
“3
Ð’@     4Ÿ@ l
"T      ™  “3   
“3  p
"T   [1]   w “3 ( 

I completed the first requirement using UDFs. But unable to generate binary file. Please guide.

Regards,

Nutan

Accepted Solutions (0)

Answers (1)

Answers (1)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Nutan,

               Do you have file format information of .sad file? Ask the business for the file format of the binary file. All binary file has a fixed format. First thing is to find the format and then use a java mapping to create the output format in SAP PI. Do not use receiver FCC in communiction channel. From your post it seems the input to the scenario is also a binary file content. Anyways you can check one of my articles on binary file in this thread http://scn.sap.com/thread/1983926. Please check response to the query and the link to the article.

Regards

Anupam  

Former Member
0 Kudos

Hi Anupam,

Thanks for your valuable reply. Before posting this query here, I went through your blog. You showed how to read a binary file of .MDEF through java mapping. My requirement is to generate a binary file as output file.

This scenario is Proxy to File. As you asked for format, whether it means output structure. If so, below is the output structure:

·    The file to be created consists of the following:

1 header record

1 header extension record

1 header sub record

n data records

in binary format without any control line-feeds.

Regards,

Nutan

anupam_ghosh2
Active Contributor
0 Kudos

Hi Nutan,

                The process of generating a binary file such as MDEF is exactly reverse of the process of reading the same. The information needs to be converted into byte from string then writtten to the binary file. The header record or extension record, each of these has a apecific size in bytes. They have to be written down to the file in a byte array of same size. In case you have fully understood the code I wrote then I feel you can do this one too. In the code I had to dig deep into each bit of the file to understand its content , in your case this might not be required. In case business has provided you detailed structural information about the file please go through the document and try to create a small sample file.

Regards

Anupam

Former Member
0 Kudos

Hi Anupam,

Thank you, I will look into it and come back if find any issues.

Regards,

Nutan

Former Member
0 Kudos

Hi Anupam,

I tried to parse a small xml file and did all the necessary conversions. But as per the suggestion convert the data from string to bytes and then write in a file, is not happening. While writing in a file if I use FileOutputstream then it gives the same text data. I open the file in notepad but it's in readable format.

Regards,

Nutan

anupam_ghosh2
Active Contributor
0 Kudos

Hi Nutan,

              Need to check file format information before I can comment further on this issue.

The flow should be like this

string---->binary---->restructure binary according to file format----> write output.

If you have link or ducuments regarding this file please forward me the same. Need to study and then I can be in position to comment on the issue.

Regards

Anupam

Former Member
0 Kudos

Hi Anupam,

Thanks for the help. I have sent the details in your personal mail id, as mentioned in your profile. Kindly check that and let me know your inputs.

Regards,

Nutan

Former Member
0 Kudos

Hi All,

I am able to write a binary file in eclipse, but donot know how to replicate that in java mapping. I am using sax parser to read the XML payload and then in character method I am doing all the specific conversions as mentioned above. Then writing in DataOutputStream as Short,Int,Long as per the field byte size. Kindly let me know how to write the file through java mapping, as we cannot use public static void main method there, so I am confused how to use DataOutputstream and create a binary file. Please suggest.

Regards,

Nutan

anupam_ghosh2
Active Contributor
0 Kudos

Hi Nutan,

                Could you post/send a small sample input XML to your code?

Went through SDA format. Java mapping needs an input XML.

Regards

Anupam