cancel
Showing results for 
Search instead for 
Did you mean: 

BRM call not happening from PI UDF

sanjaybadhai
Explorer
0 Kudos

Hi,

I am following the below sdn link to call BRM Rule from a PI mapping.When I traced the UDF, realized that the BRM call statement is not reacting and it is not yielding any result post this statement in the UDF. When I tried to execute my webservice from the SOAP UI, I get the following message

"org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Unexpected element: TAG_END"

But when I test the service in WS Navigator it shows the correct result.

Below statement is not working in the UDF--

// 3. Call BRM

XmlPayload resPayload = (XmlPayload)accessor.call(reqPayload);

https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b07ce666-fdf1-2c10-96b0-be959a344ede&overrid...

Anyone clue on this is really appreciated.

Thanks

Sanjay

Accepted Solutions (0)

Answers (2)

Answers (2)

sanjaybadhai
Explorer
0 Kudos

Problem is now resolved and the solution goes like this:

SOAP BRM Look up call expects an outbound binding for the response and hence it throws that exception.

1. Hence create a dummy Service Interface e.g "Dummy" (with only 1 field "Field1")

2. Create a business component(earlier called Business Service) e.g "BLService". No need to create it, if it is already created for the SOAP BRM receiver channel.

3. Create a dummy communication channel e.g "Dummy" (type SOAP sender) under BLService

4. Create another Integrated Configuration with Sender = BLService , Receiver=BLService, Sender Channel = Dummy , Outbound Processing Channel = SOAP receiver channel already configured for the BRM, No Operation Mapping, Sender Interface = "Dummy" and Receiver Interface = "Dummy".

Now run the scenario. It should do the trick now..

Since we are on PI single stack with only Java so ICO is the only option to make the outbound binding. Otherwise in dual stack perhaps it could be achieved using a receiver agreement.

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

it may not be the way you've wanted but as per my blog:

http://scn.sap.com/people/michal.krawczyk2/blog/2010/04/13/pixi-how-to-call-brm-and-brfplus-from-pi-...

there is a way to call BRM (from BRF) without writing any line of code   just using RFC lookup,

Regards,

Michal Krawczyk

sanjaybadhai
Explorer
0 Kudos

Hi,

I have seen your blog. But in our case we are not using BRF.In future we may utilize the other alternatives if required.If you have any further clue on this problem please suggest.Thanks for your reply!!

BR/Sanjay

nageshwar_reddy
Contributor
0 Kudos

Sanjay,

1. There should be no error when tested from SoapUI. I was able to successfully test a BRM web service from SoapUI

2. How have you constructed your request for the soap look up call. You need to follow a specific format and SoapUI test request should help you in arriving at the correct request. You can also use WSNavigator(XML  Content tab) to look at how your request message should look like. Also, Appendix B in the document you referred shows a way to get the request message and the format therein.

If you still have issues, post the UDF code, specifically the request creation piece.

baskar_gopalakrishnan2
Active Contributor
0 Kudos

The problem you elaborated is not enough. Unless we see your UDF coding we cannot figure it out. Especially the payload string you create for the request is causing the error. One simple suggestion is you can write the payload string that you build in a file and validate the xml file using xmlspy or some validator tool. This is one quickest way to fix your build request error.

sanjaybadhai
Explorer
0 Kudos

Hi,

Thanks for the reply.

Here is the UDF code used. The request payload has been constructed exactly the way it is mentioned in the how to guide(link in my original post).In WSNavigator it works fine. But it throws an error(ref to my original post) while executed in SOAPUI.

Input : PRCTR and BWKEY

-- --

MappingTrace trac;
trac = container.getTrace();

SystemAccessor accessor = null;
String prctr = "";
StringBuffer sb = new StringBuffer();

trac.addWarning(" 1st Trace");

