cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in creating UDF to read multiple rows of IDOC segment

Former Member
0 Kudos

Hi Experts,

I am working on IDOC to File scenario, in message mapping i have to read segment of idoc (occurence of this segment is 0..4) and check the key of this segment and accordingly pass the value. I am creating a UDF to send the data in target field

My logic in UDF is as follows

if id = BB and payment = V

return variable1

else

return variable2

this logic is not working

Note: The id BB is in second line of the segment and first line of the segment has id BA.

Please help me to send me the correct logic.

Regards,

Shradha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

After analysing this issue i come to know that the if condition is using data from 2 different segments

Segment1 (key fiiqualli)

The occurence of this segment is 0....4, Inside this segment i have 2 rows first row has Key Fiiqualli = BA, second row has key Fiiqualli = BB

Segment2 (Key payment id)

The occurence of this segment is 0....1

Inside this segment i have only 1 row with Key payment ID= V

Now if i write the condition if fiiqualli = BB and payment ID = V

return 1

else

return 2

Here if condition fails for second line but works for first line because it is unable to read payment ID for second row as payment id is in different segment.

Is there any way to read the data from two different segment where the occurence of one segment is 0..4 and other is 0..1

Regards,

Shradha

Former Member
0 Kudos

Hi,

U havent mentioned ur question correctly???

What i have understood is that:

Source:

<E1IDB02 SEGMENT="1">

<FIIQUALI>BA</FIIQUALI>

</E1IDB02>

<E1IDB02 SEGMENT="1">

<FIIQUALI>BB</FIIQUALI>

</E1IDB02>

<Payment>

<PaymentId>V</PaymnetId>

</Payment>

Target Required:

<G_SSG2>

<S_FII>

<C_C088>

<D_1131>10</D_1131>

</C_C088>

</S_FII>

</G_SSG2>

<G_SSG2>

<S_FII>

<C_C088>

<D_1131>15</D_1131>

<C_C088>

</S_FII>

</G_SSG2>

If yes?? then use this UDF:

for(int i=0;i<var1.length;i++)

{

if(var1<i>.equals("BB") && var2[0].equals("V"))

{

result.addValue("15");

}

else

{

result.addValue("10");

}

}

Mapping:

1)E1IDB02 ---G_SSG2

2) FIIQUALIremovecontext

-


UDF-SplitByVlaue--S_FII

PaymentId----


3) FIIQUALIremovecontext

-


UDF-SplitByVlaue---C_C088

PaymentId----


4) FIIQUALIremovecontext

-


UDF-SplitByVlaue---D_1131

PaymentId----


Thanks

Amit

Former Member
0 Kudos

Hi Amit,

Thanks a lot. Problem solved

Points awarded

Regards,

Shradha

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Paste ur input XML structure and the desired output structure??

i think u need to take care abt the context...

Thanks

Amit

Former Member
0 Kudos

Hi Amit,

My source and target structure are as follows

My requirement is if FIIQUALI = BB than return D_1131 = 25 else D_1131= 20.

+Source IDOC structure:+

- <E1IDB02 SEGMENT="1">

<FIIQUALI>BA</FIIQUALI>

<FIIBKENN>206151</FIIBKENN>

<FIIBKCDE>013</FIIBKCDE>

<FIIBKNAM>BARCLAYS BANK PLC</FIIBKNAM>

<FIIBKORT>NORTHAMPTON NN1 4YD</FIIBKORT>

<FIIBLAND>GB</FIIBLAND>

<FIIKONTO>18150680</FIIKONTO>

<FIIKWAER>USD</FIIKWAER>

<CTABNAME>Norman Jackson</CTABNAME>

<FIIBRANCH>NTHAMPTON WELLINBOROUGH RD</FIIBRANCH>

</E1IDB02>

- <E1IDB02 SEGMENT="1">

<FIIQUALI>BB</FIIQUALI>

<FIIBKENN>BOFAUS3NWDC</FIIBKENN>

<FIIBKCDE>002</FIIBKCDE>

<FIIBKUKN>054001204</FIIBKUKN>

<FIIBKUCD>003</FIIBKUCD>

<FIIBKNAM>BOFA</FIIBKNAM>

<FIIBKORT>WASHINGTON DC</FIIBKORT>

<FIIBLAND>US</FIIBLAND>

<FIIKONTO>1920901042</FIIKONTO>

<FIIKNAME>VERISIGN INC</FIIKNAME>

</E1IDB02>

Target File structure:

