bm_batch management batch information from non-sap systems using sap mii

35
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 1 Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII Applies to: Batch History functionality (EhP4 release) Summary Today’s manufacturing scenario, customers store batch history information in different SAP and non SAP systems. From Good Manufacturing Practice guidelines it is important for customers to trace the history of manufacture of each batch. The Batch History functionality in EhP4 release delivers to trace the history of batch maintained in different SAP ERP and non SAP systems. The Batch History functionality is enhancement to the existing Batch Information Cockpit feature. This paper addresses how we can leverage SAP MII (Manufacturing Integration and Intelligence) in obtaining batch information in non SAP systems and viewed from Batch Information Cockpit Author(s): Pradip Ray Company: SAP Labs India Created on: 01 September 2008 Author Bio Pradip Ray has been working with SAP Labs since 2006 and is part of the Manufacturing development team in Bangalore with main focus on manufacturing integration and collaboration projects. Before he moved to SAP, he worked for a steel manufacturing company and was involved in Level-1 and Level-2 automation projects. He has completed his Instrumentation Engineering from National Institute of Technology, Trichy.

Upload: gautam-sapre

Post on 25-Oct-2014

166 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 1

Batch History: How to Guide ongetting Batch information fromnon SAP systems using SAP MII

Applies to:Batch History functionality (EhP4 release)

SummaryToday’s manufacturing scenario, customers store batch history information in different SAP and non SAPsystems. From Good Manufacturing Practice guidelines it is important for customers to trace the history ofmanufacture of each batch. The Batch History functionality in EhP4 release delivers to trace the history ofbatch maintained in different SAP ERP and non SAP systems. The Batch History functionality isenhancement to the existing Batch Information Cockpit feature. This paper addresses how we can leverageSAP MII (Manufacturing Integration and Intelligence) in obtaining batch information in non SAP systems andviewed from Batch Information Cockpit

Author(s): Pradip Ray

Company: SAP Labs India

Created on: 01 September 2008

Author Bio

Pradip Ray has been working with SAP Labs since 2006 and is part of the Manufacturingdevelopment team in Bangalore with main focus on manufacturing integration andcollaboration projects. Before he moved to SAP, he worked for a steel manufacturing companyand was involved in Level-1 and Level-2 automation projects. He has completed hisInstrumentation Engineering from National Institute of Technology, Trichy.

Page 2: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 2

Table of ContentsIntroduction...................................................................................................................................................3

Prerequisite...................................................................................................................................................3

Customization...............................................................................................................................................3

Create MII transaction and MII Web Service to get the MES Batch Data.......................................................6Creation of MII SQL Query for fetching data from MES (Non-SAP) system ................................................6Create a BLS transaction with the SQL Query ...........................................................................................9Creation of Web service out of the transaction .........................................................................................15

Consuming MII WebServices ......................................................................................................................15

Creation of a Logical port for the Proxy class...............................................................................................21

BAdi implementation for Follow up action ....................................................................................................29

Copyright ....................................................................................................................................................35

Page 3: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 3

IntroductionSituation:

Customers store the batch related information:

- In different SAP ERP systems.

Example: In one SAP ERP system the batch is produced and delivered to another SAP ERP system.Here the packaging takes place and also the delivery to the customer.

- In SAP ERP systems and non SAP systems with different levels of granularity.

Example: Higher data granularity in the ERP systems, such as,the batch characteristics relevant forthe batch determination in the ERP processes and detailed data granularity in LIMS or MES systemslike the process parameters like temperature for producing a batch.

Problem:

To get the complete history data for a batch with all details it is necessary to go in different systems, reportsand transactions.

There is a high probability of fault when considering all relevant objects and transactions in the differentsystems or single SAP ERP system.

Prerequisite:

We need a structure to define BRO attributes for different events in customization.

Create a structure ZMII_STR:

Also, create a table type ZMIIROW_TY from the structure ZMII_STR.

Customization

To set up the scenario we have to create our own BRO types. We need to create this BRO type incustomization as follows:

