cancel
Showing results for 
Search instead for 
Did you mean: 

udf for global incremental number

deva_gembali2
Participant
0 Kudos

Hi Friends,

    I need incremental number as global set and get parameter code.

Please let me know incremental four digit number 0001, 0002,0003...

We have to set initial value at global and use increment whenever file triggers at file name.

example, scenario...  IDOC to file , have to write file name by using  variables.

      Regards,

Deva

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Deva,

You need to define

Maintain number range object in PI. This is defined using Tcode - SNRO. Where you need to provide Number lengh domain - for e.g. NUM4 if you want your number as 4 digit long.

Add interval starts with 0001 & To number as 9999. 

Create a Z RFC which is in turn calling standard RFC 'Number_Get_Next'. This standard RFC takes  Number Range object created in above step as parameter & Quanatity value - which is nothing but increment value which 1 in our case. So its value will be 0001 in your case.

Import this ZRFC in PI. Call this in RFC Lookup function. This will return next number than before each time when RFC is called.

Each time when a new instance will call this will return the next number to the number of the last instance of the mapping call.

Regards,

Ashish

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Deva,

If you are using NFS file transport protocol, incremental number to file name can be done by selecting "Add counter" in File construction mode, use step 1, format 0000.

Thanks,

Pranav

deva_gembali2
Participant
0 Kudos

Hi Pranav,

    I am using for one of the mapping fields not for file name.

Regards,

deva

Former Member
0 Kudos

Hi,

We have implemented similar kind(sequence no generation) of requirements in our project.We used RFC look up in our case.

You can either use RFC or JDBC look up in your case.

Regards

Venkat

deva_gembali2
Participant
0 Kudos

Hi Guys,

   Thanking for your valuable information.

In this case, what is the approach for incremental value for same mapping? can we achieve by graphical mapping ? need udf ?

Regards,

Deva

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Globalcontainer does work within the same context for the persistence but not across messages because it treat as different session context . So doing globalcontainer does not help at all for your requirement.

deva_gembali2
Participant
0 Kudos

HI Guys,

   Can you able to tell me java code in mapping as Global Container method ?

sample as :

public String setGlobalContainer(String globalContainerName,String globalContainerValue,Container container){

GlobalContainer gc = container.getGlobalContainer();

gc.setParameter(globalContainerName,globalContainerValue);

return globalContainerValue;

Regards,

Deva

Former Member
0 Kudos

Hi Deva,

You can not use GlobalContainer for incrementing purpose.

Please check this link:

http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/mappingtool/tf7/rt/GlobalContainer.html

Its used for storing values in same message mapping.

So in your case if file has been triggered once and globalcontainer sets the value as 1 , you cant increment the value to 2 for next file.

Please check the options provided by Baskar and Ashish.

Regards,

Beena

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You can handle using datbase table in the mapping. Your dba can create sequencer in the table. YOu do jdbc lookup to get the next value in the mapping and use it for the filename. This is an another approach.