cancel
Showing results for 
Search instead for 
Did you mean: 

Creating target conditionally but mapping target field from the same source level as condition

former_member596513
Participant
0 Kudos

Hi,

We are on PI 7.4 SP 11. This is an IDOC to file scenario. I have few concerns and hope you can help me.

Source -

There will be only 1 E1WPZ01 with more than 1 E1WPZ02 which will have multiple E1WXX01 with different FLDGRP and FLDNAME combinations.

Target -

Condition 1 – Structure LedgerGL to be created ONLY if the source E1WXX01 has FLDGRP as A or B and FLDNAME = 10 or 20

Condition 2 – Value from source VORZECHEN to be mapped for every target created from the E1WXX01 under that E1WPZ02. I can map this across no issues as this is level above E1WXX01.

Condition 3 - Additionally, the value from FLDVAL for segment E1WXX01 with FLDGRP as TIME should be mapped to the target Filler. I am able to create the target based on the condition 1 including the value from condition 2 but unable to generate the target field Filler from E1WXX01 on the same level based on which the target is originally created.

Condition 4 – Target field NATW should have the sequential number generated based on how many LedgersGL target structures are generated. I am unable to do this in single mapping step but can be completed in step 2 mapping once I have the target structures generated. If there is any way to do this in single step mapping then please let me know.

The source will contain multiple E1WXX01 segments and not all are considered which is why the counter and index is not working.

Any advise please.

Regards,

Archana

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member596513
Participant
0 Kudos

Thank you Raghuraman and Praveen.

former_member186851
Active Contributor
0 Kudos

Helo Archana,,

Condition 1 – Structure LedgerGL to be created ONLY if the source E1WXX01 has FLDGRP as A or B and FLDNAME = 10 or 20

Check using If then and or condtions

FLDGRP Equals  A

                                      OR

FLDGRP Equals B                                             if Then  Map E1WXX01 to LedgerGL.

FLD Name  Equals 10     OR

FLD Name  Equals 20

Condition 3 - Additionally, the value from FLDVAL for segment E1WXX01 with FLDGRP as TIME should be mapped to the target Filler. I am able to create the target based on the condition 1 including the value from condition 2 but unable to generate the target field Filler from E1WXX01 on the same level based on which the target is originally created.

Change the context of FLDDVAL and FLDGRP to E1WPZ02 and try.

Condition 4

For this create a variable Counter

FLDGRP Equals  A

                                      OR

FLDGRP Equals B                                             if Then  Map Some constant like A To the Counter.

FLD Name  Equals 10     OR

FLD Name  Equals 20

Now count the occurences of the variable using Counter function and pass it to NATW.

Let me know if you face any issues

former_member596513
Participant
0 Kudos

Hi Raghuraman,

i tried what you have said about condition 3 but is giving incorrect values.

Queue and mapping-

E1WXX01 – for Time value-

Example source – 2 E1WPZ02 segments with multiple E1WXX01 segments

Based on condition 1 3 LedgersGL are generated which is ok.

Condition 2 is ok.

Based on condition 3, Value from source 1A should be mapped to Target LedgersGL 1 and 2 but is mapped to an incorrect instance of E1WXX01 as evident from queue.

Value from source 1B should be mapped to target instance 3 of LedgersGL but is also incorrect.

Source –

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

<WPUTAB01>

<IDOC>

<EDI_DC40>…</EDI_DC40>

<E1WPZ01>             --------------------------------------- Only once - Top level

<BELEGDATUM>20151001</BELEGDATUM>

<E1WPZ02>           -----------------------------------------First Instance

<VORZEICHEN>21.00</VORZEICHEN>

<ZAHLART>ZTMC</ZAHLART>

<SUMME>21.00</SUMME>

<WAEHRUNG>GBP</WAEHRUNG>

<E1WXX01>       -------------------------------------This generates target LedgersGL 1

<FLDGRP>TEND</FLDGRP>

<FLDNAME>GL</FLDNAME>

<FLDVAL>4000</FLDVAL> ------------in the queue this is mapped through for condition 3

</E1WXX01>

<E1WXX01>              -------------------------------------This generates target LedgersGL 2

<FLDGRP>TEND</FLDGRP>

