You are on page 1of 29

SDN Contribution

AUTOMATED PO DOWNLOAD MESSAGE

Summary The interface proposed is based on a standard SAP interface for Purchase Orders via ALE/IDoc and Message Control type ORDRS (function module: IDOC_OUTPUT_ORDERS), which is used to generate an IDOC (IDoc type " ORDERS01") directly whenever Purchase Orders are approved. This technique (message control) can be used to send purchase order data to a 3rd Party WMS. The condition technique is used to determine in which cases (e.g. only for specific purchase order types) and to which partners the data is to be sent. When the message is processed, an intermediate document (IDoc) is generated that contains the purchase order data. The IDoc is forwarded to the EDI layer, which takes care of sending the message to the outbound port and, if necessary, triggers immediate further processing. This type of interface is suitable for both batch and online communication. There has been a requirement to generate idocs whenever the Purchase Order is created, changed or deleted. The deletion of the purchase order is at the line item level and the idocs are created at the line item level and not in the header part. The user need not enter the data in the message control in order to generate the idocs.
Created on: 15 Sep 2005

Author Bio Aveek has more than 11 years experience in software analysis and design and custom development both in India and abroad. He has handled software projects U.S., Holland, UK, Switzerland and India. He has during his association with IBM, PWC & Consultancy firms in the U.S. gathered wide experience in developing leading edge technological solutions. He has been heavily involved in developing Materials Management System, Manufacturing & Material Handlings applications, Process Control System Interfaces, Warehouse Control applications and Financial
2006 SAP AG 1

applications in almost all the software projects he has undertaken. For the past 6 years, Aveek has been associated with a number of SAP projects in India and abroad.. Aveek has been involved in handling Process Control Interfaces in the Manufacturing area.
.

2006 SAP AG

Table of Contents

2006 SAP AG

Data Flow Diagram

Schematic Diagram of Outbound Interfaces (Sample IDOC to message with file contents)

SAP Instance
Function module for outbound message processing

IDOC Outbound Processing

IDOC

Send IDOC Outbound Server of SapLink for R/3 Send Message Populate Wrapper

Message(IDOC)
MQ Series Input Queue Map Transformation Engine Map Map MQ Series Output Queue

Middleware Hub

Message(FILE)
MQ Series Input Queue Process Message Remove Wrapper Trigger

Receiving Server
The initial processing of the message is always triggered by middleware

File

Write File Load/Process File The loading of the file can be triggered by middleware on receipt or scheduled by the application

Application Scheduler

2006 SAP AG

Customizing Overview Our goal is to send purchase order data to an output port. The easiest way to do it is to use the IDOC output processing that is already defined in standard. Then, rather than sending the data to the vendor, we send it to our interfaced system. A new message type Z005 has to be created, for which a processing routine using medium type a (ALE) and the program RSNASTED with subroutine ALE_PROCESSING is to be set up. As a partner function, an entry for the medium ALE and partner function RP (Receiving Plant, see below) has to be created. Regarding its fine-tuned control, this message should be defined for operation 1 (creation) and operation 2 (change). This message type can be linked to the existing access sequence Z001. Since the application EF (Purchase Order), from which the message control originates, generates only messages having as a partner type either VN or CU, dummy vendors will have to be created to represent the receiving plants. This is necessary because on entering a partner number in a condition record, a check for a corresponding vendor master record is carried out by the system. For this purpose, a new partner function RP (Receiving Plant) with partner type LI is to be created. It is possible, though, to map this partner function with partner type LI to partner type LS using the above mentioned medium ALE and subroutine ALE_PROCESSING in the output type. An ALE distribution model is to be maintained with all the receiving plants as receiving logical systems and message type ORDERS. In the filter setting, the vendor number of the dummy vendors, identical with the receiving logical systems, are to be entered. The output of the idoc message will have to be conditioned to the keyfields purchasing document type and plant, possibly purchasing organization. To facilitate this, a new condition table 923 with these key fields will be created. This condition table has to be integrated into the access sequence as a new access. Since the message is only to be sent on release of the purchase order, an additional requirement needs to be specified for this access. For the set up of the partner profiles, an outbound partner profile of the message type ORDERS is to be created for every plant that needs to receive the message. Both the partner type and the partner function will be that of LS (logical system). The idoc format will be an enhancement of the standard idoc type ORDERS05. In the Message Control options, an entry for the application EF (Purchase Order), the newly created message output type Z005 and the process code ME10 has to be made.

2006 SAP AG

Interface Overview SAP Release Purchase Order (note that each Purchase Order change has to be approved) IDoc Created with Header and Detail Information tRFC Initiates IDoc Pass through ALE Adapter to Mercator/translator Mercator/Translator IDoc Information Mapped to Format for Purchase Orders in the 3rd Party WMS One message created for each Line-Delivery Point in Purchase Order Mercator Output delivered to Correct WMS Instance (SAP Plant) WMS Import File from SAP (through Mercator /Translator) Add to Current List of Purchase Orders

