• SAP web 开发 (第二篇 bsp 开发 mvc模式 Part2 )


    单击第一个图标,第一个图标突出显示,单击第二个图标,第一个变灰,第二个突出显示,反之一样。单击history读取历史记录。

    Controller ZCL_SUS_C_ORDER_CHANGE

    1. 1.    DO_INIT

    method DO_INIT.

    *CALL METHOD SUPER->DO_INIT

    *    .

      if  ZORDERCHANGEMODEL is initial.

        create object ZORDERCHANGEMODEL.

        select * from usr02 into corresponding fields of table ZORDERCHANGEMODEL->ORDERCHANGE up to 5 rows.

        field-symbols <usr_tab> like line of ZORDERCHANGEMODEL->ORDERCHANGE.

        loop at ZORDERCHANGEMODEL->ORDERCHANGE assigning <usr_tab>.

          <usr_tab>-icons = '/sap/bc/bsp/sap/srmsus/images/order/ok-grau.gif'.

          <usr_tab>-cancel = '/sap/bc/bsp/sap/srmsus/images/order/cancel-grau.gif'.

        endloop.

     

        append initial line to ZORDERCHANGEMODEL->ORDERCHANGE_history.

        append initial line to ZORDERCHANGEMODEL->ORDERCHANGE_history.

        append initial line to ZORDERCHANGEMODEL->ORDERCHANGE_history.

        append initial line to ZORDERCHANGEMODEL->ORDERCHANGE_history.

        append initial line to ZORDERCHANGEMODEL->ORDERCHANGE_history.

        loop at ZORDERCHANGEMODEL->ORDERCHANGE_history assigning <usr_tab>.

          <usr_tab>-icons = '/sap/bc/bsp/sap/srmsus/images/order/ok-grau.gif'.

          <usr_tab>-cancel = '/sap/bc/bsp/sap/srmsus/images/order/cancel-grau.gif'.

          <usr_tab>-bname = 'history'.

        endloop.

        create object ZORDERCHANGEMODEL->io_iterator.

        ZORDERCHANGEMODEL->io_iterator->request = request.

      endif.

    endmethod.

    1. 2.    DO_REQUEST

    method DO_REQUEST.

    *CALL METHOD SUPER->DO_REQUEST

    *    .

    me->DISPATCH_INPUT( ).

    data: lo_view type ref to if_bsp_page.

    lo_view = create_view( view_name = '../order/order_change_response.inc' ).

    lo_view->set_attribute( name = 'zmodel'  value = ZORDERCHANGEMODEL  ).

    call_view( lo_view ).

    endmethod.

    1. 3.    DO_HANDLE_EVENT

    method DO_HANDLE_EVENT.

    *CALL METHOD SUPER->DO_HANDLE_EVENT

    *  EXPORTING

    *    EVENT           =

    *    HTMLB_EVENT     =

    **    HTMLB_EVENT_EX  =

    *    GLOBAL_MESSAGES =

    *  RECEIVING

    *    GLOBAL_EVENT    =

    *    .

    data lr_tableview type ref to CL_HTMLB_TABLEVIEW.

      lr_tableview ?= cl_htmlb_manager=>get_data(

                                    request = me->request

                                         id = 'zorder.cuschanged_t2'

                                       name = 'tableView' ).

      IF  NOT LR_TABLEVIEW IS INITIAL.

        IF LR_TABLEVIEW->DATA->SERVER_EVENT = 'onCellClick'

                 AND LR_TABLEVIEW->DATA->ID = 'zorder.cuschanged_t2'

                 AND LR_TABLEVIEW->DATA->NAME = 'tableView'

                 AND LR_TABLEVIEW->DATA->COLUMN_KEY = 'ICONS'

                 AND LR_TABLEVIEW->DATA->COLUMN_INDEX > 0

                 AND LR_TABLEVIEW->DATA->ROW_INDEX > 0.

          field-symbols: <usr_tab> type zusr02,

                         <usr_cancel> type zusr02.

          data usr_tab type zusr02.

          IF ZORDERCHANGEMODEL->HISTORY_SHOW = ''.

          read table ZORDERCHANGEMODEL->ORDERCHANGE  index LR_TABLEVIEW->DATA->ROW_INDEX assigning <usr_tab>.

          ELSE.

                read table ZORDERCHANGEMODEL->ORDERCHANGE_history  index LR_TABLEVIEW->DATA->ROW_INDEX assigning <usr_tab>.

          endif.

          if <usr_tab>-icons = '/sap/bc/bsp/sap/srmsus/images/order/ok.gif'.

            <usr_tab>-icons = '/sap/bc/bsp/sap/srmsus/images/order/ok-grau.gif'.

          else.

            <usr_tab>-icons = '/sap/bc/bsp/sap/srmsus/images/order/ok.gif'.

            <usr_tab>-cancel = '/sap/bc/bsp/sap/srmsus/images/order/cancel-grau.gif'.

          endif.

     

        ENDIF.

        IF LR_TABLEVIEW->DATA->SERVER_EVENT = 'onCellClick'

                 AND LR_TABLEVIEW->DATA->ID = 'zorder.cuschanged_t2'

                 AND LR_TABLEVIEW->DATA->NAME = 'tableView'

                 AND LR_TABLEVIEW->DATA->COLUMN_KEY = 'CANCEL'

                 AND LR_TABLEVIEW->DATA->COLUMN_INDEX > 0

                 AND LR_TABLEVIEW->DATA->ROW_INDEX > 0.

          IF ZORDERCHANGEMODEL->HISTORY_SHOW = ''.

          read table ZORDERCHANGEMODEL->ORDERCHANGE  index LR_TABLEVIEW->DATA->ROW_INDEX assigning <usr_tab>.

          ELSE.

                read table ZORDERCHANGEMODEL->ORDERCHANGE_history  index LR_TABLEVIEW->DATA->ROW_INDEX assigning <usr_tab>.

          endif.

          if <usr_tab>-cancel = '/sap/bc/bsp/sap/srmsus/images/order/cancel.gif'.

            <usr_tab>-cancel = '/sap/bc/bsp/sap/srmsus/images/order/cancel-grau.gif'.

          else.

            <usr_tab>-cancel = '/sap/bc/bsp/sap/srmsus/images/order/cancel.gif'.

            <usr_tab>-icons = '/sap/bc/bsp/sap/srmsus/images/order/ok-grau.gif'.

          endif.

        endif.

      ENDIF.

    if not htmlb_event is initial.

       if HTMLB_EVENT->SERVER_EVENT = 'onhistoryclick'.

          ZORDERCHANGEMODEL->HISTORY_SHOW = 'X'.

       elseif HTMLB_EVENT->SERVER_EVENT = 'onprocessclick'.

          ZORDERCHANGEMODEL->HISTORY_SHOW = ''.

       endif.

    endif.

    endmethod.

    1. 4.    View

    <%@page language="abap" otrTrim="true" %>

    <%@extension name="htmlb" prefix="htmlb" %>

    <%@extension name="SRMSUS" prefix="sus" %>

    <%@extension name="xhtmlb" prefix="xhtmlb" %>

    <%

      INCLUDE bbp_sus_ui_const.

    %>

    <!-- messages controller -->

    <%@include file="framework/carrier_view_message.inc" %>

     

     

    <htmlb:tray id = "orderchange"

                 title = "Order Change Response"

                 width = "100%">

                 <htmlb:gridLayout id = "GR_RPT_Query"

              rowSize = "3"

              columnSize = "1"

              cellSpacing = "10"

              width = "100%">

               <htmlb:gridLayoutCell rowIndex = "1"

                         columnIndex = "1"

                         width = "100%" >

     <% if zmodel->history_show <> 'X'. %>

                 <td align = "right">

                 <htmlb:link id="history"

                           text="history"

                           onClick="onhistoryclick"

                           ></htmlb:link>

                 </td>

     <% else. %>

                 <td align = "right">

                 <htmlb:link id="inprocess"

                           text="inprocess"

                           onClick="onprocessclick"

                           ></htmlb:link>

                 </td>

     <% endif.%>.

                 </htmlb:gridLayoutCell>

              <htmlb:gridLayoutCell rowIndex = "2"

                         columnIndex = "1"

                         width = "100%" >

    <% if zmodel->history_show <> 'X'. %>

    <htmlb:tableView id="t2"

                           emptyTableText  = "<%= otr(BBP_SUS_UI/LIST_ORDER_NO_ENTRIES_FOUND) %>"

                           sort            = "SERVER"

                           onHeaderClick   = "onmyHeaderClick"

                           onNavigate      = "onMyNavigate"

                           onRowSelection  = "onMyRowSelection"

                           visibleRowCount = "10"

                           visibleFirstRow = "1"

                           iterator        = "<%=zmodel->io_iterator%>"

                           table="//zmodel/ORDERCHANGE">

               <htmlb:tableViewColumn columnName="ICONS"

                                   onCellClick="onCellClick"

     

                                    width="5"

           ></htmlb:tableViewColumn>

           <htmlb:tableViewColumn columnName="CANCEL"

                                   onCellClick="onCellClick"

     

                                   width="5"

     

           ></htmlb:tableViewColumn>

           <htmlb:tableViewColumn columnName="BNAME"

                                   onCellClick="onCellClick"

                                    title="BNAME"

     

           ></htmlb:tableViewColumn>

    </htmlb:tableView>

     <% else. %>

     <htmlb:tableView id="t2"

                           emptyTableText  = "<%= otr(BBP_SUS_UI/LIST_ORDER_NO_ENTRIES_FOUND) %>"

                           sort            = "SERVER"

                           onHeaderClick   = "onmyHeaderClick"

                           onNavigate      = "onMyNavigate"

                           onRowSelection  = "onMyRowSelection"

                           visibleRowCount = "10"

                           visibleFirstRow = "1"

                           iterator        = "<%=zmodel->io_iterator%>"

                           table="//zmodel/ORDERCHANGE_HISTORY">

                 <htmlb:tableViewColumn columnName="ICONS"

                                   onCellClick="onCellClick"

     

                                    width="5"

           ></htmlb:tableViewColumn>

           <htmlb:tableViewColumn columnName="CANCEL"

                                   onCellClick="onCellClick"

     

                                   width="5"

     

           ></htmlb:tableViewColumn>

           <htmlb:tableViewColumn columnName="BNAME"

                                   onCellClick="onCellClick"

                                    title="BNAME"

     

           ></htmlb:tableViewColumn>

    </htmlb:tableView>

         <% endif.%>.

     

     

     </htmlb:gridLayoutCell>

     

      <htmlb:gridLayoutCell rowIndex = "3"

                         columnIndex = "1"

                         width = "100%" >

            <htmlb:button id="update"

                          text = "Update"

                          onClick = "onupdateclick"

            />

      </htmlb:gridLayoutCell>

     </htmlb:gridLayout>

    </htmlb:tray>

    1. 5.    Page attributes

    zmodel TYPE REF TO    ZCL_SUS_C_ORDER_CHANGE_MODEL

    1. 6.    Controller attributes

    ZORDERCHANGEMODEL     Instance Attribute  Public   Type Ref ToZCL_SUS_C_ORDER_CHANGE_MODEL

    HISTORY_SHOW     Instance Attribute  Public   Type     CHAR1

    1. 7.    Model ZCL_SUS_C_ORDER_CHANGE_MODEL

    Attributes:

    ORDERCHANGE Instance Attribute  Public   Type     ZTESTUSR01

    IO_ITERATOR   Instance Attribute  Public   Type Ref To ZCL_SUS_C_ORD_C_ITERATOR

    ORDERCHANGE_HISTORY  Instance Attribute  Public   Type     ZTESTUSR01

    HISTORY_SHOW     Instance Attribute  Public   Type     CHAR1

    1. 8.    ITERATOR ZCL_SUS_C_ORD_C_ITERATOR

    Interface IF_HTMLB_TABLEVIEW_ITERATOR

    Attributes:

     M_ROW_REF   Instance Attribute  Public   Type Ref To ZUSR02

    REQUEST    Instance Attribute  Public   Type Ref To IF_HTTP_REQUEST

    method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_ROW_START.

     m_row_ref ?= p_row_data_ref.

    endmethod.

    method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START.

      data lr_tableview type ref to CL_HTMLB_TABLEVIEW.

    *  lr_tableview ?= cl_htmlb_manager=>get_data(

    *                                request = request

    *                                     id = 't2'

    *                                   name = 'tableView' ).

      field-symbols <icons_name> type char50.

      field-symbols:

                     <ls_data> type any,

                     <ls_icons> type any,

                     <ls_kyfs> type any.

      DATA: icon_plane TYPE STRING.

      CASE p_column_key.

        WHEN 'CANCEL'.

     

          ASSIGN P_ROW_DATA_REF->* to <ls_data>.

          assign component 'CANCEL' of  structure <ls_data> TO <ls_icons>.

          icon_plane = <ls_icons>.

          p_replacement_bee = CL_HTMLB_IMAGE=>FACTORY( id = p_cell_id src = icon_plane ).

        WHEN 'ICONS'.

     

          ASSIGN P_ROW_DATA_REF->* to <ls_data>.

          assign component 'ICONS' of  structure <ls_data> TO <ls_icons>.

          icon_plane = <ls_icons>.

          p_replacement_bee = CL_HTMLB_IMAGE=>FACTORY( id = p_cell_id src = icon_plane ).

        WHEN 'BNAME'.

          ASSIGN P_ROW_DATA_REF->* to <ls_data>.

          assign component 'BNAME' of  structure <ls_data> TO <ls_icons>.

          icon_plane = <ls_icons>.

          p_replacement_bee = CL_HTMLB_TEXTVIEW=>FACTORY( id = p_cell_id text = icon_plane ).

     

      ENDCASE.

    endmethod.

    转:http://blog.chinaunix.net/uid-465882-id-2115966.html

  • 相关阅读:
    PHP
    优秀网址
    客户关系管理系统CRM
    面试题
    练习并熟练掌握交互式 SQL 语言
    嵌入式的SQL程序设计
    数据库总结
    JDBC
    玩转Android之Drawable的使用
    Android开发之Activity转场动画
  • 原文地址:https://www.cnblogs.com/goodsmith/p/4482527.html
Copyright © 2020-2023  润新知