20170313 ABAP Returns the value to HTTP (interface content return) in Jason format

Source: Internet
Author: User

Question 1:

Back to Jason format information you can't get through this step,

How can this be handled,

Received the SCP System development reply, they need to adjust the method;

(1) Call function to do return,

It_zsmlscpnotice-functionname ='zmlscp1_fr0005'. It_zsmlscpnotice-bcpcode =Bcpcode. It_zsmlscpnotice-status =O_statu. It_zsmlscpnotice-msg =o_msg. It_zsmlscpnotice-result ="'.    APPEND It_zsmlscpnotice.    Clear:it_zsmlscpnotice. Call FUNCTION'zmlscp1_fr0018'Exporting L_fname='zmlscp1_fr0018'Importing Ev_msgty=l_msgty EV_MSGTX=L_MSGTX TABLES it_input=It_zsmlscpnotice.* O_statu =l_msgty. O_msg='call the return result function:'&& L_MSGTX.
FUNCTION zmlscp1_fr0018.*"----------------------------------------------------------------------*"*"Local Interface:*"Importing*"VALUE (l_fname) TYPE Rs38l_fnam OPTIONAL*"Exporting*"VALUE (ev_msgty) TYPE CHAR1*"VALUE (EV_MSGTX) TYPE STRING*"TABLES*"it_input STRUCTURE zsmlscpnotice OPTIONAL*"----------------------------------------------------------------------Data:json_ser type ref to Cl_trex_json_serializer, Json_des type ref to Cl_trex_json_deserializer. Data:lv_url TYPE STRING."HTTP Service Interface addressdata:lo_http_client TYPE REF to If_http_client. Data:lv_len TYPE I."length of hair delivery paperdata:lv_respon TYPE STRING. DATA:LV_SUBRC TYPE SY-SUBRC. Data:lv_json_str TYPE STRING. "Send a delivery paperIF l_fname EQ SPACE. L_fname='zmlscp1_fr0018'. ENDIF.*set HTTP interface address SELECT single zaddr to Lv_url from zmlscp_url_cfg WHERE sysid EQ SY-sysid and functionname EQ l_fname.    IF Lv_url is INITIAL. Ev_msgty='E'. EV_MSGTX= Sy-sysid &&'Table Zmlscp_url_cfg Service address not configured'.  EXIT. ENDIF.* Inner tableJSON set message content (JSON format string) CREATE OBJECT json_ser exporting DATA=it_input[]. Call METHOD Json_ser-SERIALIZE. Call METHOD Json_ser-Get_data receiving Rval=Lv_json_str. "Create a client requestCall METHOD cl_http_client=>Create_by_url Exporting URL=Lv_url Importing CLIENT=lo_http_client EXCEPTIONS Argument_not_found=1plugin_not_active=2Internal_error=3OTHERS=4. IF SY-SUBRC <>0. Call FUNCTION'Message_text_build'Exporting MSGID= sy-MSGID Msgnr= sy-Msgno MSGV1= sy-MSGV1 MSGV2= sy-MSGV2 MSGV3= sy-MSGV3 MSGV4= sy-MSGV4 Importing Message_text_output=EV_MSGTX. Ev_msgty='E'.  EXIT.  ENDIF. "format transfer request content and encoding formatLo_http_client->request->set_content_type (Content_Type ='Application/json; Charset=utf-8' ). "Setting the invocation serviceLo_http_client->request->set_method (if_http_request=>co_request_method_post). "set up what to transferLv_len =STRLEN (LV_JSON_STR). Call METHOD lo_http_client->request->Set_cdata Exporting DATA=lv_json_str OFFSET=0LENGTH=Lv_len. "Send RequestLo_http_client->send (EXCEPTIONS http_communication_failure =1http_invalid_state=2 ). IF SY-SUBRC <>0. "The operation failed to get the reason for the failureLo_http_client->get_last_error (Importing MESSAGE =EV_MSGTX). Ev_msgty='E'.  EXIT.  ENDIF. "reads the processed results returned by the remote service. Lo_http_client->receive (EXCEPTIONS http_communication_failure =1http_invalid_state=2http_processing_failed=3 ). IF SY-SUBRC <>0 . Lo_http_client->get_last_error (Importing MESSAGE =EV_MSGTX). Ev_msgty='E'.  EXIT.    ELSE. "read back return contentCLEAR Lv_respon. Lv_respon= lo_http_client->response->Get_cdata ().    MOVE Lv_respon to EV_MSGTX. Ev_msgty='S'. ENDIF. Endfunction.
11:37:47 return to Jason content
[{functionname: "zmlscp1_fr0005", Bcpcode: "20170313001", Status: "S", msg: "Write the self-built table successfully! ", Result:" "}]
11:40:14
Now return the content to this address Http://deiap.changhong.com:18082/PM/ScpFunction/DispatchNotice

20170313 ABAP Returns the value to HTTP (interface content return) in Jason format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.