cancel
Showing results for 
Search instead for 
Did you mean: 

UDF For Retrieving the Tax Code based on PO

Former Member
0 Kudos

Hi all,

Mine is a file to Idoc scenario.

I wrote a FM to retrieve the Tax Code based on PO .

Created the udf which directly gets the Taxcode from the r/3 with out importing in to the imported objects,is this correct i never tried this before.

Find the UDF for the Same.

final String CHANNEL_NAME = "GeneratedReceiverChannel_RFC",

VALNOTFOUND = "VALUE_NOT_FOUND",

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

TAG_FM = "Z_P_INT012_RFC_LOOKUP",

TAG_TAX_CODE = "T_TAX_CODE",

TAG_TAX_CODE_P = "TAX_CODE";

AbstractTrace 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());

}

Document docReq = null;

try {

// Building up RFC Request Document

docReq = builder.newDocument();

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

Node nodeTbOpt = root.appendChild(docReq.createElement(TAG_TAX_CODE));

for (int i = 0; i < pernr.length; i++) {

Node nodeTbOptItem = nodeTbOpt.appendChild(docReq.createElement("item"));

nodeTbOptItem.appendChild(docReq.createElement(TAG_TAX_CODE_P)).appendChild(docReq.createTextNode(TAX_CODE<i>));

}

} catch (Exception e) {

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

}

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

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

// Lookup

Payload load = null;

try {

Channel channel = LookupService.getChannel(receiver[0], CHANNEL_NAME);

RfcAccessor accessor = LookupService.getRfcAccessor(channel);

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

XmlPayload payload = LookupService.getXmlPayload(is);

load = accessor.call(payload);

} catch (LookupException e) {

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

}

// Parsing RFC Response Document

Document docRsp = null;

try {

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

} catch (Exception e) {

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

}

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

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

try {

NodeList res = docRsp.getElementsByTagName("item");

for(int i=0;i<res.getLength();i++){

NodeList itemNodes = res.item(i).getChildNodes();

Map itemMap = new HashMap();

for(int j=0;j<itemNodes.getLength();j++){

itemMap.put(itemNodes.item(j).getNodeName(), itemNodes.item(j).getFirstChild().getNodeValue());

}

rows.add(itemMap);

}

}

catch (Exception e) {

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

}

result.addValue("true");

}

Error:

16:24:08 Start of test

Source code has syntax error: /usr/sap/XD1/DVEBMGS30/j2ee/cluster/server0/./temp/classpath_resolver/Map283041f0edf311dd960b0003bacd2461/source/com/sap/xi/tf/_MM_INT012_INVOICE_DET_.java:598: 'class' or 'interface' expected public void TaxValues$(String[] a,String[] b,ResultList result,Container container){ ^ /usr/sap/XD1/DVEBMGS30/j2ee/cluster/server0/./temp/classpath_resolver/Map283041f0edf311dd960b0003bacd2461/source/com/sap/xi/tf/_MM_INT012_INVOICE_DET_.java:618: 'class' or 'interface' expected } ^ /usr/sap/XD1/DVEBMGS30/j2ee/cluster/server0/./temp/classpath_resolver/Map283041f0edf311dd960b0003bacd2461/source/com/sap/xi/tf/_MM_INT012_INVOICE_DET_.java:619: 'class' or 'interface' expected ^ 3 errors Source code has syntax error: /usr/sap/XD1/DVEBMGS30/j2ee/cluster/server0/./temp/classpath_resolver/Map283041f0edf311dd960b0003bacd2461/source/com/sap/xi/tf/_MM_INT012_INVOICE_DET_.java:598: 'class' or 'interface' expected public void TaxValues$(String[] a,String[] b,ResultList result,Container container){ ^ /usr/sap/XD1/DVEBMGS30/j2ee/cluster/server0/./temp/classpath_resolver/Map283041f0edf311dd960b0003bacd2461/source/com/sap/xi/tf/_MM_INT012_INVOICE_DET_.java:618: 'class' or 'interface' expected } ^ /usr/sap/XD1/DVEBMGS30/j2ee/cluster/server0/./temp/classpath_resolver/Map283041f0edf311dd960b0003bacd2461/source/com/sap/xi/tf/_MM_INT012_INVOICE_DET_.java:619: 'class' or 'interface' expected ^ 3 errors

16:24:11 End of test.

Accepted Solutions (1)

Accepted Solutions (1)

former_member182004
Contributor
0 Kudos

Hi Potharaju,

Why don't you try this, that really works:

If you are using PI 7.1:

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

If you are using XI 3.0, PI 7.0

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1...

Try with these.

Regards,

Juan

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Raju,

You need to do an RFC Lookup. Check this document where you have all the necessary code:

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1...

Regards,

---Satish