Skip to Content
Introduction:- This blog will narrate “Navigation between BSP Applications”.

This blog is described into two parts for better understanding.

  • BSP Application using MVC Architecture
    1. From MVC-BSP Application to MVC-BSP Application
    2. From MVC-BSP Application to Flow Logic BSP Application
  • BSP Application using Flow Logic Methodology
    1. From Flow Logic-BSP Application to MVC-BSP Application
    2. From Flow Logic-BSP Application to Flow Logic BSP Application


Let’s look at Part-I…


Scenario: The scenario which i took here to explain the Navigation process is: The main BSP Application will accept the Employee’s personal Number as input from user & pass it to another BSP Application which shows the details of employee and comes back to main BSP Application when event is triggered.

To pass the data: I used two approaches to pass the data’s between the BSP Application.

  1. Via URL -You can use this approach just to pass one or two variables between applications.
  2. Via cookies – Server/Client side cookies –
  3. If you need to pass Structures or Internal tables you can use this approach.

1. Let’s start how to navigate from MVC-BSP Application to MVC-BSP Application…

Highlights: – We’re going to create the following objects:

  1. Model Class of Source BSP Application- ZCL_MVC_PERNR.
  2. Source BSP Application- YMVC_NAV
  3. Controller class -YMVC_NAV_CTRL.
  4. Model class of Target BSP Application-ZCL_MVC_PERNR_DETAIL.
  5. Target BSP Application-YMVC_TARGET.
  6. Controller calss-YMVC_TARGET_CTRL.

Let’s see in detail: Steps involved to create the Source BSP Application:-YMVC_NAV

    1. Create Model Class-ZCL_MVC_PERNR


image

!https://weblogs.sdn.sap.com/weblogs/images/11786/MVC2.JPG|height=342|alt=image|width=353|src=https://weblogs.sdn.sap.com/weblogs/images/11786/MVC2.JPG|border=0!


image


image

    1. Write below code in DO_INIT method of controller class
    2. Write below code in DO_REQUEST method.
    3. Write below code in DO_HANDLE_EVENT method

SERVER_EVENT.
      WHEN ‘navigate’.


  1. Construct the Target URL


        CALL METHOD RUNTIME->CONSTRUCT_BSP_URL
          EXPORTING
            IN_PROTOCOL       = ‘http’
            IN_APPLICATION_NS = RUNTIME->APPLICATION_NAMESPACE
            IN_APPLICATION    = RUNTIME->APPLICATION_NAME
            IN_PAGE           = ‘**/YMVC_TARGET/main.do’
          IMPORTING
            OUT_ABS_URL       = V_TARGET_URL.


        CONCATENATE RUNTIME->APPLICATION_NAME ‘/**/’ INTO W_APP_NAME.


        REPLACE W_APP_NAME IN V_TARGET_URL WITH SPACE.


  1. Pass the Emp. Personal Number via URL

        CONCATENATE V_TARGET_URL ‘?pernr=’ MODEL_ID->PERNR INTO V_TARGET_URL.


  1. Set Server side cookie to store the source BSP appl detail


        V_COOKIE = ‘YMVC_NAV/main.do’.


        CALL METHOD CL_BSP_SERVER_SIDE_COOKIE=>SET_SERVER_COOKIE
          EXPORTING
            NAME                  = ‘source_bsp’
            APPLICATION_NAME      = ‘NONE’
            APPLICATION_NAMESPACE = ‘NONE’
            USERNAME              = SY-UNAME
            SESSION_ID            = ‘NONE’
            DATA_VALUE            = V_COOKIE
            DATA_NAME             = ‘sbsp’
            EXPIRY_TIME_REL       = 3600.


        NAVIGATION->GOTO_PAGE( V_TARGET_URL ).


      WHEN OTHERS.
    ENDCASE.
  ENDIF.
ENDMETHOD.


image

VIEW_NAME IS INITIAL.


  1. Get the value of Page level variables.
  2. Get the values from source BSP Application which was set via URL

    MODEL_ID->PERNR = REQUEST->GET_FORM_FIELD( ‘pernr’ ).


    IF MODEL_ID->SOURCE_BSP IS INITIAL.

  1. Get the values  from source BSP Application which was set via Cookies

      CALL METHOD CL_BSP_SERVER_SIDE_COOKIE=>GET_SERVER_COOKIE
        EXPORTING
          NAME                  = ‘source_bsp’
          APPLICATION_NAME      = ‘NONE’
          APPLICATION_NAMESPACE = ‘NONE’
          USERNAME              = SY-UNAME
          SESSION_ID            = ‘NONE’
          DATA_NAME             = ‘sbsp’
        CHANGING
          DATA_VALUE            = MODEL_ID->SOURCE_BSP.


    ENDIF.


  1. Get the details of Employee

    IF MODEL_ID->PERNR IS NOT INITIAL.
      CALL METHOD MODEL_ID->GET_DETAIL.
    ENDIF.
    ME->VIEW_NAME = ‘target.htm’.
  ENDIF.


  VIEW = ME->CREATE_VIEW( VIEW_NAME = ME->VIEW_NAME ).
  IF VIEW IS BOUND.
    VIEW->SET_ATTRIBUTE( NAME = ‘model_id’ VALUE = ME->MODEL_ID ).
    ME->CALL_VIEW( VIEW ).
  ENDIF.
ENDMETHOD.


