WPita_MMSIS Super Contributor.
Super Contributor.
4986 views

NetExpress convert to Visual Studio

Jump to solution

Good morning, I am again with this old problem, I need to convert this program done in Net EXpress to Visual Cobol, noting que the program works Correctly in NetExpress but in Visual Cobol can not load the DLL. The dll this installed in windows \ system32 folder. Thank you.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Altair Absent Member.
Absent Member.

RE: NetExpress convert to Visual Studio

Jump to solution

Pita,

It worked?  Funcionou?

0 Likes
10 Replies
WPita_MMSIS Super Contributor.
Super Contributor.

RE: NetExpress convert to Visual Studio

Jump to solution

     $set mfoo

      class-id. ECF.

      environment division.

      input-output section.

     *

      object section.

      class-control.

          Util                    is class "Util"

          .

      special-names.

          call-convention 2 is DSDLL.

     *>----------------------------------------------------------------

      data division.

      file section.

     *

      working-storage section. *> Definition of global data

      77  cmdstatus               pic s9 comp-5.

      77  cmdstatus-r             pic s9.

     *Crio um ponteiro

     *-----variaveis do ecf --------

     *variavel utilizada para carregar a DLL na memoria

      01  SAT-Tanca               usage is procedure-pointer.

     *>----------------------------------------------------------------

      class-object.   *> Definition of class data and methods

     *>----------------------------------------------------------------

      object-storage section.

     *>----------------------------------------------------------------

     *> Poe Nulo no final

     *>----------------------------------------------------------------

      method-id. "PoeNulo".

      01  i                   Pic X(4) comp-5.

      01  j                   Pic X(4) comp-5.

      linkage section.

      77  zSTR                pic x(256).

      procedure division using zSTR. *> by value i.

          MOVE LENGTH OF zStr         TO j

          perform varying i from j by -1 until i = 0

                 if zSTR(i:1) not = space and x"0"

                    add 1                 to i

                    move x"0"             to zSTR(i:1)

                    exit method

                 end-if

          end-perform.

          exit method.

      end method "PoeNulo".

     *>----------------------------------------------------------------

     *>----------------------------------------------------------------

     *>             I N I C I O    D A S    R O T I N A S

     *>                       SAT-CFe

     *>----------------------------------------------------------------

     *>----------------------------------------------------------------

      method-id. "SATEnviarCFe".

      local-storage section.

      01  WS-NRO-OFI                  pic x(006).

      01  RZ-INFADCONTRIB             pic x(008).

      01  retorno                     pic x(008).

      01  codigoDeAtivacao            pic x(009).

      01 DataBlock-Pointer            usage pointer.

      01 w-campos-ret.

          03 w-campo1                 pic x(256).

          03 w-campo2                 pic x(256).

          03 w-campo3                 pic x(256).

          03 w-campo4                 pic x(256).

          03 w-campo5                 pic x(256).

          03 w-campo6                 pic x(256).

      linkage section.

      01 lnk-datahoraimp.

          03 lnk-dataimp          pic x(006).

          03 lnk-horaimp          pic x(006).

      01  lnk-erro.

          02 lnk-fs                   pic x(002).

          02 lnk-mensagem             pic x(040).

      01 VDA-DATA-BLOCK.

            05 VDA-IO-TEXT-BUFFER2          PIC X(256).

      procedure division.

      *>Seto essa variável para cada um dos sat.

          set SAT-Tanca           to entry "SAT.dll".

          move "000001"           to ws-nro-ofi

          move z"12345678"         to rz-infadcontrib codigoDeAtivacao

          CALL DSDLL "ConsultarStatusOperacional" using

                                        ws-Nro-ofi

                                        by reference codigoDeAtivacao

                               returning DataBlock-Pointer

      *>Ai pego o retorno

          set address of VDA-DATA-BLOCK to DataBlock-Pointer

          perform trata-retorno

          move spaces to VDA-IO-TEXT-BUFFER2

          exit method.

      processos-ok.

          CALL DSDLL "ConsultarSAT" using WS-Nro-ofi

                               returning DataBlock-Pointer

          set address of VDA-DATA-BLOCK to DataBlock-Pointer

          perform trata-retorno

          move spaces to VDA-IO-TEXT-BUFFER2

          CANCEL "ConsultarSAT"

          exit method.

      trata-retorno.

          unstring VDA-IO-TEXT-BUFFER2

                                   delimited by "|" into w-campo1

                                                         w-campo2

                                                         w-campo3

                                                         w-campo4

                                                         w-campo5

                                                         w-campo6

      end method "SATEnviarCFe".

      end class-object.

0 Likes
Micro Focus Expert
Micro Focus Expert

RE: NetExpress convert to Visual Studio

