cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping tdline at item level

former_member452321
Participant
0 Kudos

I tried to generate mulitple target notes based on count (10) of tdlines on each item level

E1EDP01>E1EDPT1>E1EDPT2>TDLINE

Using the following udf

int count = Integer.parseInt(segcount[0]);

for (int i=0; i<count; i= i+10)

{

result.addValue("");

}

I have two E1EDPT1>E1EDPT2>TDLINE(with 5 tdlines) segments on source on each E1EDPO1 segments . Expecting two Notes segments on each item level on target

But I am getting all four Notes in first item level only

mapping .(TDlinecontext set to E!ETPT1) .I tried and changed to E1DP01 then i got only one segment on each item

TDLine>count>udf.>removecontext>Notes

Thanks for your help

Accepted Solutions (0)

Answers (3)

Answers (3)

praveen_sutra
Active Contributor
0 Kudos

hi Mahesh,

Please try this.

hope this helps.

thanks and regards,

Praveen T

Ryan-Crosby
Active Contributor
0 Kudos

Hi Mahesh,

Keep your original context and add this to the end of your UDF after the for loop:

result.addContextChange();

Regards,

Ryan Crosby

former_member452321
Participant
0 Kudos

Thanks Ryan. Attached display queue for count,udf and final target .getting only one Notes Node in target in first item level

Ryan-Crosby
Active Contributor
0 Kudos

Hi Mahesh,

Ok, I think maybe I was misunderstanding how you want your output to look.  Based on the queues that you have listed how are you expecting your XML output to look?

Regards,

Ryan Crosby

former_member452321
Participant
0 Kudos

In first E1EDP01 ,there are two E1EDPT1 >E1EDPT2 with one 5 TD lines and other E1EDPT1 >E1EDPT2 has one TDline . So I am expecting in first item level two notes and similar way in EDP01 expecting two Notes .If you look at the incoming dispaly queue for udf 5 CC 1 are first item TDlines count and 5 CC 1 are second t item TDlines count  .each line item there should be atleast two Notes .

Ryan-Crosby
Active Contributor
0 Kudos

Hi Mahesh,

It looks like you want to setup your UDF like this then:


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

{

int num = Integer.parseInt(count[i]);

for(int j = 0; j < num; j++)

{

result.addValue("");

}

result.addContextChange();

}

Regards,

Ryan Crosby

Ryan-Crosby
Active Contributor
0 Kudos

I also forgot to mention that you want to remove the RemoveContext function that you have in your field mapping.

former_member452321
Participant
0 Kudos
getting this Exception:[java.lang.NumberFormatException: For input string: "__cC_"] in class com.sap.xi
Ryan-Crosby
Active Contributor
0 Kudos

Hi,

Oops, so that RemoveContext will actually come in handy... reverse the order of that and the UDF and then you should be all set to go.

former_member452321
Participant
0 Kudos

firs item created 5 notes and 2nd item level created one note . For TDline count of 1 to 10 ,one note in target is requried .So If  we  have 5, one note ,15 two notes ,21  three notes like that for each E1EDPT1. with the following getting each item only one Note . Expecting two in each item 

for(int i = 0; i < count.length; i++) 
{  
  int num = Integer.parseInt(count[i]); 
     for(int j = 0; j < num; j = j+10)  
      {  

      result.addValue("");  

    } 
     result.addContextChange(); 
  } 

Ryan-Crosby
Active Contributor
0 Kudos

Hi Mahesh,

Ok, now I see what you are meaning... you are talking about the total count of notes so that's using integer division... change to the following code:


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

{

int num = (Integer.parseInt(count[i]) / 10) + 1;

for(int j = 0; j < num; j++)

{

result.addValue("");

}

if(i < count.length - 1)

result.addContextChange();

}

Regards,

Ryan Crosby

Message was edited by: Ryan Crosby

former_member452321
Participant
0 Kudos

Hi Ryan,

Received only one Note on each item level.

Expecting each two notes in each line item since we have two EDPT1 segments in each line item

Ryan-Crosby
Active Contributor
0 Kudos

Hi,

if you always need 2 per item always then change line 3 to:

int num = 2;

Regards,

Ryan Crosby

former_member452321
Participant
0 Kudos

It is not the question of always need 2 per item. for each   E1EDPT1  generate based on the no of tdlines

 

