on 11-20-2006 7:08 AM
Hi all
I m developing a java module for altering a file's name. I m trying to append system date and time to the file name and send it back. I was successful in retrieving the file's name, appending date n time in it but now I want to send it back. How can I achieve this ? any pointers will be very helpful
awaiting your reply
Regards
Kapil
Hi Kapil,
Try this
Object obj = md.getPrincipalData();
com.sap.aii.af.ra.ms.api.Message msg = (Message) obj;
msg.setMessageProperty("http://sap.com/xi/XI/System/File", "FileName","FileNameModule");
// FileNameModule represents the resultantFile name.
Set Adapter Specific Attributes(FileName) in receiver commn channel.
Rest of ur logic is same.
Get back if u have any issues.
Regards,
Sudharshan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
>>>> but now I want to send it back
what do you mean?
to the XI again ? if you put the file in a folder in which XI pulls
the files the file will be in XI again
Regards,
michal
-
<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
String SIGNATURE = "process(ModuleContext moduleContext, ModuleData inputModuleData)";
TRACE.entering(SIGNATURE, new Object[] { moduleContext, inputModuleData });
// Access the XI message. I.e. this module must be placed in the module chain
// behind a module that sets an XI message as principal data.
Object obj = null;
Message msg = null;
try {
obj = inputModuleData.getPrincipalData();
msg = (Message) obj;
Message msgg = (Message)inputModuleData.getPrincipalData();
AuditMessageKey amk = new AuditMessageKey(msgg.getMessageId(), AuditDirection.INBOUND);
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "RenameFile: Module Called");
// Read the channel ID, channel and the module configuration
String cid = null;
String mode = null;
String fileName = null;
try {
// CS_GETMODDAT START
mode = (String) moduleContext.getContextData("mode");
// CS_GETMODDAT END
// CS_GETCHADAT START
cid = moduleContext.getChannelID();
Channel channel = new Channel(cid);
// channel = (Channel) LookupManager.getInstance().getCPAObject(CPAObjectType.CHANNEL, cid);
// Example to access a channel configuration parameter in a module: String someParameter = channel.getValueAsString("YourAttributeName");
// CS_GETCHADAT END
// Hashtable mp = (Hashtable) inputModuleData.getSupplementalData("module.parameters");
// if(null != mp)
// {
// fileName = (String)mp.get("FileName");
// fileName = fileName + todaysDate;
// mp.put("FileName",fileName);
// }
fileName = channel.getValueAsString("file.targetFileName");
Date todaysDate = new Date(System.currentTimeMillis());
fileName = fileName + todaysDate;
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "RenameFile: fileed" + fileName);
if (mode == null) {
TRACE.debugT(SIGNATURE, "Mode parameter is not set. Switch to 'none' as default.");
mode = "none";
}
TRACE.debugT(SIGNATURE, "Mode is set to {0}", new Object[] {mode});
} catch (Exception e) {
TRACE.catching(SIGNATURE, e);
TRACE.errorT(SIGNATURE, "Cannot read the module context and configuration data");
ModuleException me = new ModuleException(e);
TRACE.throwing(SIGNATURE, me);
Audit.addAuditLogEntry(amk, AuditLogStatus.ERROR, "Rerrrd" + me);
throw me;
}
// try{
// Hashtable mp = (Hashtable) inputModuleData.getSupplementalData("module.parameters");
// String fileName = null;
// Date todaysDate = new Date(System.currentTimeMillis());
// if(null != mp)
// {
// fileName = (String)mp.get("FileName");
// fileName = fileName + todaysDate;
// mp.put("FileName",fileName);
// }
// inputModuleData.setSupplementalData("module.parameters", mp);
// }catch(Exception e){
//
// }
} catch (Exception e) {
TRACE.catching(SIGNATURE, e);
if (obj != null)
TRACE.errorT(SIGNATURE, "Input ModuleData does not contain an object that implements the XI message interface. The object class is: {0}", new Object[] {obj.getClass().getName()});
else
TRACE.errorT(SIGNATURE, "Input ModuleData contains only null as XI message");
ModuleException me = new ModuleException(e);
TRACE.throwing(SIGNATURE, me);
throw me;
}
return inputModuleData;
Please refer the above code, it might help you to understand what i m trying to do. I have also included some code that is in comments which I tried by referring the links given by other users but its nt working. Please tell me how to improve my code to set the filename into the <b>reciever file adapter</b>.
Regards
Kapil
Kapil,
if you ref. the earlier link i sent you then u wud understand the aproach is to fill your XML that comes into XI with a node/field with the filename generated.your module will be deployed in the sender channel.
And then maybe later in your receiver adapter, you cud use variable substitution (http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm) to get the value to generate the file name for ur output file.
Hi KApil,
Use the ASMA field for changing target filename : Adapter-specific-message-attribute,
You can find some blogs on how to use it for altering your filename
( you could even have done this is message mapping : no module necessary )
rgds
Dirk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
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.