Absent Member.
Absent Member.
814 views

Problems with calling Procedural Cobol from Java in VC Eclipse and the use of the RM/COBOL File handler

Jump to solution

[Migrated content. Thread originally posted on 26 January 2012]

Hello,

I have this code (from the Microfocus documentation) to test


program-id. StringAdd.
thread-local-storage section.
copy "javatypes.cpy".
01 lsNewPtr pointer.
01 lsSize jint. *> type defined in javatypes.cpy
01 i jint.
01 lsStatus jint.
01 lsBigBuffer pic x(1024).
linkage section.
01 lnkJString mf-jstring.
01 lnkJStringBuffer mf-jstring.
01 lnkString pic x(256).
01 lnkStringbuffer pic x(256).

procedure division using lnkJString lnkJStringBuffer.

           set address of lnkStringBuffer to
                              ptr2string of lnkJStringBuffer.
           set address of lnkString to ptr2string of lnkJString
      *>Check that lnkJStringBuffer is a Java StringBuffer
           if capacity of lnkJStringBuffer > 0
             add len of lnkJString to len of lnkJStringBuffer
                    giving lsSize
      *>Check we don't overflow concatenation buffer
             if lsSize
               move len of lnkJString to i
               move lnkString(1:i) to lsBigBuffer
               add 1 to i
               move lnkStringBuffer to lsBigBuffer(i:lsSize)
               set ptr2string of lnkJStringBuffer
                                 to address of lsBigBuffer
               move lsSize to len of lnkJStringBuffer
             end-if
           end-if.



import mfcobol.*;
public class StringsToCobol {
public static void main(String[] args) throws Exception {
   StringBuffer sb1 = new StringBuffer("ginger") ;
   Object theParams[] = {"fred" , sb1} ;
   RuntimeSystem.cobcall_int("stringadd", theParams) ;
   System.out.println(sb1) ;
}
}


This works correctly. This display “fredginger”.

We have to work with RM/COBOL file handler, so we use the next compiler directives in the Cobol Program :

SHOW-DIR
CALLFH(ACUFH)
RM "GIVING"
RM "ANSI"
PERFORM-TYPE"RM"


But then the programs don’t work. The Java program display “ginger”.

Where can be the problem?


Thank you

0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.
I just found the solution ...



     ...
     SPECIAL-NAMES.
           CALL-CONVENTION 0 IS VisualCobolCall       
           DECIMAL-POINT IS COMMA.
     ....
     PROCEDURE DIVISION VisualCobolCall
                       using lnkJString lnkJStringBuffer.
     ...

View solution in original post

0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.
I just found the solution ...



     ...
     SPECIAL-NAMES.
           CALL-CONVENTION 0 IS VisualCobolCall       
           DECIMAL-POINT IS COMMA.
     ....
     PROCEDURE DIVISION VisualCobolCall
                       using lnkJString lnkJStringBuffer.
     ...

View solution in original post

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.