The structure

          E1EDPT1   

                         TDID 0..99

             E1EDPT2     0.999999999999

               TDLINE

             E1EDPT2

                 TDLINE                                          for every 10 TDlines one note in taget 1st line item

             E1EDPT2      

               TDLINE

              E1EDPT2

                 TDLINE

              E1EDPT1     

                         TDID 0..99

             E1EDPT2     0.999999999999

               TDLINE

             E1EDPT2

                 TDLINE                                          for every 10 TDlines one note in taget 1st line item

             E1EDPT2      

               TDLINE

              E1EDPT2

                 TDLINE

2)E1EDP01 2nd  line item

          E1EDPT1   

                         TDID 0..99

             E1EDPT2     0.999999999999

               TDLINE

             E1EDPT2

                 TDLINE                                          for every 10 TDlines one note in taget 2nd line item

             E1EDPT2      

               TDLINE

              E1EDPT2

                 TDLINE

              E1EDPT1     

                         TDID 0..99

             E1EDPT2     0.999999999999

               TDLINE

             E1EDPT2

                 TDLINE                                          for every 10 TDlines one note in taget 2nd line item

             E1EDPT2      

               TDLINE

              E1EDPT2

                 TDLINE

So we need divide all TDlines of E1EDPT2/10 under each  E1EDPT1   

Ryan-Crosby
Active Contributor
0 Kudos

Hi,

The code I have given that mentioned integer division would already do this if you have your source context setup correctly.  There is no way for me to tell where the necessary context changes would need to be placed without seeing sample source and expected target xml however.

Regards,

Ryan Crosby

former_member452321
Participant
0 Kudos

Thank you Ryan for looking in to this .I set up context change for TDLine to   E1EDPT1
,I tried with E1EDP01 context also .Still i got the same result. 1st E1EDP01 item > 2nd E1EDPT2 tdlines moved to 2nd item level. Not sure if i am not doing something not correct.

tdline-count -remove context-udf-notes

Thanks

Ryan-Crosby
Active Contributor
0 Kudos

Hi,

My hands are tied without knowing the target structure and expected xml.  The understanding of that is crucial to knowing the proper arrangement of contexts in the source and context chanes.  Once I know that I can help solve your troubles.

Regards,

Ryan Crosby

former_member452321
Participant
0 Kudos

Source                                                                                     Target

E1EDP01 

      E1EDPT1        0..99                                                                   Notes 0..10000

        TDID          1.1                                                                                   Id 0.1

    E1EDPT2     0.999999999999                                                           Text 1..1

        TDLINE 0..1

For each 10 Tdlines need to generate one Notes structure on target in each item

Ryan-Crosby
Active Contributor
0 Kudos

Hi,

I tried this out using this target structure:

I mapped Item and Notes like this (TDLINE was set to E1EDP01 context and my UDF was all values of a context):

I used this code since it was all values of a context:


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

{

int num = (Integer.parseInt(count[i] / 10) + 1;

for(int j = 0; j < num; j++)

{

result.addValue("");

}

}

This was the XML result that I got when I had 11 TDLINE values for each E1EDP01 segment:


<?xml version="1.0" encoding="UTF-8"?>

<Item><Notes></Notes><Notes></Notes></Item>

<Item><Notes></Notes><Notes></Notes></Item>

Based on what you have described of 1 Notes node per 10 TDLINES that UDF should be working fine.  The only question is whether you were using all values of a context or queue and what your full target structure looks like.

Regards,

Ryan Crosby

former_member452321
Participant
0 Kudos

Hi Ryan,

Context change set to E1EDP01 for TDline. Attached test data with two E1EDPT1 segments E1EDPT2-one TDline in line item( E1EDP01). Similary in 2nd E1EDP01 also  two E1EDPT1 segments E1EDPT2-one TDline . There is only one Notes structure in each line item created . Expecting two since we have two E1EDPT1 in each E1EDP01. Set all values of context The issue is with the count I guess. We need to count under each z1edpt1 based on no of tdlines and create strucutre. changed the context to E1EDPT1 added removed context but created all 4 notes in first item only

Ryan-Crosby
Active Contributor
0 Kudos

Hi,

Change your mapping for TDLINE -> Notes like so:

Set the context of TDLINE to E1EDPT1 and the context of E1EDPT2 to E1EDP01.

Regards,

Ryan Crosby

Message was edited by: Ryan Crosby

former_member452321
Participant
0 Kudos

I tried the above and still got the one note on each item .

former_member452321
Participant
0 Kudos


sorry .it worked now . I need to test with other test data .Thanks

former_member452321
Participant
0 Kudos
Tested with 5 and 1 td lines in each line item Receving Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Function formatByExample: Queues do not have the same number of values] in class com.sap.aii.mappingtool.flib7.NodeFunctions method formatByEx
Ryan-Crosby
Active Contributor
0 Kudos