Step 1: Go to transaction OCHA

Page 4: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 4

Step 2: Navigate to Batch Information Cockpit Batch History Batch related Object types DefineBatch-related Object Types and Parameters

Page 5: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 5

Step 3: Create a Batch-Related object type

Step 4: Assign User Group:

Step 5: Create Events for the BRO type

Page 6: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 6

Step 6: Select an Attributes for the Event

Step 7: Save the customization.

Create MII transaction and MII Web Service to get the MES Batch Data

To complete the scenario we have the architecture as given bellow:

As shown above, ERP event will invoke the Web Service of MII transaction. MII transactions will fetch thedata from MES DB. MII transaction uses different types of connector to communicate the Historian or MESDatabase. Here we used IDBC connector. All MII BLS transactions can be exposed as Web Services.

Creation of MII SQL Query for fetching data from MES (Non-SAP) systemTo fetch the MES Batch data we are going to use SQL Queries from the MII.http://help.sap.com/saphelp_xmii120/helpdata/en/45/58d3e94d4009cae10000000a114a6b/content.htm linkguides, how to make the IDBC connection from MII.

ERP MII

IDBC ConnectorWeb Service

MES DB

Page 7: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 7

Step 1: Right click on the project and Create a SQL Query

Step 2 : Make the Query as fixed Query

Page 8: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 8

Step 3: Click on fixed Query Detail at left hand bottom panel

Step 4: Create a fix query at the left hand side

Step 5. Save the Query.

Page 9: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 9

Create a BLS transaction with the SQL QueryStep 1: Create Transaction.

Step 2: Create the logic as follows:

Page 10: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 10

Step 3: Configure Object BatchAttrQuery (Refer the fig. above)

Step 4: Configure Object Repeater_for_batch_data:

Page 11: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 11

Step 5: Configure Object XML_Structure.

Page 12: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 12

Step 6: Configure Link of Query_To_Document.

Page 13: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 13

Step 7: Create a transaction property as XML type and output parameter.

Step 7: Assign the output XML from transaction Context menu:

Page 14: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 14

Step 8: Assign it to BatchAttrQuery.Result

Step 9: Configure the Link of assignment block:

Page 15: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 15

Step 10: Save the transaction

Creation of Web service out of the transactionhttp://<Host>:<port>/XMII/WSDLGen/<Path>/Wscheck This URL will give the WSDL file for the transaction.Now shall consume the same WSDL in ERP.

Consuming MII WebServicesStep-1: Go to object navigator (SE80) and create a proxy object as shown below. The wizard will guide youthe whole process

Page 16: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 16

Step-2: As we are consuming the Web Services, we have to select the Object type as Service Consumer:

Step-3: Source selection for us is URL/HTTP Destination.

Page 17: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 17

Step-4: Give the MII Web Service Path at URL

Step-5: Give the package name and Prefix (For this Demo We are using Local object)

Page 18: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 18

Final Step: Click on Complete button. Save and Active.

How Does it look like?

Page 19: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 19

Some detail: To verify the detail between the WSDL file and the proxy detail at ABAP.Proxy Class name starts with Prefix you have given. All structures and table types start withthe prefix.

issame as - <portType name="XacuteWSSoap"> of the WSDL fileOperation of the WSDL file <operation name="Xacute"> is the method name of the proxyclass. With the importing and exporting parameter.

For importing parameter in WSDL file: (How to read?)

Step 1: Read the message name and part element.

<message name="XacuteSoapIn">

<part element="s0:XacuteRequest" name="parameters" />

</message>

Page 20: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 20

Step 2: Element will contain the other elements. LoginName and LoginPassword ismandatory.

Step 3: Rowset refers Row

Step 4: Row refers RowSequence with elements

<s:element name="XacuteRequest">

- <s:complexType>

- <s:sequence>

<s:element maxOccurs="1" minOccurs="0" name="LoginName" type="s:string" />

<s:element maxOccurs="1" minOccurs="0" name="LoginPassword" type="s:string" />

