cancel
Showing results for 
Search instead for 
Did you mean: 

Dummy XML not getting generated from empty file by J2EE adapter module

Former Member
0 Kudos

Hi All,

i know when XI gets an empty input text file, it does not generate a send message for it in sender communication channel.

in my scenario, if i get a file with data, i have to generate an XML message for it using file content conversion - this i have done...........

but if i get an empty text file, then i have to generate a dummy XML send message for it for my BPM.......

So i made a J2EE adapter module to generate dummy xml for empty file.....<b>when i give a file with data in it, then my adapter module is called..... but when i give an empty file, then my adapter module is not called</b>.........

<b><i>Can anybody suggest why the module processor is not invoking my customer-adapter module when an empty file is given.............but the module processor is invoking my customer-adapter module when a file with data is given</i>.</b>

Thanks,

Rajeev Gupta

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Rajeev,

Can you send the code of process method you implemented?

Amit

Former Member
0 Kudos

Hi Amit,

Below is the code of process method which i used:

<i>public ModuleData process(ModuleContext moduleContext,

ModuleData inputModuleData)

throws ModuleException

{

Object obj;

Message msg_audit;

AuditMessageKey amk;

try

{

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

PrintStream ps;

if (f.canWrite())

{

FileOutputStream fos =new FileOutputStream(f);

ps = new PrintStream(fos);

ps.println("Testing");

ps.close();

fos.close();

}

else

{

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

if (f.exists() ==false)

{

f.createNewFile();

}

}

obj = inputModuleData.getPrincipalData();

if (obj!=null)

{

msg_audit = (Message)obj;

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

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

}

else

{

String str = new String();

String str1 = new String();

str1="<?xml version=\"1.0\" encoding=\"utf-8\" ?>";

str1+="<ns:MT_PWC_RECORD xmlns:ns=\"urn://PWC_SR3_01/PWC/Customer\">";

str1+="<RECORD_SET>";

str1+="<RECORD>";

str1+="<RECORD_DATA>BLANK_FILE</RECORD_DATA>";

str1+="</RECORD>";

str1+="</RECORD_SET>";

str1+="</ns:MT_PWC_RECORD>";

str=str1;

inputModuleData.setPrincipalData(str);

}

}

catch(Exception e)

{

try

{

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

PrintStream ps;

if (f.canWrite())

{

FileOutputStream fos =new FileOutputStream(f);

ps = new PrintStream(fos);

ps.println(e.toString());

ps.close();

fos.close();

}

}

catch(Exception ex)

{

}

}

return inputModuleData;

}</i>

in the above methood, i used file operations at start just to see whether the module is getting invoked or not...so when i give a data file, then the file operations are performed and messages are written in audit log.........but when i give an empty file, then the file operations are not performed - meaning the module is not getting invoked........

Thanks,

Rajeev Gupta

Former Member
0 Kudos

Rajiv,

The empty file does not generate any XI message at IS. Hence the module is also not triggered. See SAP note 821267.

You can either put some meaningless text in the file and build your logic around whether the text is comprehensible or not.

Regards

Amit

Former Member
0 Kudos

Hi Amit,

i cant modify the input text file because it is coming from a third-party company..........

i have to use that input text file for my BPM....if that file is not having data, then i have to generate a alert message to administrator..............so i was trying to generate a dummy XML for my empty file for BPM so that in BPM i can generate an alert message for my empty file...

Regards,

Rajeev Gupta

Former Member
0 Kudos

Hello Rajeev,

In that case I suggest you prepare an OS-level script which will archive the empty file to a different folder as and when it is posted and create a new file containing info ( e.g. name , timestamp ) about the moved file. On finding this data XI can generate message and your BPM can raise alerts.

CHEERS

Amit

Former Member
0 Kudos

Hi Amit,

can you explain in slightly more detail how to write the OS script for empty file movement and creation of a new file with same name and timestamp in the same directory....

Thanks,

Rajeev Gupta