Try switching the source value E1EDPT2 with E1EDPT1 instead.  I tried that for your example and it worked ok.

former_member452321
Participant
0 Kudos


Thank you ryan for your help. This could be final issue. when there is no E1EDPT1 present in any of the line items getting that exception

com.sap.aii.mappingtool.tf7.FunctionException: Function formatByExample: Queues do not have the same number of values] in class com.sap.aii.mappingtool.flib7.NodeFunctions method formatByEx

Thanks again

Ryan-Crosby
Active Contributor
0 Kudos

Hi Mahesh,

Adjust the field mapping like this to handle the blank case:

Regards,

Ryan Crosby

former_member452321
Participant
0 Kudos

I tried this it didnt working still throwing the same exception

Ryan-Crosby
Active Contributor
0 Kudos

Hi,

Can you share your source XML for the E1EDPO1 segments?  I'll try it out on my test mapping because it worked as expected using the map I sent above.

Regards,

Ryan Crosby

former_member452321
Participant
0 Kudos

<E1EDP01 SEGMENT="1">

         <POSEX>00010</POSEX>

         <ACTION>001</ACTION>

         <PSTYP>0</PSTYP>

         <MENGE>4.000</MENGE>

         <MENEE>EA</MENEE>

         <BMNG2>4.000</BMNG2>

         <PMENE>EA</PMENE>

         <VPREI>12.39</VPREI>

         <PEINH>1</PEINH>

         <NETWR>49.56</NETWR>

         <MATKL>078XX</MATKL>

         <BPUMN>1</BPUMN>

         <BPUMZ>1</BPUMZ>

         <WERKS>2400</WERKS>

         <Z1KONV2 SEGMENT="1">

            <KNUMV>1000022683</KNUMV>

            <KPOSN>000010</KPOSN>

            <KBETR>       12.39</KBETR>

         </Z1KONV2>

         <Z1EKET2 SEGMENT="1">

            <SLFDT>20120702</SLFDT>

            <LPEIN>1</LPEIN>

            <ETENR>0001</ETENR>

         </Z1EKET2>

         <Z1EKPO2 SEGMENT="1">

            <KNTTP>F</KNTTP>

            <PSTYP>0</PSTYP>

            <AFNAM>Stores</AFNAM>

            <EFFWR>         53.82</EFFWR>

            <REPOS>X</REPOS>

            <WEBRE>X</WEBRE>

            <WEPOS>X</WEPOS>

            <ZZDIRECT>Taxable</ZZDIRECT>

            <XERSY>X</XERSY>

         </Z1EKPO2>

         <Z1EKKN2 SEGMENT="1">

            <SAKTO>0000620102</SAKTO>

            <PS_PSP_PNR>00000000</PS_PSP_PNR>

            <AUFNR>000010015832</AUFNR>

            <VPROZ> 0.0</VPROZ>

            <WEMPF>test</WEMPF>

            <ABLAD>Jude</ABLAD>

            <MENGE>         4.000</MENGE>

         </Z1EKKN2>

         <E1EDP20 SEGMENT="1">

            <WMENG>4.000</WMENG>

            <AMENG>0.000</AMENG>

            <EDATU>20130702</EDATU>

         </E1EDP20>

         <E1EDP19 SEGMENT="1">

            <QUALF>001</QUALF>

            <KTEXT>4MUX5 - test</KTEXT>

         </E1EDP19>

      </E1EDP01>

Ryan-Crosby
Active Contributor
0 Kudos

Hi Mahesh,

This payload worked perfectly in the map with the ifwithoutelse function setup for Notes as the target.  Can you send a screenshot of your field mapping on Notes?

Regards,

Ryan Crosby

former_member452321
Participant
0 Kudos

soory .I was using ifSthenelse. It is working as expected . Thank you

former_member452321
Participant
0 Kudos

