Calling Acucobol program from Java


We need from java to call a cobol program with the following linkage on Acu 9.1 on Unix:

  01 lnk-proc-block.       
        02 tbl-exams-lnk.
         03 tea-exam-lnk         occurs 500.
          04 tea-exam              pic 9(5).
          04 tea-analisis          occurs 500.
           05 tea-anal             pic 9(8).
           05 tea-resu             pic x(45).        
           05 tea-uni              pic x(15).
           05 tea-ran              pic x(12).
           05 tea-ens              pic x(2).
           05 tea-est              pic x(1).
           05 tea-estmuc           pic x(1).
           05 tea-orden            pic 9(3).
          04 tea-cantAnal          pic 9(4).
          04 tea-socio             pic 9(8).
          04 tea-tubo              pic 9(12).
          04 tea-check.
             05 tea-chalf          pic x(5).
             05 tea-chnum          pic 9(4).
          04 tea-impreso           pic x.
          04 tea-repetido          pic x.
          04 tea-bloque-fallido    pic x.
        02 totalRegistros          pic 9(4).
        02 nombreArchivoLogLnk     pic x(20).
        02 nombreArchivoModulabLnk pic x(80).
        02 graboArchivoTmpLnk      pic x.
        02 varIntentosLnk          pic 9(2) value 1.
        02 retorno-lnk             pic 9.

The samples that come with Extend do not include how to deal with an array of string.

Any ideas or samples to use?


Juan Urraburu

  • I believe you need to consider this as one large string .. when using the CVM for Java calling COBOL, there is a CALL_OPTIONS which allows you to specify the amount of bytes the COBOL will receive. A Guide to Interoperating with ACUCOBOL-GT  Chapter 2: Working with Java Technology > 2.2 Calling COBOL from Java > 2.2.3 Using the Java API, "CVM.jar"  > CALL_OPTIONS class

    The CALL_OPTIONS class contains a linkage_signature property that describes the data in the linkage section. For example, a linkage_signature of "X45X20SSIJ" describes two PIC X items of 45 and 20 bytes respectively, two shorts, an integer, and a long.

    The linkage_signature ensures that there is enough memory for Java strings to get passed in, even when the Java string has a shorter length than the PIC X data item in the linkage section. For example, a Java string of length 10 can be passed into a PIX X(45) data item. In this case, 45 bytes are allocated to memory, not 10 bytes.