Web dynpro-01 重置账号密码

重置账号密码

新建一个Web dynpro组件以及一个视图view一个窗口window

Web dynpro-01 重置账号密码_第1张图片

视图新建一个组group,输入标题文本CAPTION

Web dynpro-01 重置账号密码_第2张图片

创建4个容器TransparentContainer,布局选择GridLayout,外面的透明容器colCount设置为3,里面三个设置为1

(通过colCount的参数控制列数量,竖直方向左对齐,浏览器长度不够不会换行)
Web dynpro-01 重置账号密码_第3张图片

在容器1下创建标签Label,并为标签指定容器

(因为容器TC_01设置colCount为1,所以一个元素就换行了)
Web dynpro-01 重置账号密码_第4张图片

创建节点node

Web dynpro-01 重置账号密码_第5张图片

在节点下新建属性

Web dynpro-01 重置账号密码_第6张图片

在容器3下创建输入字段InputField,状态state设置必输requeired,元素绑定属性,设置宽度

(属性在上一步创建)
Web dynpro-01 重置账号密码_第7张图片

新建行为action,编辑提交代码

(仅检查账号邮箱是否输入,提交则保存至自建表)
实际需求:
BAPI_USER_GET_DETAIL:检查账号是否存在,邮箱账号是否匹配
RSEC_GENERATE_PASSWORD:生成随机密码
RSEC_GENERATE_PASSWORD:获取账号信息
BAPI_USER_CHANGE:初始化密码
密码重置成功后,通过邮件发送给用户
Web dynpro-01 重置账号密码_第8张图片
点击提交:检查无报错,重置密码
Web dynpro-01 重置账号密码_第9张图片
Web dynpro-01 重置账号密码_第10张图片
代码:
检查

METHOD data_check .

  DATA lo_nd_data TYPE REF TO if_wd_context_node.
  DATA lo_el_element TYPE REF TO if_wd_context_element.
  DATA ls_data TYPE wd_this->element_data.    "获取元素

  DATA lt_messages_elem    TYPE cl_wd_dynamic_tool=>t_check_result_message_tab. "输出消息
  DATA ls_messages_elem    LIKE LINE OF lt_messages_elem.

  DATA:lo_api_controller  TYPE REF TO if_wd_controller,
       lo_message_manager TYPE REF TO if_wd_message_manager.


  lo_nd_data = wd_context->get_child_node( name = wd_this->wdctx_data ).
  lo_el_element = lo_nd_data->get_element( ).
  lo_nd_data->get_static_attributes( IMPORTING static_attributes = ls_data ).

*context中建的属性,也可通过双击wd_this->element_data查看
  IF ls_data-user_id IS INITIAL.
    ls_messages_elem-t100_message-msgid = 'ZMM01'.
    ls_messages_elem-t100_message-msgno = '001'. " 请输入您的“账号”!
    ls_messages_elem-t100_message-msgty = 'E'.
    ls_messages_elem-t100_message-msgv1 = '请输入您的“账号”!'.

    ls_messages_elem-context_element = lo_el_element.
    ls_messages_elem-attribute_name = 'USER_ID'.
  ENDIF.

  IF ls_data-user_id IS INITIAL.
    ls_messages_elem-t100_message-msgid = 'ZMM01'.
    ls_messages_elem-t100_message-msgno = '002'. " 请输入您的“账号”!
    ls_messages_elem-t100_message-msgty = 'E'.
    ls_messages_elem-t100_message-msgv1 = '请输入您的“邮箱”!'.

    ls_messages_elem-context_element = lo_el_element.
    ls_messages_elem-attribute_name = 'ADDRESS'.
  ENDIF.

  IF ls_messages_elem IS NOT INITIAL.
    ev_error = 'X'.

    lo_api_controller ?= wd_this->wd_get_api( ).
    CALL METHOD lo_api_controller->get_message_manager
      RECEIVING
        message_manager = lo_message_manager.
    CALL METHOD lo_message_manager->report_t100_message
      EXPORTING
        msgid      = ls_messages_elem-t100_message-msgid
        msgno      = ls_messages_elem-t100_message-msgno
        msgty      = 'E'
      RECEIVING
        message_id = ls_messages_elem-t100_message-msgv1.
  ENDIF.

ENDMETHOD.

提交

METHOD password_reset .

  DATA ls_logoondatax TYPE bapilogonx.
  DATA lv_password TYPE bapipwd.
  DATA: lv_passwordtmp(40).
  DATA: lv_passwordstring(80).
  DATA:lt_mda_0101 TYPE TABLE OF zwda_test0101,
       ls_mda_0101 TYPE zwda_test0101,
       lv_symsgv   TYPE symsgv.

  DATA lo_nd_data TYPE REF TO if_wd_context_node.
  DATA lo_el_data TYPE REF TO if_wd_context_element.
  DATA ls_data TYPE wd_this->element_data.

  DATA:lo_api_controller  TYPE REF TO if_wd_controller,
       lo_message_manager TYPE REF TO if_wd_message_manager.

  lo_nd_data = wd_context->get_child_node( name = wd_this->wdctx_data ).
  lo_el_data = lo_nd_data->get_element( ).

  lo_el_data->get_static_attributes( IMPORTING static_attributes = ls_data ).

  CLEAR: lv_passwordstring,lv_passwordtmp,ls_logoondatax.

  lv_password = '123456'.

  ls_mda_0101-user_id = ls_data-user_id.
  ls_mda_0101-address = ls_data-address.
  ls_mda_0101-password = lv_password.
  APPEND ls_mda_0101 TO lt_mda_0101.

  MODIFY zwda_test0101 FROM TABLE lt_mda_0101.
  COMMIT WORK AND WAIT.

  lo_api_controller ?= wd_this->wd_get_api( ).
  CALL METHOD lo_api_controller->get_message_manager
    RECEIVING
      message_manager = lo_message_manager.
  lv_symsgv = '密码重置成功!'.
  CALL METHOD lo_message_manager->report_t100_message
    EXPORTING
      msgid      = 'ZMM01'
      msgno      = '003'
      msgty      = 'S'
    RECEIVING
      message_id = lv_symsgv.


ENDMETHOD.

将新建的行为和按钮绑定

Web dynpro-01 重置账号密码_第11张图片

将视图拖拽到窗口

Web dynpro-01 重置账号密码_第12张图片

创建应用程序,测试

Web dynpro-01 重置账号密码_第13张图片

效果图:

(报错消息编号随便找的,提成成功后保存自建表)
Web dynpro-01 重置账号密码_第14张图片

你可能感兴趣的:(WDA,其他)