Show TOC

Background documentationInterface IF_BSP_PAGE Locate this document in the navigation structure

 

The interface IF_BSP_PAGE gives access to information about a BSP such as the page names, the lifetime, the corresponding BSP application, the URL of the page, and so on.

IF_BSP_PAGE is implemented using the class CL_BSP_PAGE, which is the base class of all BSPs. Consequently, the methods and attributes of this interface are indirectly available by inheritance in all BSPs and can be accessed with the appropriate qualification via the interface name (for example "name = if_bsp_page~get_page_name( )").

The interface can also be addressed in all BSP event handlers by means of the parameter

page and can be extended to lower application levels if required. In particular, the BSP page attributes can be read and set using the methods get_attribute() and set_attribute().

Inheritance Hierarchy/Interface Composition
Implementing Classes

CL_BSP_PAGE

Enhanced Interface

-

Specialized Interfaces

-

Attributes

Attribute Name

Declaration Type

Description

co_format_currency

Constant

write() or to_string() method:

Displayed as currency

co_format_long

Constant

write() or to_string() method:

Long output

co_format_lower

Constant

write() or to_string() method:

Displayed in lower case

co_format_none

Constant

write() or to_string() method:

Default format

co_format_short

Constant

write() or to_string() method:

Short display

co_format_upper

Constant

write() or to_string() method:

Display in upper case

lifetime_page

Constant

Page is valid until explicit navigation away from this page

lifetime_request

Constant

Page is only valid for this HTTP Request

lifetime_session

Constant

Page is valid for the complete session (only for stateful BSP applications)

messages

instance attribute

Reference to the messages object of this BSP

Methods
Method get_application

Signature

Syntax Syntax

  1. method get_application
      returning 
        application type ref to object
      .
    
End of the source code.

Description

This method returns the application object for this BSP.

If no application class was defined for the BSP application of this page, a zero (0) reference is returned.

Parameters

-

Return Values/Exceptions

application

Name of the BSP application

Cross References

Application Class of a BSP Application

Method get_application_name

Signature

Syntax Syntax

  1. method get_application_name
      returning 
        name  type string
      .
    
End of the source code.

Description

This method returns the name of the BSP application of this page as defined in the development environment (transaction SE80).

Parameters

-

Return Values/Exceptions

name

Name of the BSP application

Cross References

-

Methode get_application_start_page

Signature

Syntax Syntax

  1. method get_application_start_page
      returning
        start_page type string 
      .
    
End of the source code.

Description

This method returns the start page of the corresponding BSP application as defined in the development environment (SE80). If no page was explicitly specified, the method returns the name default.htm. The start page of a BSP application is called if no specific page is included in the URL when the application is started, in other words, when the URL ends with the application name.

Parameters

-

Return Values/Exceptions

start_page

Start page of BSP application

Cross References

-

Method get_application_url

Signature

Syntax Syntax

  1. method get_application_url 
      returning
        url type string 
      .
    
End of the source code.

Description

This method returns a server-specific URL that references the current BSP application, for example /sap/bc/bsp/sap/retailstore.

Parameters

-

Return Values/Exceptions

url

Server-specific URL of current BSP application.

Cross References

-

Method get_attribute

Signature

Syntax Syntax

  1. method get_attribute 
      importing
        name  type string
      exporting 
        value type any 
      .
    
End of the source code.

Description

This method returns the value of the requested attribute. Since attributes can be of any type, the return value can only be untyped and must be integrated type-related when called.

Caution Caution

ABAP move logic plays a role in the assignment of the attribute value to the return value to enable the type conversion to take place. The ABAP restrictions regarding type conversion apply so that exceptions may occur in the event of incompatible type assignments.

End of the caution.

Parameters

name

Name of attribute (case-insensitive)

Return Values/Exceptions

value

Attribute value

cx_bsp_inv_attr_name

Exception: Attribute does not exist

Cross References

Refer also to:

set_attribute()

Method get_lifetime

Signature

Syntax Syntax

  1. method get_lifetime
      returning 
        lifetime type i 
      .
    
End of the source code.

Description

This method returns the current settings of the lifetime of this BSP page (see lifetime_ constants of the IF_BSP_PAGE).

This method has no effect on stateless applications and always returns the value lifetime_request.

Parameters

-

Return Values/Exceptions

lifetime

Current lifetime of the BSP (see lifetime_ constants of the IF_BSP_PAGE):

lifetime_page | lifetime_request | lifetime_session

Cross References

See also:

set_lifetime, lifetime_page, lifetime_request, lifetime_session

Method get_page_name

Signature

Syntax Syntax

  1. method get_page_name
      returning 
        name type string 
      .
    
End of the source code.

Description

This method returns the name of this BSP.

Parameters

-

Return Values/Exceptions

name

Name of BSP

Cross References

-

Method get_page_url

Signature

Syntax Syntax

  1. method get_page_url
      returning
        url type string
      .
    
End of the source code.

Description

This method returns the server-specific URL for this BSP.

Parameters

-

Return Values/Exceptions

url

Server-specific URL of the BSP

Cross References

-

Methode get_request

Signature

Syntax Syntax

  1. method get_request
      returning
        request type ref to if_http_request
      .
    
End of the source code.

Description

This method returns an interface reference to the current HTTP request object.

