Вы находитесь на странице: 1из 59

Integrating RFID Technology and ERP Systems

by

Janice Totleben

Abstract

Starting in the 1980s companies began to use RFID in their supply chain systems. This
practice has grown to the point where large companies like Wal-Mart and government
agencies like the Department of Defense have mandated the use of RFID. These mandates
have forced suppliers to use RFID technology and now the goal must be to uncover the
operational benefits of RFID. Organizations today are adopting Enterprise Resource
Planning (ERP) Systems that integrate business processes across department boundaries. It
is a necessity that RFID technology and ERP systems work together to gain the greatest
advantages. This project implements RFID technology into SAP which is the market leader
in ERP systems. Data from RFID tags will be used to input data into the supply chain faster
and with greater accuracy.

There have been inefficiencies in the supply chain which include stock-outs, pilferage, and
inventory obsolescence. With RFID and reengineered business processes the supply chain
problems should be greatly reduced because more accurate data will be available to managers
to make intelligent decisions. The mandates from Wal-Mart and Department of Defense
make tracking of cases and pallets a necessity. Further down the RFID horizon, there is a
vision of item level tracking where an item can be traced from the manufactured level to the
customer level and every stage in between.

The goal of this project is to implement a proof of concept of Integrating Radio Frequency
Identification and Enterprise Resource Planning. The ERP system is SAP which is the
market leader and the supply chain process is the Goods Receipt. Once this is implemented
the same concept will be used to integrate other supply chain processes thereby improving
supply chain return on investment.
List of Symbols

EPC : Electronic Product Code


RFID : Radio Frequency Identification
RF : Radio Frequency
ERP : Enterprise Resource Planning
DoD : Department of Defense
WSDL : Web Services Description Language
VAN : Value Added Network
EDI : Electronic Data Interchange
IDoc : Intermediate Document
ALE : Application Linking and Embedding
EDI : Electronic Data Interchange
BAPI : Business Application Programming Interface
RFC : Remote Function Call
SSCC : Serial Shipping Container Code
SGLN : Serialized Global Location Number
GID : General Identifier
SGTIN : Serialized Global Trade Item Number
dBi : Decibel Isotropic

ii
TABLE OF CONTENTS

1. INTRODUCTION ........................................................................................................................................1
1.1. SCOPE ..................................................................................................................................................1
1.2. BACKGROUND ......................................................................................................................................1
1.3. SUMMARY .......................................................................................................................................... 13
2. REQUIREMENTS ANALYSIS ................................................................................................................. 14
2.1. SYSTEM OVERVIEW ........................................................................................................................... 14
2.2. APPLICATION CONSTRAINTS AND DEPENDENCIES.............................................................................. 24
2.3. SPECIFIC REQUIREMENTS ................................................................................................................... 24
2.4. INTERFACES ....................................................................................................................................... 25
2.5. SUMMARY .......................................................................................................................................... 25
3. DESIGN PROCEDURE ............................................................................................................................. 26
3.1. TOP LEVEL DESIGN ............................................................................................................................ 26
3.2. PRODUCT FLOW ................................................................................................................................. 27
3.3. INTERFACE ......................................................................................................................................... 28
3.4. DESCRIPTION...................................................................................................................................... 29
3.5. INITIALIZATION .................................................................................................................................. 29
3.6. INTERFACE DESIGN ............................................................................................................................ 29
3.7. FUNCTIONAL DESIGN ......................................................................................................................... 30
3.8. SUMMARY .......................................................................................................................................... 31
4. FUNCTIONAL TESTING ......................................................................................................................... 32
4.1. FUNCTIONALITY TEST ........................................................................................................................ 34
4.2. SUMMARY .......................................................................................................................................... 36
5. SYSTEM INTEGRATION AND VALIDATION ..................................................................................... 37

6. CONCLUSIONS AND RECOMMENDATIONS...................................................................................... 38

7. REFERENCES ........................................................................................................................................... 39

8. APPENDIX ................................................................................................................................................. 40

iii
LIST OF FIGURES

Figure 1 RFID System Components……………………………………….2

Figure 2 General Structure of EPC Encodings…………………………….4

Figure 3 96-bit SGTIN Scheme…………………………………………….6

Figure 4 96-bit SGLN Scheme……………………………………………..7

Figure 5 96-bit SSCC Scheme……………………………………………...7

Figure 6 96-bit GRAI Scheme……………………………………………..8

Figure 7 96-bit GIAI Scheme……………………………………………...8

Figure 8 EPCglobal Architectural Framework…………………………….9

Figure 9 SAP.NET Configuration………….………………………………10

Figure 10 Process Flow and Data Flow in an Inbound EDI Process…........11

Figure 11 Top Level Software Requirements………………………..……..14

Figure 12 System Architecture for the ALR-9780 Reader……….………..15

Figure 13 Data Flow Diagram ……………………………………………26

Figure 14 Organizational Architectural Flow of Data…………………….27

Figure 15 Top-Level Functional Flow…………………………………….30

iv
LIST OF TABLES
Table 1 Tag Types…………………..……………………………………3

Table 2 Tag Frequencies………………………………..………………...3

Table 3 Electronic Product Code Headers………………………………5

Table 4 RFID Reader……………………………………………..........16

Table 5 RFID Reader External Circular Antenna………………………16

Table 6 RFID Reader External Linear Antenna………………………..17

Table 7 Post Goods Movement Specification for IDoc MBGMCR02..23

Table 8 Requirements………………………………………………….24

Table 9 Organizational Architectural Flow of Data…………………...28

Table 10 SAP Transactions Used For Functional Testing……………….33

Table 11 Results of Functionality Test…………………………………..35

Table 12 Summary of Testing Modules…………………………………36

v
1. INTRODUCTION

The most basic function of the Radio Frequency Identification (RFID) reader is to read tags.
The data from the tags must be integrated into the Enterprise Resource Planning (ERP)
systems that are running the businesses of today in order for this technology to be viable.
RFID technology must be integrated into the existing business processes for companies to
take advantage of its full potential. Through increased accuracy and the ability to gather
information at new points in the supply chain, RFID has the potential to reduce costs in
companies.

1.1. Scope
The scope of the project is to redesign the current business process for receiving. Data read
from the RFID tags will automatically generate a goods receipt transaction in SAP when
RFID tag data is read at the receiving dock. The project is a prototype only and will not
actually implement a field test. The project is being used in demonstrations to local industry
by the RFID Center of Excellence at Penn State Erie.

1.2. Background

A definition of RFID from SearchNetworking.com Definitions is as follows:


RFID (radio frequency identification) is a technology that incorporates the use of
electromagnetic or electrostatic coupling in the radio frequency (RF) portion of the
electromagnetic spectrum to uniquely identify an object, animal, or person. RFID is coming
into increasing use in industry as an alternative to the bar code. The advantage of RFID is
that it does not require direct contact or line-of-sight scanning. An RFID system consists of
three components: an antenna and transceiver (often combined into one reader) and a
transponder (the tag). The antenna uses radio frequency waves to transmit a signal that
activates the transponder. When activated, the tag transmits data back to the antenna. The
data is used to notify a programmable logic controller that an action should occur. The action
could be as simple as raising an access gate or as complicated as interfacing with a database
to carry out a monetary transaction. [1]

1
Figure 1 RFID System Components [2]

A reader interrogates tags for their ID information. A reader typically contains a transmitter,
a receiver, and a microprocessor. The reader also contains an antenna. The antenna
broadcasts the RF signals generated inside the reader’s transmitter into the immediate
environment. The antenna also receives responses from tags within range.

