on 10-28-2013 6:32 AM
Hi All,
I a working on File to FTP Scenario to pull pdf file (the Filename scheme is without pdf extension but the file type is pdf) and upload on FTP Server.
Now, since the sender file name do not have .pdf extension, I am not able to get the same .pdf file at receiver FTP Also.
The file at receiver side is of FileType PDF but its not opening directly as pdf file.Instead it asks every time how to open the file.
Can any one suggest me how i can achieve this .pdf extension explicitly at target side.
Note: There is no ESR in this scenario.
Current parameters settings in channels
Sender File Name Scheme - *
Receiver File Name Scheme - *.pdf
Using ASMA attributes to pull same file name from sender to receiver.
Thanks
Neha
Hi Neha,
Check the below links you can try in this scenario:
http://wiki.scn.sap.com/wiki/display/XI/Dynamic+file+name+for+pass-through+scenario
Regards,
Pranav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Neha
Either you need to create some dummy interface in ESR and create an dummy mapping which will contain the UDF for changing the file name.
UDF code:
String FileName_input = "";
try
{
DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey Filekey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
FileName_input=conf.get(Filekey)+".pdf";
conf.put(Filekey,FileName_input);
return "";
}
catch (Exception e)
{
}
Or you can create this adapter module and use it in the communication channel
Module Code:
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.io.InputStream;
import com.sap.aii.af.lib.mp.module.Module;
import com.sap.aii.af.lib.mp.module.ModuleContext;
import com.sap.aii.af.lib.mp.module.ModuleData;
import com.sap.aii.af.lib.mp.module.ModuleException;
import com.sap.engine.interfaces.messaging.api.Message;
import com.sap.engine.interfaces.messaging.api.MessageKey;
import com.sap.engine.interfaces.messaging.api.MessagePropertyKey;
import com.sap.engine.interfaces.messaging.api.PublicAPIAccess;
import com.sap.engine.interfaces.messaging.api.PublicAPIAccessFactory;
import com.sap.engine.interfaces.messaging.api.XMLPayload;
import com.sap.engine.interfaces.messaging.api.auditlog.AuditAccess;
import com.sap.engine.interfaces.messaging.api.auditlog.AuditLogStatus;
import com.sap.engine.interfaces.messaging.api.exception.InvalidParamException;
import com.sap.engine.interfaces.messaging.api.exception.MessagingException;
public class GenerateFilename implements Module, SessionBean {
private static final long serialVersionUID = 1L;
private AuditAccess Audit = null;
private MessageKey amk = null;
public ModuleData process(ModuleContext moduleContext,
ModuleData inputModuleData) throws ModuleException {
Message mes = null;
String filename = "";
XMLPayload xmlData = null;
mes = (Message) inputModuleData.getPrincipalData();
xmlData = mes.getDocument();
// For Audit Log Fetch the Audit Message key from the message.
amk = new MessageKey(mes.getMessageId(), mes.getMessageDirection());
PublicAPIAccess pa;
try {
pa = PublicAPIAccessFactory.getPublicAPIAccess();
} catch (MessagingException me) {
ModuleException e1 = new ModuleException(me);
throw e1;
}
MessagePropertyKey mpk = new MessagePropertyKey("FileName","http://sap.com/xi/XI/System/File");
String NewFileName = mes.getMessageProperty(mpk)+".pdf";
try {
mes.setMessageProperty(mpk, NewFileName);
} catch (InvalidParamException e2) {
Audit.addAuditLogEntry(amk, AuditLogStatus.ERROR,
"Error Target filename : " + filename);
ModuleException e1 = new ModuleException(e2);
throw e1;
}
return inputModuleData;
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Neha,
If you want to rename the file via script you can read Raja Sekhar Reddy's blog
http://scn.sap.com/people/rajasekhar.reddy14/blog/2011/04/19/logging-archiving-and-changing-the-file...
Thinking about this theme, I agree with Amit, you should develop an own adapter module to rename the file. Right now i cant find any example code, but i remember a blog wich its code worked with file receiver.
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I would suggest you to write a small piece of code (AM) and rename files if ur sender system i.e. SAP (if i am not wrong) is not adding file extension.
Using scripts also u can change the filename, but personally speaking i don't like that option just because if by any reasons script executions fails PI message won't go into error state - in short a dicey situation.
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.