REPORT ZGETHELP.
************************************************************************
* This little abap is to demonstrate the possibility of getting to
* the web, searching for some information and displaying the filtered
* and processed result.
* This particular ABAP searches for SAP mailing list entries in
* the list archive using a search criteria entered as a parameter.
* < and > are substituted by [ and ], otherwise it looks really bad
* as an html file
************************************************************************
* Get the search criteria
PARAMETERS: SEARCH(20).

* Create a script on UNIX
DATA: F(30) VALUE '/tmp/query_saplist',
      S(100) VALUE 'get /cgi-local/AT-prim17saplistsearch.cgi?search='.
OPEN DATASET F IN TEXT MODE FOR OUTPUT.
TRANSFER 'telnet www.primestaff.net 80 [[ !!' TO F.
S+49 = SEARCH.
TRANSFER S TO F.
TRANSFER '!!' TO F.
CLOSE DATASET F.

* Make it runnable
DATA: CM(90) VALUE 'chmod 777 /tmp/query_saplist',
      BEGIN OF TABL OCCURS 0,
            LINE(200),
      END OF TABL.
CALL 'SYSTEM' ID 'COMMAND' FIELD CM
             ID 'TAB'     FIELD TABL-*SYS*.

* Run telnet, and get the result of the search
CM = '/tmp/query_saplist 1]/tmp/query_result'.
CALL 'SYSTEM' ID 'COMMAND' FIELD CM
              ID 'TAB'     FIELD TABL-*SYS*.

* Read the result and filter out the junk and fix the links
DATA: BEGIN OF ITAB OCCURS 100,
      LINE(255),
END OF ITAB.
OPEN DATASET '/tmp/query_result' FOR INPUT IN TEXT MODE.
DO.
  READ DATASET '/tmp/query_result' INTO ITAB.
  IF SY-SUBRC [] 0. EXIT. ENDIF.
  APPEND ITAB.
ENDDO.
LOOP AT ITAB.
  IF ITAB NP '*AT-prim17saplistsearch.cgi?doc*'.
    DELETE ITAB.
  ENDIF.
ENDLOOP.
LOOP AT ITAB.
  SHIFT ITAB LEFT UP TO 'x'.
  SHIFT ITAB LEFT BY 25 PLACES.
  SHIFT ITAB RIGHT UP TO '='.
  SHIFT ITAB RIGHT BY 9 PLACES.
  SHIFT ITAB LEFT UP TO '/'.
  SHIFT ITAB RIGHT BY 39 PLACES.
  ITAB+1(39) = '[BR][A HREF="http://www.primestaff.net/'.
  MODIFY ITAB.
ENDLOOP.
ITAB = '[p] The results of the search in the SAP archive for [B]'.
ITAB+57 = SEARCH. ITAB+130 = '[/B][/p][br]'.
INSERT ITAB INDEX 1.

* Create an html file on the PC
CALL FUNCTION 'WS_DOWNLOAD'
     EXPORTING
          FILENAME = 'c:\result.htm'
     TABLES
          DATA_TAB = ITAB.

* Start the web browser to display the html file
DATA: COMM(70) VALUE
    'd:\program files\netscape\communicator\program\netscape.exe'.
CALL FUNCTION 'WS_EXECUTE'
     EXPORTING
          PROGRAM        = COMM
          COMMANDLINE    = 'file:///c:/result.htm'
          INFORM         = ''
     EXCEPTIONS
          PROG_NOT_FOUND = 1.