Skip to Content
avatar image
Former Member

Can we call Web Services from SAP 4.6C?

Hi All,

Can we make call to Webservice from SAP 4.6C? If yes, How?

If No, then Why?

Kindly let me know your valuable inputs..

Thanks & Regards,

Chandravadan

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Nov 29, 2006 at 06:36 PM

    I don't think so, the required framework is not avaiable in 46c. This framework was not introduced untill the basis turned to the Web Application Server.

    Regards,

    Rich Heilman

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 30, 2006 at 03:39 AM

    Try this code..

    REPORT  ZWORKORDER.
    
    TYPES: BEGIN OF OUTTAB1 ,
      JOBCODE(20),
      COMPONENTCODE(20),
      ACCURATEHOURS(20),
      ACCURATECOST(20),
      LENGTH TYPE I,
       END OF OUTTAB1 .
    
    DATA: OUTTAB TYPE  TABLE OF OUTTAB1.
    DATA: TAB TYPE OUTTAB1.
    
    DATA: WF_O LIKE LINE OF OUTTAB .
    DATA: XSLT_ERR TYPE REF TO CX_XSLT_EXCEPTION .
    DATA: RLENGTH TYPE I,
          TXLEN TYPE STRING  .
    
    DATA: HTTP_CLIENT TYPE REF TO IF_HTTP_CLIENT .
    
    DATA: WF_STRING TYPE STRING .
    DATA: WF_STRING1 TYPE STRING .
    DATA: WF_PROXY TYPE STRING ,
          WF_PORT TYPE STRING .
    
    
    CLEAR WF_STRING .
    
    * Form the input string to send the Input Data to Web service.
    
    CONCATENATE
    
    '<?xml version="1.0" encoding="utf-8"?>'
    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
    '  <soap:Body>'
    '    <GetWorkOrder xmlns="http://******t.net/webservices/">'
    '      <nWorkOrder>2</nWorkOrder>'
    '      <nDistributorCode>4871</nDistributorCode>'
    '      <model>HM400</model>'
    '     <type>1 </type>'
    '    </GetWorkOrder>'
    '  </soap:Body>'
    '</soap:Envelope>'
    
    INTO WF_STRING .
    
    CLEAR :RLENGTH , TXLEN .
    RLENGTH = STRLEN( WF_STRING ) .
    MOVE: RLENGTH TO TXLEN .
    
    CLEAR: WF_PROXY, WF_PORT .
    
    CALL METHOD CL_HTTP_CLIENT=>CREATE
      EXPORTING
        HOST    = '192.168.1.401' 
        SERVICE = '8080'
        SCHEME  = '1'
      IMPORTING
        CLIENT  = HTTP_CLIENT.
    
    HTTP_CLIENT->PROPERTYTYPE_LOGON_POPUP = HTTP_CLIENT->CO_DISABLED.
    
    
    CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
      EXPORTING
        NAME  = '~request_method'
        VALUE = 'POST'.
    
    CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
      EXPORTING
        NAME  = '~server_protocol'
        VALUE = 'HTTP/1.1'.
    
    CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
      EXPORTING
        NAME  = '~request_uri'
        VALUE = '/service/accurate/workorder.asmx?'.
    
    CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
      EXPORTING
        NAME  = 'Content-Type'
        VALUE = 'text/xml; charset=utf-8'.
    
    CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
      EXPORTING
        NAME  = 'Content-Length'
        VALUE = TXLEN.
    
    CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
      EXPORTING
        NAME  = 'SOAPAction'
        VALUE = 'http://*******ica.net/webservices/GetWorkOrder'.
    
    
    CALL METHOD HTTP_CLIENT->REQUEST->SET_CDATA
      EXPORTING
        DATA   = WF_STRING
        OFFSET = 0
        LENGTH = RLENGTH.
    
    * Send the Input Data to Web service.
    
    CALL METHOD HTTP_CLIENT->SEND
      EXCEPTIONS
        HTTP_COMMUNICATION_FAILURE = 1
        HTTP_INVALID_STATE         = 2.
    
    * Receive the Input from Web Serice.
    
    CALL METHOD HTTP_CLIENT->RECEIVE
      EXCEPTIONS
        HTTP_COMMUNICATION_FAILURE = 1
        HTTP_INVALID_STATE         = 2
        HTTP_PROCESSING_FAILED     = 3.
    
    CLEAR WF_STRING1 .
    WF_STRING1 = HTTP_CLIENT->RESPONSE->GET_CDATA( ).
    DATA: LENGTH TYPE I.
    
    LENGTH = STRLEN( WF_STRING1 ).
    
    DATA: VALUE_FIELD TYPE NAME_KOMP.
    DATA: VALUE TYPE REF TO DATA.
    FIELD-SYMBOLS: <FS_CONVERTED_DATA>.
    
    DATA: TAB1 TYPE TABLE OF STRING.
    
    DATA: FROM_LENGTH TYPE I VALUE 1.
    DATA: TO_LENGTH TYPE I.
    DATA: DIFF TYPE I.
    DATA: START TYPE I VALUE 1.
    
    
    DO.
    
    * JOBCODE.
    
      SEARCH WF_STRING1 FOR 'JobCode=' . "STARTING AT START .
    
      IF SY-SUBRC <> 0.
        EXIT.
      ENDIF.
    
      FROM_LENGTH = SY-FDPOS .
    
    
      FROM_LENGTH = FROM_LENGTH  + 8.
    
      SEARCH WF_STRING1 FOR 'JobDescription=' ."STARTING AT START ..
    
    
      TO_LENGTH = SY-FDPOS .
    
      DIFF = TO_LENGTH - FROM_LENGTH .
    
      MOVE WF_STRING1+FROM_LENGTH(DIFF) TO TAB-JOBCODE.
    
      TO_LENGTH = DIFF + TO_LENGTH.
    
      SHIFT WF_STRING1 BY TO_LENGTH PLACES.
    
    * COMPONENT CODE
    
      SEARCH WF_STRING1 FOR 'ComponentCode=' .
    
      IF SY-SUBRC <> 0.
        EXIT.
      ENDIF.
    
      FROM_LENGTH = SY-FDPOS .
    
    
      FROM_LENGTH = FROM_LENGTH  + 14.
    
      SEARCH WF_STRING1 FOR 'ComponentDescription=' .
    
      TO_LENGTH = SY-FDPOS .
    
      DIFF = TO_LENGTH - FROM_LENGTH .
    
      MOVE WF_STRING1+FROM_LENGTH(DIFF) TO TAB-COMPONENTCODE.
    
      TO_LENGTH = DIFF + TO_LENGTH.
    
      SHIFT WF_STRING1 BY TO_LENGTH PLACES.
    
    
    * AccurateHours
    
      SEARCH WF_STRING1 FOR 'AccurateHours=' .
    
      IF SY-SUBRC <> 0.
        EXIT.
      ENDIF.
    
      FROM_LENGTH = SY-FDPOS .
    
    
      FROM_LENGTH = FROM_LENGTH  + 14.
    
      SEARCH WF_STRING1 FOR 'AccurateCost='.
    
      TO_LENGTH = SY-FDPOS .
    
      DIFF = TO_LENGTH - FROM_LENGTH .
    
      MOVE WF_STRING1+FROM_LENGTH(DIFF) TO TAB-ACCURATEHOURS.
    
      TO_LENGTH = DIFF + TO_LENGTH.
    
    
    *  AccurateCost
    
      SEARCH WF_STRING1 FOR 'AccurateCost='.
    
      FROM_LENGTH =  SY-FDPOS.
    
      FROM_LENGTH =  FROM_LENGTH + 13.
    
      SEARCH WF_STRING1 FOR '/>'.
    
      TO_LENGTH = SY-FDPOS.
    
      DIFF = TO_LENGTH - FROM_LENGTH .
    
      MOVE WF_STRING1+FROM_LENGTH(DIFF) TO TAB-ACCURATECOST.
    
      TO_LENGTH = DIFF + TO_LENGTH.
    
      SHIFT WF_STRING1 BY TO_LENGTH PLACES.
    
      APPEND TAB TO OUTTAB.
    
    ENDDO.
    
    WRITE: (10) 'JOBCODE'.
    WRITE (20) 'COMPONENTCODE'.
    WRITE (30) 'ACCURATEHOURS'.
    WRITE (40) 'ACCURATECOST'.
    
    LOOP AT OUTTAB INTO TAB.
      WRITE:/ TAB-JOBCODE .
      WRITE (20) TAB-COMPONENTCODE.
      WRITE (30) TAB-ACCURATEHOURS.
      WRITE (40) TAB-ACCURATECOST.
    
    ENDLOOP .

    Raja T

    Add comment
    10|10000 characters needed characters exceeded