Quantcast
Channel: SCN: Message List - ABAP Connectivity
Viewing all articles
Browse latest Browse all 3125

Re: using FM HTTP_POST

$
0
0

This is my full source~

 

 

*----------------------------------------------------------------------*

*  Report  ZEONC_HTTP_POST

*

*----------------------------------------------------------------------*

*

*

*----------------------------------------------------------------------*

REPORT ZEONC_HTTP_POST.

 

PARAMETERS : P_URI(100) LOWER CASE DEFAULT

                   'http://xxx.com/dwgNew/Mi_cutDwgDown.jsp'.

* HTTP POST

DATA : LV_STATUS_CODE(5),

       LV_STATUS_TEXT(300),

       LV_LEN              TYPE          I,

       LV_PARAMS           TYPE          STRING,

       LT_REQ_HEAD         TYPE TABLE OF SBCHEADER WITH HEADER LINE,

       LT_REQ_BODY         TYPE TABLE OF SBCBODY WITH HEADER LINE,

       LT_RES_HEAD         TYPE TABLE OF SBCHEADER WITH HEADER LINE,

       LT_RES_BODY         TYPE TABLE OF SBCBODY WITH HEADER LINE.

 

* XML Parsing

DATA : LV_XML     TYPE        STRING,

       LO_NODE    TYPE REF TO IF_IXML_NODE,

       LV_VALUE   TYPE        STRING,

       LO_XML_DOC TYPE REF TO CL_XML_DOCUMENT.

 

* ETC.

DATA : LV_URL TYPE BXMNODES-URL.

 

* Set Header

APPEND 'Content-Type: text/xml; charset=euc-kr' TO LT_REQ_HEAD.

 

* Set Parameter

APPEND '<?xml version="1.0" encoding="euc-kr"?>             ' TO LT_REQ_BODY.

APPEND '<root>                                              ' TO LT_REQ_BODY.

APPEND '<params>                                            ' TO LT_REQ_BODY.

APPEND '<param id="admMode" type="STRING">Y</param>         ' TO LT_REQ_BODY.

APPEND '<param id="block" type="STRING">A23</param>         ' TO LT_REQ_BODY.

APPEND '<param id="gubun" type="STRING">lot</param>         ' TO LT_REQ_BODY.

APPEND '<param id="ocomp" type="STRING"></param>            ' TO LT_REQ_BODY.

APPEND '<param id="path" type="STRING"></param>             ' TO LT_REQ_BODY.

APPEND '<param id="shipno" type="STRING">S630</param>       ' TO LT_REQ_BODY.

APPEND '<param id="userid" type="STRING">AAAAAAAAAA</param> ' TO LT_REQ_BODY.

APPEND '<param id="plate" type="STRING">Y</param>           ' TO LT_REQ_BODY.

APPEND '<param id="print_view" type="STRING">V</param>      ' TO LT_REQ_BODY.

APPEND '</params>                                           ' TO LT_REQ_BODY.

APPEND '<dataset id="ds_input">                             ' TO LT_REQ_BODY.

APPEND '<colinfo id="chk" size="1" type="STRING"/>          ' TO LT_REQ_BODY.

APPEND '<colinfo id="dwgno" size="2" type="STRING"/>        ' TO LT_REQ_BODY.

APPEND '<colinfo id="fab" size="3" type="STRING"/>          ' TO LT_REQ_BODY.

APPEND '<colinfo id="filechk" size="3" type="STRING"/>      ' TO LT_REQ_BODY.

APPEND '<colinfo id="filename" size="30" type="STRING"/>    ' TO LT_REQ_BODY.

APPEND '<colinfo id="grp" size="1" type="STRING"/>          ' TO LT_REQ_BODY.

APPEND '<colinfo id="lot" size="3" type="STRING"/>          ' TO LT_REQ_BODY.

APPEND '<colinfo id="revno" size="3" type="STRING"/>        ' TO LT_REQ_BODY.

