on 05-10-2007 10:32 AM
Hi experts,
I have a few questions regarding the variable substitution in the File-Adapter. I want to have it for my filename.
For the variable substitution I can only take elements from the target structure, is that right? I know that I can take attributes from the header information like the interface_name etc. <b>But can I take attributes from the target structure?</b> Is it possible?
With best regards
Christopher
HI,
Please see the below links
/people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i - Dynamic File Name Part 1
/people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii - Dynamic File Name Part 2
Dynamic configuration payload -
https://media.sdn.sap.com/javadocs/NW04/SPS15/pi/com/sap/aii/mapping/api/DynamicConfiguration.html
Regards
Chilla
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
sorry, but this does't help me. In this Weblogs is only explained, how to take values from the target structure with variable sustitution to create the filename. But for my case I have to take values from the source structure (I don't have these values in my target structure) to create my filename.
I hope you understand my problem.
Thanks
Christopher
Christopher,
Attributes cannot be be used in varibale Name subsituttion.
Wrtie a UDF as follows,
1. The input to this UDF will be the source field in which the values occurs,
Let us say this input is A.
the code will be,
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create(
http://sap.com/xi/XI/System/File,
FileName);
conf.put(key, A);
return A;
2. Now when mapping this source field to the target call this UDF. The inout and output of the UDF will be the same.
3. In the receievr file adapter select optioon, Adapter Specific Attributes --> FileName . Give some dummyname for the filename in the filename field.
In the runtime this UDF will set the file name as needed.
Regards
Bhavesh
Thanks for this, but there is the following runtime exception:
14:38:41 Teststart
Kompilierung von PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF war erfolgreich. Runtime exception during processing target field mapping /xdoc/Invoice/purno. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF_ method Filename_purno$[5075, com.sap.aii.mappingtool.tf3.rt.Context@10cfad9] com.sap.aii.mappingtool.tf3.MessageMappingException: Runtime exception during processing target field mapping /xdoc/Invoice/purno. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF_ method Filename_purno$[5075, com.sap.aii.mappingtool.tf3.rt.Context@10cfad9] at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:347) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:309) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:309) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:398) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:142) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:102) 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_0.execute(MapServiceRemoteObjectImpl0_0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0p4_Skel.dispatch(MapServiceRemoteObjectImpl0_0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Root Cause: com.sap.aii.utilxi.misc.api.BaseRuntimeException: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF_ method Filename_purno$[5075, com.sap.aii.mappingtool.tf3.rt.Context@10cfad9] at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:56) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:291) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:309) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:309) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:398) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:142) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:102) 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_0.execute(MapServiceRemoteObjectImpl0_0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0p4_Skel.dispatch(MapServiceRemoteObjectImpl0_0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Root Cause: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:47) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:291) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:309) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:309) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:398) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:142) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:102) 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_0.execute(MapServiceRemoteObjectImpl0_0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0p4_Skel.dispatch(MapServiceRemoteObjectImpl0_0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Caused by: java.lang.NullPointerException at com.sap.xi.tf._PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF_.Filename_purno$(_PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF_.java:227) ... 25 more RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /xdoc/Invoice/purno. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF_ method Filename_purno$[5075, com.sap.aii.mappingtool.tf3.rt.Context@10cfad9]
14:38:42 Testende
<u>The Code of my UDF:</u> --- "purno" is the input string
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
conf.put(key, purno);
return purno;
Can somebody explain me, what the DynamicConfigurationKey is? And for which task the following code is responsible for?
conf.put(key, purno);
With kind regards
Christopher
The code looks good to me.
1. Where are you getting this error?
Did you try to test the message mapping? Do not do this. Try to test the interface mapping instead of the message mapping.
Or, did you get the error in the RunTime?
2. Is the mapping activated with the UDF being used as expected?
3. In the receiver file adapter have you selected Adapter Specific Attributes --> FileName?
From SP 14, there are a few parameters that can be read and put into your XI Message's SOAP Header.One among these is the FileName.
In this code you are putting the filename in the SOAP Header and then in the receiver fie adapter by selecting the option mentioned above, you are making the file adapter read the SOAP header and take the filename from the SOAP header.
Regards
Bhavesh
Christopher
Are you trying to create an output file name called <purno>?
If so, I have successfully completed this exercise from the target mapping.
in file name of the file adapter Add the %var1% for the variable.
I will provide my example:
%var1%_epiw_records.dat
Select the check box: Variable Substitution (Target Directory/Filename Scheme)
<i>name:</i> var1 ; <i>Reference:</i>payload:EPIWEmployeeFile,1,Personal_Area,1
The schema is EPIWEmployeeFile, the Field is Personal_Area.
This then writes a file: ES01_epiw_records.dat
This is done without any Java coding as described in this post.
I have mapped this field outside of the main body (header)of the schema and these are not included in the file once converted to Text (using conversion) If that makes sense.
Hi Bhavesh,
thanks for this answer.
>1. Where are you getting this error?
>Did you try to test the message mapping? Do not do this. Try to test the >interface mapping instead of the message mapping.
Yes, I got this error by testing the message mapping. Now I tested the interface mapping. There was no error.
>3. In the receiver file adapter have you selected Adapter Specific Attributes --> >FileName?
I activated it in the communication channel. Where I can activate it in the receiver file adapter? or do you mean the receiver communication channel?
At the moment I cannot test the scenario, but what I have to write in the variable substitution? This?:
payload:FileName
Best regards
Christopher
Hi,
Half of the job is done.
Now go to your receiver file adapter,
<b>1. Select the option , Adapter Specific Message ATtributes --> FileName.
2. In the receiver file name give any dummy value.</b>
<i>You need not use %var% and need not select variable substitution etc as , payload: etc , just give some dummy value for filename/i]
Now run the interface and check what the file name is
Regards
Bhavesh
Hi,
If you target is
<root>
<element1> xyz</element1>
<element2 attribute=123>sss</element2>
</root>
In thise case, the Element 1 and Element 2's values can be usedi n variable name subsitutition. But the Attributes cannot be used.
Better option is to use the Adapter Specific Message Attributes with the java Code in this link in the message mapping in an UDF.
http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm
Regards
Bhavesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dont think it is possible. But why do want that? You can go for Dynamic COnfiguration and set the file name from inside the mapping. Since you are handling it with in mapping, you can use all Java functions to manipulate your file Name.
Regards,
Jai Shankar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jai, thanks for your answer,
I have no experience in such things. How can I create a filename inside the mapping? I will give you a example of a source and a target structure, ok?
<u>Source structure:</u>
<IDOC>
<E1EDK02>
<QUALF> 001 </QUALF>
<BELNR> 1200 </BELNR>
<DATUM> 20070103 </DATUM>
</E1EDK02>
<E1EDK02>
<QUALF> 002 </QUALF>
<BELNR> 5193 </BELNR>
<DATUM> 20070106 </DATUM>
</E1EDK02>
<E1EDK02>
<QUALF> 009 </QUALF>
<BELNR> 4200112627 </BELNR>
<DATUM> 20070109 </DATUM>
</E1EDK02>
</IDOC>
<u>target structure</u>
<xdoc>
<Invoice purno="1200">
<HeaderInfo>
<invno> 4200112627 </invno>
</HeaderInfo>
</Invoice>
</xdoc>
The attribute "purno" is filled with the value "BELNR" from the source-element "E1EDK02" where QUALF=001. The target-element is filled with the value "BELNR" from the source-element "E1EDK02" where QUALF=009.
My Mapping is working fine, but now I have to create my filename like described in the following:
Filename: INV_@purno_Nr_Date.XML
"@purno" ist the attribute "purno" from my target structure. but this value I cannot take with the variable substitution.
"Nr" should be the value "BELNR" from the source-element "E1EDK02" with QUALF=002.
"Date" should be the value "DATUM" from the source-element "E1EDK02" with QUALF=009.
Can you help me? I don't know how to create my filename with a UDF.
Thanks a lot
Christopher
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.