用ABAP往网页上取数据

标签:ABAP

boss交给我的第2个练习=。=

代码中搜索的员工不是我,是最大的BOSS…

REPORT zhttp_receive.
 
INITIALIZATION.
  DATA : url_ TYPE string,
        http_client TYPE REF TO if_http_client,
        xbuffer TYPE xstring.

START-OF-SELECTION.
  url_ = 'http://bluepages.ibm.com'.
  CALL METHOD cl_http_client=>create_by_url
    EXPORTING
      url    = url_
    IMPORTING
      client = http_client
    EXCEPTIONS
      OTHERS = 1.
  CALL METHOD http_client->request->set_header_field
    EXPORTING
      name  = '~request_uri'
      value = '/BpHttpApis/slaphapi?ibmperson/((sn=Chow)(c=cn)).list/byxml'.
  CALL METHOD http_client->send
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3.
  WRITE / sy-subrc.
  CALL METHOD http_client->receive
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3.
  IF sy-subrc <> 0.
    WRITE / sy-subrc.
    EXIT.
  ENDIF.

END-OF-SELECTION.
  xbuffer = http_client->response->get_data( ).
  WRITE : / xbuffer. 

3条评论 你不来一发么↓ 顺序排列 倒序排列

    向下滚动可载入更多评论,或者点这里禁止自动加载

    想说点什么呢?