on 05-02-2006 8:31 PM
RFC mapping lookup.
Hi All,
I have to do mapping lookup to backend SAP using RFC API to translate SAP PLANT value to 3rd party plant value.
FM "Z_CA_SAP_TO_EXTERNAL" in SAP takes 2 import parameters and returns table.This is very generic FM used for all workstreams.
*" IMPORTING
*" VALUE(IM_WORKSTREAM) TYPE ZCA_WORKSTREAM
*" VALUE(IM_OBJ_TYPE) TYPE ZCA_OBJ_TYPE
*" TABLES
*" TB_SAP_TO_EXT STRUCTURE ZSCA_TRANSLATION
If I pass IM_WORKSTREAM = MM and IM_OBJ_TYPE = PLANT, it will return a table with all avilable plants in SAP(for workstream MM) with corresponding values for 3rd party.
In my mapping(Bet Idoc and I/B message for 3rd party) I am passing MM and PLANT as contants to User-Defined funtion.
Once I receive renponse from FM to my UDF, I have to parse the table,send the plant value to get corresponding value to target. How do I achieve this?
How can I check the response from FM in my UDF before parsing? Sample code/information would be very helpful.
Thank You
Indrasena
Hi,
>>>Once I receive renponse from FM to my UDF, I have to parse the table,send the plant value to get corresponding value to target. How do I achieve this?
if you use the RFC API in UDF then you get the
xml resul which you have to parse
later on you can put all values into an array and
do whatever you need with it
or you can do it in a more generic way
- we have created a generic class and you only have to
tell which tags from the result table you want
and a result array gets filled with them
(cannot share the code but the idea is not difficult
to implement)
anyway you just have to parse the result,
do with the result values whatever you need
and output from the UDF exactly what you need
Regards,
michal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi indrasena,
First I would suggest you use a DOM parser. Normally , DOm parsers are to be avoided in XI as DOM parser will load the whole XML into the main memory. But , in our case , as we are to be parsing a small XML response , DOM would not cause performance and memory issues and would be easier.
For info on the methods of DOM, just refer to this link,
http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html
http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm
try this code,
<b>DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// create DOM structure from input XML
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(inputstream);//inputystream will be the RFC response in your case converted from payload in a Stream
// look for the tag 'XYZ'
NodeList list = document.getElementsByTagName("XYZ");
Node node = list.item(0);
if (node != null) {
// if found, look for the value of XYZ
node = node.getFirstChild();if (node != null) {
String XYZ = node.getNodeValue();
}
}
return XYZ;</b>
Regards,
Bhavesh
Hi,
it's better to not to hardcode it
(I wrote the API article a few days afret the API
was released that's why it shows such a "dirty" way)
did you try this weblogs's code:
/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
?
it's a good start and it shows how to create the request
Regards,
michal
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.