cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to declare a GLOBAL variable

Former Member
0 Kudos

Hi All,

My requirement is to have a global variable that can hold the value and gives an incremented value in next call or you can say I am trying to generate sequence number globally.

Please help me with the UDF to define a Global variable , increment the value and return the variable.

Thanks & Regards,

Nida Fatima

Accepted Solutions (0)

Answers (4)

Answers (4)

vinaymittal
Contributor
0 Kudos

Hi Nida,

in the "Functions" Tab go to Attributes and methods....

just declare a variable there after the comments section like this

int record_count = 0;

or in case you want to store strings etc better declare an arraylist

ArrayList<String> global_variable = new ArrayList<String>();


these variables declared in attributes and methods are accessible globally over multiple udf calls and there value persists and is not lost you can update the variables, increment them etc... in all the udf directly just like a normal variable.

PS: my undertanding is that you need this variable to maintain record count and access that in a udf or for whatever reason but you are looking for a global variable localized to one instance of a "pipeline/per message" I mean as soon as the message mapping is over everything is again set to 0.

Regards

Vinay

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Nida,

Can you check the below blogs:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/503e9bea-ea09-2e10-ec8a-cdf369de9...

Else you can try using Graphical function Index:

arunneerolil
Contributor
0 Kudos

Nida,

The right approach is to use the Number Range Object(NRO) for this purpose.

The Number Range Objects (NRO) module provides the option of automatically inserting continuous counters into outgoing messages.

Please refer the links for details

http://help.sap.com/saphelp_nw-b2b-addon102/helpdata/en/c8/bb03c8626745f584351d7abc2c81ae/content.ht...

http://scn.sap.com/community/b2b-integration/blog/2013/06/03/the-convenience-of-number-range-objects

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b042b45c-8a73-3010-e288-9c9042404...

regards,

Arun

Former Member
0 Kudos

Hi Arun,

NRO is no doubt is easiest solution but we don't have B2B cockpit installed on our PI7.4 system.

Other option please.

Thanks,

Nida

RaghuVamseedhar
Active Contributor
0 Kudos

Nida,

Please use "graphical variable" instead of Global variable.

FYI ...