SAP Connector

The SHARK Link SAP Connector supports interface to SAP, using the XML IDOC file format for receiving and confirmation.

The described setup requires the SAP WM module to be available. If the SAP WM module is not an option, an alternative solution is to interface to SAP at a more basic level, using WMMBID and DELVRY IDOCs.

The interface supports both a configuration where the stock is maintained in SAP and in SHARK. 

The following transaction types are supported as basic functionality:

IDOC Message Type Direction SAP -> SHARK SHARK format Description
MATMAS02 MATMAS -> Article Update Article
WMTOID02 WMTORD -> Order Receiving transfer orders from SAP.
WMCAID01 WMCATO -> >Cancel Cancel a transfer order.
WMIVID01 WMINVE -> Inventory Create a inventory order in SHARK (Requires the optional inventory module)
WMTOCO WMTOCO <- Confirmation Transfer order Send to SAP when an order line has been processed in Shark.
      Stock Adjustment Used when stock is adjusted, stored or picked in SHARK without an order from SAP.

The version numbers may change.

The interface can be customized, extended and modified, as needed.

The SAP Connector does not include a standard setup for handling:

As alternatives to the XML IDOCs, the following methods are partly supported, but will require some customization:

Exchange of IDOCs from SAP

A shared folder is defined from where SHARK will read the IDOC XML files. SHARK first copy the file to a temporary folder, transform the file using an XSLT style sheet from SAP to the native XML format of SHARK and then import the file. Afterwards the file is deleted or moved to a log folder if successfully imported or to an error folder if the import failed.

This figure shows the flow of an IDOC from SAP and the import process performed by SHARK Link.

SHARK has also build-in support for FTP/SFTP and may poll an external FTP server for files to import.

As an alternative to using a shared folder, SAP XI can be used in combination with the SHARK Link HTTP Interface.

XSLT file for reading SAP IDOCs

The IDOC documents are read by transforming the SAP format to SHARK internal XML format. This is done using a XSLT stylesheet. The SHARK Link SAP Connector has a default XSLT stylesheet called sap-to-SHARK.xslt. The stylesheet is typical  modified to fit the actually requirement.

Exchange IDOCs to SAP using XML files

IDOC files will be written to SAP, using the following procedure:

  1. The IDOC will be generated in a local folder for temporary files.
  2. When the file is generated, it will be moved to the destination folder, from where SAP will read the file. Normal file system folders and FTP folders are supported.
  3. A copy will also be made to a log folder, where it will reside for a specified number of days (default is 14 days).
  4. SAP reads the IDOC file and move or delete the file afterwards.

The file name of the IDOC file can somehow be configured and consist of one of more fields:

IDOC Control Segment

This section represents the header of the IDoc, it contains an identifier of the IDOC, along with data concerning the sender system and the receiver system.

Fields in the Control Segment:

SAP Element SHARK Note
DOCNUM DocumentID SHARKs internal document number.
MESTYP   Message Type
IDOCTYPE   Basic document type, eg. WMTCID
SNDPOR    
SNDPRT    
SNDPRN LOGISOFT  
RSVPOR SAPVME Port
RSVPRT LS Partner Type
RSVPRN VME700 Partner Number

Some of these fields are hard coded in the XSLT, used for creating the IDOC and can be defined by modifying the XSLT.

XSLT file for writing SAP IDOCs

The IDOC is generated from the standard SHARK XML, using a XSLT transformation file. This file can be modified, to adjust the IDOC format to the actually requirements.

Exchange of information to SAP using RPC

To return information back to SAP, SHARK can as an alternative use the SAPs RPC interface (WMS-WCU).

Login information to the SAP RPC Interface

To allow SHARK to logon to SAP to use RFT, the following information must be provided:

Parameter Description
SAP Host Name Name of the SAP server
SAP client For example “100”
SAP User ID User with authorization for RFC
SAP System Number eg “00”
Password Password for the specified user
Warehouse Number eg “191”
Language eg. “EN”

This covers the supported transaction types and IDOCs involved.

Mapping SAP to SHARK

SAP SHARK Notes
Handling Unit (HU) Picking Box  

