Adobe Interactive Forms Online_Offline Using WD ABAP – HR Personal Address.

22
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 1 Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address Applies to: This document applies to SAP version ECC 6.0. For more information, visit the Web Dynpro ABAP homepage . Summary This article describes a mechanism in which same Adobe Interactive Form can be used for Online and Offline submission. Author: Hobin Thomas Company: Applexus Technologies (P) Ltd. Created on: 29 June 2011 Author Bio Hobin Thomas is working as SAP Technology Consultant with Applexus Technologies (P) Ltd. He is specialized in NetWeaver Technologies such as WebDynpro Abap, SAP Interactive Forms by Adobe and Sap Mobile Infrastructure.

description

Webdynpro

Transcript of Adobe Interactive Forms Online_Offline Using WD ABAP – HR Personal Address.

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

    2011 SAP AG 1

    Adobe Interactive forms

    Online/Offline using WD ABAP HR Personal Address

    Applies to:

    This document applies to SAP version ECC 6.0. For more information, visit the Web Dynpro ABAP homepage.

    Summary

    This article describes a mechanism in which same Adobe Interactive Form can be used for Online and Offline submission.

    Author: Hobin Thomas

    Company: Applexus Technologies (P) Ltd.

    Created on: 29 June 2011

    Author Bio

    Hobin Thomas is working as SAP Technology Consultant with Applexus Technologies (P) Ltd. He is specialized in NetWeaver Technologies such as WebDynpro Abap, SAP Interactive Forms by Adobe and Sap Mobile Infrastructure.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

    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

    Scenario .............................................................................................................................................................. 3

    Developments ................................................................................................................................................. 3 WebDynpro Component .............................................................................................................................................. 3

    Adobe Interactive Forms / Interface ............................................................................................................................. 7

    Submission WebDynpro ............................................................................................................................................ 11

    WebDynpro Application ............................................................................................................................................. 15

    Test Result ........................................................................................................................................................ 15

    Related Content ................................................................................................................................................ 21

    Disclaimer and Liability Notice .......................................................................................................................... 22

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 3

    Introduction

    This article describes the implementation on Adobe Interactive Form Online/Offline scenario using WebDynpro ABAP. This also covers up the scenarios where single Adobe Interactive Form can be used for Online and Offline solution for HR Personal Address Data maintenance. While I went through SDN blogs I found that many of the valuable topics on Adobe Interactive Forms are missing. So I thought of posting this article that would help others in Adobe Interactive Forms Development.

    Scenario

    In this article there are two scenarios for Adobe Form Submission Online and Offline. The online scenario include where Adobe forms are loaded on to the browser. And user can interact with forms to submit the data to SAP. In the case offline scenario the form is saved locally. This form is opened in Adobe Reader; user then can enter the required information and save it. Later when SAP submission is required he/she can upload the form with help of WebDynpro and then submit it to SAP. The HR Personal Address Details is maintained through this example.

    Developments Included:

    WebDynpro Component.

    Adobe Interactive Form/Interface.

    Developments

    WebDynpro Component

    Create WebDynpro Component using transaction SE80. Here for this example I am going to create ZWD_ADOBE_FORMS with window name as W_WINDOW and view as V_MAIN. Then activate all the components.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 4

    Create following Context Nodes in Component Controller,

    The cardinality of the following node are 1:1

    ADDRESS is given the dictionary structure P0006.

    Attribute:

    PERNR type PSKEY-PERNR.

    INFTY type PSKEY-INFTY.

    SUBTY type PSKEY-SUBTY.

    PDF_SOURCE type XSTRING.

    Navigate to view V_MAIN and map all the context nodes from component controller.

    Create layout for the Online and offline scenarios.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 5

    Use WebDynpro Code Wizard HR Details Adobe Online which will bind Personal Number, Infotype and Subtype. Along with this add Submit button which will navigate to Adobe Form for HR Personal Address Submission.

    For Upload the HR Adobe Form through Offline Adobe Forms and Upload UI element and bind it to the PDF_SOURCE context attribute. Also add Upload button which uploads the PDF form and navigates to Adobe Form for HR Personal Address Submission.

    Create Inbound and Outbound plugs to help to navigate to and fro.

    Inbound plugs IN_FORM

    Outbound plugs OUT_MAIN

    Also create actions for following Buttons:

    Submit ON_SUBMIT

    Upload ON_UPLOAD

    Add the following Code Snippet for Submit Action:-

    METHOD onactionon_submit .

    DATA lo_nd_list TYPE REF TO if_wd_context_node.

    DATA lo_el_list TYPE REF TO if_wd_context_element.

    DATA ls_list TYPE wd_this->element_list.

    DATA lt_p0006 TYPE TABLE OF p0006.

    DATA ls_p0006 TYPE p0006.

    DATA lo_nd_address TYPE REF TO if_wd_context_node.

    DATA lo_el_address TYPE REF TO if_wd_context_element.

    DATA ls_address TYPE wd_this->element_address.

    * navigate from to via lead selection

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 6

    lo_nd_list = wd_context->get_child_node( name = wd_this->wdctx_list ).

    * get element via lead selection

    lo_el_list = lo_nd_list->get_element( ).

    * get all declared attributes

    lo_el_list->get_static_attributes(

    IMPORTING

    static_attributes = ls_list ).

    CALL FUNCTION 'HR_READ_INFOTYPE'

    EXPORTING

    * TCLAS = 'A'

    pernr = ls_list-pernr

    infty = ls_list-infty

    * BEGDA = '18000101'

    * ENDDA = '99991231'

    * BYPASS_BUFFER = ' '

    * LEGACY_MODE = ' '

    * IMPORTING

    * SUBRC =

    TABLES

    infty_tab = lt_p0006

    * EXCEPTIONS

    * INFTY_NOT_FOUND = 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.

    SORT lt_p0006 BY endda.

    READ TABLE lt_p0006 INTO ls_p0006 INDEX 1.

    CHECK sy-subrc EQ 0.

    * navigate from to via lead selection

    lo_nd_address = wd_context->path_get_node( path = `ROOT.ADDRESS` ).

    * get element via lead selection

    lo_el_address = lo_nd_address->get_element( ).

    MOVE-CORRESPONDING ls_p0006 TO ls_address.

    * set all declared attributes

    lo_el_address->set_static_attributes(

    static_attributes = ls_address ).

    wd_this->fire_out_main_plg(

    ).

    ENDMETHOD.

    Add the following Code Snippet for Upload Action:-

    method ONACTIONUPLOAD .

    wd_this->fire_out_main_plg(

    ).

    endmethod.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 7

    Create another View named as V_FORM. This will hold the corresponding Adobe Form for HR Personal Address. In the context map all the nodes except the List node from component controller. In the view layout add the InteractiveForm UI element and add the DataSource as the ROOT context node. The displayType should be native, enabled property should be checked and give onSubmit event property as ON_SUBMIT.

    Adobe Interactive Forms / Interface

    Now the next process is to create an Adobe Form and its interface. We can use SFP transaction to create the same the interface and then the form. But here I am going to create by specifying the template source in the property of InteractiveForm UI element. Specify ZAF_ADOBE_FORMS as template source and press enter it will pop-up a screen to give the interface and its node.

    Here specify the context by clicking Context button and specify the ROOT context and Interface as ZAI_ADOBE_FORMS. One pressing Use button this will create the Adobe Form ZAF_ADOBE_FORMS and interface as ZAI_ADOBE_FORMS. Here the Adobe Form should be specified ZCI and we should insert the WebDynpro Script to help native WebDynpro elements to work.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 8

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 9

    The property of the form interface ZAI_ADOBE_FORMS generated will be XML Schema-Based Interface.

    And the Interface will be having XML schema of the Context mapped as Data Source

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 10

    For the example I have designed a simple form for HR Permanent Address.

    The following fields have given the Default Binding. It can be given out by selecting the elements and then go for Palette Object ->Binding. Here select the data connection ZAF_ADOBE_FORMS select the structure and the corresponding attribute.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 11

    For the submission to SAP we have to use the SUBMIT button from library WebDynpro Native section.

    This will make out form level developments.

    Submission WebDynpro

    Now for submission process we need to define the onSubmit event of the InteractiveForm UI element in V_FORM view. The event is defined here as ON_SUBMIT.

    Add the following Code Snippet for Submit Action:-

    method ONACTIONON_SUBMIT .

    DATA lo_nd_address TYPE REF TO if_wd_context_node.

    DATA lo_el_address TYPE REF TO if_wd_context_element.

    DATA ls_address TYPE wd_this->element_address.

    DATA ls_p0006 TYPE p0006.

    DATA lt_p0006 TYPE TABLE OF p0006.

    DATA ls_return TYPE BAPIRETURN1.

    *get message manager

    DATA lo_api_controller TYPE REF TO if_wd_controller.

    DATA lo_message_manager TYPE REF TO if_wd_message_manager.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 12

    DATA lv_msgid TYPE string.

    * navigate from to via lead selection

    lo_nd_address = wd_context->path_get_node( path = `ROOT.ADDRESS` ).

    * @TODO handle non existant child

    * IF lo_nd_address IS INITIAL.

    * ENDIF.

    * get element via lead selection

    lo_el_address = lo_nd_address->get_element( ).

    * @TODO handle not set lead selection

    IF lo_el_address IS INITIAL.

    ENDIF.

    * get all declared attributes

    lo_el_address->get_static_attributes(

    IMPORTING

    static_attributes = ls_address ).

    MOVE-CORRESPONDING ls_address to ls_p0006.

    * ls_p0006-infty = ls_list-infty.

    * ls_p0006-SUBTy = ls_list-SUBTy.

    * APPEND ls_p0006 to lt_p0006.

    CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'

    EXPORTING

    number = ls_address-pernr

    * IMPORTING

    * RETURN =

    * LOCKING_USER =

    .

    CALL FUNCTION 'HR_INFOTYPE_OPERATION'

    EXPORTING

    infty = ls_p0006-infty

    number = ls_p0006-pernr

    SUBTYPE = ls_p0006-SUBTy

    * OBJECTID =

    * LOCKINDICATOR =

    VALIDITYEND = ls_p0006-ENDDA

    VALIDITYBEGIN = ls_p0006-BEGDA

    * RECORDNUMBER =

    record = ls_p0006

    operation = 'MOD'

    * TCLAS = 'A'

    * DIALOG_MODE = '0'

    * NOCOMMIT =

    * VIEW_IDENTIFIER =

    * SECONDARY_RECORD =

    IMPORTING

    RETURN = ls_return

    * KEY =

    .

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 13

    lo_api_controller ?= wd_this->wd_get_api( ).

    CALL METHOD lo_api_controller->get_message_manager

    RECEIVING

    message_manager = lo_message_manager

    .

    IF ls_return-type eq 'E'.

    * report message

    CALL METHOD lo_message_manager->report_error_message

    EXPORTING

    message_text = ls_return-MESSAGE

    * params =

    * msg_user_data =

    * is_permanent = ABAP_FALSE

    * scope_permanent_msg = CO_MSG_SCOPE_CONTROLLER

    * view =

    * show_as_popup =

    * controller_permanent_msg =

    * msg_index =

    * cancel_navigation =

    * enable_message_navigation =

    receiving

    message_id = lv_msgid

    .

    ELSE.

    * report message

    CALL METHOD lo_message_manager->report_success

    EXPORTING

    message_text = 'Trasaction completed Succesfully'

    * params =

    * msg_user_data =

    * is_permanent = ABAP_FALSE

    * scope_permanent_msg = CO_MSG_SCOPE_CONTROLLER

    * view =

    * show_as_popup =

    * controller_permanent_msg =

    * msg_index =

    * cancel_navigation =

    * enable_message_navigation =

    receiving

    message_id = lv_msgid

    .

    ENDIF.

    CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'

    EXPORTING

    number = ls_address-pernr

    * IMPORTING

    * RETURN =

    .

    endmethod.

    This code snippet will update the Adobe Forms details into Infotype 06.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 14

    Add the Inbound and Outbound plug named IN_MAIN and OUT_FORM for navigation to and from the V_FORM. We will add a Back button in the V_FORM. This will navigate back to the view V_MAIN. The Back button has given the onAction Events as ON_BACK.

    Add the code snippet to navigate to V_MAIN.

    method ONACTIONON_BACK .

    wd_this->fire_out_form_plg(

    ).

    endmethod.

    In the W_WINDOW embed the views V_MAIN and V_FORM. And create navigation link from OUT_MAIN to IN_FORM which will navigate to V_FORM to display the adobe form. Also create another navigation link from OUT_FORM to IN_MAIN which will navigate back to initial screen.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 15

    WebDynpro Application

    Create a WebDynpro application ZWDA_ADOBE_FORMS for testing this componet component.

    Test Result

    Test the application ZWDA_ADOBE_FORMS.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 16

    For test scenario test with following data.

    Personal number : 1000

    Infotype : 0006

    Subtype : 1

    On clicking Submit, this will navigate on to the screen which will display the adobe form HR Permanent Address.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 17

    Update the Form with required information. And click on Submit To SAP button. This will update Infotype 6 with required information corresponding to the employee.

    On checking the PA30 for employee 1000 we will find the telephone number being updated.

    For checking Offline Scenario.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 18

    Download the Adobe Form on to desktop.

    Open the Adobe File saved locally using Adobe Reader, make necessary changes and then save it.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 19

    Get into the initial screen, where option is given for Uploading the offline Adobe Form. Use Browse button to select the file saved locally. And click the Upload button. This will upload the PDF file and navigates to the next screen for submission.

    We could see the changed field which was updated locally. Now submit the form to save the data to Infotype.

    On submission the data using Submit To SAP button, it will update Infotype with changed information.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 20

    Check PA30 for changes done.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 21

    Related Content

    http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/00545e6d-0679-2910-acab-8073ce9a1659

    Prerequisites for Form Integration

    For more information, visit the Web Dynpro ABAP homepage.

  • Adobe Interactive forms Online/Offline using WD ABAP HR Personal Address

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

    2011 SAP AG 22

    Disclaimer and Liability Notice

    This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

    SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

    SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.