transfer data from sap to microsoft sharepoint and outlook 2010

13
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 1 Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 Duet Enterprise Workflow Part I Applies to: Duet Enterprise 1.0. For more information, visit the. Duet Enterprise Home Site . Summary This article explains how to implement a custom handler to transfer business data in static format (i.e. HTML content) from SAP workflow to Microsoft SharePoint and Office 2010. The article shows an example of creating an outbound custom handler for a purchase order approval workflow. Author: Edward Lu Company: SAP Labs LLC Created on: 1 January 2011 Author Bio Xiaosheng (Edward) Lu has been working for SAP since 2001. He joined SAP as a RIG consultant. Since then, he has been working on numerous projects including different releases of Netwever platform, Business Suite SRM, and new technologies including Duet Enterprise and Gateway. He is now working as an Information Worker solution manager in Palo Alto. Before joining SAP, Edward worked as a technology consultant for a San Francisco based consulting firm.

Upload: others

Post on 12-Sep-2021

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 1

Transfer Data from SAP to

Microsoft SharePoint and Outlook

2010 – Duet Enterprise Workflow

Part I

Applies to:

Duet Enterprise 1.0. For more information, visit the. Duet Enterprise Home Site.

Summary

This article explains how to implement a custom handler to transfer business data in static format (i.e. HTML content) from SAP workflow to Microsoft SharePoint and Office 2010. The article shows an example of creating an outbound custom handler for a purchase order approval workflow.

Author: Edward Lu

Company: SAP Labs LLC

Created on: 1 January 2011

Author Bio

Xiaosheng (Edward) Lu has been working for SAP since 2001. He joined SAP as a RIG consultant. Since then, he has been working on numerous projects including different releases of Netwever platform, Business Suite SRM, and new technologies including Duet Enterprise and Gateway. He is now working as an Information Worker solution manager in Palo Alto. Before joining SAP, Edward worked as a technology consultant for a San Francisco based consulting firm.

Page 2: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 – Duet Enterprise Workflow Part I

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 2

Table of Contents

Introduction ......................................................................................................................................................... 3

Implement Duet Enterprise Workflow Outbound Custom Handler to Transfer Business Data .......................... 3

Highlights of Configuration Steps ....................................................................................................................... 9

Example Workflow Approval UI on SharePoint and Outlook ............................................................................ 11

Related Content ................................................................................................................................................ 12

Copyright........................................................................................................................................................... 13

Page 3: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 – Duet Enterprise Workflow Part I

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 3

Introduction

One of the core capabilities in Duet Enterprise 1.0 is Duet Enterprise workflow. The core capability allows the exposing of SAP user decision workflow to Microsoft SharePoint and Outlook 2010. There are two types of work required for exposing a SAP user decision workflow task to SharePoint – configuration and custom development. The configuration steps have been covered in the Duet Enterprise install and deployment guides. But custom development, which accounts for the exposing of SAP business information to SharePoint task and Outlook approval email in assisting the decision making process, has not been covered in the official configuration document. The purpose of this document is to fill the gap and explain how to implement a custom handler to transfer data from SAP ERP workflow to Duet Enterprise SharePoint and Outlook 2010.

In this part I document for Duet Enterprise workflow I will explain how to create a custom handler to transfer SAP business data from SAP workflow to Microsoft SharePoint and Office 2010, in the format of HTML content of SharePoint approval task and Outlook email.

Implement Duet Enterprise Workflow Outbound Custom Handler to Transfer Business Data

The below example demonstrates the option of customizing SharePoint workflow task body and subject to present business data such as purchase order header and item details, which will help the approver to make a decision. Methods presented here is only an option. As this is custom development, you can choose other methods you prefer.

Create the workflow outbound custom handler in the ERP system where your workflow resides (not the SCL system). 1. You can create the outbound custom handler by copying the delivered SAP default outbound custom

handler S_OSP_WF_PAT_DEFAULT_CH_OB. Go to SE37 and copy the default SAP outbound custom

handler to your new function module.

2. Specify the new name of the function module such as Z_OUTBOUND_CUSTOM_HANDLER.

Page 4: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 – Duet Enterprise Workflow Part I

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 4

3. Once the function module is created. Click the Change button.

4. Switch to the attributes tab and change the Short Text to description you prefer, such as “Duet Enterprise

