cancel
Showing results for 
Search instead for 
Did you mean: 

BPM loop

Former Member
0 Kudos

Dear All,

My requirement is to get the PO details (Header in one table and Items in another table) and send it to R/3 for PO creation. Now I am doing it by taking one record from header and all it corresponding line items from item table.

But if I need to select all header records from header and corresponding item records and process it in BPM such that only one header and all its item details are sent to R/3, how can I do it? Can you pls list the steps that would be required in the BPM?

Thanks in Advance.

Thanks & Regards,

Jai Shankar.

Accepted Solutions (0)

Answers (2)

Answers (2)

moorthy
Active Contributor
0 Kudos

Hi,

As Michal, suggested , you can achieve this with Message Mapping.

First make the idoc occurence as 0/1..n and then map accordingly as per blog mentioned. But you may need to use some of the Builtin Mapping functions here.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/877c0d53-0801-0010-3bb0-e38...

Regards,

moorthy

MichalKrawczyk
Active Contributor
0 Kudos

hi,

you don't need a loop for that

you can do it in the mapping

take all header and combine them

with items and then post each as one idoc

but in the IDOC bundle

/people/michal.krawczyk2/blog/2005/12/04/xi-idoc-bundling--the-trick-with-the-occurance-change

so you only need to do it in the mapping

Regards,

michal

Former Member
0 Kudos

Hi Michal,

Thanks for a vey useful pointer. But in my case the POs are created by a standard function module in R/3 and it takes only one header and multiple line items at a time.

Thanks & Regards,

Jai Shankar.

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

then you also don't need a loop step

you can do the loop in the <b>block step </b>

(foreach for example)

you need to do one mapping (like I said)

and create many RFC calls (in a multiline container)

- multiline check in containers section

then the BPM will process each message from the

multiline container as one call

and you can still do the mapping in one place

Regards,

michal

Former Member
0 Kudos

Can any one explain the approach suggested by Michal. Now I have 2 header records and each header has 2 line items. I need 2 calls to R/3. How should I take the records from table and how should I map the header and items?

Thanks & Regards,

Jai Shankar.

bhavesh_kantilal
Active Contributor
0 Kudos

Jai,

Mapping Step in the BPM ~~

Combine Header 1 and the 2 line items of Header 1 in one of the Request message to the R3.

Like wise, do the same for Header 2 and the 2 line items of Header.

This will be a multimapping and you will have multiple target messages , one for each Header item.

Next, BLOCK step with Par for each ~~ Give the Output of Mapping as the Par For Each multiline element for the Bloc. Inside the block, make the call to the RFC with the currentline element being the same Output of mapping but, not a multiline element.

Regards,

Bhavesh

Former Member
0 Kudos

Bhavesh still I am not in sync.

>>>>Combine Header 1 and the 2 line items of Header 1 in one of the Request message to the R3.

Like wise, do the same for Header 2 and the 2 line items of Header.

How can this be done? How to write select querry which will fetch the data from header and Item and make a difference between each header record and all its item records?

Suppose I write the querry like <b>select header.key , header.type, item.key, item. quantity where header.key = item.key </b>. This will return 4 records 2 records for each header. Now how can I handle the mapping?

Thanks & Regards,

Jai Shankar.

former_member206604
Active Contributor
0 Kudos

Hi,

Do you think we need a BPM? If I understood it properly thsi can also be done without BPM using Multimapping without BPM as given in Michal's Blog /people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions

What do you say Michal and Bhavesh?

Thanks,

Prakash

bhavesh_kantilal
Active Contributor
0 Kudos

Jai,

This is what I have understood of your requirements,

You are getting the Header details and Line details separately inside your BPM with 2 separate Receive steps. correct?

If this is the case, then

1. you have your header details in one source message and line details in the other source message,

2.you would also have the header field in line message to ascoiate the header with the line item.

Now, in a multimapping scenario , do a check over the Header of the Header and the Line item and segregate the records.

@ Prakash~~

If Jai is looking at taking multiple messages ( separate header and lIne ) , he needs to have a BPM as he needs to collect messsages inside the BPM .

Regards,

Bhavesh

Former Member
0 Kudos

Bhavesh,

As I told in the beggining of this thread, my design was without a BPM. Take a single header(using min operator in select querry and a status field) and all line items, map it send it R/3. This was very simple. But for some specific reasons, I need to avoid this approach.

