cancel
Showing results for 
Search instead for 
Did you mean: 

Reg. RFC look up

former_member333459
Participant
0 Kudos

Hi All,

I am working on RFC look up. My Scenario is IDoc to IDoc. The IDoc has a segment say E1 where the occurence is 0---5 and two fields inside that i.e. QUALF and IDTNR. The requiremnt is like when QUALF is equal to 002 then fetch the value of material number from SAP and map to IDTNR. Also this material number is picked only when QUALF is equal to 003 and the field IDTNR has some value i.e. article number in SAP. So I need to get value of the material number equal to this article number.

I am using RFC look up for this mapping condition in order to fetch value from SAP.

Can anyone help me on this to configure the RFC look up in PI?

Thanks and Regards,

Neethu

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Neethu,

check the thread below:

http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70d90a91-3cf4-2a10-d189-bfd37d9c3....

However, we have created our own library for RFC lookup.

Sample Code:

trace = container.getTrace();

String m = "<?xml version="1.0" encoding="UTF-8"?>" +

"<ns0:ZSCE_RFC_LOOKUP" +

" xmlns:ns0="urn:sap-com:document:sap:rfc:functions"><TANUM>" + a +

"</TANUM><VSOLA>" + b +

"</VSOLA></ns0:ZSCE_RFC_LOOKUP>" ;

RfcAccessor accessor = null;

ByteArrayOutputStream out = null;

InputStream in = null;

try

{

Channel channel = LookupService.getChannel("BS_RFC_Lookup","CC_RFC_RCVR");

accessor = LookupService.getRfcAccessor(channel);

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

XmlPayload payload = LookupService.getXmlPayload(inputStream);

Payload result = accessor.call(payload);

in = result.getContent();

}catch(LookupException e)

{

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

}

String txt = "";

InputStreamReader inR = new InputStreamReader(in);

BufferedReader buf = new BufferedReader(inR);

String line;

while ( ( line = buf.readLine() ) != null )

{

txt = txt + line;

}

/*

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = null;

factory.setNamespaceAware(false);

factory.setValidating(false);

Document docRsp = null;

try {

docRsp = builder.parse(in);

} catch (Exception e) {

trace.addWarning("Error when parsing RFC Response1 - " + e.getMessage()); return null;

} */

//trace.addInfo("RFC Response XML: " + docRsp.toString());

if (accessor!=null) {

try {

accessor.close();

} catch (LookupException e) {

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

}

}

return txt;

Thanks,

Sushama

former_member333459
Participant
0 Kudos

Hi Sushama,

Can you please explain me what is a and b in this piece of coding?

String m = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +

"<ns0:ZSCE_RFC_LOOKUP" +

" xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><TANUM>" + a +

"</TANUM><VSOLA>" + b +

"</VSOLA></ns0:ZSCE_RFC_LOOKUP>" ;

Thanks in advance.

Regards,

Neethu

Former Member
0 Kudos

These must be the input string variables you pass to your RFC lookup function (UDF) ...

Rgds

Chris

former_member333459
Participant
0 Kudos

Hi All,

For my requirement I have used this UDF,

String content = "";

MappingTrace importanttrace;

importanttrace = container.getTrace();

// filling the string with our RFC-XML (with values)

String m ="<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:ZSD_EAN_MATERIAL_GET xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><P_EAN11></P_EAN11></ns0:ZSD_EAN_MATERIAL_GET>" ;

RfcAccessor accessor = null;

ByteArrayOutputStream out = null;

try

{

// 1. Determine a channel (Business system, Communication channel)

Channel channel = LookupService.getChannel("RD9","CC_RFC_RECEIVER_LOOKUP_I040");

// 2. Get a RFC accessor for a channel.

accessor = LookupService.getRfcAccessor(channel);

// 3. Create a xml input stream representing the function module request message.

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

// 4. Create xml payload

XmlPayload payload = LookupService.getXmlPayload(inputStream);

// 5. Execute lookup.

Payload result = accessor.call(payload);

InputStream in = result.getContent();

out = new ByteArrayOutputStream(1024);

byte[] buffer = new byte[1024];

for (int read = in.read(buffer); read > 0; read = in.read(buffer)) {

out.write(buffer, 0, read);

}

content = out.toString();

}

catch(LookupException e)

{

importanttrace.addWarning("Error while lookup " + e.getMessage() );

}

catch(IOException e)

{

importanttrace.addWarning("Error " + e.getMessage() );

}

finally

{

if (out!=null) {

try {

out.close();

} catch (IOException e) {

importanttrace.addWarning("Error while closing stream " + e.getMessage() );

}

}

// 7. close the accessor in order to free resources.

if (accessor!=null) {

try {

accessor.close();

} catch (LookupException e) {

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

}

}

}

//returning the result u2013 RFC-XML.response

return content;

While executing this UDF I am getting the output as:

<?xml version="1.0" encoding="UTF-8"?><rfc:ZSD_EAN_MATERIAL_GET.Response xmlns:rfc="urn:sap-com:document:sap:rfc:functions"><Materialnumber></Materialnumber></rfc:ZSD_EAN_MATERIAL_GET.Response></IDTNR>

<KTEXT />

instead of value

Can anyone suggest me on this?

Thanks and Regards,

Neethu

Former Member
0 Kudos

you're passing an empty P_EAN11 value (<P_EAN11></P_EAN11>) is that normal ? Your UDF should accept at least one input param (let's say a as a String) and add it to the input RFC msg :

String m ="<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:ZSD_EAN_MATERIAL_GET xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><P_EAN11>" + a + "</P_EAN11></ns0:ZSD_EAN_MATERIAL_GET>" ;

Former Member
0 Kudos

Hi,

you can use the standard RFC lookup function in PI 71- check this out

http://help.sap.com/saphelp_nwpi71/helpdata/en/33/1ec6ced273493a993a80c2301c03da/frameset.htm

if you are in PI 70 where the standard function is not available, you have to write your UDF check this document

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70d90a91-3cf4-2a10-d189-bfd37d9c3...

regards,

francis

Former Member
0 Kudos

Hi,

Before posting a question in Forum, please check if it is already available.

There are lot of Blogs and threads in forum, about this.

Please search once..

Then if u are facing any problem , u can post the question...

Babu