Entering content frame

Procedure documentation Event Handlers for the Results Page Locate the document in its SAP Library structure

Two event handlers are required for the processing procedure of the results page (results.htm), OnInitialization and OnInputProcessing.

OnInitialization

data: isbn_tab TYPE isbn_tab.

CALL METHOD cl_book_shop=>search_book
    EXPORTING
        author = author
        title = title
        publisher = publisher
        ISBN = ISBN
        keyword = keyword
    IMPORTING isbn_tab = isbn_tab
    EXCEPTIONS
        no_search_parameter = 2
        invalid_isbn = 4.

if sy-subrc = 4.
  navigation->goto_page( 'invalid_isbn.htm' ).
elseif sy-subrc <> 0.
  navigation->goto_page( 'error.htm' ).
endif.

IF sy-subrc = 0.
  CALL METHOD cl_book_shop=>get_book_data
    EXPORTING
      isbn_tab = isbn_tab
    IMPORTING
      bookcat_tab = bookcat_tab
    EXCEPTIONS
      empty_input_table = 2
      invalid_isbn = 4.
ENDIF.

The data statement sets the data transfer for the ISBN table.

The method search_book of the class cl_book_shop is used to search for book titles that match the user input. When this happens, the method search_book gets the page parameters author, title, publisher, isbn and keyword, and the parameter isbn_tab is returned with the results of the search. The following exceptions or errors are defined in search_book:

This scenario is already taken care of by OnInputProcessing on the search page. Therefore, it cannot occur here.

In this case, the ISBN error page (invalid_isbn.htm) is called.

In this case, the general error page (error.htm) is called.

If no errors occur, the method get_book_data of the class cl_book_shop is called, which finds suitable results. Sometimes, no suitable results are found, that is, isbn_tab is empty. In this case, get_book_data returns sy-subrc = 2, and the table bookcat_tab is empty. The layout part checks for this scenario.

OnInputProcessing

navigation->set_parameter( 's_cata_id' ).

Based on the user input, the book page is opened for the book with the s_cata_id that was specified in the layout with the statement below:

<a href="showbook.htm?s_cata_id=<%= bookcat-cata_id %>">

This graphic is explained in the accompanying text Layout for the Book Page

 

 

Leaving content frame