cancel
Showing results for 
Search instead for 
Did you mean: 

generated XML naming conventions

Former Member
0 Kudos

HI Xi friends...

i am generating XML in this naming convention..

FileName_20061204-123032-628.xml( using add TimeStamp option)

(filename_yyyyMMdd-HHmmss-mmm.xml)

but my requirement is

FileName_2006-12-04<b>T</b>123032628.xml

(filename_yyyy-MM-dd<b>T</b>HHMMSSmmm</b>)( here date-time in format ISO

mmm= thousandths of seconds )

is this possible to generate the above mentioned naming convention using XI AddTimestamp.

please guide me.

regards

ram

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Bhavesh..

thank you very much for your quick responses..

i tried put the above code you mentioned in inialization of java section...

i am getting....

<b>Compilation of MM_SAP_WMMBXY_To_MES_RawMaterialReceipt successful java.lang.NullPointerException</b>

...

i need your help...

regards

ram

bhavesh_kantilal
Active Contributor
0 Kudos

Ram,

Have not tried this code in the intilization section . My server is down for an upgrade and so cannot try it now either.Instead, push the code into an UDF itself ( Sorry , but am not sure if my code change for initilization section is correct ).

Use the code inside an UDF and call this UDF, during the mapping of some field, The UDF takes the source field as input and returns the same field as output, and inside changes the file name,

<i>SimpleDateFormat simpledatFormat = new SimpleDateFormat("yyyy-MM-dd");

Date date = new Date();

String datewithYear = simpledatFormat.format(date);

SimpleDateFormat simpledatFormat1 = new SimpleDateFormat("HHmmssmmm");

Date date1 = new Date();

String datewithMs = simpledatFormat1.format(date1);

//Get the OldFileName

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System/File”,

“FileName”);

String oldFileName=conf.get(key);

String valueNew = oldFileNamedatewithYeardatewithMs;

//set the new filename

conf.put(key, valueNew);

return inputparameter;</i>

Also ensure that in your sender file adapter, you have selected --> Adapter Specific Attributes --> FileName and you have done the same in the receievr file adapter as well.

Regards,

Bhavesh

Answers (11)

Answers (11)

Former Member
0 Kudos

Hi Bhavesh....

thank you very much....i got it..what i want with your help..

thank you so much..

keep going..

Hi alll

thanks alot..

regards

ram

Former Member
0 Kudos

Hi

What happens when Sender is not File and lets say IDoc.

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

Conf above will be null,how do you change the target file name in this case.

Regards,

Bikram

Former Member
0 Kudos

Hi Bhavesh...

i got chequered flag in SXMB_MONI.

but the file isnt created on FTP server..

and also...the receiver communication channel status is functiong..but no file processed..

in SXMB_MONI..DynamicConfiguration....

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

- <!-- Response

-->

- <SAP:DynamicConfiguration xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">

<b><SAP:Record namespace="http://sap.com/xi/XI/System/File" name="FileName">null2006-12-11T114744047</SAP:Record></b> <SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="CIMTYP" />

</SAP:DynamicConfiguration>

</i>

here null is showing instead of file name given in receiver comminication channel..

guide me..please..

regards

ram

bhavesh_kantilal
Active Contributor
0 Kudos

Ram,

In both your Sender File adapter and receievr , you would need to select the Adapter Specific Identifiers --> FileName .

Have you done this?

Regards,

Bhavesh

Former Member
0 Kudos

Hi Bhavesh...

i am getting error in SXMB_MONI

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

- <!-- Request Message Mapping

-->

- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">

<SAP:Category>Application</SAP:Category>

<SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>

<SAP:P1>com/sap/xi/tf/_MM_wmmbxy_to_filefordate_</SAP:P1>

<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>

<SAP:P3>RuntimeException in Message-Mapping transformatio~</SAP:P3>

<SAP:P4 />

<SAP:AdditionalText />

<SAP:ApplicationFaultMessage namespace="" />

<SAP:Stack>During the application mapping com/sap/xi/tf/_MM_wmmbxy_to_filefordate_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: RuntimeException in Message-Mapping transformatio~</SAP:Stack>

<SAP:Retry>M</SAP:Retry>

</SAP:Error></i>

please guide me....

regards

ram

Former Member
0 Kudos

Hi bhavesh..

please help me..

i put the below code in initialization of java section..

Container container = null ;

SimpleDateFormat simpledatFormat = new SimpleDateFormat("yyyy-MM-dd");

Date date = new Date();

String datewithYear = simpledatFormat.format(date);

SimpleDateFormat simpledatFormat1 = new SimpleDateFormat("HHmmssmmm");

Date date1 = new Date();

String datewithMs = simpledatFormat1.format(date1);

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

DynamicConfigurationKey key = DynamicConfigurationKey.create("http:/""/""sap.com""/""xi""/""XI""/""System""/""File" , "RawMaterial");

