on 08-18-2010 8:29 AM
Hi
I have FCC at sender picking up a csv file . Header comprises field name and at item level is the values for the field names and at trailer we have record count .
need to ignore header and trailer and the item data is passed to proxy strcuture
Document offset been done to ignore header but iwhen i see the mesage in sxmb_moni , I am unable to get the trailer but the trailer field is again taken as the item level .
File - no key specified
Docno,docdate,invoiceno,passname
500,20.07.2010,123,AAAA
*
*
Recordcount,5
In datatype i have not defined the header but onky with item and trailer record.
fcc
item.fieldnames
item.fieldSeparator
item.endSeparator
item.keyFieldvalue
when i see the message in moni , incoming message with the item and trailer is not distinguished and trailer is taken as a item level data itslef Please advise where I am going wrong
> need to ignore header and trailer and the item data is passed to proxy strcuture
Why don't you pick the entire file and then inside mapping just map the ITEM data to Proxy structure.
I don't see any problem in doing that, what you say?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks Sarvesh
Issue was that it had taken the trailer record also as a item level that resulted in error
As we had the record count as th e trailer and that was a fixed field at trailer . I had given the end separator as the recordcount and passed the file as is .Sorry still in error
Taking the trailer level as the item data
CSV file
DocumentNo,DocumentDate,DocumentType,PassengerName,
530-700010-001,28/07/2010,INV,SMITH A MR,
530-700016-001,26/07/2010,INV,TEST B MR,
530-700016-002,26/07/2010,INV,TEST B MR,
530-700123-001,03/07/2010,C/N,SMITH A MR,
RecordCount,4
Edited by: Anusha Ramsiva on Aug 19, 2010 12:43 PM
Hi
Checked out all possiblities and finally the adapter module is here for removing trailer record but instead using byte array stream I have acquired thexml in a string
public byte[] convert(byte src[],String msgType,String nameSpace) throws Exception {
String xmldata = "";
I am getting an parsing an empty document.root nde expected. Please advise
Created on 29-Aug-2010
*
To change the template for this generated file go to
Window>Preferences>Java>Code Generation>Code and Comments
*/
package trailerPackage;
import java.io.ByteArrayInputStream;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import com.sap.aii.af.mp.module.Module;
import com.sap.aii.af.mp.module.ModuleContext;
import com.sap.aii.af.mp.module.ModuleData;
import com.sap.aii.af.mp.module.ModuleException;
import com.sap.aii.af.ra.ms.api.Message;
import com.sap.aii.af.ra.ms.api.MessageDirection;
import com.sap.aii.af.ra.ms.api.XMLPayload;
import com.sap.aii.af.service.auditlog.Audit;
import com.sap.aii.af.service.auditlog.AuditDirection;
import com.sap.aii.af.service.auditlog.AuditLogStatus;
import com.sap.aii.af.service.auditlog.AuditMessageKey;
/**
@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 TrailerClass implements SessionBean, Module
{
private SessionContext myContext;
AuditMessageKey amk;
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 mc,
ModuleData imd)
throws ModuleException {
Object obj = null;
Message msg = null;
String msgType = null;
String nameSpace = null;
try {
obj = imd.getPrincipalData();
msg = (Message) obj;
msgType = (String) mc.getContextData("msgType");
nameSpace = (String) mc.getContextData("nameSpace");
if (msg.getMessageDirection()== MessageDirection.INBOUND)
amk = new AuditMessageKey(msg.getMessageId(),AuditDirection.INBOUND);
else
amk = new AuditMessageKey(msg.getMessageId(),AuditDirection.OUTBOUND);
XMLPayload xp = msg.getDocument();
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO: Now got the xml payload object.");
if (xp != null)
{
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO: Now calling the Convert Method to convert CSV to XML.");
byte by[] = convert(xp.getContent(),msgType,nameSpace);
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO: Conversion Done Successfully.");
xp.setContent(by);
}
imd.setPrincipalData(msg);
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO: Principle data is set successfully.");
} catch (Exception e)
{
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO: Module Exception Caught .");
ModuleException me = new ModuleException(e);
throw me;
}
return imd;
}
public byte[] convert(byte src[],String msgType,String nameSpace) throws Exception {
String xmldata = "";
try {
String input = new String(src);
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO: Conversion Started.");
String tmp1 = input.substring(0, input.indexOf("<Trailer>")) ;
String tmp2 = input.substring(input.indexOf("</Trailer>")+10) ;
xmldata = tmp1 + tmp2 ;
}
catch (Exception e)
{
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO: Exception in Convert Method.");
}
return xmldata.getBytes();
}
}
Edited by: Anusha Ramsiva on Aug 31, 2010 11:59 AM
Edited by: Anusha Ramsiva on Aug 31, 2010 5:02 PM
Edited by: Anusha Ramsiva on Aug 31, 2010 5:04 PM
if you are having key fields which can distingush your trailer , use it in mapping and produce only item fields which are required.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anusha,
Probably you can try writing a script which ignores the last line of the file and call the script before the message processing in your sender communication channel so that you dont have the trailer record and then in content conversion you can ignore the header line.
Regards,
---Satish
Hi satish
yes I started using the script but still there is an issue because I am unsing wild card in the filename
@ECHO OFF
cd /home/Dev_transfer/XXX/pi/ABC/In
Filename = ABC*.CSV
mv -f $Filename ABC_TEMP
sed '$d' ABC_TEMP > $Filename
and the last move operation would not be succesful since it has a wild card .checking out hte ways for it
Edited by: Anusha Ramsiva on Aug 18, 2010 4:56 PM
Hi Anusha,
Is the script able to delete the last line?
If yes and when you use it with PI if it is not doing the job then the only options come to my mind is with either writing a module or create two interfaces and in the first interface first delete the header and trailer lines calling the script and writing to a different folder. Then your second interface will pick the new file and process it. I know it is not a straight solution but just a work around I could think of.
Regards,
---Satish
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.