Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7137305
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2008-07-04 09:58:17

昨天在一个群友的博客上看到一篇HTTP Get的文章(http://www.dbsun.com/blog/article.asp?id=117),用的是if_http_client,其实,像这样简单的应用没有必要搞的这么麻烦,用一个函数就搞定了。
 
 
REPORT z_barry_test_http_get LINE-SIZE 256 .
 
TYPES: BEGIN OF text,
         line(256),
       END OF text.
DATA: status(3) TYPE c,
      statustext(128) TYPE c,
      rlength TYPE i .
DATA: response TYPE TABLE OF text WITH HEADER LINE,
      response_headers TYPE TABLE OF text WITH HEADER LINE.
 
PARAMETERS: url(256) TYPE c LOWER CASE default '' &
                     'huobizhengce/huobizhengcegongju/huilvzhengce/' &
                     'renminbihuilvjiaoyishoupanjia.asp' ,
            dest LIKE rfcdes-rfcdest DEFAULT 'SAPHTTP'.
 
START-OF-SELECTION.
 
  CALL FUNCTION 'HTTP_GET'
    EXPORTING
      absolute_uri                = url
      rfc_destination             = dest
      blankstocrlf                = 'Y'
*       proxy                       = '10.99.60.203:8080' 
    IMPORTING
      status_code                 = status
      status_text                 = statustext
      response_entity_body_length = rlength
    TABLES
      response_entity_body        = response
      response_headers            = response_headers.
 
  LOOP AT response_headers.
    WRITE response_headers-line.
  ENDLOOP.
  SKIP 2.
  LOOP AT response.
    REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab
                            IN response-line WITH ' '.
    WRITE response-line.
  ENDLOOP.
 
  CALL FUNCTION 'RFC_CONNECTION_CLOSE'
    EXPORTING
      destination = dest
    EXCEPTIONS
      OTHERS      = 0.
 
阅读(5273) | 评论(2) | 转发(1) |
给主人留下些什么吧!~~

qdbarry2008-07-24 17:52:09

我很少使用MSN的,在博客上交流吧:)

yangzilong2008-07-24 14:50:05

大哥,太强了吧。。。。 我是dbsun文章的作者, 能留个MSN么? jmuca_yang@hotmail.com