Hi Ryan,

Sorry to come again with the same issue. Attached source xml with two edpt1 segments each 3 tdlines in each line items . Modifled code to tdline count/2(for testing). So for each edpt1 expecting two notes in target . So total for each line item  I am  getting only two in each line item target .Expecting four in each line item

  <E1EDP01 SEGMENT="1">

       

         <E1EDPT1 SEGMENT="1">

            <TDID>G1</TDID>

            <TSSPRAS>E</TSSPRAS>

            <TSSPRAS_ISO>EN</TSSPRAS_ISO>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>1ST LINE ITEM </TDLINE>

               <TDFORMAT>*</TDFORMAT>

            </E1EDPT2>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>1ST LINE ITEM </TDLINE>

               <TDFORMAT>/</TDFORMAT>

            </E1EDPT2>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>1ST LINE ITEM </TDLINE>

               <TDFORMAT>/</TDFORMAT>

            </E1EDPT2>

         </E1EDPT1>

         <E1EDPT1 SEGMENT="1">

            <TDID>G2</TDID>

            <TSSPRAS>E</TSSPRAS>

            <TSSPRAS_ISO>EN</TSSPRAS_ISO>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>1ST LINE ITEM </TDLINE>

               <TDFORMAT>*</TDFORMAT>

            </E1EDPT2>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>1ST LINE ITEM </TDLINE>

               <TDFORMAT>*</TDFORMAT>

            </E1EDPT2>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>1ST LINE ITEM </TDLINE>

               <TDFORMAT>*</TDFORMAT>

            </E1EDPT2>

         </E1EDPT1>

      </E1EDP01>

      <E1EDP01 SEGMENT="1">

       

         <E1EDPT1 SEGMENT="1">

            <TDID>G3</TDID>

            <TSSPRAS>E</TSSPRAS>

            <TSSPRAS_ISO>EN</TSSPRAS_ISO>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>2ND LINE ITEM</TDLINE>

               <TDFORMAT>*</TDFORMAT>

            </E1EDPT2>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>2ND LINE ITEM</TDLINE>

               <TDFORMAT>/</TDFORMAT>

            </E1EDPT2>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>2ND LINE ITEM</TDLINE>

               <TDFORMAT>/</TDFORMAT>

            </E1EDPT2>

         </E1EDPT1>

         <E1EDPT1 SEGMENT="1">

            <TDID>G4</TDID>

            <TSSPRAS>E</TSSPRAS>

            <TSSPRAS_ISO>EN</TSSPRAS_ISO>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>2ND LINE ITEM</TDLINE>

               <TDFORMAT>*</TDFORMAT>

            </E1EDPT2>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>2ND LINE ITEM</TDLINE>

               <TDFORMAT>*</TDFORMAT>

            </E1EDPT2>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>2ND LINE ITEM</TDLINE>

               <TDFORMAT>*</TDFORMAT>

            </E1EDPT2>

            <E1EDPT2 SEGMENT="1">

               <TDLINE>2ND LINE ITEM</TDLINE>

               <TDFORMAT>*</TDFORMAT>

            </E1EDPT2>

         </E1EDPT1>

      </E1EDP01>

Thank you

Ryan-Crosby
Active Contributor
0 Kudos

Hi Mahesh,

It looks like a result of how the system manages the queue when using the ifWithouElse that it suppresses many values because the length of each context has to match.  If we move the UDF to the spot after the ifWithoutElse then it solves the queue suppression problem:

Regards,

Ryan Crosby

Message was edited by: Ryan Crosby

former_member452321
Participant
0 Kudos

Thank you. Attached display queue . Getiing 3 in target and expecting four in each line item

Ryan-Crosby
Active Contributor
0 Kudos

Hi Mahesh,

You'll need to double check the contexts and code then... I got a total of 4 & then 5 on the second line item for the same mapping.  Based on your example from the 10 before it would be 2 notes nodes for a count of 3 and 3 for a count of 4 (the num + 1 part in the code).

Regards,

Ryan Crosby

Former Member
0 Kudos

Hi. Can you put your XML Source and the XML expected ?

Regards

former_member452321
Participant
0 Kudos

Attached source for 1st item EDP01 .Similar data on second item E1EDP01 also

Expecting target

Item(1)

Notes

Notes

Item(2)

Notes

Notes

Thank you