cancel
Showing results for 
Search instead for 
Did you mean: 

Empty file to process in customer J2EE adapter module

Former Member
0 Kudos

Hi All,

if i give an empty text file to a sender communication channel, then no message is generated by XI.

i want to generate a dummy XML if empty file is given.

so is it possible to make a customer-specific J2EE adapter module - then deploy it - then if in sender comm channel this adapter module is written before SAPAdapter module, then should XI generate a dummy XML for this empty file.

i am asking this because i developed a J2EE adapter module, then deployed it, then tried to invoke it from sender comm channel but this J2EE adapter module is not getting invoked - this i can tell because i have written the following lines only in Java class process method:

<i>Message msg_audit = (Message)inputModuleData.getPrincipalData();

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

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"FileCheck: Module called");

return inputModuleData;</i>

but still in the audit log only 3 messages of entire file content converted to XML format, empty doc so no sending of message and deleting of empty file are coming.

<b>Can anybody suggest whether is it possible to process an empty text file to generate a dummy XML in sender communication channel in XI.</b>

Thanks,

Rajeev Gupta

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Rajeev,

We were wandering the module you developed ever work for you. We are facing the same scenario, and would greatly appreciate your feedback on developing this module.

Thanks so much in advanced,

David

Former Member
0 Kudos

Hi Rajeev,

According to SAP Note 821267 (Question No.31), an empty file is not processed by the receiver, i.e although the sender adapter might pick the empty file it will not be sent as outbound payload.

Go through this generic configuration for sender file adapter in order to <i>pick</i> any kind of file...

/people/sravya.talanki2/blog/2005/08/16/configuring-generic-sender-file-cc-adapter

Regards,

Sushumna

Former Member
0 Kudos

Hi All,

i know that empty input text file is not send by the sender communication channel as a message........

so in order to generate a dummy XML message for empty text file, i created a java adapter module with the following lines of code in the process method of the java class:

<i>Object obj = inputModuleData.getPrincipalData();

Message msg_audit = (Message)obj;

AuditMessageKey amk = new AuditMessageKey(msg_audit.getMessageId(),AuditDirection.INBOUND);

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"FileCheck: Module called");

return inputModuleData;</i>

this java process method is not giving any error in the Netweaver Developer Studio...........

but when i deployed this .ear file and called this java adapter from sender comm channel, then when i gave as input a text file with data in it, then in Message Monitoring Tool - <b>i see this error in the auditlog of the send message:

Error: Attempt to process file failed with ClassCastException</b>

Can anybody suggest why this error is occuring and how to rectify this error...............

Thanks,

Rajeev Gupta

Former Member
0 Kudos

Hi All,

When i deployed the .ear file then when i gave the file with data in it, it showed the above java error in the audit log but further in the audit log, it said:

<b>Application attempting to send an XI message asynchronously using connection AFW.</b>then it send the message to queue and then finally delivered the message successfully.

But when i again gave the same data file as input, then in the audit log of that message, it did not showed the above java error of ClassClassException, but it directly showed this message:

<b>Application attempting to send an XI message asynchronously using connection AFW.</b>

then it send the message to queue and then finally delivered the message successfully.

<b>Can anybody suggest what is happening in the sender comm channel.......is java module getting called or not - if called then why my audit message "FileCheck: Module called" or the ClassCastException is not showing in audit log....</b>

points will be rewarded to the person who solves this query.

Thanks,

Rajeev Gupta

Former Member
0 Kudos

Hi Rajeev,

To check whether your module is getting called or not, try to write something into the server's local file system using Module and open the same file and check.

I think your Adapter Module is failing because your payload doesnot have anything, So try to create your Source message structure with empty values here and set the OutputStream content to XMLPayload object in Message.

Regards,

Ananth


public ModuleData process(ModuleContext arg0, ModuleData modData)
		throws ModuleException {

	Message xiMessage = (Message) modData.getPrincipalData();

	XMLPayload payloadData = xiMessage.getDocument();
	ByteArrayOutputStream outXML=new ByteArrayOutputStream();
	
	//Write the logic to fill Empty Source XML structure in outXML stream
	
	payloadData.setContent(outXML.toByteArray());
	

	modData.setPrincipalData(xiMessage);

return modData;
}

Former Member
0 Kudos

Hi Ananth,

i had this java source code:

<i>Message msg = (Message)inputModuleData.getPrincipalData();

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

Audit.addAuditLogEntry(amk1,AuditLogStatus.SUCCESS,"Empty File Validation Module OUTBOUND is called");</i>

when i invoked this from a file having data, i got this message "Empty File Validation Module OUTBOUND is called"..........but when i invoked this from an empty file, i did not got this message - this means (Message)inputModuleData.getPrincipalData() is throwing exception on empty file

in another similar scenario, i wrote the following code:

<i> public ModuleData process(ModuleContext moduleContext,

ModuleData inputModuleData)

throws ModuleException

{

File f;

PrintStream ps;

try

{

try {

f = new File("
components
XITEMP
sample
PWC
check.txt");

ps = new PrintStream(new FileOutputStream(f));

ps.println("Testing");

ps.close();

} catch (IOException e) {

f = new File("
components
XITEMP
sample
PWC
exception.txt");

ps = new PrintStream(new FileOutputStream(f));

ps.println("IOException");

}

}

catch (IOException e){

}

}</i>

but the file check.txt was still having no data even when an input file with data was given.

<b>So can you suggest how to write some content in a file in the local server system to check what is going on in adapter module.</b>

Thanks,

Rajeev Gupta

Former Member
0 Kudos

Hi All,

When i write this code:

try

{

obj = inputModuleData.getPrincipalData();

msg_audit = (Message)obj;

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

Audit.addAuditLogEntry(amk,AuditLogStatus.SUCCESS,"FileCheck: Module called");

<i>File f = new File("/components/XITEMP/sample/PWC/check.txt");

if (f.canWrite())

{

PrintStream ps;

FileOutputStream fos =new FileOutputStream(f);

File f1 = new File("/components/XITEMP/sample/PWC/check1.txt");

ps = new PrintStream(fos);

if (f1.exists()==false)

{

f1.createNewFile();

}

ps.println("Testing");

ps.close();

fos.close();

}

else

{

File f2 = new File("/components/XITEMP/sample/PWC/check2.txt");

if (f2.exists()==false)

{

f2.createNewFile();

}

} </i>

}

}

it works fine......it creates the file check1.txt

but when i place the italiced code in this format:

try

{

obj = inputModuleData.getPrincipalData();

msg_audit = (Message)obj;

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

Audit.addAuditLogEntry(amk,AuditLogStatus.SUCCESS,"FileCheck: Module called");

}

catch (Exception e)

{

try

{

File f = new File("/components/XITEMP/sample/PWC/check.txt");

if (f.canWrite())

{

PrintStream ps;

FileOutputStream fos =new FileOutputStream(f);

File f1 = new File("/components/XITEMP/sample/PWC/check1.txt");

ps = new PrintStream(fos);

if (f1.exists()==false)

{

f1.createNewFile();

}

ps.println("Testing");

ps.close();

fos.close();

}

else

{

File f2 = new File("/components/XITEMP/sample/PWC/check2.txt");

if (f2.exists()==false)

{

f2.createNewFile();

}

}

}

catch(Exception ex)

{

}

}

it doesnot create the file check1.txt......

Can anybody suggest why in the exception block this italiced code is not working........means it is working in try block of try{}catch{} block.......but it is not working in catch block of try{}catch{try{}catch{}}

Thanks,

Rajeev Gupta

Former Member
0 Kudos

Hi Rajeev,

Your code is not creating <b>check1.txt</b> because it is in catch block and it will be reached only if there is an Exception.

So if you want to create a file regardless of whether Exception occured or not, use finally block to create the file and check it again.

BTW any success in processing Empty files you mentioned in earlier posts?

Regards,

Ananth

Former Member
0 Kudos

Hi All,

a strange thing is occuring in the adapter module...

the java class is not showing any error in these statements:

<i>Object obj = inputModuleData.getPrincipalData();

Message msg_audit = (Message)obj;

AuditMessageKey amk = new AuditMessageKey(msg_audit.getMessageId(),AuditDirection.INBOUND);

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"FileCheck: Module called");

return inputModuleData;</i>

but when i deploy this .ear project file to SDM, then the adapter monitoring of this sender communication channel is showing <i>Error: java.lang.ClassCastException</i>

<b>Can anybody suggest how to rectify this error.</b>

Thanks and Regards,

Rajeev Gupta