cancel
Showing results for 
Search instead for 
Did you mean: 

mapping: workaround instead of EXISTS

Former Member
0 Kudos

Hello everybody,

in my target message interface a special tag - let's call it <special> - should only be generated if several fields in the source structure occur.

To do this you normaly use the function <b>exists</b>.

But I have more than 50 fields in the source.

My idea was to <i>concat</i> all the 50 fields in a user defined function.

This works but it looks very ugly.

I hope you have some better ideas?

Regards Mario

Accepted Solutions (1)

Accepted Solutions (1)

bhavesh_kantilal
Active Contributor
0 Kudos

Mario,

Just an idea.. How about using a GLOBAL VARIABLE in the JAVA section?

Use EXISTS against each source field individually. If it does not EXIST , then set the FLAG and then write a SIMPLE UDF, that will check for the Global Variable FLAG and then create the Tag in the target if needed?

This way, you can avoid multiple ( 50 ) entried to the UDF.

Regards,

Bhavesh

former_member206604
Active Contributor
0 Kudos

Hi,

I can think of one option, write a UDF and while mapping those 50 fields make it pass thru this UDF. All you need to do in the UDF is set a flag and save it in global container. The while mapping the special field write a UDF and read the flag and use it. Hope this helps.

Thanks,

Prakash

Former Member
0 Kudos

Hi Bhavesh & Prakash,

would you be so kind and give some sample coding to

a) set a global container variable

b) get and inkrement a global container variable

Thanks a lot, Mario

former_member206604
Active Contributor
bhavesh_kantilal
Active Contributor
0 Kudos

/people/sap.user72/blog/2005/10/01/xi-new-features-in-sp14

This blog will help,

regards,

Bhavesh

Former Member
0 Kudos

Hi Bhavesh & Prakash,

your idea sounded good.

Unfortunately it is not practicable.

The mapping is done sequentielly.

But the target-field that depends on the occurence of the fifty other fields is mapped first!

So when I call the UDF <b>get</b>GlobalParameter, the UDF <b>set</b>GlobalParameter have not been processed and is NULL!

Regards Mario

bhavesh_kantilal
Active Contributor
0 Kudos

Mario,

Exactly what I was fearing would be an issue with the approach.

if the field was the last field , then the solution would 've been feasible.

Anyways, hopefully, it was a new learning with regard to the Global Variables / Java Section available from SP 14.

Regards,

Bhavesh

former_member206604
Active Contributor
0 Kudos

Hi,

Hmm Yes it was a new learning as Bhavesh said. I did not think abt the order of the fields. There are workarounds but that will end up making things complex and untidy.

Thanks,

Prakash

henrique_pinto
Active Contributor
0 Kudos

If it's really sequential and not random, you could do it like this:

Create two boolean global variables on the java section. One is the flag that you use to check whether the special tag will be created or not. The other one is a flag which you set only on the last field UDF, after you have updated or not the first flag.

For the special tag, your UDF would be something like this:

while (flag2 == false) {

//wait for the last UDF to run

}

if (flag1 == true) {

//create special tag

}

Regards,

Henrique.

Edit: as it's probably random and not exactly sequential, it'd be better if you created a integer variable and in each udf you just increment it. Then, in the special tag udf, you make a while like

while (count < 50) {

//wait for all the mappings to be completed

}

(you could use a Thread.sleep(10) in the while, to make the loop to wait for 10 milisseconds)

Also, I don't know if it will work because I don't know what is the treatment that XI has for parallel access to global variables. But it's worth a test.

Former Member
0 Kudos

Hi,

I am still confuse weather above suggestion would work. I have another method to handle this type of problem.

Create two mapping and put up in same Interface mapping

First mapping between your source structure and semi-target Structure. Create your mid-target almost same as your target but difference in sequence of tag and put special tag at the last Tag for particular context. Now apply Global Container method for its creation.

Second Mapping between your semi-Target Structure and actual target structure having simple direct mapping (for changing the sequence of tag).

Hope this will solve your problem.

Regards,

Vijay Singh Rajput

Answers (0)