Use
If you do not always want to use the
write function to create the HTML page content (as described in Creating a Controller), and you want to create it as pure HTMLO layout instead, then create a view that you can call from the controller.Procedure
To do this, choose Create ® Page.
You cannot define auto-page attributes, since views cannot be called directly from the browser.
Create the following attribute:
<%@ page language="abap" %> <html> <head> <link rel="stylesheet" href="../../sap/public/bc/bsp/styles/sapbsp.css"> <title> Layout for Controller </title> </head> <body class="bspBody1"> </head> <body class="bspBody1"> <H1>View Example</H1> <H3>Hello, user <%= name%></H3></body> </html> |
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):
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( main_view ). endmethod. |
Result
You have created your own view for the layout.
Continue by
Calling the Controller.