on 02-23-2010 1:58 PM
Hi,
We have a UDF for RFC look up.
In the UDF, we have the following code:
String recService = "";
recService = (String) container.getTransformationParameters().get("ReceiverService");
if (recService.equals("Test_ReceiverService")) recService = "RQ1";
Other lines in the code are not of much relevance, hence I am not writing it here.
The problem is with the second line of the code "recService = (String) container.getTransformationParameters().get("ReceiverService");
We have not used any "set()" function to keep any parameter values in the global container.
But still the 'recService' is carrying the value "Test_ReceiverService".
Kindly help me in identifying where this value is coming from.
Also I am providing the entire logic of UDF here for your reference.
-
String content = "";
String werks = "";
String lgort = "";
String insmk = "";
MappingTrace importanttrace;
importanttrace = container.getTrace();
// filling the string with our RFC-XML (with values)
String m = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:ZRFC_CCA_CONVERT_WAREHOUSE xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><DUTYPAID>" + dutyPaid + "</DUTYPAID><WAREHOUSE>" + warehouse + "</WAREHOUSE></ns0:ZRFC_CCA_CONVERT_WAREHOUSE>";
RfcAccessor accessor = null;
try {
String recService = "";
recService = (String) container.getTransformationParameters().get("ReceiverService");
if (recService.equals("Test_ReceiverService")) recService = "RQ1"; //Test environment in mapping design
// 1. Determine a channel (Business system, Communication channel)
Channel channel = LookupService.getChannel(recService,"ReceiverRFC");
// 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();
// create DOM structure from input XML
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(in);
// look for the tag 'WERKS'
NodeList list = document.getElementsByTagName("WERKS");
Node node = list.item(0);
// if found, look for the value of WERKS
if (node != null) {
node = node.getFirstChild();
if (node != null) {
werks = node.getNodeValue();
} else werks = warehouse;
} else werks = warehouse;
// look for the tag 'LGORT'
node = null;
list = null;
list = document.getElementsByTagName("LGORT");
node = list.item(0);
// if found, look for the value of LGORT
if (node != null) {
node = node.getFirstChild();
if (node != null) {
lgort = node.getNodeValue();
}
}
// look for the tag 'INSMK'
node = null;
list = null;
list = document.getElementsByTagName("INSMK");
node = list.item(0);
// if found, look for the value of INSMK
if (node != null) {
node = node.getFirstChild();
if (node != null) {
insmk = node.getNodeValue();
}
}
} catch(LookupException e) {
importanttrace.addWarning("Error while lookup " + e.getMessage());
} catch(Exception e) {
importanttrace.addWarning("Error parsing response " + 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() );
}
}
// Store lgort and insmk in memory for performance (get werks, lgort and insmk in a single RFC call)
container.getGlobalContainer().setParameter("LGORT",lgort);
container.getGlobalContainer().setParameter("INSMK",insmk);
return werks;
-
Kindly reply soon.
Thanks,
John
Hi,
We have a UDF for RFC look up.
In the UDF, we have the following code:
-
String recService = ""; recService = (String) container.getTransformationParameters().get("ReceiverService");
if (recService.equals("Test_ReceiverService"))
recService = "RQ1";
-
Other lines in the code are not of much relevance, hence I am not writing it here.
The problem is with the second line of the code "recService = (String) container.getTransformationParameters().get("ReceiverService");
We have not used any "set()" function to keep any parameter values in the global container.
But still the 'recService' is carrying the value "Test_ReceiverService".
Kindly help me in identifying where this value is coming from.
Thanks,
John
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi John,
Please change your code to:
String service = "";
String recService = (String) container.getTransformationParameters().get("ReceiverService");
if (recService.equals("Test_ReceiverService"))
service = "RQ1";
return service;
Since, you were saving the data in the same variable, I believe it was unable to return the value properly.
And in the test tab, you can get the document and parameters tab. Under parameter tab you can find this entry automatically.
ReceiverService Test_ReceiverService
So, it will be taking from there.
Regards,
Nutan
> Kindly help me in identifying where this value is coming from.
Check Javadoc:
http://help.sap.com/javadocs/pi/SP3/xpi/index.html?com/sap/aii/mappingtool/tf7/rt/Container.html
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.