签名算法
app_key和app_secret由对方系统提供
MD5_CALCULATE_HASH_FOR_CHAR(中文加密与JAVA不一致)
代码:
*获取传输字段名的ASCII码,根据ASCII码对字段名进行排序SELECT * FROM zthr0051WHERE functionid = @iv_functionidINTO CORRESPONDING FIELDS OF TABLE @et_sort.LOOP AT et_sort INTO DATA(es_sort).es_sort-ascii = cl_abap_conv_out_ce=>uccpi( es_sort-f_json ).MODIFY et_sort FROM es_sort.CLEAR:es_sort.ENDLOOP.SORT et_sort BY ascii.*接口参数赋值gs_per_input-timestamp = gv_timestamp+0(10).gs_per_input-app_key = ls_zthr0167-zkey.gs_per_input-person_no = gs_out_pernr-personid_ext.gs_per_input-name = gs_out_pernr-ename.IF gs_out_pernr-sex = '1'.gs_per_input-gender = 'MAN'.ELSEIF gs_out_pernr-sex = '2'.gs_per_input-gender = 'WOMEN'.ELSEIF gs_out_pernr-sex = '其他'.gs_per_input-gender = 'OTHER'.ENDIF.gs_per_input-phone = gs_per_input-phone.gs_per_input-card_department_group_id = gs_out_pernr-department_id.*参数拼接LOOP AT gt_sort001 ASSIGNING FIELD-SYMBOL(<fs_sort001>) WHERE f_abap <> 'SIGNATURE'.ASSIGN COMPONENT <fs_sort001>-f_ABAP OF STRUCTURE gs_per_input TO <field>.IF <field> IS NOT INITIAL.lv_input = lv_input && <fs_sort001>-f_json && '=' && <field> && '&'.ENDIF.AT LAST.lv_input = lv_input && 'key=' && ls_zthr0167-secret.ENDAT.ENDLOOP.
*对拼接后的值进行MD5加密后的值放在接口参数中,并转换为大写,传输CALL FUNCTION 'ZFM_GET_MD5'EXPORTINGiv_string = lv_inputIMPORTINGev_md5 = gs_per_input-signature.TRANSLATE gs_per_input-signature TO UPPER CASE.
MD5加密参考