SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Searches WEB the mailing list archive for old postings



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sun Nov 18, 2007 8:40 pm    Post subject: Searches WEB the mailing list archive for old postings Reply with quote

Search the WEB from ABAP - this program searches the mailing list archive for old postings

Code:
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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.