Empty file to process in customer J2EE adapter module

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

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

Similar Messages

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

    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

    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

  • J2EE adapter module not getting invoked by module processor

    Hi All,
    i have deployed my .ear file in SDM Repository successfully.
    but my J2EE adapter module is not getting invoked by module processor......this i can say because i have written code to audit log my message in the java class...but when i gave input an empty file, the audit log of that file in Message Audit Log showed only 3 Steps of file converted to XML format, no data found so not generating message, deletion of my empty file.
    Can anybody suggest how to enable my J2EE adapter module as i have created this module so that if i give empty file, then in the adapter i am creating a dummy XML for my message.
    Thanks and Regards,
    Rajeev Gupta

    Hi Stefan,
    1. JNDI name in visual admin is CustomerMeter
    2. the files in .ear file are:
    libraries,
    ejb project file,
    META-INF folder
    in ejb project file the following files are there:
    ejb-j2ee-engine.xml
    ejb-jar.xml
    CustomerMeter.class
    Please tell what to do now.
    Hi Amol,
    in audit log only 3 messages are coming: File converted to XML format, no data in document  so not sending message, deleting of empty file.
    i have given audit log statements in java class but my audit-log statements are not coming in the audit log
    this means my adapter module is not getting invoked.
    Please tell what to do to correct this error.
    Thanks and Regards,
    Rajeev Gupta

  • Reg :: Exception in custom java adapter module in sap pi

    Hi Experts,
                  I have included custom  java adapter module in SAP PI. I get the below error in sender communication channel  monitoring.
    Error: javax.ejb.TransactionRolledbackLocalException: nested exception is: java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/apache/xml/utils/URI$MalformedURIException; nested exception is: javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/apache/xml/utils/URI$MalformedURIException; nested exception is: javax.ejb.EJBTransactionRolledbackException: nested exception is: java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/apache/xml/utils/URI$MalformedURIException; nested exception is: javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/apache/xml/utils/URI$MalformedURIException
    I have included in External jar files in EJB project  also..Will that cause the above exception?
    Kindly suggest your solution.
    Thanks
    Priya

    Hi !
    have a look
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f013e82c-e56e-2910-c3ae-c602a67b918e
    and this thread also
    Throw Error in Module Adapter EJB
    Thanks!

  • Creating J2EE adapter module problem

    Hi All,
    when i am creating a J2EE customer-specific adapter module in SAP Netweaver Developer Studio, then in the java class when i write these statements:
    <u>import com.sap.aii.af.mp.module.*;
    import com.sap.aii.af.ra.ms.api.*;</u>
    public class CustomerMeter implements SessionBean, <u>Module</u>{
    it is showing error on the  above underlined things that it cannot resolve these things.
    can anybody suggest where to locate these librarys in Project - Properties - Java Build Path - Libraries path from the main menu.
    Thanks,
    Rajeev Gupta

    Hi Amit,
    On changing the ejb-jar.xml as you said:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
                             "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
        <description>EJB JAR description</description>  
        <display-name>EJB JAR</display-name>
         <enterprise-beans>
              <session>
                   <ejb-name>CustomerMeter</ejb-name>
                   <ejb-class>pkgCustomerMeter.CustomerMeter</ejb-class>
                   <home>com.sap.aii.af.mp.module.ModuleHome</home>
                   <remote>com.sap.aii.af.mp.module.ModuleRemote</remote>
                   <local-home>com.sap.aii.af.mp.module.ModuleLocalHome</local-home>
                   <local>com.sap.aii.af.mp.module.ModuleLocal</local>
                   <session-type>Stateless</session-type>
                   <transaction-type>Container</transaction-type>
              </session>
         </enterprise-beans>       
    </ejb-jar>
    But now on saving this xml, it is giving the following  error:
    <b>The content of element type "session" must match "(description?,display-name?,small-icon?,large-icon?,ejb-name,home?,remote?,local-home?,local?,ejb-class,session-type,transaction-type,env-entry,ejb-ref,ejb-local-ref,security-role-ref,security-identity?,resource-ref,resource-env-ref)".</b>
    Could you please tell how to correct this error.
    Thanks and Regards,
    Rajeev Gupta

  • Cleanly stop a process in an  XI adapter module

    Hi,
    I have a java adapter module that decides whether the process should carry on or not.
    When I want to stop the process I throw an UnsupportedOperationException that is reported in Runtime Workbench -> system monitoring.
    Are there any other means to stop the process (other exception....) from an adapter module?
    Thanks
    Yann

    Hi,
    I have a java adapter module that decides whether the process should carry on or not.
    When I want to stop the process I throw an UnsupportedOperationException that is reported in Runtime Workbench -> system monitoring.
    Are there any other means to stop the process (other exception....) from an adapter module?
    Thanks
    Yann

  • Empty File handling and raise alert.

    Hi,
    We have requirement where we are doing file pass through. But client wants PI to raise alert when it receives 0 byte file.
    How can we achieve this using File/FTP/SFTP adapter when we are not reading the actual payload and doing only pass thru?
    Thanks,
    Vertika

    Hi Vertika,
    AFAIK - there is no standard way for pass through interface to raise alert (for empty file). so you need to develop adapter module to raise the alert for empty file.
    Please refer the help page
    Configuring the Sender File Adapter - Advanced Adapter Engine - SAP Library
    Under Handling of Empty Files, specify how empty files (length 0 bytes) are to be handled:
    Do Not Create Message No XI messages are created from empty files.The files are processed according to the selected processing mode.For example, if the processing mode is Delete, empty files are deleted in the source directory.
    Process Empty Files XI messages are created with an empty main payload.The files are processed according to the selected processing mode.
    Skip Empty Files No XI messages are created from empty files.Empty files are skipped and remain in the source directory.

  • Sending empty files using SFTP Adapter

    I am trying to send empty files using SFTP adapter. The interface has to send the file whether its empty file or containing data using SFTP adapter. I am using BizTalk Server 2013 R2. Is it a bug or the hotfix is already there for this issue.

    The issue here is not your SFTP not able to send 0KB files, but the file receive adapter that is receiving the file. The file adapter deletes 0 KB files and doest not transmit it further.
    If u have a ftp receive for example you should be able to send 0KB files.
    If u have a custom file receive adapter , is it handling 0KB files ?
    Regards &lt;br/&gt; When you see answers and helpful posts,&lt;br/&gt; please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

  • Process 0kb empty file and deliver to target directory

    Hello Experts,
    We had a requirements to process an empty file handling and send it to the receiver/target directory. We had configured to "Process Empty File" Handling and “Write Empty File. The 0KB file polling successfully and archived to the directory with empty payload, but the message output was never created/sent to the target directory. In smxi_moni error message displayed:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--
    Request Message Mapping
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>XIServer</SAP:Category>
      <SAP:Code area="MAPPING">CANNOT_READ_PAYLOAD</SAP:Code>
      <SAP:P1 />
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>Unable to read payload from the message object</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Since this is an empty file, there are no mappings involved.  Is there a way to that we could check for 0kb file? If it is empty file, we want to pass/place the empty file to the target directory and if it is not empty, we want the message to process in the standard way.

    Hi David,
    "Since this is an empty file, there are no mappings involved. "
    do you mean you didnt do the mapping at all cos it is empty file ?
    though it is empty file still you need to do the mapping as usually,but when you check the option process the empty file both in sender and receiver adapter ,then it will process even an empty file comes.if you dont check these options and you get an empty file during the process then the mapping will fail.
    in real time you don't know which one is empty file right,but her you know cos you are placing empty file.
    I think you got to do all the steps you do in eneral for a scenario and top on that you have to check process empty file in both sender and receiver adapters,but you may not see the payload in SXMB_MONI.
    but search in SDn you get lot stuff.

  • Empty file in sender comm channel

    i have issue with the empty files coming from the sender which are getting processed and getting saved in given file location.
    Now the problem is,these files donot contain data and rather just gets outputted with header and trailer with some dummy data usually spaces,some zeros,-- like this...,this makes the file size of some 444 bytes or 834 bytes but as it is not having any data,we need to goto SXMB_MONI everyday,check for files,if its empty,needs to  cancel them manually because it appears in red flag.
    To avoid this,i was thinking of setting the empty file option in processing of communication channel to SKIp messages or delete messages.
    Am i right in this approach?
    From other thread:
    "Currently when a process fails in PI due to an empty file the process needs to be manually set to u201Ccancelledu201D,where to locate in PI,what could be the problem and how it is to be solved.i have asked a similar question and hope that this error will help."
    please reply and show me right way of resolving this.
    thanks!
    cheers!
    Edited by: Prateek Raj Srivastava on Aug 19, 2010 10:54 AM

    Hi,
    As per ur req, its nt possible in this way.
    The empty file handling means the whole file is empty, the size is 0k.
    So in ur req, empty file means Header and Trailer present, but no data Records.
    we can achive this in following ways also,
    1.write an adapter module, to check if at all there is atleast there is 1 Data record, if not throw exception there itself.
    2.In the mapping check if at all there is any Data Record. If no Data Records raise exception and also the Alerts.
    Babu

  • Problem with „Empty-File Handling" in PI 7.11

    Hi,
    Iu2019m working in PI 7.11 with file adapter, Sender CC, option: Empty-File Handling: Process Empty Files.
    What I want to do is giving target file the system-date, if the source file is empty.
    But I always get a mapping error in RTWB: Premature end of file.
    It seems that the payload is empty.
    Any idea?
    Thanks a lot in advance!
    Rene Dong
    Edited by: Rene Dong on Aug 31, 2010 4:20 PM

    What I want to do is giving target file the system-date, if the source file is empty.
    The error you are getting makes sense. You should do a check in the mapping, if the payload is empty then use brute force to pass the system date.

  • Adapter Module for File Adapter

    I have a scenario where I have 2 related files (text file and a pdf file) for the message. I need to enhance the payload (content conversion from text file) with the size of the pdf file. I have developed a adapter module for this and it is working fine if there is 1 set of text and pdf file. But if there are more than 1 set of files, it is processing the first set and giving the below error for other files.
    "Error: com.sap.engine.services.ejb.exceptions.BaseTransactionRolledbackLocalException: Exception thrown in method process. The transaction is marked for rollback."
    Regards
    Yogesh

    check this thread :
    BaseTransactionRolledbackLocalException in custom adapter module
    Exceptions in Recievr Communication Channel with Adapter Module

  • How can transfer the read file name via own developed adapter module

    Hello experts,
    I want to know how I can handle the following issue:
    I developed a J2EE adapter module for the file adapter "sender" with the aim to read the file name of incoming files. Thereto I implement the following code like this:
    public ModuleData process(ModuleContext mc, ModuleData md) throws
    ModuleException
    Hashtable mp = (Hashtable)
    md.getSupplementalData("module.parameters");
    String fileName = null;
    if (mp != null)
    fileName = (String) mp.get("FileName");
    Now I get the filename which includes a order nr.  I need this order number to call a RFC Adapter via mapping. So my question is how can transfer this order nr to the RFC adapter?
    Kind regards,
    Fatih

    Hi,
    >> to read the file name of incoming files
    Use file adapter with Adapter specific identifiers selected.
    >>Thereto I implement the following code like this:
    use udf in message mapping and avoid module
    >>Now I get the filename which includes a order nr. I need this order number to call a RFC Adapter via mapping. So my question is how can transfer this order nr to the RFC adapter?
    use RFC Look up function in message mapping...
    Is module so necessary in this case???
    Regards
    Suraj

  • Dynamic configuration required in sender file - Adapter Module

    Hi Everybody,
    I am developing an Adapter Module in the file adapter (sender) using Adapter Specific Message Attributes.
    I am using Dynamic configuration inside the Module Process method in the adapter module.
    We are getting an error saying Dynamic Configuration cannot be resolved.
    Can anybody tell me the package to be used.
    Thanks,
    Zabiulla

    You can access the dynamic configuration in adapter module like this:
    Message msg = (Message) inputModuleData.getPrincipalData();
    String fileName = msg.getMessageProperty("http://sap.com/xi/XI/System/File", "FileName");
    You do not need any addition library besides the adapter module API.
    Hope that helps
    Stefan

  • Adapter module that dumps file to XI file directory

    I am given a task to find a way of backing up files the simpliest way. Currently, our config is in a scenario where there are 2 receiver, the receiving system (SAP) and the file backup (File adapter). I would want to reduce the config requirements by eliminating the file backup objects. And I am thinking of doing this by creating an adapter module to be included in the sender adapter.
    Another idea I could think of is the adapter module calls upon the file comm channel to do the file backup.
    The purpose of this research is to reduce object transport time and the mistakes the transport guys are doing on the file comm ch reconfiguration.
    To those who have experiences with adapter module development, is this idea feasible?

    Hi Jai,
    Thanks for your reply. That is the 2nd option I have in case the 1st one isnt possible.
    To further elaborate,
    Current config:
    we have two AS2 comm channels (sender and receiver) managing the connection with our external partners.
    File comm channels to backup the files we send and receive.
    The problem:
    We are having problems with the transport guys as they often make mistake on reconfiguring the file comm channel during transport.
    Requirements:
    Reduce object creation and tranport time.
    Solution proposal 1:
    The idea is to remove all existing objects related to file back up and have all the file back ups done by the adapter module. And this adapter module would become part of the as2 comm channels module processes.
    Hope this clarifies things more.

Maybe you are looking for

  • Help! The album artwork is not showing on my ipod!

    Hi! I bought a ipod nano 3 days ago and i'm really excited about it! But I tried everything to put an artwork for my songs. I went on iTunes and set the artwork by going into file - get info, and I added the image file in the artwork section. And I c

  • Video Setting greyed out

    Hi, I'm trying to find a way to control my blacks while digitizing footage in via a component cable and a aja Kona LHE card. I noticed that in the clip settings on the digitize window there are slioders for hue,sat, bright, Contras, black and white b

  • Keep servlet running after closing telnet

    I'm writing a chat application. I need to be able to have the servlet running all of the time, but it currently kills the process after I close telnet. I've tried running it normally and with an '&', but both result in the process dying after telnet

  • Converting Files to bytes

    hello Just want to know if there anyway to convert a text file to bytes. I can read the textfile but i want to convert them to bytes and store them.

  • Touchscreen not working with windows 8

    I just upgraded my touchsmart laptop to windows 8 and now the touchscreen doesn't work. Any suggestions?