Skip to Content

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.

image

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.

image

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=https://weblogs.sdn.sap.com/weblogs/images/251873931/seq3.jpg|border=0!”

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.

image

And here is out :

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

If we use advanced function:

image

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=https://weblogs.sdn.sap.com/weblogs/images/251873931/seq8.jpg|border=0!

And here is the Output

image

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=https://weblogs.sdn.sap.com/weblogs/images/251873931/seq11.JPG|border=0!</body>

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Ananth Chinnaraj
    Hi,

    You can use INDEX std function(found under statistic group) along with Node functions like SplitByValue to achieve this functionality. We don’t have to write a single line of code to produce sequence numbers and also it is possible to configure the increment values 🙂

    Regards,
    Ananth

    (0) 
    1. Rohan Sharma
      Hi Ananth

      this is regarding the below comment of yours in one of the blogs

      ” You can use INDEX std function(found under statistic group) along with Node functions like SplitByValue to achieve this functionality. We don’t have to write a single line of code to produce sequence numbers and also it is possible to configure the increment values 🙂 ”

      Can  you please tell me how is it done or some blog explaining it ?

      A simple Source field generating a random sequence number for a target field

      (0) 

Leave a Reply