Using IDocs 

Use

The SAPforms interface allows you to fill an IDoc (Intermediate Document) using an electronic form. The EDI-IDoc interface in R/3 is used for this purpose.

The IDoc interface supports electronic data communication between various computers and/or systems. In our case, communication takes place between the SAPforms interface (via an electronic form) and an R/3 System.

The use of IDocs is demonstrated here using a BAPI call as an example ( Example: Create customer master record via IDoc). This is just one way to use this function. Naturally, the entire functionality of the IDoc interface can be leveraged with electronic forms. Reference will be made to the corresponding online documentation where necessary.

Using IDocs

Integration

IDocs are complex hierarchical data structures.

One IDoc type (structure) consists of several segment types (naming convention: E1 ... or Z1 ...), that are arranged in a hierarchy. Each segment type, in turn, consists of segment attributes or fields that play a central role when the binding is defined at a later stage.

IDoc instances are instantiations of an IDoc type. They can be compared to text files that contain rows of concrete information. At the "meta level", these instances are divided into a control record ( EDI_DC40 ), data record ( EDI_DD40 ), and a status record ( EDI_DS40 ). The control record contains administrative information, such as the recipient, sender, client, port, or message type. The status records describe the current status of the IDoc (for example "processed"). The data records contain the actual useful data. This useful data is structured by the segment types.

Prerequisites

This technology is used in the following scenario to call a BAPI in the R/3 System using an IDoc. This will be carried out using the ALE-IDoc interface, which enables IDoc types to be generated on the basis of BAPIs. Using an appropriate partner profile and port definition, the BAPI can be called from an incoming IDoc.

Generating an ALE-IDoc Interface

BAPIs are used as a basis for generating an ALE-IDoc interface. This means that the BAPI’s transfer parameters are mapped to segments in the IDoc type. When an IDoc is received, the call parameters of the BAPI are filled with the contents of the corresponding segments. Return values issued by the BAPI are stored in the status records of the IDoc.

To send IDocs to the R/3 System, you must first configure the inbound processing function in R/3. All of the generated interfaces use the BAPI process code. This code refers to the BAPI_IDOC_INPUT1 function module. This function module calls the BAPI (as a standard interface) that is to be started by the electronic form.

Defining a Partner Profile

A partner profile is an entry in which the communication parameters are defined. The values entered in the profile are primarily information that is required in the IDoc control record. The recipient (in our case, an R/3 System) must have a corresponding inbound partner profile for these values so that an assignment can be made.

See also: General Partner Profile

Configuring a Port

IDocs can be exchanged with external systems across different paths or ports. In our case, a sender port must be defined in the control record of the IDoc and then made known to the relevant R/3 System.

See also: Configuring a Port

Creating a Form and Processing it with the SAPforms Designer

After you have created the electronic form, you must prepare it for communication with the R/3 System. This is the task of the SAPforms Designer.

Features

Processing Inbound IDocs

After you have started and filled out your Visual Basic form, for example, an IDoc instance is generated according to the form structure and is filled with data from the form. Following this, the IDoc is sent by SAPforms to the R/3 System by a synchronous RFC where it is processed in accordance with the inbound processing settings.

In many applications, some of the segment fields are not to be filled from the inputs in the form fields, for example, because the BAPI requires input data that would only confuse the person filling out the form. In this case, the data can be filled in the background. In the SENDIDOC.VBP model, which is stored in the ...\SAPforms\Samples directory, this function is carried out by the CUSTOMER.TXT file in the same directory and by additional VB code.

The control record must also be filled with data. To do so, you must add VB code to the electronic form.