cancel
Showing results for 
Search instead for 
Did you mean: 

Need help on the java udf

former_member452321
Participant
0 Kudos


Hi

Here id the soruce strucre

Target -  I need to map it to Reference qualifer 1:Unbounded

z1EKPD1 can occur muliple times in one item

If zzontractnumber not eual to blank  then

     if substring(ZZPARSRATING(0,2) = DS then

          copy DS

               else

          if substring(ZZPARSRATING(0,2)= DX then

          copy DX

If the value of zzparsrating existing in all the line  items it is working but it it has only in 2nd item i am getting arryindexout of bound exception and not populating the value of zzparsrating

and if the Z1EKPD1 has more than one then also i am getting exception

Thanks for your help

Accepted Solutions (1)

Accepted Solutions (1)

former_member452321
Participant
0 Kudos

The issue is resolved

Muniyappan
Active Contributor
0 Kudos

Could you please close this thread?

please explain what you did to solve this.

former_member452321
Participant
0 Kudos

It is not completely solved i am getting other issue.If you help that will be appreciated.

1) Z1EKPD1 segment coming from idoc many times . But in target i have to create only one REF segment . This can be done by mapping Z1EKPD1 to constant .But sometimes i am getting the value of ZZASQTY with 0.000 in segment Z1EKPD1 and any not any other fields. In this case it should not create REF segment  in target . How can i give the condition to satisfy these

Thanks

Mahesh

Harish
Active Contributor
0 Kudos

Hi Mahesh,

If you want to create target node only when atleast one ZZASQTY is greater then 0.000 then put the below condition

ZZASQTY equals 0.000 --> Not --> remove context --> sort (true first) --> Collaps context --> If without else --> Map with constant.

regards,

Harish

former_member452321
Participant
0 Kudos

Thank you Harish. I have one Z1EDKP1 with all the four fields  In each line item .The ref segment created for first line item only and 2nd line item ther is no refsegment

what properties should i set up sort . Attached the screen shot

If the z1edkp1 has only one field it is not created REF segment which is i am expected . expected the issue above

Thanks

Harish
Active Contributor
0 Kudos

Hi Mahesh,

Do you have 4 Z1EDKP1 for 4 line item? If yes then remove the remove context, collaps context and sorting. Map the comparison direct to If.

If you have more Z1EDKP1 in input line item. Then take input on line item and remove the removecontext function.

Hope it help!

Harish

former_member452321
Participant
0 Kudos

Hi Harish,

Here is my scenarios

In each line item

1) If one Z1EKPD1 present with  four fiedls(ZZCONTRACTNUMBER,ZZDPASRATING,ZZPRIMECONTRACT,ZZASQTY )

then create on REF on target

2) If more than one Z1EKPD1 present with  four fiedls then create only one REF on target

3) If Z1EKPD1 is not present in any line item it should not create REF segment

4) If Z1EKPD1 is present one line item and not present 2nd line

item it should create one REF segment in the corresponding line item

5) Sometimes from idoc data coming with Z1EKPD1 and with only field ZZASQTY  =0.000

In this case it should not create REF segment in target

Thanks

former_member452321
Participant
0 Kudos

How can i make it  to create only one REFsegment in target If Z1EDKP1 repeated multiple times   I need only one in target .Context change for ZZASQTY is Z1EDKP1. But this getting the issue when there  Z1EDKP1 is not in first item and Z1EDKP1 is in 2nd item. In this case it is creatting in first item only and not 2nd item level . I changed the context to E1EDP01 it is working but creating issue if Z1EDKP1 is present multiple times. It is creating multiple REF segments


Harish
Active Contributor
0 Kudos

Hi Mahesh,

When you have more then one Z1EDKP1 in one line item and they can have ZZASQTY 0.000 or more. So you need to create target when atleast one ZZASQTY is more then 0.000. Please change your mapping as below

ZZASQTY (context of line item) --> trim --> equals (0.000) --> Not --> Sort (true on top) --> Collaps context --> input to if withoult else and map the constant.

In case of any issue, past the display queue screenshot.

regards,

Harish

former_member452321
Participant
0 Kudos

Thank you for looking in to this. with the above suggestion tested with two Z1EDKP1 in first item and one
Z1EDKP1 segment in second line item . But it created two ref segments in first line item and expecting only one and in 2nd line item expecting one REF segment and it didnt created anything.

Attached testdata.png for this and ifelse display queue .

if ZZASQTY =0.000 then this will always only once and only this field will be coming not other fields along with that  This is default is coming from idoc.

Attached testdata2.png for this sample and in this case it should not create any segment in target

Harish
Active Contributor
0 Kudos

Hi Mahesh,

your display queue and test tab screenshot are not matching. Can you check and provide the display again for same data?

regards,

Harish

former_member452321
Participant
0 Kudos

