"Select Run Type 选择运行类型 SELECTION-SCREEN BEGIN OF BLOCK K01 WITH FRAME TITLE TEXT-T01. SELECTION-SCREEN BEGIN OF LINE. "Select Run Type: PARAMETERS P_TXT NO-DISPLAY. SELECTION-SCREEN COMMENT 1(26) TEXT-002 FOR FIELD P_TXT.
"Test Mode SELECTION-SCREEN POSITION 32. PARAMETERS: P_TEST RADIOBUTTON GROUP GR01 USER-COMMAND UC1 DEFAULT 'X'. "测试用URL SELECTION-SCREEN COMMENT 34(27) TEXT-R01 FOR FIELD P_TEST.
"Customize SELECTION-SCREEN POSITION 62. PARAMETERS: P_CUST RADIOBUTTON GROUP GR01. "自定义URL SELECTION-SCREEN COMMENT 63(32) TEXT-R02 FOR FIELD P_CUST. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK K01.
"Input peripheral interface information 输入外围接口信息 SELECTION-SCREEN BEGIN OF BLOCK K02 WITH FRAME TITLE TEXT-T02. PARAMETERS: P_URL TYPE STRING, P_TYPE TYPE CHAR10 AS LISTBOX VISIBLE LENGTH 10 MODIF ID LIS. SELECTION-SCREEN END OF BLOCK K02.
"Inquiry Type 查询类型 SELECTION-SCREEN BEGIN OF BLOCK K03 WITH FRAME TITLE TEXT-T03. "Search for national regions PARAMETERS: P_AREA RADIOBUTTON GROUP GR02 USER-COMMAND UC2 DEFAULT 'X' MODIF ID TES. "Search for mobile phone location PARAMETERS: P_LOCAT RADIOBUTTON GROUP GR02 MODIF ID TES. PARAMETERS: P_PHONE TYPE C LENGTH 11 MODIF ID PHO. SELECTION-SCREEN END OF BLOCK K03.
"Enter account and password SELECTION-SCREEN BEGIN OF BLOCK K04 WITH FRAME TITLE TEXT-T04. PARAMETERS: P_USER TYPE STRING MODIF ID USP, P_PASS TYPE STRING MODIF ID USP. "和输入框样式一致的类型XUNCODE SELECTION-SCREEN END OF BLOCK K04.
FORM SET_LIST_VALUE . *--------------------------Variables-----------------------------------* CONSTANTS: LC_GET TYPE STRING VALUE 'GET', LC_PUT TYPE STRING VALUE 'PUT', LC_POST TYPE STRING VALUE 'POST', LC_PATCH TYPE STRING VALUE 'PATCH', LC_DELETE TYPE STRING VALUE 'DELETE'. DATA: LV_VID TYPE VRM_ID VALUE 'P_TYPE', LS_LIST TYPE VRM_VALUE, LT_LIST TYPE VRM_VALUES. *----------------------------Logic-------------------------------------* "Set List Value "Get LS_LIST-KEY = LC_GET. LS_LIST-TEXT = 'Get'. INSERT LS_LIST INTO TABLE LT_LIST.
CALL FUNCTION 'VRM_SET_VALUES' EXPORTING ID = LV_VID VALUES = LT_LIST EXCEPTIONS ID_ILLEGAL_NAME = 1 OTHERS = 2.
ENDFORM.
2.设置不同模式的URL
(1)界面展示
(2)源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
FORM SET_URL_VALUE . *--------------------------Variables-----------------------------------* CONSTANTS: LC_GET TYPE STRING VALUE 'GET', LC_POST TYPE STRING VALUE 'POST'. *----------------------------Logic-------------------------------------* CHECK P_TXT IS INITIAL. IF P_LOCAT IS NOT INITIAL. "http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo P_URL = TEXT-U02. P_TYPE = LC_POST. ELSE. "http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getDatabaseInfo P_URL = TEXT-U01. P_TYPE = LC_GET. ENDIF. ENDFORM.
3.创建客户端请求
(1)全局变量
1 2 3 4 5
*----------------------------------------------------------------------* * Object *----------------------------------------------------------------------* DATA: GO_HTTPCLIENT TYPE REF TO IF_HTTP_CLIENT.
(2)源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
"创建客户端请求 CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL EXPORTING URL = P_URL IMPORTING CLIENT = GO_HTTPCLIENT EXCEPTIONS ARGUMENT_NOT_FOUND = 1 PLUGIN_NOT_ACTIVE = 2 INTERNAL_ERROR = 3 OTHERS = 4. IF SY-SUBRC NE 0. "URL link failed MESSAGE S000 WITH TEXT-E01 DISPLAY LIKE GC_E. LEAVE LIST-PROCESSING. ENDIF.
4.设置用户名与密码
(1)源码
1 2 3 4 5 6 7 8 9 10 11 12
"判断是否需要登陆 IF P_USER IS INITIAL AND P_PASS IS INITIAL. "抑制登陆框 GO_HTTPCLIENT->PROPERTYTYPE_LOGON_POPUP = GO_HTTPCLIENT->CO_DISABLED. ELSE. "验证用户名与密码 CALL METHOD GO_HTTPCLIENT->AUTHENTICATE EXPORTING USERNAME = P_USER PASSWORD = P_PASS. ENDIF.
*--------------------------Variables-----------------------------------* CONSTANTS: LC_GET TYPE STRING VALUE 'GET', LC_PUT TYPE STRING VALUE 'PUT', LC_POST TYPE STRING VALUE 'POST', LC_PATCH TYPE STRING VALUE 'PATCH', LC_DELETE TYPE STRING VALUE 'DELETE'. *----------------------------Logic-------------------------------------* CASE P_TYPE. WHEN LC_GET. "设置请求方式 GET GO_HTTPCLIENT->REQUEST->SET_METHOD( IF_HTTP_REQUEST=>CO_REQUEST_METHOD_GET ). WHEN LC_PUT. WHEN LC_POST. "设置传输格式 GO_HTTPCLIENT->REQUEST->SET_CONTENT_TYPE( CONTENT_TYPE = 'application/x-www-form-urlencoded' ). "( content_type = 'application/json; charset=utf-8' ) "设置请求方式 POST GO_HTTPCLIENT->REQUEST->SET_METHOD( IF_HTTP_REQUEST=>CO_REQUEST_METHOD_POST ). "设置JSON内容格式 GV_OUTPUTJSON = 'mobileCode=' && P_PHONE && '&userID='. WHEN LC_PATCH. WHEN LC_DELETE. WHEN OTHERS. ENDCASE.
"将返回参数的回车转换,否则回车会在SAP变成'#' REPLACE ALL OCCURRENCES OF REGEX '\n' IN GV_RETURNJSON WITH GC_NULL.
"获取运行状态码 GO_HTTPCLIENT->RESPONSE->GET_STATUS( IMPORTING CODE = LV_STATUSCODE ). IF LV_STATUSCODE EQ 200. CASE GC_X. WHEN P_AREA. PERFORM GET_NATIONAL_REGIONAL. WHEN P_LOCAT. PERFORM GET_SELECT_PHONE_RESULT. WHEN OTHERS. ENDCASE. ENDIF.
*--------------------------Variables-----------------------------------* CONSTANTS: LC_STRING TYPE STRING VALUE '<string>', LC_STRING1 TYPE STRING VALUE '</string>'. *----------------------------Logic-------------------------------------* SPLIT GV_RETURNJSON AT LC_STRING INTO TABLE DATA(LT_RESPON). DELETE LT_RESPON INDEX 1. LOOP AT LT_RESPON INTO DATA(LS_RESPON). REPLACE LC_STRING1 WITH '' INTO LS_RESPON. CONDENSE LS_RESPON NO-GAPS. REPLACE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>CR_LF WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>VERTICAL_TAB WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>NEWLINE WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>FORM_FEED WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>BACKSPACE WITH '' INTO LS_RESPON. REPLACE ALL OCCURRENCES OF REGEX '[^[:print:]]+$' IN LS_RESPON WITH '' IGNORING CASE. WRITE: / LS_RESPON. CLEAR: LS_RESPON. ENDLOOP.
*--------------------------Variables-----------------------------------* CONSTANTS: LC_SPLITWHERE TYPE STRING VALUE '<string xmlns="http://WebXml.com.cn/">', LC_STRING TYPE STRING VALUE '</string>'. *----------------------------Logic-------------------------------------* "截取<string xmlns="http://WebXml.com.cn/">右边的值放到内表中 SPLIT GV_RETURNJSON AT LC_SPLITWHERE INTO TABLE DATA(LT_RESPON). DELETE LT_RESPON INDEX 1. LOOP AT LT_RESPON INTO DATA(LS_RESPON). REPLACE LC_STRING WITH '' INTO LS_RESPON. CONDENSE LS_RESPON NO-GAPS. REPLACE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>CR_LF WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>VERTICAL_TAB WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>NEWLINE WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>FORM_FEED WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>BACKSPACE WITH '' INTO LS_RESPON. REPLACE ALL OCCURRENCES OF REGEX '[^[:print:]]+$' IN LS_RESPON WITH '' IGNORING CASE. WRITE: / LS_RESPON. CLEAR: LS_RESPON. ENDLOOP.
*----------------------------------------------------------------------* * Include *----------------------------------------------------------------------* INCLUDE YCALLRESTHTTP_TOP. INCLUDE YCALLRESTHTTP_SCR. INCLUDE YCALLRESTHTTP_F01.
*----------------------------------------------------------------------* * AT SELECTION-SCREEN OUTPUT *----------------------------------------------------------------------* AT SELECTION-SCREEN OUTPUT. "Set Dropdown Box Values PERFORM SET_LIST_VALUE. "Set Screen Variable Status PERFORM SET_SCREEN_VARIABLE. "Set Test Stauts URL And Type PERFORM SET_URL_VALUE.
*----------------------------------------------------------------------* * START-OF-SELECTION *----------------------------------------------------------------------* START-OF-SELECTION. "Call URL PERFORM CALL_URL. "Set response logic for call types PERFORM SET_INTERFACE_TYPE_LOGIC. "Send Request PERFORM SEND_REQUEST. "Obtain peripheral system return value PERFORM GET_RETURN_DATA.
*----------------------------------------------------------------------* * Constants *----------------------------------------------------------------------* CONSTANTS: GC_X TYPE C LENGTH 1 VALUE 'X', GC_S TYPE C LENGTH 1 VALUE 'S', GC_E TYPE C LENGTH 1 VALUE 'E', GC_NULL TYPE C LENGTH 1 VALUE ''.
*----------------------------------------------------------------------* * Variables *----------------------------------------------------------------------* DATA: GV_RETURNJSON TYPE STRING, GV_OUTPUTJSON TYPE STRING, GV_MESSAGE TYPE C.
*----------------------------------------------------------------------* * Object *----------------------------------------------------------------------* DATA: GO_HTTPCLIENT TYPE REF TO IF_HTTP_CLIENT.
"Select Run Type 选择运行类型 SELECTION-SCREEN BEGIN OF BLOCK K01 WITH FRAME TITLE TEXT-T01. SELECTION-SCREEN BEGIN OF LINE. "Select Run Type: PARAMETERS P_TXT NO-DISPLAY. SELECTION-SCREEN COMMENT 1(26) TEXT-002 FOR FIELD P_TXT.
"Test Mode SELECTION-SCREEN POSITION 32. PARAMETERS: P_TEST RADIOBUTTON GROUP GR01 USER-COMMAND UC1 DEFAULT 'X'. "测试用URL SELECTION-SCREEN COMMENT 34(27) TEXT-R01 FOR FIELD P_TEST.
"Customize SELECTION-SCREEN POSITION 62. PARAMETERS: P_CUST RADIOBUTTON GROUP GR01. "自定义URL SELECTION-SCREEN COMMENT 63(32) TEXT-R02 FOR FIELD P_CUST. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK K01.
"Input peripheral interface information 输入外围接口信息 SELECTION-SCREEN BEGIN OF BLOCK K02 WITH FRAME TITLE TEXT-T02. PARAMETERS: P_URL TYPE STRING, P_TYPE TYPE CHAR10 AS LISTBOX VISIBLE LENGTH 10 MODIF ID LIS. SELECTION-SCREEN END OF BLOCK K02.
"Inquiry Type 查询类型 SELECTION-SCREEN BEGIN OF BLOCK K03 WITH FRAME TITLE TEXT-T03. "Search for national regions PARAMETERS: P_AREA RADIOBUTTON GROUP GR02 USER-COMMAND UC2 DEFAULT 'X' MODIF ID TES. "Search for mobile phone location PARAMETERS: P_LOCAT RADIOBUTTON GROUP GR02 MODIF ID TES. PARAMETERS: P_PHONE TYPE C LENGTH 11 MODIF ID PHO. SELECTION-SCREEN END OF BLOCK K03.
"Enter account and password SELECTION-SCREEN BEGIN OF BLOCK K04 WITH FRAME TITLE TEXT-T04. PARAMETERS: P_USER TYPE STRING MODIF ID USP, P_PASS TYPE STRING MODIF ID USP. "和输入框样式一致的类型XUNCODE SELECTION-SCREEN END OF BLOCK K04.
*&---------------------------------------------------------------------* *& Include YCALLRESTHTTP_F01 *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form SET_LIST_VALUE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM SET_LIST_VALUE . *--------------------------Variables-----------------------------------* CONSTANTS: LC_GET TYPE STRING VALUE 'GET', LC_PUT TYPE STRING VALUE 'PUT', LC_POST TYPE STRING VALUE 'POST', LC_PATCH TYPE STRING VALUE 'PATCH', LC_DELETE TYPE STRING VALUE 'DELETE'. DATA: LV_VID TYPE VRM_ID VALUE 'P_TYPE', LS_LIST TYPE VRM_VALUE, LT_LIST TYPE VRM_VALUES. *----------------------------Logic-------------------------------------* "Set List Value "Get LS_LIST-KEY = LC_GET. LS_LIST-TEXT = 'Get'. INSERT LS_LIST INTO TABLE LT_LIST.
CALL FUNCTION 'VRM_SET_VALUES' EXPORTING ID = LV_VID VALUES = LT_LIST EXCEPTIONS ID_ILLEGAL_NAME = 1 OTHERS = 2.
ENDFORM. *&---------------------------------------------------------------------* *& Form SET_INITIAL_VALUE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM SET_INITIAL_VALUE . *--------------------------Variables-----------------------------------* CONSTANTS: LC_GET TYPE STRING VALUE 'GET'. *----------------------------Logic-------------------------------------* "Set Initial Url Value "http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getDatabaseInfo P_URL = TEXT-U01. "Set Call Interface Type Value P_TYPE = LC_GET. ENDFORM. *&---------------------------------------------------------------------* *& Form SET_SCREEN_VARIABLE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM SET_SCREEN_VARIABLE . *--------------------------Variables-----------------------------------* CONSTANTS: LC_URL TYPE STRING VALUE 'P_URL', LC_LIST TYPE STRING VALUE 'LIS', LC_USER TYPE STRING VALUE 'P_USER', LC_PASS TYPE STRING VALUE 'P_PASS'. *----------------------------Logic-------------------------------------* "Set Input URL Not Edit Status LOOP AT SCREEN. IF P_TEST EQ GC_X. IF SCREEN-NAME EQ LC_URL. SCREEN-INPUT = '0'. ENDIF.
IF SCREEN-GROUP1 EQ LC_LIST. SCREEN-ACTIVE = '0'. ENDIF.
IF SCREEN-GROUP1 EQ 'USP'. SCREEN-ACTIVE = '0'. ENDIF.
IF P_AREA IS NOT INITIAL AND SCREEN-GROUP1 EQ 'PHO'. SCREEN-ACTIVE = '0'. ELSEIF P_AREA IS INITIAL AND SCREEN-GROUP1 EQ 'PHO'. SCREEN-ACTIVE = '1'. ENDIF. ELSE. IF SCREEN-GROUP1 EQ 'TES' OR SCREEN-GROUP1 EQ 'PHO'. SCREEN-ACTIVE = '0'. ENDIF. ENDIF.
IF SCREEN-NAME EQ LC_PASS. SCREEN-INVISIBLE = '1'. ENDIF.
MODIFY SCREEN. CLEAR: SCREEN. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form CALL_URL *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM CALL_URL . "创建客户端请求 CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL EXPORTING URL = P_URL IMPORTING CLIENT = GO_HTTPCLIENT EXCEPTIONS ARGUMENT_NOT_FOUND = 1 PLUGIN_NOT_ACTIVE = 2 INTERNAL_ERROR = 3 OTHERS = 4. IF SY-SUBRC NE 0. "URL link failed MESSAGE S000 WITH TEXT-E01 DISPLAY LIKE GC_E. LEAVE LIST-PROCESSING. ENDIF.
"判断是否需要登陆 IF P_USER IS INITIAL AND P_PASS IS INITIAL. "抑制登陆框 GO_HTTPCLIENT->PROPERTYTYPE_LOGON_POPUP = GO_HTTPCLIENT->CO_DISABLED. ELSE. "验证用户名与密码 CALL METHOD GO_HTTPCLIENT->AUTHENTICATE EXPORTING USERNAME = P_USER PASSWORD = P_PASS. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form SET_INTERFACE_TYPE_LOGIC *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM SET_INTERFACE_TYPE_LOGIC . *--------------------------Variables-----------------------------------* CONSTANTS: LC_GET TYPE STRING VALUE 'GET', LC_PUT TYPE STRING VALUE 'PUT', LC_POST TYPE STRING VALUE 'POST', LC_PATCH TYPE STRING VALUE 'PATCH', LC_DELETE TYPE STRING VALUE 'DELETE'. *----------------------------Logic-------------------------------------* CASE P_TYPE. WHEN LC_GET. GO_HTTPCLIENT->REQUEST->SET_METHOD( IF_HTTP_REQUEST=>CO_REQUEST_METHOD_GET ). WHEN LC_PUT. WHEN LC_POST. GO_HTTPCLIENT->REQUEST->SET_CONTENT_TYPE( CONTENT_TYPE = 'application/x-www-form-urlencoded' ). "( content_type = 'application/json; charset=utf-8' ) GO_HTTPCLIENT->REQUEST->SET_METHOD( IF_HTTP_REQUEST=>CO_REQUEST_METHOD_POST ).
GV_OUTPUTJSON = 'mobileCode=' && P_PHONE && '&userID='. WHEN LC_PATCH. WHEN LC_DELETE. WHEN OTHERS. ENDCASE. ENDFORM. *&---------------------------------------------------------------------* *& Form SEND_REQUEST *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM SEND_REQUEST . "抑制登陆框 GO_HTTPCLIENT->PROPERTYTYPE_LOGON_POPUP = GO_HTTPCLIENT->CO_DISABLED.
"Call Interface Fail MESSAGE S000 WITH LV_MESSAGE DISPLAY LIKE GC_E. LEAVE LIST-PROCESSING. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_RETURN_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM GET_RETURN_DATA . *--------------------------Variables-----------------------------------* DATA: LV_STATUSCODE TYPE I. *----------------------------Logic-------------------------------------* "读取远程服务返回的处理过结果 GO_HTTPCLIENT->RECEIVE( EXCEPTIONS HTTP_COMMUNICATION_FAILURE = 1 HTTP_INVALID_STATE = 2 HTTP_PROCESSING_FAILED = 3 ). IF SY-SUBRC NE 0. "Return Data Error MESSAGE S000 WITH TEXT-E03 DISPLAY LIKE GC_E. LEAVE LIST-PROCESSING. ENDIF.
"将返回参数的回车转换,否则回车会在SAP变成'#' REPLACE ALL OCCURRENCES OF REGEX '\n' IN GV_RETURNJSON WITH GC_NULL.
"获取运行状态码 GO_HTTPCLIENT->RESPONSE->GET_STATUS( IMPORTING CODE = LV_STATUSCODE ). IF LV_STATUSCODE EQ 200. CASE GC_X. WHEN P_AREA. PERFORM GET_NATIONAL_REGIONAL. WHEN P_LOCAT. PERFORM GET_SELECT_PHONE_RESULT. WHEN OTHERS. ENDCASE. ENDIF.
"关闭HTTP请求 CALL METHOD GO_HTTPCLIENT->CLOSE. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_NATIONAL_REGIONAL *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM GET_NATIONAL_REGIONAL . *--------------------------Variables-----------------------------------* CONSTANTS: LC_STRING TYPE STRING VALUE '<string>', LC_STRING1 TYPE STRING VALUE '</string>'. *----------------------------Logic-------------------------------------* SPLIT GV_RETURNJSON AT LC_STRING INTO TABLE DATA(LT_RESPON). DELETE LT_RESPON INDEX 1. LOOP AT LT_RESPON INTO DATA(LS_RESPON). REPLACE LC_STRING1 WITH '' INTO LS_RESPON. CONDENSE LS_RESPON NO-GAPS. REPLACE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>CR_LF WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>VERTICAL_TAB WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>NEWLINE WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>FORM_FEED WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>BACKSPACE WITH '' INTO LS_RESPON. REPLACE ALL OCCURRENCES OF REGEX '[^[:print:]]+$' IN LS_RESPON WITH '' IGNORING CASE. WRITE: / LS_RESPON. CLEAR: LS_RESPON. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_SELECT_PHONE_RESULT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM GET_SELECT_PHONE_RESULT . *--------------------------Variables-----------------------------------* CONSTANTS: LC_SPLITWHERE TYPE STRING VALUE '<string xmlns="http://WebXml.com.cn/">', LC_STRING TYPE STRING VALUE '</string>'. *----------------------------Logic-------------------------------------* "截取<string xmlns="http://WebXml.com.cn/">右边的值放到内表中 SPLIT GV_RETURNJSON AT LC_SPLITWHERE INTO TABLE DATA(LT_RESPON). DELETE LT_RESPON INDEX 1. LOOP AT LT_RESPON INTO DATA(LS_RESPON). REPLACE LC_STRING WITH '' INTO LS_RESPON. CONDENSE LS_RESPON NO-GAPS. REPLACE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>CR_LF WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>VERTICAL_TAB WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>NEWLINE WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>FORM_FEED WITH '' INTO LS_RESPON. REPLACE CL_ABAP_CHAR_UTILITIES=>BACKSPACE WITH '' INTO LS_RESPON. REPLACE ALL OCCURRENCES OF REGEX '[^[:print:]]+$' IN LS_RESPON WITH '' IGNORING CASE. WRITE: / LS_RESPON. CLEAR: LS_RESPON. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form SET_URL_VALUE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM SET_URL_VALUE . *--------------------------Variables-----------------------------------* CONSTANTS: LC_GET TYPE STRING VALUE 'GET', LC_POST TYPE STRING VALUE 'POST'. *----------------------------Logic-------------------------------------* CHECK P_TXT IS INITIAL. IF P_LOCAT IS NOT INITIAL. "http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo P_URL = TEXT-U02. P_TYPE = LC_POST. ELSE. "http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getDatabaseInfo P_URL = TEXT-U01. P_TYPE = LC_GET. ENDIF. ENDFORM.