cancel
Showing results for 
Search instead for 
Did you mean: 

how to filter records?

former_member745782
Active Participant
0 Kudos

hello!

i have a easy problem but really i cannot solve it with graphical mapping :(((

This is a example of my inbound data:

<MT_001>
	<RECORDS>
		<ROW>
			<FIELD1>aaa</FIELD1>
			<FIELD2>xxx</FIELD2>
		</ROW>
		<ROW>
			<FIELD1>bbb</FIELD1>
		</ROW>
	</RECORDS>
	<RECORDS>
		<ROW>
			<FIELD1>ccc</FIELD1>
		</ROW>
		<ROW>
			<FIELD1>ddd</FIELD1>
			<FIELD2>xxx</FIELD2>
		</ROW>
	</RECORDS>
</MT_001>

and i outbout i want same structure, but filtering only ROW that have FIELD2.

I tried to map FIELD2 - exist- create if - ROW but no one record is mapped (also if i changed context).

I tried using ifWithoutels too with same result.

Any suggestion?

thanks in advance

Alex

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

My solution to this requirement is:

Field2(context record) - exists - createif - collapsecontext - record

Field2(context record) - row

Field2 - exists - ifthen(without else) map then to Field1 - removecontext - splitbyvalue(each value) - Field1

Field2(context record) - removecontext - splitbyvalue(eachvalue) - Field2

Warm Regards,

Anshul

former_member745782
Active Participant
0 Kudos

Thanks to everybody!

seems Mark solution work correctly and the first problem is solved.

But now my data type is more complex.

I have a new structure PLU under ROW.

<MT_001>
	<RECORDS>
		<ROW>
			<FIELD1>aaa</FIELD1>
			<FIELD2>xxx</FIELD2>
				<PLU>
					<FIELD99>12345</FIELD99>
				</PLU>
		</ROW>
		<ROW>
			<FIELD1>bbb</FIELD1>
		</ROW>
	</RECORDS>
	<RECORDS>
		<ROW>
			<FIELD1>ccc</FIELD1>
		</ROW>
		<ROW>
			<FIELD1>ddd</FIELD1>
			<FIELD2>xxx</FIELD2>
				<PLU>
					<FIELD99>54321</FIELD99>
				</PLU>
				<PLU>
					<FIELD99>997766</FIELD99>
				</PLU>
		</ROW>
	</RECORDS>
</MT_001>

In my mapping FIELD1 and FIELD2 are mapped correctly but PLU and his child no.

I tried some solution but the result is PLU not mapped or mapped in not correct solution or all PLU under first ROW.

Any other suggestion?

thanks again

Former Member
0 Kudos

Hi apederiva

Try the following rules:

for RECORDS:

FIELD2 -> exists -> ifWithoutElse (use SUPPRESS value  / keepss = true) -> removeContexts -> RECORDS
             FIELD2 /

for ROW:

FIELD2 -> exists -> ifWithoutElse (use SUPPRESS value / keepss = true) -> ROW
            FIELD2 /

for remaining fileds, map directly with source field without changing context.

Regards,

Giuseppe

Edited by: Giuseppe Agnello on May 25, 2011 11:58 AM

Rules wrapped in code tags

former_member745782
Active Participant
0 Kudos

thanks Giuseppe,

i tried your solution but is not good.

I have in output N RECORDS (same number of ROW).

with Mark solution i have good result. The only one problem now, is on PLU record

Edited by: apederiva on May 26, 2011 10:19 AM

Former Member
0 Kudos

Hi apederiva

Try this one:

Rule for RECORDS:

FIELD2 (context at RECORDS level) -> exist -> collapseContext -> ifWithoutElse (keepss = true) -> RECORDS
                                                         RECORDS/

Rule for ROW (context has to be changed only for FIELD1):

FIELD2 -> exist -> formatByExample-> ifWithoutElse (keepss = true) -> ROW
            FIELD1/              ROW/
(context at RECORDS level)

Mapping 1:1 for remaining fields.

Regards,

Giuseppe

former_member745782
Active Participant
0 Kudos

hello Giuseppe,

mapping 1:1 also to PLU record?

Former Member
0 Kudos

Hi apederiva

Yes, just map it with source PLU field without changing context and without using any function.

Same for FIELD99.

Regards,

Giuseppe

former_member745782
Active Participant
0 Kudos

thanks Giuseppe!!

your solution is perfect!

Former Member
0 Kudos

I'm glad it works

You are welcome

Answers (4)

Answers (4)

Former Member
0 Kudos

Hai!

Follow the method given by Mark for the Record,Row and Field2 fields here i gave u the mapping for Field1.

Field2(Set context to Row)>exist>(SplitByValue(EachValue))>createif>removecontext->SplitByValue(EachValue))>field1

\

Field(Set context to Row) this for Then.

I have tried out this scenario Ninu.

If your source struct is

<Records>

<Row>

<Field1>A</Field1>

<Field2>B</Field2>

</Row>

<Row>

<Field1>C</Field1>

</Row>

<Row>

<Field1>D</Field1>

</Row>

<Row>

<Field1>E</Field1>

<Field2>F</Field2>

</Row>

</Records>

If u fllow the mapping given By Mark and myself u will get the out put us

Records>

<Row><Field1>A</Field1>

<Field2>B</Field2>

</Row>

<Row>

<Field1>E</Field1>

<Field2>F</Field2>

</Row>

</Records

if this reply helps u kindly reply to me

Former Member
0 Kudos

Hi,

Mark is right, but i guess for Field2 mapping you should use:

Field2 (Context to record) - Remove context - splitbyvalue(each value) - Field2

Warm Regards,

Anshul

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Can you try this mapping:

For RECORDS


FIELD2 (set context to RECORDS) -> collapseContext -> RECORDS

For ROW


FIELD2 (set context to RECORDS) -> ROW

For FIELD2


FIELD2 -> exists -> ifWithoutElse -> removeContext -> splitByValue:eachValue -> FIELD2
          FIEDL2 -> /

Hope this helps,

Mark

Former Member
0 Kudos

Try using global variable.

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.

former_member745782
Active Participant
0 Kudos

sorry i forget to say that i'm working with XI 30 so i cannot use global variable

Former Member
0 Kudos

Can you just check if it works when like given below :-

Field2 -- > mapwithdefault "" -- >removecontexts -- >

"" -- > equals -- > Not-- > createIf -- > Row.

Then just directly map the child nodes. I guess it should work.

Regards,

Ninu

Edited by: NinuPSankar on May 23, 2011 8:35 PM