Jump to solution

A few questions for you:

Is SAT.dll written in Net Express? If it is then it too will have to be recompiled using Visual COBOL.

What is the error that you are receiving?

Is the set SAT-Tanca to entry "SAT.dll" statement loading the .dll? Try removing the .dll extension from name.

Are the calling program and the called program both the same bitism?

0 Likes
WPita_MMSIS Super Contributor.
Super Contributor.

RE: NetExpress convert to Visual Studio

Jump to solution

Not SAT.dll was not done in NetExpress.

I put the image of the error, but my Visual Studio is in Portuguese: www.mmsis.com.br/images/Erro_SAT.png

I took the .dll but the error persists

Are the calling program and the called program both the same bitism? I did not understand that.

0 Likes
Micro Focus Expert
Micro Focus Expert

RE: NetExpress convert to Visual Studio

Jump to solution

This looks like you are trying to call this native .dll from a managed .NET program in Visual COBOL whereas you were calling it from a native program in Net Express, correct?

Are you compiling the OO program that you show above as managed code or is that compiled as native code? I am a bit confused because the syntax of the program you are showing uses the old native OO syntax and not the new managed syntax.

If you are calling a native .dll from a managed code program then they must be using the same bitism. That means that if SAT.dll is a 32-bit .dll then your managed project should also have a target of x86 and not x64 or anyCPU. If SAT.dll is a 64-bit .dll then your managed project should be targeting x64.

Can you check your project properties on the COBOL tab and tell me what the target CPU is set to?

0 Likes
WPita_MMSIS Super Contributor.
Super Contributor.

RE: NetExpress convert to Visual Studio

Jump to solution

- I do not understand anything, the DLL was written in C # if it is native I have no idea.

- That's how I learned and this working out for that will change, I do not know anything about the managed syntax.

- SAT.dll is a 32-bit dll, Yes my project is set to AnyCPU.

0 Likes
Altair Absent Member.
Absent Member.

RE: NetExpress convert to Visual Studio

Jump to solution

          Pita, tente o seguinte:

          Crie um novo projeto nativo dentro da solução.

          adiciona a dll

          selecione propriedades do projeto nativo e informe a plataforma 86x

          No projeto da aplicação insira algo como:

          declare myClass as type solution.projectNative = new solution.projetcNative()

          declare myString as string = "visual cobol"

          invoke myClass::nameMethod(myString)

          display myString.

          Penso que isso irá te ajudar.

0 Likes
WPita_MMSIS Super Contributor.
Super Contributor.

RE: NetExpress convert to Visual Studio

Jump to solution

Altair, adicionar a dll, onde? Fica complicado programei em NET Express por muito tempo agora temos que nos adaptar a esta nova plataforma e esta bem complicado, não encontramos nada na WEB sobre VC e para fazer qualquer coisa temos que recorrer a programação C# ai traduzir para o Cobol. Veja eu tenho um código que esta em BASE64 passei a pergunta mas não sei se temos que falar que queremos converter ou decodificar, a língua portuguesa nos prega muitas peças, principalmente para traduzir para o Inglês usando o Google Tradutor.

Só um desabafo, voltando ao assunto, fiz um projeto Nativo mas não sei onde adicionar a dll.

Grande abraço e obrigado pelo tempo.

0 Likes
Altair Absent Member.
Absent Member.

RE: NetExpress convert to Visual Studio

Jump to solution

Na verdade, você não precisa criar um projeto nativo. Click-right sobre o nome do projeto e Add Reference > Browse e selecione a DLL desejada. Depois é só fazer a chamada. Anexei um arquivo com dois projetos, um em VB.NET (DLL) e outro em Visual Cobol chamando a DLL. Espero que possa lhe ajudar. Caso ainda não saiba, escrevi o livro Visual Cobol for .NET disponível nas livrarias online AgBook e Saraiva.

In fact, you do not need to create a native project. Click-right on the project name and Add Reference> Browse and select the desired DLL. Then just make the call. I have attached one file with two projects, one in VB.NET (DLL) and another in Visual Cobol calling the DLL. I hope you can help. If you still do not know, I wrote a book Visual COBOL for .NETavailable in online bookstores AgBook and Saraiva.

0 Likes
Highlighted
Altair Absent Member.
Absent Member.

RE: NetExpress convert to Visual Studio

Jump to solution

Pita,

It worked?  Funcionou?

0 Likes
WPita_MMSIS Super Contributor.
Super Contributor.

RE: NetExpress convert to Visual Studio

Jump to solution

O exemplo que você me passou funciona, vou tentar fazer a adaptação para o SAT.dll mas agora tenho que terminar o processo com o ACBr já esta muito atrasado. Obrigado

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.