Highlighted
Absent Member.
Absent Member.
1181 views

Invoke a URL from NetExpress cobol

Hi,

We use OLE methodology to invoke server objects like VB modules to perform print operation. I would like to know if there's any way to invoke a URL from cobol program.

For suppose invoke "www.google.com" from cobol program.

Appreciate your help. Thank you.

0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

RE: Invoke a URL from NetExpress cobol

Hi,

I have attached a code sample showing how you can use the WinHTTP COM objects from Net Express (or Visual COBOL).

There is an HTTP GET and HTTP POST example.

Regards

David

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Invoke a URL from NetExpress cobol

I think that...

     $set mfoo case remove(beep) remove(escape)

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

     * Modulo : cblSExec                                               *

     * Funcao : Exemplo de utilização da API ShellExecute, baseado em  *

     *          exemplo em VB que se encontra no APIGuide.             *

     *                                                                 *

     *Declaração da Função em VB:                                      *

     *ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"             *

     *            (ByVal hwnd As Long,                                 *

     *             ByVal lpOperation As String,                        *

     *             ByVal lpFile As String,                             *

     *             ByVal lpParameters As String,                       *

     *             ByVal lpDirectory As String,                        *

     *             ByVal nShowCmd As Long) As Long                     *

     *                                                                 *

     * Mais informações sobre a função no final deste arquivo.         *

     *                                                                 *

     * Pede-se a gentileza de, caso alguém venha a alterar/incluir     *

     * alguma função, enviar a mesma para ajsauro@gmail.com            *

     *                                                                 *

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

     * Se este código não funcionar, não faço idéia de quem o escreveu,*

     * mas se funcionar, ele foi escrito por:                          *

     *                                                                 *

     *                             /"""\                               *

     *                            ( o o )                              *

     *   .--------------------oOOO--(_)--OOOo--------------------.     *

     *   | Antonio João                                   ajSauro|     *

     *   | ajsauro@gmail.com                                     |     *

     *   |-------------------------------------------------------|     *

     *   | Primavera do Leste                 Diga não às drogas.|     *

     *   | Mato Grosso         .oooO          Não ouça pagode!   |     *

     *   | Brasil              (   )   Oooo.  Não ouça sertanojo!|     *

     *   `----------------------\ (----(   )---------------------´     *

     *                           \_)    ) /                            *

     *                                 (_/                             *

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

     *******************************************************************

      IDENTIFICATION         DIVISION.

     *******************************************************************

      PROGRAM-ID.  cblSExec.

     *******************************************************************

      ENVIRONMENT            DIVISION.

     *******************************************************************

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

      CONFIGURATION          SECTION.

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

      SPECIAL-NAMES.         Decimal-Point is Comma

                             Call-Convention 74 is WINAPI

                             .

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

      INPUT-OUTPUT           SECTION.

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

      FILE-CONTROL.

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

     *******************************************************************

      DATA                   DIVISION.

     *******************************************************************

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

      FILE                   SECTION.

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

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

      WORKING-STORAGE        SECTION.

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

      77           bool                pic s9(009) comp-5 is typedef.

      77           Program-Name        PIC X(008) VALUE "cblSExec".

     *

      78           DialogSystem        Value "dsgrun".

      78           cblNullString       VALUE X"00".

     * Você encontrará a definição destas constantes em WINDOWS.CPY

      78           SW-SHOWNORMAL       value 1.

      78           SW-SHOWMINIMIZED    value 2.

      78           SW-SHOWMAXIMIZED    value 3.

     *

      01           lsBool              bool.

      01           This-Program-Name   PIC X(012) VALUE "cblSExec".

      01           Program-Flags       PIC 9(2) COMP-5 VALUE 1.

        88         New-Instance        VALUE 1 FALSE 0.

     *

      01 DATA-BLOCK.

         03 WINDOW-HANDLE                   PIC x(4) COMP-5 value 0.

         03 OPERACAO                        PIC X(22).

     *

         03 DOPERATION                      PIC X(7).

         03 DSEXECPARAM.

            05 DFLAG                        PIC X(7).

            05 DQUERY                       PIC X(194).

     *******************************************************************

      procedure              division.

     *******************************************************************

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

      000-000-INICIO         Section.

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

          Perform  New-Set-Instance

          Perform  Abrir-WExplorer

          Perform  Abrir-IExplorer

          Perform  Program-Terminate

          Stop     Run

          .

      000-000-FINAL.

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

      Abrir-WExplorer        Section.

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

     *Abrir o Windows Explorer na pasta C:\Temp

          call     Winapi "ShellExecuteA" using

                                    by value Window-Handle

                                by Reference z"Open"

                                by Reference z"Explorer.exe"

                                by Reference z"C:\Temp\"

                                by Reference cblNullString

                                    by value SW-SHOWNORMAL

                                   returning lsBool

          .

      Abrir-IExplorer        Section.

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

     *Abrir o Internet Explorer em ajsauro.blogspot.com

          call     Winapi "ShellExecuteA" using

                                    by value Window-Handle             *>hwnd

                                by Reference dOperation                *>lpOperation

                                by Reference dSExecParam               *>lpFile

                                by Reference cblNullString             *>lpParameters

                                by Reference z"C:\"                    *>lpDirectory

                                    by value SW-SHOWNORMAL             *>nShowCmd

                                   returning lsBool                    *>Return value

          .

      New-Set-Instance       Section.

          CALL     'COB32API'

          MOVE     z"Open"             to dOPERATION

          MOVE     "http://"           to dFLAG

          MOVE

          z"ajsauro.blogspot.com.br/2014/03/campo-minado-em-cobol.html"

                                       to dQUERY

          .

      Program-Terminate      Section.

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

          Cancel   'COB32API'

          Move     "Zé Endi"           to dOperation

          .

     *******************************************************************

Antonio João

Primavera do Leste / MT / Brasil

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Invoke a URL from NetExpress cobol

Also see the simple example in the kb article here:

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.