Workflow Custom Handler”.

5. Switch to the source code tab and replace the existing source code with the code below. Please note the

below example only set the body and subject text for “Task”, which corresponds to SharePoint task. In

Duet Enterprise there is no need to set body and subject text for “Email”, as there is no direct sending of

workflow item to Outlook. The workflow approval item will be sent to SharePoint as a task, and then

SharePoint server will relay the task to Exchange Server as email.

Page 5: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 – Duet Enterprise Workflow Part I

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 5

FUNCTION z_outbound_custom_handler.

*"----------------------------------------------------------------------

*"*"Local Interface:

*" IMPORTING

*" VALUE(IT_WORKITEM_DETAIL) TYPE SOSP_TT_WF_RUNTIME_INFO OPTIONAL

*" EXPORTING

*" VALUE(EV_ERROR_FLAG) TYPE S_OSP_DT_FLAG

*" VALUE(ET_WORKITEM_DETAIL) TYPE SOSP_TT_WF_RUNTIME_INFO

*" VALUE(ET_RETURN) TYPE BAPIRETTAB

*"----------------------------------------------------------------------

DATA: ls_workitem_detail TYPE sosp_s_wf_runtime_info,

ls_client_gpw_info TYPE sosp_s_client_gpw_info,

ls_subj_body_tab TYPE sosp_s_subj_body_tab,

lt_client_gpw_info TYPE sosp_tt_client_gpw_info,

lv_body_string TYPE string.

LOOP AT it_workitem_detail INTO ls_workitem_detail.

CALL FUNCTION 'Z_SAMPLE_APP_CONTENT'

EXPORTING

workitem_detail = ls_workitem_detail

IMPORTING

ev_body_html_text = lv_body_string.

lt_client_gpw_info = ls_workitem_detail-client_gpw_info.

LOOP AT lt_client_gpw_info INTO ls_client_gpw_info

WHERE recp_role_id = 'APPROVER'

AND gpw_object_sub_type = 'BND'.

IF ls_client_gpw_info-gpw_object_type = 'TASK'.

*Fill the subject text information

ls_subj_body_tab-subject = 'Please approve this PO for Hardware and Software

purchase'.

*Fill the body text information

ls_client_gpw_info-task_details-body-value = lv_body_string.

*Fill the subject text information

ls_client_gpw_info-task_details-subject-value = ls_subj_body_tab-subject.

ENDIF.

MODIFY lt_client_gpw_info FROM ls_client_gpw_info.

ENDLOOP.

***Set Client info to Workflow Pattern structure

ls_workitem_detail-client_gpw_info = lt_client_gpw_info.

APPEND ls_workitem_detail TO et_workitem_detail.

ENDLOOP.

ENDFUNCTION.

The following section explains outbound custom handler function module in detail.

6. Constructing the SharePoint task body with SAP business content.

The easiest way to construct SAP business content for SharePoint approval task is by using SAP standard text. This is usually not enough for content formatting and handling at SharePoint site. The best way is to display the content at SharePoint as HTML format. To achieve that, there are two options.

Page 6: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 – Duet Enterprise Workflow Part I

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 6

Build the content as ABAP XML in SAP and transform the XML into HTML string directly in SAP by

using XSLT transformation. For this approach please see the other document for Duet 1.5 workflow

in SDN - Duet 1.5 workflow approval blog Build the content as ABAP XML in SAP, send the XML to SharePoint and handle the XSLT

transformation to HTML using SharePoint Designer

The second approach seems to be better as this will save you from putting every single UI change into ABAP transport. Also it is a cleaner approach compared to the first option. The SharePoint UI should be handled in front-end development tool - Microsoft SharePoint Designer, rather than tools from SAP backend.

The sample code below demonstrates the construction of ABAP XML in SAP for PO approval business content. The outcome XML string of the function module will be passed to your outbound custom handler and sent over to SharePoint.

FUNCTION z_sample_app_content.

*"----------------------------------------------------------------------

*"*"Local Interface:

*" IMPORTING

*" REFERENCE(WORKITEM_DETAIL) TYPE SOSP_S_WF_RUNTIME_INFO

*" EXPORTING

*" REFERENCE(EV_BODY_XML) TYPE STRING

