cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Timestamp to Target Directory in RCVR CC

Former Member
0 Kudos

Hi All,

I have a requirement where I need to pick XML and PDF files and send it to a subdirectory  in the target directory . The subdirectory name should be current DATE (YYYYMM to be precise , for every month a new folder has to be created).

I googled a lot on these. But Since i am using PDF and not using Message mapping I cannot use Dynamic configuration in Message mapping (tried with XMLs ,it works!!). I cannot parse a PDF in message mapping easily.

So I decided to write a Adapter module. But later realised Dynamic Configuration cannot be used in Adapter module as we cannot use container.

I referred to the blogs :

http://wiki.sdn.sap.com/wiki/display/xi/adapter%20module%20pi%207.0%20set%20attachment%20name?bc=tru...

http://wiki.sdn.sap.com/wiki/display/xi/adapter%20module%20pi%207.0%20set%20attachment%20name?bc=tru...http://scn.sap.com/people/daniel.graversen/blog/2006/10/05/dynamic-configuration-in-adapter-modules

I have created a code something like this:

package sample;

import javax.ejb.CreateException;

import javax.ejb.SessionBean;

import javax.ejb.SessionContext;

import com.sap.aii.af.mp.module.*;

import com.sap.aii.af.ra.ms.api.*;

/**

* @ejbHome <{com.sap.aii.af.mp.module.ModuleHome}>

* @ejbLocal <{com.sap.aii.af.mp.module.ModuleLocal}>

* @ejbLocalHome <{com.sap.aii.af.mp.module.ModuleLocalHome}>

* @ejbRemote <{com.sap.aii.af.mp.module.ModuleRemote}>

* @stateless

*/

public class createDir implements SessionBean, Module{

          private SessionContext myContext;

          public void ejbRemove() {

          }

          public void ejbActivate() {

          }

          public void ejbPassivate() {

          }

          public void setSessionContext(SessionContext context) {

                    myContext = context;

          }

          public void ejbCreate() throws CreateException {

          }

public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)

                      throws ModuleException{

     try {

        Message msg = (Message) inputModuleData.getPrincipalData();

        //Payload payload = msg.getDocument();

        String fileName = msg.getMessageProperty("http://sap.com/xi/XI/System/File",

                                                 "FileName");

          String timestamp = msg.getMessageProperty("http://sap.com/xi/XI/System/File",

                                                 "sourceTimestamp");

          String Directory = msg.getMessageProperty("http://sap.com/xi/XI/System/File",

                                                 "Directory");

 

          timestamp = timestamp.substring(0,6);

       // if(fileName == null) fileName="default.txt";

        //payload.setContentType("text/plain;charset = \"UTF-8\";"+ "name=\"" + fileName + "\"");

 

          Directory = Directory + "/" + timestamp;

         msg.setMessageProperty("http://sap.com/xi/XI/System/File", "Directory",Directory);

           inputModuleData.setPrincipalData(msg);

    } catch (Exception e) {

        throw new ModuleException(e);

    }

    return inputModuleData;

}

}

I just need some guidance if this approach would work / or is there any other easier way? Please suggest if at all this is possible in an adapter module.

Please let me know if there is a better solution.

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

>>> But later realised Dynamic Configuration cannot be used in Adapter module as we cannot use container.

>>> Please suggest if at all this is possible in an adapter module


always the easiest way is to have a look at Daniel's blog

http://scn.sap.com/people/daniel.graversen/blog/2006/10/05/dynamic-configuration-in-adapter-modules

Regards,

Michal Krawczyk