image

  1. We can re-use the Model class of Source BSP Application- ZCL_MVC_PERNR – No Change required
  2. Source BSP Application- YMVC_NAV – No change Required
  3. Controller class -YMVC_NAV_CTRL – Need to change the DO_HANDLE_EVENT to call the Flow Logic BSP Application.
  4. Create Flow logic BSP Application (Target)-YFL_TARGET.

Let’s see in detail:

    1. Change the DO_HANDLE_EVENT method with following: Check the comments, I mentioned different ways to pass the datas to Target application

SERVER_EVENT.
      WHEN ‘navigate’.


  1. Construct the Target URL


        CALL METHOD RUNTIME->CONSTRUCT_BSP_URL
          EXPORTING
            IN_PROTOCOL       = ‘http’
            IN_APPLICATION_NS = RUNTIME->APPLICATION_NAMESPACE
            IN_APPLICATION    = RUNTIME->APPLICATION_NAME
            IN_PAGE           = ‘**/YFL_TARGET/target_Page.htm’ “‘**/YMVC_TARGET/main.do’
          IMPORTING
            OUT_ABS_URL       = V_TARGET_URL.


        CONCATENATE RUNTIME->APPLICATION_NAME ‘/**/’ INTO W_APP_NAME.


        REPLACE W_APP_NAME IN V_TARGET_URL WITH SPACE.


  1. Set Server side cookie to store the source BSP appl detail


        V_COOKIE = ‘YMVC_NAV/main.do’.


        CALL METHOD CL_BSP_SERVER_SIDE_COOKIE=>SET_SERVER_COOKIE
          EXPORTING
            NAME                  = ‘source_bsp’
            APPLICATION_NAME      = ‘NONE’
            APPLICATION_NAMESPACE = ‘NONE’
            USERNAME              = SY-UNAME
            SESSION_ID            = ‘NONE’
            DATA_VALUE            = V_COOKIE
            DATA_NAME             = ‘sbsp’
            EXPIRY_TIME_REL       = 3600.


        NAVIGATION->SET_PARAMETER( NAME = ‘pernr’ VALUE = MODEL_ID->PERNR ).

  1. Or Even you can Pass the Emp. Personal Number via URL
  2.        CONCATENATE V_TARGET_URL ‘?pernr=’ MODEL_ID->PERNR INTO V_TARGET_URL.


        NAVIGATION->GOTO_PAGE( V_TARGET_URL ).


      WHEN OTHERS.
    ENDCASE.
  ENDIF.
ENDMETHOD.



  1. event handler for data retrieval


    IF SOURCE_BSP IS INITIAL.

  1. Get the values  from source BSP Application which was set via Cookies

      CALL METHOD CL_BSP_SERVER_SIDE_COOKIE=>GET_SERVER_COOKIE
        EXPORTING
          NAME                  = ‘source_bsp’
          APPLICATION_NAME      = ‘NONE’
          APPLICATION_NAMESPACE = ‘NONE’
          USERNAME              = SY-UNAME
          SESSION_ID            = ‘NONE’
          DATA_NAME             = ‘sbsp’
        CHANGING
          DATA_VALUE            = SOURCE_BSP.


    ENDIF.


    DATA: L_PERNR TYPE PERNR_D.


    L_PERNR  = PERNR.
    CALL FUNCTION ‘HR_READ_INFOTYPE’
      EXPORTING
        PERNR                 = L_PERNR
        INFTY                 = ‘0006’
      TABLES
        INFTY_TAB             = I_DETAIL
     EXCEPTIONS
       INFTY_NOT_FOUND       = 1
       OTHERS                = 2
              .
    IF SY-SUBRC <> 0.

ENDIF.

    1. Write below code in Oninputprocessing.


  1. event handler for checking and processing user input and
  2. for defining navigation


DATA EVENT TYPE REF TO CL_HTMLB_EVENT.


DATA: V_TARGET_URL TYPE STRING,
        W_APP_NAME TYPE STRING.


IF NOT EVENT_ID IS INITIAL.


  EVENT ?= CL_HTMLB_MANAGER=>GET_EVENT_EX( REQUEST ).


  IF NOT EVENT IS INITIAL.


    CASE EVENT->SERVER_EVENT.


      WHEN ‘back’.
        CALL METHOD REQUEST->GET_FORM_FIELD
          EXPORTING
            NAME  = ‘source_bsp’
          RECEIVING
            VALUE = SOURCE_BSP.


        CONCATENATE ‘**/’ SOURCE_BSP INTO SOURCE_BSP.


        CALL METHOD RUNTIME->CONSTRUCT_BSP_URL
          EXPORTING
            IN_PROTOCOL       = ‘http’
            IN_APPLICATION_NS = RUNTIME->APPLICATION_NAMESPACE
            IN_APPLICATION    = RUNTIME->APPLICATION_NAME
            IN_PAGE           = SOURCE_BSP
          IMPORTING
            OUT_ABS_URL       = V_TARGET_URL.


        CONCATENATE RUNTIME->APPLICATION_NAME ‘/**/’ INTO W_APP_NAME.


        REPLACE W_APP_NAME IN V_TARGET_URL WITH SPACE.


        NAVIGATION->GOTO_PAGE( V_TARGET_URL ).


    ENDCASE.
  ENDIF.
ENDIF.


image


Last but not the least, my special Thanks to Payal Sinha who helped me to narrate this…


To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Anonymous
    Hi,

    Do you know how can I pass values between BSP pages at the Application Class level?  Or, is there another way of passing values between pages?

    Thanks in advance for your help!
    Sarah

    (0) 

Leave a Reply