cancel
Showing results for 
Search instead for 
Did you mean: 

RFC Lookup

Former Member
0 Kudos

I have written RFC Lookup.

But I am getting the belows errors

/usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:3: <identifier> expected import com.sap.aii.mappingtool.tf3.;import com.sap.aii.mappingtool.tf3.rt.;import java.util.;import java.io.; import java.lang.reflect.;import java.io.InputStream;import javax.xml.parsers.DocumentBuilder;import java.util.Iterator;import com.sap.aii.mapping.api.AbstractTrace;import java.util.Map;import org.w3c.dom.;import javax.xml.parsers.DocumentBuilderFactory;import import;import java.io.ByteArrayInputStream;import com.sap.aii.mapping.lookup.; ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:3: '.' expected import com.sap.aii.mappingtool.tf3.;import com.sap.aii.mappingtool.tf3.rt.;import java.util.;import java.io.; import java.lang.reflect.;import java.io.InputStream;import javax.xml.parsers.DocumentBuilder;import java.util.Iterator;import com.sap.aii.mapping.api.AbstractTrace;import java.util.Map;import org.w3c.dom.;import javax.xml.parsers.DocumentBuilderFactory;import import;import java.io.ByteArrayInputStream;import com.sap.aii.mapping.lookup.; ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:119: 'try' without 'catch' or 'finally' try { ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:130: illegal start of type } catch (Exception e) { ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:135: <identifier> expected trace.addInfo("RFC Request XML: " + docReq.toString()); ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:139: illegal start of type try { ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:151: <identifier> expected Document docRsp = null; ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:152: illegal start of type try { ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:167: <identifier> expected trace.addInfo("RFC Response XML: " + docRsp.toString()); ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:170: illegal start of type try { ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:176: <identifier> expected return res; ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:181: 'class' or 'interface' expected public static void main(String[] args) throws Exception{/!_$ClNRep_/_MM_RFCLookup_ st = new /!_$ClNRep_/_MM_RFCLookup_(); st.testExecute(); } ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:182: 'class' or 'interface' expected } ^ /usr/sap/XPD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map1f873e902d6811df9e460017a451d38e/source/com/sap/xi/tf/_MM_RFCLookup_.java:183: 'class' or 'interface' expected

Can someone please help to resolve this issue

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member187339
Active Contributor
0 Kudos

Hi Prabhu,

Are you using udf for RFC Lookup or dirctly java mapping?

Can you paste here the code?

Regards

Suraj

Former Member
0 Kudos

Hi All,

I have resolved the problem. There was an extra bracket in the code.

I need other help.

Currently i get the Output as below

<rfc:Z_COMP.Response xmlns:rfc="urn:sap-com:document:sap:rfc:functions"> <E_FLAG>Y</E_FLAG> </rfc:Z_COMP.Response>

But I just want the Output of the whole UDF to be the value in the "E_FLAG"

Can you tell me how can i do it. The Code written for parsing the document is as below:

{

Document docRsp = null;

try {

docRsp = builder.parse(result.getContent());

} catch (Exception e) {

trace.addWarning("Error when parsing RFC Response - " + e.getMessage());

return null;

}

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

String res = "";

try {

res = docRsp.getElementsByTagName(TAG_RES).item(0).getNodeValue();

} catch (Exception e) {

trace.addWarning("Result value not found in DOM - " + e);

return VALNOTFOUND;

}

return res;

}

Former Member
0 Kudos

Hi Prabhu,

If you exactly whatever mentioned in this document you should be able to solve your issue:

http://wiki.sdn.sap.com/wiki/display/Snippets/User-definedMappingFunctionforRFC+Lookup

Else can you give your compelte code so that somebody can help you out here.

Regards,

---Satish

Former Member
0 Kudos

Hello Satish,

Here is my complete code

{

final String CHANNEL_NAME = "cc_Rfc_Receiver_Lookup",

SERVICE = "Sys_EPD_110" ,

VALNOTFOUND = "VALUE_NOT_FOUND",

SAPRFCNS = "urn:sap-com:document:sap:rfc:functions",

TAG_FM = "Z_COMPARE_ADDRESS",

TAG_RES = "E_FLAG",

TAG_I_ALLIANCEID = "I_ALLIANCEID",

//TAG_I_OVRDFLAG = "I_OVRDFLAG",

TAG_I_PSTLZ = "I_PSTLZ",

TAG_I_CITY1 = "I_CITY1",

TAG_I_STATE = "I_STATE",

TAG_I_COUNTRY = "I_COUNTRY";

MappingTrace trace;

trace = container.getTrace();

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = null;

factory.setNamespaceAware(false);

factory.setValidating(false);

try {

builder = factory.newDocumentBuilder();

} catch (Exception e) {

trace.addWarning("Error creating DocumentBuilder - " + e.getMessage());

return null;

}

Document docReq = null;

try {

// Building up RFC Request Document

docReq = builder.newDocument();

Node root = docReq.appendChild(docReq.createElementNS(SAPRFCNS, TAG_FM));

root.appendChild(docReq.createElement(TAG_I_ALLIANCEID)).appendChild(docReq.createTextNode(I_ALLIANCEID));

//root.appendChild(docReq.createElement(TAG_I_OVRDFLAG)).appendChild(docReq.createTextNode(I_OVRDFLAG));

root.appendChild(docReq.createElement(TAG_I_PSTLZ)).appendChild(docReq.createTextNode(I_PSTLZ));

root.appendChild(docReq.createElement(TAG_I_CITY1)).appendChild(docReq.createTextNode(I_CITY1));

root.appendChild(docReq.createElement(TAG_I_STATE)).appendChild(docReq.createTextNode(I_STATE));

root.appendChild(docReq.createElement(TAG_I_COUNTRY)).appendChild(docReq.createTextNode(I_COUNTRY));

} catch (Exception e) {

trace.addWarning("Error while building RFC Request - " + e);

return null;

}

trace.addInfo("RFC Request XML: " + docReq.toString());

// Lookup

Payload result = null;

try {

Channel channel = LookupService.getChannel(SERVICE, CHANNEL_NAME);

RfcAccessor accessor = LookupService.getRfcAccessor(channel);

InputStream is = new ByteArrayInputStream(docReq.toString().getBytes());

XmlPayload payload = LookupService.getXmlPayload(is);

result = accessor.call(payload);

} catch (LookupException e) {

trace.addWarning("Error during lookup - " + e);

return null;

}

// Parsing RFC Response Document

Document docRsp = null;

try {

docRsp = builder.parse(result.getContent());

} catch (Exception e) {

trace.addWarning("Error when parsing RFC Response - " + e.getMessage());

return null;

}

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

String res = "";

try {

res = docRsp.getElementsByTagName(TAG_RES).item(0).getNodeValue();

} catch (Exception e) {

trace.addWarning("Result value not found in DOM - " + e);

return VALNOTFOUND;

}

return res;

}

The Output of this RFC lookup is

<RFC Response XML: <rfc:Z_COMPARE_ADDRESS.Response xmlns:rfc="urn:sap-com:document:sap:rfc:functions"> <E_FLAG>Y</E_FLAG> </rfc:Z_COMPARE_ADDRESS.Response>

But the field value shows null

Thanks

Former Member
0 Kudos

Changed the code

From:

{

res = docRsp.getElementsByTagName(TAG_RES).item(0).getNodeValue();

}

To:

{

res = docRsp.getElementsByTagName(TAG_RES).item(0).getFirstChild().getNodeValue();

}

Thanks

former_member204873
Contributor
0 Kudos

hi,

Are you using any try block in your code?

in trace it is visible " 'try' without 'catch' or 'finally' try "

Check this wiki:

http://wiki.sdn.sap.com/wiki/display/Snippets/User-definedMappingFunctionforRFC+Lookup

Thanks.

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Prabhu,

Format your question,its not in understandable format.

Regards,

Raj