I am trying to get a call from a COBOL program to a C++ function working properly on our IBM 0S/390 mainframe. I have the following code in my test COBOL program:
WORKING-STORAGE SECTION.
01 WS-WORK-FIELDS.
05 WS-TEST-1 PIC X(6).
05 WS-TEST-2 PIC X(6).
PROCEDURE DIVISION.
0000-MAINLINE.
STRING 'HELLO', '00'
DELIMITED BY SIZE INTO WS-TEST-1.
STRING 'WORLD', X'00'
DELIMITED BY SIZE INTO WS-TEST-2.
CALL 'TESTCPGM' USING BY CONTENT WS-TEST-1,
BY CONTENT WS-TEST-2.
DISPLAY 'BACK IN COBOL PROGRAM AFTER CALL '.
In my C++ program I have the following:
extern "C" {
void TESTCPGM( char* arg1, char* arg2);
}
#include <iostream.h>
void TESTCPGM( char* arg1, char* arg2 )
{
cout << "Am here in C++ !!" << endl;
cout << "*" << arg1 << " " << arg2 << "*" << endl;
cout << "Am done with C++" << endl;
}
When I run the COBOL program the output is the following:
*HELLO WORLD
when I am expecting *HELLO WORLD*
I never get the ending * after WORLD and it appears control is never passed back to the COBOL program.
If I pass both arguements to the C function but only use the first arguement, it runs fine and returns to the COBOL program, but whenever I try using the second arguement it doesn't work.
Any help with this would be appreciated. Thanks!
WORKING-STORAGE SECTION.
01 WS-WORK-FIELDS.
05 WS-TEST-1 PIC X(6).
05 WS-TEST-2 PIC X(6).
PROCEDURE DIVISION.
0000-MAINLINE.
STRING 'HELLO', '00'
DELIMITED BY SIZE INTO WS-TEST-1.
STRING 'WORLD', X'00'
DELIMITED BY SIZE INTO WS-TEST-2.
CALL 'TESTCPGM' USING BY CONTENT WS-TEST-1,
BY CONTENT WS-TEST-2.
DISPLAY 'BACK IN COBOL PROGRAM AFTER CALL '.
In my C++ program I have the following:
extern "C" {
void TESTCPGM( char* arg1, char* arg2);
}
#include <iostream.h>
void TESTCPGM( char* arg1, char* arg2 )
{
cout << "Am here in C++ !!" << endl;
cout << "*" << arg1 << " " << arg2 << "*" << endl;
cout << "Am done with C++" << endl;
}
When I run the COBOL program the output is the following:
*HELLO WORLD
when I am expecting *HELLO WORLD*
I never get the ending * after WORLD and it appears control is never passed back to the COBOL program.
If I pass both arguements to the C function but only use the first arguement, it runs fine and returns to the COBOL program, but whenever I try using the second arguement it doesn't work.
Any help with this would be appreciated. Thanks!