on 03-20-2013 11:05 AM
Hi Experts,
My requirement is that, I need to set the Source Directory Path Value at run time before calling the Standard Adapter Module.
For this developed a custom Adapter Module code as below:
In the above delpoyed mdule i have written the as below to set the source directory value at runtime.
Here my intension is that I have to pick the file from a source directory based on environment.
If PI server is DEV then source directory ="//myeccserver/interface/payments/Bank/ECD";.
If PI server is TEST/QA then source directory ="//myeccserver/interface/payments/Bank/ECT";.
If PI server is PROD then source directory ="//myeccserver/interface/payments/Bank/ECP";.
See the below code from EJB Module and Deployed onto PI 7.3 Server from NWDS and used in File Sender Adapter Channel as below picture.
-----------------------------------------------------------------------------------------------
public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData) throws ModuleException{
Object obj = null; // Handler to get Principle data
Message msg = null; // Handler to get Message object
String sourceDirectory = null; // sourceDirectory Name which is being processed
String sid = null;
AuditAccess audit = null;
MessageKey key1;
try {
obj = inputModuleData.getPrincipalData();
msg = (Message) obj;
MessagePropertyKey key = new MessagePropertyKey("Directory", "http://sap.com/xi/XI/System" );
key1 = new MessageKey(msg.getMessageId(),msg.getMessageDirection());
audit = PublicAPIAccessFactory.getPublicAPIAccess().getAuditAccess();
sid = System.getProperty("SAPSYSTEMNAME");
if (sid.equals("XID")){
sourceDirectory = "//myeccserver/interface/payments/Bank/ECD";
audit.addAuditLogEntry(key1, AuditLogStatus.SUCCESS, " sourceDirectory: "+sourceDirectory);
}
else{
if (sid.equals("XIT")){
sourceDirectory = "//myeccserver/interface/payments/Bank/ECT";
audit.addAuditLogEntry(key1, AuditLogStatus.SUCCESS, " sourceDirectory : "+sourceDirectory);
}
else{
if (sid.equals("XIP")){
sourceDirectory = "//myeccserver/interface/payments/Bank/ECP";
audit.addAuditLogEntry(key1, AuditLogStatus.SUCCESS, " sourceDirectory : "+sourceDirectory);
}
}
}
msg.setMessageProperty(key,sourceDirectory);
inputModuleData.setPrincipalData(msg);
} catch (Exception e) {
throw new ModuleException(e);
}
return inputModuleData;
}
-----------------------------------------------------------------------------------------------
Pleat me know if any thing missed the above.
Regards,
Sreeni.
What you are trying to do is not possible. You cannot influence the source directory from an adapter module. The adapter module is calles after the PI message is created.
It is normal that directories are different for dev, qa and prod. Just type the correct directory in the channel. There is no need for an adapter module which you have to change whenever the directories change.
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,
One option could be.. Create dummy comm channel, and use the module to just place file into appropriate directory that you pass module.
In the Adapter module,
1. connect to ftp server.
2. read the file from default DIR and copy it into environment specific directory which you can provide as module parameter.
Please let me know if that is the requirement you have.
Regards,
Akshay
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.