String oldFileName=conf.get(key);

String valueNew = oldFileNamedatewithYear"T"+datewithMs;

//set the new filename

conf.put(key, valueNew);

when static test..its giving..

<i>Start of test

<b>Compilation of MM_SAP_WMMBXY_To_MES_RawMaterialReceipt successful java.lang.NullPointerException at</b> com.sap.xi.tf._MM_SAP_WMMBXY_To_MES_RawMaterialReceipt_.preStart(_MM_SAP_WMMBXY_To_MES_RawMaterialReceipt_.java:157) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:346) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:60) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:105) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInternal(ServerMapService.java:431) at com.sap.aii.ibrep.server.mapping.ServerMapService.execute(ServerMapService.java:169) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.execute(MapServiceBean.java:52) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.execute(MapServiceRemoteObjectImpl0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java(Compiled Code)) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java(Inlined Compiled Code)) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java(Compiled Code)) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java(Compiled Code)) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java(Compiled Code)) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java(Compiled Code)) at java.security.AccessController.doPrivileged1(Native Method) at java.security.AccessController.doPrivileged(AccessController.java(Compiled Code)) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java(Compiled Code)) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java(Compiled Code)) java.lang.NullPointerException

15:27:57 End of test</i>

please guide me...

regards

ram

bhavesh_kantilal
Active Contributor
0 Kudos

Ram,

1. You cannot test the code in a static test as the problem occurs in the fact that the file name becomes available during RunTime.

2. Also, noted that you are changing the code DynamicConfigurationKey key = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System/File”,

“FileName”); to DynamicConfigurationKey key = DynamicConfigurationKey.create("http:/""/""sap.com""/""xi""/""XI""/""System""/""File" , "RawMaterial");

Please do not do that.

3. Also, the initlization section does not have access to the Container. So the code will change a bit. Try this code in the intilization section and then let us know,

<i>

SimpleDateFormat simpledatFormat = new SimpleDateFormat("yyyy-MM-dd");

Date date = new Date();

String datewithYear = simpledatFormat.format(date);

SimpleDateFormat simpledatFormat1 = new SimpleDateFormat("HHmmssmmm");

Date date1 = new Date();

String datewithMs = simpledatFormat1.format(date1);

DynamicConfiguration conf = (DynamicConfiguration) getParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System/File”,

“FileName”);

String oldFileName=conf.get(key);

String valueNew = oldFileNamedatewithYear"T"+datewithMs;

//set the new filename

conf.put(key, valueNew);</i>

Regards,

Bhavesh

Former Member
0 Kudos

Hi Bhavesh...

Thank you so much for your responses..

i created user define fucntion like this and i assined to one of the target field.(filename).

public void dyFileName(ResultList result,Container container){

SimpleDateFormat simpledatFormat = new SimpleDateFormat("yyyy-MM-dd");

Date date = new Date();

String datewithYear = simpledatFormat.format(date);

SimpleDateFormat simpledatFormat1 = new SimpleDateFormat("HHmmssmmm");

Date date1 = new Date();

String datewithMs = simpledatFormat1.format(date1);

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

DynamicConfigurationKey key = DynamicConfigurationKey.create("http:/""/""sap.com""/""xi""/""XI""/""System""/""File" , "RawMat_");

String oldFileName=conf.get(key);

String valueNew = oldFileNamedatewithYear"T"+datewithMs;

//set the new filename

conf.put(key, valueNew);

}

in static test...i am getting

<i>RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /ns0:MT_Material/fileName. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._MM_wmmbxy_to_filefordate_ method dyFileName$[]</i>

in ID,

file receiver adapter..

i gven filename scheme : rammat.xml

adapter-specific attributes..

i selected Use Adapter-specific attributes

Fail if adapter-specific attribute id missing

File Name

in sxmb_moni i amgetting error like this...

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

- <!-- Request Message Mapping

-->

- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">

<SAP:Category>Application</SAP:Category>

<SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>

<SAP:P1>com/sap/xi/tf/_MM_wmmbxy_to_filefordate_</SAP:P1>

<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>

<SAP:P3>RuntimeException in Message-Mapping transformatio~</SAP:P3>

<SAP:P4 />

<SAP:AdditionalText />

<SAP:ApplicationFaultMessage namespace="" />

<SAP:Stack>During the application mapping com/sap/xi/tf/_MM_wmmbxy_to_filefordate_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: RuntimeException in Message-Mapping transformatio~</SAP:Stack>

<SAP:Retry>M</SAP:Retry>

</SAP:Error></i>

please help me..

bhavesh_kantilal
Active Contributor
0 Kudos

Ram,

You need not assign the UDF's output to any target field.

Instead, use the code in the Java Section of your Message Mapping. please refer to this blog for the java section ( write the code in the initlization section ).

Also, Make sure that in the sender file adapter --> adapter specific attributes --> the filename is selected just as in the receiver file adapter.

Regards,

Bhavesh

