SAP Process Order IDoc LOIPRO – Structure, User-Exit and Outbound Processing

SAP Process Order

SAP Process Order IDoc in detail is the main topic of the following SAP ABAP Tutorial.
The topics will be divided into the following 4 subtopics:

  • First, the SAP Process Order IDoc structure LOIPRO will be detailed. (Part 1)
  • Second How To trigger IDOC LOIPRO when PO Changed/Created(Part 1)
  • Third, the easiest way to Generate Outbound IDoc LOIPRO for SAP PO. (Part 1)
  • Last, how to fill the extra segment of an IDoc LOIPRO extension. (part 2)

SAP Process Order IDoc LOIPRO Structure

LOIPRO Message & Basic Type

LOIPRO is the Message Type for SAP Process Order IDoc. The basic Types available in ECC 6 system for example are:

  • LOIPRO01 SAP IDOC for Master production order
  • LOIPRO02 SAP IDOC for Production Order (MES Integration)
  • LOIPRO03 SAP IDOC for Production Order (SAP ME Integration)

Let focus on SAP Process Order Master Data (LOIPRO01). For the rest of the ABAP Tutorial.
Read more on SAP Process Order on help.sap.com (Integration of Production Orders)

IDoc LOIPRO01 Structure

In a last SAP system version, here the different segments which compose the IDoc LOIPRO01 for Master production order

  • E1AFKOL Production order header (AFKO, AUFK)
    • E1JSTKL Production order status for header (JEST)
    • E1AFABL Master Production Order Relationships (AFAB)
    • E1AFFLL Production Order Sequences (AFFL)
      • E1AFVOL Production order processes (AFVV, AFVC)
        • E1JSTVL Production order status for process (JEST)
        • E1RESBL Reservation/dependent requirements (RESB)
        • E1AFUVL Production Order Suboperations (AFVV,AFVC)
          • E1JSTUL Production order status for subprocesses (JEST)
          • E1KBEUL Capacity requirements records for subprocesses (KBED)
        • E1KBEDL Capacity requirements records for processes (KBED)
    • E1AFPOL Production order items (AFPO)

Generate Outbound IDoc LOIPRO for SAP PO

Thanks to a SAP Standard Function module there is no need to write the LOIPRO01 IDoc Segment by segment and field by field. To generate an outbound IDoc for SAP Process Order, call the function CLOI_MASTERIDOC_CREATE_LOIPRO (Create master IDOC for message type LOIPRO).

Here the signature of CLOI_MASTERIDOC_CREATE_LOIPRO function:

function 'CLOI_MASTERIDOC_CREATE_LOIPRO'.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(OPT_SYS) LIKE  TBDLST-LOGSYS
*"     VALUE(MESSAGE_TYPE) LIKE  TBDME-MESTYP
*"     REFERENCE(NO_COMMIT) TYPE  CHAR1 OPTIONAL
*"     REFERENCE(IN_UPDATE_TASK) TYPE  CHAR1 OPTIONAL
*"     REFERENCE(IT_SERIAL_NUMBERS) TYPE  CO_RSEROB_TAB OPTIONAL
*"     REFERENCE(IT_PRT) TYPE  OPS_GT_AFFHD OPTIONAL
*"     REFERENCE(IT_TLINEKOM) TYPE  CO_MES_TLINEKOM_T OPTIONAL
*"     REFERENCE(IT_THEAD) TYPE  CO_MES_THEAD_T OPTIONAL
*"     REFERENCE(IT_AFDLD) TYPE  AFDLD_TAB OPTIONAL
*"     REFERENCE(IT_INSP_SPEC) TYPE  COMES_INSP_CHAR_T OPTIONAL
*"     REFERENCE(IT_INSP_OPER_SAMPLE_SIZE) TYPE
*"        COMES_INSP_OPER_SAMPLE_SIZE_T OPTIONAL
*"  EXPORTING
*"     REFERENCE(ET_CREATED_IDOCS) TYPE  COMES_INT_CREATED_IDOCS_T
*"  TABLES
*"      ORDER_DATA TYPE  CLOI_AFKO_TAB
*"----------------------------------------------------------------------

You have with all the information, the different pieces how to trigger ?LOIPRO01 Idoc when SAP Process Order is created or updated even how to fill the extension segments for the SAP Process Order IDOC.

SAP PO IDoc LOIPRO Extension

For most of the case, the Standard IDoc LOIPRO01 is enough to replicate through ALE the Process Order.
If you want to extend the LOIPRO01 IDoc, first create the extra segments in WE31,then create a new Extension for LOIPRO01 in WE30 and assign the new segments.

IDoc LOIPRO01 UserExit

The question now, is how to fill the extra segments for LOIPRO extension ?

Simply, use the UserExit, EXIT_SAPLLOI1_002. Do not forget to use a WHEN Statement in order to process the business logic only for the extension you have created.
An example of implementation in the EXIT_SAPLL01_002 include would be

" User Exit for SAP Process Order LOIPRO IDoc 
CASE message_type.
  WHEN 'ZLOIPRO'.
    " write here how to fill LOIPRO extension
  WHEN OTHERS.
ENDCASE.

For information, the EXIT_SAPLLO1_00* exits are:

User Exits for LOI Interface Description
EXIT_SAPLLOI1_001 User exit for planned orders
EXIT_SAPLLOI1_002 User exit for production orders
EXIT_SAPLLOI1_003 User exit for current stock/requirements lists
EXIT_SAPLLOI1_004 User exit for run schedule headers
EXIT_SAPLLOI1_005 User exit for BOMs
EXIT_SAPLLOI1_006 User exit for routing
EXIT_SAPLLOI1_007 User exit for work centers
EXIT_SAPLLOI1_008 User exit for hierarchies/resource networks
EXIT_SAPLLOI1_009 User exit for calendars

How To trigger IDOC LOIPRO when PO Changed/Created

Continue to the next post explaining How To trigger IDOC LOIPRO when PO Changed/Created