cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate a file containing substructure of inboud interface

gopalkrishna_baliga
Participant
0 Kudos

Hi Experts,

My outbound interface structure is like below:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:File_Input xmlns:ns0="http:/training/POC">

<NUM1>1</NUM1>

<NUM2>2</NUM2>

</ns0:File_Input>

My inbound interface is like below:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:File_Output xmlns:ns0="http:/training/POC">

<Filename></Filename>

<Output>

<TOTAL>3</TOTAL>

</Output>

</ns0:File_Output>

This is FILE to FILE scenario.

The input (sender or outbound) file is XML. Output file is also XML but I want it to be:

<ns0:File_Output xmlns:ns0="http:/training/POC">

<Output>

<TOTAL>3</TOTAL>

</Output>

</ns0:File_Output>

I don't want the node <Filename> in the output XML file even though the inbound interface structure contains the node <Filename>. The output file name is dynamic and hence I am using the node <Filename>. I am populating this node in message mapping.

I tried File content conversion but it is not generating the file. I gave the following conversion values.

What am I doing wrong?

File_Output.fieldSeparator = nl

Output.fieldSeparator = nl

TOTAL.fieldSeparator = nl

Please help!

Thanks

Gopal

Accepted Solutions (0)

Answers (2)

Answers (2)

Shabarish_Nair
Active Contributor
0 Kudos
The output file name is dynamic and hence I am using the node <Filename>.

instead of this use dynamic configuration to avoid such issues - /people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name

Former Member
0 Kudos

I think that the error is in paramaters value:

File_Output.fieldSeparator = 'nl'

Output.fieldSeparator = 'nl'

TOTAL.fieldSeparator = 'nl'

You need to include quotes

gopalkrishna_baliga
Participant
0 Kudos

Hi spantaleoni ,

quotes are not required.

Actually file is getting generated but it is plain text. I wanted XML file.

The output file getting generated contains only one line:

input_20110523T104117Z.xmlnl3

Here is the " input_20110523T104117Z.xml" is the file name that I am populating dynamically.

The value "3" in the end is the value of node TOTAL.

<?xml version="1.0" encoding="UTF-8"?>

<ns0:File_Output xmlns:ns0="http://training/POC">

<Filename>input_20110523T104117Z.xml</Filename>

<Output><TOTAL>3</TOTAL>

</Output></ns0:File_Output>

I want XML output file as below:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:File_Output xmlns:ns0="http://training/POC">

<Output><TOTAL>3</TOTAL>

</Output></ns0:File_Output>

What am I doing wrong? Can't we use content conversion to get XML file?

Please help!

Thanks

gopal

Edited by: gopalkrishna baliga on May 23, 2011 12:50 PM

Former Member
0 Kudos

Hello Mr,

For quote: NameA.endSeparator

If you enter a character string here, the system adds it to the last column as a closing character. You can also make this specification in addition to NameA.fieldFixedLengths. To include a line break following the closing character, you must explicitly define it by attaching ´nl´ (including the quotation marks) to the string.

The default value is a line break (no explicit separator after the last column; instead the structures are arranged line-by-line).

This is from sap help:

http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm

Former Member
0 Kudos

hi Gopal,

First thing, as Spantaleoni has said, you can not avoid the quotes.

It has been clear in your case itself. That's the reason that you have nl input_20110523T104117Z.xmlnl3 in between your filename "input_20110523T104117Z.xml" and total value "3". Had you put quotes, 3 would have come in the next line itself and there would not be nl explicitly.

As for your actual issue, if it is an xml that you want at the receiver end, why are you using content conversion? As Shabarish has mentioned in his blog, dynamic configuration is always better than variable substition.

You can set the filename dynamically in a udf which is mapped to a mandatory field at the target side.

Write the below code in a udf and map it to a mandatory node at the target end , like "Output" node in your case.

-


DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(u201Chttp://sap.com/xi/XI/System/Fileu201D,u201CFileNameu201D);

String MyFileName = a + "_" + b +".xml";

conf.put(key, myFileName);

return "";

-


Regards,

Ninu

Former Member
0 Kudos

Hi Gopal.

If you need xml file as an output,

No File Content Conversion is required.

Please change the Message protocol from FCC to File in the receiver communication Channel.

Add code, as Ninu said, u are done.

Thankyou

Kiran