<FLDNAME>BALGL</FLDNAME>

<FLDVAL>50000</FLDVAL>     ------------in the queue this is mapped through for condition 3

</E1WXX01>

<E1WXX01>   -----------This is what should be mapped for Condition 3 for 1 and 2 LedeersGL <FLDGRP>PERD</FLDGRP>

<FLDNAME>Month</FLDNAME>

<FLDVAL>1A</FLDVAL>

</E1WXX01>

</E1WPZ02>

<E1WPZ02>                      -----------------------------------------Second Instance

<VORZEICHEN>21.00</VORZEICHEN>

<ZAHLART>ZTMC</ZAHLART>

<SUMME>21.00</SUMME>

<WAEHRUNG>GBP</WAEHRUNG>

<E1WXX01>              -----------------This is invalid condition so no target LedgersGL

<FLDGRP>GL</FLDGRP>

<FLDNAME>ACCOUNT</FLDNAME>

<FLDVAL>6000</FLDVAL>

</E1WXX01>

<E1WXX01>    -------------------------------------This generates target LedgersGL 3

<FLDGRP>TEND</FLDGRP>

<FLDNAME>BALGL</FLDNAME>

<FLDVAL>7000</FLDVAL>

</E1WXX01>

<E1WXX01>      ------FLDVAL is what should be mapped for Condition 3 for LedeersGL 3

<FLDGRP>PERD</FLDGRP>

<FLDNAME>Month</FLDNAME>

<FLDVAL>iB</FLDVAL>

</E1WXX01>

</E1WPZ02>

</E1WPZ01>

</IDOC>

  </WPUTAB01>


Please advise.

Regards,

Archana

former_member596513
Participant
0 Kudos

Hi Raghuraman,

I experimented and now i am able to create te target based on condition 3. My mapping is below-

My result is as below-

However, now for the counter i am facing an issue.

My top target node LedgersGL is not created with remove context but straight based on condition check.

If i use the remove context for top node in target side, i can use the below mapping for counter and it works-

But then my condition 3 does not work corerctly.

Please help.

I want to accomplish all this in 1 step mapping.

Regards,

Archana

former_member186851
Active Contributor
0 Kudos

Archana why dont you try a variable for counter as I mentioned earlier.

For this create a variable Counter

FLDGRP Equals  A

                                      OR

FLDGRP Equals B                                             if Then  Map Some constant like A To the Counter.

FLD Name  Equals 10     OR

FLD Name  Equals 20

Now count the occurences of the variable using Counter function and pass it to NATW.

former_member596513
Participant
0 Kudos

Hi Raghuraman,

I was posting when you responded

I tried but it is giving an exception.

Maybe i am giving the level incorrect where i have to create the variable.

Please check the below-

Regards,

Archana

former_member596513
Participant
0 Kudos

Exception is as below-

Compilation of tab_to_tab2 successful
Cannot create target element /ns0:Tab2/LedgersGL[2]/NATW. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD
com.sap.aii.mappingtool.tf7.IllegalInstanceException: Cannot create target element /ns0:Tab2/LedgersGL[2]/NATW. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD

former_member596513
Participant
0 Kudos

Forgot to give the mapping for the variable Raghuraman.

Regards,

Archana

former_member186851
Active Contributor
0 Kudos


Hello Archana,

I tried the below logic and it worked.you try the same replacing with the actual values of urs

former_member596513
Participant
0 Kudos

Hi Raghuraman,

I tried but it is not creating the target field which is at the moment 0..1

Only in the first instance of LedgersGL it is created and that too it is 0

I have the below mapping-

Result as below-

This is my source -

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

