cancel
Showing results for 
Search instead for 
Did you mean: 

Error when use User-Defined Function

Former Member
0 Kudos

I just create User defined function "getfilename" and I put there:

"DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

String ourSourceFileName = conf.get(key);

return ourSourceFileName; ".

But In test mapping I have worning:

"Runtime exception during processing target field mapping /ns1:Z_KBFI_INPUT_FILE/IS_IFILE/FILE_NAME. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._KBFIMsgMapping_ method get_fname$[com.sap.aii.mappingtool.tf3.rt.Context@37d4662c] com.sap.aii.mappingtool.tf3.MessageMappingException: Runtime exception during processing target field mapping /ns1:Z_KBFI_INPUT_FILE/IS_IFILE/FILE_NAME. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._KBFIMsgMapping_ method get_fname$[com.sap.aii.mappingtool.tf3.rt.Context@37d4662c] at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:284) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:238)...."

And in RWB in Communication Channel Monitoring I can not see file name in the payload.

Maby I do something wrong, please tell me.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI Grzegorz,

your code seems to be ok, just which SP are you running? this was allowed from SP14 onward.

Regards,

Sergio

Answers (12)

Answers (12)

Former Member
0 Kudos

my source file 200610.txt is like this:

HR 0610 061030 061021

DR 03 C 0610 820114 00010111 0000015000 PLN descr...

DR 03 D 0610 403201 00010111 0000015000 PLN descr..

TR 0000000002

Then in sxmb_moni in inbound message (payload) I have:

<?xml version="1.0" encoding="utf-8" ?>

- <ns:KBFIMsgTypeSource xmlns:ns="http://p4.org/xi/KBFI/Interface">

- <FIRecordset>

- <HeaderLine>

<LineKey>HR</LineKey>

<PostingPeriod>0610</PostingPeriod>

<PostingEndDate>061030</PostingEndDate>

<PostingDate>061021</PostingDate>

</HeaderLine>

- <PostingLine>

<LineKey>DR</LineKey>

<ServerID>03</ServerID>

<DCFlag>C</DCFlag>

<PostingPeriod>0610</PostingPeriod>

<GLAccount>820114</GLAccount>

<SubAccount>00010111</SubAccount>

<NetValue>0000015000</NetValue>

<Currency>PLN</Currency>

<Description>descr...</Description>

</PostingLine>

- <PostingLine>

<LineKey>DR</LineKey>

<ServerID>03</ServerID>

<DCFlag>D</DCFlag>

<PostingPeriod>0610</PostingPeriod>

<GLAccount>403201</GLAccount>

<SubAccount>00010111</SubAccount>

<NetValue>0000015000</NetValue>

<Currency>PLN</Currency>

<Description>descr..</Description>

</PostingLine>

</FIRecordset>

</ns:KBFIMsgTypeSource>

But I don't have payload for Response (black and white flag).

In DynamicConfiguration i have:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

- <!-- Response

-->

- <SAP:DynamicConfiguration xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">

<SAP:Record namespace="http://sap.com/xi/XI/System/File" name="SourceFileSize">141</SAP:Record>

<SAP:Record namespace="http://sap.com/xi/XI/System/File" name="FileType">txt</SAP:Record>

<SAP:Record namespace="http://sap.com/xi/XI/System/File" name="SourceFileTimestamp">20061212T121622Z</SAP:Record>

<SAP:Record namespace="http://sap.com/xi/XI/System/File" name="FileEncoding">ISO646-US</SAP:Record>

<SAP:Record namespace="http://sap.com/xi/XI/System/File" name="FileName">200610.txt</SAP:Record>

<SAP:Record namespace="http://sap.com/xi/XI/System/File" name="Directory">/usr/sap/PXD/put/archive</SAP:Record>

</SAP:DynamicConfiguration>

Former Member
0 Kudos

"Does the Filename node have a parent. If so check if parent node occurs.

Also return any dummy value in ur UDF and check if u get the tag and that value."

Yes hava a parent which occure.

When I try return "dummy value" i still don't have this tag.

Former Member
0 Kudos

Hi,

