cancel
Showing results for 
Search instead for 
Did you mean: 

Remove cancelled records

Former Member
0 Kudos

Hi,

I have source XML as follows:

<ROW>

<ZPOSSIPNO>1001</ZPOSSIPNO>

<AMOUNT>65</AMOUNT>

</ROW>

<ROW>

<ZPOSSIPNO>1001</ZPOSSIPNO>

<AMOUNT>-65</AMOUNT>

</ROW>

<ROW>

<ZPOSSIPNO>1002</ZPOSSIPNO>

<AMOUNT>40</AMOUNT>

</ROW>

Result XML should be like;

<ROW>

<ZPOSSIPNO>1002</ZPOSSIPNO>

<AMOUNT>40</AMOUNT>

</ROW>

Is there any solution to solve this issue? We need to remove the record lines with amount values.

Thanks in advance,

Nurhan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You may also use the following mapping for the same.

AMount - - -- -- >

index of --- >

Constant("-")-------> equalsS --- > createIF --- > collapsecontexts --- > Row

Constant("-1") --->

The above mapping is for Row. the remaining fields you may map one to one

Regards,

Ninu

Edited by: NinuPSankar on Jun 7, 2011 5:33 PM

Edited by: NinuPSankar on Jun 7, 2011 5:33 PM

Edited by: NinuPSankar on Jun 8, 2011 9:00 AM

Answers (3)

Answers (3)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

This is possible without using UDF. See mapping below:

For ROW



ZPOSSZIPNO -> removeContext -> sortByKey: ascending ->  formatByExample -> sum -> greater: 0 -> ifWithoutElse (output of sum) -> removeContext -> ROW
   AMOUNT -> removeContext -> /                                / 
ZPOSSZIPNO -> removeContext -> sort: ascending -> splitByValue: valueChanged

For ZPOSSZIPNO



ZPOSSZIPNO -> removeContext -> sortByKey: ascending ->  formatByExample -> sum -> greater: 0 ------> ifWithoutElse -> removeContext -> SplitByValue:eachValue -> ZPOSSZIPNO   
   AMOUNT -> removeContext -> /                                /                                            /
ZPOSSZIPNO -> removeContext -> sort: ascending -> splitByValue: valueChanged                               /
ZPOSSZIPNO -> removeContext -> sort: ascending -> splitByValue: valueChanged - > collapseContext -> SplitByValue: eachValue 

For AMOUNT



ZPOSSZIPNO -> removeContext -> sortByKey: ascending ->  formatByExample -> sum -> greater: 0 -> ifWithoutElse (output of sum) -> removeContext -> SplitByValue:eachValue -> AMOUNT
   AMOUNT -> removeContext -> /                                / 
ZPOSSZIPNO -> removeContext -> sort: ascending -> splitByValue: valueChanged

Hope this helps,

Mark

Edited by: Mark Dihiansan on Jun 8, 2011 7:19 AM

Former Member
0 Kudos

Hi Nurhan

If you need to remove records having amount smaller than 0, try this:

Rule for ROW:

AMOUNT -> removeContexts -> greater -> ifWithoutElse (choose Properties and set use SUPPRESS values to true)-> ROW
             Constant [-1] /     ROW / 

Then map the remaining target fields with source fields without any additional rule.

The output will be:

<ROW>

<ZPOSSIPNO>1001</ZPOSSIPNO>

<AMOUNT>65</AMOUNT>

</ROW>

<ROW>

<ZPOSSIPNO>1002</ZPOSSIPNO>

<AMOUNT>40</AMOUNT>

</ROW>

Regards,

Giuseppe

Former Member
0 Kudos

Try using global variable, if you are on PI 7.1 .

we can skip the records using conditions in global variable.

/people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-graphical-variable

-santosh.