Process diagram
The diagram below demonstrates generalized outbound idoc processing (SAP ECC/S4 → SAP FSM).
Process description
Detailed description of the outbound idoc processing. In this scenario an activity is transferred to SAP FSM with the sending program /PACG/ECM_TRIG_ACTIE - E4C Activity.
Keep in mind that even though most of the steps described below are relevant for the majority of objects, some of them are ACTIVITY-specific.
Event trigger
The outbound processing is started by an event triggered after user’s action on an activity.
Selection class
The general purpose of this method is to prepare a relevant list of objects to pass for the idoc outbound class.
Example of selection logic #1 - sales area assignment check
Check if any sales area is maintained for the target company and object ‘ACTIVITY’ in Sales Area assignment. If not, the object is not relevant for transfer.
If sales areas are found, it is checked if the selected activity’s sales area matches the retrieved values.
Example of selection logic #2 - activity mapping check
Another validation check in the selection class method before proceeding to document generation is ensuring that the activity’s type (in this case it’s ‘ASSI’) can be found in the activity type mapping - transaction /PACG/ECM_ACTMAE - Activity code mapping.
Since such an entry can be found for company 1 and type ‘ASSI’, the execution proceeds.
Generate a document
An idoc document is created by method ‘CREATE’ of class /PACG/ECM_CL_S_IDOC. This is where the basic idoc control data is filled. Based on class assignment of message type ‘/PACG/ECM_ACTIVITYOUT’ (to be precise, the 'Process code' field), a relevant function module name is determined. The retrieved function module’s name is /PACG/ECM_S_IDOC_OUTPUT. It is now called to fill the idoc’s header and segments. Notice which data is passed as parameters.
Fill the idoc - function /PACG/ECM_S_IDOC_OUTPUT
The outbound idoc class entered in the outgoing class assignment customizing will be used to retrieve specific data for each idoc field. In this case it is class /PACG/ECM_CL_S_IDOC_O_ACTI_E. It implements interface method ‘IDOC_OUTPUT’.
Idoc output class
The idoc output class gathers all the additional data for objects retrieved in the selection class so that all relevant idoc fields can be filled with properties.
Back to the document generation
The final result of output idoc class processing is the idoc data table which will be passed back to function /PACG/ECM_S_IDOC_OUTPUT.
Hash handling
If no exception was raised and the class assignment configuration has the ‘Use hash’ checkbox set, a hash will be created for the transferred activity.
Hash handling prevents resending of already transferred idocs. A hash is created for this activity based on the idoc’s content. If the same hash has been generated before for this company, message type and activity number (can be found in table /PACG/ECM_AHASH), the ‘forcesend’ parameter must be checked. In such a case the old hash will be overwritten. Otherwise, the activity won’t be transferred at all.
The idoc will be distributed using the SAP standard function ‘MASTER_IDOC_DISTRIBUTE'.
Back to the selection class
The idoc’s document number is passed back to the selection class method.
Process the idoc
A function module responsible for idoc processing is assigned to ports in transaction WE21.
Idoc segments are read with the function 'EDI_DOCUMENT_OPEN_FOR_PROCESS' based on the imported document number. The function exports the control segment. If no processing errors were raised (e.g. related to idoc’s status) , the function 'EDI_SEGMENTS_GET_ALL' retrieves all the idoc segments.
Send data to the communication channel
Data is sent to the channel with method ‘PROCESS’ of an instance of class /PACG/ECM_CL_S_COM_FACADE. After determination of the communication channel, the data will be passed for sending to the communication channel.
XML transformation
It is in method /PACG/ECM_IF_S_CHANNEL~SEND of class /PACG/ECM_CL_S_CHANNEL_XML_WS where the XML transformation will be called.
The transformation logic is the same for all message types apart from /PACG/ECM_ATTCHMOUT, /PACG/ECM_CHECKLIST_D_O and /PACG/ECM_GENERIC (which require special handling). The outgoing class assignment configuration is read once again, this time to retrieve the XSLT transformation program name. In this case it is /PACG/ECM_OUT_ACTIVITY_1.XSLT. The retrieved XSLT transformation is called.
The source XML will be transformed to FSM-friendly format (tag names will correspond to SAP FSM property names). Currently, the XML reflects the idoc field names, as shown below:
After successful transformation, the XML’s tags correspond to SAP FSM property names:
The XML is then converted into UTF-8 string and certain ASCII codes are removed from it.
Proxy - send the data to the Message Broker
Before sending the data to the Message Broker, the logical port is determined from mapping in table /PACG/ECM_CACC (to be customized with transaction /PACG/ECM_CACC - Company account assignment).
The method ‘SEND_XML_MESSAGES’ of class /PACG/ECM_CL_S_WS_PROXY will be used to pass the XML to a webservice. Sending of XML will be repeated up to 30 times (the loop will be escaped once the sending is successful). Sending failures might be caused by Message Broker disfunction or internal network issues.
Idoc status and log update
Idoc statuses will be updated based on the success of transfer. Document process closing is conducted by function ‘EDI_DOCUMENT_CLOSE_PROCESS’. Finally, the statuses and logs are saved by a commit.
Back to the sending program
The successful transfer is confirmed by logs. A new idoc of type /PACG/ECM_ITYPE_ACTIVITY_OUT can be found in transaction WE02.