cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to count values of a field when other field in parent segment is blank

Former Member
0 Kudos

Hi Friends

Please help me out on below requirement!!

IDOC to File scenario.

Structure:

IDOC

     E1EDL20  (0 to unbounded)

          E1EDL37 (0 to unbounded)

               E1EDL38 (0 to unbounded)

if field A of E1EDL37 =empty/blank then check for values of field B in E1EDL38 and count them.

for example:

Input IDOC:

               E1EDL37

                         field A=blank

                         E1EDL38

                                field B= Rose

----------------------------------------------------------

               E1EDL37

                         field A=blank

                         E1EDL38

                                field B= Rose

----------------------------------------------------------

               E1EDL37

                         field A=00113

                         E1EDL38

                                field B= Rose

----------------------------------------------------------

               E1EDL37

                         field A=blank

                         E1EDL38

                                field B= Green

----------------------------------------------------------

               E1EDL37

                         field A=blank

                         E1EDL38

                                field B= Orange

----------------------------------------------------------

               E1EDL37

                         field A=00116

                         E1EDL38

                                field B= Orange

Output File:


No.of Roses= 2

No.of.Orange=1

No.of.Green=1

I tried using standard functions.Its not working.Please find the screen shot of logic.

Do we need UDF for this?Please help me out!!

Regards

Anitha

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

No need for UDF. You just need to rearrange your logic, something like this

Regards,

Mark

Former Member
0 Kudos

Thank you Harsha.... I cant use Sort by value.Because the no.of values for VEBEZ and SORTL will not be equal.

Thank you Mark!!

I tried this.When we use Count function it is counting no.of values in each context and sending as output.

But my requirement is as below:This is where I am struggling!!

I have three output fields like

No. of Green

No.of Rose

No.of Orange.

For output field No.of Rose I should send count of only Rose and if no Rose then '0'

For output field No.of Orange I should send count of only Orange and if no Orange then '0'

For output field No.of Green I should send count of only Green and if no Green then '0'

As Count function count values in each context... to get desired output do we need UDF.

If not please help me out!!

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Anitha,

Since you have three output fields, in that case it makes the logic easier. Just repeat the logic below for Orange and Green (replace Rose)

Regards,

Mark

Former Member
0 Kudos

Thank you Mark for Prompt response.

I will try this and let you know the result.

Regards

Anitha

Former Member
0 Kudos

Hi Mark

Thank you Very much!!

I tried the logic as per your suggestion.My scenario working as expected.

Hence closing the thread.

Regards

Anitha

Answers (1)

Answers (1)

Harish
Active Contributor
0 Kudos

Hi Anitha,

You are doing sorting for VEBEZ then you need to apply sort by key for other input field, so the context is correct for the mapping.

regards,

Harish