SAP R 3 IDoc Cookbook For EDI and Interf
SAP R 3 IDoc Cookbook For EDI and Interf
SAP R 3 IDoc Cookbook For EDI and Interf
This book is an in-depth discussion and cookbook for IDoc development in R/3 for EDI and
eCommerce
SAP R/3 made an old dream come true: enter your business data once in your computer and trigger
all the following activities automatically, send the data to another computer without typing them in
again.
Facts, Know-how and recipes, that is all you can except from this book.
• Establish EDI communication with your clients or suppliers
• communicate in real-time with your legacy and satellite systems
• send and receive data to and from your production machine
• integrate PC or UNIX applications directly in R/3 with RFC
• automate your business from order entry to invoicing
• survey your purchase orders for goods receipt to clearing payments
The authors know, that nobody will believe them: but it is so imple and easy with R/3 to set up an
automated business scenario with IDocs, ALE and Workflow
This book teaches you how SAP R/3 approaches in a coherent concept the electronic data exchange
with another computer. With this know-how
Paper is out - EDI is in
No modern global playing company will allow their suppliers any more, to deliver their order, delivery,
transport and invoice information on paper. They require
Read in this book, why
• EDI will be unevitable in future global business
• EDI projects with R/3 would often cost five to ten times as much as necessary?
• IDocs and ALE are the ideal bridge between R/3 and legacy systems
• IDocs are the framework for a fully automated business workflow
In the technical part of the book you will learn, how to
• customize the R/3 IDoc engine
• interface IDocs with standard converters for X.12, EDIFACT, VDA etc.
• design your own IDoc structures
• write IDoc handler programs in an hour
• trigger IDocs from any R/3 application via messages or workflow
• set up automated workflow based on IDocs
• set up ALE scenarios for automated data replications
Preface
Proper Know-How Saves Costs
We always believed, what has been confirmed over and over again in manifold projects: The main
source to cutting project costs, is a proper education of the team. Giving the team members the same
book to read homogenizes the knowledge and sharpens a common sense within the group.
A Frequently Given Answers Book
This book is the result of thousands of hours of discussion and work with R/3 consultants, developer
and clients about interface development from and to R/3. When we started a new big project in
autumn 1998 at the Polar Circle, which involved a big number of interfaces, I observed curiously, that
my developers were ordering numerous books, all being related to EDI.
Well, those books did not say any word about R/3 and it was obvious that they were not very helpful
for our team. I consequently searched the directories for books on R/3 IDocs, but there was nothing.
So I started to compile my material on IDocs and ALE with the intent to publish it in the WWW. Since I
submit the site http://idocs.de to some search engines I got an astonishing amount of hits. Emails
asked for a written version of the stuff on the web. So – here it is.
Mystery EDI Unveiled
EDI and e-commerce are miracle words in today’s IT world. Like any other mystery it draws its magic
from the ignorance of the potential users. It is true that there are many fortune making companies in
the IT world who specialize on EDI. They sell software and know-how for giant sums of money.
Looking behind the scenes reveals, that the whole EDI business can simply be reduced to writing
some conversion programs. This is not too easy, but the secret of EDI companies is, that the so-called
standards are sold for a lot of money. As soon as you get hold of the documentation, things turn out to
be easy.
IDocs, A Universal Tool for Interface Programming
Although R/3 IDocs had been introduced as a tool to implement EDI solution for R/3, it is now
accepted as a helpful tool for any kind of interface programming. While this is not taught clearly in
SAP’s learning courses, we put our focus on writing an interface quickly and easily.
http://idocs.de
We praise cutting edge technology. So this book takes advantage of the modern multimedia hype.
Latest updates, corrections and more sophisticated and detailed examples are found on our web site.
Axel Angeli in December 1999
Logos! Informatik GmbH
email us ! info@logosworld.de
or visit http://idocs.de
R/ 3 Ap plic a tio n
R/ 3 Da ta b a se File Tra nsa c tio n
(e .g . DB/ 2,
ADABAS, O RAC LE
A BAP
IDo c C re a ting
Func tio n Mo dule
XML, X.12.
EDIFAC T ...
C o nve rte r
(PC p ro g ra m)
5 Da ta is se nt
o p tio na l to re c e ive r,
4 An e xte rna l pro g ra m e .g . via FTP,
ISDN pro to c o l
(e .g . running o n NT)
c o nve rts to inte rna tio na l
sta nda rds
The illustration above displays a sketch for a typical IDoc communication scenario.
The steps are just the same as with every communication scenario. There is a
requesting application, a request handler and a target.
The sketch shows the communication outbound R/3. Data is leaving the R/3 system.
Sender The sender's identification PROCLNT100 tells the receiver who sent the IDoc. This
serves the purpose of filtering unwanted data and also provides the opportunity to
process IDocs differently with respect to the sender.
Receiver The receiver's identification DEVCLNT100 should be included in the IDoc header to
make sure that the data has reached the intended recipient.
IDoc Type The name of the IDoc type MATMAS01 is the key information for the IDoc
processor. It is used to interpret the data in the IDoc records, which otherwise would
be nothing more than a sequence of meaningless characters.
Data and segment info Regardless of the used IDoc type, all IDocs are stored in the same database tables
are stored in EDID4 EDID4 for release 4.x and EDID3 for release 2.x and 3.x. Both release formats are
slightly different with respect to the lengths of some fields. Please read the chapter
on port types for details.
Depending on the R/3 release, the IDoc data records are formatted either according
the DDic structure EDID3 or EDID3. The difference between the two structures
reflects mainly the changes in the R/3 repository, which allow longer names starting
from release 4.x.
Then you can access the fields of the IDoc segment EDIDD-SDATA as fields of the
structure e1maram .
Data in EDID4-SDATA WRI TE: e1mar am- mat nr .
Sample coding The following coding sample, shows how you may read a MATMAS IDoc and
extract the data for the MARA and MARC segments to some internal variables and
tables.
DATA: xmar a LI KE e1mar am.
DATA: t mar c AS STANDARD TABLE OF e1mar cm
WI TH HEADER LI NE.
LOOP AT edi dd.
CASE edi dd- segnam.
WHEN ' E1MARAM' .
MOVE edi dd- sdat a TO xmar a.
WHEN ' E1MARCM' .
MOVE edi dd- sdat a TO t mar c.
APPEND t mar c.
ENDCASE.
ENDLOOP.
now do somet hi ng wi t h xmar a and t mar c.
Keep
It
S imple and
S mart
We will show a short example that packs SAP R/3 SapScript standard text elements
into IDocs and stores them back to texts in a second routine. The text elements can
be edited with SO10.
Text from READ_TEXT Each R/3 standard text element has a header record which is stored in table STXH.
The text lines themselves are stored in a special cluster table. To retrieve the text
from the cluster, you will use the standard function module function
READ_TEXT.
Outbound processing The program below will retrieve a text document from the text pool, convert the text
lines into IDoc format, and create the necessary control information.
The first step is reading the data from the application database by calling the
function module READ_TEXT.
Our next duty is to pack the data into the IDoc record. This means moving the
application data to the data part of the IDoc record structure EDIDD and filling the
corresponding segment information.
* * * * - - - Packi ng t he appl i cat i on dat a i nt o I doc
MOVE E_THEAD TO I DOC_DATA- SDATA.
* t he r ecei ver needs t he segment name
i n or der t o i nt er pr et t he segment
MOVE ' YAXX_THEAD' TO I DOC_DATA- SEGNAM.
APPEND I DOC_DATA.
LOOP AT TLI NES.
MOVE E_THEAD TO I DOC_DATA- SDATA.
* *** - - we st i l l need t o f i l l mor e segment i nf o
MOVE ' YAXX_TLI NE' TO I DOC_DATA- SEGNAM.
APPEND I DOC_DATA.
ENDLOOP.
Finally, we have to provide a correctly filled control record for this IDoc. If the IDoc
routine is used in a standard automated environment, it is usually sufficient to fill the
field EDIDC-IDOCTP with the IDoc type, EDIDC-MESTYP with the context
message type and the receiver name. The remaining fields are automatically filled
by the standard processing routines if applicable.
* * * * - - - Packi ng t he I doc cont r ol r ecor d - - - * * * *
CLEAR I DOC_CONTRL.
I DOC_CONTRL- I DOCTP = ' YAXX_TEXT' .
* *** - - we st i l l need t o f i l l mor e cont r ol r ec i nf o
APPEND I DOC_CONTRL.
Inbound processing This example of a simple inbound function module expects as input an IDoc with
function module rows of plain text as created in the outbound example above. The procedure will
extract the text name and the text line from the IDoc and hand over the text data to
the function module SAVE_TEXT which will store the text in the text pool.
Unpacking the IDoc data The received IDoc data is processed record by record and data is sorted out
Finally the processing routine needs to pass a status record to the IDoc processor.
This status indicates successful or unsuccessful processing and will be added as a
log entry to the table EDIDS.
* f i l l I DOC_St at us
I F OK NE 0.
I DOC_STATUS- STATUS = ' 51' .
* I DOC_STATUS- . . = . f i l l t he ot her f i el ds t o l og i nf or mat i on
ELSE.
I DOC_STATUS- STATUS = ' 53' .
ENDI F.
APPEND I DOC_STATUS.
The status value '51' indicates a general error during application processing and the
status '53' indicates everything is OK.
Define the semantic The message type defines the semantic context of an IDoc. The message type tells
context the receiverhow the message has to be interpreted.
Messages are The term message is commonly used in communication, be it EDI or
information for a foreign telecommunication. Any stream of data sent to a receiver with well-defined
partner information in itis known as a message. EDIFACT, ANSI/X.12, XML and others
use message the same way.
The term message is Unfortunately, the term message is used in many contexts other than EDI as well.
also used for R/3’s Even R/3 uses the word message for the internal communication between
internal communication applications. While this is totally OK from the abstract point of view of data
between applications modelling, it may sometimes cause confusion if it is unclear whether we are
referring to IDoc messages or internal messages.
The specification of the message type along with the sent IDoc package is especially
important when the physical IDoc type (the data structure of the IDoc file) is used
for different purposes.
A classical ambiguity arises in communication with customs via EDI. They usually
set up a universal file format for an arbitrary kind of declaration, e.g. Intrastat,
Extrastat, Export declarations, monthly reports etc. Depending on the message type,
only applicable fields are filled with valid data. The message type tells the receiver
which fields are of interest at all.
The Idoc type is defined with transaction WE30, the respective segments are defined
with transaction WE31.
Processing Codes
The processing code is a pointer to an algorithm to process an IDoc. It is used to allow more
flexibility in assigning the processing function to an IDoc message.
The logical processing The processing code is a logical name for the algorithm used to process the IDoc.
code determines the The processing code points itself to a method or function, which is capable of
algorithm in R/3 used to processing the IDoc data.
process the IDoc
A processing code can point to an SAP predefined or a self-written business object
or function module as long as they comply with certain interface standards.
Allows changing the The processing codes allow you to easily change the processing algorithm. Because
algorithm easily the process code can be used for more than one partner profile, the algorithm can be
easily changed for every concerned IDoc.
The processing code The IDoc engine will call a function module or a business object which is expected
defines a method or to perform the application processing for the received IDoc data. The function
function to process an module must provide exactly the interface parameters which are needed to call it
IDoc from the IDoc engine.
Copy the segment To facilitate our work, we will use the "copy-from-template-tool", which reads the
structure from a DDic definition of a DDIC structure and inserts the field and the matching definitions as
object rows in the IDoc editor. You could, of course, define the structure completely
manually, but using the template makes it easier.
The tool in release 4.0b lets you use both DDIC structures or another IDoc segment
definition as a template.
The definition The thus created structure can be edited any time. When saving, it will create a data
autpmatically creates a dictionary structure based on the definition in WE31. The DDIC structure will retain
corresponding DDic the same name. You can view the structure as a table definition with SE11 and use it
structure in an ABAP the same way.
EDMSG used as check The entry is only a base entry which tells the system that the message type is
table allowed. Other transactions will use that table as a check table to validate the entry.
Figure 24: EDIMSG: Define valid combination of message and IDoc types
The definition for inbound and outbound IDocs is analogous. Of course, the function
module will be different.
Processing with ALE This is the option you would usually choose. It allows processing via the ALE
scenarios.
Validate allowed After defining the processing code you have to assign it to one or several logical
message types message types. This declaration is used to validate, if a message can be handled by
the receiving system.
Validate allowed After defining the processing code, you have to assign it to one or several logical
message types message types. This declaration is used to validate, if a message can be handled by
the receiving system.
The examples above show only the association with a function module. You can
also define business objects with transaction SWO1 and define them as a handler. For
those familiar with the object model of R/3, it may be a design decision. In this
book, we will deal with the function modules only.
NAST messages are Creating NAST messages is a standard functionality in most of the SAP core
created by application by applications. Those applications - e.g. VA01, ME21 - perform calls to the central
calling function module function module MESSAGING of group V61B. The function module uses
MESSAGING customizing entries, mainly those of the tables T681* to T685*.
NAST contains object A NAST output message is stored as a single record in the table NAST. The record
key, sender and receiver stores all information that is necessary to create an IDoc. This includes mainly an
object key to identify the processed object and application to the message handler
and the sender and receiver information.
Programs are The processing routine for the respective media and message is customized in the
customized in table table TNAPR. This table records the name of a FORM routine, which processes the
TNAPR message for the chosen media and the name of an ABAP where this FORM is found.
SWLD lets install and log You can check if an application fires events by activating the event log from
workflows transaction SWLD. Calling and saving a transaction will write the event’s name and
circumstances into the log file.
If an application does not fire workflow events directly, there is still another chance
that a workflow may be used without touching the R/3 original programs.
Workflow Events are also Every application that writes change documents triggers a workflow event from
fired from change within the function module CHANGEDOCUMENT_CLOSE, which is called form the
document update processing upon writing the change document. This will call the workflow
processor
FUNCTI ON swe_event _cr eat e_changedocument
Both workflow types are not compatible with each other with respect to the function
modules used to handle the event.
The workflow types are Both will call a function module whose name they find in the workflow linkage
incompatible but work tables. swe_event_create will look in table SWETYPECOU while
according the same swe_event_create_changedocument would look in SWECDOBJ for the name of the
principal function module.
The workflow handler will If a name is found, the function module will then be called dynamically. This is all
be called dynamically to say about the linkage of the workflow.
The dynamic call looks like the following.
CALL FUNCTI ON swecdobj - obj t ypef b
EXPORTI NG
changedocument _header = changedocument _header
obj ect t ype = swecdobj - obj t ype
I MPORTI NG
obj ect t ype = swecdobj - obj t ype
TABLES
changedocument _posi t i on = changedocument _posi t i on.
Currently (release 40B) this check does nothing else than to check, if this table has
an entry or not. If there is an entry in TBDA1, the ALE change pointers are generally
active. If this table is empty, change pointers are turned off for everybody and
everything, regardless of the other settings.
The two points read like you had the choice between turning it on generally or
selectively. This is not the case: you always turn them on selectively. The switch to
turn on generally is meant to activate or deactivate the whole mechanism.
reading the change The change pointers which have not been processed yet, can be read with a function
pointers which are not module.
yet processed
Cal l Funct i on ' CHANGE_POI NTERS_READ'
RBDMIDOC The ABAP RBDMIDOC will process all open change pointers and distribute the
matching IDocs.
Use Change Documents When you want to send out an IDoc unconditionally every time a transaction
Instead Of Change updates, you better use the workflow from the change documents.
Pointers
Example A complex example for a function module, which collects the change pointers, can
be examined in:
MASTERIDOC_CREATE_SMD_DEBMAS .
This one reads change pointers for debtors (customer masters). During the
processing, it calls the actual IDoc creating module
MASTERIDOC_CREATE_DEBMAS .
To summarize the change pointer concept
• Change pointers record relevant updates of transaction data
• Change pointers are written separate from the change documents, while at the
same time
• Change pointers are evaluated by a collector run
BDCPS Change pointer: Status
BDCP Change pointer
BDCPV A view with BDCP and BDCPS combined: Change pointer with status
TBDA2 Declare activate message types for change pointers with view V_TBDA2.or
transaction BD50 or .
SALE -> Activate change pointers for message types
TBD62 The view V_TBD62 defines those fields which are relevant for change pointer
creation. The table is evaluated by the CHANGE_DOCUMENT_CLOSE function.
The object is the same used by the change document. To find out the object name,
look for CHANGE_DOCUMENT_CLOSE in the transaction you are inspecting or
see table CDHDR for traces.
Figure 33: Tables involved in change pointers processing
Fill control record Finally, the control record has to be filled with meaningful data, especially telling
the IDoc type and message type.
IF I DOC_CONTRL- SNDPRN I S I NI TI AL.
SELECT SI NGLE * FROM T000 WHERE MANDT EQ SY- MANDT.
MOVE T000- LOGSYS TO I DOC_CONTRL- SNDPRN.
ENDI F.
I DOC_CONTRL- SNDPRT = ' LS' .
* Tr ans we20 - > Out bound Cont r ol s muss ent spr echend geset zt wer den.
* 2 = Tr ansf er I Doc i mmedi at el y
* 4 = Col l ect I Docs
I DOC_CONTRL- OUTMOD = ' 2' . " 1=i medi at el y, subsyst em
CLEAR I DOC_CONTRL.
I DOC_CONTRL- I DOCTP = ' YAXX_TEXT' .
APPEND I DOC_CONTRL.
Fill control record Finally, the control record has to be filled with meaningful data, especially telling
the IDoc type and message type.
IF I DOC_CONTRL- SNDPRN I S I NI TI AL.
SELECT SI NGLE * FROM T000 WHERE MANDT EQ SY- MANDT.
MOVE T000- LOGSYS TO I DOC_CONTRL- SNDPRN.
ENDI F.
I DOC_CONTRL- SNDPRT = ' LS' .
* Tr ans we20 - > Out bound Cont r ol s muss ent spr echend geset zt wer den.
* 2 = Tr ansf er I Doc i mmedi at el y
* 4 = Col l ect I Docs
I DOC_CONTRL- OUTMOD = ' 2' . " 1=i medi at el y, subsyst em
CLEAR I DOC_CONTRL.
I DOC_CONTRL- I DOCTP = ' YAXX_TEXT' .
APPEND I DOC_CONTRL.
The example shows you that sales orders can be exchanged in different file formats.
There may be some customers who accept the latest IDoc format ORDERS02, while
others still insist on receiving the old format ORDERS01.
The IDoc format for sales orders would also be used to transfer a purchase
requisition. While the format remains the same, the different message type signals
that it is not an actual order but a request.
Port versions differ in The difference between the port types is mainly the length of some fields. E.g. does
length of fields port type 3 allow segment names up to 30 characters in length, while port type 3 is
constrained to a maximum segment name of 8 characters.
Figure 47: Program to copy text modules into a remote system via RFC
The example call above would execute the following when run on a DOS system.
command.com /c copy c:\config.sys c:\temp
rfc_remote_pipe rfc_remote_pipe will call RFCEXEC, execute the command line interpreter with the
parameter string and catch the output into an internal table.
CALL FUNCTI ON ‘ RFC_REMOTE_PI PE’
DESTI NATI ON ‘ RFC_EXEC’
EXPORTI NG COMMAND = ’ di r c: \ sapgui >i nput ’
The example call above would execute the following when run on a DOS system,
command.com /c dir c:\sapgui >input
while the file input is caught by rfc_remote_pipe and returned to the calling system.
Process incoming files A common application for the use of rfc_remote_pipe is to automatically check a
file system for newly arrived files and process them. For that purpose, you would
create three directories, e.g. the following.
x: \ i ncomi ng
x: \ wor k
x: \ pr ocessed
The statement retrieves the file list with rfc_remote_pipe into an R/3 internal table.
dir x:\incoming /b
Figure 48: This is the call of the type coupled event in release 40B
Figure 49: This is the call of the change doc event in release 40B
Figure 50: This is the call of the type coupled event in release 40B
NAST must be declared In addition, you need to declare the table NAST with a tables statement public in the
public in the called ABAP where the form routinely resides. When the form is called, the variable NAST
program is filled with the values of the calling NAST message.
Template for workflow Release 40B provides the function module WF_EQUI_CHANGE_AFTER_ASSET
handler which could be used as a template for the interface. So we will copy it and put our
coding in instead..
FUNCTI ON Z_WORKFLOW_HANDLER.
* " * " Lokal e Schni t t st el l e:
*" I MPORTI NG
*" VALUE( OBJKEY) LI KE SWEI NSTCOU- OBJKEY
*" VALUE( EVENT) LI KE SWETYPECOU- EVENT
*" VALUE( RECTYPE) LI KE SWETYPECOU- RECTYPE
*" VALUE( OBJTYPE) LI KE SWETYPECOU- OBJTYPE
*" TABLES
*" EVENT_CONTAI NER STRUCTURE SWCONT
*" EXCEPTI ONS
*" NO_WORKFLOW
RECEI VERS- EXPRESS = ' ' .
RECEI VERS- RECEI VER = SY- SUBRC.
APPEND RECEI VERS.
DOCUMENT_DATA- OBJ_DESCR = OBJ_KEY.
CONTENT = OBJ_KEY.
APPEND CONTENT.
CALL FUNCTI ON ' SO_NEW_DOCUMENT_SEND_API 1'
EXPORTI NG DOCUMENT_DATA = DOCUMENT_DATA
TABLES OBJECT_CONTENT = CONTENT
RECEI VERS = RECEI VERS.
ENDFUNCTI ON.
Link handler to caller The function can be registered as a handler for an event. This is done with
transaction SWLD.
Event logging If you do not know the object type that will trigger the event, you can use the event
log. You have to activate it from SWLD and then execute the event firing transaction.
When the event has been fired, it will trace it in the event log.
• doc_data-obj_expdat
• doc_data-sensitivty
• doc_data-obj_prio
• doc_data-no_change
*----------------------------------------------------------------------*
CALL FUNCTI ON ‚ SO_NEW_DOCUMENT_SEND_API 1’
EXPORTI NG
DOCUMENT_DATA = DOC_DATA
* DOCUMENT_TYPE = ‚ RAW’
* PUT_I N_OUTBOX = ‚ ‚
• IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_I D =
TABLES
* OBJECT_HEADER =
OBJECT_CONTENT = MAI L
* OBJECT_PARA =
* OBJECT_PARB =
RECEI VERS = RECLI ST
EXCEPTI ONS
TOO_MANY_RECEI VERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXI ST = 3
OPERATI ON_NO_AUTHORI ZATI ON = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
*----------------------------------------------------------------------*
ENDFUNCTI ON.
Listing 3: Send an SAP office mail triggered by a workflow event (full example)
Data Object
Sender
Receiver
WEDI - IDoc Here you define all the IDoc related parts, which make up most of the work related
Administration to ALE.
Figure 55: WE
DI
me
nu
BDBG - Automatically Good stuff for power developers. It allows you to generate all IDoc definitions
generate IDocs From A including segments and IDoc types from the DDIC entries for a BAPI definition.
BAPI
Logical System Before we start, we need to maintain some logical systems. These are names for the
RFC destinations which are used as communication partners. An entry for the
logical system is created in the table TBDLS.
Assign logical system to Finally. you will have to assign a logical system to the clients involved in ALE or
a client IDoc distribution. This is done in table T000, which can be edited via SM31 or via
the respective SALE tree element.
Suggestion: One You can have many scenarios for eventual different purposes. You may also want to
scenario per put everything in a single scenario. As a rule of thumb, it proved as successful that
administration area you create one scenario per administrator. If you have only one ALE administrator,
there is no use having more than one scenario. If you have several departments with
different requirements, then it might be helpful to create one scenario per
department.
Now go on defining The model view displays graphically the from-to relations between logical systems.
partner profiles You now have to generate the partner profiles which are used to identify the
physical means of data transportation between the partners.
The values give here are not really important. The partner class is only a
classification value. You can give an arbitrary name in order to group the type of
partners, e.g. EDI for external ones, ALE for internal ones, and IBM for connection
with IBM OS/390 systems.
There have been two profiles generated. The one is for MATMAS, which we
explicitly assigned in the distribution scenario. The second one is a mandatory IDoc
type with the name SYNCH ,which is used for RFC control information and
synchronisation. This one is only created if it does not yet exist.
Here is a detail view of the parameters generated. The receiver port is the RFC
destination that had been created for TESTTARGET with SM59.
Data goes to table EDP13.
Figure 75: Specify a name for the created message type. The message type will be created in table
EDMSG .
Now you can specify the required IDoc types and the names of the function module
and function group for the processing routines. Note, that the development class
(Entwicklungsklasse) and the function group (Funktionsgruppe) need to be in your
customer name space, i.e. should begin with Y or Z. The values proposed on this
screen are usually inappropriate.
Result report Click on generated objects to see what was generated in detail.
A detailed report is shown. The report is clickable so that you can directly view the
generated objects. The hotspot will appearwhen you move over a clickable object.
The transaction has generated an IDoc type.
The IDoc type is generated with a header section containing the interface values of
the object and a data section with the remaining fields of the object data structure.
The BAPIs interface definition looks like that.
FUNCTI ON bapi _cust omer _changef r omdat a.
*"----------------------------------------------------------------------
* " * " Lokal e Schni t t st el l e:
* " I MPORTI NG
*" VALUE( PI _ADDRESS) LI KE BAPI KNA101 STRUCTURE BAPI KNA101
*" VALUE( PI _SALESORG) LI KE BAPI KNA102- SALESORG
*" VALUE( PI _DI STR_CHAN) LI KE BAPI KNA102- DI STR_CHAN OPTI ONAL
*" VALUE( PI _DI VI SI ON) LI KE BAPI KNA102- DI VI SI ON OPTI ONAL
*" VALUE( CUSTOMERNO) LI KE BAPI KNA103- CUSTOMER
* " EXPORTI NG
*" VALUE( PE_ADDRESS) LI KE BAPI KNA101 STRUCTURE BAPI KNA101
*" VALUE( RETURN) LI KE BAPI RETURN STRUCTURE BAPI RETURN
*"----------------------------------------------------------------------
Generated segment For each of the parameters in the BAPI's interface, the generator created a segment
structure from BAPI for the IDoc type. Some segments are used for IDoc inbound only; others for IDoc
function interface outbound instead. Parameter fields that are not structured will be combined in a
parameter single segment which is placed as first segment of the IDoc type and contains all
Figure 81: Tell where the value for a field should come from
Di m f ns As Obj ect
Di m conn As Obj ect
Di m SAP_l ogon As Bool ean
Sub R3Cal l Tr ansact i on( )
' get t he TCODE f r om t he WORD t ext , MACROBUTTON does not al l ow par amet er s
t code = Sel ect i on. Text & Act i veDocument . Fi el ds( 1) . Code
l l = Len( " MACROBUTTON R3Cal l Tr ansact i on " ) + 3
t code = Mi d$( t code, l l )
R3Cal l Tr ansact i onExecut e ( t code)
End Sub
Sub R3Cal l Tr ansact i onExecut e( t code)
On Er r or GoTo Er r Cal l Tr ansact i on
R3Logon_I f _Necessar y
Resul t = f ns. RFC_CALL_TRANSACTI ON( Except i on, t code: =t code)
t he_except i on = Except i on
Er r Cal l Tr ansact i on: ' Er r or Handl er Gener al
Debug. Pr i nt Er r
I f Er r = 438 Then
MsgBox " Funct i on modul e not f ound or RFC di sabl ed"
R3Logof f ' Logof f t o r el ease t he connect i on ! ! !
Exi t Sub
El se
MsgBox Er r . Descr i pt i on
End I f
End Sub
Sub R3Logon_I f _Necessar y( )
I f SAP_l ogon <> 1 Then R3Logon
End Sub
Sub R3Logon( )
SAP_l ogon = Fal se
Set f ns = Cr eat eObj ect ( " SAP. Funct i ons" ) ' Cr eat e f unct i ons obj ect
f ns. l ogf i l ename = " wdt f l og. t xt "
f ns. l ogl evel = 1
Set conn = f ns. connect i on
conn. Appl i cat i onSer ver = " r 3"
conn. Syst em = " DEV"
conn. user = " user i d"
conn. Cl i ent = " 001"
conn. Language = " E"
conn. t r acel evel = 6
conn. RFCWi t hDi al og = Tr ue
I f conn. l ogon( 0, Fal se) <> Tr ue Then
MsgBox " Cannot l ogon! . "
Exi t Sub
El se
SAP_l ogon = conn. I sConnect ed
End I f
End Sub
Sub R3Logof f ( )
conn. l ogof f
SAP_l ogon = Fal se
End Sub
Now the transaction is The following screens will show the usual transaction screens. All entries that you
played and all entries make are recorded together with the screen name and eventual cursor positions.
recorded
From the recorded After you finished the recording, you have the possibility to generate ABAP coding
session, you can from it. This will be a sequence of statements which can generate a batch input
generate an ABAP session, which is an exact replay of the recorded one.
The generated program contains an include BDCRECXX which contains all the
FORM routines referenced.
Put the coding into a To make the recorded code usable for other programs, you should make a function
function module module out of it. Starting with release 4.5A the recorded code provides a feature to
automatically generate such a function module. For earlier releases, we give the
coding of a program which fulfils this task further down.
Test the function module The created function module should work without modification for testing at least.
and add eventual loops However, you probably will need to modify it, e.g. by adding a loop for processing
for detail processing. multiple entries in a table control (scroll area).
EDIFACT/UN EDIFACT was originally a European standard. It became popular when chosen by
the UNO for their EDI transactions. EDIFACT is a document description language.
EDIFACT is very similar to ANSI X.12 and differs merely in syntactical details and
the meaning of tags.
XML XML and the internet page description language HTML are both subsets derived
from the super standard SGML...
The patent and trademark holder of XML (W3C, http://w3c.org) describes the
advantages of XML very precisely as follows.
1. XML is a method for putting structured data in a text file.
2. XML looks a bit like HTML but isn't HTML.
3. XML is text, but isn't meant to be read.
4. XML is verbose, but that is not a problem.
5. XML is license-free and platform-independent.
And XML is fully integrated in the world wide web. It can be said briefly: XML
sends the form just as the customer entered the data.
Figure 93: XML Order form as displayed in a browser after interpretation by a JAVA applet
XML plug-ins exist often The example shows an XML sales order. In order to be displayed with a standard
as JAVA applets for browser like Internet Explorer 5, plug-ins and JAVA applets exist that interpret the
standard browsers XML and translate the XML specific data tags into HTML form.
Bill to (VBPA-PARVW)
0111213 number of bill-to-party ( VBPA-PARNR)
N1* ST* * * 5566789~
N101
N104
Ship to (VBPA-PARVW)
5566789 (VBPA-PARNR)
The item segments for item 01 – 250 kg of material MY1001 for $15.3 per kg
PO1* 1* 250* KGM* 15. 3* SR* EAN* MY1001~
PO101
PO102
PO103
PO104
PO106
PO107
1 PO1 segments
2 some of quantities (ignore unit)
SE* 7* 000000101~
SE01
SE02
7 segments altogether
Control number 453. This is the same as ST02