<s:element maxOccurs="1" minOccurs="0" name="InputParams"type="s0:InputParams" />

</s:sequence>

</s:complexType>

</s:element>

<s:complexType name="Rowset">

- <s:sequence>

<s:element maxOccurs="unbounded" minOccurs="0" name="Row" type="s0:Row" />

</s:sequence>

<s:attribute name="Message" type="s:string" />

</s:complexType>

<s:complexType name="Row">

- <s:sequence id="RowSequence">

<s:element maxOccurs="1" minOccurs="1" name="BatchID" type="s:string" />

<s:element maxOccurs="1" minOccurs="1" name="Color" type="s:string" />

<s:element maxOccurs="1" minOccurs="1" name="ChipsPerGram" type="s:double" />

<s:element maxOccurs="1" minOccurs="1" name="MeltingPt" type="s:double" />

<s:element maxOccurs="1" minOccurs="1" name="OrderNo" type="s:string" />

<s:element maxOccurs="1" minOccurs="1" name="LotID" type="s:string" />

</s:sequence>

</s:complexType>

Page 21: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 21

Creation of a Logical port for the Proxy class To invoke the web service we need a logical port for the proxy class.

Using LPCONFIG (Transaction) we can create a Logical port:

Step 1: Give the same proxy class name and a logical port name.

Step 2: Make the port as default. At runtime tab select Web Service Infrastructure.

Check Message ID and State Management.

Page 22: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 22

Step 3: At call parameter tab give the URL ashttp://<HOST>:<PORT>/XMII/SOAPRunner/<TransactionPath>

Now our Proxy Class is ready. Now we shall create a function module to execute the Xacute method of theProxy class.

Page 23: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 23

Function Module: We create a function module to invoke the web seriveceZMII_BATCH

FUNCTION zmii_batch.*"----------------------------------------------------------------------*"*"Local Interface:*" TABLES*" ET_BATCH_DET TYPE ZMIIROW_TY*" ET_BRODATA TYPE BICBH_T_BDINTF*"----------------------------------------------------------------------

CONSTANTS: lv_brotype type char6 value 'ZMESII'.DATA: lo_xmii TYPE REF TO zmiico_xacute_wssoap.DATA: input TYPE zmiiaacute_soap_in.DATA: output TYPE zmiiaacute_soap_out.DATA: fault_msg TYPE REF TO cx_ai_system_fault.DATA : l_str TYPE zmiirow.DATA: ls_batch_det TYPE LINE OF zmiirow_ty.DATA ls_objdata TYPE bicbh_s_bdintf.

DATA lr_badistr1 TYPE REF TO data.

FIELD-SYMBOLS: <lt_badistr1> TYPE zmiirow_ty.

CREATE DATA lr_badistr1 TYPE zmiirow_ty.ASSIGN lr_badistr1->* TO <lt_badistr1>.

******Create instance of zmiico_xacute_wssoap proxy classTRY.CREATE OBJECT lo_xmiiEXPORTING

logical_port_name = 'ZMIITEST' “Logical Port Name .

*Set the user name and password for the authentication in MIIinput-login_name = 'USERNAME'.input-login_password = 'PASSWORD'.

*******Invoke the Web ServiceTRY.CALL METHOD lo_xmii->xacuteEXPORTINGinput = input

IMPORTINGoutput = output

.CATCH cx_ai_system_fault INTO fault_msg.

CATCH cx_ai_application_fault .

Page 24: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 24

Report ZXMII_TEST: We are going to call the Function Module in the report. As the report runs Save Buttonwill save the data in batch history table.

ENDTRY.CATCH cx_ai_system_fault .ENDTRY.

LOOP AT output-rowset-row INTO l_str.MOVE l_str-batch TO ls_batch_det-batch_id.MOVE l_str-attr_color TO ls_batch_det-color .MOVE l_str-chips_per_gram TO ls_batch_det-chips_per_gram .MOVE l_str-melting_point TO ls_batch_det-melting_pt .MOVE l_str-order_id TO ls_batch_det-order_no .MOVE l_str-material TO ls_batch_det-material .APPEND ls_batch_det TO et_batch_det.APPEND ls_batch_det TO <lt_badistr1>.