APPEND '<colinfo id="ship" size="5" type="STRING"/>         ' TO LT_REQ_BODY.

APPEND '<record>                                            ' TO LT_REQ_BODY.

APPEND '<chk>1</chk>                                        ' TO LT_REQ_BODY.

APPEND '<dwgno>01</dwgno>                                   ' TO LT_REQ_BODY.

APPEND '<fab>COM</fab>                                      ' TO LT_REQ_BODY.

APPEND '<filechk>Oilechk>                                   ' TO LT_REQ_BODY.

APPEND '<filename>XXXXXXXXXXXXX.XXX</filename>              ' TO LT_REQ_BODY.

APPEND '<grp>4L</grp>                                       ' TO LT_REQ_BODY.

APPEND '<lot>A23</lot>                                      ' TO LT_REQ_BODY.

APPEND '<revno>0</revno>                                    ' TO LT_REQ_BODY.

APPEND '<ship>S630</ship>                                   ' TO LT_REQ_BODY.

APPEND '</record>                                           ' TO LT_REQ_BODY.

APPEND '</dataset>                                          ' TO LT_REQ_BODY.

APPEND '</root>                                             ' TO LT_REQ_BODY.

 

* Send Post **********************************************************

CALL FUNCTION 'HTTP_POST'

  EXPORTING

    ABSOLUTE_URI                = P_URI

    REQUEST_ENTITY_BODY_LENGTH  = LV_LEN

    RFC_DESTINATION             = 'SAPHTTP'

*   PROXY                       =

*   PROXY_USER                  =

*   PROXY_PASSWORD              =

*   USER                        =

*   PASSWORD                    =

    BLANKSTOCRLF                = 'X'

  IMPORTING

    STATUS_CODE                 = LV_STATUS_CODE

    STATUS_TEXT                 = LV_STATUS_TEXT

    RESPONSE_ENTITY_BODY_LENGTH = LV_LEN

  TABLES

    REQUEST_ENTITY_BODY         = LT_REQ_BODY

    RESPONSE_ENTITY_BODY        = LT_RES_BODY

    RESPONSE_HEADERS            = LT_RES_HEAD

    REQUEST_HEADERS             = LT_REQ_HEAD

  EXCEPTIONS

    CONNECT_FAILED              = 1

    TIMEOUT                     = 2

    INTERNAL_ERROR              = 3

    TCPIP_ERROR                 = 4

    SYSTEM_FAILURE              = 5

    COMMUNICATION_FAILURE       = 6

    OTHERS                      = 7.

 

* Check result

IF LV_STATUS_CODE NE '200'. " Failure

  WRITE : / 'STATUS CODE :' , 15 LV_STATUS_CODE.

  WRITE : / 'STATUS TEXT :' , 15 LV_STATUS_TEXT , /.

 

 

  WRITE : / 'RESPONSE HEADER : '.

  LOOP AT LT_RES_HEAD.

    WRITE /3 LT_RES_HEAD.

  ENDLOOP.

 

 

  WRITE : /, / 'RESPONSE BODY : '.

  LOOP AT LT_RES_BODY.

    WRITE /3 LT_RES_BODY.

  ENDLOOP.

 

 

  EXIT.

ENDIF.

 

* Parsing XML Return Value

CLEAR : LV_XML.

LOOP AT LT_RES_BODY.

  CONCATENATE LV_XML LT_RES_BODY INTO LV_XML.

ENDLOOP.

 

CREATE OBJECT LO_XML_DOC.

 

LO_XML_DOC->PARSE_STRING( STREAM = LV_XML ).

LO_NODE  = LO_XML_DOC->FIND_NODE( NAME = 'iis_url' ).

LV_VALUE = LO_XML_DOC->GET_NODE_VALUE( NODE = LO_NODE ).

 

LV_URL = LV_VALUE.

 

CALL FUNCTION 'PRGN_GENER_EXECUTE_URL'

  EXPORTING

    NODE_DATA = LV_URL.


Viewing all articles
Browse latest Browse all 3125

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>