Have u done mapping for that parent node.

Could u post the source and target xml.

Regards,

Sudharshan

Former Member
0 Kudos

No I even don't have empty XML tag coresponding to file name. The file name apear in message header but in target message i don't have any file name tag and file name.

Former Member
0 Kudos

Hi,

Does the Filename node have a parent. If so check if parent node occurs.

Also return any dummy value in ur UDF and check if u get the tag and that value.

Regards,

Sudharshan

Former Member
0 Kudos

Also check that the node that is input to UDF is not optional...

Make sure that node occurs in ur input.

How to check that?? Which node is this?

Yes I getting the XML node corresponding to filename.

Message was edited by:

Grzegorz Stankiewicz

Former Member
0 Kudos

Hi,

I suppose ur UDF has no input and it is mapped to the target node.

Are u getting empty XML tag corresponding to ur FileName.

Regards,

Sudharshan

Former Member
0 Kudos

I can see in Message content->SOAP Document message like this:

<sap:DynamicConfiguration>

<sap:Record namespace="http://sap.com/xi/XI/System/File" name="Directory">/usr/sap/PXD/put/archive</sap:Record>

<sap:Record namespace="http://sap.com/xi/XI/System/File" name="FileEncoding">ISO646-US</sap:Record>

<sap:Record namespace="http://sap.com/xi/XI/System/File" name="SourceFileTimestamp">20061212T121622Z</sap:Record>

<sap:Record namespace="http://sap.com/xi/XI/System/File" name="FileType">txt</sap:Record>

<sap:Record namespace="http://sap.com/xi/XI/System/File" name="FileName">200610.TXT</sap:Record>

<sap:Record namespace="http://sap.com/xi/XI/System/File" name="SourceFileSize">124</sap:Record>

</sap:DynamicConfiguration>

And I see the file name but in Message content->payload..: I still can't see even file name xml tag

Former Member
0 Kudos

I just did like you advice but it still doesn't work.

Yes I set the FileName checkbox in Adapter Specific Identifiers in sender communication channel.

Former Member
0 Kudos

Hi,

Just go to transcation SXI_MONITOR and choose ur scenario.

in that Inbound side check SOAP header and Dynamic Configuration. U should have ur file name there.

Also check that the node that is input to UDF is not optional...

Make sure that node occurs in ur input.

Are u getting the XML node corresponding to filename atleast .

Regards,

Sudharshan

Former Member
0 Kudos

Even if you test it by sending a file/message through comm. channel. it still doesn't work. I can not see the xml tag like <FileName>XXXX.txt</FileName> which I want. The channel is working without error.

Former Member
0 Kudos

Hi,

Try the following piece of code to replace Key object

DynamicConfigurationKey key = DynamicConfigurationKey.create("http:" + "/" + "/" + "sap.com/xi/XI/System/File", "FileName");

and execute ur scenario.

Also Make sure that Adapter Specific Identifiers and FileName Checkbox is set in sender communication channel

Regards,

Sudharshan

Former Member
0 Kudos

testing using mapping tool will generate runtime exception as the Dynamic config set in Communication channel is not availbale in IR,but this will work if you test it by sending a file/message through comm. channel.

You have to disable this field in the mapping temporarly to use the Mapping test tool.

Former Member
0 Kudos

If you want the mapping running without errors both at design time (message mapping test) and at runtime you must to manage this in the JAVA code of your function.

Regards,

Sandro

Former Member
0 Kudos

Ok, thanks!

But how to solve the problem?? Where is an error?

Former Member
0 Kudos

Hi Grzegorz,

which is the name of your udf?

Could you post the complete exception log?

Kind Regards,

Sergio

Former Member
0 Kudos

Yes my SP allowe for that solution. I asked my basis administrators.

Former Member
0 Kudos

Hi,

you do not need to ask them you can verify it from Integration repository menu:

Help->information and have verify Service pack.

Regards,

Sergio

Former Member
0 Kudos

Can you show me how to do that??

Former Member
0 Kudos

I think you took your code from here:

/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14

Try to put the block code in Try, Catch and stamp and trace the exception.

Regards,

Sandro