cancel
Showing results for 
Search instead for 
Did you mean: 

Standard Mapping functions as UDF?!

Former Member
0 Kudos

Hi guys,

well i am using the standard mapping obejcts given in the editor of the IB.

Because i am getting sick of clicking all these simple functions together i thought of writing the code on my own.

I did but it's not working out for me.

The goal is that when a value occuers in the data-field it should be taken, else it should be free (even no whitespace). At the end, the should be a semicolon when no value occurs because the target is a csv-file.

Simple method looks like:

public String dataExists(String a,Container container){

if (a.length() == 0){
a = "";
return a;
}
else{
return a;
}
}

in Xi-Standard-Mapping i use:

/MT_NC_ART_DELIVER/DELRecordSet/DELDetailsStruct/nQtyProduced=iF
(/ZBC14_ART_DEL/IDOC/ZBC14_ART_DEL/NQTYPRODUCED=, exists
(/ZBC14_ART_DEL/IDOC/ZBC14_ART_DEL/NQTYPRODUCED=), const([value=]))

can somebody give me a hand?! the problem is only that in FCC with standard XI-mapping there is a semicolon written when no value occurs, when i use my UDF the semicolon isn't written.

br Jens

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

Jens,

Please correct me if i'm wrong. If the input field is empty I mean the node is present but the length is 0 then u want the value to be <b>;</b> am I right? If yes ur code is perfect , but inside string give <b>;</b>

if (a.length() == 0){

a = <b>";"</b>;

return a;

}

else{

return a;

}

}

If I understood ur reqmt wrongly plz reply back.

-raj.

Former Member
0 Kudos

Hi Raj,

well i thought of this solution, but didn't tried it because i do a FCC (write to FTP) and for every present field the adapter writes a semicolon.

Perhaps it will write two semicolons with this solution because the ";" indicates a present value?! Am i rigtht?

Otherwise i will try it....

UPDATE:

Ok i tried ur suggestion but we are both wrong because XI doesn't work like the code assumes...nothing is written not even a semicolon even if i use ur edited code...

What is wrong?!

br Jens

justin_santhanam
Active Contributor
0 Kudos

Jens,

Are u sure? I checked in the mapping editor with the same code. The semicolon is populated in target field.

Best regards,

raj.

Former Member
0 Kudos

Hi Raj,

well yes i am sure. Indeed, if u simulate the mapping everything works fine.

But when u use the FileContentConversion afterwards the semicolon disappears.

Perhaps XI does not intepret the standard-value given in the UDF dureing the FCC?!

br Jens

stefan_grube
Active Contributor
0 Kudos

The point is that you mix up an empty node and a not-existing node.

If the node does not exist, the UDF is not invoked at all.

What you can do is using an advanced UDF. Then you can write the code like this:

public String dataExists(String[] a, ResultList result, Container container){

if (a.length == 0){
result.addvalue("");
}
else{
result.addvalue(a[0]);
}
}

Former Member
0 Kudos

Hi Stefan,

well i guess i have to be more familiar with UDFs and the advanced one. Because i am new to this, i have some problems.

I added ur code for testing but cannot activate the MM because of some Syntax-Errors in the UDF.

560: cannot resolve symbol symbol : method addvalue (java.lang.String) location: interface com.sap.aii.mappingtool.tf3.rt.ResultList result.addvalue("");

563: cannot resolve symbol symbol : method addvalue (java.lang.String) location: interface com.sap.aii.mappingtool.tf3.rt.ResultList result.addvalue(a[0]);

Do i have to add some packages?! Imports aren't missing because ResultList comes from class Object?!

can u give me one more advise?!

br Jens

stefan_grube
Active Contributor
0 Kudos

Sorry, there is a typo:

result.addValue(..)

For an advanced UDF, you have to change the attribute Cache = Context

See more details here:

http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/frameset.htm

Check this blog also, that should help to find out, which method you can use:

/people/stefan.grube/blog/2005/12/30/test-user-defined-functions-for-the-xi-graphical-mapping-tool-in-developer-studio

Stefan

Message was edited by:

Stefan Grube

Former Member
0 Kudos

Hi Stefan, well already find it on my own....typo yes.

Thx, it seems to be running!

One last question: What should i use for client's needs?! Should there be the standard mapping function or is it also usual to use the UDFs to just save work?

br Jens

stefan_grube
Active Contributor
0 Kudos

For this special request, you can use the standard function: mapWithDefault.

That does exactly, what you need.

Regards

Stefan

Answers (0)