cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Adapter Module is not calling Before Standard Adapter Module

former_member201264
Active Contributor
0 Kudos

Hi Experts,

My requirement is that, I need to set the Source Directory Path Value at run time before calling the Standard Adapter Module.

For this developed a custom Adapter Module code as below:

In the above delpoyed mdule i have written the as below to set the source directory value at runtime.

Here my intension is that I have to pick the file from a source directory based on environment.

If PI server is DEV then source directory ="//myeccserver/interface/payments/Bank/ECD";.

If PI server is TEST/QA then source directory ="//myeccserver/interface/payments/Bank/ECT";.

If PI server is PROD then source directory ="//myeccserver/interface/payments/Bank/ECP";.

See the below code from EJB Module and Deployed onto PI 7.3 Server from NWDS and used in File Sender Adapter Channel as below picture.

-----------------------------------------------------------------------------------------------

public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData) throws ModuleException{
 
Object obj = null; // Handler to get Principle data
Message msg = null; // Handler to get Message object

String sourceDirectory = null; //  sourceDirectory Name which is being processed

String sid = null;
AuditAccess  audit = null;
MessageKey key1;
  
try {
  
  obj = inputModuleData.getPrincipalData();
  msg = (Message) obj;

         MessagePropertyKey key = new MessagePropertyKey("Directory", "http://sap.com/xi/XI/System" );
         key1 = new MessageKey(msg.getMessageId(),msg.getMessageDirection());
         audit = PublicAPIAccessFactory.getPublicAPIAccess().getAuditAccess();

         sid = System.getProperty("SAPSYSTEMNAME"); 
   
         if (sid.equals("XID")){
                sourceDirectory = "//myeccserver/interface/payments/Bank/ECD";
            audit.addAuditLogEntry(key1, AuditLogStatus.SUCCESS, " sourceDirectory: "+sourceDirectory);
         }
  else{
        
          if (sid.equals("XIT")){
             sourceDirectory = "//myeccserver/interface/payments/Bank/ECT";
             audit.addAuditLogEntry(key1, AuditLogStatus.SUCCESS, " sourceDirectory : "+sourceDirectory);
         }
  else{
          if (sid.equals("XIP")){
             sourceDirectory = "//myeccserver/interface/payments/Bank/ECP";
             audit.addAuditLogEntry(key1, AuditLogStatus.SUCCESS, " sourceDirectory : "+sourceDirectory);
         }
        }
        }
        
       msg.setMessageProperty(key,sourceDirectory);

        inputModuleData.setPrincipalData(msg);

    } catch (Exception e) {
        throw new ModuleException(e);
    }

    return inputModuleData;
}

-----------------------------------------------------------------------------------------------

Pleat me know if any thing missed the above.

Regards,

Sreeni.

Accepted Solutions (0)

Answers (2)

Answers (2)

stefan_grube
Active Contributor
0 Kudos

What you are trying to do is not possible. You cannot influence the source directory from an adapter module. The adapter module is calles after the PI message is created.

It is normal that directories are different for dev, qa and prod. Just type the correct directory in the channel. There is no need for an adapter module which you have to change whenever the directories change.

former_member201264
Active Contributor
0 Kudos

Hi All,

For More clarity see the below picture:

Regards,

Sreei.

Former Member
0 Kudos

Hi,

One option could be.. Create dummy comm channel, and use the module to just place file into appropriate directory that you pass module.

In the Adapter module, 

1. connect to ftp server.

2. read the file from default DIR and copy it into environment specific directory which you can provide as module parameter.

Please let me know if that is the requirement you have.

Regards,

Akshay

Former Member
0 Kudos

In above case, your normal scenario execution will have another channel to poll the required directory for each environment.