An RFID tag is composed of an RFID chip (also called an Application Specific Integrated
Circuit or ASIC), an antenna, and a power source. The RFID chip consists of modulation
circuitry, control circuitry, memory, and a processor.
Antenna: The antenna receives a signal from the reader and radiates a response back
to the reader. Whether the tag uses an induction coil or antenna is a function of the
frequency at which the tag is designed to operate.
o Low frequency (125 KHz) and high frequency (13.56 MHz) tags normally use
induction coils.
o Ultra high frequency (856-928MHz) and microwave frequency (2.56 GHz and
above and 5.8 GHz) tags have antennas.
Modulation circuitry: Modulation circuitry changes the signal received from the
reader to include data that will be transmitted back to the reader.
Control circuitry: The internal functions under the command of the processor are
controlled by control circuitry.
Processor: The processor interprets the signal received from the reader and controls
memory storage and retrieval.
Memory: The memory element serves as writable and non-writable data storage. [3,
pp. 10-11]

An RFID tag can be powered either by the RF signal from the reader or can have its own
internal power source (battery). The way the tag gets its power generally determines the
category of the tag. The following table gives a summary of the different tag types.

2
Tag Type Distance from Source Usage
Passive Up to 10 ft. (3.3 m) High volume, low cost, smaller distances
tracking. Used in retail, pharmaceutical.
Semi-passive Up to 30 ft. (10 m) Utilizes power source to power on board
sensors and larger memory. Used in retail
tracking.
Active Up to several miles Higher cost and capabilities. Can carry
depending on the design sensors and large memory. Used for
tracking high value goods over long
distances and in difficult environments.
Used by Department of Defense (DoD),
aviation, automotive.
Table 1 Tag Types [3, pp. 11-14]

There are four primary frequency bands for RFID tags. These are summarized in the
following table.

Frequency Name Frequency Distance(passive tags)


Low(LF) 125 KHz 1-36‖, typically around 18‖ (0.5 m)
High(HF) 13.56 MHz 1‖ to 30‖, typically under 36‖ (1m)
Ultra High(UHF) 865-868 MHz(Europe) Up to 30 ft. (10m)
902-928 MHz (USA)
433 MHz (active tags)
Microwave(µW) 2.56 GHz Typically 1-3 ft. (0.3 – 1 m)
5.8 GHz
Table 2 Tag Frequencies [3, p. 17]

Companies are being given mandates by their partners that they must use RFID technology
and the challenge is to use this new technology to improve productivity in the processes that
are already in place in existing companies. This means that this new RFID technology must
interface with either stand alone IT systems or commercial enterprise systems. A new area of
software is being developed to handle these new requirements.

"Many suppliers have found themselves in a position in which — in the short term — they
must implement RFID to comply with high-profile mandates," says Forrester Research Vice
President and Research Director Sharyn Leaver. "In order to gain long-term benefits, these
suppliers need to intelligently incorporate the data they are collecting to make improvements
to their overall business processes.‖[4]

RFID technology is in its infancy and went through an evolution of changing standards.
With the announced ratification of the royalty-free EPCglobal UHF (ultra-high-frequency)
Generation 2 candidate specification it appears that standards have been set. Companies are
now confident that solutions can be built on standard technology.

3
The Class 1 Generation 2 UHF Air Interface Protocol Standard Referred to as ―Gen 2" EPC
standard is an EPCglobal air interface standard for passive UHF (Frequency range between
865 to 960 UHF) that defines the physical and logical requirements for a passive-backscatter,
Interrogator-talks-first (ITF), radio-frequency identification (RFID) system. Gen 2
EPCglobal air interface standards were ratified in December 2004 as an approved ISO 18006
part C standard. [5]

EPCglobal is a non-profit organization set up by the Uniform Code Council and EAN
International and is made up of chapters in different countries and regions. EPCglobal is
leading the development of industry-driven standards for EPC to support the use of RFID.

EPC Global has issued an EPCglobal Tag Data Standards. The general structure of EPC Tag
Encodings on a tag is a string of bits (i.e. a binary representation) consisting of a fixed length
(8-bits) header followed by a series of numeric fields whose overall length, structure, and
functions are completely determined by the header value.

Figure 2 General Structure of EPC Encodings [6]

The header is summarized in following table.

Header Value Header Encoding Encoding Scheme


(binary) Value Length
(hex) (bits)

0000 0000 00 NA Unprogrammed Tag

0000 0001 01 NA Reserved for Future Use


0000 001x 02,03 NA Reserved for Future Use
0000 01xx 04,05 NA Reserved for Future Use
06,07 NA Reserved for Future Use

0000 1000 08 64 Reserved until 64bit Sunset


<SSCC-64>

0000 1001 09 64 Reserved until 64bit Sunset


<SGLN-64>
0000 1010 0A 64 Reserved until 64bit Sunset
<GRAI-64>

0000 1100 0C Reserved until 64 bit Sunset


to to Due to 64 bit encoding rule in

4
0000 1111 0F Gen 1

0001 0000 10 NA Reserved for Future Use


to to
0010 1110 2E NA

0010 1111 2F 96 DoD-96


0011 0000 30 96 SGTIN-96
0011 0001 31 96 SSCC-96
0011 0010 32 96 SGLN-96
0011 0011 33 96 GRAI-96
0011 0100 34 96 GIAI-96
0011 0101 35 96 GID-96
0011 0110 36 198 SGTIN-198
0011 0111 37 170 GRAI-170
0011 1000 38 202 GIAI-202
0011 1001 39 195 SGLN-195
0011 1010 3A Reserved for future Header
to to values
0011 1111 3F

0100 0000 40 Reserved until 64 bit Sunset


to to
0111 1111 7F

1000 0000 80 64 Reserved until 64 bit Sunset


to to <SGTIN-64>
1011 1111 BF (64 header values)

1100 0000 C0 Reserved until 64 bit Sunset


to to
1100 1101 CD

1100 1110 CE 64 Reserved until 64 bit Sunset


<DoD-64>
1100 1111 CF Reserved until 64 bit Sunset
to to
1111 1110 FE

1111 1111 FF NA Reserved for future headers


longer than 8 bits

Table 3 Electronic Product Code Headers [6]

5
The EPCglobal Tag Data Standards defines one general identity type. The General Identifier
(GID-96) is independent of any known, existing specifications of identity types. The General
Identifier is defined for a 96-bit EPC. The General Identifier (GID-96) is composed of three
fields:
The General Manager Number – identifies an organizational entity that is responsible
for maintaining the numbers in subsequent fields – Object Class and Serial Number.
The General Manager Number is 28 bits.
The Object Class – is used by an EPC managing entity to identify a class or ―type‖ of
things. The Object Class is 24 bits.
The Serial Number Code – is unique within each object class. The Serial Number
Code is 36 bits.

The EPCglobal Tag Data Standards defines five EPC identity types:
Serialized Global Trade Item Number (SGTIN)
o Header, which is 8 bits and is common for all SGTIN-96 tags.
o Filter, which is 3 bits and specifies if the tagged object is an item, case or
pallet.
o Partition, which is 3 bits and indicates how the subsequent fields are divided
to get the correct data for each.
o Company Prefix, which is 20-40 bits (depending on the Partition) and contains
the company’s EAN.UCC Company Prefix.
o Item Reference, which is 24-4 bits (depending on the Partition) and contains
the item’s GTIN item reference number.
o Serial Number, which is 38 bits and contains the item’s unique serial number.

Figure 3 96-bit SGTIN Scheme [7]

6
Serialized Global Location Number (SGLN)
o Header, which is 8 bits and is common for all SGLN-96 tags.
o Filter, which is 3 bits.
o Partition, which is 3 bits and indicates how the subsequent fields are divided
to get the correct data for each.
o Company Prefix, which is 20-40 bits (depending on the Partition) and contains
the company’s EAN.UCC Company Prefix.
o Location Reference, which is 21-1 bits (depending on the Partition) .
o Serial Number, which is 41 bits and is not used.

Figure 4 96-bit SGLN Scheme [7]

Serial Shipping Container Code (SSCC)


o Header, which is 8 bits and is common for all SSCC-96 tags.
o Filter, which is 3 bits.
o Partition, which is 3 bits and indicates how the subsequent fields are divided
to get the correct data for each.
o Company Prefix, which is 20-40 bits (depending on the Partition) and contains
the company’s EAN.UCC Company Prefix.
o Serial Reference, which is 37-17 bits.
o Unallocated