Master Data - Message MATMAS

Master data is imported by the MATMAS document.

Note that if Master Data is updated by SAP, the data will override information edited directly in SHARK . Especially  if any kind of replenishment data is specified, for example like quantity that fits into a box type and similar information, this data could also be modified directly in SHARK, these data will be overwritten and lost when updated by SAP.

IDOC MATMAT

Segment: E1MARAM

Element Type SHARK Name Description
MATNR string Article/ArticleNumber Unique article number defining the item, despite the name, it is a string that can contain both numbers and letters.
E1MAKTM/MAKTX string Article/Description Description of the article
EAN11 string Article/EAN Article EAN Code
MEINS string Article/Unit Default unit for this article

This is the basic information in the file, more fields can be added as needed.

Below is the section of the sap-to-SHARK.xsl file, that transform the the SAP IDoc to XML format used by SHARK.


    <!-- ************************************* -->
    <!-- Read Item Master Data -->
    <!-- ************************************* -->
    
    <xsl:template match="/MATMAS01/IDOC">
        <SHARK-ERP>
            <xsl:apply-templates/>
        </SHARK-ERP>
    
    </xsl:template>
    <xsl:template match="E1MARAM">
        <Article>
            <ArticleNumber><xsl:value-of select="MATNR"/></ArticleNumber>
            <Description><xsl:value-of select="E1MAKTM/MAKTX"/></Description>
           <EAN><xsl:value-of select="EAN11"/></EAN>
           <LocationType>Floating</LocationType>
           <Unit><xsl:value-of select="MEINS"/></Unit>
           <Packages>
               <Package>
                   <Unit><xsl:value-of select="MEINS"/></Unit>
                  <LocationTypes>
                      <LocationType>
                          <LocationName><xsl:value-of select="E1MLGNM/LETY1"/></LocationName>
                      </LocationType>
                   </LocationTypes>
               </Package>
           </Packages>
        </Article>
    </xsl:template>

Inbound Transfer Order (Goods Reception) - Message WMTORD

SAP creates transfer orders (TOs) for the goods movements.

SAP transfers the transfer orders to SHARK system using the message type WMTORD.

SHARK executes the goods movements in the warehouse on the basis of the transferred data.

SHARK reports  back to the WMS via message type WMTOCO, that the warehouse movements for the TO have been executed.

The SAP confirms the transfer order on the basis of the data that was transferred using message type WMTOCO

Orders are received using the IDOC WMTORD.

IDOC Exhange for Outbound Transfer OrdersSAPSAPSHARKSHARKGoods movenent is triggerand TO is created.WMTORDOrder is processedWMTOCOConfirm of goodsreceived.

IDOC WMORD

WMORD IDOC contains the order from SAP. It is mapped to the SHARK type by an XML-XSLT transformation file.

Segment: E1LTORH

Element Type SHARK Name Description
TANUM string OrderNumber Transfer order number in SAP is mapped to a SHARK order number.
BWLVS string Order type The movement type in SAP is called OrderTypeID in SHARK.  The mapping can either be done by having a one-to-one mapping (BWLVS=>OrderTypeID) or the XSLT file is used to convert the SAP type to another type.

Please note that if an undefined movement type is received. The only action taken, is to generate an error log. SHARK cannot see if it is a pick or put order will not generate any orders from the received document.

 #### Segment: E1LTORI

Repeated for each order line in the transfer order.

Element Type Type Description  
MATNR string Article number Unique article number defining the item, despite the name, it is a string that can contain both numbers and letters.  
NSOLM float Qty Description of the article  
MEINS string PackageSize If defined, this must match an package size in SHARK .  
TAPOS integert LineNumber This is the position or line number for the order line.  
CHARG string BatchNumber Optional batch number.  

Order line Confirmation

When a put is done in SHARK it is reported back to SAP using an XML IDOC alternatively an RPC call.

RPC Call

These calls can fail if a SAP user has opened the order SHARK is trying to confirm, in that case will SAP put a lock on the order and the confirmation will fail. SHARK will in this situation log a warning and try again to commit until it succeeds. Other errors will log an error in the system log and SHARK will not try again. Typical errors can for example be if a user as confirmed an order manually that SHARK is trying to confirm.

