[NEWSboard IBMi Forum]
  1. #1
    Registriert seit
    May 2004
    Beiträge
    444

    Download Link über RPG

    Hallo zusammen,

    weiß jemand ob es möglich ist eine Internetaddresse über RPG direkt (aus dem Programm heraus ohne Benutzerinteraktion) oder per Mausklick (Link im Screen) aufzurufen ?
    Und wenn ja wie ?

    Vielen Danke für die Mühe

    Viele Grüße Harald

  2. #2
    Registriert seit
    Feb 2001
    Beiträge
    20.241
    Das geht nur über STRPCCMD mit vorherigem STRPCO an einer 5250-Sitzung, die dies unterstützt (z.B. CA).
    Dienstleistungen? Die gibt es hier: http://www.fuerchau.de
    Das Excel-AddIn: https://www.ftsolutions.de/index.php/downloads
    BI? Da war doch noch was: http://www.ftsolutions.de

  3. #3
    Registriert seit
    Nov 2003
    Beiträge
    2.307

  4. #4
    Registriert seit
    May 2004
    Beiträge
    444
    Um ganz ehrlich zu sein hab ich von dem was ich gemacht habe überhaupt keine Ahnung. Ich hab mir mal das Programm was bei dem Socket-Tutorial angegeben war compiliert. Nachfolgend der Programmcode
    PHP-Code:
    H DFTACTGRP(*NOACTGRP(*NEW)                                  
                                                                   
    D getservbyname   PR              *   ExtProc('getservbyname'
    D  service_name                   *   value options(*string)   
    D  protocol_name                  *   value options(*string)   
                                                                   
    D p_servent       S               *                            
    D servent         DS                  based(p_servent)         
    D   s_name                        *                            
    D   s_aliases                     *                            
    D   s_port                      10I 0                          
    D   s_proto                       
    *                            
    D inet_addr       PR            10U 0 ExtProc('inet_addr')     
    D  address_str                    *   value options(*string)   
                                                                   
    D INADDR_NONE     C                   CONST(4294967295)        
                                                                   
    D inet_ntoa       PR              *   ExtProc('inet_ntoa')     
    D  internet_addr                10U 0 value                    
                                                                  
    D p_hostent       S               
    *                           
    D hostent         DS                  Based(p_hostent)        
    D   h_name                        *                           
    D   h_aliases                     *                           
    D   h_addrtype                  10I 0                         
    D   h_length                    10I 0                         
    D   h_addr_list                   
    *                           
    D p_h_addr        S               *   Based(h_addr_list)      
    D h_addr          S             10U 0 Based(p_h_addr)         
    D gethostbyname   PR              *   extproc('gethostbyname')
    D   host_name                     *   value options(*string)  
                                                                  
    D socket          PR            10I 0 ExtProc('socket')       
    D  addr_family                  10I 0 value                   
    D  type                         10I 0 value                   
    D  protocol                     10I 0 value                   
                                                                  
    D AF_INET         C                   
    CONST(2)                
    D SOCK_STREAM     C                   CONST(1)                
    D IPPROTO_IP      C                   CONST(0)            
                                                              
    D connect         PR            10I 0 ExtProc('connect')  
    D  sock_desc                    10I 0 value               
    D  dest_addr                      
    *   value               
    D  addr_len                     10I 0 value               
    D p_sockaddr      S               
    *                       
    D sockaddr        DS                  based(p_sockaddr)   
    D   sa_family                    5I 0                     
    D   sa_data                     14A                       
    D sockaddr_in     DS                  based
    (p_sockaddr)   
    D   sin_family                   5I 0                     
    D   sin_port                     5U 0                     
    D   sin_addr                    10U 0                     
    D   sin_zero                     8A                       
                                                              
    D send            PR            10I 0 ExtProc
    ('send')     
    D   sock_desc                   10I 0 value               
    D   buffer                        
    *   value               
    D   buffer_len                  10I 0 value               
    D   flags                       10I 0 value                
                                                               
    D recv            PR            10I 0 ExtProc
    ('recv')      
    D   sock_desc                   10I 0 value                
    D   buffer                        
    *   value                
    D   buffer_len                  10I 0 value                
    D   flags                       10I 0 value                
                                                               
    D close           PR            10I 0 ExtProc
    ('close')     
    D  sock_desc                    10I 0 value                
                                                               
    D translate       PR                  ExtPgm
    ('QDCXLATE')   
    D   length                       5P 0 const                
    D   data                     32766A   options(*varsize)    
    D   table                       10A   const                
    D msg             S             50A                        
    D sock            S             10I 0                      
    D port            S              5U 0                      
    D addrlen         S             10I 0                      
    D ch              S              1A                        
    D host            s             32A                      
    D file            s             32A                      
    D IP              s             10U 0                    
    D p_Connto        S               
    *                      
    D RC              S             10I 0                    
    D Request         S             60A                      
    D ReqLen          S             10I 0                    
    D RecBuf          S             50A                      
    D RecLen          S             10I 0                    
    C
    *************************************************       
    CThe user will supply a hostname and file              
    C
    *  name as parameters to our program...                 
    C*************************************************       
    c     *entry        plist                                
    c                   parm                    host         
    c                   parm                    file         
                                                             
    c                   
    eval      *inlr = *on                
                                                             
    C
    *************************************************       
    Cwhat port is the http service located on?                             
    C*************************************************                       
    c                   eval      p_servent getservbyname('http':'tcp')    
    c                   if        p_servent = *NULL                          
    c                   
    eval      msg 'Can''t find the http service!'      
    c                   dsply                   msg                          
    c                   
    return                                               
    c                   endif                                                
    c                   eval      port s_port                              
                                                                             
    C
    *************************************************                       
    CGet the 32-bit network IP address for the host                        
    C
    *  that was supplied by the user:                                       
    C*************************************************                       
    c                   eval      IP inet_addr(%trim(host))                
    c                   if        IP INADDR_NONE                           
    c                   
    eval      p_hostent gethostbyname(%trim(host))     
    c                   if        p_hostent = *NULL                          
    c                   
    eval      msg 'Unable to find that host!'          
    c                   dsply                   msg                          
    c                   
    return                                          
    c                   endif                                           
    c                   eval      IP h_addr                           
    c                   
    endif                                           
    C*************************************************                  
    CCreate a socket                                                  
    C
    *************************************************                  
    c                   eval      sock socket(AF_INETSOCK_STREAM:   
    c                                           IPPROTO_IP)             
    c                   if        sock 0                              
    c                   
    eval      msg 'Error calling socket()!'       
    c                   dsply                   msg                     
    c                   
    return                                          
    c                   endif                                           
    C*************************************************                  
    CCreate a socket address structure that                           
    C
    *   describes the host port we wanted to                         
    C
    *   connect to                                                     
    C
    *************************************************                  
    c                   eval      addrlen = %size(sockaddr)             
    c                   alloc     addrlen       p_connto                       
                                                                               
    c                   
    eval      p_sockaddr p_connto                        
    c                   
    eval      sin_family AF_INET                         
    c                   
    eval      sin_addr IP                                
    c                   
    eval      sin_port port                              
    c                   
    eval      sin_zero = *ALLx'00'                         
    C*************************************************                         
    CConnect to the requested host                                           
    C
    *************************************************                         
    C                   if        connect(sockp_conntoaddrlen) < 0         
    c                   
    eval      msg 'unable to connect to server!'         
    c                   dsply                   msg                            
    c                   callp     close
    (sock)                                  
    c                   return                                                 
    c                   endif                                                  
                                                                               
    C*************************************************                         
    CFormat a request for the file that we'd like                            
    C* the http server to send us:                                             
    C*************************************************                          
    c                   eval      request = '
    GET ' + %trim(file) +              
    c                               ' 
    HTTP/1.0' + x'0D25' + x'0D25'             
    c                   eval      reqlen = %len(%trim(request))                 
    c                   callp     Translate(reqlen: request: '
    QTCPASC')         
    C*************************************************                          
    c*  Send the request to the http server                                     
    C*************************************************                          
    c                   eval      rc = send(sock: %addr(request): reqlen:0)     
    c                   if        rc < reqlen                                   
    c                   eval      Msg = '
    Unable to send entire request!'        
    c                   dsply                   msg                             
    c                   callp     close(sock)                                   
    c                   return                                                  
    c                   endif                                                   
                                                                                
    C*************************************************                          
    C* Get back the server'
    s response                                           
    C
    *************************************************                          
    c                   dou       rc 1                                        
                                                                             
    C                   exsr      DsplyLine                                   
    c                   enddo                                                 
    C
    *************************************************                        
    C*  We're done, so close the socket.                                      
    C*   do a dsply with input to pause the display                           
    C*   and then end the program                                             
    C*************************************************                        
    c                   callp     close(sock)                                 
    c                   dsply                   pause             1           
    c                   return                                                
    C*===============================================================         
    C* This subroutine receives one line of text from a server and            
    C*  displays it on the screen using the DSPLY op-code                     
    C*===============================================================         
    CSR   DsplyLine     begsr                                                 
    C*------------------------                                                
    C*************************************************                        
    C* Receive one line of text from the HTTP server.                         
    C*  note that "lines of text" vary in length,                             
    C*  but always end with the ASCII values for CR                           
    C*  and LF.  CR = x'
    0D' and LF = x'0A'                             
    C*                                                                 
    C* The easiest way for us to work with this data                   
    C* is to receive it one byte at a time until we                    
    C* get the LF character.   Each time we receive                    
    C* a byte, we add it to our receive buffer.                        
    C*************************************************                 
    c                   eval      reclen = 0                           
    c                   eval      recbuf = *blanks                     
                                                                       
    c                   dou       reclen = 50 or ch = x'
    0A'            
    c                   eval      rc = recv(sock: %addr(ch): 1: 0)     
    c                   if        rc < 1                               
    c                   leave                                          
    c                   endif                                          
    c                   if        ch<>x'
    0D' and ch<>x'0A'              
    c                   eval      reclen = reclen + 1                  
    c                   eval      %subst(recbuf:reclen:1) = ch         
    c                   endif                                          
    c                   enddo                                          
    C*************************************************                               
    C* translate the line of text into EBCDIC                                        
    C* (to make it readable) and display it                                          
    C*************************************************                               
    c                   if        reclen > 0                                         
    c                   callp     Translate(reclen: recbuf: '
    QTCPEBC')               
    c                   endif                                                        
    c     recbuf        dsply                                                        
    C*------------------------                                                       
    Csr                 endsr 
    Bei Connect to requested host bringt er dann den Fehler.

    Kann mir da jemand helfen ???

    Falls mir überhaupt noch zu helfen ist

  5. #5
    Registriert seit
    Nov 2003
    Beiträge
    2.307
    Was hast du denn genau vor bzw. mach doch mal ein Beispiel.

  6. #6
    Registriert seit
    May 2004
    Beiträge
    444
    Aufgabenstellung ist folgende:

    Diese Seite https://www.db-markets.com/portal/FxFixings/23-06-2010
    natürlich abhängig vom Datum einzulesen und die Daten dann aufbereitet zur Verfügung zu stellen.

  7. #7
    Registriert seit
    Nov 2003
    Beiträge
    2.307
    Hm, https. Also auch noch verschlüsselt. Probier mal BVS/Tools - Get URI (GETURI).

  8. #8
    Registriert seit
    May 2004
    Beiträge
    444
    Das mit dem verschlüsselten soll erst später zum Problem werden. Im Moment komm ich ja noch nicht mal an eine normale Seite ran. GETURI ist kostenpflichtig also fällt das für mich weg.

  9. #9
    Registriert seit
    Feb 2001
    Beiträge
    20.241
    Kannst du denn per Ping das Internet erreichen ?
    Stimmen die DNS-Einträge CHGTCPDMN, so dass die Namensauflösung auch funktioniert ?

    Und was die Kosten angeht, der EUR steht doch ganz gut und die Zeit die du zur Entwicklung benötigst übersteigen die Einmalkoste wohl bei weitem.
    Dienstleistungen? Die gibt es hier: http://www.fuerchau.de
    Das Excel-AddIn: https://www.ftsolutions.de/index.php/downloads
    BI? Da war doch noch was: http://www.ftsolutions.de

  10. #10
    Registriert seit
    May 2004
    Beiträge
    444
    Mir brauchst Du solche Sachen nicht erklären. Also das mit den Programmierkosten meine ich. Firmenpolitik usw.

    Aber jetzt noch mal zum Thema

    Ping kann ich machen von der AS400 aus und funktioniert auch 5 von 5

    Ich denk mal dass ich den CHGTCPDMN nicht brauche da die Pings ja funktionieren

  11. #11
    Registriert seit
    May 2006
    Beiträge
    88

    Scott C. Klement kann dir helfen

    Schau dir mal HTTPAPIR4 von Scott Klement an. Mit der Prozedure http_url_get() kann man das XMl ins IFS schreiben und von da kann man es ja verarbeiten.

Similar Threads

  1. Rückgabewert vom RPG Programm
    By mk in forum NEWSboard Java
    Antworten: 8
    Letzter Beitrag: 21-04-11, 21:51
  2. Bibliotheksliste in RPG IV abfragen
    By timeless in forum IBM i Hauptforum
    Antworten: 5
    Letzter Beitrag: 11-01-07, 12:04
  3. Frei Porn Site!
    By Fucasdreh in forum NEWSboard Server Job
    Antworten: 0
    Letzter Beitrag: 10-01-07, 13:12
  4. Problem mit Java-Methoden Aufruf aus ILE RPG?
    By Stoeberl in forum NEWSboard Programmierung
    Antworten: 8
    Letzter Beitrag: 10-01-07, 10:58
  5. RPG goes Web
    By jth in forum NEWSboard Programmierung
    Antworten: 1
    Letzter Beitrag: 21-12-06, 11:13

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • You may not post attachments
  • You may not edit your posts
  •