Figure 5 96-bit SSCC Scheme [7]

7
Global Returnable Asset Identifier (GRAI)

Header Filter Partition Company Asset Serial


Value Prefix Type Number
GRAI-96 8 3 3 20-40 24-4 38
0011 999,999- 999,999- 247,877,906,943
0011 999,999,999,999 0
(Binary
Value)

Figure 6 96-bit GRAI Scheme [6]

Global Individual Asset Identifier (GIAI)

Figure 7 96-bit GIAI Scheme [6]

EPCglobal has defined and described the EPCglobal Architectural Framework. The
EPCglobal Architectural Framework is a collection of interrelated standards for hardware,
software, and data interfaces, together with core services that are operated by EPCglobal and
its delegates, all in service of a common goal of enhancing the supply chain through the use
of EPCs. The EPCglobal Architectural Framework is shown in the following diagram.

8
Figure 8 EPCglobal Architectural Framework [8]

SAP R/2 was a mainframe based business application software suite that was very successful
in the 1980s and early 1990s. It was particularly popular with large multinational European
companies who required soft-real-time business applications, with multi-currency and multi-
language capabilities built in. With the advent of distributed client-server computing SAP
AG brought out a client-server version of the software called SAP R/3 that was manageable
on multiple platforms and operating systems, such as Windows or UNIX since 1999, which
opened up SAP to a whole new customer base. SAP R/3 was officially launched on 6 July
1992. SAP came to dominate the large business applications market over the next 10 years.
[9]

9
The project uses a Microsoft .NET project so it needs to integrate SAP and .NET. In order
to accomplish this task the software will use a .NET integrator specifically SAP.NET. The
SAP client allows your .NET code to execute SAP functions that are remote-enabled (RFC).
In the SAP client solution, the SAP system is the server and the .NET application is the client
that interacts with the RFC. When you generate an SAP client application, a sapwsdl file is
added to your Visual Studio .NET project. This sapwsdl file will contain all the metadata
retrieved from the SAP system, when you later add functions to it. The sapwsdl file in
coordination with a custom tool in Visual Studio creates several C# classes needed to
communicate with the SAP system via either RFC or SOAP. There is one class for the proxy
itself, one for each export parameter and two for each Table parameter in your RFC. [10]

Microsoft.Net
Proxy SAP Technology
Class
Visual Studio.Net Generator
Interface
Repository

VB C# …

Application Web .Net


Services Connector RFC Layer
Runtime

Net Connector Component


SOAP Layer
Generated

SAP.Net
Common Language Connector
Runtime

Figure 9 SAP.NET Configuration [10]

An understanding of ALE(Application Linking and Embedding), EDI( Electronic Data


Interchange), and IDoc technologies for SAP is essential to completion of this project.

10
SAP Database
5 Repository

EDI-Enabled
Application
Application Document

Posting IDoc

Program

Inbound 3 1
Trigger
Program EDI VAN
Subsystem
2

IDoc File EDI


Document

Process No Process Description


1 The Electronic Data Interchange (EDI) transmission is received. EDI documents are received
from a business partner via the Value Added Network (VAN).
2 The EDI document is converted into an Intermediate Document (IDoc).

3 The IDoc is transferred to the SAP layer.

4 The application document is created.

5 The application document can be viewed. The application document created via EDI is the
same as any document created manually in the system
Figure 10 Process Flow and Data Flow in an Inbound EDI Process [11, pp. 29-30]

11
The data read from the RFID tags at a receiving dock will be used to automatically interface
with the SAP system. The system will need to create an inbound EDI process. This means
that an IDoc must be created that will be used in the EDI interface. Various configuration
settings must be set up for the IDoc to be processed correctly. The inbound processes uses
the following components to post an application document from an IDoc: IDoc type, port
definition, posting programs, service programs, and configuration tables. These settings will
be addressed in the project.

12
1.3. Summary

The goal of the project is to integrate RFID technology and ERP systems. The RFID product
used in this project is Alien Technology RFID Electronic Product Code (EPC) Class 1 Gen 2
tags and Alien Technology high-performance, flexible RFID readers-software upgradeable
to future protocols. The ERP system is SAP R/3 which is the market leader. The project
demonstrates that RFID tags can be read at a receiving dock and the successful read will
automatically complete the receiving business process in an ERP system. The success of this
project will demonstrate the integration of RFID technology and ERP. The project is a
prototype only.

13
2. REQUIREMENTS ANALYSIS

2.1. System Overview

2.1.1 Software Overview

Advance Shipping Notice


Microsoft SQL 2005 RFID Tag
Alien

ASP.NET 2.0
Application

SAP.NET Connector

Enterprise Resource Planning System


SAP R/3

Figure 11 Top Level Software Requirements

Penn State University is in the SAP University Alliance. The SAP University Alliances
program is a global endeavor to provide university faculty members with the tools and
resources necessary to teach students how technology can enable integrated business
processes and strategic thinking -- and gives students the skills to add immediate value to the
marketplace. The SAP system is being used as part of the Penn State/SAP University
alliance.

14
2.1.2 Hardware Overview

The project is being completed in the RFID Center of Excellence located at Penn State Erie
in Erie, Pennsylvania. The Center uses Alien Technology RFID Electronic Product Code
(EPC) Class 1 and Class 1 Gen 2 tags. The Center also uses Alien Technology high-
performance, flexible RFID readers-software upgradeable to future protocols. The Alien
RFID Reader can be programmatically controlled using a number of systems and languages.
Alien has developed a .NET API which is contained within AlienRFID.dll and provides type
structures and classes that constitute discrete functional groups for controlling various
aspects of the reader.

The system architecture for the Alien Reader is provided in the following figure.

Host RF Receiver A0
Digital
Communication Control
Circuitry Antenna A1
Interface Switch

A2

RF Source RF
Modulator

Figure 12 System Architecture for the ALR-9780 Reader [12, p. 6]

15
The specifications for key components of the Alien RFID Reader system are provided in the
tables below.
Name Alien Mlti-Port General Purpose RFID
Reader
Model Number ALR9780
Architecture Point-to-multipoint reader network
Frequency 902.6 MHz – 927.4 MHz
Hopping Channels 63
Channel Spacing 400 KHz
Channel Dwell Time < 0.4 Seconds
RF Transmitter < 30 dBm (abbreviation for the power ratio
in decibel(dB) of the measured power
referenced to one milliwatt (mW))
at the end of 15 ft LMR-195 cable
Modulation Method On Off Keying(OOK)
20 db Modulation Bandwidth < 400 KHz
RF Receiver 2 Channels
Power Consumption 25 Watts (120 VAC a 500 mW)
Communications Interface RS-232, Lan TCPI/IP
Inputs/Outputs 2 or 4 coax antenna 8 logic I/O, com port,
LAN, power
Dimensions (L) 19 cm (7.5 in) x (W) 28 cm (11 in) x (D)
5 cm(2 in)
Weight Approximately 1.8 kg(4lb)

Operating Temperature 0ºC to 50º C(32 ºF to 122º F)

Table 4 RFID Reader [12, p. 3]

3 dB Beamwidth E-plane: 65 degrees H-plane: 65 degrees


Frequency 902-928 MHz
Gain(dBi) 5.73 Decibel Isotropic (dBi)
Polarization Circular
RF Connector 15 ft LMR-195 with Reverse-Polarity TNC
VSWR 1.5:1
Dimensions (cm) 22x27x4 (in)8.5x10.5x1.65
Weight .57 kg 1.25 lb

Table 5 RFID Reader External Circular Antenna [12, p. 3]

16
3 dB Beamwidth E-plane: 40 degrees
Frequency 902-928 MHz
Gain(dBi) 6.0 dBi
Polarization Linear
RF Connector 15 ft LMR-195 with Reverse-Polarity TNC
VSWR 1.5:1
Dimensions (cm) 19.5x28x4 (in)7.75x11.25x1.65
Weight .57 kg 1.25 lb

Table 6 RFID Reader External Linear Antenna [12, p.4]

17
2.1.3 Physical Overview