ENDLOOP. ls_objdata-bhobj_type = lv_brotype. ls_objdata-bhobj_data = lr_badistr1.

APPEND ls_objdata TO et_brodata.

ENDFUNCTION.

Page 25: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 25

Code for the report ZXMII_TEST

*&---------------------------------------------------------------------**& Report ZXMII_TEST*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

REPORT zxmii_test NO STANDARD PAGE HEADING LINE-SIZE 200.TYPE-POOLS slis.DATA: lt_zmiirow TYPE zmiirow_ty.DATA: lt_brodata TYPE bicbh_t_bdintf.DATA: lt_attrib TYPE TABLE OF tobj_c_attrib, ls_brodata LIKE LINE OF lt_brodata.

DATA: gt_fieldcat TYPE slis_t_fieldcat_alv, lt_dd03p TYPE TABLE OF dd03p WITH HEADER LINE.FIELD-SYMBOLS: <ls_fcat> TYPE slis_fieldcat_alv.

DATA: lt_objindex TYPE TABLE OF tobj_d_index, lo_conv_util TYPE REF TO cl_bh_conv_string, ls_attrib LIKE LINE OF lt_attrib, lt_dfies TYPE STANDARD TABLE OF dfies, ls_objindex LIKE LINE OF lt_objindex.DATA: ls_dfies LIKE LINE OF lt_dfies.

FIELD-SYMBOLS: <lf_structure> TYPE ANY, <lf_key> TYPE ANY,<lt_table> TYPE ANY TABLE.

SET TITLEBAR 'MESBATCH'.AT SELECTION-SCREEN OUTPUT.

START-OF-SELECTION.

CALL FUNCTION 'ZMII_BATCH'TABLES

et_batch_det = lt_zmiirow et_brodata = lt_brodata .

LOOP AT lt_brodata INTO ls_brodata.ASSIGN ls_brodata-bhobj_data->* TO <lt_table>.

ENDLOOP.

Page 26: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 26

LOOP AT <lt_table> ASSIGNING <lf_structure>.CALL FUNCTION 'GUID_CREATE'IMPORTING

ev_guid_16 = ls_objindex-guid.

ls_objindex-bhobj_type = ls_brodata-bhobj_type. ls_objindex-log_system = 'MES'.* Map Event ls_objindex-bhobj_event = 'CRTD'.

ASSIGN COMPONENT 'MATERIAL' OF STRUCTURE <lf_structure> TO <lf_key>. ls_objindex-matnr = <lf_key>.** ASSIGN COMPONENT 'WERKS' OF STRUCTURE <lf_structure> TO <lf_key>.* ls_objindex-werks = <lf_key>.*ASSIGN COMPONENT 'BATCH_ID' OF STRUCTURE <lf_structure> TO <lf_key>.

ls_objindex-charg = <lf_key>.** ASSIGN COMPONENT 'EVENT_TIME' OF STRUCTURE <lf_structure> TO <lf_key>. ls_objindex-event_time = sy-timlo.** ASSIGN COMPONENT 'EVENT_DATE' OF STRUCTURE <lf_structure> TO <lf_key>. ls_objindex-event_date = sy-datum.** ASSIGN COMPONENT 'AUTHOR' OF STRUCTURE <lf_structure> TO <lf_key>. ls_objindex-author = sy-ucomm.

SELECT * FROM tobj_c_attrib INTO TABLE lt_attribWHERE bhobj_type = ls_brodata-bhobj_typeAND bhobj_event = 'CRTD'AND attrib_type = 'ATTB'.

IF sy-subrc = 0.CREATE OBJECT lo_conv_util.LOOP AT lt_attrib INTO ls_attrib.

CALL FUNCTION 'DDIF_NAMETAB_GET'EXPORTING