Now I have 2 receive steps in my BPM design one to receive header(all) and the other one to receive items(all). Now how can I segregate the records and do the mapping?

Thanks & Regards,

Jai Shankar.

MichalKrawczyk
Active Contributor
0 Kudos

hi,

>>>>>Now I have 2 receive steps in my BPM design one to receive header(all) and the other one to receive items(all). Now how can I segregate the records and do the mapping?

in your mapping you need to put it all in

array structures do the loop on

header and loop on segments and add

it all to a hashtable for instance

then in the output you can just take

one header and all items from it

it requires a some java handling

(search google for array and hashtable)

if you're not familaria with that

or just ask any java guy for whom

this will be very easy

Regards,

michal

bhavesh_kantilal
Active Contributor
0 Kudos

Jai,

In your Header Message and LineDetails Message , you will have a field that will associate both these messages . Or, you will have some field in the header message that will be used to associate with the line item (s) in the second message.

So, you will need a mapping , wherein, you will create multiple RFC request messages. You will have to use the Common Field / Joining COndition for these to combine / Segregate Line Items and Header Messages.

Eg:

<Header >

<Header Idefntifier>

</Header>

<Line Item>

<Header Identifier>

</Line Item>

Now, in the mapping ,for every Header Identifier of HEADER , you will create your Request Message , and then , use the Header Identifier of Header and Line Item to create the Line Item Records. Ofcourse such a mapping would need Node Functions and Context Handling as well, and mapping requirements depends on the actual message struture.

Regards,

Bhavesh

Former Member
0 Kudos

Hi,

Header and Item tables are associated in my case with Header.key and Item.key. Can you pls let me know the steps reqd in my BPM design?

Thanks & Regards,

Jai Shankar.

Former Member
0 Kudos

Dear All,

I tried a small exmple with block for each and amulti line container. Yes, it worked perfectly.

But still I cant do the mapping for this scenario. Michal do you suggest a Java mapping for this scenario? Pls help me in completing this scenario.

Thanks & Regards,

Jai Shankar.

former_member206604
Active Contributor
0 Kudos

Hi,

You can do with graphical mapping with UDF, but I think it would be bit complex. You can go for Java/ABAP or XSLT mapping.

Eg: for XSLT mapping.

[code]<?xml version='1.0'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">

<xsl:variable name="msg2" select="//MT_Src2"/>

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

<xsl:for-each select="ns0:Messages/ns0:Message1/MT_Src1/Row">

<Row>

<PONum><xsl:value-of select="PONum"/></PONum>

<ItemNum><xsl:value-of select="ItemNum"/></ItemNum>

<Matno><xsl:value-of select="Material"/></MatNo>

<xsl:variable name="empid" select="EmpID"/>

<xsl:for-each select="$msg2/Row">

<xsl:if test="EmpID = $PONum">

<Vendor><xsl:value-of select="vendor"/></Vendor>

</xsl:if>

</xsl:for-each>

</Row>

</xsl:for-each>

</ns0:MT_Targ>

</xsl:template>

</xsl:stylesheet>[/code]

Here the assumed source and target as

[code]<b>Src1</b>

MT_Src1

- Row

- PONum

- ItemNum

- Material

<b>Src2</b>

MT_Src2

- Row

- PONum

- vendor

<b>Target</b>

MT_Targ

- Row

- PONum

- ItemNum

- MatNo

- Vendor[/code]

Thanks,

Prakash

Message was edited by: Prakash Arunachalam

Former Member
0 Kudos

Hi Prakash,

Thanks a lot for the mapping. In my case, there will be thousands of PO requirements created daily. And my target structure is not this simple. I beleive XSLT mapping has to be avoided for performace reasons.

Can you pls tell me how the logic can be implemented with graphical mapping or JAVA mapping?

Thanks & Regards,

Jai Shankar.

former_member206604
Active Contributor
0 Kudos

Hi,

<i>>>>Thanks a lot for the mapping. In my case, there will be thousands of PO requirements created daily. And my target structure is not this simple. I beleive XSLT mapping has to be avoided for performace reasons</i>

Then Java mapping would be better. You can get some example for Java mapping in SDN. I think you will need a Multi mappping in this case. So you need to take care Messages/Message1 tag while parsing it.

Thanks,

Prakash