cancel
Showing results for 
Search instead for 
Did you mean: 

Merging Conditional Check with CREATEIF

David
Advisor
Advisor
0 Kudos

Hi

I am using a mapping...

DocNumField -> SplitByVal(each val) -> collapseContexts -> SplitBy Value(value changed) -> exists -> createif -> IDOCSegment.

I need to add a conditional check in such that the IDOC Segment is only created if the RecTypeField = 1.

Where and how in the above stream do I add in a link to that check? Would I add in a RecType -> EqualsS "2" -> AND

Thx J

Accepted Solutions (0)

Answers (3)

Answers (3)

STALANKI
Active Contributor
0 Kudos

This happens because you have created two idoc nodes and all the children context will get disturbed due to that.

we can definetly do it by playing around the context of all the XML elements or write an advanced function which exactly adds contexts..but Iam bit lazy to try out the actuall mapping..:)

https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2792. [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken]

Please look at it.It might be useful .

stefan_grube
Active Contributor
0 Kudos

Hi Tony,

the condition you can add like follows:


              RecTypeField 
                            formatByExample  
DocNumField - SplitByValue /                 equalS
                                constant(1) /      
                                                    ifWithoutElse - exists - createif - IDOCSegment
                        DocNumField - SplitByValue /

In both cases you set the context of DocNumField to the root level.

The function formatByExample keeps both queues in range.

Regards

Stefan

STALANKI
Active Contributor
0 Kudos

I will tell you a easy way out..:)

write a advanced user defined function and set the context of DocNumField(a) and RecType(b) to idoc .

and write sample algo like this..

map a-adv \ c

b-adv /

advanced function code.

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

if (b<i>.equals(1))

result.addValue(" ");

I get my 10 points if solved..:)

stefan_grube
Active Contributor
0 Kudos

Hi Sravya,

change the variable i to j.

[i] is a format description and starts <i>italic</i>

Best regards

Stefan

David
Advisor
Advisor
0 Kudos

Hi Stefan

Thanks a lot for helping me out here. I've tried your suggestion and it's nearly there. 1 problem.

I have 4 records.

Record1 -> DocNum 1, RecT 2, Values

Record2 -> DocNum 1, RecT 2, Values

Record3 -> DocNum 2, RecT 2, Values

Record4 -> DocNum 2, RecT 2, Values

The DocuNum 1 records create IDOC 1. Great.

The DocNum 2 records create IDOC 2. Great.

BUT, IDOC 1 contains only the first record. It should contain records 1&2.

IDOC 2 contains only the second record. It should contain records 3&4.

Any thoughts ? Once again, really appreciate your time.

stefan_grube
Active Contributor
0 Kudos

Hi Tony,

I am glad, that you provide me an example for the use of the function formatByExample. If have been looking long for it

If Record is an element:


                    Record 
                            formatByExample - Record
DocNumField - SplitByValue /

Of course, if Record is only a node, then it is sufficent to do this:


DocNumField - SplitByValue - formatByExample - Record

If you would provide more information about source and target, it would be easier to provide help.

Regards

Stefan

David
Advisor
Advisor
0 Kudos

Hi,

I'd be more than happy to send you an example of the scenario with screen shots, if you have an e-mail address.

Thx

T

stefan_grube
Active Contributor
0 Kudos

Hi Tony,

source xml and taget xml would be sufficient.

Guess my email address

Regards

Stefan

David
Advisor
Advisor
0 Kudos

Source...

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

- <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

- <ns0:Message1>

- <ns1:UKExpenses_MT xmlns:ns1="http://burberry.com/finance/journalpostings/expenses">

- <UKExpensesData>

<DocumentNum>1</DocumentNum>

<RecordType>2</RecordType>

<DocumentDate>20051219</DocumentDate>

<CompanyCode>KR10</CompanyCode>

<GLAccount>999991</GLAccount>

<CostCenter>CC1</CostCenter>

<OrderId>F120</OrderId>

<Vendor />

<PostingInd>+</PostingInd>

<Currency />

<Amount>500</Amount>

<Description>GL1</Description>

</UKExpensesData>

- <UKExpensesData>

<DocumentNum>1</DocumentNum>

<RecordType>2</RecordType>

<DocumentDate>20051219</DocumentDate>

<CompanyCode>KR10</CompanyCode>

<GLAccount>999992</GLAccount>

<CostCenter>CC1</CostCenter>

<OrderId>F120</OrderId>

<Vendor />

<PostingInd>+</PostingInd>

<Currency />

<Amount>500</Amount>

<Description>GL</Description>

</UKExpensesData>

- <UKExpensesData>

<DocumentNum>2</DocumentNum>

<RecordType>2</RecordType>

<DocumentDate>1</DocumentDate>

<CompanyCode>KR10</CompanyCode>

<GLAccount>999993</GLAccount>

<CostCenter>CC1</CostCenter>

<OrderId>F120</OrderId>

<Vendor />

<PostingInd>+</PostingInd>

<Currency />

<Amount>500</Amount>

<Description>GL1</Description>

</UKExpensesData>

- <UKExpensesData>

<DocumentNum>2</DocumentNum>

<RecordType>2</RecordType>

<DocumentDate>20051219</DocumentDate>

<CompanyCode>KR10</CompanyCode>

<GLAccount>999994</GLAccount>

<CostCenter>CC1</CostCenter>

<OrderId>F120</OrderId>

<Vendor />

<PostingInd>+</PostingInd>

<Currency />

<Amount>500</Amount>

<Description>GL1</Description>

2

</UKExpensesData>

</ns1:UKExpenses_MT>

</ns0:Message1>

</ns0:Messages>

Target....

See IDOC ACC_DOCUMENT02 in WE31

stefan_grube
Active Contributor
0 Kudos

Hi Jaime

I think you want to have so many E1BPACGL09 entry as RecTypeField = 2

Do following:


                      RecTypeField 
                                    equalS 
                       constant(2) /        
                                             formatByExample - creatIf - E1BPACGL09
DocNumField - removeContexts - SplitByValue*/

The main node ACC_DOCUMENT02 occurs as often, as you have different values in DocNumField


DocNumField - SplitByValue* - collapseContexts - ACC_DOCUMENT02
  • value changed

Now it looks a little bit easier as my first version.

Regards

Stefan