Former Member
0 Kudos

hi friends..

please help me ...in variable substitution..

thanks and regards

ram

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

You would need to use the CUT parameter.Take a look at this blog,

/people/sravya.talanki2/blog/2005/08/11/solution-to-the-problem-encountered-using-variable-substitution-with-xi-sp12

I would suggest that instead of using Variable Name substitution, use the code I have listed above / Adapter Specific Identifiers as it would make things a lot simpler.

Regards,

Bhavesh

Former Member
0 Kudos

Hi Friends..

Thank you very much for your quick responses...

i am using variable substitution method...

my extermal message ...is

RawMaterial (root element)

---values 1..unbounded

-


materialNumber <i>String</i>

-


Unit <i>String</i>

-


DocumentDate <i>xsd.dateTime</i>

-


MOvement Type <i>xsd.Integer</i>

-


StorageLocation <i>String</i>

-


Plant <i> String</i>

-


SupplierName <i>String</i>

-


DeleveryNote <i>String</i>

-


BillOfLadding <i>String</i>

-


Quantity <i>xsd.decimal</i>

so how to declare varible name and corresponded reference in File adapter.

please tell me elaborately...

and also..

but i dont want the dynamic XML file name in generated XML file.

i wrote..java functions like this

public void getDate(ResultList result,Container container)

{

SimpleDateFormat simpledatFormat = new SimpleDateFormat("yyyy-MM-dd");

Date date = new Date();

String datewithYear = simpledatFormat.format(date);

result.addValue(datewithYear);

result.addContextChange();

}

public void getTime(ResultList result,Container container){

SimpleDateFormat simpledatFormat = new SimpleDateFormat("HHmmssmmm");

Date date1 = new Date();

String datewithMs = simpledatFormat.format(date1);

result.addValue(datewithMs);

result.addContextChange();

}

and in MessageMapping if i tak <b>RawMat_</b> as constant

and concatenatd between getDate() and getTime() using <b>T</b> and again concatenatd RawMat_ to above result..and now its like <b>RawMat_2006-1209T113911039</b>

but if i map the above result to one of fields of target message it appears in output XML file.but i dont want the dynamic filename in XML file..so how mapping should be??

please help me friends....

thanks in advance....

regards

ram

bhavesh_kantilal
Active Contributor
0 Kudos

Ram,

This code will create the filename as you want it,

<i>//Get the Date and Time--> Your own source code

SimpleDateFormat simpledatFormat = new SimpleDateFormat("yyyy-MM-dd");

Date date = new Date();

String datewithYear = simpledatFormat.format(date);

SimpleDateFormat simpledatFormat1 = new SimpleDateFormat("HHmmssmmm");

Date date1 = new Date();

String datewithMs = simpledatFormat1.format(date1);

//Get the OldFileName

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System/File”,

“FileName”);

<b>String oldFileName=conf.get(key);</b>

<b>String valueNew = oldFileNamedatewithYeardatewithMs;</b>

//set the new filename

conf.put(key, valueNew);</i>

Regards,

Bhavesh

Former Member
0 Kudos

Hi Ram,

See these..

/people/sriram.vasudevan3/blog/2005/11/21/effective-xsl-for-multimapping-getting-source-filenames-in-legacy-legacy-scenarios

/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14

cheers,

Prashanth

Former Member
0 Kudos

Hi,

1. Use the Varible Substituion Option in Receiver Fild adapter (as Bhavesh explained)

2. once you get the file name the + using Date Trans function you will get the date format as you want (here give your input date format in Source and give the target date format what do you want) + use the Constant (T) + using the Simple Java Function to get the time and concatenate these are all send it target variable , that variable you can pass the in File adapter.

Regards,

Venu.

Former Member
0 Kudos

HI Bavesh..

thank you very much for your quick response..

i am not understanding properly...

please explain me step by step..

if possible ..tell me the code for it..

please guide me..

thank you

regards

ram

bhavesh_kantilal
Active Contributor
0 Kudos

Ram,

<u><b>Option 1</b></u>

In your receiver file adapter, select the option --> Adapter Specific Attrbutes --> File Name and in the field against the filename give some dummy value.

Now, in your message mapping use the following code to change the filename

<i>DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System/File”,

“FileName”);

//Write the logic to get the Timstamp in the format you want and then append it to the fileName

String valueNew = "NEWFILENAME WITH THE TIMESTAMP"

conf.put(key, valueNew);</i>

The value you give for valueNew is the FileName with which the file will be created.

<u><b>Option 2</b></u>

The other option would be to use Variable Name subsititution. Get the filename inside of the fields and then use the variable name subsititution concept explain in this link,

http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm

Regards,

Bhavesh

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

No this would not be possible using the standard File adapter's Add Timestamp.

Instead, you can use variable name substituiion or adapter specific identifiers --> File Name with a simple code to set the file name with the time stamp.

Regards,

Bhavesh