Vous êtes sur la page 1sur 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
Z1EMHDR

IDoc Type: ZWKDET02

Fields
SSN
FNAME
LNAME
DOB
Message Type: ZWKDET

Segment
Z1WKDET

IDoc Type: ZCLDET02

Fields
SSN
WEEKNO
TOTHOURS
HRLYRATE
Message Type: ZCLDET

Segment
Z1CLDET

Fields
SSN
CLSITE
WORKDESC

Sender system: YRACLNT100


Receiver system: yhsapdev05/xi_test(File directory)
2. Create Customer Distribution Model
3. 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.

*&---------------------------------------------------------------------*
* Constants
*&---------------------------------------------------------------------*
constants:
*segment names
c_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 type
c_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 type
c_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 data
fs_week_data like z1wkdet, " Employee weekly details data
fs_clientdet_data like z1cldet. " Client details data
*total hours and amount for the summary segment
data: total_hrs_month type i,
total_amt_month type i.
*&---------------------------------------------------------------------*
* Database Tables
*&---------------------------------------------------------------------*
*Application data tables
tables: zempdetail, " Employee header data
zempwkdet. " Employee weekly details data
*&---------------------------------------------------------------------*
* Internal Tables
*&---------------------------------------------------------------------*
*Header details - Header data of employee
data: it_emhdr like zempdetail occurs 0 with header line,
*weekly details - application data
it_wkdet like zempwkdet occurs 0 with header line,
*data records
int_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 generated
it_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 line.
*&---------------------------------------------------------------------*
* 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:

*----------------------------------------------------------------------*
form data_retrieval .
select single *
from zempdetail
where ssn = p_ssn.
if sy-subrc ne 0.
message e001(0) with p_ssn.
exit.
endif.
select *
from zempwkdet
into 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 header
control_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 details
control_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 details
control_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 header
fs_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 record
int_edidd_emhdr-segnam = c_header_segment.
int_edidd_emhdr-sdata = fs_emphdr_data.
append int_edidd_emhdr.
*Employee Weekly details
loop at it_wkdet.
*Fill the weekly details for each week
fs_week_data-weekno = it_wkdet-weekno.

fs_week_data-tothours = it_wkdet-tothours.
fs_week_data-hrlyrate = it_wkdet-hrlyrate.
*Add administrative information to the data record
int_edidd_wkdet-segnam = c_weekly_details_segment.
int_edidd_wkdet-sdata = fs_week_data.
append int_edidd_wkdet.
*Client details of each week
fs_clientdet_data-clsite = it_wkdet-clsite.
fs_clientdet_data-workdesc = it_wkdet-workdesc.
*Add administrative information to the data record
int_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 details
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control = control_record_out_emp
* OBJ_TYPE = ''
* CHNUM = ''
tables
communication_idoc_control = it_comm_idocs_emhdr
master_idoc_data = int_edidd_emhdr
EXCEPTIONS
ERROR_IN_IDOC_CONTROL = 1
ERROR_WRITING_IDOC_STATUS = 2
ERROR_IN_IDOC_DATA = 3
SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
OTHERS = 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 Details
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control = control_record_out_wkdet
* OBJ_TYPE = ''
* CHNUM = ''
tables
communication_idoc_control = it_comm_idocs_wkdet
master_idoc_data = int_edidd_wkdet
EXCEPTIONS
ERROR_IN_IDOC_CONTROL = 1
ERROR_WRITING_IDOC_STATUS = 2
ERROR_IN_IDOC_DATA = 3
SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
OTHERS = 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_wkdet.
write : / 'IDoc generated', it_comm_idocs_wkdet-docnum.
endloop. " loop at it_comm_idocs.
commit work.
ENDIF.
*Employee Client Details
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control = control_record_out_cldet
* OBJ_TYPE = ''
* CHNUM = ''
tables
communication_idoc_control = it_comm_idocs_cldet
master_idoc_data = int_edidd_cldet
EXCEPTIONS
ERROR_IN_IDOC_CONTROL = 1
ERROR_WRITING_IDOC_STATUS = 2
ERROR_IN_IDOC_DATA = 3
SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
OTHERS = 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..

Collect Multiple IDocs to File using BPM


Previous..
Design/Configuration in XI (Middleware)
4. Import IDoc types from Source system
5. First of all we have to create <U>Data type</U> for the flat Receiver as shown in figure

3. Then create <U>Message Type</U> for Target Data: EMP_MT_09 with data type used
emp_file_structure.
4. Create three <U>Message Interface</U> of type <U>Abstract Asynchronous</U> for the IDOCs and
two for the File as follows:
Message Interface
ZEMHDR_MI_ABS_09 (Abstract Asynchronous)
ZWKDET_MI_ABS_09 (Abstract Asynchronous)
ZCLDET_MI_ABS_09 (Abstract Asynchronous)
EMP_MI_ABS_09 (Abstract Asynchronous)
EMP_MI_IB_09 (Inbound Asynchronous)

Message Type
ZEMHDR.ZEMHDR02
ZWKDET.ZWKDET02
ZCLDET.ZCLDET02
EMP_MT_09
EMP_MT_09

5. Create three <u>Message Mapping</u> 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 to
their 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 Abstract
IDOCs and target will be having Abstract Target File type)
ZEMP_TO_ZEMP_ABS

ZEMHDR.ZEMHDR02

