on 05-10-2009 10:29 AM
Hi all,
I am doing an RFC lookup to increment counter. I am facing a problem.
I followed the code written by Michael. https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1...
*********************************************************************************************************
My udf is as shown below: -
String content = "";
MappingTrace importanttrace;
importanttrace = container.getTrace();
java.util.Map param = container.getTransformationParameters();
String MSGID = (String) param.get (StreamTransformationConstants.MESSAGE_ID);
// filling the string with our RFC-XML (with values)
String m="<?xml version="1.0" encoding="UTF-8"?><ns0:_-GLB_-ZGT_RFBIBL00_COUNTER xmlns:ns0="urn:sap-com:document:sap:rfc:functions"><IM_V_FILENAME>CA10.NCH.FCIPAY04</IM_V_FILENAME><IM_V_MSGID>"MSGID"</IM_V_MSGID><IM_V_WRNO>DEVWR0001725</IM_V_WRNO></ns0:_-GLB_-ZGT_RFBIBL00_COUNTER>";
importanttrace.addWarning("Input value is "+m);
RfcAccessor accessor = null;
ByteArrayOutputStream out = null;
try
{
// 1. Determine a channel (Business system, Communication channel)
Channel channel = LookupService.getChannel(receiverBS,"CC_RFC_RCV_AMS_R3F_DEVWR001725");
// 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();
out = new ByteArrayOutputStream(1024);
byte[] buffer = new byte[1024];
for (int read = in.read(buffer); read > 0; read = in.read(buffer)) {
out.write(buffer, 0, read);
}
content = out.toString();
}
catch(LookupException e)
{
importanttrace.addWarning("Error while lookup " + e.getMessage() );
}
catch(IOException e)
{
importanttrace.addWarning("Error " + e.getMessage() );
}
finally
{
if (out!=null) {
try {
out.close();
} catch (IOException e) {
importanttrace.addWarning("Error while closing stream " + 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() );
}
}
}
//returning the result u2013 RFC-XML.response
if ((content.substring(143,150)).equals("NOENTRY"))
{
ExceptionThrower.generate("INVALID INPUT DEVWR NUMBER OR ID" );
return "Nothing";
}
else
return (content.substring(143,155));
**********************************************************************************************************************
The problem i am facing is that, i am not able to pass the IM_V_MSGID parameter to the function module.
The other 2 parameters i can pass. that is IM_V_FILENAME and IM_V_WRNO.
i am able to extract the message ID using
java.util.Map param = container.getTransformationParameters();
String MSGID = (String) param.get (StreamTransformationConstants.MESSAGE_ID);
and displayed it in SXI_MONITOR trace also using importanttrace.addWarning("Input value is "+m);
i got the correct MSGID in the trace.But the problem is that this value is not getting passed to the FM. Cos the table is supposed to increment the counter whenever the MSGID value changes.
I tried hardcoding the MSGID value to 'abc' or '123' like values but the same thing happended. The counter will not increment. The FM is working perfectly when i run it and change the MSGID values manually.
Thanks
Pratichi
hey everyone,
it worked . there was some cache problem.
However i have another problem.
I need to increment the counter based on parent MSG id not MSG id. If the message goes to 2 receivers, the counter value should be the same. MSG ID will not work for this as there is a 1 byte difference.
Can someone tell me if there is a way to extract parent
MSG ID please in my Java udf.
Thanks in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
We have done this by creating an FM in XI ABAP stack:
FUNCTION Z_ZBXI_GET_PRE_MSG_ID.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(I_CURRMSGID) TYPE CHAR40
*" EXPORTING
*" VALUE(E_PREMSGID) TYPE CHAR40
*"----
DATA: lv_currmsgid type SXMSPMAST-MSGGUID,
lv_parentmsgid LIKE SXMSPMAST-PARENTMSG,
lv_premsgid LIKE SXMSPMAST-MSGGUID.
lv_currmsgid = i_currmsgid.
select single PARENTMSG from SXMSPMAST into lv_parentmsgid where MSGGUID = lv_currmsgid.
e_premsgid = lv_parentmsgid.
ENDFUNCTION.
You need to call this FM through RFC lookup UDF in your mapping.
Let me know if it works for you.
Regards,
Shweta
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
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.