<WPUTAB01>

   <IDOC>

      <EDI_DC40>

         <TABNAM>EDI_DC40</TABNAM>

         <MANDT>202</MANDT>

         <DOCNUM>0000000002232027</DOCNUM>

         <DOCREL>701</DOCREL>

         <STATUS>37</STATUS>

         <DIRECT>1</DIRECT>

         <OUTMOD>2</OUTMOD>

         <IDOCTYP>WPUTAB01</IDOCTYP>

         <MESTYP>WPUTAB</MESTYP>

         <STDMES>WPUTAB</STDMES>

         <SNDPOR>SAPUBD</SNDPOR>

         <SNDPRT>KU</SNDPRT>

         <SNDPRN>0000008000</SNDPRN>

         <RCVPOR>A000000004</RCVPOR>

         <RCVPRT>KU</RCVPRT>

         <RCVPRN>0000008000</RCVPRN>

         <CREDAT>20151006</CREDAT>

         <CRETIM>120750</CRETIM>

         <SERIAL>20151006103554</SERIAL>

      </EDI_DC40>

      <E1WPZ01>

         <BELEGDATUM>20151001</BELEGDATUM>

         <E1WPZ02>

            <VORZEICHEN>-</VORZEICHEN>

            <ZAHLART>ZTCS</ZAHLART>

            <SUMME>62.00</SUMME>

            <WAEHRUNG>GBP</WAEHRUNG>

            <E1WXX01>

               <FLDGRP>TEND</FLDGRP>

               <FLDNAME>GL</FLDNAME>

               <FLDVAL>3004</FLDVAL>

            </E1WXX01>

            <E1WXX01>

               <FLDGRP>TEND</FLDGRP>

               <FLDNAME>BALGL</FLDNAME>

               <FLDVAL>3008</FLDVAL>

            </E1WXX01>

            <E1WXX01>

               <FLDGRP>PERD</FLDGRP>

               <FLDNAME>MONTH</FLDNAME>

               <FLDVAL>10</FLDVAL>

            </E1WXX01>

            <E1WXX01>

               <FLDGRP>PERD</FLDGRP>

               <FLDNAME>YEAR</FLDNAME>

               <FLDVAL>2015</FLDVAL>

            </E1WXX01>

            <E1WXX01>

               <FLDGRP>PERD</FLDGRP>

               <FLDNAME>DATE</FLDNAME>

               <FLDVAL>20.10.2015</FLDVAL>

            </E1WXX01>

            <E1WXX01>

               <FLDGRP>TRAN</FLDGRP>

               <FLDNAME>BATCHID</FLDNAME>

               <FLDVAL>1036798920</FLDVAL>

            </E1WXX01>

         </E1WPZ02>

         <E1WPZ02>

           <VORZEICHEN>-</VORZEICHEN>

            <ZAHLART>ZTMC</ZAHLART>

            <SUMME>42.00</SUMME>

            <WAEHRUNG>GBP</WAEHRUNG>

            <E1WXX01>

               <FLDGRP>TEND</FLDGRP>

               <FLDNAME>GL</FLDNAME>

               <FLDVAL>7540</FLDVAL>

            </E1WXX01>

            <E1WXX01>

               <FLDGRP>TEND</FLDGRP>

               <FLDNAME>BALGL</FLDNAME>

               <FLDVAL>9540</FLDVAL>

            </E1WXX01>

            <E1WXX01>

               <FLDGRP>PERD</FLDGRP>

               <FLDNAME>MONTH</FLDNAME>

               <FLDVAL>10</FLDVAL>

            </E1WXX01>

            <E1WXX01>

               <FLDGRP>PERD</FLDGRP>

               <FLDNAME>YEAR</FLDNAME>

               <FLDVAL>2015</FLDVAL>

            </E1WXX01>

            <E1WXX01>

               <FLDGRP>PERD</FLDGRP>

               <FLDNAME>DATE</FLDNAME>

               <FLDVAL>20.10.2015</FLDVAL>

            </E1WXX01>

            <E1WXX01>

               <FLDGRP>TRAN</FLDGRP>

               <FLDNAME>BATCHID</FLDNAME>

               <FLDVAL>1036798920</FLDVAL>

            </E1WXX01>

         </E1WPZ02>

      </E1WPZ01>

   </IDOC>

</WPUTAB01>

Regards,

Archana

former_member596513
Participant
0 Kudos

Hi Raghuraman,

Display queue- for remove context before then condition -

Queue values after if then-

Regards,

Archana

former_member186851
Active Contributor
0 Kudos

Hello Archana,

your getting 4 in the NATW right which is count.

You want the Same 4 to be repeated in al the NATW,if that is the case then use one as many function and give the NATW for the input and count for context and value changes.

former_member596513
Participant
0 Kudos

Hi Raghuraman,

What is required is to get 1 in first target instance in NATW, 2 in second and so on.