ZEMP_MT_09

ZWKDET.ZWKDET02
ZCLDET.ZCLDET02
7. Create Interface Mapping to replicate Business Partner data between two systems.

ZEMHDR_MI_ABS_09
ZWKDET_MI_ABS_09
ZCLDET_MI_ABS_09

ZEMP_MI_ABS_09

8. Create the Integration Process to Collect IDOCs of different types to one place and after the
specified 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:

<u>CollectEmhdr</u> is used to retrieve Abstract form of IDOC type ZEMHDR.ZEMHDR02.


<u>CollectEmhdrlist</u> is used to collect the IDOC of type ZEMHDR.ZEMHDR02 , and so we have
set
its
Multiline
as
true.
Same way for IDOCs of type ZWKDET.ZWKDET02 and ZCLDET.ZCLDET02 we defines the
container
items
as
<u>CollectWkdet
</u>and
<u>Collectcldet</u>
respectively.
For collecting them we again define <u>CollectWkdetlist</u> and <u>CollectCldetlist</u> of type
ZWKDET.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 as
follows:
Let us name it as <u>CorrFileType</u>

10. We
set
the
value
in
<u>Properties</u>
as
follows:
Specify correlation field in XPath option. E.g here we are selecting the<u> SSN</u> as our
Correlation
field.
Once we select the field we find the <u>XPath Expression</u> at bottom as shown in figure.

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

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

Set
Give

<u>Properties</u>
some
Exception

of
name

in

Block
Exception

step
Property.

as
E.g

follows:
TimeOut

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

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

14. Add <u>DEADLINE Step</u> in BPM. It can be added by selecting the Deadline branch submenu
from
the
menu
option<u>
Insert
of
Block</u>.
It
will
look
like
as
in
figure
below.

Set
<u>Properties</u>
of
Deadline
Step
as
follows:
We have to specify the <u>DURATION </u>property which depicts the time for which the block
processing
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 we
add<u>FORK
step </u>in
our
BPM
as
exposed
below:

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

16. We need to collect each type of IDOCs for some time duration (one which we have specified in our
deadline step). So we add <u>LOOP step </u> in our fork branch, which enables to collect IDOCs
for
specified
time
duration.
Our
BPM
looks
like:

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

17. To receive IDOCs into BPM we insert <u>RECEIVE step</u> (as shown below). This will receive
IDOC
of
ZMHDR02
type.

We
set
the
<u>Properties</u>
of
Receive
as
follows:
Message property defines, what type of data is going to receive by the RECEIVE step. As shown in
figure 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 of
correlation (CorrFileType) which we have created in beginning.

18. Add <u>CONTAINER Operation step</u> in our BPM(as shown in figure below). This Step
facilitates
collection
of
IDOCs
which
the
Receive1
step
has
collected.

Set

<u>Properties</u>

of

CONTAINER

as

follows:

In <u>Target Property</u> 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 whose
Multiline
property
we
have
set
as
true.
<u>Operation Property</u> is used to define the operation we want to perform. Here as we want to
append each newly coming IDOC, we are setting its value as APPEND.
Third property which we set here is <u>Expression </u> which will specify the type of IDOC going to
be 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 and
ZCLDET02
also.

For
For

ZWKDET02:
ZCLDET02:

Receive2
Receive3

and
and

Container2
Container3

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

20. Till now we have done everything to collect our IDOCs in our BPM. Once IDOCs are collected after
the specified time interval (2 minutes in our case) a transformation step is required to convert the N
collected
IDOCs
into
one.
Add a <u>TRANSFORMATION step </u>in the BPM. This step is for the N:1 conversion. Our BPM
will
look
like:

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

program we will get the three different source messages in our <u>Source Messages </u> property
(In interface mapping program we have three input Abstract Data).We then fill this value into
CollectEmhdrList , CollectWkdetList, CollectCldetList for ZEMHDR02, ZWKDET02, ZCLDET02
IDOCs
respectively.
These
Lists
are
output
of
Container
Operations
of
Block.
In Third property of transformation we specify the <u>Target Messages</u>. Here we set it as
TargetFile which is of Abstract Target Type as shown in figure below.

21. Once we complete the N:1 transformation of data a <u>SEND step</u> follows. This is as stated in
the
figure
below

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

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..

Collect Multiple IDocs to File using BPM


Previous
Configuration in Integration Directory
Business Process Mangement is an implementation methodology for the management of business process
that 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 Created
in Repository).

3.

Import the Integration Process

As Integration Process is used to hold messages in XI, it should receive the messages and should send
the 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 by
selecting Integration Process, which is created in Repository. This step is to import the Integration
Process as it acts as a Sender/Receiver Service.

4.

Create Communication Channels

Create two Communication Channels of adapter type IDoc and File.


5.

Create Receiver Determination/Inteface Determination/Receiver Agreement

So we need to create 4 receiver Determinations.


First three are used from Source to BPM and fourth one is uded from BPM to Target.

While creating second Receiver Determination, make sure that Sender Server is Integration Process (i.e
imported in one of the above steps). Interface is Abstract Interface and Receiver is actual receiver, in this
case Business System created for File. Interface Determination is created for Inbound File Interface. No
Interface mapping is required, because BPM itself contains mapped data.Unlike in first receiver
determination, 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 from
File.

6.

Save all and activate all.

Vous aimerez peut-être aussi