abap - part 2 how to pass data to web dynpro abap from ?· how to pass data to web dynpro abap...

Download ABAP - Part 2 How to pass data to Web Dynpro ABAP from ?· How to pass data to Web Dynpro ABAP from…

Post on 08-Sep-2018

214 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • Generated by Jive on 2013-08-30+02:001

    How to pass data to Web Dynpro ABAP fromABAP - Part 2

    In the first part, How to pass data to from ABAP to Web Dynpro ABAP- Part 1 , we haveseen how to create shared memory objects and creating Web Dynpro ABAP Application.

    Now we will see, creating ABAP ALV Report and how to call and pass data to Web DynproApplication using shared memory object.

    Creating ABAP ALV ReportExecute Transaction SE38. Enter Program Name and click on create.

    http://scn.sap.com/docs/DOC-27396

  • How to pass data to Web Dynpro ABAP from ABAP - Part 2

    Generated by Jive on 2013-08-30+02:002

    Enter description, select report type and click on Save.

    http://scn.sap.com/servlet/JiveServlet/showImage/102-27397-4-97139/1.jpg

  • How to pass data to Web Dynpro ABAP from ABAP - Part 2

    Generated by Jive on 2013-08-30+02:003

    Now Enter the below code

    Header 1

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

    *& Report ZKK_FLIGHT_SHM_DEMO

    *&

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

    http://scn.sap.com/servlet/JiveServlet/showImage/102-27397-4-97140/2.jpg

  • How to pass data to Web Dynpro ABAP from ABAP - Part 2

    Generated by Jive on 2013-08-30+02:004

    *& Author: V Kiran Kumar Reddy

    *& Purpose: Shared Memory Objects Demo

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

    *& 1. Create Screen 0100.

    *& 2. Create calls to PBO and PAI in the flow logic of screen 0100:

    *& PROCESS BEFORE OUTPUT.

    *& MODULE STATUS_0100.

    *&

    *& PROCESS AFTER INPUT.

    *& MODULE USER_COMMAND_0100.

    *&

    *& 3. Create GUI status zpf_shm, assign Functions SAVE and EXIT to

    *& standard icons. and create Title zt_shm.

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

    REPORT ZKK_FLIGHT_SHM_DEMO.

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

    * CLASS lcl_flight_alv DEFINITION

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

    CLASS lcl_flight_alv DEFINITION.

  • How to pass data to Web Dynpro ABAP from ABAP - Part 2

    Generated by Jive on 2013-08-30+02:005

    PUBLIC SECTION.

    METHODS: display_alv, " Display ALV

    handle_double_click FOR EVENT double_click " Event Handler Method

    OF cl_gui_alv_grid

    IMPORTING e_row.

    PRIVATE SECTION.

    DATA: lr_grid TYPE REF TO cl_gui_alv_grid,

    lt_sflight TYPE STANDARD TABLE OF sflight,

    ls_sflight TYPE sflight.

    ENDCLASS. "lcl_alv_event DEFINITION

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

    * CLASS lcl_flight_alv IMPLEMENTATION

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

    CLASS lcl_flight_alv IMPLEMENTATION.

    METHOD display_alv.

    * Get Flight Data from DB

    SELECT * FROM sflight INTO TABLE lt_sflight UP TO 10 ROWS. " Only 10 records fordemo

  • How to pass data to Web Dynpro ABAP from ABAP - Part 2

    Generated by Jive on 2013-08-30+02:006

    * Create ALV Instance

    CREATE OBJECT lr_grid

    EXPORTING

    i_parent = cl_gui_custom_container=>screen0. " Default sceen ( No need of customcontainer )

    * Display ALV

    CALL METHOD lr_grid->set_table_for_first_display

    EXPORTING

    i_structure_name = 'SFLIGHT'

    CHANGING

    it_outtab = lt_sflight.

    CALL SCREEN 100.

    ENDMETHOD. "display_alv

    METHOD handle_double_click.

    DATA: lr_shm_handle TYPE REF TO zcl_flight_data_area,

    lr_shm_root TYPE REF TO zcl_flight_data_root.

  • How to pass data to Web Dynpro ABAP from ABAP - Part 2

    Generated by Jive on 2013-08-30+02:007

    * Get the double clicked row (selected Flight data)

    READ TABLE lt_sflight INTO ls_sflight INDEX e_row.

    TRY .

    * Writing to Shared Memory ( Exporting to memory )

    lr_shm_handle = zcl_flight_data_area=>attach_for_write( ).

    CREATE OBJECT lr_shm_root AREA HANDLE lr_shm_handle.

    lr_shm_handle->set_root( lr_shm_root ).

    lr_shm_root->set_selected_flight( exporting is_flight = ls_sflight ).

    lr_shm_handle->detach_commit( ).

    CATCH cx_shm_no_active_version

    cx_shm_read_lock_active

    cx_shm_change_lock_active

    cx_shm_exclusive_lock_active

    cx_shm_inconsistent.

    ENDTRY.

    * Call Flight Bookings Web Dynpro Appl

    CALL TRANSACTION 'ZBOOKINGS_SHM'.

    ENDMETHOD. "handle_double_click

  • How to pass data to Web Dynpro ABAP from ABAP - Part 2

    Generated by Jive on 2013-08-30+02:008

    ENDCLASS. "lcl_alv_event IMPLEMENTATION

    START-OF-SELECTION.

    * Data declaration for local flight object

    DATA lr_flight_alv TYPE REF TO lcl_flight_alv.

    * Creating instance of local flight class

    CREATE OBJECT lr_flight_alv.

    * Registering Event Handler.

    SET HANDLER lr_flight_alv->handle_double_click FOR ALL INSTANCES.

    * Call method to display ALV

    lr_flight_alv->display_alv( ).

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

  • How to pass data to Web Dynpro ABAP from ABAP - Part 2

    Generated by Jive on 2013-08-30+02:009

    * MODULE STATUS_0100 OUTPUT

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

    *

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

    MODULE STATUS_0100 OUTPUT.

    * Set title bar & PF status

    SET TITLEBAR 'ZT_SHM'. " Create title bar zt_shm

    SET PF-STATUS 'ZPF_SHM'. " Create PF status zpf_shm

    ENDMODULE. "STATUS_0100 OUTPUT

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

    * MODULE USER_COMMAND_0100 INPUT

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

    *

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

    MODULE USER_COMMAND_0100 INPUT.

    IF sy-ucomm = 'BACK' or sy-ucomm = 'EXIT'.

    LEAVE PROGRAM.

    ENDIF.

  • How to pass data to Web Dynpro ABAP from ABAP - Part 2

    Generated by Jive on 2013-08-30+02:0010

    ENDMODULE. "USER_COMMAND_0100 INPUT

    Now Save and Activate the program.

    Result:

    Now Execute the Report (F8). We can see the Flight Data ALV.

    Double click on any row.

    http://scn.sap.com/servlet/JiveServlet/showImage/102-27397-4-97141/3.jpg

  • How to pass data to Web Dynpro ABAP from ABAP - Part 2

    Generated by Jive on 2013-08-30+02:0011

    We can see the Flight Bookings Web Dynpro Application for the selected Flight in the nextscreen.

    http://scn.sap.com/servlet/JiveServlet/showImage/102-27397-4-97142/4.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-27397-4-97143/5.jpg

  • How to pass data to Web Dynpro ABAP from ABAP - Part 2

    Generated by Jive on 2013-08-30+02:0012

    Explanation

    1. Here when we double click on any record in ALV, the handle_double_click method will becalled, and we are getting the selected row data using:

    Get selected row data

    * Get the double clicked row (selected Flight data)

    READ TABLE lt_sflight INTO ls_sflight INDEX e_row.

    2. Then we are Exporting the selected row data to Shared Memory using:

    Writing to Shared Memory (Export to Memory)

    * Writing to Shared Memory ( Exporting to memory )

    lr_shm_handle = zcl_flight_data_area=>attach_for_write( ).

    CREATE OBJECT lr_shm_root AREA HANDLE lr_shm_handle.

    lr_shm_handle->set_root( lr_shm_root ).

    lr_shm_root->set_selected_flight( exporting is_flight = ls_sflight ).

    lr_shm_handle->detach_commit( ).

    3. Then we are calling the Flight Bookings Data Web Dynpro Application

    Call Bookings Web Dynpro Application

    * Call Flight Bookings Web Dynpro Appl

  • How to pass data to Web Dynpro ABAP from ABAP - Part 2

    Generated by Jive on 2013-08-30+02:0013

    CALL TRANSACTION 'ZBOOKINGS_SHM'.

    4. Once the Web Dynpro Application is called, the WDDOINT method will be executed andhere we are Importing the data from Shared Memory which was exported earlier describedin step 2.

    Reading from Shared memory( Importing from Memory)

    * Reading from Shared Memory ( Importing from memory )

    lr_shm_handle = zcl_flight_data_area=>attach_for_read( ).

    lr_shm_handle->root->get_selected_flight(

    importing

    es_flight = ls_flight ).

    lr_shm_handle->detach( ).

    5. Once the data is importing from memory, we are fetching the Flight Bookings for theimported data and binding it to the Table UI.

    Get Flight Booking data and Binding to Table UI

    * Get Flight Bookings Data

    SELECT * FROM sbook INTO TABLE lt_bookings WHERE carrid = ls_flight-c