cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help for the UDF

Former Member
0 Kudos

Hi Folks,

Being i don't have much knowledge in Java coding , i need help in writing an UDF for the requirement mentioned below.

"For First Customer line default value should be "0001" for each record type . For each  next Customer Line this value should be increased by 1. e.g "0002"

Thanks in advance!!

Regards,

Balu

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

There is already a built-in function for this in message mapping, you can use Statistic function called Index . It also gives you the option to reset the counting per context change or to continue the counting.

Hope this helps,

Mark

Former Member
0 Kudos

Hi Mark,

Thanks for your help,

And one more query as am having many customers and for the first time occurence of each customer it should be 001 and further occurence it has to be increased by "1" i.e 002 . It should happen for every customer.

Please suggest me if the Index function can satisfy this.

Regards,

Balu

Former Member
0 Kudos

this will work:

and this will work:

depends on your source structure.

regards,

Robin

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Can you provide the occurrences of the target message? If it would be possible to keep just one context per customer, then you could just use the reset counting to 0001 per context change.

Hope this helps,

Mark

Former Member
0 Kudos

Hi Robin,

The answer you have proposed seems to be occurrences of a single message. But my requirement is this sequence has to be maintained for other messages in future. If your solution can solve the requirement, plz brief me on that

regards,

Balu

Former Member
0 Kudos

ok understand.

you meas you get maybe today 2 customers sended. With 001 and 002.

And another one tomorrow which should get automatic 003?

In this case you have to store the existing customer numbers somewhere.

Possible solution would to create a RFC function which handle that in a ABAP Table or Number Range Object. So you can use the RFC Lookup function to get the next free customer number for your mapping program... and the RFC handle that it never return the same number twice.

to store a counter/index value from one mapping instance for another one is not possible.

regards,

Robin

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

in a UDF you can use:

for (int i =0; i< input.length; i++)

{

result.addValue(i);

}

input is your UDF input ... so the number of customer Lines.

But why you want to use a UDF? just use the standard COUNTER or INDEX function.

regards,

Robin