*"----------------------------------------------------------------------

* TYPE-POOLS: ixml.

CLASS cl_ixml DEFINITION LOAD.

*----Local variables

DATA: ex TYPE REF TO cx_root,

ls_body_text TYPE string,

ls_document_xml TYPE string,

lo_ixml TYPE REF TO if_ixml,

lo_document TYPE REF TO if_ixml_document,

lo_element TYPE REF TO if_ixml_element,

lo_root TYPE REF TO if_ixml_element,

lo_workflow TYPE REF TO if_ixml_element,

lo_po TYPE REF TO if_ixml_element,

lo_poitems TYPE REF TO if_ixml_element,

lo_poitem TYPE REF TO if_ixml_element.

DATA: lv_temp_string TYPE string.

DATA: lt_container TYPE sosp_tt_swr_cont.

DATA: po_items TYPE STANDARD TABLE OF bapiekpo WITH HEADER LINE.

DATA: po_header LIKE bapiekkol.

DATA: po_item LIKE bapiekpo.

lt_container = workitem_detail-workitem_container.

*---Create xml structure

lo_ixml = cl_ixml=>create( ).

lo_document = lo_ixml->create_document( ).

lo_root = lo_document->create_element( name = 'duet').

lo_document->append_child( lo_root ).

lo_workflow = lo_document->create_element( name = 'workflow').

lo_root->append_child( lo_workflow ).

lo_po = lo_document->create_element( name = 'poApproval').

lo_workflow->append_child( lo_po ).

lo_poitems = lo_document->create_element( name = 'poItems').

lo_po->append_child( lo_poitems ).

** Here you can provide your own coding to retrieve 'real' PO information

** Below in below sample we will use dummy values

Page 7: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 – Duet Enterprise Workflow Part I

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 7

* CALL FUNCTION 'BAPI_PO_GETDETAIL'

* EXPORTING

* PURCHASEORDER =

* IMPORTING

* PO_HEADER = po_header

* TABLES

* PO_ITEMS = po_items.

* Document header

lo_element = lo_document->create_simple_element( name = 'poNumber'

value = '4500000287'

parent = lo_po ).

* MOVE po_header-created_by TO lv_temp_string.

lo_element = lo_document->create_simple_element( name = 'requestor'

value = 'Jenny Bryant'

parent = lo_po ).

* MOVE po_header-created_on TO lv_temp_string.

lo_element = lo_document->create_simple_element( name = 'dateSubmitted'

value = 'Jan. 14, 2010'

parent = lo_po ).

LOOP AT PO_ITEMS.

* PO Item list

lo_poitem = lo_document->create_element( name = 'poItem' ).

lo_poitems->append_child( lo_poitem ).

* Item Number

* MOVE po_items-po_item TO lv_temp_string.

lo_element = lo_document->create_simple_element( name = 'itemNumber'

value = '00010'

parent = lo_poitem ).

* Material

* MOVE po_items-material TO lv_temp_string.

lo_element = lo_document->create_simple_element( name = 'material'

value = 'CH_0011'

parent = lo_poitem ).

* Short Text

* MOVE po_items-short_text TO lv_temp_string.

lo_element = lo_document->create_simple_element( name = 'shortText'

value = 'CH Base'

parent = lo_poitem ).

* Quantity

* MOVE po_items-quantity TO lv_temp_string.

lo_element = lo_document->create_simple_element( name = 'quantity'

value = '2000'

parent = lo_poitem ).

* Unit

* MOVE po_items-unit TO lv_temp_string.

lo_element = lo_document->create_simple_element( name = 'unit'

value = 'GLL'

parent = lo_poitem ).

* Unit Price

* MOVE po_items-net_price TO lv_temp_string.

lo_element = lo_document->create_simple_element( name = 'unitPrice'

value = '7.00'

parent = lo_poitem ).

* Currency

* MOVE po_header-currency TO lv_temp_string.

Page 8: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 – Duet Enterprise Workflow Part I

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 8

lo_element = lo_document->create_simple_element( name = 'currency'

value = 'USD'

parent = lo_poitem ).

* Delivery Date

* MOVE po_items-plan_del TO lv_temp_string.

lo_element = lo_document->create_simple_element( name = 'deliveryDate'

value = '01-20-2009'

parent = lo_poitem ).

