cancel
Showing results for 
Search instead for 
Did you mean: 

Array index out of bounds exception udf

former_member452321
Participant
0 Kudos

Please I need help on the following udf attached screenshot of data which is coming in E1EDP01 . Expecting one Ref segments in target.Getting exception if the Rate is not present in second Z1EKPD1 segment for( i = 0; i < aContractNo.length; i++ ){ if (!aContractNo[i].equals("")){ if ((!aRating[i].equals(""))||(!aRating[i].equals(null))){ resultRef.addValue("");   } } } zzcontractnumber>mapwithdefault> udf > removecontext>splitbyvalue>Ref zzpasrating>mapwithdefault>both context set to E1EDP01

Accepted Solutions (0)

Answers (1)

Answers (1)

Muniyappan
Active Contributor
0 Kudos

can you try below if it works.

for( i = 0; i < aContractNo.length && i < aRating.length ; i++ )

former_member452321
Participant
0 Kudos

thank you it worked but I can't use that condition. There are some other fields in Z1EKPD1 segements which I need to create similar ref segments . first main condition is contractno exist then for the remaining each I need to create ref in target In this case rating doestnot exist but other fields exist so it should create remaining ref in target Z1EKDP1 ZZCONTRACTNUMBER ZZPARSRATING ZZPRIMECONTRACT ZZSQTY

Muniyappan
Active Contributor
0 Kudos

Hi,

I could not get your requirement.below code will send blank to target if ZZPARSRATING  has some values in source side.


if ((!aRating[i].equals(""))||(!aRating[i].equals(null))){ resultRef.addValue("");   }

do you want to pass blank to (target)ZZPARSRATING if source xml does not have ZZPARSRATING  tag?


you can try below options.

1. ZZPARSRATING -->mapwithdefault-->ZZPARSRATING

so whenever source does not have ZZPARSRATING it will create the tag in the target.

2. if you use udf then modify below code

if ((!aRating[i].equals(""))||(!aRating[i].equals(null))){ resultRef.addValue("");   } 


to


if ((aRating[i].equals(""))||(aRating[i].equals(null))){ resultRef.addValue("");   }


former_member182412
Active Contributor
0 Kudos

Hi Mahesh,

>>>>>first main condition is contractno exist then for the remaining each I need to create ref in target


  • You can use below mapping for target root node.

          ZZCONTRACTNUMBER-->exists-->removecontexts-->createif-->Z1EKPD1


  • All the fields you can map directly.

           ZZCONTRACTNUMBER------>ZZCONTRACTNUMBER

       


Regards,

Praveen.

former_member452321
Participant
0 Kudos

It should not create blank value in target and it should not throw exception if the rating field doesnot exist There are two Z1EKPD1 segments in test data as below. It should create segment if the data exist only for all of these four E1EDP01 Z1EKPD1 ZZCONTRACTNUMBER ZZPARSERATING ZZPRIMECONTACT ZZQTY Z1EKPD1 ZZCONTRACTNUMBER ZZPRIMECONTACT ZZQTY In this case  for the first Z1EKPD1 , getting 4 refsements which is expected in the second Z1EKPD1 , since there is no ZZAPRSRATING ,getting exception. I am expecting 3 ref segments . Already doing with mapwithdefault for all of these If there is any missing field in first Z1EKPD1 segments ,it doesn't throw exception only in the 2nd Z1EKDP1 segments missing any data ,throws exception first in for loop checking for contactnumber then checking for the all fields not blank then create target for each

Muniyappan
Active Contributor
0 Kudos

is this what you expecting? please make sure that source fields are in root node context.

former_member452321
Participant
0 Kudos

Thank you