An Intermediate Document (IDoc) is a container that is used to exchange information


between the systems. In an inbound ALE or EDI process, an IDoc serves as input to
create an application document. In the SAP system, IDocs are stored in the database
tables. They can be used for SAP-to-SAP and SAP to non-SAP process
communication as long as the participating processes can understand the syntax and
semantics of the data. IDocs are based on EDI standards, ANSI ASCX12 and
EDIFACT, but are closer to EDIFACT standards. IDocs can be viewed in a text
editor and do not contain any binary data. [11]

The IDoc being used is MBGMCR02 which is the Post Goods Movement. The
following table shows the documentation for the particular BAPI (Business
Application Programming Interface) used to execute the IDoc.

18
Post Goods Movement
Functionality
You can use this method to create a material document for a goods movement.
You can only create one material document each time you call up the method.
You can use a simulation function before posting the goods movement to check how the data
is updated in the database. The standard system is configured so that the goods movement is
posted immediately without simulating beforehand.
Ensure that you transfer the data in the same way as it is run in the database, for example,
Material number 18-figure with leading zeros
Batches with uppercase letters
Note that for all transactions/events listed below, the posting date is entered in the header
data of the material document. In the BAPI2017_GM_HEAD_01 interface, fill the
PSTNG_DATE (import structure GOODSMVT_HEADER) field.
Notes
Authorization check
In the MM Inventory Management component, the method does not execute any
authorization checks.
Note that during a posting of a goods movement, depending on the business transaction of
the system, authorization objects of other applications can also be checked.

Transfer
The following information about the material document that is to be created is transferred to
the method:
a structure with header data
a structure with the code for the movement
a table with the item data
a table with the serial numbers
The posting is carried out in the SAP R/3 via the MB_CREATE_GOODS_MOVEMENT
function module.

Confirmations
Messages are returned in the Return parameter. The parameter documentation shows the
return codes and their meanings.
Further Information
The method can only carry out your function if no error messages were generated in the
Return table. This is the case if the header data and all the items were processed successfully.
Transaction control is not implemented. The calling program therefore has to execute the

19
Commit Work itself after this method has been successfully called (in other words, if no
errors were reported in the Return parameter).

Which fields have to be filled during the various transactions/ events?


The following sample scenarios demonstrate which fields have to be filled for which
business transactions/events (code).
There are the following types of transactions/events:

1. GM_Code 01: Goods receipt for purchase order


2. GM_Code 02: Goods receipt for production order
3. GM_Code 03: Goods issue
4. GM_Code 04: Transfer posting
5. GM_Code 05: Other goods receipts
6. GM_Code 06: Reversal of goods movements
7. GM_Code 07: Subsequent adjustment to a subcontract order

Entering the movement indicator


Depending on the transaction, you must enter the following in the movement indicator:
GM_Code 01 (Goods receipt for purchase order): B
GM_Code 02 (Goods receipt for production order): F
For all other transactions, you leave the field blank.
For 1: GM_Code 01: Goods receipt for purchase order
Purchase order known
The following fields have to be filled:
Purchase order
Purchase order item
Movement type
Movement indicator
Quantity in unit of entry
ISO code unit of measurement for unit of entry or
quantity proposal
The following fields may have to be filled in some cases (incomplete listing):
Shelf life expiration date (if it has been configured like this in the system)
Reason for movement (if it has been configured like this in the system)
Batch (if the material is handled in batches and batch numbers are not assigned
automatically)
Storage location (if a storage location has not been specified in the purchase order item)

20
The following fields can be filled (incomplete listing):
Stock type
Item text
Unloading point
Delivery completed indicator
You cannot fill the following fields (incomplete listing):
Account assignment fields (account assignment is adopted from the purchase order)
Reservation
Receiving/issuing material
Receiving/issuing plant
Receiving/issuing storage location
In the case of a purchase order item with the "subcontracting" item category, only the GR
item in the interface is to be transferred. The system automatically determines GI items.
Purchase order unknown: Shipping notification known
The following fields have to be filled:
Delivery
Delivery item
Movement type
Other fields, such as those under "Purchase order known". The system determines the
relevant purchase order item via the delivery/delivery item.
Purchase order unknown: Purchase order should be created automatically
The following fields have to be filled:
Material number
Plant
Storage location
Vendor
Movement type
Movement indicator
Quantity in unit of entry
ISO code unit of measurement for unit of entry
The following fields may have to be filled in some cases (incomplete listing):
Shelf life expiration date (if it has been configured like this in the system)
Reason for movement (if it has been configured like this in the system)
Batch (if the material is handled in batches and batches are not assigned automatically)
The following fields can be filled (incomplete listing):
Stock type
Item text
Unloading point

21
You cannot fill the following fields (incomplete listing):
Account assignment fields (automatic creation of purchase order items with account
assignment is not supported)
Reservation
Receiving/issuing material
Receiving/issuing plant
Receiving/issuing storage location
Purchase order unknown: A purchase order should not be created
The following fields have to be filled:
Material number
Plant
Storage location
Vendor
Movement type
Movement indicator
Quantity in unit of entry
ISO code unit of measurement for unit of entry
The following fields may have to be filled in some cases (incomplete listing):
Shelf life expiration date (if it has been configured like this)
Reason for movement (if it has been configured like this)
Batch (if the material is handled in batches and automatic assignment of batch numbers is
not set)
The following fields can be filled (incomplete listing):
Special stock indicator
Item text
Unloading point
Goods recipient
The following fields cannot be filled (incomplete listing):
Account assignment fields (automatic creation of purchase order items with account
assignment is not supported)
Reservation
Receiving/issuing material
Receiving/issuing plant
Receiving/issuing storage location
Receiving/issuing batch
The input combinations listed above for the GM_CODE 01 can be combined within an input
table so that they can be posted in a material document. Items can also be posted for different
purchase orders, provided that all the purchase orders refer to the same vendor.
Transfer of subcontracting components

22
During the posting of the ordered material of a subcontract order with movement type 101,
for the transfer of the subcontracting components, the filled unique identification of the
document line (LINE_ID) is also required.

The following fields have to be filled for the components:


Unique identification of the document line
Identification of the immediately superior line
Material number
Plant
Storage location
Quantity in unit of entry
The following fields can be filled for the components:
All other fields in the method that are included in this list.
The following fields cannot be filled for the components:
All fields that are not included in the list above. The movement indicator must be initial.
Additional fields in goods-receipt-based invoice verification
When you post a goods receipt to purchase order with movement type 102, an issue with
reference to a previously posted goods issue, the following fields must also be transferred:
REF_DOC_IT (LFPOS): Item of a reference document
REF_DOC (LFBNR): Document number of a reference document
REF_DOC_YR (LFBJA): Fiscal year of a reference document
Only when you transfer these fields is it guaranteed that the reference to the original goods
movement stay the same.

Table 7 Post Goods Movement Specification for IDoc MBGMCR02 [13]

23
2.2. Application Constraints and Dependencies

The constraints and dependencies in the design of the Integration of RFID and SAP are
The AlienRFID.dll is the Reader software used
Microsoft SQL Server 2005 is the Database Management System used
SAP R/3 is the Enterprise Resource Planning System used
SAP.Net Integrator is a connector that plugs into Visual Studio that allows
.Net applications to access SAP R/3

2.3. Specific Requirements

The following section defines the requirements gathered for the Integration of RFID and
SAP.
RQMT# Requirement Priority Effort Risk
RFIDSAP001 The Alien Critical High High
hardware must
be configured to
read properly
RFIDSAP002 Login Correctly Critical Low Low
RFIDSAP003 Valid User Critical Low Low
RFIDSAP004 The 96-bit Critical High High
RFID tag will
be read using
Alien RFID
readers.
RFIDSAP005 Tag Value must Critical Low Low
be found on the
Advanced Ship
Notice Database
RFIDSAP006 Create the Critical High High
IDOC
MBGMCR02
RFIDSAP007 Configure SAP Critical High High
Partner Profile
RFIDSAP008 Configure SAP Critical High High
Port Profile
RFIDSAP009 Connect to SAP Critical High High
RFIDSAP010 Login to SAP Critical Low High
RFIDSAP011 Send the IDOC Critical Medium High
to SAP
RFIDSAP012 Validate that the Critical Medium High
IDOC was sent
to SAP correctly