try{
// 1. Get a system accessor for the channel.
accessor = LookupService.getSystemAccessor(soapPRCTR);

trac.addWarning(" 2nd Trace");

// 2. Build up request
InputStream reqStream;
String reqString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+"<ns0:Request-xyz.com-rule-support-finance-I999-New-I999-New xmlns:ns0=\"http://www.sap.com\">"
   +"<ns1:ProfitCenterBRM xmlns:ns1=\"urn:xxx:ERP:I999:AccountingDocument\">"
      +"<PRCTR/>"+PRCTR+"</PRCTR>"
      +"<BWKEY>"+BWKEY+"</BWKEY>"
      +"<RESULT>"+0+"</RESULT>"
   +"</ns1:ProfitCenterBRM>"
+"</ns0:Request-xyz.com-rule-support-finance-I999-New-I999-New>";

trac.addWarning(" 3rd Trace" + reqString);

reqStream = (InputStream) new ByteArrayInputStream(reqString.getBytes());
XmlPayload reqPayload = LookupService.getXmlPayload(reqStream);

trac.addWarning(" 4th Trace"+reqPayload);

// 3. Call BRM
XmlPayload resPayload = (XmlPayload)accessor.call(reqPayload);

trac.addWarning(" 5th Trace"+resPayload);

// 4. Parse result
byte[] b = new byte[4096];

for (int n; (n = resPayload.getContent().read(b)) != -1;) {

sb.append(new String(b, 0, n));
trac.addWarning(" 6th Trace");
}

int i =sb.indexOf("<RESULT>") + 10;

int j =sb.indexOf("</RESULT>");

prctr = sb.substring(i, j);

}

catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

finally {

// 5. Close the accessor in order to free resources.
if (accessor!=null) accessor.close();
}

return prctr;

-- --  

when UDF is executed variable "reqPayload" returns a well formatted xml.

<ns0:Request-xyz..com-rule-support-finance-I999-New-I999-New><ns1:ProfitCenterBRM><PRCTR>A</PRCTR><BWKEY>2000</BWKEY><RESULT/></ns1:ProfitCenterBRM></ns0:Request-xyz.com-rule-support-finance-I999-New-I999-New>

---

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Looks like typo ... but just to make sure. I see two .. in the <ns0:Request segment as below..

<ns0:Request-xyz..com-rule-support-finance-I999-New-I999-New>

nageshwar_reddy
Contributor
0 Kudos

What happens when you test message map in ESB? Do you see the same error as SoapUI? Do you see any error at all?

Also, You need to use 8 instead of 10. That is length of <RESULT>

int i =sb.indexOf("<RESULT>") + 10;

sanjaybadhai
Explorer
0 Kudos

I am  aware of that. xyz.com is a just a dummy I typed instead of showing the actual domain..

sanjaybadhai
Explorer
0 Kudos

There is no error when the mapping is executed in ESB. Thanks for pointing that index problem, but the program cursor doesn't appear to reach upto that. Ideally the following trace should be atleast executed if the BRM call statement is working fine. I corrected the index but still it doesn't work.

trac.addWarning(" 5th Trace"+resPayload);

nageshwar_reddy
Contributor
0 Kudos

Sanjay, I think you should ensure that it works through soapui. Can you check the raw response in soapui and see if there are any issues? Also can you post the raw response?

sanjaybadhai
Explorer
0 Kudos

Below response I get in SoapUI.

org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Unexpected element: TAG_END 


It seems to be some issue with our PI system(7.31 single java stack SP-04) while making the SOAP lookup call. I get a similar exception as mentioned in the below link, but in our case we can not create a receiver agreement, since there is no provision for that in single stack java PI 😞

http://scn.sap.com/message/13384553

nageshwar_reddy
Contributor
0 Kudos

I think you should raise a OSS message. It looks like an issue with the specific release. Couple of days back i was working on 7.3(dual stack) and it worked perfect.

SAP API documentation does not indicate any change in the behavior of these calls:

LookupService

SystemAccessor