cancel
Showing results for 
Search instead for 
Did you mean: 

Assigning unique value to multiple target elements

former_member188791
Participant
0 Kudos

Hi Group,

My requirement is I need to assign unique value to multiple target elements for each run,can any body suggest how I can achieve this requirement.

-Rajiv

Accepted Solutions (1)

Accepted Solutions (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You can create UDF. The approach is use some current date function or some sequence numbers and concatanete with random numbers.  To generate random number you can use java Random Class. You might want to see code examples for this

http://java.about.com/od/javautil/a/randomnumbers.htm

former_member188791
Participant
0 Kudos

Hi Bhaskar,

I took random number ,but when I am assigning it to various taget elements the number is changing its not at all unique.

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You might need to concatanete with some sequencer numbers or date with random numbers. Otherwise random numbers will not be helpful for unique.  Instead why dont you pick the current date and time (timestamp with milliseconds) as number. This will be alway unique. I think Udo's point is right.

former_member188791
Participant
0 Kudos

If I take Date and time for large files this number is changing,this number should be unique in whole file

udo_martens
Active Contributor
0 Kudos

Ah, you want it unique for one file? Ok - that was a missunderstood.

Put a random number or time stamp or both concatenated into a variable: Context on root of target. Then double click the variable and fill it. In the field mapping drag and drop the variable.

Regards

Udo

Former Member
0 Kudos

Hi,

Why dont u use message id if u want to have one unique number for one message?? Hope i understood u correctly?

Thanks

Amit Srivastava

former_member188791
Participant
0 Kudos

Hi Udo, Here in the above reply you mean variable means constant,how we can set context for constant,it is bit not clear

udo_martens
Active Contributor
0 Kudos

Hi Rajiv,

context menu on root element:

The variable is filled with a fixed value (for one mapping).

Regards,

Udo

gagandeep_batra
Active Contributor
0 Kudos

Hi Rajiv ,

You can see the following link for use of variable.

http://scn.sap.com/people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-gra...

Regards

Gagan

former_member188791
Participant
0 Kudos

Thanks Udo and Gagan ,its solved now

Answers (1)

Answers (1)

udo_martens
Active Contributor
0 Kudos

Hi Rajiv,

concatenate a timestamp (standard function currentDate) and a counter (function index).

Regards,

Udo

former_member188791
Participant
0 Kudos

Hi Udo,

this counter how it will be updated for each run and each day

udo_martens
Active Contributor
0 Kudos

Hi Rajiv,

>>this counter how it will be updated for each run and each day

You concatenate with a timestamp (having seconds) -> unique.

Random number is as well possible, but you need to create a new on each node.

Regards,

Udo