Table 8 Requirements

24
The project is sequential in nature so each of the requirements needs to be completed before
the next step is executed. The Priority of each requirement is Critical because of the
sequential execution of the steps.

The Effort of each requirement is categorized as High, Medium, or Low. The High value
indicates that a great deal of time is required to successfully complete this requirement. A
time requirement of 2-4 weeks indicates a High Effort. A Low value indicates that the time
required to meet this requirement is minimal. The effort to complete these tasks is generally
less than a day. The Medium value indicates that the time involved to complete these tasks is
generally more than a day but less than 2 weeks.

The Risk factor is either High or Low. A high risk indicates that the requirement must be
completed successfully and that no error or alternate solution can be tolerated. A low risk
factor indicates that an alternate solution is available and can be used.

2.4. Interfaces

The project is implemented using a Visual Studio 2003 .Net application. The language used
is C#. The application interfaces with the AlienRFID.dll. The application accesses the
Microsoft SQL 2005 database to get Advanced Ship Notice information. The interface
between the Microsoft application and SAP is accomplished by the SAP Connector for .NET.

2.5. Summary

The driving goal for this project is to create a prototype for integrating RFID technology with
existing systems specifically for an SAP enterprise system. A modular approach was used in
addressing the various requirements in this project.
Read and be able to get the data from the RFID tags
Understand and implement the SAP technology for a goods receipt transaction
Understand and implement inbound SAP EDI/ALE technology
Connect to SAP from a Microsoft project application using SAP.NET
connector
Generate a Remote Function Call(RFC) for a goods receipt transaction in SAP

Each step in the approach required extensive research and trial and error in order to
accomplish the task.

25
3. DESIGN PROCEDURE

The following section discusses the design procedure used in the project. Data Flow
Diagrams and Process Diagrams are used. The design of the project integrates a variety
of technologies.

3.1. Top Level Design

Mat erialOrdered

RFI DTag
Mat erialToShip

2
RFI DTagForMaterial

SupplierMakesMateria

POSentToSupplier

PurchaseOrder ASNRecord Mat erialAndRFIDTag

Adv ancedShjpping
Not ice

CreatePO

1
ASNRecordReceived
ComapnyOrdersMaterial

3
Company
Receives
Mat erial
POOnSAP +
IDocCreat e

IDoc
SAP

Figure 13 Data Flow Diagram

26
3.2. Product Flow
1.
Purchasing Purchase Order

PO: 4500015241
Company A RFID TAG Item:00001
A Material:DPC1020
OrderQuantity:100

2.

Supplier B

3.

Material
DPC1020

Advanced Ship
Notice RFID TAG
TagValue: 3008
TagValue: 3008
33B2 DDD9 0140 33B2 DDD9
2805 0000 0140 2805 0000
PO: 4500015241
Item:00001
Material:DPC1020

Receiving 4.

Company A

SAP
PO: 4500015241
Item:00001
5. Material:DPC1020
OrderQuantity:100
IDOC ReceivedToDate:0000000001
MBGMCR
Receipt to Stock

Figure 14 Organizational Architectural Flow of Data

27
1. Company A Sends Purchase Order to Supplier B
PO: 4500015241 Item: 00001 Material:DPC1020 Order Quantity: 100
2. Supplier B Produces Material and Ships the Material to Company A. Supplier B
slaps an RFID tag on Material; Tag No: 3008 33B2 DDD9 0140 2805 0000; Supplier B
Ships the Material to Company A.
3. Supplier B creates an Advanced Ship Notice record which indicates that Tag No:
3008 33B2 DDD9 0140 2805 0000 is for PO: 4500015241
4. Company A receives the Material along with the Advanced Ship Notice record
5. Company A reads the RFID tag and a program runs which uses this tag data to send
a Remote Function Call to SAP to generate the SAP Goods Receipt Transaction in
SAP. As a result the SAP system now reflects
PO: 4500015241 Item: 00001 Material:DPC1020 Order Quantity: 100 Received to Date:00001

Table 9 Organizational Architectural Flow of Data

3.3. Interface

There is no user interface required in the project. Alien RFID Reader API will be used to
expose the objects needed to interact with the Readers. The SAP.NET connector will
create the proxy classes to enable communication between the application and SAP. The
SAP R/3 ALE, EDI & IDoc technology will be used to communicate with the SAP
business processes.

28
3.4. Description

3.5. Initialization
This section defines the initialization phase of the project. Pre requisites etc…

3.6. Interface Design

Not interface design as discussed previously.

29
3.7. Functional Design

Figure 15 Top-Level Functional Flow

30
3.8. Summary
The design process includes extensive research. Each piece of the process required a
working knowledge of a different technology.

The RFID read tag process required a working knowledge of the Alien.dll API. The methods
for connecting to the Alien Reader and grabbing the data from the tag need to be understood.
A clear understanding of SAP business transactions is needed and a special knowledge of a
Goods Receipt transaction in SAP. In addition, the ALE, EDI, and IDoc technologies for
SAP were essential in completing this project. The book ALE, EDI & IDoc Technologies for
SAP, 2nd Edition by Arvind Nagpal and John Pitlak served as an invaluable tool in my
understanding of this technology. Countless hours of trial and error were experienced trying
to get the SAP R/3 system set up to accept a Goods Receipt transaction from an RFC call.
Finally, there needs to be a communication between the .NET application and the SAP
system. The SAP.NET connector served this purpose and considerable amount of time was
spent understanding how to use this software.

31
4. FUNCTIONAL TESTING

The following table describes the SAP transactions that are needed to perform Functional
Testing. These transactions are essential in the EDI interface. These transactions are used
to set up various configurations needed in the interface and also allows for testing the
setup.
SAP
Used to Setup Transaction
IDoc No. Description
Every IDoc created in the sytem is assined a
Number Ranges 16-digit number that uniquely identifies it in the
for Idocs OYSN sytem.

The port defines the technical characteristics of


the connection between SAP and the
subsystem. It also defines the medium in which
data is exchanged between the two systems. In
the EDI process, IDocs are transferred to
external system via ports. The EDI process
The Port Definition WE21 uses the file port.

A partner profile is defined for every business


partner with whom you exchange business
documents. A partner profile specifies the
various characteristics of data that you
exchange with a business partner, the mode of
operation and an organization or person
responsible for handling errors for that business
The Partner Profile WE20 partner.

Posting programs are implemented in the


system as function modules. A posting
program exists for each message type. A
process code is assigned to each posting
Posting Programs WE42 program.

Testing the EDI


Interface

SE38 or
from the
menus of
the initial
partner
Testing the Partner profile The output is a color-coded report that shows
Profile screen the details of any problems that were found.

32
Select your port definition, and then click the
Outbound File button to view the directory
location where IDoc files will be stored. Click
the Check button on this screen to test
Testing the Port accessibility to the directory. If the check is
Definition WE21 successful, the port definition is correct.

One of the major components for the inbound


process is the IDoc itself. If a subsystem is not
Starting the available, you need a way to create an IDoc
Inbound Process and start the inbound process.

This tool is a two-step process. In the first step,


you create an outbound IDoc. You then modify
the IDoc data as needed. In the second step,
you process your newly created IDoc. You can
call the inbound process using the normal path
by clicking the Standard Inbound button, in
Start the Inbound which case the process goes through the
Process with the checks as if it had been sent in by the
Inbound Test Tool WE19 subsystem.

Verifying the
creation of Will show the control records, data records and
Successful IDocs WE05 status records.
Status Code 53-Application document
posted. SUCCESS

Table 10 SAP Transactions Used For Functional Testing

33
4.1. Functionality Test

Transactions and Optimal Functional


Instructions Used Testing Testing
Functional Testing for Testing Results Results

