cancel
Showing results for 
Search instead for 
Did you mean: 

Query regarding Adapter Module development

Former Member
0 Kudos

Hi Experts,

I'm working on a scenario File (Text) --> XI ---> SAP (Idoc). I have to add validation for the file based on the data contained in it. I'm planning to do this usng a adapter module.

I have already started coding the module, but need confirmation on on 1 point.

The usual code for method public ModuleData process is as follows:

obj = imd.getPrincipalData();

msg = (Message) obj;

msgType = (String) mc.getContextData("msgType");

nameSpace = (String) mc.getContextData("nameSpace");

amk = new AuditMessageKey(msg.getMessageId(),AuditDirection.OUTBOUND);

XMLPayload xp = msg.getDocument();

I'm succesfully able to achieve the required validation in a java class but using the file stored in my local directoy.

Now my question is that will the object xp hold the contents of text file as it or will it contain the xmlpayload.

I will be execuitng the module before the standard CallSapAdapter in module tab.

Your reply is highly apreciated.

Thanks,

Pragati

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I'm able to succefully run my Filevalidatiobean for NFS protocol, but I'm facing issues with FTP protocol.

I can read the source file directory, source filename from the channel, but the file itself is not read.

Below is the code piece:

sourDir = channel.getValueAsString("ftp.sourceDir");

String filename = channel.getValueAsString("file.sourceFileName");

localFile = sourDir + "
" + filename; }

inputFile = new File(localFile);

if I do a inputFile.exists() then it returns false, which means it is not able to locate the file.

The audit log entries for the scenario are as follows:

Source FileName: tes.txt

Source Directory: /ftproot/input

Source File Location: /ftproot/input/test.txt

File exists at location: false

Please let me know if there is any change for ftp.

Former Member
0 Kudos

do u use a prefix ftp:// when u check the file exists code

Former Member
0 Kudos

Hi Arvind,

Do you mean that my location string shoudl like this :

Source File Location: ftp://ftp server ip/ftproot/input/test.txt

Former Member
0 Kudos

i think you might have to connect to the FTP. i am not sure if the module can make the chanel's FTP connection available for you

check this

/thread/5228080 [original link is broken]

Former Member
0 Kudos

Hi Arvind,

Thanks for the link. I tried and tested the code uisng a standalone java application. I'm able to fetch the filenmes and files from the ftp directory, but it seems that I cannot directly read the file data from ftp seerver.

Can you tell me that is it necessary to copy a file from FTP server to the local directory to read the data from it. If ths is true should my adapter module first copy the file from FTP server to local directory on PI server.

Also if I want to copy a 200MB file from FTP to PI server will ithere be any performance issues?

Regards,

Pragati

Former Member
0 Kudos

Hi Pragati,

This should be before the CallSapAdapter module, it contain the xmlpayload because the module CallSapAdapter sends the message from AF to XI.

regards,

lpbuff

Former Member
0 Kudos

Hi,

If this contains the xml payload its of no use to me. Can you tell me how can I access the file data directly using a custom module?

Will I be able to access the source directory path and filename mentioned in the channel configuration in teh adapter module?

How do I generate the instance of the channel?

Regards,

Pragati

Former Member
0 Kudos

Hi Pragathi,

Can you tell me how can I access the file data directly using a custom module

u can create a adapter module and call it in sequence before the standard module... now u can access the whole file as a object.

Will I be able to access the source directory path and filename mentioned in the channel configuration in teh adapter module?

Yes u can. Pass them as parameter to process method, ModuleConext obj has these details.

Babu

Former Member
0 Kudos

Hi,

I'm developing teh adapter module for PI 7.1 server. I have imported the required jar files in my project (these jar files are directly obtained from the server).

I need to add a line in my ciode to fetch the current channel :

Channel channel = new Channel(moduleContext.getChannelID());

but the issue is that I'm unabel to create the object of class Channel.

I can see "Channel.class" file in the jar file "com.sap.aii.af.cpa.svc.api.jar". This jar is already added in the build path.

Please let me now if anyone has a clue about this.

Regards,

Pragati

Former Member
0 Kudos

Hi,

Chk this:

Thanks

Amit