Passwort Reset Cross Landscape / HTML 5 BSP-Application
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Page Layout of Default.htm
Event OnCreate
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
- * this handler is called once the page is first created (stateful mode)
- * it performs a once-off data initialization or object creation
- * Definition of Dropdown field Option value = SM59 RFC-Connections and Description
- *
- CLEAR rc .
- '<option value="NSPCLNT200">NSP Client 200 DEMO Development</option>'
- '<option value="NSPCLNT600">NSP Client 600 DEMO Customizing</option>'
- INTO systems.
- GeSHi ©
Event OnRequest
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
- * the handler is called whenever a request is made for a particular page
- * it is used to restore the internal data structures from the request
- *DATA h_fields TYPE tihttpnvp.
- CALL METHOD page->get_request
- RECEIVING
- request = ireq.
- *CALL METHOD ireq->get_header_fields
- * CHANGING
- * fields = h_fields.
- CALL METHOD ireq->get_header_field
- EXPORTING
- name = '~request_method'
- RECEIVING
- value = l_method.
- EXIT.
- CALL METHOD ireq->get_form_fields
- CHANGING
- CLEAR sf_fields.
- READ TABLE tf_fields INTO sf_fields WITH KEY name = 'sapname'.
- l_user = sf_fields-value.
- CLEAR sf_fields.
- READ TABLE tf_fields INTO sf_fields WITH KEY name = 'emailaddress'.
- l_email = sf_fields-value.
- CLEAR sf_fields.
- READ TABLE tf_fields INTO sf_fields WITH KEY name = 'action'.
- l_action = sf_fields-value. " UNLOCK / NEWPW
- CLEAR sf_fields.
- READ TABLE tf_fields INTO sf_fields WITH KEY name = 'sysid'.
- l_dest = sf_fields-value. " SM59 Destination
- CALL FUNCTION 'Z_PASSWORD_RESET'
- EXPORTING
- i_email = l_email
- i_user = l_user
- i_action = l_action
- i_system = l_dest
- IMPORTING
- returnmessages = t_returnmessages
- EXCEPTIONS
- no_user = 1
- no_email = 2
- error = 3
- OTHERS = 4.
- rc = 1.
- ELSE.
- rc = 2.
- GeSHi ©
Page Attributes
- EMAIL TYPE AD_SMTPADR E-Mail-Adresse
RC TYPE SY-SUBRC Rückgabewert, Rückgabewert nach ABAP-Anweisungen
RC_DESCRIPTION TYPE STRING Result Information
SAPUSER TYPE XUBNAME Benutzername im Benutzerstamm
SYSTEMS TYPE STRING Drop Down values
Function Module z_password_reset
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
- FUNCTION z_password_reset.
- *"----------------------------------------------------------------------
- *"*"Local Interface:
- *" IMPORTING
- *" REFERENCE(I_EMAIL) TYPE AD_SMTPADR
- *" REFERENCE(I_USER) TYPE XUBNAME
- *" REFERENCE(I_ACTION) TYPE CHAR6
- *" REFERENCE(I_SYSTEM) TYPE RFCDEST DEFAULT 'NONE'
- *" EXPORTING
- *" REFERENCE(RETURNMESSAGES) TYPE BAPIRETTAB
- *" EXCEPTIONS
- *" NO_USER
- *" NO_EMAIL
- *" ERROR
- *"----------------------------------------------------------------------
- * Check if destination is available
- CALL FUNCTION 'RFC_SYSTEM_INFO' DESTINATION i_system
- IMPORTING
- rfcsi_export = dest_info
- EXCEPTIONS
- * Check destination is reachable
- CLEAR s_return.
- s_return-type = 'E'.
- s_return-id = 'OA'.
- s_return-number = '682'.
- RAISE error.
- CALL FUNCTION 'BAPI_USER_GET_DETAIL' DESTINATION i_system
- EXPORTING
- username = i_user
- IMPORTING
- logondata = s_logondata
- islocked = s_locked
- return = t_return
- addsmtp = t_addsmtp
- EXCEPTIONS
- RAISE error.
- * Check Valid TO Date
- CLEAR s_return.
- s_return-type = 'E'.
- s_return-id = '01'.
- s_return-number = '538'.
- RAISE error.
- * Check Valid FROM Date
- CLEAR s_return.
- s_return-type = 'E'.
- s_return-id = '01'.
- s_return-number = '538'.
- RAISE error.
- * Check Email exsist
- CLEAR s_return.
- s_return-type = 'E'.
- s_return-id = '01'.
- s_return-number = '175'.
- RAISE no_email.
- l_email = s_addsmtp-e_mail.
- * Check Email against Input
- l_email_uc = i_email.
- CLEAR s_return.
- s_return-type = 'E'.
- s_return-id = 'F2'.
- s_return-number = '830'.
- RAISE no_email.
- CALL FUNCTION 'BAPI_USER_UNLOCK' DESTINATION i_system
- EXPORTING
- username = i_user
- return = t_return
- EXCEPTIONS
- RAISE error.
- EXIT.
- *DE 01 178 Das Kennwort wird nur an die zuvor hinterlegte E-Mail Adresse geschickt
- EXIT.
- CALL FUNCTION 'BAPI_USER_CHANGE' DESTINATION i_system
- EXPORTING
- username = i_user
- * PASSWORD =
- passwordx = l_passwordx
- generate_pwd = l_generate_pwd
- * DESCRIPTION =
- * DESCRIPTIONX =
- IMPORTING
- generated_password = l_password
- return = t_return
- EXCEPTIONS
- RAISE error.
- CLEAR s_return.
- s_return-type = 'E'.
- s_return-id = '01'.
- s_return-number = '178'.
- EXIT.
- CLEAR s_return.
- s_return-type = 'E'.
- l_dummy = 'SHIT'.
- * s_return-id = 'F2'.
- * s_return-number = '830'.
- RAISE error.
- * For Email contents
- *DATA contents_hex TYPE solix_tab.
- *DATA lv_attname TYPE sood-objdes.
- TRY.
- * create the send request
- send_request = cl_bcs=>create_persistent( ).
- * create the email body
- * Email subject
- CONCATENATE 'Your Password reset request from' l_date l_time
- INTO lv_subject SEPARATED BY space.
- document = cl_document_bcs=>create_document(
- i_type = 'RAW'
- i_text = text
- i_subject = lv_subject ).
- *=============== Prep Send
- * add document to send request
- send_request->set_document( document ).
- * create recipient and add to send request
- recipient = cl_cam_address_bcs=>create_internet_address( i_email ).
- send_request->add_recipient( i_recipient = recipient ).
- * send
- send_request->set_send_immediately( i_send_immediately = 'X' ).
- sent_to_all = send_request->send( i_with_error_screen = 'X' ).
- * Im VERBUCHER kein Commit work !!
- *Values: 1: in update task, 0: not in update task
- CALL FUNCTION 'TH_IN_UPDATE_TASK'
- IMPORTING
- in_update_task = l_utask.
- COMMIT WORK.
- GeSHi ©