Result Should be Successful


RFID Testing a valid TagValue
Connect InitOnNetwork
User:xxxxx
LogIn Password:xxxxx
TagValue TagList
Substring(TagValue)
Disconnect

Result Should be Successful


Valid PO, PO
AdvanceShipNotice Item, Vendor,
Database Material, Quantity
Connect
SQL Command
Read
Get PO Data

Result should be Successful


valid EDI
SAP Testing Configuration

The Port Definition WE21

The Partner Profile WE20

Posting Programs WE42

SE38 or from the


menus of the initial
Testing the Partner Profile partner profile screen

Testing the Port Definition WE21

Start the Inbound Process with


the Inbound Test Tool WE19

34
Result should be Successful
a syntactically
IDoc Creation correct IDoc
Valid fields in IDoc
MBGMCR02
WE05

Result should be Successful


SAP.NET Testing an IDoc in SAP
Connect to SAP
IDoc Sender

Verifying the creation of


Successful IDocs WE05

Result should be Successful


the RECEIPT TO
STOCK field
should be
SAP Receipt incremented

Table 11 Results of Functionality Test

35
4.2. Summary

The testing is done in a modular fashion. The following table shows the modules that are
tested and the results. Each module is thoroughly tested and functional before the next
module is attempted.

Module Result
Read and be able to get the data from the RFID tag Passed
Run a Goods Receipt Transaction in SAP Passed
Set up a Partner in SAP Passed
Set up a Port in SAP Passed
Create the MBGMCR IDOC in SAP Passed
Connect to SAP from Microsoft project using Passed
SAP.NET connector
Generate a Remote Function Call Passed
Receipt to Stock Transaction run in SAP Passed

Table 12 Summary of Testing Modules

The results indicate that there is a successful completion to the project. The Receipt to Stock
Transaction is run in SAP as a result of a receiving dock read of an RFID tag on an incoming
shipment.

36
5. SYSTEM INTEGRATION AND VALIDATION

37
6. CONCLUSIONS AND RECOMMENDATIONS

The successful implementation of this project allows for tighter integration of RFID
technology into business processes in SAP. The technology developed in this project
has already been used to develop the automatic Purchase Order transaction in SAP.

The RFID Center for Excellence located at Penn State Erie in Erie, Pennsylvania is
pioneering RFID technology in the area. The software developed in this project is
being integrated into the industry demonstrations that are taking place at the Center
showcasing RFID technology and ERP integration. The Center is using the technology
developed in this project to extend RFID into more SAP Business Processes. Currently,
there is a project in the RFID Center to use this technology to integrate RFID into a
Goods Movement Business Process in SAP.

38
7. REFERENCES

[1] SearchNetworking.com [Accessed Jan 2007].


[2] Alien Technology, ―RFID Primer‖, Alien Technology Corporation, 2004.
[3] CompTIA RFID +, OTA Training, 2006.
[4] Forrester Research press release, August 30, 2004
http://retailindustry.about.com/b/a/109184.htm
[5] EPC Global Inc., ―EPC Radio-Frequncy Identity Protocols Class-1 Generation-2
UHF RFID Protocol for Communications at 860 MHz – 960 MHz‖, Version 1.0.9,
January 2005
[6] EPC Global Inc., ―EPCglobal Tag Data Standards Version 1.3‖, March 8, 2006
[7] EPC Global, ―RFID and EPC Essentials‖, Version 01,
http://www.epcglobalinc.org/what/cookbook/chapter1/002--
RFID_EPC_Essentials_v1.pdf
[8] EPC Global Inc., ―EPCglobal Architecture Framework, Version 1.0‖ July 2005
[9] http://en.wikipedia.org/wiki/SAP_R/3 [Accessed Jan 2007]
[10] http://www.microsoft-sap.com/overview_sap_connector.html
[11] Nagpal, Pitlak. ―ALE, EDI, & IDoc Technologies fro SAP.‖ Prima Tech
Publishers, 2001.
[12] Alien Hardware setup Guide, ALR-9780 Nov 2004
[13] SAP BAPI Documentation

39
8. APPENDIX

C# Program Code for Integration of RFID and SAP

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SAP.Connector;
using SAP.Connector.Rfc;
using SAPConnectorProxy2;
using nsAlienRFID;
using System.IO;

namespace Kanban
{
public partial class frmKanban : Form
{
public frmKanban()
{
InitializeComponent();
}

#region Variables
//Delegates for cross-threading
private delegate void displayMessageDlgt(string msg);
private delegate void addNewReaderDlgt(string address);
//create sap proxy
protected SAP.Connector.Destination destination1;
//Declare Reader
public nsAlienRFID.clsReader mReader2 = new
nsAlienRFID.clsReader();
public nsAlienRFID.clsReader mReader = new
nsAlienRFID.clsReader();
//Declare Server
public CAlienServer mServer = null;
//values to use in idoc from Advance Ship Notice database that are
used to receive
static string g_idocPO;
static string g_idocContract;
static string g_idocMaterial;
static string g_idocQty;
//Values that are parsed from the tag value and entered into PO
idoc.
string gMaterial;
string gContract;
string gQty;
string gPO;
#endregion

private void btnRun_Click(object sender, EventArgs e)


{

40
RFID_PO();
}

private void btnStartRcpt_Click(object sender, EventArgs e)


{
RFID_RCPT();
}

private void btnStop_Click(object sender, EventArgs e)


{
//Turn off readers
if (mReader2.IsConnected)
{

mReader2.ClearTagList();
mReader2.ClearCommBuffer();
mReader2.AutoMode = "OFF";
mReader2.Disconnect();
}

if (mReader.IsConnected)
{
mReader.ClearTagList();
mReader.ClearCommBuffer();
mReader.AutoMode = "OFF";
mReader.Disconnect();
}
//Stop server from listening
mServer.StopListening();

lblMessage.Text = "Demo Stopped";


}

public void RFID_PO()


{

//************************************************************************
**************
// This function connects to the Kanban Reader and configures
it for Listening for Tags.

//************************************************************************
**************

try
{
//Declare IP addresses for both Readers
string IPAddress = cboKanbanIP.SelectedItem.ToString();

//Connect to both Readers


mReader2.InitOnNetwork(IPAddress, 23);
mReader2.Connect();

//Login to both Readers


if (mReader2.IsConnected)
{
mReader2.Login(txtUser1.Text, txtPass1.Text);

41
lblMessage.Text = "Kanban Reader Connected!";
}
else
{
mReader2.Disconnect();
lblMessage.Text = "Kanban Reader Not Connected!";
}

//************************************************************************
******

//************************************************************************
******
//Configure the Kanban reader for listening mode and
proper settings for demo.

#region Settings
if (mReader2.AutoMode == "ON")
{
mReader2.AutoMode = "OFF";
}
mReader2.ClearTagList();
mReader2.NotifyMode = "OFF";
mReader2.AcquireMode = "Inventory";
//Persist Time of -1 doesn't seem to work with the
9780 readers, so set to 86400 (roughly 24 hours)
mReader2.PersistTime = "86400";
//Grabbing IP address of the server computer (the
computer the App is running on)
string nAddress = (mServer.IPAddressString).Trim() +
":" + Convert.ToString(mServer.Port).Trim();
mReader2.NotifyAddress = nAddress;
mReader2.NotifyTime = "0";
//Tagtype 16 is gen2 and 7 is gen1
mReader2.TagType = 16;
mReader2.SendReceive("RFAttenuation = 60", false);
mReader2.TagListAntennaCombine = "ON";
//mReader2.TagListFormat = "XML";
mReader2.NotifyFormat = "Text";
mReader2.AntennaSequence = "0,1";
//Only Send a notification to the server when a new
tag is added to the field.
mReader2.NotifyTrigger = "Add";
//mReader2.TagListFormat
mReader2.NotifyMode = "ON";
mReader2.AutoMode = "ON";
mReader2.SendReceive("", false);
#endregion

//************************************************************************
******

//************************************************************************
******

42
//Start listening for tags in the read field
mServer.StartListening();

}
catch (Exception ex)
{
lblMessage.Text = ex.ToString();

if ((mReader2 != null) && (mReader2.IsConnected))


mReader2.Dispose();

mReader2.Disconnect();
}
}

public void RFID_RCPT()


{

//************************************************************************
*****************
// This function connects to the Receiving Reader and
configures it for Listening for Tags.

//************************************************************************
*****************

try
{
//Declare IP addresses for both Readers
string IPAddress = cboRcptIP.SelectedItem.ToString();

//Connect to both Readers


mReader.InitOnNetwork(IPAddress, 23);
mReader.Connect();

//Login to both Readers


if (mReader.IsConnected)
{
mReader.Login(txtUser2.Text, txtPass2.Text);
lblMessage.Text = "Receiving Reader Connected!";
}
else
{
mReader.Disconnect();
lblMessage.Text = "Receiving Reader Not Connected!";
}

//************************************************************************
******

//************************************************************************
******
//Configure the Receiving reader for listening mode and
proper settings for demo.

#region Settings

43
if (mReader.AutoMode == "ON")
{
mReader.AutoMode = "OFF";
}
mReader.ClearTagList();
mReader.NotifyMode = "OFF";
mReader.AcquireMode = "Inventory";
mReader.PersistTime = "86400";
//Grabbing IP address of the server computer (the computer
the App is running on)
string nAddress = (mServer.IPAddressString).Trim() + ":" +
Convert.ToString(mServer.Port).Trim();
mReader.NotifyAddress = nAddress;
mReader.NotifyTime = "0";
mReader.TagType = 7;
mReader.SendReceive("RFAttenuation = 30", false);
mReader.TagListAntennaCombine = "ON";
//mReader2.TagListFormat = "XML";
mReader.NotifyFormat = "Text";
mReader.AntennaSequence = "0,1";
mReader.NotifyTrigger = "Add";
//mReader2.TagListFormat
mReader.NotifyMode = "ON";
mReader.AutoMode = "ON";
#endregion

//************************************************************************
******

//************************************************************************
******

//Start listening for tags in the read field


mServer.StartListening();
}

catch (Exception ex)


{
lblMessage.Text = ex.ToString();

if ((mReader != null) && (mReader.IsConnected))


mReader.Dispose();

mReader.Disconnect();
}
}