Outbound Transfer Order (Picking) - Message WMTORD

The outbound transfer order is used for picking sales, production or other types of outbound delivery of goods.

  1. SAP creates transfer orders (TOs) for the goods movements.
  2. SAP transfers the transfer orders to SHARK system using the message type WMTORD.
  3. SHARK executes the goods movements in the warehouse on the basis of the transferred data.
  4. SHARK reports back to the WMS via message type WMTOCO, that the warehouse movements for the TO have been executed.
  5. The SAP confirms the transfer order on the basis of the data that was transferred using message type WMTOCO

Orders are received using the IDOC WMTORD.

IDOC Exhange for Outbound Transfer OrdersSAPSAPSHARKSHARKSales order received.Delivery created.WMTORDOrder is picked.WMTOCOConfirm of goods moved.

IDOC WMORD

WMORD IDOC contains the order from SAP. It is mapped to the SHARK type by an XML-XSLT transformation file.

Segment: E1LTORH

Element Type SHARK name Description
TANUM string OrderNumber Transfer order number in SAP, is mapped to a SHARK order number.
BWLVS string OrderTypeID

O.Misc5
The movement type in SAP is called OrderTypeID in SHARK . The mapping can either be done by having a one-to-one mapping (BWLVS=>OrderTypeID) or the XSLT file is used to convert the SAP type to another type.
TAPRI string Priority Transfer Order Priority
LGNUM string - Storage Number in SAP.
TRART string OrderType Typical the movement type is used to identify the direction of the transfer.
BETYP string - Requirement type.
BENUM string - Purchase order number

Please note that if an undefined movement type is received. The only action taken, is to generate an error log. SHARK cannot see if it is a pick or put order will not generate any orders from the received document.

Segment: E1LTORI

Repeated for each order line in the transfer order.

       
Element Type SHARK Name Description
MATNR string Article number Unique article number defining the item, despite the name, it is a string that can contain both numbers and letters.
NSOLM float Qty Description of the article
MEINS string PackageSize Unit of measure.

If defined, this must match an package size in SHARK .
TAPOS integert LineNumber This is the position or line number for the order line.
WERKS string - Plant. Not used in SHARK.
CHARG string BatchNumber Optional batch number.
LETYP string   Storage Unit Type
KZQUI string - X: Confirmation Required.

Typical not used in SHARK.
VLTYP string OL.Misc2 Source Storage Type.
VLBER string OL.Misc3 Source Storage Section.
VLPLA string Location

OL.Misc4
Source Storage Bin.

For WCS solution, this is the location in SHARK from where SAP wants to pick to goods. It must exactly match an existing location in SHARK.
VSOLM Number - Source target quantity in stock keeping units.
NLTYP string OL.Misc5 Destination Storage Type.
(Not relevant for SHARK)
NLBER string OL.Misc6 Destination Storage Section.
(Not relevant for SHARK)
NLPLA string OL.Misc7 Destination Storage Bin.
(Not relevant for SHARK)
NSOLM Number - Destination Target Quantity in stock keeping units.
(Not relevant for SHARK)
MAKTX string   Material Description

Confirmation by RPC

A successful pick or store is reported by:

RPC function: L_TO_CONFIRM

Parameter Value Description
I_LGNUM Registry: SAP.WareHouse Warehouse Number
TANUM SHARK Order number  
TAPOS SHARK Line number  
SQUIT=X If no differences reported “X” if successfully executed.
NDIFA Subseq diff. qty Difference qty</p></td>
NISTA Subseq. Actual qty Actually delivered qty</p></td>
ALTME Unit  
KZDIF    

Cancel a Transfer Order - Message WMCATO

SAP may transfer an order or an order line in SHARK using the message.

Element Type Type Description
LGNUM string   Storage Number. This is a fixed number from SAP , ignored by SHARK.
TANUM string OrderNumber Transport Order Number.
CANRQ string   X: Cancel Request
TAPOS integert LineNumber This is the position or line number for the order line.

