on 09-20-2010 4:46 PM
Dear experts
In an IDoc2File scenario I have added the IDoc-number to dynamic configuration using the folling code in an UDF:
DynamicConfiguration conf = (DynamicConfiguration)
container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","DOCNUM");
conf.put(FileName, a);
The information is stored in the SOAP message
<SAP:DynamicConfiguration SOAP:mustUnderstand="1">
...
<SAP:Record namespace="http://sap.com/xi/XI/System/File" name="DOCNUM">0000000000012345</SAP:Record>
...
</SAP:DynamicConfiguration>
Can anybody tell me how I can access this information in the "variable substitution" section of the CC? Perhaps something like "message:docnum"?
Additional information:
Taking the IDoc-number from the payload using e.g. "payload:ORDERS05,1,IDOC,1,EDI_DC40,1,DOCNUM,1" does not work, since the XML-IDoc has been converted to an flat-IDoc.
Thanks in advance for any good ideas
Markus
why you need to do that, which use do you want to for the IDocnumber? will it be part of the file name? please explain a little more what you need to do?
i dont understand why you use DC and later want to access via variable substitution. as i can see the file name will have the idoc number coz is what you do in the udf.
container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","DOCNUM");
conf.put(FileName, a);
there you set the idoc number as the file name
if you want to use the idoc number in variable Substitution so, this value must be in the target structure
Edited by: Rodrigo Alejandro Pertierra on Sep 20, 2010 12:54 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
if the IDOC number shall be part of the file name, if posible map the IDoc number to the target structure, if not possible you have to define the complete filename by dynamic configuration.
but take in mind if you use dynamic configuration you cannot use later variable substitution. you have to choose one.
> DOCNUM shall be part of the filename.
To achive this you don't need to do Variable substitution, As you are already using the Dynamic configuration therefore just map the output of Dynamic Configuration UDF to any parent node and then set the ASMA(Adapter Specific Message Attributes) settings in your receiver file adapter and tick the "File Name" check box. Now in the File Name input parameter use %filename% (you can use any name even your's) that's it.
At the other hand you can also go through this blog..
/people/jin.shin/blog/2007/04/27/sap-netweaver-xi-variable-substitution-with-adapter-specific-message-attributes-via-dynamicconfigurationbean
I tried to solve my problem as explained in the following article
http://wiki.sdn.sap.com/wiki/display/XI/CombiningthreedifferentaspectsofPIinoneshot
Doesn't this article use DC and variable substitution? Maybe I am using the term DC incorrectly.
What I do not completely understand in this article is the section below "Another Simple way".
It would be ok for me to define the complete filename by dynamic configuration.
Do I need to change the following UDF line?
DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","DOCNUM");
How can I access filename?
DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","DOCNUM");
in that sentence replace DOCNUM for the variable that contain the full file name. i mean if the file name would be:
MasterData12345.txt where 12345 is the Docnumber, so concat MasterData with the idocnumber and replace the sentence
String filename="";
filename="MasterData"DOCNUM".txt"
DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File",filename);
then in the CC put any value for file name coz PI will take the value defined in the UDF. you have to define the proper path for the file in the CC
better now?
Hi Marcus
if you are receiving the IDOC as a text file from the ECC system, then you can use the Function Module in the File port[we 20 transaction] to generate the file name.
Following function modules are present in the list. from the below list you can use the first/third functuion module to get the document number in the file name only.
EDI_PATH_CREATE_CLIENT_DOCNUM Directory + file name in format T_Client_Docnum
EDI_PATH_CREATE_DATE_TIME Directory + file name in format T_CCYYMMDD_HHMMSS
EDI_PATH_CREATE_MESTYP_DOCNUM Directory + <message type>_<last 8 characters of DOCNUM>
Thanks
Rinku G
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Of course, I also changed the UDF
public String putDynamicConfiguration(String docnum, Container container) throws StreamTransformationException{
try
{
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
conf.put(key, docnum);
return docnum;
}
catch (Exception e)
{
return docnum;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Reason for follow-up -> my question in the previous post.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Now I could also get the DynamicConfigurationBean-approach working.
Instead of "DynamicConfigurationBean" I needed to use "AF_Modules/DynamicConfigurationBean" and I needed to uncheck the option "Use Adapter-Specific Message Attributes".
There is only one thing remaining, that I do not understand: why does at variable substitution message:interface_name hold the information, which I previously set as
key.0 write http://sap.com/xi/XI/System/File FileName
value.0 message.interface
If I anybody could explain this to me, I would be 100% glad.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I will also try the Dynamic Configuration Bean approach.
Thanks for helping - great job!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Rodrigo and Sarvesh
Thanks for your help so far! I applied your hints and now it is working fine.
But now I have the following additional questions
1.) My message mapping only maps the input IDoc to an output IDoc of the same type and structure. The MM is only required to process the UDF. Is there another, better solution to achieve my requirement that the IDoc-number shall be part of the filename?
2.) In the CC you have the possibility to use temporary files (section "Processing", Option "Put File" = "Use Temporary File". I think this will not work with the given solution, will it?
-
To possibly help somebody else or clarify the mechanism once again, I wrote down how my solution now looks like.
My UDF in the message-mapping looks like this
- Input = DOCNUM of IDoc, e.g. ORDERS05/IDOC/EDIDC/DOCNUM
- Outpt = DOCNUM of IDoc, e.g. ORDERS05/IDOC/EDIDC/DOCNUM
- UDF:
public String putDynamicConfiguration(String docnum, Container container) throws StreamTransformationException{
try
{
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String filename = "Prefix_" + docnum + ".txt";
conf.put(key, filename);
return docnum;
}
catch (Exception e)
{
return docnum;
}
In the CC the settings are now as follows
File Name Scheme = . -> only a dot or something else, because this field is obligatory, even if it is not used in this case.
Variable substitution (...)
Enable -> unchecked
Adapter-Specific Message Attributes
Use Adapter-Specific Message Attributes -> checked
Fail If Adapter-Specific Message Attributes Missing -> checked
File Name -> checked
Directory, File Type, Temporary Name Scheme for Target File Name -> unchecked
When I send an IDoc to PI and view the Adapte-Engine Version of the message (the SOAP-document, not the payload) I can find the Filename:
<SAP:DynamicConfiguration SOAP:mustUnderstand="1">
...
<SAP:Record namespace="http://sap.com/xi/XI/System/File" name="FileName">Prefix_0000000000012345.txt</SAP:Record>
...
</SAP:DynamicConfiguration>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> But now I have the following additional questions
> 1.) My message mapping only maps the input IDoc to an output IDoc of the same type and structure. The MM is only required to process the UDF. Is there another, better solution to achieve my requirement that the IDoc-number shall be part of the filename?
Without mapping it won't be possible to include the IDOC number in your file name.
> 2.) In the CC you have the possibility to use temporary files (section "Processing", Option "Put File" = "Use Temporary File". I think this will not work with the given solution, will it?
This options is used to protect the file while it is being written so that other application looking for same file can't be able to pick the half written file.
In other words this option will first write the file with given temporary name and once it is fully transfered then it renames it to it's original name (Which you will provide under File Name in your CC).
1.) My message mapping only maps the input IDoc to an output IDoc of the same type and structure. The MM is only required to process the UDF. Is there another, better solution to achieve my requirement that the IDoc-number shall be
part of the filename?
If not in a UDF then the logic can be implemented in an Adapter Module (JAVA knowledge required, increased effort)
If the value is present in the IDOC....or in target payload, then you can make use of Variable Substitution (not recommended when you have DC)
2.) In the CC you have the possibility to use temporary files (section "Processing", Option "Put File" = "Use Temporary File". I think this will not work with the given solution, will it?
Surely not.....it is not related to your requirement.
Regards,
Abhishek
1.) My message mapping only maps the input IDoc to an output IDoc of the same type and structure. The MM is only required to process the UDF. Is there another, better solution to achieve my requirement that the IDoc-number shall be part of the filename?
No if you have dynamic file name. Variable substitution is the other posibility but not allways the data could be part of the target file, so DC is the best solution.
2.) In the CC you have the possibility to use temporary files (section "Processing", Option "Put File" = "Use Temporary File". I think this will not work with the given solution, will it?
I will not work for your requirement. the functionality is different.
http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/frameset.htm
Thks
if i am not wrong ur requirement now is
1. You are able to put the DOCNUM in the Dynamic Configuration under the Key "FileName"
2. You want to use this FileName with variable substituion keeping the first part of the name as configurable in Integration directory. i.e. MASTER_<<filename>>
if this is the requirement, then you can achieve it using the Dynamic Configuration Bean and variable substituion.
Step 1.
-
In the file reciever adapter, add DynamicConfigurationBean before CallSAPAdapter.
Configure the module parameters for this as below.
key.0 write http://sap.com/xi/XI/System/File FileName
value.0 message.interface
With this, it will overwrite the header value of the Message Interface name with the value of the file name. Note that this value of message Interface (MI_Sometihng) is no longer significant now that the message is on Adapter Engine.
Step 2.
-
Activate the variable substitution. add a variable like
fname message:interface_name
done!!
you can now configure the filename as
Master_%fname%.txt
If you are still facing problems then follow 4 easy steps..
1. Create the udf by using below code as it is.. while creating UDF use the input argument as 'a'.
String str = a;
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
conf.put(FileName, str);
return "";
2. Now get the Document Number from your source and add prefix and suffix to it and then pass it to UDF input field.
Finally map the udf output to any of your parent segment.
3. Now select ASMA setting in your Receiver adapter and tick the File Name check box.
4. In you input File Name give any name e.g. %myfile%.
I hope this helps you..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.