public void Match_ASN(string tagid)


{

//************************************************************************
*****************
// Function finds the PO and item from the tag value passed
from Notification and assigns
// data to global variables.

44
//************************************************************************
*****************

//Create connection string to server 192 and select the entry


with matching tag value.
String strConnection = "Server=psbeh192\\SQLEXPRESS;User
ID=abc;password=abcabc;Database=AdvanceShipNotice;Persist Security
Info=True";
String strSQL = "SELECT * FROM dbo.Shipment WHERE TagValue =
'" + tagid + "'";

//Connect and run query command


System.Data.SqlClient.SqlConnection objConnection = new
System.Data.SqlClient.SqlConnection(strConnection);
System.Data.SqlClient.SqlCommand objCommand = new
System.Data.SqlClient.SqlCommand(strSQL, objConnection);
System.Data.SqlClient.SqlDataReader objDataReader;

try
{
objConnection.Open();
objDataReader = objCommand.ExecuteReader();
objDataReader.Read();

//Assign data to global variables


g_idocPO = (string)objDataReader["PoNo"];
g_idocMaterial = (string)objDataReader["Material"];
g_idocContract = (string)objDataReader["ContractNo"];
g_idocQty = (string)objDataReader["QTY"];

//Close Connections
objDataReader.Close();
objConnection.Close();
}

catch (Exception exx)


{
objConnection.Close();
lblMessage.Text = exx.ToString();
}
}

private void frmKanban_Load(object sender, EventArgs e)


{
mServer = new CAlienServer();

//Declare Event Handlers for when a notification is recieved


by the server(Computer application is running on).
mServer.ServerMessageReceived += new
CAlienServer.ServerMessageReceivedEventHandler(mServer_ServerMessageReceiv
ed);
mServer.ServerSocketError += new
CAlienServer.ServerSocketErrorEventHandler(mServer_ServerSocketError);
}

private void mServer_ServerMessageReceived(string msg)

45
{

//************************************************************************
*********************
//When a Notification message is received, parse the
information and check the name of the
//reader. Determines what function to call depending on the
reader that is sending the message.

//************************************************************************
*********************

NotifyInfo ni;
AlienUtils.ParseNotification(msg, out ni);

if (ni.ReaderName == "Alien9780A")
{
displayText(msg);
}

if (ni.ReaderName == "Alien9800B")
{
displayText2(msg);
}
}

private void mServer_ServerSocketError(string msg)


{

//************************************************************************
*********************
//When a Notification message is received, parse the
information and check the name of the
//reader. Determines what function to call depending on the
reader that is sending the message.

//************************************************************************
*********************

NotifyInfo ni;
AlienUtils.ParseNotification(msg, out ni);

if (ni.ReaderName == "Alien9780A")
{
displayText(msg);
}

if (ni.ReaderName == "Alien9800B")
{
displayText2(msg);
}
}

private void displayText(string data)


{

46
//************************************************************************
***********************
//When a Notification message is received from Alien9780A,
this function parses the notification,
//grabs the tagID and runs the appropriate functions to
generate a PO.

//************************************************************************
***********************

try
{
if (this.InvokeRequired)
{
object[] temp = { data };
this.Invoke(new displayMessageDlgt(displayText),
temp);
return;
}
else
{
NotifyInfo ni = null;
AlienUtils.ParseTextNotification(data, out ni);

if (ni.TagList != null)
{
string sTags = "";
//Place all TagIds into an Array
Array tInfo = (ni.TagList);
//Loop through each item in the array and grab the
TagID
foreach (TagInfo x in tInfo)
{
sTags += x.TagID + "\r\n";

//Take TagID and pass it to the parse function


Parse_Tag_Data(x.TagID);
//Take the next sequential PO from the text
file
Grab_PO();
//Produce and sent iDoc to SAP
SAP_PO_IDOC();
//Send Data to SQLServer(Simulation of vendor)
through EDI
EDI_to_SQLserver();

MessageBox.Show("A quantity of " + gQty + ",


of Material " + gMaterial + ", under contract " + gContract + " has been
ordered on PO#" + gPO + " with the vendor!");
}

}
else
return;
}
}

47
catch (Exception ex)
{
lblMessage.Text = ex.ToString();
}
}

private void displayText2(string data)


{

//************************************************************************
***********************
//When a Notification message is received from Alien9800B,
this function parses the notification,
//grabs the tagID and runs the appropriate functions to
generate receive against a PO.

//************************************************************************
***********************

try
{
if (this.InvokeRequired)
{
object[] temp = { data };
this.Invoke(new displayMessageDlgt(displayText2),
temp);
return;
}
else
{
NotifyInfo ni = null;
AlienUtils.ParseTextNotification(data, out ni);

if (ni.TagList != null)
{
string sTags = "";
//Place all TagIds into an Array
Array tInfo = (ni.TagList);
//Loop through each item in the array and grab the
TagID
foreach (TagInfo x in tInfo)
{
sTags += x.TagID + "\r\n";

//Match the TagID with a ID in the simulated


ASN database.
Match_ASN(x.TagID);
//Produce and sent Idoc to SAP
SAP_RCVD_IDOC();

MessageBox.Show("A quantity of " + g_idocQty +


", of Material " + g_idocMaterial + ", under contract " + g_idocContract +
" has been received on PO#" + g_idocPO + "!");
}
}
else
return;

48
}
}
catch (Exception ex)
{
lblMessage.Text = ex.ToString();
}
}

private void EDI_to_SQLserver()


{
//Insert data that was parsed from the TagID into the SQLServer
EDI_Orders table.
string strSQL = "INSERT INTO dbo.EDI_Orders (Material, Qty,
Contract, PO, Fullfilled) " +
"Values ('" + gMaterial + "', '" + gQty + "', '" + gContract
+ "', '" + gPO + "', " + "0)";

Run_Query(strSQL);
}