So if there are 4 targets, then count should be from 1 -4.

I am not able to get this.

I have tried the various combinations as i want to complete this in single step mapping.

Regards,

Archana

former_member186851
Active Contributor
0 Kudos

Hello Archana,

Then use Index like below.It is working.

former_member596513
Participant
0 Kudos

Hi Raghuraman,

I tested this but not qorking.

Counter in NATW is there inly in first instnace on target side but the field is not created with 2 - 4 counter values.

Index - usage- All values are there in the queue in Index

Result-

Used Split by value - which then fills in the counter in second target NATW but 3rd and 4th instances are not comig up. The first 2 are from first occurrence of E1WPZ02 but the 3 and 4 targets from E1WPZ02 number 2 are not filled with values. Even though the values for counters are there in the queue.

Result-

Not sure how to get the values. The target is 0..1 but that should be filled out. If i give the occurrence of target NATW as 1 then there will be exception.

Regards.

Archana

former_member186851
Active Contributor
0 Kudos

Hello Archana,

Its not the problem wm with occurence.

Try using use one as many giving that constant field as input for queue/context changes and index as input values.

former_member596513
Participant
0 Kudos

Hi Raghuraman,

I tried with use one as many but i am getting error or NATW only in first instance on target side.

What should be the exact inputs for this function as i must be missing the inputs?

Can you please tell me the actual?

I have Index which displays 4 counter values in the queue.

Regards,

Archana

yeeloon-khoo
Explorer
0 Kudos

Hi Archana,

My observation on why 3rd and 4th number not showing at target:

E1WXX01 will create LedgerGL, but some E1WXX01 get suppressed, due to Condition 1.

My guess is you have to create the number range 1 to 4, but insert suppress in between, follow same context change like Condition 1. Probably an UDF.

former_member186851
Active Contributor
0 Kudos

Archana,

your using the condition for E1WXX01 and NATW?

former_member596513
Participant
0 Kudos

Hi Yee,

Yes as per the Condition 1 not all the E1WXX01 segmenst are created in the target.

The number of target segments is dynamic and depends how many valid source segments are received.

In my exampel i have created 2 instances of E1WPZ02 segment each with 6 E1WXX01 segments. Based on Condition 1, only 2 E1WXX01 segments from first E1WPZ02 and 2 E1WXX01 segments from 2nd E1WPZ02 are generated as part of the target.

Using the below mapping, NATW is generated for all target but with incorrect counter value. If all E1WXX01 segments were part of the target, then this counter value will be correct.

Result-

Is there no way i can create a small UDF to give me the NATW for each target?

I checked the forum but i am not getting a code for this as that may resolve all the issues.

Else i will have to go for 2 step mapping but creating mapping 2 only for running number in NATW seems too excessive.

Regards,

Archana

former_member596513
Participant
0 Kudos

Hi Raghuraman,

I have used the If Then for E1WXX01 - check the FLDGRP and FLDNAME and then passing E1WXX01.

In Index i can see the correct running counter of 1 - 4 based on the valid target instances.

Any advise.

Regards,

Archana

yeeloon-khoo
Explorer
0 Kudos

hi,

my view is if some target LedgerGL item get suppressed, then same target NATW queue should get suppressed.

Please see if this suit your requirement, if somehow not working, modify it when you debug with DisplayQueue..

int counter = 0;

if (contextValues != null && contextValues.length > 0){

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

        String value = contextValues[i];

        if (ResultList.SUPPRESS.equalsIgnoreCase(value)){

            result.addSuppress();

        }else if (ResultList.CC.equals(value)){

            result.addContextChange();

        }

        else{

            counter = counter + 1;

            result.addValue(counter);

        }

    }

}

former_member186851
Active Contributor
0 Kudos

Thats the confusing part Archana.

When I test its fine.Even if you try split by value its not working right?

I guess its because of different conditions in E1WXX01.

Why dont you use same condition for the both?

former_member596513
Participant
0 Kudos

Hi Raghuraman,

The requirement is to use get the counter values for generated NATW in target.

At this point my top level LedgersGL is already generated as part of condition 1.

So following the example 4 LedgersGL will be generated as part of first condition.

How should i put the condition then in for getting the running number in NATW?

