cancel
Showing results for 
Search instead for 
Did you mean: 

Counter Problem for each context change in UDF

sridharreddy_kondam
Active Contributor
0 Kudos

Hi All,

I am stuck with the counter problem...

For Each E1EDL20>VSTEL and E1EDL20>E1EDL24(1...N) the counter should be incremented and whenever new E1EDL20 then again the counter should start from 1

IDOC (DELVRY06)

For e.g

1.E1EDL20

VSTEL = 61

E1EDL24

E1EDL24

2.E1EDL20

VSTEL = 61

E1EDL24

E1EDL24

E1EDL24

3.E1EDL20

VSTEL = 68

E1EDL24

E1EDL24

4.E1EDL20

VSTEL = 61

E1EDL24

E1EDL24

E1EDL24

E1EDL24

Then target counter should be like this for each E1EDl20 -->VSTEL = 61 then only the counter should be incremented and for each context change the counter value should start from 0001.

Target Structure-->

1.

Contfield-->0001

Contfield-->0002

2.

Contfield-->0001

Contfield-->0002

Contfield-->0003

4

Contfield-->0001

Contfield-->0002

Contfield-->0003

I am using Value based UDF by passing VSTEL(equal to 61 then pass true) and E1EDL24 (exists pass true) and it doesnt work,,,

I think i should use context based... but how can use ResultList and return the above values..

Please hint me and help me...

Regards,

sridhar reddy

Accepted Solutions (0)

Answers (3)

Answers (3)

sridharreddy_kondam
Active Contributor
0 Kudos

The problem is solved with passing another third input value and checking the idoc counts and using it and making the value to reinitialize with 0

Thanks all

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

Have you tried using the index function for this?

Regards,

Shabarish_Nair
Active Contributor
0 Kudos

did you try right clicking the input fields VSTEL and E1EDL24 and changing their context to E1EDL20??

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Shabarish,

Thanks for the quick reply...

The context for both VSTEL and E1EDL24 is E1EDl20 only.

But my confusion is the java code in the UDF... mean how to return the ResultLIst ...should i loop the E1EDL24 or?

Please could You give some sample code....

Regards,

Sridhar

Shabarish_Nair
Active Contributor
0 Kudos

so there are two thing that you can look at;

1. remember that your UDF will get executed for each context change.

So suppose your context looks like

A

B

=

AA

BB

CC

=

X

Y

Z

where = indicates a context change, your UDF will first execute for the first context with values A and B and then pass it to resultlist and then reinitialize, go to next context etc.

2. instead of a UDF use the count function. it will return the number of occurances which is what u need

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Shabarish,

I need the target counter for each E1EDl20 --> E1EDL24 where VSTEL = 61 and it should ignore VSTEL = 68...

So for each E1ELD20 there may be multiple E1EDL24, nad the target counter field should give the no of occurences of each E1EDL24 ...

0001

0002

0001

0002

0003

COunt gives the no. of occurances of the E1EDL24 in each E1EDL20 context...

Hope you understood what exactly i need..

Regards,

sridhar

Shabarish_Nair
Active Contributor
0 Kudos

COunt gives the no. of occurances of the E1EDL24 in each E1EDL20 context...

so you should put the condition for the count as "where VSTEL = 61"

try;

VSTEL (check with EqualsS Constant 61) --------- IF
                                                                        THEN -> COUNT -> E1EDL24 -> TARGET

make sure both the context of VSTEL and E1EDL24 is of E1EDl20

Former Member
0 Kudos

try using Index function instead of Count

Index with these parameters

initial value 1, increment 1 and Count Indices in context

you will have to play with Context of source