Professional Documents
Culture Documents
INSTOCK TO IPAS
USING EDI WITH IDOC
CHENG ZHANG
INOSSEM CANADA INC.
SUITE 1620, 2075 ROBERT-BOURASSA BLVD., MONTREAL, CANADA
目录
1. Custom IDoc Development Workflow ....................................................................................... 2
2 Develop IDOC....................................................................................................................................... 3
4.1 TCODE: WE57 Link the Function to Message and Basic Type .................................. 19
Figure 1.1 outlines the three steps for building a custom IDoc: develop the IDoc, code
the IDoc function, and configure the interface.
Figure 1.1
2 Develop IDOC
2.1 TCODE: SE11 Creating Custom Table
First, we create the custom table ZSEWM_DELIV. The IDoc will post its data to this table
and it is a mandatory part of the development cycle.
1. Run Transaction SE11 and enter table name ZSEWM_DELIV into the Database table field.
2. Click Create to open the Dictionary:
Figure 2.1
Figure 2.1.1
4. In the Currency/Quantity Fields tab a link must be made between the quantity field MENGE
and a corresponding unit of measure field in an existing table.
5. Save the table and assign it to a transport.
6. Click Technical Settings and set Data Class to APPLI (Transaction Data, Transparent Tables)
and Size Category to 0 (Data records expected: 0 to 4,300).
Figure 2.2
1. We'll first create ZDELISTATUS in the segment editor. Go to Transaction WE31, enter
“ZDELISTATUS” into the Segment type field, and click Create.
2. Create the following fields:
a. Enter “ZTYPE” in Field Name and “ZE_INT_TYPE” in Data element.
b. Enter “ZERNAM” in Field Name and “UNAME” in Data element.
c. The rest of field names are use same way to fill out.
3. Click Save. Assign the segment to a package and a change request.
4. Press (F3) to back out to the segment editor’s opening screen. Release the segment by
selecting menu option Edit • Set Release. Once released, the initial screen will look like
Figure 2.2.1.
Figure 2.2.1
5. Follow the same steps to create and release details segment ZDELILIST.
2.3 TCODE: WE30 Building an IDoc Basic Type
We'll create our custom IDoc basic type with Transaction WE30.
1. Enter "ZINSDELI" into the Obj. name field, select Basic type, and click Create. The Create
Basic Type dialog opens after the system informs you that the name is longer than eight
characters. The following are radio buttons under New basic IDoc type: (Figure 2.3)
Figure 2.3
Figure 2.3.1
2. Select Create new and click OK to open the IDoc type editor. We'll assemble our basic
type from segments in this screen. To add segments, put the cursor on the IDoc type root
name and click Create segment, press (Shift)+(F6), or follow the menu path Edit •->Create
Segment.
Figure 2.3.2
3. The Maintain Attributes dialog opens, as in Figure 8.13. To add header segment ZIVPRH,
do the following:
a. Enter "ZDELISTATUS" in the Segment type field.
b. Select the Mandatory seg. checkbox.
c. Enter "1" in Minimum number and "1" in Maximum number.
Figure 2.3.3
4. Click OK. "ZDELISTATUS" is inserted as a child of the basic type root. Select
"ZDELISTATUS" and click Create segment to add the details segment.
Figure 2.3.4
5. The Segment Hierarchy dialog opens. Select Add segment type as child.
6. Click OK to open the Maintain Attributes dialog. Do the following for the next segment:
a. Enter “ZDELILIST” in the Segment type field.
b. Select the Mandatory seg. checkbox.
c. Enter "1" in Minimum number and "999999" in Maximum number.
Figure 2.3.5
7. ZDELILIST is added as a child segment to ZDELISTATUS, as shown in the basic type editor
in Figure 2.3.6.
Figure 2.3.6
8. Double-click ZDELILIST to view the Maintain Attributes dialog. The parent segment is
ZDELISTATUS, and the hierarchy level is 2.
Figure 2.3.7
9. Save the basic type and assign it to a package and a change request. Back out of the edit
window. Release the IDoc basic type by selecting menu option Edit • Set Release.
1. Use Transaction WE81 and click Display Change (menu option Table View • Display ->
Change).
2. Click New Entries (menu option Edit • New Entries) to open the Overview of Added Entries
screen.
3. Enter " ZINS10 " in Message type and a description of the message in the Short text field,
as shown in Figure 2.4.
Figure 2.4
1. Click Display Change (menu option Table View • Display -> Change)
2. Then click New Entries (menu option Edit • New Entries) to open the Overview of Added
Entries screen.
3. Enter the following values into the table control, as illustrated in Figure 8.16:
a. Enter “ZINS10” in the Message type field.
b. Enter “ZINSDELI” in the Basic type field.
c. Enter version "740" (your current SAP system release) in the Release field.
4. Save the entry and assign it to a customizing request.
1. Run Transaction SE80 and click Edit Object at the top of the Object Navigator window. 2.
Select the Function group tab, enter "ZWM_INSTOCK_IPAS" in the Group name field, and
click Create.
Figure 3.1
2. The Create Function Group dialog opens. Enter a short description in the Short text field
and click Save.
3. Assign the function group to a package and a change request.
1. Right Click Function Group, select create, click function module, enter the function name
"ZMW_IPAS_10".
Figure 3.2
3. The Import parameters screen of the Function Builder opens. We'll use standard import
parameters that will be passed to the function by the IDoc interface at runtime.
4. Enter the following values illustrated in Figure 3.2.1.
Figure 3.2.1
5. Export parameters return workflow and other information to the IDoc interface at
runtime. You can also return document numbers and other application data for reporting.
Click the Export tab and enter the values illustrated in Figure 3.2.2.
Figure 3.2.2
6. Click the Tables tab and enter the values for the internal tables listed in Figure 3.2.3. The
tables will pass data in and out of the function. We’re most interested in the IDoc
control, data, and status records. We won't add any exceptions for this example.
Figure 3.2.3
7. Click the Source code tab and enter the function's code.
function zwm_ipas_10.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
*" EXPORTING
*" VALUE(WORKFLOW_RESULT) LIKE BDWF_PARAM-RESULT
*" VALUE(APPLICATION_VARIABLE) LIKE BDWF_PARAM-APPL_VAR
*" VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK
*" VALUE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS
*" VALUE(MBLNR) TYPE MKPF-MBLNR
*" VALUE(MJAHR) TYPE MKPF-MJAHR
*" VALUE(VBELN) TYPE LIKP-VBELN
*" VALUE(RETURN) TYPE BAPIRET2
*" TABLES
*" IDOC_CONTRL STRUCTURE EDIDC
*" IDOC_DATA STRUCTURE EDIDD
*" IDOC_STATUS STRUCTURE BDIDOCSTAT
*" RETURN_VARIABLES STRUCTURE BDWFRETVAR
*" SERIALIZATION_INFO STRUCTURE BDI_SER
*" EXCEPTIONS
*" WRONG_FUNCTION_CALLED
*"----------------------------------------------------------------------
gt_deliv1-vbeln = gs_list-vbeln.
gt_deliv1-posnr = gs_list-posnr.
gt_deliv1-matnr = gs_list-matnr.
gt_deliv1-charg = gs_list-charg.
gt_deliv1-lgort = gs_list-lgort.
gt_deliv1-dlv_qty = gs_list-dlv_qty.
gt_deliv1-dlv_qty_imunit = gs_list-dlv_qty_imunit.
gt_deliv1-fact_unit_nom = gs_list-fact_unit_nom.
gt_deliv1-fact_unit_denom = gs_list-fact_unit_denom.
gt_deliv1-base_uom = gs_list-base_uom.
gt_deliv1-base_uom_iso = gs_list-base_uom_iso.
gt_deliv1-zdjbh = gs_list-zdjbh.
gt_deliv1-zdjxm = gs_list-zdjxm.
gt_deliv1-posnv = gs_list-posnv.
gt_deliv1-extra1 = gs_list-extra1.
gt_deliv1-extra2 = gs_list-extra2.
gt_deliv1-extra3 = gs_list-extra3.
gt_deliv1-extra4 = gs_list-extra4.
gt_deliv1-extra5 = gs_list-extra5.
gt_deliv1-extra6 = gs_list-extra6.
gt_deliv1-extra7 = gs_list-extra7.
gt_deliv1-extra8 = gs_list-extra8.
gt_deliv1-extra9 = gs_list-extra9.
gt_deliv1-extra10 = gs_list-extra10.
append gt_deliv1.
clear gt_deliv1.
endcase.
endloop.
*-------------------------------------------------------------------
if sy-subrc = 0.
*success message to status record
clear idoc_status.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-msgty = 's'.
idoc_status-msgid = 'ZEDI01'.
idoc_status-msgno = '001'.
idoc_status-status = '53'.
idoc_status-msgv1 = ls_data-message.
append idoc_status.
else.
*verify record count and total before updating.
clear idoc_status.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-msgty = 'e'.
idoc_status-msgid = 'ZEDI01'.
idoc_status-msgno = '002'.
idoc_status-status = '51'.
idoc_status-msgv1 = ls_data-message.
append idoc_status.
endif.
endloop.
ENDFUNCTION.
This code is stripped down to its essentials. The control and data records are imported into the
function at runtime through the IDOC_CNTRL and IDOC_DATA internal tables. The program logic
follows:
4 Configure Interfaces
4.1 TCODE: WE57 Link the Function to Message and Basic Type
First up is to link the custom function to our logical message and basic type.
1. Go to Transaction WE57, and click Display -> Change (menu path Table View • Display ->
Change)
2. Click New Entries (or press F5) to open the Details of Added Entries screen and enter the
following values into it:
a. Enter "ZWM_IPAS_10" into the Function Module field.
b. Select Function module from the Function Type dropdown.
c. Enter "ZINSDELI" in the Basic type field.
d. Enter "ZINS10" in the Message Type field.
e. Select Inbound from Direction dropdown.
Figure 4.1
3. Click Save and assign the changes to a customizing request. The screen should look like
Figure 4.1 after you're done.
4.2 TCODE: BD51 Set Attributes for the Function
To set attributes for the function, follow these steps:
Figure 4.2
3. Save and assign the attributes to a transport. The screen should look like Figure 4.2.
Don't forget to save. This completes the link between the process code, the logical
message, and the custom function module. All these objects are now ready to be used in
a partner profile.
So, we'll create a partner profile with partner type LI for vendor.
1. Run Transaction WE20, select the Partner Type LI folder, and create a vendor partner
profile header for DSI with partner number DISK01.
2. Save the general view and create inbound parameters to add message type ZINS10. Enter
the following values into the Inbound parameters screen:
a. Enter "LS" in the Partner Role field.
b. Enter "ZINS10" in the Message type field.
c. Enter "ZINSDELI" in the Process code field.
d. Set Trigger Immediately as the processing mode. This is a simple table insert that
comes in once a day and doesn’t involve a lot of processing, so we won't
schedule a background job.
Figure 4.5
3. Save the partner profile. The finished product should look like the inbound partner profile
in Figure 4.5.
1. Proof of concept
Confirm use of a message type to post against an SAP document or data record
2. Posting requirements
Confirm data required to post an IDoc to an SAP document or record
3. Configuration
Confirm IDoc configuration settings such as message control, partner profiles, and
ports
4. Development
Debug IDoc functions and user exits
Inbound IDocs can create a business document through Transaction WE19, making it
the place to go to identify the message type and data requirements for posting to a
particular SAP document or transaction.
The Transaction WE19 selection screen offers several options for processing IDocs; these
are shown in Figure 20.1. For inbound testing, we use BasicTyp or Via message type.
Enter the message type "ZINS10", we'll see the structure of the idoc.
Double click each segment to fill out all the mandatory fields.
Then click Standard inbound button on the menu. we will get the generated idoc
number.
Now go to Tcode BD87, enter the idoc number you just got, and see the status of this
idoc whether it shows error message or passed.