tabname = ls_attrib-ref_tableTABLES

dfies_tab = lt_dfiesEXCEPTIONS

not_found = 1OTHERS = 2.

READ TABLE lt_dfies WITH KEY tabname = ls_attrib-ref_table fieldname = ls_attrib-ref_field

INTO ls_dfies.

Page 27: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 27

ASSIGN COMPONENT ls_attrib-ref_field OF STRUCTURE <lf_structure> TO <lf_key>.

CALL METHOD lo_conv_util->add_valueEXPORTING

iv_name = ls_attrib-ref_field iv_value = <lf_key>

EXCEPTIONS value_not_added = 1.

ENDLOOP. ls_objindex-attribute = lo_conv_util->export_to_data_buffer( ).ENDIF.APPEND ls_objindex TO lt_objindex.

lo_conv_util->delete_values( ).

ENDLOOP.

"Insert into table tobj_d_indexINSERT tobj_d_index FROM TABLE lt_objindex.

*******DisplayCALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'EXPORTING* I_PROGRAM_NAME =* I_INTERNAL_TABNAME = i_structure_name = 'ZMII_STR'* I_CLIENT_NEVER_DISPLAY = 'X'* I_INCLNAME =* I_BYPASSING_BUFFER =* I_BUFFER_ACTIVE =CHANGING

ct_fieldcat = gt_fieldcatEXCEPTIONS inconsistent_interface = 1 program_error = 2

OTHERS = 3 .IF sy-subrc <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.ENDIF.CALL FUNCTION 'DDIF_TABL_GET'EXPORTING

name = 'ZMII_STR' langu = sy-languTABLES dd03p_tab = lt_dd03pEXCEPTIONS illegal_input = 1

OTHERS = 2.

Page 28: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 28

Now all the MES batch detail are available in Batch History table after the save button is pressed.

IF sy-subrc = 0.LOOP AT gt_fieldcat ASSIGNING <ls_fcat>.READ TABLE lt_dd03p WITH KEY fieldname = <ls_fcat>-fieldname.IF sy-subrc = 0.

<ls_fcat>-seltext_l = lt_dd03p-ddtext. <ls_fcat>-seltext_m = lt_dd03p-ddtext. <ls_fcat>-seltext_s = lt_dd03p-ddtext.

ENDIF.ENDLOOP.

ENDIF.* Show ALVCALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'EXPORTING

i_callback_program = sy-repid i_callback_pf_status_set = 'SET_PF_STATUS' i_callback_user_command = 'USER_COMMAND' it_fieldcat = gt_fieldcat[]

i_grid_title = 'Following MES data for Batch Hiytory Index Table'

TABLES t_outtab = lt_zmiirow[]

EXCEPTIONS program_error = 1

OTHERS = 2.IF sy-subrc <> 0.MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.ENDIF.

FORM set_pf_status USING rt_extab TYPE slis_t_extab.SET PF-STATUS 'SAVE'.ENDFORM.FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.CASE r_ucomm.WHEN 'SAVE'.CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

WHEN 'EXIT'.ROLLBACK WORK.LEAVE PROGRAM.ENDCASE.

ENDFORM.

Page 29: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 29

How the batch history table will look like?

BAdI implementation for Follow up actionNow we have to implement the BAdI for the follow up action.

Step 1: Go to transaction ocha.

Page 30: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 30

Step 2: Navigate to Batch Information Cockpit Batch History Follow-up Actions For Batch-Related objecttypes BAdI: Follow-up Actions For Batch-Related object types

Step 3: Implement the IF_EX_BH_FOLLOW_UP_ACTION~GET_FOLLOW_UP_ACTION method

Page 31: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 31

Now go to batch history and right click on the Batch detail It will have anentry for the follow up action at the bottom of the context menu.

METHOD if_ex_bh_follow_up_action~get_follow_up_action.

DATA: lv_brotype TYPE bhobj_type, lt_action TYPE bicbh_t_action, ls_action LIKE LINE OF lt_action.

