Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

Problem: I have to generate sequence number.

Sometime it’s happen that we have to generate sequence number like in item number creation I have to create item sequence number like 10 20 30…and so on depending on the items or payload.

For example, I had source structure, having fields NAME and CREDIT CARD TYPE which I have to map in target structure, with generated serial number for each node.

Message Mapping: Source and target structure.

We have option to do it from User deifend function (simple user defied function as well as from advanced one) also we can do it from  Graphical tool

.

If I use simpleUserDefind.

The code :

public String SimpleUserdefined(Container container){

   //write your code here

 int inc = 1;

Integer seqNum = (Integer) container.getParameter("seqNum");

if (seqNum == null)

{

seqNum = new Integer (inc);

}

else

 {

int number  = seqNum.intValue() + inc;

seqNum = new Integer (number);

}

container.setParameter("seqNum", seqNum);

return seqNum.toString();

}

And here the Mapping:

 Source Name will be mapped with target name.

!https://weblogs.sdn.sap.com/weblogs/images/251873931/seq3.jpg|height=400|alt=image|width=600|src=htt...!"

And now i will map the simpleuserdefiend function to the card serial number as well as same functionw  maping for name serial number in target.

And here is out :

 !https://weblogs.sdn.sap.com/weblogs/images/251873931/seq6.jpg|height=395|alt=image|width=590|src=htt...!

If we use advanced function:

code :

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

   //write your code here

 int inc=10;

for (int i=0 ; i<a.length;i+)</p><p style="margin: 0in 0in 0pt" class="MsoNormal">{</p><p style="margin: 0in 0in 0pt" class="MsoNormal">result.addValue(Integer.toString((i1)*inc));

}

}

And here is the mapping:

I have to use the splitByValue for each value.

 !https://weblogs.sdn.sap.com/weblogs/images/251873931/seq8.jpg|height=352|alt=image|width=562|src=htt...!

And here is the Output

Difference:-

Advanced user defined function will generate all sequence number in one shot where simple defined function will generate for each occurrence and will keep track of old generated number.

And last which i like most is *Graphical *way to produce the Sequence number:

 !https://weblogs.sdn.sap.com/weblogs/images/251873931/seq11.JPG|height=384|alt=image|width=600|src=ht...!</body>

4 Comments