cancel
Showing results for 
Search instead for 
Did you mean: 

Receiver RFC error- RfcClientException: functiontemplate from repository wa

Former Member
0 Kudos

Hi All,

I am in an R/3(IDOC) - XI - 3rd party(File) scenario. Need to do a lookup to R/3 from XI before file is sent to 3rd party system.

For RFC, I followed various blogs( currently using Michaels blog https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1... )

However I get the error in RWB:

"Error in processing caused by: com.sap.aii.af.rfc.afcommunication.RfcAFWException: error while processing message to remote system:com.sap.aii.af.rfc.core.client.RfcClientException: functiontemplate from repository was <null>"

Came across note : 730870 and it talks of metadata refresh. So I reimported the function module into IR, reactivated the comm channel but still the same error.

Do you guys have any idea why it could be happening.

To sum up,for RFC lookup I have created

1. RFC enabled FM in R/3

2. Comm Channel in ID

3. UDF (supplied the above comm channel and Buss syst name here and FM xml signature)

4. Used the UDF in existing Message mapping

( I have not created any separate Interface mappings for this...is it OK)

( My RFC function module will return a single field, but when I import RFC FM in IR, I do not see the return field, it has only the FM incoming fields...is that OK.....??? )

Any help/pouinters are welcome

Many thanks

Shirin

Accepted Solutions (1)

Accepted Solutions (1)

former_member181985
Active Contributor
0 Kudos

Hi Shirin,

I guess your scenario is,

R/3 --> XI --> File

My question is why you are doing RFC lookup when you are directly sending data from R/3.

The reason for error is: you are using a server channel (RFC Communication channel with sender mode) instead of a client channel(RFC Communication channel with receiver mode) .

I mean you are using RFC sender communication channel name in the UDF .

Thanks,

Gujjeti.

Edited by: Praveen Gujjeti on Sep 25, 2008 2:15 PM

Former Member
0 Kudos

Hi Praveen,

Yes its an R/3 - XI - 3rd Party scenario.

To cut the story short, I am doing lookup to R/3 Due to some file sequencing requirements. This is the only option left as getting this data in the IDOC initially didnt help.

As you have pointed, can you help let me know how can I correct it in the UDF. (I am a javao novice, so appreciate if you could help me with it)

I have attached the UDF code below.

Many thanks

Shirin

Imports: java.io.*;com.sap.aii.mapping.lookup.*;

   //write your code here
  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:ZIFMS_GET_NEXT_NUMBER>xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><I_NR_RANGE_NR>01</I_NR_RANGE_NR><I_OBJECT>ZIFMS_INT</I_OBJECT></ns0:ZIFMS_GET_NEXT_NUMBER> ";

