cancel
Showing results for 
Search instead for 
Did you mean: 

FCC at sender

former_member335553
Active Contributor
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

> 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?

former_member335553
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Can you share you acutal FCC because I want to see what keyFieldValue you have used there..

former_member335553
Active Contributor
0 Kudos

Sorry for this delayed response

Recordsetstructure: Item,*

keyfieldvalue=Key

item.filedNames = Key, field1,field2....

item.keyFieldValue = 01

I am ignoring hte header in the doc. offset

and trailer I have skipped in the mapping

Thanks for responding

GabrielSagaya
Active Contributor
0 Kudos

Check wth my blog

/people/gabrielsagayaselvam.panneerselvam/blog/2009/08/31/solve-key-field-problem-using-structplain2xml-in-messagetransformationbean

former_member335553
Active Contributor
0 Kudos

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

vkaushik82
Active Participant
0 Kudos

if you are having key fields which can distingush your trailer , use it in mapping and produce only item fields which are required.

former_member335553
Active Contributor
0 Kudos

Hi

No keyfields in the incoming file and I have assigned the keyfield even then i am not able to get the right mesasge and also i am ignoring hte trailer mapping

Edited by: Anusha Ramsiva on Aug 18, 2010 9:40 AM

Former Member
0 Kudos

Hi,

why dont you consider one of the mandatory fileds from your item node in the condition to generate the target node.

This mandatory source filed will definitely be absent in ur trailer record and hence you can skip the tariler data from being mapped to proxy structure.

Regards,

Pragati.

former_member335553
Active Contributor
0 Kudos

Hi

When file is picked up in PI the trailer records are picked as item level records , Major issue is I am not ampping the trailer .

i had read through blogs but without using a module checking out how to retreive only the item fields

Former Member
0 Kudos

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

former_member335553
Active Contributor
0 Kudos

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

former_member335553
Active Contributor
0 Kudos

Hi

Even then i incude this script the os command is executed but unable to delete the last line of the file .Please advise ##

Former Member
0 Kudos

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

former_member335553
Active Contributor
0 Kudos

Yes it is deleting lastl line when standalone and if with PI it isn't

Could anyone please advise on the reason for the failure of the OS command before processing