cancel
Showing results for 
Search instead for 
Did you mean: 

Output file name

Former Member
0 Kudos

Hw to generate 5digit unique random number followed by timestamp in output file name?

Is there any function in XI helps to meet this req?

Accepted Solutions (0)

Answers (5)

Answers (5)

bhavesh_kantilal
Active Contributor
0 Kudos

The best and the cleanest solution is to use AddMessage ID in the file adapter. The message id is always unique. Why do you want it to be only a 5 digit number? Can't a unique sequence of characters do the trick instead?

Regards

Bhavesh

Former Member
0 Kudos

Hi Iñaki Vila

This is my sample output file name 20092009NNNNN.

Here NNNNN is the 5 digit random unique number i.e [

b]the last 5 digits shld be unique.

henrique_pinto
Active Contributor
0 Kudos

Naresh,

the only way to make sure it is unique is by maintaining a table (a ZTable in ABAP for example) and storing the already used names.

Do you actually need them to be random? Because if they only need to be unique, just create a table and a simple rfc that reads the table value, increments it and saves it again in the table. By always incrementing, you make sure they will be unique.

Regards,

Henrique.

iaki_vila
Active Contributor
0 Kudos

Hi,

If you use Henrique solution you must use an ABAP Mapping.

Abap Mapping help: http://help.sap.com/saphelp_nw04/helpdata/en/10/5abb2d9df242f6a62e22e027a6c382/frameset.htm

I edit with add this two very interesting blogs:

-/people/r.eijpe/blog/2006/02/19/xml-dom-processing-in-abap-part-iiia150-xml-dom-within-sap-xi-abap-mapping

-/people/r.eijpe/blog/2006/02/20/xml-dom-processing-in-abap-part-iiib150-xml-dom-within-sap-xi-abap-mapping

Message was edited by:

Iñaki Vila

henrique_pinto
Active Contributor
0 Kudos

No need for abap mapping, he could use a simple RFC Lookup.

Regards,

Henrique.

Former Member
0 Kudos

Hi Iñaki Vila

As per the java code that u mentioned above, Is it generates UNIQUE RANDOM number?

iaki_vila
Active Contributor
0 Kudos

HI,

It generates random numbers. If you excute twice diferents times you have two differents numbers.

Regards.

iaki_vila
Active Contributor
0 Kudos

Hi,

you can make an user function with this code java:

import java.util.Random;

Random rnd = new Random();

return Integer.toString(rnd.nextInt(99999) + 1);

Regards.

Shabarish_Nair
Active Contributor
0 Kudos

use the code mentioned by Inaki and then implement the same via dynamic configuration and adapter specific properties in your mapping to achieve the result.

ref:

/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14

http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/frameset.htm