- <G_SSG2>

- <S_FII>

<D_3035>OR</D_3035>

- <C_C078>

<D_3194>18150680</D_3194>

</C_C078>

- <C_C088>

<D_1131>25</D_1131>

<D_3434>206151</D_3434>

<D_1131_2>154</D_1131_2>

<D_3055_2>133</D_3055_2>

<D_3432>BARCLAYS BANK PLC</D_3432>

<D_3436>NORTHAMPTON NN1 4YD</D_3436>

</C_C088>

</S_FII>

</G_SSG2>

- <G_SSG2>

- <S_FII>

<D_3035>BF</D_3035>

- <C_C078>

<D_3194>1920901042</D_3194>

<D_3192>VERISIGN INC</D_3192>

</C_C078>

- <C_C088>

<D_1131>20</D_1131>

<D_3434>BOFAUS3NWDC</D_3434>

<D_1131_2>154</D_1131_2>

<D_3055_2>133</D_3055_2>

<D_3432>BOFA</D_3432>

<D_3436>WASHINGTON DC</D_3436>

</C_C088>

</S_FII>

</G_SSG2>

Regards,

Shradha

Former Member
0 Kudos

Hi,

why u need a UDF for this?? u can achieve the same using standard functions.

FIIQUALI

-


equalS(Text)--


IfThenElse--


D_1131

Conatnt(BB)

Constant(25)-----Then

Constat(20)----else

Thanks

Amit

Former Member
0 Kudos

Hi Amit,

I tried the same mapping. I am getting following error when i am testing my mapping

Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Cannot cast 'BB' to boolean] in class com.sap.aii.mappingtool.flib7.Bool method equalsBoolean[BB, BB, com.sap.aii.mappingtool.tf7.rt.Context@78a7b003] com.sap.aii.utilxi.misc.api.BaseRuntimeException: Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Cannot cast 'BB' to boolean] in class com.sap.aii.mappingtool.flib7.Bool method equalsBoolean[BB, BB, com.sap.aii.mappingtool.tf7.rt.Context@78a7b003]

Regards,

Shradha

Former Member
0 Kudos

I got it, that was my mistake i used EQUALS of boolean.

I will test all my scenarios and let you know.

I have one more question, do i need to insert removecontext in my parent node also. so that i can read both records.

Regards,

Shradha

Former Member
0 Kudos

Hi,

Yes use "equals" function under "Text" and no need of remove context.

Thanks

Amit

Former Member
0 Kudos

Thanks for your help

I have the same scenario in my second field mapping, but i have 2 fields in if condition

if fiiquali = BB and paymentid = V

return 10

else

return 15.

In this case i tried to use standard function AND from boolean. But i am not getting desired result. Am i missing something.

Also i like to know what is the impact if i map source parent segment(G_SSG2) -> removecontext-> target parent segment(G_SSG2)

since i am reading multiple lines, whether remove context will be helpful or not.

Regards,

Shradha

Former Member
0 Kudos

Hi,

FIIQUALI

-


equalS(Text)----


Conatnt(BB)

-


AND---IfThenElse--


D_1131

Payment

-


equalS(Text)----


Conatnt(V)

Constant(10)-----Then

Constat(15)----else

there is no need to do so..just map it 1 to 1

( parent segment(G_SSG2) -> removecontext-> target parent segment(G_SSG2))

Thanks

Amit

Former Member
0 Kudos

Hi Amit

I tried the same way. But it not working. Although when i run my mapping in test mode than i am getting correct values.

Is it because i have 2 lines in my segment?

Please see my mapping below

FIIQUALI

equalS

Constant 

[BB] Constant15

AND  ifthenelse D_1131

PAYMENT

equalS

Constant  Constant10

[V]

Thanks

Shradha

Former Member
0 Kudos

when i run my mapping in test mode than i am getting correct values

then where r u getting the error?? once again chk ur mapping

Thanks

Amit

Former Member
0 Kudos

I am getting this problem when i am executing IDOC from R/3.

There its only reading first line (where key is BA) not second one (where key is BB)

Regards,

Shradha

Former Member
0 Kudos

map E1IDB02 ---G_SSG2(i hope this target node is having unbounded cardinality) and do same mapping suggested above for the target filed.

Note: I have chked this and it is working fine for me.

Thanks

Amit

Former Member
0 Kudos

Sorry to say...i am mapping the parent node also (cardinality is 0....4 for both)

but still not working. Am i missing something?

Regards,

Shradha