1. 程式人生 > 其它 >WDA基礎十五:POPUP WINDOW

WDA基礎十五:POPUP WINDOW

1.元件控制器定義屬性:

2.實現popup方法:

METHOD stock_popup .
  DATA: l_cmp_api        TYPE REF TO if_wd_component,
        l_window_manager TYPE REF TO if_wd_window_manager,
        l_msg            TYPE string,
        l_text           TYPE string_table,
        l_api            TYPE REF TO if_wd_view_controller,
        l_popup          TYPE REF TO if_wd_window.
  CLEAR: wd_comp_controller->it_stock_total[].
  IF NOT it_stock_total[] IS INITIAL.
    wd_comp_controller->it_stock_total[] = it_stock_total[].
    l_api = wd_this->wd_get_api( ).
    l_cmp_api = wd_comp_controller->wd_get_api( ).
    l_window_manager = l_cmp_api->get_window_manager( ).
    wd_comp_controller->win_display_stock = l_window_manager->create_window(
    modal                = abap_true
    window_name          = 'WIN_DISPLAY_STOCK'
    title                = cl_wd_utilities=>get_otr_text_by_alias( 'ZCRM/STOCKINFO' )  "彈出框的標題
    close_button         = abap_false
    button_kind          = if_wd_window=>co_buttons_ok
    message_display_mode = '1'
    ).

    wd_comp_controller->win_display_stock->subscribe_to_button_event(
    button            = if_wd_window=>co_button_ok
    action_name       = 'POPUP_STOCK_OK'
    action_view       = l_api
    is_default_button = abap_true ).

    wd_comp_controller->win_display_stock->open( ).
  ENDIF.
ENDMETHOD.

這是呼叫當前程式裡的視窗。

3.OK事件:

隨便寫程式碼。。。

 

4.跳轉到URL:

method MX_FIRE_TO_NEW_WINDOW .
DATA: WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER,
        API_COMPONENT  TYPE REF TO IF_WD_COMPONENT,
        LO_WINDOW      TYPE REF TO IF_WD_WINDOW.
  DATA: ES_LOGIN TYPE ZPORTAL_LOGIN.
  DATA LV_USER TYPE STRING.
  DATA: UTILITY TYPE REF TO CL_HTTP_UTILITY.
  CREATE OBJECT UTILITY.
  DATA LV_OBJID_STR TYPE STRING.
   DATA LV_URL TYPE STRING.


  LV_OBJID_STR = IV_OBJECT_ID.
  CALL METHOD UTILITY->ENCODE_BASE64  "?a?ü
    EXPORTING
      UNENCODED = LV_OBJID_STR
    RECEIVING
      ENCODED   = LV_OBJID_STR.


  API_COMPONENT  = WD_COMP_CONTROLLER->WD_GET_API( ).
  WINDOW_MANAGER = API_COMPONENT->GET_WINDOW_MANAGER( ).

  CALL FUNCTION 'GET_LOGIN_PROFILE'
    IMPORTING
      ES_PORTAL_LOGIN = ES_LOGIN.

  LV_USER = ES_LOGIN-PARTNER.
  CALL METHOD UTILITY->ENCODE_BASE64  "?a?ü
    EXPORTING
      UNENCODED = LV_USER
    RECEIVING
      ENCODED   = LV_USER.

  CONCATENATE '/sap/bc/webdynpro/sap/ZHSCRM_SERVICE_ORDER_DISPLAY?IV_OBJECT_ID='
  LV_OBJID_STR '&IV_USER=' LV_USER '&IV_CHANGE=X' INTO LV_URL.

  CALL METHOD WINDOW_MANAGER->CREATE_EXTERNAL_WINDOW
    EXPORTING
      URL            = LV_URL
      TITLE          = 'WELCOME TO WEBSITE'
      MODAL          = ABAP_FALSE
      HAS_MENUBAR    = ABAP_TRUE
      IS_RESIZABLE   = ABAP_TRUE
      HAS_SCROLLBARS = ABAP_TRUE
      HAS_STATUSBAR  = ABAP_TRUE
      HAS_TOOLBAR    = ABAP_TRUE
      HAS_LOCATION   = ABAP_TRUE
    RECEIVING
      WINDOW         = LO_WINDOW.

  LO_WINDOW->OPEN( ).