Order line Confirmation using RPC – Message WMTOCO

When a pick is done in SHARK it is reported back to SAP using RPC calls.

These calls can fail if a SAP user has opened the order SHARK is trying to confirm, in that case will SAP put a lock on the order and the confirmation will fail. SHARK will in this situation log a warning and try again to commit until it succeeds. Other errors will log an error in the system log and SHARK will not try again. Typical errors can for example be if a user as confirmed an order manually that SHARK is trying to confirm.

A successful pick or put is reported by:

RPC function: L_TO_CONFIRM

Parameter Value/source Description
TANUM Order number  
TAPOS Line number  
SQUIT=X If no diff. reported  

A partical pick or put is reported by:

RPC function: L_TO_CONFIRM

Parameter Value/source Description
TANUM Order number  
TAPOS Line number  
NDIFA Subseq diff. qty  
NISTA Subseq. Actual qty Actually delivered quantity
ALTME Unit  
KZDIF   Differences indicator

Cancel a Transfer Order in SHARK (RFC only) 

When the order is cancelled in SHARK it will respond to SAP by calling L_TO_CANCEL.

RPC function: L_TO_CANCEL

Parameter Value/source Description
I_TANUM Order Number  
I_LGNUM Warehouse number  

Reporting Stock Adjustments to SAP using RFC

When a pick/put or adjustment is done in SHARK, as a “Manuel Operation” (transactions without orders from a host system), it can be reported back to SAP.  Because there is no transfer order in SAP that has initiated this operation, we have to create one, this is done by calling the RPC function L_TO_CREATE_SINGLE.

If the stock is increased in SHARK:

RFC: L_TO_CREATE_SINGLE

Parameter Value/source Description
I_WERKS XSLT file Plant
I_LGNUM   Warehouse number
I_BENUM Logimat Requirement number
I_BWLVS XSLT file Movement type default is 712
I_MATNR Article number from SHARK SAP Material Number
I_VLTYP Registry: SAP.Adjustments.SAPStorageType(1) Storage type in SAP . Default is 999.
I_NLTYP Registry: SAP.Adjustments.SHARKStorageType(1) Storage type in SHARK. Default is 20
I_LGORT Registry: SAP.Adjustments.SAPStorageLocation(1) Default is 0001
I_ANFME Quantity from SHARK Quantity adjusted
I_SQUIT X Execute

(1) The registry is relative to the port used for confirmation. The typical placement is Scheduler.Jobs.DocumentExport.Parameters.Ports.OrderAck.SAP  

If the stock is decreased in SHARK:

RFC: L_TO_CREATE_SINGLE

Parameter Value/source Description
I_WERKS Plant Plant
I_LGNUM Warehouse number Warehouse number
I_BENUM Logimat Requirement number
I_BWLVS Movement type Movement type default is 712
I_MATNR Article number Article number from SHARK. SAP Material Number
I_VLTYP Registry: SAP.Adjustments.SAPStorageType(1) Storage type in SAP . Default is 999.
I_NLTYP Registry: SAP.Adjustments.SHARKStorageType(1) Storage type in SHARK. Default is 20
I_ANFME Quantity Quantity adjusted
I_LGORT Registry: SAP.Adjustments.SAPStorageLocation(1) Default is 0001
I_SQUIT X Execute

(1) The registry is relative to the port used for confirmation. The typical placement is Scheduler.Jobs.DocumentExport.Parameters.Ports.OrderAck.SAP

To enable this function in SHARK, set the registry parameter:

SAP.ReportStockAdjustments=true

Absolute Stock Reports

SAP can initiate a complete stock report using absolute qty values. A stock counting list is generated in SAP, SHARK reads the file and adds the correct quantities to the file and immediately returns it to SAP. This means that the actually counting in SHARK must be done before the SAP requests the stock.

By sending an IDOC file of type WMINVE SAP is asked to read the file back in using the RPC call: EDI_DATA_INCOMING, the call requires a “port” parameter, the file port is used to determine the file type of the input file whether is flat or XML file. If the file type is XML, then FM EDI_DATA_INCOMING will call FM IDOC_XML_FROM_FILE to process inbound IDoc file.

