(is) Collect Multiple IDOCs to File Using BPM

Embed Size (px)

Citation preview

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    1/19

    Collect Multiple IDocs to File using BPM

    By Suraj Kumar Pabbathi, PI Competency Lead, YASH Technologies

    1. Create and configure the IDocs in Source system

    For eg:-

    IDoc Type: ZEMHDR02 Message Type: ZEMHDR

    Segment Fields

    Z1EMHDR SSN

    FNAME

    LNAME

    DOB

    IDoc Type: ZWKDET02 Message Type: ZWKDET

    Segment Fields

    Z1WKDET SSN

    WEEKNO

    TOTHOURS

    HRLYRATE

    IDoc Type: ZCLDET02 Message Type: ZCLDET

    Segment Fields

    Z1CLDET

    SSN

    CLSITE

    WORKDESC

    Sender system: YRACLNT100

    Receiver system: yhsapdev05/xi_test(File directory)

    2. Create Customer Distribution Model3. Create custom program to generate three custom IDocs

    *&---------------------------------------------------------------------**& Report ZRBDSEEMP **& **&---------------------------------------------------------------------**& **& **&---------------------------------------------------------------------*

    REPORT ZRBDSEEMP .*&---------------------------------------------------------------------** Parameters*&---------------------------------------------------------------------*selection-screen : begin of block b1 with frame title text-001.*object key (social securtiy number for the employee)parameters: p_ssn like zempdetail-ssn.

    *destination system

    parameters: p_logsys like tbdlst-logsys.selection-screen: end of block b1.

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    2/19

    *&---------------------------------------------------------------------** Constants*&---------------------------------------------------------------------*constants:*segment namesc_header_segment like edidd-segnam value 'Z1EMHDR',c_weekly_details_segment like edidd-segnam value 'Z1WKDET',

    c_client_details_segment like edidd-segnam value 'Z1CLDET',*message typec_emp_header_msg_type like edidc-mestyp value 'ZEMPHDR',c_emp_work_det_msg_type like edidc-mestyp value 'ZWKDET',c_emp_client_det_msg_type like edidc-mestyp value 'ZCLDET',*IDoc typec_emp_header_idoc_type like edidc-idoctp value 'ZEMPHDR02',c_emp_work_det_idoc_type like edidc-idoctp value 'ZWKDET02',c_emp_client_det_idoc_type like edidc-idoctp value 'ZCLDET02'.

    *&---------------------------------------------------------------------** Data declarations*&---------------------------------------------------------------------**IDoc control record

    data: control_record_out_emp like edidc,control_record_out_wkdet like edidc,control_record_out_cldet like edidc.data: fs_emphdr_data like z1emhdr, " Employee header datafs_week_data like z1wkdet, " Employee weekly details datafs_clientdet_data like z1cldet. " Client details data*total hours and amount for the summary segmentdata: total_hrs_month type i,total_amt_month type i.*&---------------------------------------------------------------------** Database Tables*&---------------------------------------------------------------------**Application data tablestables: zempdetail, " Employee header datazempwkdet. " Employee weekly details data

    *&---------------------------------------------------------------------** Internal Tables*&---------------------------------------------------------------------**Header details - Header data of employeedata: it_emhdr like zempdetail occurs 0 with header line,*weekly details - application datait_wkdet like zempwkdet occurs 0 with header line,*data recordsint_edidd_emhdr like edidd occurs 0 with header line,int_edidd_wkdet like edidd occurs 0 with header line,int_edidd_cldet like edidd occurs 0 with header line,*communication IDocs generatedit_comm_idocs_emhdr like edidc occurs 0 with header line,it_comm_idocs_wkdet like edidc occurs 0 with header line,

    it_comm_idocs_cldet like edidc occurs 0 with header l ine.

    *&---------------------------------------------------------------------** Program Logic*&---------------------------------------------------------------------*start-of-selection.perform data_retrieval.perform build_control_record.perform build_data_records.perform pass_control_ale_layer.

    *&---------------------------------------------------------------------*

    *& Form data_retrieval*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** Description:

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    3/19

    *----------------------------------------------------------------------*

    form data_retrieval .select single *from zempdetailwhere ssn = p_ssn.if sy-subrc ne 0.

    message e001(0) with p_ssn.exit.endif.

    select *from zempwkdetinto table it_wkdet where ssn = p_ssn.if sy-subrc ne 0.message e001(0) with p_ssn.exit.endif.endform. " data_retrieval*&---------------------------------------------------------------------**& Form build_control_record

    *&---------------------------------------------------------------------** text*----------------------------------------------------------------------***----------------------------------------------------------------------*form build_control_record .*Fill control record information for employee headercontrol_record_out_emp-mestyp = c_emp_header_msg_type.control_record_out_emp-idoctp = c_emp_header_idoc_type.control_record_out_emp-rcvprt = 'LS'.control_record_out_emp-rcvprn = p_logsys.

    *Fill control record information for employee work detailscontrol_record_out_wkdet-mestyp = c_emp_work_det_msg_type.control_record_out_wkdet-idoctp = c_emp_work_det_idoc_type.

    control_record_out_wkdet-rcvprt = 'LS'.control_record_out_wkdet-rcvprn = p_logsys.

    *Fill control record information for employee client detailscontrol_record_out_cldet-mestyp = c_emp_client_det_msg_type.control_record_out_cldet-idoctp = c_emp_client_det_idoc_type.control_record_out_cldet-rcvprt = 'LS'.control_record_out_cldet-rcvprn = p_logsys.

    endform. " build_control_record*&---------------------------------------------------------------------**& Form build_data_records*&---------------------------------------------------------------------** text

    *----------------------------------------------------------------------***----------------------------------------------------------------------*form build_data_records .*Employee headerfs_emphdr_data-lname = zempdetail-lname.fs_emphdr_data-fname = zempdetail-fname.fs_emphdr_data-ssn = zempdetail-ssn.fs_emphdr_data-dob = zempdetail-dob.

    *Fill the administrative section of the data recordint_edidd_emhdr-segnam = c_header_segment.int_edidd_emhdr-sdata = fs_emphdr_data.append int_edidd_emhdr.

    *Employee Weekly detailsloop at it_wkdet.*Fill the weekly details for each weekfs_week_data-weekno = it_wkdet-weekno.

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    4/19

    fs_week_data-tothours = it_wkdet-tothours.fs_week_data-hrlyrate = it_wkdet-hrlyrate.

    *Add administrative information to the data recordint_edidd_wkdet-segnam = c_weekly_details_segment.int_edidd_wkdet-sdata = fs_week_data.append int_edidd_wkdet.

    *Client details of each weekfs_clientdet_data-clsite = it_wkdet-clsite.fs_clientdet_data-workdesc = it_wkdet-workdesc.

    *Add administrative information to the data recordint_edidd_cldet-segnam = c_client_details_segment.int_edidd_cldet-sdata = fs_clientdet_data.append int_edidd_cldet.endloop. " loop at it_wkdet.endform. " build_data_records*&---------------------------------------------------------------------**& Form pass_control_ale_layer*&---------------------------------------------------------------------*

    * text*----------------------------------------------------------------------***----------------------------------------------------------------------*form pass_control_ale_layer .*For Employee header detailsCALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'EXPORTINGmaster_idoc_control = control_record_out_emp* OBJ_TYPE = ''* CHNUM = ''tablescommunication_idoc_control = it_comm_idocs_emhdrmaster_idoc_data = int_edidd_emhdrEXCEPTIONS

    ERROR_IN_IDOC_CONTROL = 1ERROR_WRITING_IDOC_STATUS = 2ERROR_IN_IDOC_DATA = 3SENDING_LOGICAL_SYSTEM_UNKNOWN = 4OTHERS = 5.IF sy-subrc 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.message e000(0) with p_ssn.else.loop at it_comm_idocs_emhdr.write : / 'IDoc generated', it_comm_idocs_emhdr-docnum.endloop. " loop at it_comm_idocs.

    commit work.ENDIF.

    *For Employee Weekly DetailsCALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'EXPORTINGmaster_idoc_control = control_record_out_wkdet* OBJ_TYPE = ''* CHNUM = ''tablescommunication_idoc_control = it_comm_idocs_wkdetmaster_idoc_data = int_edidd_wkdetEXCEPTIONSERROR_IN_IDOC_CONTROL = 1

    ERROR_WRITING_IDOC_STATUS = 2ERROR_IN_IDOC_DATA = 3SENDING_LOGICAL_SYSTEM_UNKNOWN = 4OTHERS = 5.

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    5/19

    IF sy-subrc 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.message e000(0) with p_ssn.else.loop at it_comm_idocs_wkdet.write : / 'IDoc generated', it_comm_idocs_wkdet-docnum.

    endloop. " loop at it_comm_idocs.commit work.ENDIF.

    *Employee Client DetailsCALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'EXPORTINGmaster_idoc_control = control_record_out_cldet* OBJ_TYPE = ''* CHNUM = ''tablescommunication_idoc_control = it_comm_idocs_cldetmaster_idoc_data = int_edidd_cldetEXCEPTIONS

    ERROR_IN_IDOC_CONTROL = 1ERROR_WRITING_IDOC_STATUS = 2ERROR_IN_IDOC_DATA = 3SENDING_LOGICAL_SYSTEM_UNKNOWN = 4OTHERS = 5.IF sy-subrc 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.message e000(0) with p_ssn.else.loop at it_comm_idocs_cldet.write : / 'IDoc generated', it_comm_idocs_cldet-docnum.endloop. " loop at it_comm_idocs.commit work.

    ENDIF.endform. " pass_control_ale_layer

    contd..

    http://www.saptechnical.com/Tutorials/XI/CollectMultipleIDocs/Collect2.htmhttp://www.saptechnical.com/Tutorials/XI/CollectMultipleIDocs/Collect2.htmhttp://www.saptechnical.com/Tutorials/XI/CollectMultipleIDocs/Collect2.htm
  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    6/19

    Collect Multiple IDocs to File using BPM

    Previous..

    Design/Configuration in XI (Middleware)

    4. Import IDoc types from Source system5. First of all we have to create Data type for the flat Receiver as shown in figure

    3. Then create Message Type for Target Data: EMP_MT_09 with data type used

    emp_file_structure.4. Create three Message Interface of type Abstract Asynchronous for the IDOCs and

    two for the File as follows:

    Message Interface Message Type

    ZEMHDR_MI_ABS_09 (Abstract Asynchronous) ZEMHDR.ZEMHDR02

    ZWKDET_MI_ABS_09 (Abstract Asynchronous) ZWKDET.ZWKDET02

    ZCLDET_MI_ABS_09 (Abstract Asynchronous) ZCLDET.ZCLDET02

    EMP_MI_ABS_09 (Abstract Asynchronous) EMP_MT_09

    EMP_MI_IB_09 (Inbound Asynchronous) EMP_MT_09

    5. Create three Message Mapping to convert Outbound type of IDOC into Abstract type so that

    we can collect it in our BPM. Message Mapping for conversion of three different types of IDOCs totheir Abstract type are as follows:

    ZEMHDR_MM_TO_ZEMHDR_ABS

    ZWKDET_MM_TO_ZWKDET_ABS

    ZCLDET_MM_TO_ZCLDET_ABS

    6. Below mapping is for N:1 transformation. (Here input will be having three different types of AbstractIDOCs and target will be having Abstract Target File type)

    ZEMP_TO_ZEMP_ABS

    ZEMHDR.ZEMHDR02 ZEMP_MT_09

    http://www.saptechnical.com/Tutorials/XI/CollectMultipleIDocs/Collect1.htmhttp://www.saptechnical.com/Tutorials/XI/CollectMultipleIDocs/Collect1.htmhttp://www.saptechnical.com/Tutorials/XI/CollectMultipleIDocs/Collect1.htm
  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    7/19

    ZWKDET.ZWKDET02

    ZCLDET.ZCLDET02

    7. Create Interface Mapping to replicate Business Partner data between two systems.

    ZEMHDR_MI_ABS_09 ZEMP_MI_ABS_09ZWKDET_MI_ABS_09

    ZCLDET_MI_ABS_09

    8. Create the Integration Process to Collect IDOCs of different types to one place and after thespecified time interval it will be posted to one flat file in some specific format.

    Let see the step by step BPM formation for collecting multiple IDOCs:

    First of all create Container content as:

    CollectEmhdr is used to retrieve Abstract form of IDOC type ZEMHDR.ZEMHDR02.

    CollectEmhdrlist is used to collect the IDOC of type ZEMHDR.ZEMHDR02 , and so we haveset its Multiline as true.

    Same way for IDOCs of type ZWKDET.ZWKDET02 and ZCLDET.ZCLDET02 we defines thecontainer items as CollectWkdet and Collectcldet respectively.For collecting them we again define CollectWkdetlist and CollectCldetlist of typeZWKDET.ZWKDET02 and ZCLDET.ZCLDET02 respectively with their Multiline property as true.

    9. As we are going to collect three different types of IDOCs in our BPM, we specify the Correlation asfollows:Let us name it as CorrFileType

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    8/19

    10. We set the value in Properties as follows:Specify correlation field in XPath option. E.g here we are selecting the SSN as ourCorrelation field.

    Once we select the field we find the XPath Expression at bottom as shown in figure.

    11. Same way select the Correlation Field for all three IDOC types. And after selection of values we canobserve our Properties screen as exposed below:

    12. Now it is time to toil with graphical editor. First step is to add Block step to our BPM.

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    9/19

    Set Properties of Block step as follows:Give some Exception name in Exception Property. E.g TimeOut

    13. Add EXCEPTION Step to BPM. We can insert this step by Right clicking on Block and thenselect the Insert option of menu and then select Exception Branch option ofsubmenu. The menu looks like as shown in figure below:

    After adding the Exception Block we have to set its Properties as shown in figure below:(TimeOut is Exception name which we have given in our Block step)

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    10/19

    14. Add DEADLINE Step in BPM. It can be added by selecting the Deadline branch submenufrom the menu option Insert of Block.It will look like as in figure below.

    Set Properties of Deadline Step as follows:We have to specify the DURATION property which depicts the time for which the blockprocessing will be done. (e.g 2 Minutes in our example).

    15. As in our paradigm, three different types of IDOCs going to be collected in BPM, so weaddFORK step in our BPM as exposed below:

    Set the Properties of Fork step as follows:As we need to have three different branches in our fork, we set the NECESSARY BRANCHproperty as 3 as shown in figure below.

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    11/19

    16. We need to collect each type of IDOCs for some time duration (one which we have specified in ourdeadline step). So we add LOOP step in our fork branch, which enables to collect IDOCs

    for specified time duration. Our BPM looks like:

    Set the Property of Loop Step as follows:Condition (1=1) indicates the Infinite loop. Once we click on the condition we get condition editor andthere we set our left operand and right operand as 1 (as shown in figure below). This enables theexecution of the loop for the time period we have specified in our deadline branch.

    17. To receive IDOCs into BPM we insert RECEIVE step (as shown below). This will receiveIDOC of ZMHDR02 type.

    We set the Properties of Receive as follows:Message property defines, what type of data is going to receive by the RECEIVE step. As shown infigure below, we have selected CollectEmhdr, as this Receive step will use to collect

    ZEMHDR.ZEMHDR02 IDOCs. Second property we set here is the correlation; here we give name ofcorrelation (CorrFileType) which we have created in beginning.

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    12/19

    18. Add CONTAINER Operation step in our BPM(as shown in figure below). This Stepfacilitates collection of IDOCs which the Receive1 step has collected.

    Set Properties of CONTAINER as follows:

    In Target Property we specify the name where we want to collect our IDOCs.As shown in figure below we are selecting CollectEmhdrList which is of Abstract type and whoseMultiline property we have set as true.

    Operation Property is used to define the operation we want to perform. Here as we want toappend each newly coming IDOC, we are setting its value as APPEND.

    Third property which we set here is Expression which will specify the type of IDOC going tobe collected by the CONTAINER. Here our container will be collecting the ZEMHDR type of IDOC so

    we specify Expression as CollectEmhdr which is again of the Abstract type of IDOC.

    19. Same as ZEMDHR02 we have to add receive and container operation for ZWKDET02 andZCLDET02 also.

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    13/19

    For ZWKDET02: Receive2 and Container2For ZCLDET02: Receive3 and Container3

    As shown in figure below we find three branches in our fork and each branch is collectingZEMHDR02, ZWKDET02 and ZCLDET02 IDOCs respectively for the time interval which we havespecified in our deadline branch.

    20. Till now we have done everything to collect our IDOCs in our BPM. Once IDOCs are collected afterthe specified time interval (2 minutes in our case) a transformation step is required to convert the Ncollected IDOCs into one.

    Add a TRANSFORMATION step in the BPM. This step is for the N:1 conversion. Our BPMwill look like:

    Set the Properties of TRANSFORMATION as follows:Interface Mapping property is place where we specify our Interface mapping which willconvert our N collected IDOCs into one. In our paradigm as soon as we select our Interface Mapping

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    14/19

    program we will get the three different source messages in our Source Messages property(In interface mapping program we have three input Abstract Data).We then fill this value intoCollectEmhdrList , CollectWkdetList, CollectCldetList for ZEMHDR02, ZWKDET02, ZCLDET02IDOCs respectively.These Lists are output of Container Operations of Block.

    In Third property of transformation we specify the Target Messages. Here we set it asTargetFile which is of Abstract Target Type as shown in figure below.

    21. Once we complete the N:1 transformation of data a SEND step follows. This is as stated in

    the figure below

    We set the Property of Send as follows:Set the Message property as TargetFile which is of Abstract type of output file and output ofour N:1 transformation step as shown in figure below.

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    15/19

    Thats all we need to follow for collecting IDOCs in BPM (N:1) in Integration Repository.

    Configuration in Integration directory follows from next page..

    contd..

    http://www.saptechnical.com/Tutorials/XI/CollectMultipleIDocs/Collect3.htmhttp://www.saptechnical.com/Tutorials/XI/CollectMultipleIDocs/Collect3.htmhttp://www.saptechnical.com/Tutorials/XI/CollectMultipleIDocs/Collect3.htm
  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    16/19

    Collect Multiple IDocs to File using BPM

    Previous

    Configuration in Integration Directory

    Business Process Mangement is an implementation methodology for the management of business processthat interacts with people and systems both within and across the organization.

    When to use BPM

    1. Control/Monitor the messages in XI

    2. Collect/Merge the messages in XI

    3. Split the messages in XI

    4. To Multicast an Message

    5. Send an Alert.

    1. Create a configuration scenario

    2. Create Business System/Busines Service

    In Business Service mention Inbound Interfaces and Outbound Interfaces as shown below (i.e Createdin Repository).

    http://www.saptechnical.com/Tutorials/XI/CollectMultipleIDocs/Collect2.htmhttp://www.saptechnical.com/Tutorials/XI/CollectMultipleIDocs/Collect2.htmhttp://www.saptechnical.com/Tutorials/XI/CollectMultipleIDocs/Collect2.htm
  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    17/19

    3. Import the Integration Process

    As Integration Process is used to hold messages in XI, it should receive the messages and should sendthe messages. So Integration Process itself acts as a Receiver Service and Sender Service.

    After clicking on New in the following screen, you can create Integration Process in Directory byselecting Integration Process, which is created in Repository. This step is to import the Integration

    Process as it acts as a Sender/Receiver Service.

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    18/19

  • 8/10/2019 (is) Collect Multiple IDOCs to File Using BPM

    19/19

    While creating second Receiver Determination, make sure that Sender Server is Integration Process (i.eimported in one of the above steps). Interface is Abstract Interface and Receiver is actual receiver, in thiscase Business System created for File. Interface Determination is created for Inbound File Interface. NoInterface mapping is required, because BPM itself contains mapped data.Unlike in first receiverdetermination, in this case Receiver Agreement is required, as file is a receiver.

    Following screen explains the Fourth Receiver Determination, where actual receivers are determined.Make sure that Sender service is BPM and Receiver service is actual Business Service created fromFile.

    6. Save all and activate all.