Parameters

-

Return Values/Exceptions

request

Interface reference to the HTTP request object

Cross References

See also:

IF_HTTP_SERVER

IF_HTTP_RESPONSE and IF_HTTP_REQUEST

Methode get_response

Signature

Syntax Syntax

  1. method get_response
      returning
        response type ref to if_http_response
      .
    
End of the source code.

Description

This method returns an interface reference to the current HTTP response object.

Parameters

-

Return Values/Exceptions

response

Interface reference to the HTTP response object

Cross References

See also:

IF_HTTP_SERVER

IF_HTTP_RESPONSE and IF_HTTP_REQUEST

Methode get_runtime

Signature

Syntax Syntax

  1. method get_runtime
      returning
        runtime type ref to if_bsp_runtime
      .
    
End of the source code.

Description

This method returns an interface reference to the current BSP runtime object.

Parameters

-

Return Values/Exceptions

runtime

Interface reference to the BSP runtime object

Cross References

-

Method serialize

Signature

Syntax Syntax

  1. method serialize
      returning
        data type string
      .
    
End of the source code.

Description

This method serializes the content of this page (after processing in the Layout event handler) in a string.

This method is typically only called in the OnManipulation section of the BSP when the generated output needs to be postprocessed. However, for performance reasons this is not recommended unless absolutely necessary.

Caution Caution

The output of a BSP is no longer automatically returned to the client in the HTTP Response when this method is called explicitly. Instead, the developer is responsible for sending it. This can be done with the method if_http_response~set_cdata() and the HTTP Response Object.

End of the caution.

Parameters

-

Return Values/Exceptions

data

Serialized response of the BSP after the layout section is processed.

Cross References

See also:

IF_HTTP_SERVER

IF_HTTP_RESPONSE and IF_HTTP_REQUEST

Method set_attribute

Signature

Syntax Syntax

  1. method set_attribute
      importing
        name  type string
        value type any
      .
    
End of the source code.

Description

This method sets the value of the specified attribute. Since attributes can be of any type, the parameter value can only be untyped and must be integrated type-related when called.

Caution Caution

This method does not let you define new attributes dynamically at runtime. On the contrary, only attributes that were defined in the development environment (SE80) statically for the BSP page can have values assigned. Otherwise, the method will terminate with the exception cx_bsp_inv_attr_name.

End of the caution.

Caution Caution

ABAP move logic plays a role in the assignment of a value to the attribute to enable the type conversion to take place. The ABAP restrictions regarding type conversion apply so that exceptions may occur in the event of incompatible type assignments.

End of the caution.

Parameters

name

Name of attribute (case-insensitive)

value

Value of attribute (appropriately typed)

Return Values/Exceptions

cx_bsp_inv_attr_name

Exception: Attribute does not exist

Cross References

See also: get_attribute()

Method set_lifetime

Signature

Syntax Syntax

  1. method set_lifetime
      importing
        lifetime type i
      .
    
End of the source code.

Description

This method sets the current settings of the lifetime of this BSP page (see lifetime_ constants of the IF_BSP_PAGE). This method has no effect on stateless applications.

Parameters

lifetime

New lifetime of the BSP (see lifetime_ constants of the IF_BSP_PAGE):

lifetime_page | lifetime_request | lifetime_session

Return Values/Exceptions

-

Cross References

See also: get_lifetime, lifetime_page, lifetime_request, lifetime_session

Method to_string

Signature

Syntax Syntax

  1. method to_string
      importing
        value           type any
        format          type i optional
        outputlength    type i optional
        num_decimals    type i optional
        reference_value type c
      returning
        string          type string
      .
    
End of the source code.

Description

This method formats as a string the value of a scalar ABAP variable with any type. There are several optional parameters available to let you control the formatting. The string generated can be easily integrated in the output in a BSP using the output directive <%= .. %>.

Parameters

value

Value to be formatted

format

Output format (see if_bsp_page~co_format_.. constants)

outputlength

Maximum output length (in characters)

num_decimals

Number of decimal places

reference_value

Reference value (for example, the currency)

Return Values/Exceptions

output

Formatted output string

Cross References

See also: write()

Method write

Signature

Syntax Syntax

  1. method write
      importing
        value           type any
        format          type i optional
        outputlength    type i optional
        num_decimals    type i optional
        reference_value type c
      .
    
End of the source code.

Description

This method outputs as a string the value of a scalar ABAP variable with any type. Output is at the current “write position” in the BSP. There are several optional parameters available to let you control the formatting.

This method can be used for output in a BSP for example, in script directives <% .. %>.

Parameters

value

Value to be formatted

format

Output format (see if_bsp_page~co_format_.. constants)

outputlength

Maximum output length (in characters)

num_decimals

Number of decimal places

reference_value

Reference value (for example, the currency)

Return Values/Exceptions

-

Cross References

See also: to_string

Method otr_trim

Signature

Syntax Syntax

  1. method otr_trim
      importing alias
      returning
        text
      .
    
End of the source code.

Description

This method returns the language-dependent text for an OTR alias (short text).‎

This method is available from SAP Web AS 6.20 Support Package 7.

Parameters

alias

Name of the defined OTR alias

Return Values/Exceptions

text

Text in current language

Cross References

See also: Internationalization and Translation