IF iv_brotype IS INITIAL.RAISE enter_bro_type.

ELSE.

lv_brotype = iv_brotype.

CASE lv_brotype.

when 'ZMESII'. ls_action-text = text-025. ls_action-trx_code = 'ZMES'.

APPEND ls_action TO lt_action.

ENDCASE.

ENDIF.APPEND LINES OF lt_action TO et_actions.

ENDMETHOD.

Page 32: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 32

Now we shall do the BAdI implementation for the Follow up action for the MES Batch.

Step 1: Go to the same BAdI.

Step 2: Implement the IF_EX_BH_FOLLOW_UP_ACTION~EX_FOLLOW_UP_ACTION method

Page 33: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 33

Implementation:

After clicking of the MES Batch at context menu, the following page opens:

METHOD if_ex_bh_follow_up_action~ex_follow_up_action.

IF iv_log_system IS INITIAL.RAISE enter_logical_system.

ELSEIF iv_bro_type IS INITIAL.

RAISE enter_bro_type.ELSEIF

iv_action IS INITIAL.RAISE enter_action_code.

ELSE.

CASE iv_bro_type.* Batch Master

* MES DataWHEN 'ZMESII'.

CASE iv_action.WHEN 'ZMES'.CALL FUNCTION 'GUI_RUN'EXPORTING

command = 'iexplore'PARAMETER = '\\<Sharelocation>\ doThis.html'

* CD =* IMPORTING* RETURNCODE = .

ENDCASE.

ENDCASE.ENDIF.

ENDMETHOD.

Page 34: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 34

To hide the username and password from the URL we have created the HTML file doThis.html

Note: SAP delivers the example content for the Batch History function and the communication with SAP MII incustomizable templates posted to the SAP Developer Network (SDN). SAP does not provide support forthis application; all risk is assumed by the customer. SAP is not liable for consequences of or damagesresulting from the customer’s use of the application.

<html>

<body onload="frmSubmit.submit();">

<form action="http://<Host>:<port>/XMII/BatchHistory/BatchAnalysis.htm" method="POST"name="frmSubmit">

<input type="hidden" name="IllumLoginName" value="USERNAME">

<input type="hidden" name="IllumLoginPassword" value="PASSWORD">

</form>

</body>

</html>

Page 35: BM_Batch Management Batch Information From Non-SAP Systems Using SAP MII

Batch History: How to Guide on getting Batch information from non SAP systems using SAP MII

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com© 2008 SAP AG 35

Copyright© 2008 SAP AG. All rights reserved.

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG.The information contained herein may be changed without prior notice.

Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries,zSeries, System i, System i5, System p, System p5, System x, System z, System z9, z/OS, AFP, Intelligent Miner, WebSphere,Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, POWER5+, OpenPower and PowerPC are trademarks or registered trademarks ofIBM Corporation.

Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe SystemsIncorporated in the United States and/or other countries.

Oracle is a registered trademark of Oracle Corporation.

UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.

Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks ofCitrix Systems, Inc.

HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, MassachusettsInstitute of Technology.

Java is a registered trademark of Sun Microsystems, Inc.

JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented byNetscape.

MaxDB is a trademark of MySQL AB, Sweden.

SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as theirrespective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. Allother product and service names mentioned are the trademarks of their respective companies. Data contained in this document servesinformational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAPGroup") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors oromissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in theexpress warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting anadditional warranty.

These materials are provided “as is” without a warranty of any kind, either express or implied, including but not limited to, the impliedwarranties of merchantability, fitness for a particular purpose, or non-infringement.

SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that mayresult from the use of these materials.

SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within thesematerials. SAP has no control over the information that you may access through the use of hot links contained in these materials anddoes not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages.

Any software coding and/or code lines/strings (“Code”) included in this documentation are only examples and are not intended to beused in a productive system environment. The Code is only intended better explain and visualize the syntax and phrasing rules ofcertain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errorsor damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent.