cancel
Showing results for 
Search instead for 
Did you mean: 

Integraiton scenario to read SAP table

hashtag_siva
Explorer
0 Kudos

Hi,

I have a integration scenario where I get a message from legacy and needs to be written as file in ECC. The legacy file has two parts, the first part has 3 characters which I should use and read a table ( the custom table can be in XI or ECC) and get the file path and file name. After I get file path and file name I need to strip out the first part of the legacy message and map the second part of the message.

The mapped document should be written as a file in ECC using the file name and file path retrieved above ( i need to provide file name and file path in the channel). Can anyone help on how to achieve this?

Thanks in advance for your help.

Accepted Solutions (1)

Accepted Solutions (1)

wilsonrsantos
Active Participant
0 Kudos

Hi Developer !

You can create the table to parametrize the file name and path in ECC, and create a simple ABAP Function as Remote Enabled Module(a RFC Function) to read this table and returns the file name and path.

So, in XI, you will design an interface file-to-file, and in the message mapping, you will need to add some java code to run a RFC lookup, to call the RFC that will get the file name and path. You can find examples of RFC Lookups at these links:

/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups

(the link above shows a very interesting example - it read contents of any table, using the standard RFC function RFC_READ_TABLE - pay attention for this blog)

/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer

(this another example makes use of a configured RFC Receiver channel, it´s very interesting too)

After this step, what you will need to set the filename and path to the receiver file adapter, is to use the variable substitution. Variables substitution allows you to use fields existing in the XML message to set some fields of the Communication Channel, like file name and path(great, no ?).

You can find information about Variable Substitution at:

http://help.sap.com/erp2005_ehp_03/helpdata/EN/bc/bb79d6061007419a081e58cbeaaf28/frameset.htm

I hope this helps you !

Best regards,

Wilson

*************************************************************************************

Hy again Developer !

I think that this link may be usefull for you too:

http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm

Use the information in it joined to the information at the link for help.sap.com mentioned in the first part of this message, that explain the configuration of the receiver file adapter.

Thank you for your attention, and best regards,

Wilson

Edited by: Wilson Santos on Jun 24, 2008 8:38 PM

Answers (4)

Answers (4)

hashtag_siva
Explorer
0 Kudos

I knew the mistake I did. The problem got fixed. Thanks Wilson for all your help.

hashtag_siva
Explorer
0 Kudos

Thanks Wilson. But after I create function in mapping to make RFC lookup I get below error

classpath_resolver/Mapb5a51f10424f11ddb17000101816a382/source/com/sap/xi/tf/_MM_O_MQ_I_SAP_.java:84: cannot resolve symbol symbol : method getChannel (java.lang.String[],java.lang.String[]) location: class com.sap.aii.mapping.lookup.LookupService Channel channel = LookupService.getChannel( businessSystem, communicationChannel );

/classpath_resolver/Mapb5a51f10424f11ddb17000101816a382/source/com/sap/xi/tf/_MM_O_MQ_I_SAP_.java:110: incompatible types found : java.lang.String required: com.sap.aii.mappingtool.tf3.rt.ResultList result = node.getNodeValue();

hashtag_siva
Explorer
0 Kudos

I created function to lookup RFC in ECC.

imports were =

javax.xml.parsers.DocumentBuilder;

javax.xml.parsers.*;

javax.xml.transform.dom.DOMSource;

org.xml.sax.*;

java.io.*;

com.sap.aii.mappingtool.tf3.rt.ResultList;

org.w3c.dom.*;

com.sap.aii.mapping.*;

com.sap.aii.mapping.lookup.*;

javax.xml.transform.*;

javax.xml.transform.stream.StreamResult;

com.sap.aii.mapping.lookup.Payload;

String rfcXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:ZRFC_XI_MQ_VALUE_TABLE_READ xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><I_DIRECTION>" + cBOUND + "</I_DIRECTION><I_RECIEVER_ID>" + wf_RPARTID +"</I_RECIEVER_ID><I_SENDER_ID>" + wf_SPARTID +"</I_SENDER_ID><I_SEQNO>" + wf_SEQNO "</I_SEQNO><I_TRANS_TYPE>" wf_TRNTYP + "</I_TRANS_TYPE></ns0:ZRFC_XI_MQ_VALUE_TABLE_READ>";

AbstractTrace trace = container.getTrace();

RfcAccessor accessor = null;

ByteArrayOutputStream out = null;

try

{

//determine the communication channel

Channel channel = LookupService.getChannel( businessSystem, communicationChannel );

//get RFC Accessor for the channel

accessor = LookupService.getRfcAccessor(channel);

//create XML input stream

InputStream inputStream = new ByteArrayInputStream(rfcXML.getBytes());

//create XML Payload

XmlPayload payLoad = LookupService.getXmlPayload(inputStream);

//execute lookup

Payload payloadResult = null;

payloadResult = accessor.call(payLoad);

InputStream in = payloadResult.getContent();

//DOM structure for input XML

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();

Document document = builder.parse(in);

NodeList list = document.getElementsByTagName("E_FILE");

Node node = list.item(0);

if ( node != null )

{

node = node.getFirstChild();

if ( node != null )

{

result = node.getNodeValue();

if ( result == null )

{

trace.addWarning( "Error no file path found" );

}

}

}

//free resources

if ( accessor != null )

{

try

{

accessor.close();

}

catch (LookupException e)

{

trace.addWarning("Error while closing accessor" + e.getMessage() );

}

}

}

catch (Exception e)

{

trace.addWarning("Error" + e);

}

I am getting below error when activating the mapping

Source code has syntax error: E:/usr/sap/<systemid>/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapb5a51f10424f11ddb17000101816a382/source/com/sap/xi/tf/_MM_O_MQ_I_SAP_.java:84: cannot resolve symbol symbol : method getChannel (java.lang.String[],java.lang.String[]) location: class com.sap.aii.mapping.lookup.LookupService Channel channel = LookupService.getChannel( businessSystem, communicationChannel ); ^ E:/usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapb5a51f10424f11ddb17000101816a382/source/com/sap/xi/tf/_MM_O_MQ_I_SAP_.java:110: incompatible types found : java.lang.String required: com.sap.aii.mappingtool.tf3.rt.ResultList result = node.getNodeValue(); ^ 2 errors

former_member181962
Active Contributor
0 Kudos

HI,

You can probably try out a FILE-XI-PROXY scenario.

In the inbound asynchronous method, you can write the code to select the data from the custom table and writing the file to the application server on the R/3 system.

Regards,

Ravi Kanth Talagana