2 Z1EKPD1 in first line item and 1 Z1EKPD1 in second line item . created two refsegs in first lineitem and no segment is created in 2nd line item

Harish
Active Contributor
0 Kudos

Hi Mahesh,

Plesae use split by value after if without else.

regards,

Harish

former_member452321
Participant
0 Kudos

Thank you Harish we are almost there. When I am testing with no Z1EDKP1 segment in any item or one of the item getting the following error.

Compilation of mm_ORDEDERS__PO1 successful
Cannot cast '' to boolean
com.sap.aii.mappingtool.tf7.FunctionException: Cannot cast '' to boolean
at com.sap.aii.mappingtool.flib7.Bool.toBoolean(Bool.java:18)
at com.sap.aii.mappingtool.flib7.IfSWithoutElse.moveToNextRealValue(IfSWithoutElse.java:81)
at com.sap.aii.mappingtool.flib7.IfSWithoutElse.gotoNextContext(IfSWithoutElse.java:57)
at com.sap.aii.mappingtool.flib7.SplitByValue$SplitByEach.gotoNextContext(SplitByValue.java:131)
I tried with other Equals (from Boolean still getting the same issue
Thanks for your help
former_member452321
Participant
0 Kudos

Attached display queue when there  Z1EDPK1 not present in item

Harish
Active Contributor
0 Kudos

Hi Mahesh,

Please use map with default (0.000) before equals function.

regards,

Harish

former_member452321
Participant
0 Kudos

Thank you Harish. I tried with this and getting one issue. If the ZIEDKP1 doesnot exist in first item and if it exist in 2nd item with all the data then in first item level it created the REF segment and not in 2nd item level

If ZIEDKP1 exist in first item level and doesnot exist in 2nd item level it worked perfect

Thanks for your help

Harish
Active Contributor
0 Kudos

Hi Mahesh,

the problem is because gray suppress for first line item. So you need to change the property of if function to keep the suppress. but this may have impact on context of child field.

regards,

Harish

former_member452321
Participant
0 Kudos

yes. It is impacing the child after changing the properties of If

Thanks for your help

former_member452321
Participant
0 Kudos

Hi Harish,

Can it done through java udf for the same .?Thanks for your help

Thanks .

Harish
Active Contributor
0 Kudos

Hi Mahesh,

you can achieve this using UDF, but i prefer graphical mapping in this case. It is good for maintenance and upgrade/migration.

regards,

Harish

former_member452321
Participant
0 Kudos

I thought with the udf we can avoid the issue of creating refsegment in target when Z1KPD1 present because of this i have to do mapwith default for refernce qualifier also which is not expected

Harish
Active Contributor
0 Kudos

you can implement with udf if you like. Some cases it is easier to write a small java code then use so many mapping functions.

Please let me know if you need help in java code.

regards,

Harish

former_member452321
Participant
0 Kudos

I will appreciate if you could send me udf

1 Z1EKPD1 segment repeate multiple times in each item level and there should be one rfe segment

2 Z1EKPD1 may present one line item and not in other line items. corresponding line item it should create only one ref segment

3 Z1EKPD1 may not present any line items it should not create refsegment

4.sometimes Z1EKPD1>ZZASQTY field comes with default value with 0.000 and not any other fields  from idoc ,it should not create refsegment

I wrote the following udf but working as expected

int i;

for (i=0;i<z1edpk1.length;i++)
{

   if (((z1edpk1[i]==null))||((z1edpk1[i]!=null)&&(zzsqty[0].equals("0.000"))))
     {

      result.addSuppress();

     }
     else

    {
      
        result.addValue("");
  //result.addContextChange();
        }
  
}

Thanks

Harish
Active Contributor
0 Kudos

Hi Mahesh,

try the below code

int i;

for (i=0;i<z1edpk1.length;i++)
{

   if (((z1edpk1[i]==null))||(zzsqty[0].equals("0.000")))
     {

      result.addSuppress();

     }
     else

    {
      
        result.addValue("");
  //result.addContextChange();
        }
  
}

former_member452321
Participant
0 Kudos

Thanks Harish .It is workiing as expected.

Answers (3)

Answers (3)

former_member187010
Participant
0 Kudos

Hi Mahesh,

You are getting this error because substring function is being used with ZZParserating and it throws error for empty value.

If empty zzparserating is valid, then check for empty string first then use substring node function on zzparserating, no need to use udf.

Hope this helps.

If you have still confussion place your output structure, will help you.

Regards

Jitender

(No need to make thing complex when you can do it easily)

Muniyappan
Active Contributor
0 Kudos

Hi,

you can use mapwithdefault to populate some values when there is no zzparsrating is present.

you have to use this before udf.

ambrish_mishra
Active Contributor
0 Kudos

Hi Mahesh,

use duplicate subtree at the target side to create the target node(s) based on the conditions outlined above and populate a constant in the field below the structure. You have not shown the target structure so I am bit lost there.

Cheers

Ambrish