Show TOC

Procedure documentationCreating Views Locate this document in the navigation structure

 

If you do not always want to use the write function to create the HTML page content (as described in Creating Controllers), and you want to create it as pure HTMLO layout instead, then create a view that you can call from the controller.

Procedure

  1. Begin as if you are creating a normal page with flow logic in your BSP application.

    To do this, choose   Create   Page  .

    This graphic is explained in the accompanying text.

  2. In the following dialog box, enter a name and short description of the view and select View as the page type:

    This graphic is explained in the accompanying text.

  3. Choose .

  4. Create the attributes for the variable parts of the view.

    Note Note

    You cannot define auto-page attributes, since views cannot be called directly from the browser.

    End of the note.

    Create the following attribute:

    This graphic is explained in the accompanying text.

  5. Define the layout as usual:

    Syntax Syntax

    1. <%@page language="abap" %>
      <html>
        <head>
          <link rel="stylesheet" href="../../sap/public/bc/bsp/styles/sapbsp.css">
          <title> Layout zum Controller </title>
        </head>
        <body class="bspBody1">
          <H1>View-Beispiel</H1>
          <H3>Hallo, Benutzer <%= name%></H3>
        </body>
      </html>
      
    End of the code.
  6. Activate the view.

  7. Finally, adjust the DO_REQUEST method to the controller class.

    Here, the schema is always the same. First you create the view, then you set the attributes, and then you call the view. (For the time being you can ignore the warning concerning exception CX_STATIC_CHECK, or you can set a try-catch block around the calls): .

    Syntax Syntax

    1. method DO_REQUEST .
      data: myview type ref to if_bsp_page.
      
        myview = create_view( view_name = 'view_test.htm' ).
        myview->set_attribute( name = 'name' value = sy-uname ).
        call_view( myview ).
      
      endmethod.
      
    End of the code.

Result

You have created your own view for the layout.

This graphic is explained in the accompanying text.

Continue by Calling the Controller.