on 04-25-2007 7:57 PM
Been searching and I've seen Michael's blog about creating a UDF to place the original file name in the payload. Since this is a file->file scenario, I have no mapping.
I have the Adapter-Specific Attributes turned on on the Sender to pass the file name in the DynamicConfiguration of the message header and I can see it in the message.
What I want to do it to have a target file name in the form of: XXXXX_<i>originalfilename</i>.
So I have turned on variable substitution and created a variable called 'file'.
In the File Name Scheme Parameter I have entered: XXXXXX_%file%
If I set the variable substitution refererance for 'file' to message:message_id, my file name is created as XXXXX_message_id, or any of the other options from -> <a href="http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm">SAP Adapter Help Page</a>
How can I get the value of FileName as the value for my variable %file%?
Hi,
Here is one way to do it.
Using the same blog from Michael as specified in your posting, you can get the sender filename in a UDF. In this same UDF, you can also dynamically set the receiver file name using the sender filename.
There is an example of setting the receiver comm chan in the blog below, which can be adopted to file adapter.
/people/william.li/blog/2006/04/18/dynamic-configuration-of-some-communication-channel-parameters-using-message-mapping
The UDF does nothing except to set the receiver file name dynamically. The same input value of the UDF can be returned as the output. So, you can use this UDF for any element.
Regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do not have, nor do I want any mappings. In these cases they are overhead that is not needed.
Additionally each receiver (there are several) will have the prefix specified in the receiver file adapter and all the prefixes will be different. The mappings will not know what the receiver.
The file name is in the header of the message.
Isn't there some way to access it, with complicating the whole thing with custom Java/ABAP code?
I have SP19 of 2004
Message was edited by: Mark Rinkel
Mark Rinkel
Mark,
I dont think it is possible without using the mapping. You can achive this with mapping only.
What you can do is just take two fields in your datatype and pass the values of the file as a whole record with maximum length and in the second field pass the original filename and use in variable substitution.
-
Satish
Hi -
You can do this using the XI 3.0 Adapter Framework DynamicConfiguration Module as specified in Note 974481. It was an interesting case, so I had to try it.
It's pretty easy - do the following:
- In your receiver file adapter, leave everything the way you have it in the Parameters tab (of course, you would have to uncheck at least the "File Name" Adapter Specific Message Attribute setting).
- In the Module tab, add the following line in bold for Processing Sequence:
<b>1 | AF_Modules/DynamicConfigurationBean | Local Enterprise Bean | 1</b>
2 | localejbs/CallSapAdapter | Local Enterprise Bean | 0
Then in the Module Configuration part:
1 | key.0 | write http://sap.com/xi/XI/System/File FileName
1 | value.0 | message.interface
Here I used "interface" for the message header. So actually, if you follow me exactly, you would have to change the variable substitution config to "message:interface" (w/o quotes.
So essentially, you're writing the FileName ASMA attribute that you're sending to the "interface" message header and using that in variable substitution. That should do it.
Regards,
Jin
> I do not have, nor do I want any mappings. In these
> cases they are overhead that is not needed.
>
> Additionally each receiver (there are several) will
> have the prefix specified in the receiver file
> adapter and all the prefixes will be different.
> The mappings will not know what the receiver.
> he file name is in the header of the message.
That is not true at all.
Mapping is done during Interface Determination runtime, which occurs after Receiver Determination logical step. Therefore, you will be able to access the RECEIVER_SERVICE StreamTransformationConstant (or use the standard Receiver constant function) in your mapping, thus mapping will be able to know receiver at runtime.
Anyway, mappings and modules are the only standard ways of introducing code in your pipeline. If you dont want to use mapping, then create a module to be used at receiver side. But either way, the overhead will be the same (if you use java mapping or module, for example). Actually, the mapping may even be faster, because you wont have to use EJB instantiation and all. You'd have to try to be sure, though.
Regards,
Henrique.
> > I do not have, nor do I want any mappings. In
> these
> > cases they are overhead that is not needed.
> >
> > Additionally each receiver (there are several)
> will
> > have the prefix specified in the receiver file
> > adapter and all the prefixes will be different.
> > The mappings will not know what the receiver.
> > he file name is in the header of the message.
>
> That is not true at all.
> Mapping is done during Interface Determination
> runtime, which occurs after Receiver Determination
> logical step. Therefore, <b>you will be able to access
> the RECEIVER_SERVICE StreamTransformationConstant (or
> use the standard Receiver constant function) in your
> mapping, thus mapping will be able to know receiver
> at runtime.</b>>
Henrique,
Actually, what I meant was the mapping will not know the value I have entered in the receiver communication channel - File Name Scheme parameter value. For example in CC for Target System 1 the FNS = FMRECEIVER1, the CC for Target System 2 the FNS = FM_RECEIVER2 and so on.
Are you saying in the mapping I could access the value of FNS from the communication channel in the mapping?
I'm very new at XI so I can be all wet on this and we never got this deep during SAP training class.
Hi Jin,
That was perfect. THANKS A BUNCH!!
I don't know why the radio buttons for points don't show up, but I award 10 points if they do.
The only thing different was in the variable substitution I had to enter <b>message:interface_name</b> to access what I had set the <b>message.interface</b>
in the value.0 assignment.
I tried using some different names for interface/interface_name and it doesn't appear that you can create dynamic variables.
Jin,
Awesome solution I am just amazed on how simple yet logical this solution is
Once question though : We are overwriting the Message ID using the DynamicConfigurationBean. How good a solution is it? What I mean to ask here is is it ok to over write the MessageID of your message in XI with the filename?
Regards
Bhavesh
> Actually, what I meant was the mapping will not know
> the value I have entered in the receiver
> communication channel - File Name Scheme parameter
> value. For example in CC for Target System 1 the
> FNS = FMRECEIVER1, the CC for Target System 2 the FNS
> = FM_RECEIVER2 and so on.
>
> Are you saying in the mapping I could access the
> value of FNS from the communication channel in the
> mapping?
No, you cant read in mapping what you set in CC.
However, you can ignore the parameter FileName scheme in CC and just set it in mapping runtime.
The way you are using, you'll have to maintain the prefix for each receiver adapter you have. If you had it in mapping, you could just do something like:
...
String receiver = container
.getTransformationParameters().
.get(StreamTransformationConstants.SENDER_SERVICE);
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create(
http://sap.com/xi/XI/System/File,
FileName);
String orgFileName = conf.get(key);
String tgtFileName = receiver + "_" + orgFileName;
conf.put(key, tgtFileName);
...
and then you wouldn't have to maintain the file name scheme in CC.
Regards,
Henrique.
Hi Bhavesh -
<i>>>>Once question though : We are overwriting the Message ID using the >>>DynamicConfigurationBean. How good a solution is it? What I mean to ask here is
>>>is it ok to over write the MessageID of your message in XI with the filename?</i>
Yeah, I was a little weary about overwriting the Message ID so I chose to use the interface name instead - seemed more harmless. Especially given that we're doing this on the receiver side, near the end of the scenario, I think there are a lot of message header elements that could have been used.
Regards,
Jin
User | Count |
---|---|
79 | |
9 | |
9 | |
7 | |
7 | |
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.