Procedure:

  1. SAP output an XML IDOC file in the SHARK import folder.
  2. SHARK reads the XML file generates a new similar file with the quantities added to the MENGA field.
  3. The final file is moved to the defined “OutFolder”.
  4. Optional SHARK calls SAPs “EDI_DATA_INCOMING” with the path to the file.

Fields in the IDOC file

Field in Source  File Field in returned file Note
SNDPRN RCVPRN  
RCVPRN SNDPRN  
  MENGA Quantity on stock
CHARG CHARG Bath number if supplied
MATNR MATNR Article Number

 

The call used to notify SAP about the returned file:

RFC: EDI_DATA_INCOMING

Parameter Value/source Description
PATHNAME Path the returned SHARK IDOC file  
PORT Registry: SAP.PortIncommingData  

 

Example of IDOC WMINVE file as send by SAP:

    <?xml version="1.0" encoding="UTF-8" ?>
      <WMIVID01>
                    <IDOC BEGIN="1">
                                  <EDI_DC40 SEGMENT="1">
                                                <TABNAM>EDI_DC40</TABNAM>
                                                <MANDT>300</MANDT>
                                                <DOCNUM>0000000000964029</DOCNUM>
                                                <DOCREL>620</DOCREL>
                                                <STATUS>30</STATUS>
                                                <DIRECT>1</DIRECT>
                                                <OUTMOD>2</OUTMOD>
                                                <IDOCTYP>WMIVID01</IDOCTYP>
                                                <MESTYP>WMINVE</MESTYP>
                    <                           <SNDPOR>SAPR3P</SNDPOR>
                                                <SNDPRT>LS</SNDPRT>
                                                <SNDPRN>R3PCLNT300</SNDPRN>
                                                <RCVPOR>XMLSYNC</RCVPOR>
                                                <RCVPRT>LS</RCVPRT>
                                                <RCVPRN>WM_SUB_001</RCVPRN>
                                                <CREDAT>20061130</CREDAT>
                                                <CRETIM>081644</CRETIM>
                                                <SERIAL>20061130081644</SERIAL>
                                  </EDI_DC40>
                                <E1LINVX SEGMENT="1">
                                                <LGNUM>191</LGNUM>
                                                <IVNUM>0000000026</IVNUM>
                                                <IVPOS>0001</IVPOS>
                                                <LGTYP>005</LGTYP>
                                                <LGPLA>LOGIMAT</LGPLA>
                                                <MATNR>000000000001000058</MATNR>
                                                <WERKS>1110</WERKS>
                                                <WDATU>20050320</WDATU>
                                                <MENGA>0.000</MENGA>
                                                <ALTME>ST</ALTME>
                                                <LQNUM>0000001958</LQNUM>
                                                <NANUM>00</NANUM>
                                                <NVERS>00</NVERS>
                                                <ISTAT>N</ISTAT>
                                                <IDATU>20050614</IDATU>
                                                <KZINV>ST</KZINV>
                                                <MAKTX>INK ROLL FOR MARKING (LOOSE)</MAKTX>
                                                <ISEIT>0000</ISEIT>
                                                <VFDAT>00000000</VFDAT>
                                                <LGORT>1191</LGORT>
                                  </E1LINVX>
      ....

Interface without SAP WM

