好男人就是我,我就是你兵哥
分类: Web开发
2014-09-19 17:17:56
REPORT zrab_zyb_test. PARAMETERS: p_pswd(32) TYPE c DEFAULT 'Welcome 007'. AT SELECTION-SCREEN OUTPUT. PERFORM modify_screen. START-OF-SELECTION. CONDENSE p_pswd. WRITE: / 'Source password:', p_pswd. CALL FUNCTION 'FIEB_PASSWORD_ENCRYPT' EXPORTING im_decrypted_password = p_pswd IMPORTING ex_encrypted_password = p_pswd. CONDENSE p_pswd. WRITE: / 'Encrypted String:', p_pswd. SKIP 2. WRITE: / 'Encrypted String:', p_pswd. CALL FUNCTION 'FIEB_PASSWORD_DECRYPT' EXPORTING im_encrypted_password = p_pswd IMPORTING ex_decrypted_password = p_pswd. CONDENSE p_pswd. WRITE: / 'Source password:', p_pswd. *&---------------------------------------------------------------------* *& Form modify_screen *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM modify_screen. LOOP AT SCREEN. IF screen-name = 'P_PSWD'. screen-invisible = 1. MODIFY SCREEN. ENDIF. ENDLOOP. ENDFORM. " modify_screen
而在ABAP 6下可以這麼用:
DATA: lo_encryptor TYPE REF TO cl_hard_wired_encryptor, lo_cx_error TYPE REF TO cx_encrypt_error, lv_ac_string TYPE string VALUE 'Welcome to ABAP', lv_en_string TYPE string, lv_de_string TYPE string, lv_error_msg TYPE string. PARAMETERS: p_string TYPE string DEFAULT 'Welcome to ABAP'. START-OF-SELECTION. CLEAR: lv_ac_string,lv_en_string,lv_de_string,lv_error_msg . CREATE OBJECT lo_encryptor. TRY. CALL METHOD lo_encryptor->encrypt_string2string
EXPORTING the_string = p_string
RECEIVING
result = lv_en_string. CATCH cx_encrypt_error INTO lo_cx_error. CALL METHOD lo_cx_error->if_message~get_text
RECEIVING
result = lv_error_msg. ENDTRY. WRITE:/ 'Actual String: ', p_string. WRITE:/ 'Encrypted String: ', lv_en_string. SKIP. TRY. CALL METHOD lo_encryptor->decrypt_string2string
EXPORTING the_string = lv_en_string
RECEIVING
result = lv_de_string. CATCH cx_encrypt_error INTO lo_cx_error. CALL METHOD lo_cx_error->if_message~get_text
RECEIVING
result = lv_error_msg. ENDTRY. WRITE:/ 'Encrypted String: ', lv_en_string. WRITE:/ 'Decrypted String: ', lv_de_string.