endmethod.

 

2.實現popup方法:

METHOD stock_popup .
  DATA: l_cmp_api        TYPE REF TO if_wd_component,
        l_window_manager TYPE REF TO if_wd_window_manager,
        l_msg            TYPE string,
        l_text           TYPE string_table,
        l_api            TYPE REF TO if_wd_view_controller,
        l_popup          TYPE REF TO if_wd_window.
  CLEAR: wd_comp_controller->it_stock_total[].
  IF NOT it_stock_total[] IS INITIAL.
    wd_comp_controller->it_stock_total[] = it_stock_total[].
    l_api = wd_this->wd_get_api( ).
    l_cmp_api = wd_comp_controller->wd_get_api( ).
    l_window_manager = l_cmp_api->get_window_manager( ).
    wd_comp_controller->win_display_stock = l_window_manager->create_window(
    modal                = abap_true
    window_name          = 'WIN_DISPLAY_STOCK'
    title                = cl_wd_utilities=>get_otr_text_by_alias( 'ZCRM/STOCKINFO' )  "彈出框的標題
    close_button         = abap_false
    button_kind          = if_wd_window=>co_buttons_ok
    message_display_mode = '1'
    ).

    wd_comp_controller->win_display_stock->subscribe_to_button_event(
    button            = if_wd_window=>co_button_ok
    action_name       = 'POPUP_STOCK_OK'
    action_view       = l_api
    is_default_button = abap_true ).

    wd_comp_controller->win_display_stock->open( ).
  ENDIF.
ENDMETHOD.

這是呼叫當前程式裡的視窗。

3.OK事件:

隨便寫程式碼。。。

 

4.跳轉到URL:

method MX_FIRE_TO_NEW_WINDOW .
DATA: WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER,
        API_COMPONENT  TYPE REF TO IF_WD_COMPONENT,
        LO_WINDOW      TYPE REF TO IF_WD_WINDOW.
  DATA: ES_LOGIN TYPE ZPORTAL_LOGIN.
  DATA LV_USER TYPE STRING.
  DATA: UTILITY TYPE REF TO CL_HTTP_UTILITY.
  CREATE OBJECT UTILITY.
  DATA LV_OBJID_STR TYPE STRING.
   DATA LV_URL TYPE STRING.


  LV_OBJID_STR = IV_OBJECT_ID.
  CALL METHOD UTILITY->ENCODE_BASE64  "?a?ü
    EXPORTING
      UNENCODED = LV_OBJID_STR
    RECEIVING
      ENCODED   = LV_OBJID_STR.


  API_COMPONENT  = WD_COMP_CONTROLLER->WD_GET_API( ).
  WINDOW_MANAGER = API_COMPONENT->GET_WINDOW_MANAGER( ).

  CALL FUNCTION 'GET_LOGIN_PROFILE'
    IMPORTING
      ES_PORTAL_LOGIN = ES_LOGIN.

  LV_USER = ES_LOGIN-PARTNER.
  CALL METHOD UTILITY->ENCODE_BASE64  "?a?ü
    EXPORTING
      UNENCODED = LV_USER
    RECEIVING
      ENCODED   = LV_USER.

  CONCATENATE '/sap/bc/webdynpro/sap/ZHSCRM_SERVICE_ORDER_DISPLAY?IV_OBJECT_ID='
  LV_OBJID_STR '&IV_USER=' LV_USER '&IV_CHANGE=X' INTO LV_URL.

  CALL METHOD WINDOW_MANAGER->CREATE_EXTERNAL_WINDOW
    EXPORTING
      URL            = LV_URL
      TITLE          = 'WELCOME TO WEBSITE'
      MODAL          = ABAP_FALSE
      HAS_MENUBAR    = ABAP_TRUE
      IS_RESIZABLE   = ABAP_TRUE
      HAS_SCROLLBARS = ABAP_TRUE
      HAS_STATUSBAR  = ABAP_TRUE
      HAS_TOOLBAR    = ABAP_TRUE
      HAS_LOCATION   = ABAP_TRUE
    RECEIVING
      WINDOW         = LO_WINDOW.

  LO_WINDOW->OPEN( ).
endmethod.

 

搜尋

複製