cancel
Showing results for 
Search instead for 
Did you mean: 

count of number of target segments at runtime

Former Member
0 Kudos

Hi,

I have a requirement to dynamically count the total number of segments and subsegments generated in the target structure(flat file) and map that count to the last field of the same structure.

This count should also consider the segment to which this field belongs.

Any suggestions on how this can be achived

Thanks in advance

Minisha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can achive this by seting the globle container in the root node and then incrementing it at the node which you want to count. You can write UDF to set the globle container variable. and when you want to increment it then write a UDF to first get the globle container variable and then increment it and set this value by calling the set globle container variable.

Former Member
0 Kudos

Hi Shweta,

Thanks for your response.

I am aware that global container variable can be used to get the count but am unable to implement it correctly in a UDF.

it would be really helpful if you could tell me how exactly the getParameter() and setParameter() functions should be used.

Regards,

Minisha

Former Member
0 Kudos

UDF for set globle container:

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

GlobalContainer gc = container.getGlobalContainer();

gc.setParameter(globalContainerName,globalContainerValue);

return globalContainerValue;

Use: Send Variable name and value to initialise the count.

UDF to get the goble Container.

public String getGlobalContainer(String globalContainer,Container container){ //write your code here

String gctmp;

GlobalContainer gc = container.getGlobalContainer();

gctmp = (String) gc.getParameter(globalContainer);

return gctmp;

Use: when you want to increment: First call this udf with the veriable name you set in the first UDF. then increment the value by one and call set goble container UDF to set the new value of this variable.

Answers (1)

Answers (1)

Shabarish_Nair
Active Contributor
0 Kudos

had a chance to look thru some of the options mentioned here? - http://wiki.sdn.sap.com/wiki/display/XI/CountofRecords-%27Countontheeasiestway+through%27