* Material Group

* MOVE po_items-mat_grp TO lv_temp_string.

lo_element = lo_document->create_simple_element( name = 'materialGroup'

value = '01'

parent = lo_poitem ).

* Plant

* MOVE po_items-plant TO lv_temp_string.

lo_element = lo_document->create_simple_element( name = 'plant'

value = 'BP01'

parent = lo_poitem ).

ENDLOOP.

TRY.

CALL TRANSFORMATION id

SOURCE XML lo_document

RESULT XML ls_document_xml.

CATCH cx_transformation_error INTO ex.

ENDTRY.

ev_body_xml = ls_document_xml.

ENDFUNCTION.

Open again the custom handler “Z_OUTBOUND_CUSTOM_HANDLER” in SE37. In this line of the code, the custom handler calls function module “Z_SAMPLE_APP_CONTENT” to create the PO XML document string.

7. Optional: Inside the custom handler function module, you can change the subject of the workflow

approval task.

8. Pass the XML string to SharePoint by appending the string to Duet Enterprise default workflow task body

structure.

9. Activate the function module.

Page 9: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 – Duet Enterprise Workflow Part I

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 9

Highlights of Configuration Steps

The below section gives some highlights of SAP configuration steps for Duet Enterprise workflow. You could find this information from SAP delivered Duet Enterprise implementation document, 1. Include the “Z_OUTBOUND_CUSTOM_HANDLER” as custom handler for your workflow. Go to

transaction SIMGH in the ERP system (Not SCL system). Search and display IMG structure “Duet

Implementation Guide”.

2. Choose “Workflow Pattern Customization”.

3. Select the application ID where your workflow customization already exists. Such as “TGWF”. Double

click on menu Workflow.

4. Click on the New Entries button and insert the Outbound Custom Handler –

“Z_OUTBOUND_CUSTOM_HANDLER”. Call the Z Outbound Custom Handler first, which is indicated by

Counter 1 in this example. Make sure to include and call the SAP default Outbound Custom Handler

“S_OSP_WF_PAT_DEFAULT_CH_OB” the last, which is indicated by Counter 2 in this example.

Page 10: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 – Duet Enterprise Workflow Part I

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 10

5. Select one of the workflow entries and double click on menu Tasks. It doesn’t matter which one you

choose.

6. Display the setting defined for PO approval workflow. These settings inform Duet Enterprise Workflow

which SAP workflow template, which user decision task, and which workflow step should be picked up

and sent to Duet Enterprise SharePoint and Outlook. Notice the settings - Groupware Object Type and

GPW Bound Item Type. The two settings define how SAP workflow associates with a SharePoint

workflow task. The GPW Bound Item Type “POApproval” is exactly what you should define in SharePoint

as Task Name for PO Approval workflow site.

7. Double click on menu Action.

8. Display transition actions defined for PO approval workflow. Transition actions define how Duet

Enterprise Workflow should act for a specific workflow item status transition. For example, if a workflow

item status changed from blank to C (Create), a workflow task should be created and sent out to

SharePoint 2010 and Outlook 2010.

Page 11: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 – Duet Enterprise Workflow Part I

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 11

Example Workflow Approval UI on SharePoint and Outlook

Below are example screens of Duet Enterprise workflow approval UI in Microsoft SharePoint and Outlook 2010. Your UI could be very different depending on the custom development methods you choose in SAP custom handler and SharePoint Designer.

1. Example PO approval email UI in Outlook.

2. Example invoice approval task UI in SharePoint site.

In this document, you learned how to:

Implement custom handler in SAP backend for Duet Enterprise Workflow

Build custom workflow task body and subject using outbound custom handler

Page 12: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 – Duet Enterprise Workflow Part I

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 12

Related Content

Duet Enterprise Home Site

Duet 1.5 workflow approval blog

How to decide if my workflow fits Duet Workflow Template?

Page 13: Transfer Data from SAP to Microsoft SharePoint and Outlook 2010

Transfer Data from SAP to Microsoft SharePoint and Outlook 2010 – Duet Enterprise Workflow Part I

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 13

Copyright

© Copyright 2011 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, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.

Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.

Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated 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 of Citrix Systems, Inc.

HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute 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 by Netscape.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.

Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company.

All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational 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 ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.