2006 SAP AG

EDI Message Structure

EANCOM - ORDERS Message D 96A Purchase order message Segment ID UNH BGM DTM FTX SG1 RFF SG2 NAD SG3 RFF SG5 CTA COM SG25 LIN PIA QTY DTM FTX SG29 RFF UNS CNT UNT Page N Seg.N Status Max. Use o 1 M 1 2 M 1 3 M 35 4 C 10 5 M 1 99 6 M 1 10 7 M 1 5 8 M 1 9 C 200000 12 M 1 13 C 14 C 3 M 35 15 C 10 17 M 1 18 M 1 19 C 20 M 1 Segment Name MESSAGE HEADER Beginning of message Date/time/period Free text Order Notes RFF Reference NAD-SG3-SG5 Name and address RFF Reference CTA-COM Contact information Communication contact LIN-PIA-QTY-DTM-FTX-SG29 Line item Additional product id Quantity Date/time/period Free text Line Notes Only as required RFF Reference SECTION CONTROL Control total MESSAGE TRAILER

C C C C

EDI Message Example Purchase Order from Nestl to Vendor for delivery to a 3rd. Party Warehouse Example of proposed message UNA:+.? ' UNB+UNOB:3+9301235852671:14+9300605123458:14+020525:1058+00000000453847'

2006 SAP AG

UNH+00000000453847+ ORDERS :D:96A:EN:EAN008 BGM+241+453847+9 DTM+137:200205251059:203 A "Delivery schedule" IDOC N, Original message This Message Date & Time Order Note (Delivery) Instructions as

FTX+ORI+1++PLEASE DELIVER ON CHEP PALLETS' required RFF+ON:4500000493 NAD+BY+20005::92' CTA+PD' COM+021 9876543:TE' NAD+SE+5001000668943::9 RFF+IA:0100000100' CTA+SD' COM+021 9246354:TE' NAD+ST+9300605123458::9 LIN+10++9300605345676:EN GTIN If available Material Code = 30532 Purchasing Plant code

Customer Purchase Order N = 4500000493 Purchasing Contact Telephone N 021 9876543 Vendor's GLN Account number for the Vendor Shipping Contact Telephone N 021 9246354 Delivery Site's GLN Third Party Warehouse First line of this Purchase Order (Line 10), Material

PIA+1+02:PV+30532:IN+30532:SA GTIN Variant = 02, and Vendor's Material Code QTY+21:48:CS DTM+2:200205260830:203 Quantity Ordered = 48 Cases Requested Delivery date (time) only available at line level.

FTX+MKS+1++PLEASE DELIVER ON ONE PALLET' Shipping marks/ Instructions (free text) if required at line-level LIN+20 Material PIA+41643:IN+ QTY+21:5000:MTR DTM+2:200205280700:203 RFF+ZSS:K' UNS+S' CNT+2:2' UNT+143+00000000453847 UNZ+1+00000000453847 Second line of this Purchase Order, No GTIN for this Only have Material Code = 41643 Quantity Ordered = 5 000 Metres Requested Delivery date (time) only available at line level. It is "Consignment " Material Detail/summary section separation Two LIN segment(s) in this message

2006 SAP AG

Routing lookup table

Seq 1 2 3 4 5

Field name GLN code Logical system Delivery_GID Delivery_ID Mapping format

Description EANCOM value Idoc header value Middleware Hub

Format char(13) char(10) char(2)

Pad fixed fixed yes, with space fixed no

Mandatory yes yes yes yes yes

Middleware value for the char(6) destination describe which message format will have to be produced

Routing rule A lookup table is used Read the Idoc field EDIDC-RCVPRN Read the MW lookup table where Idoc field EDIDC-RCVPRN = Logical system If Mapping field = EANCOM, map the Idoc to an EANCOM message and send it to the Delivery GID / Delivery ID of the lookup table The corresponding GLN code will be populated in the EANCOM message.

2006 SAP AG

Customizing for Automated PO Download

Condition Tables

SPRO-> MM->Purchasing->Messages->Output control

2006 SAP AG

10

The condition table used in the config is 925 which is by Purchasing document type and plant.

2006 SAP AG

11

Access Sequence
Access Sequence used is Z002.

Maintain Message Types

2006 SAP AG

12

The output type we need to consider is Z005. General Tab when displaying the details of the output

The access sequence in the config for message type should be Z002.

Default values Tab:

2006 SAP AG

13

Processing Routine for the output type: for EDI

2006 SAP AG

14

Processing Routine for the output type: for ALE:

Partner Roles option for the output type Z005:

2006 SAP AG

15

Maintain Message types for message Control

The Routine relevant for the Purchase Order download is 911 which is linked to the application EF. Routine 911 source Code:
FORM KOBED_911. *{ INSERT G10K916219 1

* Remove duplicate entries for output conditioning by DocTyp/Plant * in xnast data: l_objkey_from like nast-objky, l_objkey_to like nast-objky, l_parnr like nast-PARNR, l_parvw like nast-PARVW, l_knumh like nach-knumh, l_lines type i, l_sysubrc like sy-subrc, i_objky like table of nast-objky with header line.

2006 SAP AG

16

local: l_objkey_from, l_objkey_to, l_parnr, l_parvw, l_knumh, l_lines, l_sysubrc, i_objky. refresh i_objky. * Check for the name of the condition table. If changed in customizing, * it has to be maintained! check T682I-KOTABNR = '925'. * KNUMH: number of valid condition record select single KNUMH from B925 into l_knumh where KAPPL = KOMT1-KAPPL and KSCHL = KOMT1-KSCHL and BSART = KOMKBEA-BSART and WERKS = KOMPBEA-WERKS. * sy-subrc = 0 has to be returned to calling program, otherwise no * further access to conditions is executed! l_sysubrc = sy-subrc. clear sy-subrc. * >>> INS HOTFIX * Check if failed Idocs exist already loop at xnast where kappl = komt1-kappl and kschl = komt1-kschl and vstat = '2'. xnast-vstat = '0'. modify xnast. endloop. * <<< INS HOTFIX. check l_sysubrc = 0. * Get partner information to condition record select single PARVW PARNR from nach into (l_parvw, l_parnr) where KNUMH = l_knumh.

2006 SAP AG

17

l_sysubrc = sy-subrc. clear sy-subrc. check l_sysubrc = 0. * Exist other xnast records with identical partner? loop at xnast where KAPPL = KOMT1-KAPPL and KSCHL = KOMT1-KSCHL and SPRAS = sy-langu and PARNR = l_parnr and PARVW = l_parvw and ERDAT = sy-datum and VSTAT = '0'. i_objky = xnast-objky. append i_objky. clear i_objky. endloop. l_sysubrc = sy-subrc. clear sy-subrc. check l_sysubrc = 0. sort i_objky. describe table i_objky lines l_lines. read table i_objky index 1 into l_objkey_from. read table i_objky index l_lines into l_objkey_to. * Delete duplicate xnast records for partner currently processed CALL FUNCTION 'RV_MESSAGES_DELETE_PARTNER' EXPORTING msg_objky MSG_OBJKY_TO msg_parnr msg_parvw *} INSERT ENDFORM. FORM KOBEV_911. *{ INSERT G10K916219 1 = l_objkey_from = l_objkey_to = l_parnr = l_parvw.

perform KOBED_911. *} INSERT

ENDFORM.

2006 SAP AG

18

Message Determination Schema

Click on RMBEF1 and double click the control data. This brings you to the following screen.

Make sure that the Z005 output type is configured to the 911 routine.

2006 SAP AG

19

Config in VK01

Enter the usage as B and the application as EF. This brings you to the following screen

Choose Condition Types and press execute button Choose Z005 and press the magnifying glass:

2006 SAP AG

20

This displays the following screen:

2006 SAP AG

21

Note the partner function is maintained as LS instead of VN. Press on the Partner definition and enter the following details: There should be 2 entries for each EDI and ALE ie 6 and A.

2006 SAP AG

22

For the processing program details enter the following:

2006 SAP AG

23

ALE Config
Partner Profile set up ( WE20). Outbound Options

2006 SAP AG

24

Message Control

Note there are 2 entries in the message control one for create and one for change.

2006 SAP AG

25

Distribution Model

Setting up the automation in the master data

2006 SAP AG

26

The transactions we are interested in are MN04/MN05.

Enter output type Z005. In the following screen enter the PO type as Z002 or Z008 depending on the PUR teams requirement. Add the entries in the screen for each plant GBEPCS1080 for ex and maintain the entries as follows:

2006 SAP AG

27

When a purchase order is deleted or changed at the item level an idoc will be created but you will not be able to see the message in message control. This will be visible in the older transaction me22 instead of me22n. Enter the PO number then in the next screen click on the item- on the menu click on items ->> more functions messages. This should display the message details.

2006 SAP AG

28

Copyright
Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, and Informix are trademarks or registered trademarks of IBM Corporation in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves information purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty. These materials are provided as is without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages. Any software coding and/or code lines / strings (Code) included in this documentation are only examples and are not intended to be used in a productive system environment. The Code is only intended better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent.

2006 SAP AG

29

You might also like