public void Run_Query(string strSQL)


{
//Run a query string on SQL server 192
string strConnection = "Server=psbeh192\\SQLEXPRESS;User
ID=abc;password=abcabc;Database=AdvanceShipNotice;Persist Security
Info=True";
System.Data.SqlClient.SqlConnection objConnection = new
System.Data.SqlClient.SqlConnection(strConnection);
System.Data.SqlClient.SqlCommand objCommand = new
System.Data.SqlClient.SqlCommand(strSQL, objConnection);
System.Data.SqlClient.SqlDataReader objDataReader;

try
{
objConnection.Open();
objDataReader = objCommand.ExecuteReader();
objDataReader.Close();
objConnection.Close();

}
catch (Exception exx)
{
objConnection.Close();
lblMessage.Text = exx.ToString();
}
}
public void Get_PO()
{
}
public void Grab_PO()
{

//************************************************************************
**************************
//Use streamreader to open a textfile, read the PO, add 1 to
the end of the PO, and rewrites the PO.

49
//************************************************************************
**************************

string FILENAME = "PO_Track.txt";


StreamReader sr = File.OpenText(FILENAME);
string InFile = sr.ReadToEnd();
sr.Close();

string OutFile;
Int64 PO_Num;
InFile.Trim();
//Assigns the new PO to a global variable
gPO = InFile;
//Converts to Integer to add 1
PO_Num = Convert.ToInt64(InFile);
PO_Num = PO_Num + 1;
//Sends new number back to text file
OutFile = Convert.ToString(PO_Num);
StreamWriter sw = File.CreateText(FILENAME);
sw.Write(OutFile);
sw.Close();

public void Parse_Tag_Data(string strHex)


{

//************************************************************************
**************************
//Reads in Hex Tag ID and parses the information into
Material, Contract, and Qty information.

//************************************************************************
**************************

string temp;
string material1;
string material2;
char material3;
string material4 = "";

temp = strHex.Replace(" ", "");


//Convert Material and letters
material1 = temp.Substring(9, 6);

int i = 0;
for (i = 0; i < 6; i = i + 2)
{
material2 = material1.Substring(i, 2);
material3 = (char)int.Parse(material2,
System.Globalization.NumberStyles.HexNumber);
material4 += material3;
}
//Grabing particular section of Hex string and converting it
to readable data

50
if (int.Parse(temp.Substring(15, 4),
System.Globalization.NumberStyles.HexNumber) > 1000)
{
material4 += Convert.ToString(int.Parse(temp.Substring(15,
4), System.Globalization.NumberStyles.HexNumber));
}
else
{
material4 += "0" +
Convert.ToString(int.Parse(temp.Substring(15, 4),
System.Globalization.NumberStyles.HexNumber));
}

gContract = Convert.ToString(Int64.Parse(temp.Substring(0, 9),


System.Globalization.NumberStyles.HexNumber));
gMaterial = material4;

//Building Qty string for iDoc. Run through a loop to


concatenate proper string length of 15
gQty = "";
string tQty = Convert.ToString(int.Parse(temp.Substring(19,
5), System.Globalization.NumberStyles.HexNumber));
int j = 0;
do
{
gQty += "0";
j++;
}
while (j < (15 - tQty.Length));

gQty = gQty + tQty;


}

public void SAP_RCVD_IDOC()


{
//Open a file for reading
string FILENAMEIN = "mbgmcr.txt";

//File for writing


string FILENAMEOT = "mbgmcrott.txt";

//Get a StreamReader class that can be used to read the file


StreamReader objStreamReader = new StreamReader(FILENAMEIN);
objStreamReader = File.OpenText(FILENAMEIN);

//Get a StreamWriter class that can be used to write the file


StreamWriter objStreamWriter = new StreamWriter(FILENAMEOT);

string InFile;
string OutFile;
//Read entire TextFile into a string
InFile = objStreamReader.ReadToEnd();
//Find and replace dummy values in string with actual
InFile = InFile.Replace("PO12345678", g_idocPO);
InFile = InFile.Replace("MAT9999", g_idocMaterial);
InFile = InFile.Replace("QTY999999999999", g_idocQty);
OutFile = InFile;

51
objStreamWriter.Write(OutFile);
//Close reader and writer
objStreamReader.Close();
objStreamWriter.Close();

// Submit idoc to SAP via RFC


RfcTID myTid = RfcTID.NewTID();

//Logon to SAP with proper server information


SAPProxy2 proxy = new SAPProxy2();
SAP.Connector.Destination destination = new
SAP.Connector.Destination();
destination.AppServerHost = "sap1.win.psu.edu";
destination.Client = 406;
destination.Password = "rfid";
destination.SystemNumber = 0;
destination.Username = "ecr124";
destination.Language = "en";

try
{
//Create a connection into SAP
SAP.Connector.SAPConnection connection = new
SAP.Connector.SAPConnection((IDestination)destination);
proxy.Connection = connection;
}
catch (Exception ex)
{
lblMessage.Text = ex.ToString();
}
//Declare iDoc sender
SAPIDocSender sapiDocSender1 = new SAPIDocSender();
try
{
//Send iDoc to SAP via RFC
sapiDocSender1.Connection = proxy.Connection;
sapiDocSender1.SubmitIDoc((("mbgmcrott.txt")), myTid);
proxy.ConfirmTID(myTid);
lblMessage.Text = "Idoc Sent";
}
catch (Exception ex)
{
lblMessage.Text = ex.ToString();
}
//Close Proxy
proxy.Connection.Close();
proxy.Connection = null;

public void SAP_PO_IDOC()


{
//Open a file for reading
string FILENAMEIN = "po_idoc1.txt";

//File for writing

52
string FILENAMEOT = "po_idoc2.txt";

//Get a StreamReader class that can be used to read the file


StreamReader objStreamReader = new StreamReader(FILENAMEIN);
objStreamReader = File.OpenText(FILENAMEIN);

//Get a StreamWriter class that can be used to write the file


StreamWriter objStreamWriter = new StreamWriter(FILENAMEOT);

string InFile;
string OutFile;
//Set date to current date plus two weeks
string currentDate =
DateTime.Now.AddDays(14).ToString("MM/dd/yyyy");

//Read in the receiving iDoc and replace dummy variables with


actual data from SQLserver
InFile = objStreamReader.ReadToEnd();
InFile = InFile.Replace("PO99999999", gPO);
InFile = InFile.Replace("CONTRACT99", gContract);
InFile = InFile.Replace("QTY999999999999", gQty);
InFile = InFile.Replace("MAT9999", gMaterial);
InFile = InFile.Replace("99/99/9999", currentDate);
//Write the new string into receiving idoc text file
OutFile = InFile;
objStreamWriter.Write(OutFile);
//Close reader and writer
objStreamReader.Close();
objStreamWriter.Close();

// submit to SAP via RFC


RfcTID myTid = RfcTID.NewTID();

//Logon to SAP
SAPProxy2 proxy = new SAPProxy2();
SAP.Connector.Destination destination = new
SAP.Connector.Destination();
destination.AppServerHost = "sap1.win.psu.edu";
destination.Client = 406;
destination.Password = "rfid";
destination.SystemNumber = 0;
destination.Username = "ecr124";
destination.Language = "en";

//Send Idoc through SAP connector


try
{
SAP.Connector.SAPConnection connection = new
SAP.Connector.SAPConnection((IDestination)destination);
proxy.Connection = connection;

SAPIDocSender sapiDocSender1 = new SAPIDocSender();


//Send idoc created above to SAP
sapiDocSender1.Connection = proxy.Connection;
sapiDocSender1.SubmitIDoc((("po_idoc2.txt")), myTid);
proxy.ConfirmTID(myTid);
lblMessage.Text = "Idoc Sent";

53
}
catch (Exception ex)
{
lblMessage.Text = ex.ToString();
}

proxy.Connection.Close();
proxy.Connection = null;
}
}
}

54

Вам также может понравиться