If the SAP installation does not use SAP WM, an alternative way to interface the 2 systems is to use the interface between SHARK and SAP, that can be used when not using the SAP WM module, can be based on the exchange of orders using the IDOCs WMTCID and WMTCID.


 


    <xsl:template match="/WMMBID02/IDOC/E1MBXYH/E1MBXYI [BWART='312' or BWLVS='999']">
            <SHARK-ERP>
                <Order>
                    <OrderNumber>
                        <xsl:value-of select="TANUM"/>
                    </OrderNumber>
                    <DeliveryNote>
                        <xsl:value-of select="E1LTORI/NLPLA"/> [<xsl:value-of select="BWLVS"/>]
                    </DeliveryNote>
                    <xsl:for-each select="E1LTORI">
                        <xsl:call-template  name="PICKLINE"/>
                    </xsl:for-each>
                </Order>
            </SHARK-ERP>
        </xsl:template>
    
        <xsl:template match="/WMMBID02/IDOC/E1MBXYH/E1MBXYI[(BWART='101' or BWART='311') and SHKZG='S']">
            <SHARK-ERP>
                <Article>
                    <ArticleNumber><xsl:value-of select="MATNR"/></ArticleNumber>
                </Article>
                <PutAway>
                    <OrderNumber><xsl:value-of select="EBELN"/></OrderNumber>
                    <DeliveryNoteNumber><xsl:value-of select="SMBLN"/></DeliveryNoteNumber>
                    <OrderLine>
                        <ItemNumber><xsl:value-of select="MATNR"/></ItemNumber>
                        <ItemText><xsl:value-of select="MAKTX"/></ItemText>
                        <ItemCount><xsl:value-of select="BPMNG"/></ItemCount>
                        <BatchNumber><xsl:value-of select="CHARG"/></BatchNumber>
                    </OrderLine>
                </PutAway>
            </SHARK-ERP>
        </xsl:template>
    
        <xsl:template match="/WMMBID02/IDOC/E1MBXYH/E1MBXYI[(BWART='102' or BWART='311') and SHKZG='H']">

Pick and Put-Away Orders

Orders are received using the IDOC WMTCID02, Post goods receipt (goods movement), message.

SHARK confirms the goods movement, using the IDOC DELVRY05.

Movement types are used to control the direction of material flow.

Picking Confirmation to SAP

Confirmation is done using the IDOC WMTCID01. SHARK will return this document when the order is finalized.

IDOC: WMTCID03

Configuration

This section covers configuration issues with the SAP interface.

SHARK Scheduler Setup

The SHARK Scheduler is used to setup automatic import of IDOCs and to confirm by IDOCs and RPC call to SAP.

Two jobs are defined in the Scheduler:

An file importer using the class dk.logiware.SHARKlink.SHARKLinkImportSAP.

A job that confirms operations to SAP using the class: dk.logiware.SHARKlink.SHARKLinkExportSAP.

Configuration of the Importer:

 

SAP specific parameters for the importer:

PortIncommingData: This is the SAP Port used in the EDI_DATA_INCOMING RPC call for reading the XML inventory file. The port must be an XML file reader entry.

Configuration of the exporter:

DefaultCommitUser: This is the default SAP user name used for commitment of transactions. It must be a valid SAP user or leave it empty.

InventoryMode: If true the inventory functionality will be enabled.

ReportStockAdjustment: If true stock adjustment in SHARK will be reported back to SAP using relative adjustment and the L_TO_CREATE_SINGLE RPC call. Not all SAP setups will accept this.

OutFolder: This is the SAP path to the folder where SHARK deliveres IDOC files for import into SAP. Default is the same path as SHARK see, but in case SAP is using another file system than Windows, the path may be different. SHARK still uses the normal OutFolder parameter when generating the file, it is only the information that is supplied to SAP.

SAP Movement Types

SAP uses Movement Types to specify transfer orders. The translation of the Movement Types to SHARK order types happens in the XSLT template, default named “sap-to-SHARK.xslt”. If customized or none supported Movement Types are used, they must be added to the XSLT file. There are two lines in the file, one for picking orders and one for put-away.

Picking orders:

\<xsl:template match="/WMTOID01/IDOC/E1LTORH\[BWLVS='319' or
BWLVS='601'  or BWLVS='711' or BWLVS='712' or ....

Put-away orders:

\<xsl:template match="/WMTOID01/IDOC/E1LTORH\[BWLVS='101' or BWLVS='561'
or BWLVS='501' or BWLVS='312' or ...

Add a new BWLVS=’<movement type>’ to one of those lines.

Please note that if transfer order is received from SAP with an unknown movement type, it will result in an error and the file will not be imported.

SAP Configuration

This document does not cover configuration of the SAP application. But the following must be configured in SAP:

The Partner Profile must be defined.

A PORT must be defined to the exchange of IDocs.