SAP Connector 5.8 Examples - Mule 4
The following examples show several Mule flows for SAP Connector:
Send an IDoc to SAP
This example shows you how to create a Mule app that sends an IDoc to SAP. The following screenshot shows the Studio flow for this example:
Configure HTTP Listener
Configure HTTP Listener to initiate a Mule flow when a call is made to the /sendIDoc
path on localhost port 8081
:
-
In Anypoint Studio, create a new Mule project.
-
From the Mule Palette view, drag the HTTP > Listener source to the canvas.
-
Configure the global element using the default values.
-
In the Listener properties tab, set the path to
/sendIDoc
.
Add the Transform Message Component
Configure the Transform Message component to convert the IDoc input to XML:
-
From the Mule Palette view, select Core and drag the Transform Message component next to the Listener source.
-
After the metadata is retrieved, overlay the text in the Output section of the Transform Message component with the following text:
%dw 2.0 output application/xml <MATMAS01> <IDOC BEGIN="1"> <EDI_DC40 SEGMENT="1"> <TABNAM>EDI_DC40</TABNAM> <MANDT>800</MANDT> <DOCNUM>0000000003519646</DOCNUM> <DOCREL>740</DOCREL> <STATUS>30</STATUS> <DIRECT>1</DIRECT> <OUTMOD>2</OUTMOD> <IDOCTYP>MATMAS01</IDOCTYP> <MESTYP>MATMAS</MESTYP> <SNDPOR>SAPIDE</SNDPOR> <SNDPRT>LS</SNDPRT> <SNDPRN>T90CLNT090</SNDPRN> <RCVPOR>MULE01_TP</RCVPOR> <RCVPRT>LS</RCVPRT> <RCVPRN>MULE01_LS</RCVPRN> <CREDAT>20180606</CREDAT> <CRETIM>133420</CRETIM> <SERIAL>20180606133420</SERIAL> </EDI_DC40> <E1MARAM SEGMENT="1"> <MSGFN>005</MSGFN> <MATNR>000000000000000088</MATNR> <ERSDA>19970527</ERSDA> <ERNAM>MORLEY</ERNAM> <LAEDA>20030122</LAEDA> <AENAM>I021066</AENAM> <PSTAT>KVB</PSTAT> <LVORM>X</LVORM> <MTART>FERT</MTART> <MBRSH>M</MBRSH> <MATKL>02004</MATKL> <MEINS>PCE</MEINS> <BLANZ>000</BLANZ> <BRGEW>0.200</BRGEW> <NTGEW>0.200</NTGEW> <GEWEI>KGM</GEWEI> <VOLUM>0.000</VOLUM> <TRAGR>0001</TRAGR> <SPART>09</SPART> <WESCH>0.000</WESCH> <LAENG>0.000</LAENG> <BREIT>0.000</BREIT> <HOEHE>0.000</HOEHE> <ERGEW>0.000</ERGEW> <ERVOL>0.000</ERVOL> <GEWTO>0.0</GEWTO> <VOLTO>0.0</VOLTO> <FUELG>0</FUELG> <STFAK>0</STFAK> <MHDRZ>0</MHDRZ> <MHDHB>0</MHDHB> <MHDLP>0</MHDLP> <VPSTA>KVB</VPSTA> <MSTDE>00000000</MSTDE> <MSTDV>00000000</MSTDV> <COMPL>00</COMPL> <GEWTO_NEW>0.0</GEWTO_NEW> <VOLTO_NEW>0.0</VOLTO_NEW> <ANP>000000000</ANP> <E1MAKTM SEGMENT="1"> <MSGFN>005</MSGFN> <SPRAS>1</SPRAS> <MAKTX>AS-100 T-shirt</MAKTX> <SPRAS_ISO>ZH</SPRAS_ISO> </E1MAKTM> <E1MAKTM SEGMENT="1"> <MSGFN>005</MSGFN> <SPRAS>4</SPRAS> <MAKTX>AS-100 T-shirt</MAKTX> <SPRAS_ISO>RO</SPRAS_ISO> </E1MAKTM> <E1MAKTM SEGMENT="1"> <MSGFN>005</MSGFN> <SPRAS>5</SPRAS> <MAKTX>AS-100 T-shirt</MAKTX> <SPRAS_ISO>SL</SPRAS_ISO> </E1MAKTM> <E1MAKTM SEGMENT="1"> <MSGFN>005</MSGFN> <SPRAS>6</SPRAS> <MAKTX>AS-100 T-shirt</MAKTX> <SPRAS_ISO>HR</SPRAS_ISO> </E1MAKTM> <E1MAKTM SEGMENT="1"> <MSGFN>005</MSGFN> <SPRAS>E</SPRAS> <MAKTX>AS-100 T-shirt</MAKTX> <SPRAS_ISO>EN</SPRAS_ISO> </E1MAKTM> <E1MAKTM SEGMENT="1"> <MSGFN>005</MSGFN> <SPRAS>F</SPRAS> <MAKTX>AS-100 T-shirt</MAKTX> <SPRAS_ISO>FR</SPRAS_ISO> </E1MAKTM> <E1MAKTM SEGMENT="1"> <MSGFN>005</MSGFN> <SPRAS>G</SPRAS> <MAKTX>AS-100 T-shirt</MAKTX> <SPRAS_ISO>EL</SPRAS_ISO> </E1MAKTM> <E1MAKTM SEGMENT="1"> <MSGFN>005</MSGFN> <SPRAS>J</SPRAS> <MAKTX>AS-100 T ???</MAKTX> <SPRAS_ISO>JA</SPRAS_ISO> </E1MAKTM> <E1MAKTM SEGMENT="1"> <MSGFN>005</MSGFN> <SPRAS>W</SPRAS> <MAKTX>AS-100 T-shirt</MAKTX> <SPRAS_ISO>BG</SPRAS_ISO> </E1MAKTM> <E1MAKTM SEGMENT="1"> <MSGFN>005</MSGFN> <SPRAS>d</SPRAS> <MAKTX>AS-100 T-shirt</MAKTX> <SPRAS_ISO>SH</SPRAS_ISO> </E1MAKTM> <E1MARCM SEGMENT="1"> <MSGFN>005</MSGFN> <WERKS>1000</WERKS> <PSTAT>V</PSTAT> <LVORM>X</LVORM> <PLIFZ>0</PLIFZ> <WEBAZ>0</WEBAZ> <PERKZ>M</PERKZ> <AUSSS>0.00</AUSSS> <MINBE>0.000</MINBE> <EISBE>0.000</EISBE> <BSTMI>0.000</BSTMI> <BSTMA>0.000</BSTMA> <BSTFE>0.000</BSTFE> <BSTRF>0.000</BSTRF> <MABST>0.000</MABST> <LOSFX>0</LOSFX> <AUSDT>00000000</AUSDT> <BEARZ>0.00</BEARZ> <RUEZT>0.00</RUEZT> <TRANZ>0.00</TRANZ> <BASMG>0.000</BASMG> <DZEIT>0</DZEIT> <MAXLZ>0</MAXLZ> <UEETO>0.0</UEETO> <UNETO>0.0</UNETO> <WZEIT>0</WZEIT> <VZUSL>0.00</VZUSL> <UMLMC>0.000</UMLMC> <LGRAD>0.0</LGRAD> <OBJID>00000000</OBJID> <MTVFP>01</MTVFP> <VRVEZ>0.00</VRVEZ> <VBAMG>0.000</VBAMG> <VBEAZ>0.00</VBEAZ> <TRAME>0.000</TRAME> <FXHOR>000</FXHOR> <VINT1>000</VINT1> <VINT2>000</VINT2> <LOSGR>0.000</LOSGR> <KAUSF>0.00</KAUSF> <TAKZT>0</TAKZT> <VRBDT>00000000</VRBDT> <VRBFK>0.00</VRBFK> <PREND>00000000</PREND> <PRENG>00000000</PRENG> <PRFRQ>0</PRFRQ> <SHZET>00</SHZET> <MMSTD>00000000</MMSTD> <DPLHO>0</DPLHO> <MINLS>0.000</MINLS> <MAXLS>0.000</MAXLS> <FIXLS>0.000</FIXLS> <LTINC>0.000</LTINC> <COMPL>00</COMPL> <EISLO>0.000</EISLO> </E1MARCM> <E1MARCM SEGMENT="1"> <MSGFN>005</MSGFN> <WERKS>2300</WERKS> <PSTAT>VB</PSTAT> <LVORM>X</LVORM> <PLIFZ>0</PLIFZ> <WEBAZ>0</WEBAZ> <PERKZ>M</PERKZ> <AUSSS>0.00</AUSSS> <MINBE>0.000</MINBE> <EISBE>0.000</EISBE> <BSTMI>0.000</BSTMI> <BSTMA>0.000</BSTMA> <BSTFE>0.000</BSTFE> <BSTRF>0.000</BSTRF> <MABST>0.000</MABST> <LOSFX>0</LOSFX> <AUSDT>00000000</AUSDT> <BEARZ>0.00</BEARZ> <RUEZT>0.00</RUEZT> <TRANZ>0.00</TRANZ> <BASMG>0.000</BASMG> <DZEIT>0</DZEIT> <MAXLZ>0</MAXLZ> <UEETO>0.0</UEETO> <UNETO>0.0</UNETO> <WZEIT>0</WZEIT> <VZUSL>0.00</VZUSL> <UMLMC>0.000</UMLMC> <LADGR>0001</LADGR> <LGRAD>0.0</LGRAD> <OBJID>00000000</OBJID> <MTVFP>01</MTVFP> <VRVEZ>0.00</VRVEZ> <VBAMG>0.000</VBAMG> <VBEAZ>0.00</VBEAZ> <TRAME>0.000</TRAME> <FXHOR>000</FXHOR> <VINT1>000</VINT1> <VINT2>000</VINT2> <LOSGR>0.000</LOSGR> <KAUSF>0.00</KAUSF> <TAKZT>0</TAKZT> <VRBDT>00000000</VRBDT> <VRBFK>0.00</VRBFK> <PRENO>00000000</PRENO> <PREND>00000000</PREND> <PRENG>00000000</PRENG> <PRFRQ>0</PRFRQ> <SHZET>00</SHZET> <MMSTD>00000000</MMSTD> <DPLHO>0</DPLHO> <MINLS>0.000</MINLS> <MAXLS>0.000</MAXLS> <FIXLS>0.000</FIXLS> <LTINC>0.000</LTINC> <COMPL>00</COMPL> <EISLO>0.000</EISLO> </E1MARCM> <E1MARMM SEGMENT="1"> <MSGFN>005</MSGFN> <MEINH>PCE</MEINH> <UMREZ>1</UMREZ> <UMREN>1</UMREN> <LAENG>0.000</LAENG> <BREIT>0.000</BREIT> <HOEHE>0.000</HOEHE> <VOLUM>0.000</VOLUM> <BRGEW>0.200</BRGEW> <GEWEI>KGM</GEWEI> <NEST_FTR>0</NEST_FTR> <MAX_STACK>0</MAX_STACK> <CAPAUSE>0.000</CAPAUSE> </E1MARMM> <E1MBEWM SEGMENT="1"> <MSGFN>005</MSGFN> <BWKEY>2300</BWKEY> <LVORM>X</LVORM> <VPRSV>S</VPRSV> <VERPR>0</VERPR> <STPRS>0.3</STPRS> <PEINH>1</PEINH> <BKLAS>7920</BKLAS> <VMVPR>S</VMVPR> <VMVER>0</VMVER> <VMSTP>0.3</VMSTP> <VMPEI>1</VMPEI> <VMBKL>7920</VMBKL> <VJVPR>S</VJVPR> <VJVER>0</VJVER> <VJSTP>0.3</VJSTP> <LFGJA>1998</LFGJA> <LFMON>09</LFMON> <ZKPRS>0</ZKPRS> <ZKDAT>00000000</ZKDAT> <BWPRS>0</BWPRS> <BWPRH>0</BWPRH> <VJBWS>0</VJBWS> <VJBWH>0</VJBWH> <VVJLB>0.000</VVJLB> <VVMLB>0.000</VVMLB> <VVSAL>0</VVSAL> <ZPLPR>0</ZPLPR> <ZPLP1>0</ZPLP1> <ZPLP2>0</ZPLP2> <ZPLP3>0</ZPLP3> <ZPLD1>00000000</ZPLD1> <ZPLD2>00000000</ZPLD2> <ZPLD3>00000000</ZPLD3> <BWPH1>0</BWPH1> <BWPS1>0</BWPS1> <ABWKZ>00</ABWKZ> <PSTAT>B</PSTAT> <KALN1>000100014878</KALN1> <KALNR>000100014879</KALNR> <VERS1>00</VERS1> <VERS2>00</VERS2> <VERS3>00</VERS3> <PPRDZ>000</PPRDZ> <PPRDL>000</PPRDL> <PPRDV>000</PPRDV> <PDATZ>0000</PDATZ> <PDATL>0000</PDATL> <PDATV>0000</PDATV> <VPLPR>0</VPLPR> <VJBKL>7920</VJBKL> <VJPEI>1</VJPEI> <HKMAT>X</HKMAT> <BWPEI>0</BWPEI> </E1MBEWM> <E1MLANM SEGMENT="1"> <MSGFN>005</MSGFN> <ALAND>ES</ALAND> <TATY1>MWST</TATY1> <TAXM1>0</TAXM1> </E1MLANM> </E1MARAM> </IDOC> </MATMAS01> ',"application/xml")
Add the Send IDoc Operation
The Send IDoc operation sends an IDoc to SAP over a remote function call (RFC):
-
From the Mule Palette view, select SAP and drag the Send IDoc operation next to the Transform Message component.
-
Create a global element named
SAP_Outbound
and specify the connection information. -
Click Test Connection to confirm that Mule runtime engine can connect with the SAP instance.
-
If the connection is successful, save the configuration.
-
Otherwise, review and correct any invalid parameters, and test again.
-
-
Configure the Send IDoc properties with the following values:
Field Value IDoc Name
MATMAS01
Content
#[payload]
Add the Logger Component
The Logger component displays the connector payload in the Studio console.
-
From the Mule Palette view, select Core and drag Logger next to the Send IDoc operation.
-
Click File > Save to save the app.
Run the App
To run the Mule app:
-
Click Run > Run as > Mule Application.
-
From a web browser, test the application by entering an employee’s internal ID, first name, and last name as query parameters for the following URL:
http://localhost:8081/sendIDoc
Mule sends the IDoc to SAP.
XML for Sending an IDoc to SAP
Paste this code into a new Mule app in Studio to quickly load the flow for the sending an IDoc example. Change the values to reflect your environment.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:sap="http://www.mulesoft.org/schema/mule/sap"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/sap http://www.mulesoft.org/schema/mule/sap/current/mule-sap.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="58cb7168-7f00-4b96-977a-31dcc54992dd" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<sap:sap-config name="SAP_Outbound" doc:name="SAP Config" doc:id="367ae57d-001b-4d8f-b50f-f6d1d17410a7" >
<sap:simple-connection-provider-connection username="User1" password="myPassword" systemNumber="00" client="800" applicationServerHost="saptext.net" />
</sap:sap-config>
<flow name="sap_send_idocFlow" doc:id="1ee42fb2-8d7d-482d-8f31-095cef12ff08" >
<http:listener doc:name="Listener" doc:id="a1f287ba-4138-4183-903b-90d34abde5c6" config-ref="HTTP_Listener_config" path="/"/>
<ee:transform doc:name="Transform Message" doc:id="ae593540-a467-463f-9aae-fbfb781da0cd" >
<ee:message >
<ee:set-payload >
<![CDATA[%dw 2.0
output application/xml
---
read('<MATMAS01>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<TABNAM>EDI_DC40</TABNAM>
<MANDT>800</MANDT>
<DOCNUM>0000000003519646</DOCNUM>
<DOCREL>740</DOCREL>
<STATUS>30</STATUS>
<DIRECT>1</DIRECT>
<OUTMOD>2</OUTMOD>
<IDOCTYP>MATMAS01</IDOCTYP>
<MESTYP>MATMAS</MESTYP>
<SNDPOR>SAPIDE</SNDPOR>
<SNDPRT>LS</SNDPRT>
<SNDPRN>T90CLNT090</SNDPRN>
<RCVPOR>MULE01_TP</RCVPOR>
<RCVPRT>LS</RCVPRT>
<RCVPRN>MULE01_LS</RCVPRN>
<CREDAT>20180606</CREDAT>
<CRETIM>133420</CRETIM>
<SERIAL>20180606133420</SERIAL>
</EDI_DC40>
</IDOC>
</MATMAS01>
',"application/xml") ]]>
</ee:set-payload>
</ee:message>
</ee:transform>
<sap:send doc:name="Send IDoc" doc:id="9d6b0825-7cfb-4c3b-bc6a-b9eae917af9b" config-ref="SAP_Outbound" key="MATMAS01"/>
<logger level="INFO" doc:name="Logger" doc:id="8fd50dd8-8db4-4271-863b-ef7a463dcaea" />
</flow>
</mule>
Receive an Incoming IDoc Request
This example shows you how to create a Mule app that waits for incoming IDoc requests from an external SAP system. In this example, the app acts like an RFC server and registers itself as an SAP gateway. When the app receives an IDoc request, it uses a remote function (RFC) call to ask SAP to create the IDoc. Then it logs the IDoc contents to the Studio console.
The following screenshot shows the Studio flows for this example:
Configure the First Flow
The first flow uses a BAPI function to send IDoc requests to an external SAP system. To configure this flow:
-
In Anypoint Studio, create a new Mule project.
-
From the Mule Palette view, select HTTP and drag the Listener source to the canvas.
-
Configure the global element using the default values.
-
In the Listener properties tab, set the path to
/trigger
. -
Drag a Transform Message component next to Listener.
The content of this message is the payload of the BAPI function that receives the IDoc requests.
-
In the Output section of the Transform Message component, overlay the brackets with this text:
%dw 2.0 output application/xml --- { ZMMFM_TRIGGER_IDOC_MATMAS: { "import": { IV_MTYP: "MATMAS" , IV_OBJ: "23" , IV_SYS: "MULE11_LS" } , export: { EV_RET: "0" },export: { EV_OBJ: "0000000003526552" },export: null,changing: null, tables: { T_MSG: null }, } }
-
From the Mule Palette view, select SAP and Drag the Synchronous Remote Function Call operation next to the Transform Message component.
-
Create a global element named
SAP_Config
and specify the connection information. -
Click Test Connection to confirm that Mule runtime engine can connect with the SAP instance.
Configure the Second Flow
The second flow logs the contents of each new IDoc request to the Studio console. To configure this flow:
-
From the Mule Palette view, select SAP and drag the Document listener source to the canvas.
-
Create a new global element for the source and specify the required information.
Configure the Document listener properties with the following values:
Field Value Gateway host
Host running the gateway server
Gateway service
3200
Program id
MULE01_PID
Connection count
1
Idoc type filter regex
MATMAS01
The Gateway host, Gateway service, and Program id must be retrieved from the customer’s SAP team.
Anything that relates to the SAP instance, such as configurations or credentials, must be retrieved from the customer’s SAP team.
-
From the Mule Palette view, select Core and drag a Logger component next to Document listener on the canvas.
-
Click File > Save to save the app.
Run the App
To run the Mule app:
-
Click Run > Run as > Mule Application.
-
From a web browser, test the application by entering the following URL:
http://localhost:8081/trigger
XML for Receiving an IDoc Request
Paste this code into a new Mule app in Studio to quickly load the flow for the receiving an IDoc request example. Change the values to reflect your environment.
%dw 2.0
output application/xml
---
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:sap="http://www.mulesoft.org/schema/mule/sap"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/sap http://www.mulesoft.org/schema/mule/sap/current/mule-sap.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="75b36b20-040b-401f-a65c-f0a966b51190" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<sap:sap-config name="SAP_Config" doc:name="SAP Config" doc:id="1f7e7c6e-4bb5-4270-870f-442cda3e3eb8" >
<sap:simple-connection-provider-connection username="User1" password="myPassword" systemNumber="00" client="800" applicationServerHost="sap.test.net" />
</sap:sap-config>
<flow name="sap-receive-idocFlow1" doc:id="bea8cd17-64d9-4f32-8229-d7eb909e8ee1">
<http:listener doc:name="Listener" doc:id="448acc4a-0078-485b-bc10-f70d05abf721" config-ref="HTTP_Listener_config" path="/trigger" />
<ee:transform doc:name="Transform Message" doc:id="44124bf5-7caf-4050-a3a6-06cfbd37da48">
<ee:message>
<ee:set-payload>
<![CDATA[%dw 2.0
output application/xml
---
{
ZMMFM_TRIGGER_IDOC_MATMAS: {
"import": {
IV_MTYP: "MATMAS"
,
IV_OBJ: "23"
,
IV_SYS: "MULE11_LS"
}
,
export: {
EV_RET: "0"
},export: {
EV_OBJ: "0000000003526552"
},export: null,changing: null,
tables: {
T_MSG: null
},
}
}]]>
</ee:set-payload>
</ee:message>
</ee:transform>
<sap:sync-rfc doc:name="Synchronous Remote Function Call" doc:id="e420d5e1-c436-471e-aa48-59a7d2cee1b9" key="ZCAFM_TRIGGER_IDOC_BY_MSG_TYPE" config-ref="SAP_Config" />
</flow>
<flow name="sap-receive-idocFlow2" doc:id="4b070ed0-19ac-4899-82ce-275226b08426" >
<sap:document-listener doc:name="Document listener" doc:id="a0d3bf88-1bf1-4210-9cf1-5403f30b2d80" gatewayHost="xxx.com" gatewayService="3200" programID="MULE11_IDOC_PID" config-ref="SAP_Config"/>
<logger level="INFO" doc:name="Logger" doc:id="db7ff63b-31b7-48ab-b0ad-73082f4b66c7" message="#[payload]"/>
</flow>
</mule>
Example response on the Studio console:
<MATMAS01>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<TABNAM>EDI_DC40</TABNAM>
<MANDT>800</MANDT>
<DOCNUM>0000000003572826</DOCNUM>
<DOCREL>740</DOCREL>
<STATUS>30</STATUS>
<DIRECT>1</DIRECT>
<OUTMOD>2</OUTMOD>
<IDOCTYP>MATMAS01</IDOCTYP>
<MESTYP>MATMAS</MESTYP>
<SNDPOR>SAPIDE</SNDPOR>
<SNDPRT>LS</SNDPRT>
<SNDPRN>T90CLNT090</SNDPRN>
<RCVPOR>MULE11_TP</RCVPOR>
<RCVPRT>LS</RCVPRT>
<RCVPRN>MULE11_LS</RCVPRN>
<CREDAT>20191004</CREDAT>
<CRETIM>050305</CRETIM>
<SERIAL>20191004050305</SERIAL>
</EDI_DC40>
...
Receive an SAP Function
This example shows you how to create a Mule app that receives an SAP function. This example displays a result when a function is triggered from either another Mule flow or from the SAP GUI. The following screenshot shows the Studio flow for this example:
To create the flow:
-
From the Mule Palette view, select SAP and drag the Function listener source to the canvas.
-
Create a global element named
SAP_Inbound
and specify the connection information. -
Configure the required fields in the properties tab.
-
From the Mule Palette view, select Core and drag the Transform Message component to the right of Function listener.
-
Specify the details based on the metadata. For example:
-
Click File > Save to save the app.
-
Click Run > Run as > Mule Application.
XML for Receiving an SAP Function
Paste this code into a new Mule app in Studio to quickly load the flow for the receiving a function example. Change the values to reflect your environment.
%dw 2.0
output application/xml
---
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:sap="http://www.mulesoft.org/schema/mule/sap"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/sap http://www.mulesoft.org/schema/mule/sap/current/mule-sap.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<sap:sap-config name="SAP_Inbound" doc:name="SAP Config" doc:id="9eb4758e-4eb4-4291-9604-84586dda5cd3" >
<sap:simple-connection-provider-connection username="User1" password="Password" systemNumber="00" client="800" applicationServerHost="sapdev.muletest.net" />
</sap:sap-config>
<flow name="receive-a-functionFlow" doc:id="5104aaba-944d-4b8b-ba35-fc210e1f2c4e" >
<sap:function-listener doc:name="Function listener" doc:id="58ee92ea-967f-4a9c-a14d-164032b1b8ee" config-ref="SAP_Inbound" gatewayHost="gateway.host.com" gatewayService="3200" programID="MULE01_API_PID"/>
<ee:transform doc:name="Transform Message" doc:id="59b4c48f-40ca-4587-80e3-f06d895e1c5b" >
<ee:message >
<ee:set-payload >
<![CDATA[%dw 2.0
output application/java
---
{
}]]>
</ee:set-payload>
</ee:message>
</ee:transform>
</flow>
</mule>
Manage Transactions
This example performs two calls on standard BAPIs that handle bank records and manages those transactions.
The following screenshots show the Studio flows for this example:
Configure the First Flow
The first flow retrieves a list of available banks in the United States, filters the first result, and fetches information about the bank. Transactions are not necessary for queries to SAP. To configure this flow:
-
In Anypoint Studio, create a new Mule project.
-
From the Mule Palette view, select HTTP and drag the Listener source to the canvas.
-
Configure the global element using the default values.
-
In the Listener properties tab, set the path to
/sync-rfc
. -
Drag a Transform Message component next to Listener.
The content of this message filters the banks by country.
-
In the Output section of the Transform Message component, overlay the brackets with this text:
%dw 2.0 output application/xml --- { BAPI_BANK_GETLIST: { "import": { BANK_CTRY: "US", MAX_ROWS: 0 } } }
-
From the Mule Palette view, select SAP and drag the Synchronous Remote Function Call operation next to the Transform Message component.
-
Create a global element named
SAP_Config
and specify the connection information. -
Click Test Connection to confirm that Mule runtime engine can connect with the SAP instance.
-
Enter
BAPI_BANK_GETLIST
for the Function Name andpayload
for the Content. -
Drag another Transform Message component next to Synchronous Remote Function Call.
The content of this message filters the first result.
-
In the Output section of the Transform Message component, overlay the brackets with this text:
%dw 2.0 output application/xml --- { BAPI_BANK_GETDETAIL: { "import" : { BANKCOUNTRY: payload.BAPI_BANK_GETLIST.tables.BANK_LIST.*row[0].BANK_CTRY, BANKKEY: payload.BAPI_BANK_GETLIST.tables.BANK_LIST.*row[0].BANK_KEY } } }
-
From the Mule Palette view, select SAP and drag another Synchronous Remote Function Call operation next to the Transform Message component.
-
Create a global element named
SAP_Config
and specify the connection information. -
Click Test Connection to confirm that Mule runtime engine can connect with the SAP instance.
-
Enter
"BAPI_BANK_GETDETAIL"
for the Function Name andpayload
for the Content. -
From the Mule Palette view, select Core and drag a Logger component next to Synchronous Remote Function Call.
Configure the Second Flow
The second flow creates a sales order from the data. You must add try
to the BAPI call to create a transaction, otherwise the change does not impact SAP. To configure this flow:
-
From the Mule Palette view, select HTTP and drag the Listener source to the canvas.
-
Configure the global element using the default values.
-
In the Listener properties tab, set the path to
/sync-mule-transaction
. -
Drag a Transform Message component next to Listener.
The content of this message creates a sales order from the data.
-
In the Output section of the Transform Message component, overlay the brackets with this text:
%dw 2.0 output application/xml --- { BAPI_SALESORDER_CREATEFROMDAT2: { "import": { ORDER_HEADER_IN: { DOC_TYPE: "TA", SALES_ORG: "3000", DISTR_CHAN: "10", DIVISION: "00" }, ORDER_HEADER_INX: { DOC_TYPE: "X", SALES_ORG: "X", DISTR_CHAN: "X", DIVISION: "X" } }, tables: { ORDER_ITEMS_IN: { row: { ITM_NUMBER: "000010", MATERIAL: "000000000050066128" as Number as String {format: "000000000000000000"}, PLANT: "3000", TARGET_QTY: "1" } }, ORDER_ITEMS_INX: { row: { ITM_NUMBER: "000010", MATERIAL: "X", PLANT: "X", TARGET_QTY: "X" } }, ORDER_PARTNERS: { row: { PARTN_ROLE: "WE", PARTN_NUMB: "0000000448" } }, ORDER_SCHEDULES_IN: { row: { ITM_NUMBER: "000010", SCHED_LINE: "0001", REQ_QTY: "1" } }, ORDER_SCHEDULES_INX: { row: { ITM_NUMBER: "000010", SCHED_LINE: "0001", REQ_QTY: "X" } } } } }
-
From the Mule Palette view, select SAP and drag the Synchronous Remote Function Call operation next to the Transform Message component.
-
Create a global element named
SAP_Config
and specify the connection information. -
Click Test Connection to confirm that Mule runtime engine can connect with the SAP instance.
-
Enter
BAPI_SALESORDER_CREATEFROMDAT2
for the Function Name andpayload
for the Content. -
From the Mule Palette view, select Core and drag On Error Continue under Synchronous Remote Function Call.
-
From the Mule Palette view, select Core and drag a Logger component into On Error Continue.
-
From the Mule Palette view, select Core and drag another Logger component next to Synchronous Remote Function Call.
-
Enter
payload.BAPI_SALESORDER_CREATEFROMDAT2.export.SALESDOCUMENT
for the Message.
Configure the Third Flow
The third flow creates a transaction ID and gets a list. Asynchronous calls do not expect a response and require a different way of managing the transaction. Use specific operations to manage transactions of asynchronous calls. To configure this flow:
-
From the Mule Palette view, select HTTP and drag the Listener source to the canvas.
-
Configure the global element using the default values.
-
In the Listener properties tab, set the path to
/async-rfc
. -
From the Mule Palette view, select SAP and drag the Start SAP transaction operation next to Listener.
-
Create a global element named
SAP_Config
and specify the connection information. -
Click Test Connection to confirm that Mule runtime engine can connect with the SAP instance.
-
From the Mule Palette view, select Core and drag a Set Variable transformer next to Start SAP transaction.
-
Enter
createdTransactionId
for the Name andpayload
for the Value. -
Drag a Transform Message component next to Set Variable.
The content of this message gets a list of banks.
-
In the Output section of the Transform Message component, overlay the brackets with this text:
%dw 2.0 output application/xml --- %dw 2.0 output application/xml --- { BAPI_BANK_GETLIST: { "import": { BANK_CTRY: "US", MAX_ROWS: 0 } } }
-
From the Mule Palette view, select SAP and drag the Asynchronous Remote Function Call operation next to Transform Message.
-
Create a global element named
SAP_Config
and specify the connection information. -
Click Test Connection to confirm that Mule runtime engine can connect with the SAP instance.
-
Enter
"BAPI_BANK_GETLIST"
for the Function Name andpayload
for the Content. -
From the Mule Palette view, select SAP and drag the Confirm transaction operation next to Asynchronous Remote Function Call.
-
Create a global element named
SAP_Config
and specify the connection information. -
Click Test Connection to confirm that Mule runtime engine can connect with the SAP instance.
-
Enter
vars.createdTransactionId
for the Transaction ID (TID).
Run the App
To run the Mule app:
-
Click Run > Run as > Mule Application.
-
From a web browser, test the first flow by entering the following URL:
http://localhost:8081/sync-rfc
You should see the XML output of the request, similar to the following:
<BAPI_BANK_GETDETAIL> <import> <BANKCOUNTRY>US</BANKCOUNTRY> <BANKKEY>021000089</BANKKEY> </import> <export> <BANK_ADDRESS> <BANK_NAME>Citibank</BANK_NAME> <REGION>NY</REGION> <STREET>Park Avenue</STREET> <CITY>New York</CITY> <SWIFT_CODE>CITIUSXX</SWIFT_CODE> <BANK_GROUP/> <POBK_CURAC/> <BANK_NO>021000089</BANK_NO> <POST_BANK/> <BANK_BRANCH>Manhattan</BANK_BRANCH> <ADDR_NO/> </BANK_ADDRESS> <BANK_DETAIL> <CREAT_DATE>2005-03-11</CREAT_DATE> <CREATOR>C5031845</CREATOR> <METHOD/> <FORMATTING/> <BANK_DELETE/> <IBAN_RULE/> <B2B_SUPPORTED>0</B2B_SUPPORTED> <COR1_SUPPORTED>0</COR1_SUPPORTED> <R_TRANSACTION_SUPPORTED>0</R_TRANSACTION_SUPPORTED> </BANK_DETAIL> <RETURN> <TYPE/> <ID/> <NUMBER>000</NUMBER> <MESSAGE/> <LOG_NO/> <LOG_MSG_NO>000000</LOG_MSG_NO> <MESSAGE_V1/> <MESSAGE_V2/> <MESSAGE_V3/> <MESSAGE_V4/> <PARAMETER/> <ROW>0</ROW> <FIELD/> <SYSTEM/> </RETURN> </export> </BAPI_BANK_GETDETAIL>
-
From a web browser, test the second flow by entering the following URL:
http://localhost:8081/sync-mule-transaction
You should see the XML output of the request, similar to the following:
<BAPI_SALESORDER_CREATEFROMDAT2> <import> <BEHAVE_WHEN_ERROR/> <BINARY_RELATIONSHIPTYPE/> <CONVERT/> <INT_NUMBER_ASSIGNMENT/> <LOGIC_SWITCH> <PRICING/> <ATP_WRKMOD/> <SCHEDULING/> <NOSTRUCTURE/> <COND_HANDL/> <ADDR_CHECK/> </LOGIC_SWITCH> <ORDER_HEADER_IN> <REFOBJTYPE/> <REFOBJKEY/> <REFDOCTYPE/> <DOC_TYPE>TA</DOC_TYPE> <COLLECT_NO/> <SALES_ORG>3000</SALES_ORG> <DISTR_CHAN>10</DISTR_CHAN> <DIVISION>00</DIVISION> <SALES_GRP/> <SALES_OFF/> <REQ_DATE_H/> .................... <row id="2"> <TYPE>S</TYPE> <ID>V1</ID> <NUMBER>311</NUMBER> <MESSAGE>Standard Order 23669 has been saved</MESSAGE> <LOG_NO/> <LOG_MSG_NO>000000</LOG_MSG_NO> <MESSAGE_V1>Standard Order</MESSAGE_V1> <MESSAGE_V2>23669</MESSAGE_V2> <MESSAGE_V3/> <MESSAGE_V4/> <PARAMETER>SALES_HEADER_IN</PARAMETER> <ROW>0</ROW> <FIELD/> <SYSTEM>T90CLNT090</SYSTEM> </row> </RETURN> </tables> </BAPI_SALESORDER_CREATEFROMDAT2>
-
From a web browser, test the third flow by entering the following URL:
http://localhost:8081/async-rfc
You should see the XML output of the request, similar to the following:
<BAPI_BANK_GETLIST> <import> <BANK_CTRY>US</BANK_CTRY> <MAX_ROWS>0</MAX_ROWS> </import> </BAPI_BANK_GETLIST>
XML for Managing Transactions
Paste this code into a new Mule app in Studio to quickly load the flow for the managing transactions example. Change the values to reflect your environment.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:sap="http://www.mulesoft.org/schema/mule/sap" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/sap http://www.mulesoft.org/schema/mule/sap/current/mule-sap.xsd">
<configuration-properties file="mule-artifact.properties"/>
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="b89c52ef-8c07-4788-b87e-4c698d718341" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<sap:sap-config name="SAP_Config" doc:name="SAP Config" doc:id="90c5a950-aefd-4fba-9e28-db3fa29767bb">
<sap:simple-connection-provider-connection username="${sap.jcoUser}" password="${sap.jcoPasswd}"
systemNumber="${sap.jcoSysnr}" client="${sap.jcoClient}"
applicationServerHost="${sap.jcoAsHost}"/>
</sap:sap-config>
<flow name="bapi-srfc" doc:id="26ade074-48b4-47bb-a8e9-ca040034dee6" >
<http:listener doc:name="Listener" doc:id="16a60ec9-f1c9-4a07-9a02-e7fcbb185a12" config-ref="HTTP_Listener_config" path="/sync-rfc"/>
<ee:transform doc:name="Filter by country" doc:id="f285db36-da88-4e96-b7e6-c92acf4a8e5b" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
---
{
BAPI_BANK_GETLIST: {
"import": {
BANK_CTRY: "US",
MAX_ROWS: 0
}
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<sap:sync-rfc doc:name="Synchronous Remote Function Call" doc:id="cd5a8815-c5be-4bcc-aaf5-77c90090d124" config-ref="SAP_Config" key="BAPI_BANK_GETLIST"/>
<ee:transform doc:name="Filter first result" doc:id="55eecae1-4e9a-4e5b-93f2-1633bf14dbc9" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
---
{
BAPI_BANK_GETDETAIL: {
"import" : {
BANKCOUNTRY: payload.BAPI_BANK_GETLIST.tables.BANK_LIST.*row[0].BANK_CTRY,
BANKKEY: payload.BAPI_BANK_GETLIST.tables.BANK_LIST.*row[0].BANK_KEY
}
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<sap:sync-rfc doc:name="Synchronous Remote Function Call" doc:id="10404fb9-f887-4cea-9a64-32f8559814d2" config-ref="SAP_Config" key='#["BAPI_BANK_GETDETAIL"]'/>
<logger level="INFO" doc:name="Logger" doc:id="f65b06a8-ff33-4906-9bd0-6c3895e5e0cf" message="#[payload]"/>
</flow>
<flow name="bapi-mule-transaction" doc:id="f47687b3-6e2b-4c22-b4b1-900f9ac5a078" >
<http:listener doc:name="Listener" doc:id="c16d6ef3-4601-4260-b82f-37f35540fdd3" config-ref="HTTP_Listener_config" path="/sync-mule-transaction"/>
<ee:transform doc:name="Transform Message" doc:id="5b07e4f5-12bb-4ed2-941f-599789e5e04f">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/xml
---
{
BAPI_SALESORDER_CREATEFROMDAT2: {
"import": {
ORDER_HEADER_IN: {
DOC_TYPE: "TA",
SALES_ORG: "3000",
DISTR_CHAN: "10",
DIVISION: "00"
},
ORDER_HEADER_INX: {
DOC_TYPE: "X",
SALES_ORG: "X",
DISTR_CHAN: "X",
DIVISION: "X"
}
},
tables: {
ORDER_ITEMS_IN: {
row: {
ITM_NUMBER: "000010",
MATERIAL: "000000000050066128" as Number as String {format: "000000000000000000"},
PLANT: "3000",
TARGET_QTY: "1"
}
},
ORDER_ITEMS_INX: {
row: {
ITM_NUMBER: "000010",
MATERIAL: "X",
PLANT: "X",
TARGET_QTY: "X"
}
},
ORDER_PARTNERS: {
row: {
PARTN_ROLE: "WE",
PARTN_NUMB: "0000000448"
}
},
ORDER_SCHEDULES_IN: {
row: {
ITM_NUMBER: "000010",
SCHED_LINE: "0001",
REQ_QTY: "1"
}
},
ORDER_SCHEDULES_INX: {
row: {
ITM_NUMBER: "000010",
SCHED_LINE: "0001",
REQ_QTY: "X"
}
}
}
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<try doc:name="Try" doc:id="a5e37154-87b2-495a-9576-509d21d2d234" transactionalAction="ALWAYS_BEGIN">
<sap:sync-rfc doc:name="Synchronous Remote Function Call" doc:id="8af8b804-57d2-4b44-a0d2-7a50d7018573" config-ref="SAP_Config" key="BAPI_SALESORDER_CREATEFROMDAT2"/>
<error-handler>
<on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="144141a8-7941-41f3-837b-40a2e25905be">
<logger level="INFO" doc:name="Logger" doc:id="50a3d4c1-1a01-4a8b-ac9d-cdb354ec8ddb" message="Bapi Error" />
</on-error-continue>
</error-handler>
</try>
<logger level="INFO" doc:name="Logger" doc:id="36097fa1-0a5d-44fc-9432-b0ef048a85c7" message="#[payload.BAPI_SALESORDER_CREATEFROMDAT2.export.SALESDOCUMENT]"/>
</flow>
<flow name="async-rfc" doc:id="ba757987-1e8c-47d5-8168-23043948ae8f" >
<http:listener doc:name="Listener" doc:id="ee6d3bf1-3474-4d38-80f9-2651f374d876" config-ref="HTTP_Listener_config" path="/async-rfc"/>
<sap:create-transaction-id doc:name="Start SAP transaction" doc:id="3bfd77a6-3397-45cb-b9c6-6450f3f010c8" config-ref="SAP_Config"/>
<set-variable value="#[payload]" doc:name="Set Variable" doc:id="a20de9fb-61ec-4d90-8da7-fee910da7d49" variableName="createdTransactionId"/>
<ee:transform doc:name="Transform Message" doc:id="7c000a34-c035-470b-8ff3-546e8156ece4" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
---
{
BAPI_BANK_GETLIST: {
"import": {
BANK_CTRY: "US",
MAX_ROWS: 0
}
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<sap:async-rfc doc:name="Asynchronous Remote Function Call" doc:id="a45ec861-be1b-4c16-8d3e-ef83dab24cea" config-ref="SAP_Config" key='#["BAPI_BANK_GETLIST"]' transactionId="#[vars.createdTransactionId]"/>
<sap:confirm-transaction-id doc:name="Confirm transaction" doc:id="939e882d-9416-40c0-8b5d-85871e264aa6" config-ref="SAP_Config" transactionId="#[vars.createdTransactionId]"/>
</flow>
</mule>
Configure Multiple Gateways
This example shows you how to create a Mule app that configures a message server with multiple gateway connections to distribute the load and improve performance, instead of a single gateway connection.
The following screenshot shows the Studio flows for this example:
Configure the First Flow
The first flow passes the message server to the Document listener source. To configure this flow:
-
In Anypoint Studio, create a new Mule project.
-
From the Mule Palette view, select SAP and drag the Document listener source to the canvas.
-
Configure the global element for the Document listener source and fill in the required fields.
-
In the Document listener properties tab, configure the following fields:
Field Value Gateway host
54.160.77.19
Gateway service
3300
Program id
MULE11_IDOC_PID
Connection count
1
-
From the Mule Palette view, select Core and drag a Logger component next to Document listener on the canvas.
Configure the Second Flow
The second flow triggers the first individual gateway. To configure this flow:
-
From the Mule Palette view, drag the HTTP > Listener source to the canvas.
-
Configure the global element using the default values.
-
In the Listener properties tab, set the path to
/c
. -
From the Mule Palette view, select Core and drag the Transform Message component next to the Listener source.
-
In the Output section of the Transform Message component, overlay the brackets with this text:
%dw 2.0 output application/xml --- { ZMMFM_TRIGGER_IDOC_MATMAS: { "import": { IV_MTYP: "MATMAS" , IV_OBJ: "23" , IV_SYS: "MULE11_LS" } , export: { EV_RET: "0" },export: { EV_OBJ: "0000000003526552" },export: null,changing: null, tables: { T_MSG: null }, } }
-
From the Mule Palette view, select SAP and drag the Synchronous Remote Function Call operation to the canvas.
-
Configure the global element for the Synchronous Remote Function Call operation and fill in the required fields.
-
In the Synchronous Remote Function Call properties tab, configure the following fields:
Field Value Function Name
"ZMMFM_TRIGGER_IDOC_MATMAS"
Content
payload
-
From the Mule Palette view, select Core and drag the Transform Message component next to the Synchronous Remote Function Call operation.
-
In the Output section of the Transform Message component, overlay the brackets with this text:
%dw 2.0 output application/json --- payload
Configure the Third Flow
The third flow triggers the second individual gateway. To configure this flow:
-
From the Mule Palette view, drag the HTTP > Listener source to the canvas.
-
Configure the global element using the default values.
-
In the Listener properties tab, set the path to
/d
. -
From the Mule Palette view, select Core and drag the Transform Message component next to the Listener source.
-
In the Output section of the Transform Message component, overlay the brackets with this text:
%dw 2.0 output application/xml --- { ZMMFM_TRIGGER_IDOC_MATMAS: { "import": { IV_MTYP: "MATMAS" , IV_OBJ: "23" , IV_SYS: "MULE11_LS" } , export: { EV_RET: "0" },export: { EV_OBJ: "0000000003526552" },export: null,changing: null, tables: { T_MSG: null }, } }
-
From the Mule Palette view, select SAP and drag the Synchronous Remote Function Call operation to the canvas.
-
Configure the global element for the Synchronous Remote Function Call operation and fill in the required fields.
-
In the Synchronous Remote Function Call properties tab, configure the following fields:
Field Value Function Name
"ZMMFM_TRIGGER_IDOC_MATMAS"
Content
payload
-
From the Mule Palette view, select Core and drag the Transform Message component next to the Synchronous Remote Function Call operation.
-
In the Output section of the Transform Message component, overlay the brackets with this text:
%dw 2.0 output application/json --- payload
XML for Configuring Multiple Gateways
Paste this code into a new Mule app in Studio to quickly load the flow for the configuring multiple gateways example. Change the values to reflect your environment.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:sap="http://www.mulesoft.org/schema/mule/sap" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/sap http://www.mulesoft.org/schema/mule/sap/current/mule-sap.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="5d46abaa-dc40-457b-a7df-ce54fc8f3a43" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<sap:sap-config name="SAP_Config_C" doc:name="SAP Config" doc:id="78a4da95-2381-4bd1-919c-fc86ae23c134" >
<sap:simple-connection-provider-connection systemNumber="02" client="800" applicationServerHost="34.225.79.228" />
</sap:sap-config>
<sap:sap-config name="SAP_Config_D" doc:name="SAP Config" doc:id="0f026b1e-96f8-4ef8-ae46-f4677b1f95ae" >
<sap:simple-connection-provider-connection systemNumber="03" client="800" applicationServerHost="44.214.23.92" />
</sap:sap-config>
<sap:sap-config name="SAP_Config_B" doc:name="SAP Config" doc:id="829dbb29-682b-443d-b85c-47ad20d7c134" >
<sap:simple-connection-provider-connection systemNumber="00" client="800" applicationServerHost="54.160.77.19"/>
</sap:sap-config>
<flow name="sapgatewaytestFlow" doc:id="2f660909-8fef-4872-85d0-efd172ac47fe" >
<sap:document-listener doc:name="Document listener" doc:id="36de92d6-8796-46f6-b280-ac288a57b343" config-ref="SAP_Config_B" gatewayHost="54.160.77.19" gatewayService="3300" programID="MULE11_IDOC_PID"/>
<logger level="INFO" doc:name="Logger" doc:id="51941f3f-a26e-4f60-99bf-637ce7f39e12" message="#[payload]"/>
</flow>
<flow name="sapgatewaytestFlowC" doc:id="4be0cd2f-197c-4cd2-afa5-5833b42399d2" >
<http:listener doc:name="Listener" doc:id="3561b7af-6a02-4497-b02a-09e5dcc71f46" config-ref="HTTP_Listener_config" path="/c"/>
<ee:transform doc:name="Transform Message" doc:id="71afc270-fc02-4fd8-bf82-a97a3eac86ac" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
---
{
ZMMFM_TRIGGER_IDOC_MATMAS: {
"import": {
IV_MTYP: "MATMAS"
,
IV_OBJ: "23"
,
IV_SYS: "MULE11_LS"
}
,
export: {
EV_RET: "0"
},export: {
EV_OBJ: "0000000003526552"
},export: null,changing: null,
tables: {
T_MSG: null
},
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<sap:sync-rfc doc:name="Synchronous Remote Function Call" doc:id="d3b152e0-db3a-4745-a9fe-60cc6ade0581" config-ref="SAP_Config_C" key='#["ZMMFM_TRIGGER_IDOC_MATMAS"]'/>
<ee:transform doc:name="Transform Message" doc:id="387d00c7-efbf-4675-9f50-5fbafe592ec0" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="sapgatewaytestFlowD" doc:id="3b2c4526-74e7-4a21-b18a-f11ba2f86beb" >
<http:listener doc:name="Listener" doc:id="fa1567ab-1ded-415e-8dd2-8a0833451176" config-ref="HTTP_Listener_config" path="/d"/>
<ee:transform doc:name="Transform Message" doc:id="b71d390e-5de2-435d-b0b0-51efb6f70b60" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
---
{
ZMMFM_TRIGGER_IDOC_MATMAS: {
"import": {
IV_MTYP: "MATMAS"
,
IV_OBJ: "23"
,
IV_SYS: "MULE11_LS"
}
,
export: {
EV_RET: "0"
},export: {
EV_OBJ: "0000000003526552"
},export: null,changing: null,
tables: {
T_MSG: null
},
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<sap:sync-rfc doc:name="Synchronous Remote Function Call" doc:id="edfae6dd-edc3-4e56-8a26-d3ad1b51db04" config-ref="SAP_Config_D" key='#["ZMMFM_TRIGGER_IDOC_MATMAS"]'/>
<ee:transform doc:name="Transform Message" doc:id="fd6eb7f2-0c9f-43c6-842d-02be2216620a" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
</mule>