Idocs in SAP R/3
[30 mn 阅读 - 发表时间 6/13/2005 2:52:29 AM - 对象 : Expert]
|
   
|
作者
2 Customizing of an outbound interface
This chapter approaches the creation of a new outbound interface entirely specific. It uses no one of the standard SAP R/3 structures.
2.1 Creation of a new message type
2.1.1 Creation of a new segment type
Launch the WE31 transaction (Development segments: Initial screen).
Fill the Segment type field with the value Z1VISTAPM then press F5 (Create).

Fill the Short Description field and add as much lines as wished fields in the segment. For each field, give it a name and a Data Element to refer to.

Save.
2.1.2 Creation of a new basic IDoc type
Launch WE30 transaction (Develop IDoc Types: Initial Screen).
Fill the Obj. name field with the value ZVISTAPM01 then press F5 (Create).

In the popup window which appears, choose Create new and fill the Description field.
Select the ZVISTAPM01 header line then choose the Create segment... button. In the popup window which appears, fill the fields like the following:
- Segm.type: Z1VISTAPM
- Mandatory seg.: [checked]
- Minimum number: 1
- Maximum number: 999999

Save.
2.1.3 Creation of a new message type
Launch the WE81 transaction (Display View "EDI: Logical Message Types": Overview).

Choose the Display -> Change button then the New Entries button.
In the Message type column, type the value ZVISTAPM then in the Short text column type a short description.

Save.
2.1.4 Association of the basic IDoc type to the message type
Launch the WE82 transaction (Display View "Output Types and Assignment to IDoc Types": Overview).

Choose the Display -> Change button then the New Entries button.
In the Message Type column, type the value ZVISTAPM. In the Basic Type column, type the value ZVISTAPM01. In the Release column, type the value 620.

2.2 Customizing of a new interface
2.2.1 Creation of a new distribution model view
Launch the BD64 transaction (Display Distribution Model).

Press the Switch between display and edit mode button, then the Create model view button.
In the popup window which appears, enter in the Short text field a short description and in the Technical name field the value YVISTAPM.

Place on the newly created entry then press the Add Message Type button.
In the popup window which appears, enter in the Sender field the name of the local logical system, in the Receiver field the name of the receiving logical system and in the Message type field the name of the message type of the interface.

Validate then save.

2.2.2 Distribute the distribution model view
This step is necessary only if the partner system is a SAP R/3 system. It allows to centralize the changes to make on the interface. Be careful! The partner profiles also have to be generated and managed in the partner system.
Select the recently created view then choose in the menu Edit / Model view / Distribute. In the popup window which appears, the partner system is already selected, there is no need to make other further selection. Validate.
2.2.3 Generate and manage the partner profiles
From the distribution model view (BD64 transaction), place on the message type then choose in the menu Environment / Generate partner profiles, or launch the BD82 transaction (Generating partner profile).
Enter in the Model view field the value YVISTAPM, in the Partner system field the value TIBCO, and choose as Output mode the Collect IDocs and transfer radio button. Press the Execute button.


Check the partner profiles. To do so, launch the WE20 transaction (Partner profiles). Select LS / TIBCO / Outbound parmtrs. / ZVISTAPM.
The port should be checked first, because it is not specified at the generation of the partner profiles level, so it is the first port which is selected by default.
If needed, manage the partner profiles then save.

2.3 Creation of an outbound interface program
2.3.1 Creation of an IDoc generation program
The following code extract contains everything needed to generate an IDoc from data contained in a table. FORM F_110_SEND_IDOC. CONSTANTS: C_MESTYP TYPE EDIDC-MESTYP VALUE 'ZVISTAPM', C_DOCTYP TYPE EDIDC-IDOCTP VALUE 'ZVISTAPM01', C_SEGNAM TYPE EDIDD-SEGNAM VALUE 'Z1VISTAPM'. DATA: I_ZVISTA_PM TYPE ZVISTA_PM_T OCCURS 6000, I_EDIDC TYPE EDIDC OCCURS 0, I_EDIDD TYPE EDIDD OCCURS 0, WA_ZVISTA_PM TYPE ZVISTA_PM_T, WA_EDIDC TYPE EDIDC, WA_EDIDD TYPE EDIDD, WA_Z1VISTAPM TYPE Z1VISTAPM, V_OCCMAX TYPE IDOCSYN-OCCMAX, V_NBSEG TYPE I. CLEAR WA_ZVISTA_PM. CLEAR WA_EDIDC. * Save the message type and the basic IDoc type * in the control segment MOVE C_MESTYP TO WA_EDIDC-MESTYP. MOVE C_DOCTYP TO WA_EDIDC-IDOCTP. * Retrieve the maximum number of segments in the basic IDoc * type SELECT MIN( OCCMAX ) FROM IDOCSYN INTO V_OCCMAX WHERE IDOCTYP EQ C_DOCTYP AND SEGTYP EQ C_SEGNAM. * Save the whole ZVISTA_PM_T table content * in the I_ZVISTA_PM internal table. SELECT * FROM ZVISTA_PM_T INTO CORRESPONDING FIELDS OF TABLE I_ZVISTA_PM. * Create a data segment for each line of I_ZVISTA_PM LOOP AT I_ZVISTA_PM INTO WA_ZVISTA_PM. MOVE-CORRESPONDING WA_ZVISTA_PM TO WA_Z1VISTAPM. CLEAR WA_EDIDD. MOVE C_SEGNAM TO WA_EDIDD-SEGNAM. MOVE WA_Z1VISTAPM TO WA_EDIDD-SDATA. APPEND WA_EDIDD TO I_EDIDD. CLEAR WA_ZVISTA_PM. CLEAR WA_Z1VISTAPM. ENDLOOP. * Count the number of data segments DESCRIBE TABLE I_EDIDD LINES V_NBSEG. * If the number of data segments exceeds the maximum * allowed number, then edit a message in the spool, * then display an error message (quit the program) IF V_NBSEG GT V_OCCMAX. WRITE:/ TEXT-003, V_OCCMAX. MESSAGE E751. ENDIF. * Call the IDoc creation function CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE' EXPORTING MASTER_IDOC_CONTROL = WA_EDIDC TABLES COMMUNICATION_IDOC_CONTROL = I_EDIDC MASTER_IDOC_DATA = I_EDIDD EXCEPTIONS ERROR_IN_IDOC_CONTROL = 1 ERROR_WRITING_IDOC_STATUS = 2 ERROR_IN_IDOC_DATA = 3 SENDING_LOGICAL_SYSTEM_UNKNOWN = 4 OTHERS = 5. * If there was an error, display a message (quit the * program) IF SY-SUBRC NE 0. MESSAGE E746. ENDIF. ENDFORM.
2.3.2 Running of the IDoc sending program
The interface having been customized for a collected mode output, the program created IDoc is not sent immediately to the receiving system. The IDoc stays waiting for processing. It can be viewed in the BD87 transaction (Status Monitor for ALE Messages).

It is possible to press the Process button to send the IDoc which waits for processing. However, if there were several IDocs to be sent in collected mode, pressing the Process button would have sent them one by one instead of sending them in a batch.
Actually, the RSEOUT00 program has to be executed with adequat parameters: Logical message set to the value ZVISTAPM and Output mode set to the value 4.

|