on 02-03-2011 9:22 AM
Hi everybody,
We are in PI 7.1
I need in an adapter module (file adapter receiver) to access to the Target Directory comming from parameters
I foound the code in a weblog
/people/sap.user72/blog/2005/07/15/copy-a-file-with-same-filename-using-xi
Here is the code I found
public ModuleData process(
ModuleContext moduleContext,
ModuleData inputModuleData)
throws ModuleException {
Object obj = null;
Message msg = null;
try {
Channel ch = new Channel(moduleContext.getChannelID());
obj = inputModuleData.getPrincipalData();
msg = (Message) obj;
XMLPayload xmlpayload = msg.getDocument();
String path = ch.getValueAsString("file.targetDir");
if (!path.endsWith("
") && !path.endsWith("/"))
if(path.indexOf("
")!=-1)
path+="
";
else
path += "/";
if (xmlpayload != null) {
convert(xmlpayload.getContent(), path);
}
inputModuleData.setPrincipalData(msg);
} catch (Exception e) {}
return null;
}
private void convert(byte[] bs, String path) throws Exception {
String bs_out = new String(bs);
String filename =
bs_out.substring(
bs_out.indexOf("<FileName>") + 10,
bs_out.lastIndexOf("</FileName>"));
bs_out =
bs_out.substring(
bs_out.indexOf("<Base64>") + 8,
bs_out.lastIndexOf("</Base64>"));
byte bb[] = com.sap.aii.utilxi.base64.api.Base64.decode(bs_out);
File f1 = new File(path + filename);
FileOutputStream fos = new FileOutputStream(f1);
fos.write(bb);
fos.close();
}
The object Channel come s from the package import com.sap.aii.af.service.cpa.Channel;
The jar is in the build path (com.sap.aii.af.service.cpa.jar);
When I write in NWDS
Channel ch = new Channel(moduleContext.getChannelID());
NDWS gives me an error "Cannot instantiate the type Channel".
Can somebody help me about that, please?
Does that code dosn't work in pi 7.1?
Thanks in Advance for your help.
Best Regards.
E. Koralewski
Edited by: Eric Koralewski on Feb 3, 2011 1:40 PM
> When I write in NWDS
> Channel ch = new Channel(moduleContext.getChannelID());
> NDWS gives me an error "Cannot instantiate the type Channel".
it should be:
Channel ch = (Channel) LookupManager.getInstance().getCPAObject(CPAObjectType.CHANNEL, moduleContext.getChannelID());
(taken from sample module ConvertCRLFfromToLF)
http://help.sap.com/javadocs/pi/pi711sp03/index.html?com/sap/aii/af/service/cpa/Channel.html
Edited by: Stefan Grube on Feb 3, 2011 2:02 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Eric Koralewski,
Can you please tell me why you are going for "Adapter module"? Is it not possible to achive your requirment by Dynamic Configuration?
Regards,
Raghu_Vamsee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
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.