RfcAccessor accessor = null;
ByteArrayOutputStream out = null;
try
{
//1. Determine a channel (Business System, Communication channel)
Channel channel = LookupService.getChannel("BS_IFMS_GENIUS_UAT" , "CC_RFC_LOOKUP");

//2. Get a RFC accesor for a channel.
accessor = LookupService.getRfcAccessor(channel);

//3. Create a xml input stream representing the FM 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;

former_member181985
Active Contributor
0 Kudos

Hi Shrini,

As per your explanation,

I understood the following.

your scenario is some thing R/3(BAPI ONE)>XI>File

For file sequencing (sequnce file name generator) purposes you have one more BAPI say BAPI TWO and you want to read one of the field from this BAPI TWO and then for the File Name.

Let me know if my understanding is wrong.......

Thanks,

gujjeti.

Former Member
0 Kudos

Hi Praveen,

My scenario is R/3 (IDOC) - XI - 3rd party(File)

So after my IDOC has reached XI, before converting it into a File, I need to do a RFC to R/3, pick the latest number from a number range and use this in my file name. ( As mentioned earlier, I can not use this number range object during intial transfer of IDOC and hence an RFC call).

Apprecaite if you could let me know whats wrong in my UDF?

Many thanks

Shirin

former_member181985
Active Contributor
0 Kudos

Hi Shrini,

I just tested your code and nothing wrong in that code.

only thing is I used my own BAPI, channel and business sytem and the query payload.

Thanks,

Gujjeti.

former_member181985
Active Contributor
0 Kudos

Hi Shrini,

I was able to produce the error that you are getting.

This can happen if your RFC receiver channel is pointing to wrong R/3 server where the BAPI doesnt exist.

Check the paramerts again.

i.e., you have created a Z - BAPI in a R/3 system so point your RFC Receiver communication channel to that server. This will definitely solve your problem.

Also I am not sure if we have to import the RFC structure in IR . But my guess is, import is not required.

Thanks,

Gujjeti.

Former Member
0 Kudos

Hi Praveen,

I have changed the RFC server deatils and for a moment the initial error disappeared and came up with another error

Error in processing caused by: com.sap.aii.af.rfc.afcommunication.RfcAFWException: error while processing message to remote system:com.sap.aii.af.rfc.core.client.RfcClientException: could not convert request from XML to RFC:com.sap.mw.jco.JCO$Exception: (130) JCO_ERROR_XML_PARSER: Expecting a tag to begin with '<' instead of 'x', in "XT_NUMBER>xmlns:ns0="

To correct this error I changed my UDF to have a '<' tag but then it again gave back the original error of 'functiontemplate from repository was <null>'

Just for your ref, I changed the initial part of my UDF code here

//Filling the string with our RFC-XML (With Values)
String m = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:<ZIFMS_GET_NEXT_NUMBER>xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><I_NR_RANGE_NR>01</I_NR_RANGE_NR><I_OBJECT>ZIFMS_INT</I_OBJECT></ns0:ZIFMS_GET_NEXT_NUMBER> ";

Really appreciate your help Praveen.

Many thanks

Shirin

former_member181985
Active Contributor
0 Kudos

Hi Shrini,

I can confirm that importing the RFC structure is not mandatory. As per the article the author "Michal Krawczyk" imports it only to have the query payload in the UDF so that there will less chance for the incorrect query payload.

Thanks,

Gujjeti.

former_member181985
Active Contributor
0 Kudos

Hi,

Hmm you have given the wrong payload.

Give this:

String m = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:ZIFMS_GET_NEXT_NUMBER xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><I_NR_RANGE_NR>01</I_NR_RANGE_NR><I_OBJECT>ZIFMS_INT</I_OBJECT></ns0:ZIFMS_GET_NEXT_NUMBER>"

compare yours & mine, you will know the difference.

Thanks,

Gujjeti.

Former Member
0 Kudos

Hi Praveen,

Thanks a ton!!

This has solved half of the problem as I can see it fetching the data from SAP. However messages are failing in XI now.

I guess I was expecting just a single value from this RFC but I guess its returning a string like

<?xml version="1.0" encoding="UTF-8"?><rfc:ZIFMS_GET_NEXT_NUMBER.Response xmlns:rfc="urn:sap-com:document:sap:rfc:functions"><E_NUMBER>0000000000000009</E_NUMBER></rfc:ZIFMS_GET_NEXT_NUMBER.Response>.DFR

I am interested in only getting the value '000000000000000009' in the above string. Is my UDF code capable of doing that.

Many thanks

Shirin

Former Member
0 Kudos

HI Praveen,

Thanks for all the help. Really appreciated.

I managed to sort it by following another Blog which showed how to retreive the function module return parameters.

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

This solved all the issues.

Thanks once again

Shirin

former_member181985
Active Contributor
0 Kudos

Happy to help you......:)

Its nice that your closing this thread with an extra supporting doc which will help the other people.

Thanks,

Gujjeti.

Answers (2)

Answers (2)

Former Member
0 Kudos

check your RFC parameters....if everything is fine...do a complete cache refresh along with delta refresh...

prateek
Active Contributor
0 Kudos

( I have not created any separate Interface mappings for this...is it OK)

Yes. Its ok.

My RFC function module will return a single field, but when I import RFC FM in IR, I do not see the return field, it has only the FM incoming fields...is that OK.....???

Important is that you could see both request and response messages in XI. Actually, u need not import the RFC in XI.

Recheck the RFC receiver channel that it is pointing to correct client and the user used has proper authorizations to import the metadata.

Regards,

Prateek

Former Member
0 Kudos

HI Prateek,

Thanks for the info.

My RFC comm channel parameters are configured correctly so prob might be somewhere else..

How do I know if my user-id has all the authorisations to import Metadata?

Regards

Raj