I need to use the same condition as condition1 to get the number of E1WXX01 segments in my queue if i am not wrong.

Plaese advise.

Regards,

Archana

former_member596513
Participant
0 Kudos

Hi Yee,

I am getting counter as 1 always in NATW.

Created the UDF. Used in mapping as below- not ok.

Changed the mapping a little but still not working- counter is always 1

Result-

Regards,

Archana

former_member596513
Participant
0 Kudos

NATW is not even mapped to any source field.

It should be part of the target LedgersGL and should just have the running number from 1 onwards for as many times the target LedgersGL is created.

if 2 LedgersGL - Then NATW in first LedgersGL should have 1 and NATW in second LedgersGL should have 2

Regards,

Archana

former_member182412
Active Contributor
0 Kudos

Hi Archana,

Use below mapping:

Parameter for first UDF:

FixValues:

FirstUDF:


public void getValueByQualifierContext(String qualifier, String[] qualifiers, String[] values, ResultList result, Container container) throws

StreamTransformationException{

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

  if (qualifiers[i].equals(qualifier))

  result.addValue(values[i]);

}

SecondUDF:


public void indexGlobal(String[] a, ResultList result, Container container) throws StreamTransformationException{

int cnt;

GlobalContainer globalCount = container.getGlobalContainer();

String nextCount = (String) globalCount.getParameter("nextCount");

if (nextCount == null) {

   cnt = 1;

}

else {

   cnt = Integer.parseInt(nextCount);

}

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

   if (a[i].equals(ResultList.SUPPRESS )) {

     result.addSuppress();

   }

   else {

     result.addValue(Integer.toString(cnt));

     cnt++;

   }

}

globalCount.setParameter("nextCount", Integer.toString(cnt));

}

Regards,

Praveen.

former_member186851
Active Contributor
0 Kudos

Yes Archana put the same condition and post what your getting

yeeloon-khoo
Explorer
0 Kudos

Hi,

Expected to replace the index function with NumberRangeByExample since this function already producing number 1,2,3, 4....

Input is a queue with potential suppressed item, output is a queue with number range 1,2,3,4 follow same suppressed item position.

former_member596513
Participant
0 Kudos

Thanks Praveen.

I tried but the issue as below-

Already have the condition check to generate LedgersGL ONLY if FLDGRP = TEND and FLDNAME = GL or BALGL for source segment E1WXX01

So the mapping for this target is given below and then i tried to implement the one for NATW also. Tried to put LedgersGL as per your post but then no target is generated. NATW in the below case will not be generated as the createif condition is missing the LedgersGL as per your post.

I am giving the values for every step as per your post-

After the step above all is SUPPRESS. I am not getting the value out from the UDF 1 so everything is false after that.

How do i proceed?

I have tried with so much help from you guys but looks like i will have to go for step 2 mapping only to get the counter. I am unable to see any way out of this.

Regards,

Archana

former_member596513
Participant
0 Kudos

Hi Raghuraman,

I have done as you said but no luck.

Mapping as below-

Result- NATW only in first target instance of LedgersGL but field NATW is missing in other LedgersGL-

Regards,

Archana

former_member182412
Active Contributor
0 Kudos

Hi Archana,

Did you give the parameter value as TEND for first UDF?? you need to double click on the first UDF and give the value as TEND.

You can use the same mapping for LedgersGL root node also as per my screen shot below, you need to map after createif function to LedgersGL. dont create the separate mapping for LedgersGL.

Display queue od NATW and LedgersGL are below:

Regards,

Praveen.

former_member596513
Participant
0 Kudos

Hi Praveen,

It is coming

I had forgotten to give the parameter.

I will try withh all the combinations now and update.

Thank you so much.

So resolved my condition 4

Thank you so much raghuraman

you resolved my condition 1

You guys have been so helpful....

Is there any way i can mark both of you as correct answers

I could not have done this without you.

Reagrds,

Archana

former_member182412
Active Contributor
0 Kudos

Hi Archana,

Glad to hear the problem was resolved, you cannot mark both as answered, only one you can make as correct answer, other replies you can give helpful answer.

Regards,

Praveen.

former_member186851
Active Contributor
0 Kudos

Hello Archana..

Nice to hear..