Quantcast
Channel: Visual COBOL Knowledge Base
Viewing all 214 articles
Browse latest View live

DELETE FILE ‘filename’ statement not removing both .dat and .idx files in native code

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 3/8/2013 6:52:47 AM

Problem:

A problem was encountered opening indexed files after an application was upgraded from Net Express to Visual COBOL running native code.

The SELECT statement was as follows: SELECT ‘filename’ (i.e. no extension specified).

Also, INDEXNAMETYPE=2 was set in the file handler configuration file. As a result when opening a new version of a file in Net Express the file handler created an indexed file with the naming convention filename.dat and filename.idx.

When testing Visual COBOL it seemed the Visual COBOL Native Runtime was ignoring this directive and was creating just the one file - filename.dat.

Some files were temporary transaction files and these were to be removed using the DELETE FILE statement each time the program was run.

But in Visual COBOL the .idx file was not deleted when the DELETE FILE statement was executed, and this caused a problem when opening the file later on.

 

Resolution:

The reason this happened was because in Net Express the default IDXFORMAT is “3” – which means 2 physical files (eg filename.dat & filename.idx) are created.

But with Visual COBOL the default IDXFORMAT is “8” – meaning both data and index are concatenated into one physical file – filename.dat

So the file was being generated correctly, it’s just that it was using a different IDXFORMAT.

All files were copied over from the Net Express environment, including the redundant transaction .dat and .idx files. Therefore, when either the CALL “CBL_DELETE_FILE” or the DELETE FILE <identifier> statement was executed it would only delete filename.dat and wouldn’t delete the .idx. This was simply because the file handler determined it was an IDXFORMAT”8” file and wouldn’t have an associated .idx to delete.

So there are a couple of options -:

1)      In Visual COBOL set IDXFORMAT=4 (much better than 3) in your extfh.cfg file (or directly in the program using the $SET statement) to override the default IDXFORMAT”8”.

This could be set as the ‘DEFAULT’ for all files or the transaction files only. When the file is  recreated it will create both a .dat & .idx – and subsequently delete both as well. The only downside to this is if the size of the transaction file gets greater than 4gb, which is why IDXFORMAT”8” files were developed. But as these are transaction files it’s unlikely they would, but that has to be a consideration.         

 2)      Or - simply delete any existing .idx file of the same name as the transaction file(s). That way, the transaction file will always be generated as IDXFORMAT”8”. Once the .idx has been deleted it won’t be re-regenerated and so won’t be a problem to the file handler. This is probably the best option.

So it really comes down to the fact that Visual COBOL generates IDXFORMAT”8” files when creating a new version of the file instead of IDXFORMAT”3” as in Net Express. This makes it appear as if IDXNAMETYPE is being ignored, but it isn’t.

 

 

Tags: DELETE_FILE IDXNAMETYPE IDXFORMAT

Printing to a USB Printer and columns are not aligned

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 3/8/2013 6:54:29 AM

Problem:

Customer has a native Visual COBOL application that is using an OPEN to a printer which is a USB printer under Windows.

They are setting the configuration option set printer_redirection=TRUE in a cobconfig.cfg file and are setting the environment variable COBCONFIG_ to point to this file.

The printer redirection is working correctly and the output from the WRITE statements is successfully be printed. The problem is that the report is supposed to be aligned in columns and these columns are not be aligned properly so they do not match up from row to row.

It prints correctly when printing to a printer attached to the LPT1 port.

Resolution:

Notes: Printer alignment issues on a USB printer most likely have nothing to do with COBOL and have everything to do with what is set as the default font for the printer.

If the default font is a proportional font then all characters are not the same width so depending on what characters you are printiing the columns will not line up correctly.

Example if you are printing the following: WWWWW It will be much wider than if you are printing 1111

The resolution to this is to change the default font to one that is a fixed font so that all charcaters are printed with the same width.

Courier New can be used for this.

Since you are using the printer redirection and do direct write statements to the printer you can set the font for the printer at the time it is opened by using pc_printer_redirection_proc in conjunction with pc_printer_set_font.

The following is a sample of how this can be done.

       id division.
       program-id.    printformat.       
       environment division.
       input-output section.
       file-control.

               select print-file assign to PRINTER
                                 organization is line sequential
                                 file status is file-status.

       data division.
       file section.
       fd print-file.
       01 print-record.
          05                 pic x(5).
          05 column1         pic x(5).
          05                 pic x(5).          
          05 column2         pic x(5).
          05                 pic x(5).       
          05 column3         pic x(5).
       working-storage section.
       01 file-status        pic x(2)  value spaces.
       01 flags              pic x(4) comp-5 value zeroes.
       01 user-func          procedure-pointer.
       01 font-family-name.
            05 font-name-len   pic x(2) comp-5 value 11.
            05 font-name       pic x(11) value "Courier New".
       01 font-size          pic x(4) comp-5 value 12.
       01 font-style         pic x(4) comp-5 value 0.       
       01 status-code        pic x(4) comp-5 value zeroes.
       local-storage section.       
       linkage section.
       01 printer-handle     pic x(4) comp-5.
       procedure division.

          set user-func to entry "user-func"

          call "PC_PRINTER_REDIRECTION_PROC"
              using by value flags
                             user-func
           end-call.

           open output print-file
           display "open = " file-status
           move spaces to print-record
           move all "1" to column1 column2 column3
           write print-record            
           display "write = " file-status
           move all "W" to column1 column2 column3           
           write print-record
           display "write = " file-status
           move all "D" to column1 column2 column3
           write print-record           
           display "write = " file-status
           close print-file
           stop run.

       entry "user-func" using by value printer-handle.

           call "PC_PRINTER_SET_FONT"
              using printer-handle                  
                       font-family-name
                       by value font-size
                       by value  font-style
              returning status-code
           end-call

           exit program returning status-code.

 

Program using ACCEPT/DISPLAY drops a character displayed on line 25 position 79

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 3/8/2013 6:58:23 AM

Problem:

Customer is using ACCEPT/DISPLAY statements in a Visual COBOL native program to perform screen I-O.

The screen that they have defined is 80 characters by 30 lines.
They are displaying data on line 25 and the character that should be displayed in column 79 is being dropped.
 
Why and how can this be fixed?

Resolution:

There are several positions on the screen to which error messages and indicators are displayed by the ACCEPT/DISPLAY screen handling module and by default these are set on row 25.

You can configure these to display on a different line or column by using the ADISCF utility.

Open up a Visual COBOL command prompt and do a cd to your project folder and enter the command:

adiscf

to start the accept/display configuration utility.
Press F2-Alter
Press F7 positions

Change the locations to the desired ones and then press Enter to return to menu.
Press Esc key to return to main menu and then press F4 to save.
Press F3 to overwrite current configuration then press Enter to accept the default configuration.
Press Esc once more to exit.

This will create or update a file called ADISCTRL in your C:\Program Files (x86)\Micro Focus\Visual COBOL\etc folder which will contain the modified options.

You will need to include this file in your application folder when deploying the application so that the changes will take effect in production also.

Program using OpenESQL gets compile errors when moving from Net Express to Visual COBOL

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 3/8/2013 7:31:05 AM

Problem:

Customer has a program that uses embedded SQL statements using the OpenESQL precompiler.
This program compiles without errors under Net Express but when compiling under Visual COBOL as a native program it gets the following error:

COBCH0801: Statement Incompatible with BEHAVIOR setting
on the following statement:
      EXEC SQL SET CONCURRENCY READ-ONLY END-EXEC

Why is this occurring?

Resolution:

This error message occurs because the default settings of the SQL BEHAVIOR directive have changed in Visual COBOL.

By default it is now set to BEHAVIOR=MAINFRAME if it is not specified.
You can change this behavior back to the Net Express defaults as follows:

Close Visual Studio and then in the C:\Program Files\Micro Focus\Visual COBOL\bin folder run the program esqlconfigw.exe.

Click on the third option down which is for no change in behavior and then click the save button.

Open up Visual Studio and try compiling again.
The error message should now be gone.

Setting link option /STACK in Visual COBOL for Visual Studio

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 3/8/2013 7:32:17 AM

Problem:

Customer is using Visual COBOL for Visual Studio and needs to increase the stack size that is linked into a native .EXE.

Is there a way to set this option other than by setting the LINK environment variable with the "/STACK:8000000" value?

Resolution:

Setting the LINK environment variable should also work under Visual COBOL for linking native .exes but you can additionally set the link directives in the project properties.

Open the properties and look at the COBOL Link tab. Near the bottom there is a field called Additional Directives.

You can pass directives to the linker by specifying the -wl option along with the directive.

-wl"/STACK:8000000"

For managed code we have a directive called -ILSTACKSIZE that allows you to do this.

Stack Overflow Error in native Cobol

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 3/14/2013 9:58:38 AM

Problem:

During runtime you get Stack Overflow errors when Cobol DLLs are called. As the levels of inheritance grow up to a specific level everything runs fine, but when you move a step down in the inheritance level you get a stack overflow error.

Solution:

The usual cause of this kind of exception is that there is not enough stack space, and this is one of those cases. 

The default stack size for a Windows executable is only 1Mb. To increase the stack size there are a couple of options here ...

1) Build the top-level code to an exe, and include a larger stack size

e.g. set link=/stack:2000000
cbllink cobclient.cbl

2) Use editbin (in a VS command prompt) on the MF run trigger, to increase its stack size

e.g. editbin /stack:2000000 run.exe

The issue will not appear with INT code since in that case local storage is dynamically allocated from the Windows heap rather than from the system stack.

Tags: Stack Overflow

Exception occurs when native Dialog System program calls managed WinForm

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 3/19/2013 9:09:02 AM

PROBLEM:

Customer has a native Dialog System application that displays a window on which an ActiveX control resides.

This native application displays this Dialog System window and then calls a managed code .Net WinForm application that displays a Windows Form which also has an ActiveX control on it.

When the program does this it gets the following exception:

    Application Exception  A device attached to the system is not functioning.

What is causing this to occur?

RESOLUTION:

Try setting the following environment variable in your computers environment

MFOLECL_NO_THREAD_INIT=ON

This is a problem that is caused by the Micro Focus native OLE support calling CoInitialize on a thread that it did not own, mainly the managed code thread.

If this environment variable is set the OLE support will not try to initialize a thread that it does not own.

Interpreting the status-code returned by CBL_COPY_FILE

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 3/26/2013 8:36:59 AM

PROBLEM

Using CBL_COPY_FILE returning status-code. 0 = successful non-0 = not successful

Is there a way to interpret the value of status-code to determine the reason for the failure similar to the file status and extended file status?

RESOLUTION

Actually, the value returned for status-code if used or in the RETURN-CODE special register is a file status code.

You can check the success of the call by examining RETURN-CODE.

Interpreting the return code as a file status code If any of the routines

CBL_CHECK_FILE_EXIST
CBL_COPY_FILE
CBL_CREATE_FILE
CBL_DELETE_FILE
CBL_OPEN_FILE
CBL_READ_FILE
CBL_RENAME_FILE
CBL_WRITE_FILE
CBL_CHANGE_DIR
CBL_CREATE_DIR
CBL_DELETE_DIR
CBL_READ_DIR

fails, the RETURN-CODE register contains a file status value indicating the failure.
This file status is always the standard ANSI'74 file status value.
If no ANSI'74 file status is defined for the error, an extended file status is returned (9/nnn where nnn is the run-time system error number).

You should, therefore, use RETURN-CODE and not a RETURNING clause.
If RETURN-CODE is non-zero after calling one of these routines, you must process it as a file status, for example:

 01 file-status      pic xx comp-x.
 01 redefines file-status.
     03 fs-byte-1  pic x.     
     03 fs-byte-2  cblt-x1-compx    . . .     
  
      call "CBL_xxx_xxx" using parameters
     if return-code not = 0
        move return-code to file-status
           . . . At this point fs-byte-1 contains "9" and fs-byte-2 contains the run-time system error number.


.Net Class to Obtain Regional PC Settings

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 4/3/2013 5:58:12 AM

Problem

In .Net how can COBOL find out the regional settings that are currently in use for a class.

 

Solution

The .Net Framework provides the class System.Globalization.CultureInfo that allows you to obtain regional characteristics.

Some sample code that uses this class is:-

 

      $set ilusing"System.Globalization" 
       program-id. Program1 as "CurrentCulture.Program1".

       data division.
       working-storage section.
       01  Cult        type CultureInfo.

       procedure division.
       
      ***** Obtan the Culture Information from the Current Thread 
           set Cult to type CultureInfo::CurrentCulture
           
       
      ***** Display some Values from the Culture Class 
           display "Current Locale= " Cult::EnglishName
           display "Current Date and Time Format = " Cult::DateTimeFormat::FullDateTimePattern
           display "Currency Symbol = " Cult::NumberFormat::CurrencySymbol
           display "Decimal Indicator = " Cult::NumberFormat::NumberDecimalSeparator

           goback.
           
       end program Program1.

 

 

 

 

Tags: COBOL .Net regional date format

ASP.NET application gets RTS error 173 - "Program not Found" when attempting to call an unmanaged .dll in same folder

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 4/3/2013 6:02:04 AM

Problem:

Customer has an ASP.NET Web application written in Visual COBOL which does a call to an unmanaged COBOL .dll.

The .dll is located in the web applications bin folder along with the calling program yet when a call is made a 173 error "Program Not Found" occurs.

How can this be resolved?

Resolution:

When an ASP.NET application is run, the sources for the web pages are moved to a temporary location, compiled and run from that temporary location so the default folder is no longer the bin folder..

The unmanaged .dlls are not moved to this temprary location so the web application needs to know where to look for these files.

It is therefore necessary to place the location of these unmanaged .dlls within the PATH environment variable.
This can be done directly within the web applications web.config file by right-clicking on web.config in Solution Explorer and selecting the Edit option.

You can then add the PATH environment variable and set it to the value of the folder in which your unmanaged .dlls reside.

 

ASP.NET application gets RTS error 174 - "Imported File not found" when calling unmanaged COBOL .dll

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 4/3/2013 6:02:26 AM

Problem

Customer has created an ASP.NET Web Application in Visual COBOL which needs to do a P/Invoke call to an unmanaged COBOL program by using the following code:

01 pp   procedure-pointer.
01 next-prog   pic x(20)   value "myentry".

    set pp to entry "DECHANGE"
    call next-prog

This works fine if the program is debugged using the Visual Studio interner Development Web Server but when the Web Server is changed to use Local IIS instead the following error message is displayed when executing the set pp to entry ... statement:

Why?

Resoulution:

This error occurs because when running under IIS you must link the unmanaged COBOL .dll as dynamic instead of Shared on the COBOL Link option tab of the Project Properties page.

This is because the search mechanism for the COBOL run-time system cblrtsm.dll is different when run under IIS. The error occurs because the run-time system cannot be found.

When linking the program as Dynamic it will use the Visual COBOL registry settings in order to locate the COBOL run-time system instead of requiring it to be within the system PATH.


 

Eclipse heap size 1

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 4/3/2013 6:05:53 AM

Problem

Error “COBCH1501S Insufficient memory”

Need to adjust Xms and Xmx settings in eclipse.ini

Solution

If you are doing large projects it is a good idea to increase the java HEAP size for your eclipse installation.

There is a file in the eclipse directory eclipse.ini that needs changing

To find this file Look at properties of visual COBOL start menu

Select properties

And highlight the start in directory

This should contain something like this.   

C:\Users\Public\Micro Focus\vc21upd1pkg70439\eclipse

Open window explorer and navigate to that directory.

In this directory edit the file using a editor I use notepad++

change –Xms and –Xmx settings

There are many thoughts on values to use here maybe 512 fo Xms minimum size of memory

And 1024m for Xmx maximum size of memory or 1g

To look like this

Now close down eclipse if open and start eclipse again so we can check the settings have been applied.

Go to help>about eclipse

Then installation Details

Select configuration

And check the Xms and Xmx settings

And hopefully the insufficient memory error will go away.

If the size is too big for your machine and its current workload you will get a error like this.

And some details also

You need to adjust the settings down in the eclipse.ini kill some process’s on your machine or get more memory.

Note the eclipse version is 32 bit so from internet 3g or lower might be the maximum.

Tags: Xms Xmx insuffcient memory eclipse visual COBOL COBCH1501S

UNIX Visual COBOL for Eclipse won’t start

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 4/3/2013 6:08:36 AM

Problem

UNIX Visual COBOL for Eclipse won’t start

 

Resolution

After investigation see below, for Oracle Linux 6.2.

Need to instal these packages using yum.

 

yum install gtk2-2.18.9-6.el6.i686

yum install PackageKit-gtk-module-0.5.8-19.0.1.el6.i686

yum install libcanberra-gtk2-0.22-1.el6.i686

 

Then eclipse will start okay.

[support@nwb-ora62sup bin]$ pwd

/home/products/vceclipse21/bin

[support@nwb-ora62sup bin]$ . ./cobsetenv

COBDIR set to /home/products/vceclipse21

[support@nwb-ora62sup bin]$ echo $JAVA_HOME

/usr/java/jdk1.7.0_13

[support@nwb-ora62sup bin]$ java -XshowSettings 2>&1 | grep "sun.arch.data.model"

    sun.arch.data.model = 32

Needs to be 32 bit

[support@nwb-ora62sup bin]$ eclipse

Starting Eclipse at Display localhost:10.0

   Please Wait...


Investigation


Just failed to start no error at all using normal user

Try as root user you should get some errors on the console.

See this article

http://www.eclipse.org/forums/index.php/t/262868/

Basically these three libraries missing


libgtk-x11-2.0.so.0, libpk-gtk-module.so, libcanberra-gtk-module.so

Do

yum provides "*/libpk-gtk-module.so"

you need the i686 package gtk2-2.18.9-6.el6.i686

yum install gtk2-2.18.9-6.el6.i686

To get more information you can run eclipse launcher from command line.

java -jar /home/products/vceclipse21/eclipse/eclipse/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar


This will give you some error logs in your home directory as well as screen output.

 

Visual COBOL and JAVA Integration

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 4/17/2013 5:19:03 AM

Problem

Unable to execute JAVA class or a COBOL JVM class on a UNIX machine.

 Resolution

This simple example demonstrates how well Visual COBOL and JAVA can integrate.

It covers the core subjects of CLASSPATH, PACKAGES, BUILDING JAR files and executing programs.

This will show you how to do this by using three programs on a test stub that invokes a JAVA program and a COBOL JVM program. This will also use some jar files created on a windows machine as well to show that the jar files are portable which is as they should be.

For all programs and scripts needed for this example, click the link and save as < jar-002.tar >

Setup build and run example

mkdir test
cd test
# mv jar into test or point to were you downloaded the file.
tar -xvf jar-002.tar
cd jar
ls
setup.sh  unixbld  unixjar  winjar

You will need to change setup.sh to point to your java version and your Visual COBOL version.

setup.sh

#
# set up java version
#
#JAVA_HOME=/usr/java/jdk1.7.0_03
#export JAVA_HOME
#PATH=$JAVA_HOME/bin:$PATH:
#export PATH
#java -version
#
. /home/products/vceclipse21/bin/cobsetenv
#
# make sure doing stuff in jvm 32 or 64 bit mode.
COBMODE=32
export COBMODE
#
# set original_classpath use all .jar file in current directory
#
ORIGINAL_CLASSPATH=$CLASSPATH
export ORIGINAL_CLASSPATH
echo $ORIGINAL_CLASSPATH
#
# set up env variable for this directory to use in classpath in runit scripts
#
ORIGINAL_ROOTDIR=$PWD
export ORIGINAL_ROOTDIR
echo $ORIGINAL_ROOTDIR
#

Execute the setup.sh script

. ./setup.sh
COBDIR set to /home/products/vceclipse21
/home/products/vceclipse21/lib/mfcobol.jar:/home/products/vceclipse21/lib/mfcobolrts.jar:/home/products/vceclipse21/lib/mfsqljvm.jar:
/home/tonyt/test/jar

The programs build and execution scripts are in unixbld

cd unixbld
ls *.java *.cbl *.sh
buildit.sh  JList.java  Program1.cbl  runitjava.sh  runit.sh  VCList.cbl

Here is how the windows jar files used in this test where built. This was done in a eclipse work space the directories follow the package name

winjar/makejarfiles.bat

cd C:\Users\tonyt\rhtony01shr\pcworkspace20\jclass\bin
jar -cvfe C:\Users\tonyt\bin\JList.jar com.microfocus.jexamples.list.JList com\microfocus\jexamples\list\JList.class
cd C:\Users\tonyt\rhtony01shr\pcworkspace20\vcclass\bin
jar -cvfe C:\Users\tonyt\bin\VCList.jar com.microfocus.vcexamples.list.VCList com\microfocus\vcexamples\list\VCList.class
cd C:\Users\tonyt\bin
copy C:\Users\tonyt\rhtony01shr\pcworkspace20\testem\bin\Program1.class Program1.class
copy C:\Users\tonyt\rhtony01shr\pcworkspace20\testem\src\Program1.cbl Program1.cbl
copy C:\Users\tonyt\rhtony01shr\pcworkspace20\jclass\src\com\microfocus\jexamples\list\JList.java JList.java
copy C:\Users\tonyt\rhtony01shr\pcworkspace20\vcclass\src\com\microfocus\vcexamples\list\VCList.cbl VCList.cbl

buildit.sh

# build simple program to execute class files in .jar's
# test standalone
# test using window jar files
#
# set back to mfcobol class path see ../setup.sh
CLASSPATH=$ORIGINAL_CLASSPATH
export CLASSPATH
echo $CLASSPATH
#
javac JList.java -d .
cob -j -C list="VCList.lis" VCList.cbl
cob -j -C list="Program1.lis" Program1.cbl
#
# create the unix jar files
#
jar -cvfe ../unixjar/VCList.jar com.microfocus.vcexamples.list.VCList com/microfocus/vcexamples/list/VCList.class
jar -cvfe ../unixjar/JList.jar com.microfocus.jexamples.list.JList com/microfocus/jexamples/list/JList.class

Execute the buildit.sh script

. ./buildit.sh
/home/products/vceclipse21/lib/mfcobol.jar:/home/products/vceclipse21/lib/mfcobolrts.jar:/home/products/vceclipse21/lib/mfsqljvm.jar:
added manifest
adding: com/microfocus/vcexamples/list/VCList.class(in = 2869) (out= 1472)(deflated 48%)
added manifest
adding: com/microfocus/jexamples/list/JList.class(in = 1988) (out= 1034)(deflated 47%)

Notes on what buildit.sh has done. You will see two .jar files have been created. Most importanly a directory called com has been created. This is the start of the underlying package directory structure, this is where the class files are put by java compilation and Visual COBOL compilation.

ls -R com ../unixjar/*.jar
../unixjar/JList.jar  ../unixjar/VCList.jar

com:
microfocus

com/microfocus:
cobol  jexamples  vcexamples

com/microfocus/cobol:
references

com/microfocus/cobol/references:
java

com/microfocus/cobol/references/java:
util

com/microfocus/cobol/references/java/util:
ListRef.class

com/microfocus/jexamples:
list

com/microfocus/jexamples/list:
JList.class

com/microfocus/vcexamples:
list

com/microfocus/vcexamples/list:
VCList.class

We have two scripts for running this test one uses java to run the programs and the other use cobjrun to run the programs, both work for this test. This shows you, For purejvm cobol apps, there are only a few .jars needed from the cobol server product. Pure jvm apps do not check licensing. For .jars needed see the CLASSPATH in this example.

runit.sh

# 
# run the simple VC COBOL program class file
# releativly accessining the invoked classes using the package directory structure.
# com/microfocus/jexamples/list
# com/microfocus/vcexample/list
#
# set back to mfcobol class path see ../setup.sh
CLASSPATH=$ORIGINAL_CLASSPATH
export CLASSPATH
echo $CLASSPATH
#
echo "test 1 using no jar files"
cobjrun Program1
#
# Run using the window jar files
#
CLASSPATH=$ORIGINAL_ROOTDIR/winjar/VCList.jar:$ORIGINAL_ROOTDIR/winjar/JList.jar:$ORIGINAL_CLASSPATH
export CLASSPATH
echo $CLASSPATH
#
# just for test remove the com package diretory
#
echo "remove the built packages so we know must use jar files."
rm -r com
#
# now we know it has to pick up the jar files
#
echo "test 2 using the windows built jar files see winjar/makejarfiles.bat"
cobjrun Program1
#
# test accessing the main method
#
echo "test3 execute the main method of a java jar file"
cobjrun com/microfocus/jexamples/list/JList
#
echo "test4 execute the main method of a VC jar file"
cobjrun com/microfocus/vcexamples/list/VCList
#
# Just do three test again should fail
# if jars not on CLASSPATH
# set back to mfcobol class path see ../setup.sh
CLASSPATH=$ORIGINAL_CLASSPATH
export CLASSPATH
echo $CLASSPATH
#
echo "test 5 should fail know jar on classpath"
cobjrun Program1
#
# test accessing the main method
#
echo "test6 should fail know jar on classpath"
cobjrun com/microfocus/jexamples/list/JList
#
echo "test7 should fail know jar on classpath"
cobjrun com/microfocus/vcexamples/list/VCList
#
# Run using the unix jar files
#
CLASSPATH=$ORIGINAL_ROOTDIR/unixjar/VCList.jar:$ORIGINAL_ROOTDIR/unixjar/JList.jar:$ORIGINAL_CLASSPATH
export CLASSPATH
echo $CLASSPATH
#
echo "test 8 using the unix built jar files see buildit.sh"
cobjrun Program1
#
# test accessing the main method
#
echo "test9 execute the main method of a java jar file"
cobjrun com/microfocus/jexamples/list/JList
#
echo "test10 execute the main method of a VC jar file"
cobjrun com/microfocus/vcexamples/list/VCList
#

runitjava.sh

# 
# run the simple VC COBOL program class file
# releativly accessining the invoked classes using the package directory structure.
# com/microfocus/jexamples/list
# com/microfocus/vcexample/list
#
# set back to mfcobol class path see ../setup.sh
CLASSPATH=$ORIGINAL_CLASSPATH
export CLASSPATH
echo $CLASSPATH
#
echo "test 1 using no jar files"
java Program1
#
# Run using the window jar files
#
CLASSPATH=$ORIGINAL_ROOTDIR/winjar/VCList.jar:$ORIGINAL_ROOTDIR/winjar/JList.jar:$ORIGINAL_CLASSPATH
export CLASSPATH
echo $CLASSPATH
#
# just for test remove the com package diretory
#
echo "remove the built packages so we know must use jar files."
rm -r com
#
# now we know it has to pick up the jar files
#
echo "test 2 using the windows built jar files see winjar/makejarfiles.bat"
java Program1
#
# test accessing the main method
#
echo "test3 execute the main method of a java jar file"
java com/microfocus/jexamples/list/JList
#
echo "test4 execute the main method of a VC jar file"
java com/microfocus/vcexamples/list/VCList
#
# Just do three test again should fail
# if jars not on CLASSPATH
# set back to mfcobol class path see ../setup.sh
CLASSPATH=$ORIGINAL_CLASSPATH
export CLASSPATH
echo $CLASSPATH
#
echo "test 5 should fail know jar on classpath"
java Program1
#
# test accessing the main method
#
echo "test6 should fail know jar on classpath"
java com/microfocus/jexamples/list/JList
#
echo "test7 should fail know jar on classpath"
java com/microfocus/vcexamples/list/VCList
#
# Run using the unix jar files
#
CLASSPATH=$ORIGINAL_ROOTDIR/unixjar/VCList.jar:$ORIGINAL_ROOTDIR/unixjar/JList.jar:$ORIGINAL_CLASSPATH
export CLASSPATH
echo $CLASSPATH
#
echo "test 8 using the unix built jar files see buildit.sh"
java Program1
#
# test accessing the main method
#
echo "test9 execute the main method of a java jar file"
java com/microfocus/jexamples/list/JList
#
echo "test10 execute the main method of a VC jar file"
java com/microfocus/vcexamples/list/VCList
#

Execute the runitit.sh script

. ./runit.sh
/home/products/vceclipse21/lib/mfcobol.jar:/home/products/vceclipse21/lib/mfcobolrts.jar:/home/products/vceclipse21/lib/mfsqljvm.jar:
test 1 using no jar files
Program1 start :::
Java the JList at start :
using List::tostring : [one, Three, two, four]
using JList::tostring : 
<one>
<Three>
<two>
<four>

Java the JList after sort :
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

Visual Cobol the VCList at start :
using List::tostring : [one, Three, two, four]
using VCList::tostring : 
<one>
<Three>
<two>
<four>

Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

back in Program1 lets play with objects
Create instance and access its public data use set.
Access a static method to sort 
Visual Cobol the JList after sort : 
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

Create instance and access its public data use declare and create.
Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

/home/tonyt/test/jar/winjar/VCList.jar:/home/tonyt/test/jar/winjar/JList.jar:/home/products/vceclipse21/lib/mfcobol.jar:/home/products/vceclipse21/lib/mfcobolrts.jar:/home/products/vceclipse21/lib/mfsqljvm.jar:
remove the built packages so we know must use jar files.
test 2 using the windows built jar files see winjar/makejarfiles.bat
Program1 start :::
Java the JList at start :
using List::tostring : [one, Three, two, four]
using JList::tostring : 
<one>
<Three>
<two>
<four>

Java the JList after sort :
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

Visual Cobol the VCList at start :
using List::tostring : [one, Three, two, four]
using VCList::tostring : 
<one>
<Three>
<two>
<four>

Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

back in Program1 lets play with objects
Create instance and access its public data use set.
Access a static method to sort 
Visual Cobol the JList after sort : 
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

Create instance and access its public data use declare and create.
Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

test3 execute the main method of a java jar file
Java the JList at start :
using List::tostring : [one, Three, two, four]
using JList::tostring : 
<one>
<Three>
<two>
<four>

Java the JList after sort :
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

test4 execute the main method of a VC jar file
Visual Cobol the VCList at start :
using List::tostring : [one, Three, two, four]
using VCList::tostring : 
<one>
<Three>
<two>
<four>

Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

/home/products/vceclipse21/lib/mfcobol.jar:/home/products/vceclipse21/lib/mfcobolrts.jar:/home/products/vceclipse21/lib/mfsqljvm.jar:
test 5 should fail know jar on classpath
Program1 start :::
/home/products/vceclipse21/bin/cobjrun32: Program1.main ended due to an exception
Exception in thread "main" java.lang.NoClassDefFoundError: com/microfocus/jexamples/list/JList
	at Program1.Program1(Program1.cbl:19)
	at Program1.main(Program1.cbl)
Caused by: java.lang.ClassNotFoundException: com.microfocus.jexamples.list.JList
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
	... 2 more
test6 should fail know jar on classpath
/home/products/vceclipse21/bin/cobjrun32: Could not find com/microfocus/jexamples/list/JList
Exception in thread "main" java.lang.NoClassDefFoundError: com/microfocus/jexamples/list/JList
Caused by: java.lang.ClassNotFoundException: com.microfocus.jexamples.list.JList
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
test7 should fail know jar on classpath
/home/products/vceclipse21/bin/cobjrun32: Could not find com/microfocus/vcexamples/list/VCList
Exception in thread "main" java.lang.NoClassDefFoundError: com/microfocus/vcexamples/list/VCList
Caused by: java.lang.ClassNotFoundException: com.microfocus.vcexamples.list.VCList
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
/home/tonyt/test/jar/unixjar/VCList.jar:/home/tonyt/test/jar/unixjar/JList.jar:/home/products/vceclipse21/lib/mfcobol.jar:/home/products/vceclipse21/lib/mfcobolrts.jar:/home/products/vceclipse21/lib/mfsqljvm.jar:
test 8 using the unix built jar files see buildit.sh
Program1 start :::
Java the JList at start :
using List::tostring : [one, Three, two, four]
using JList::tostring : 
<one>
<Three>
<two>
<four>

Java the JList after sort :
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

Visual Cobol the VCList at start :
using List::tostring : [one, Three, two, four]
using VCList::tostring : 
<one>
<Three>
<two>
<four>

Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

back in Program1 lets play with objects
Create instance and access its public data use set.
Access a static method to sort 
Visual Cobol the JList after sort : 
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

Create instance and access its public data use declare and create.
Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

test9 execute the main method of a java jar file
Java the JList at start :
using List::tostring : [one, Three, two, four]
using JList::tostring : 
<one>
<Three>
<two>
<four>

Java the JList after sort :
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

test10 execute the main method of a VC jar file
Visual Cobol the VCList at start :
using List::tostring : [one, Three, two, four]
using VCList::tostring : 
<one>
<Three>
<two>
<four>

Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

This test is destructive so execute the build script again

Execute the buildit.sh script

. ./buildit.sh
/home/products/vceclipse21/lib/mfcobol.jar:/home/products/vceclipse21/lib/mfcobolrts.jar:/home/products/vceclipse21/lib/mfsqljvm.jar:
added manifest
adding: com/microfocus/vcexamples/list/VCList.class(in = 2869) (out= 1472)(deflated 48%)
added manifest
adding: com/microfocus/jexamples/list/JList.class(in = 1988) (out= 1034)(deflated 47%)

Execute the runititjava.sh script

. ./runitjava.sh
/home/products/vceclipse21/lib/mfcobol.jar:/home/products/vceclipse21/lib/mfcobolrts.jar:/home/products/vceclipse21/lib/mfsqljvm.jar:
test 1 using no jar files
Program1 start :::
Java the JList at start :
using List::tostring : [one, Three, two, four]
using JList::tostring : 
<one>
<Three>
<two>
<four>

Java the JList after sort :
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

Visual Cobol the VCList at start :
using List::tostring : [one, Three, two, four]
using VCList::tostring : 
<one>
<Three>
<two>
<four>

Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

back in Program1 lets play with objects
Create instance and access its public data use set.
Access a static method to sort 
Visual Cobol the JList after sort : 
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

Create instance and access its public data use declare and create.
Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

/home/tonyt/test/jar/winjar/VCList.jar:/home/tonyt/test/jar/winjar/JList.jar:/home/products/vceclipse21/lib/mfcobol.jar:/home/products/vceclipse21/lib/mfcobolrts.jar:/home/products/vceclipse21/lib/mfsqljvm.jar:
remove the built packages so we know must use jar files.
test 2 using the windows built jar files see winjar/makejarfiles.bat
Program1 start :::
Java the JList at start :
using List::tostring : [one, Three, two, four]
using JList::tostring : 
<one>
<Three>
<two>
<four>

Java the JList after sort :
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

Visual Cobol the VCList at start :
using List::tostring : [one, Three, two, four]
using VCList::tostring : 
<one>
<Three>
<two>
<four>

Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

back in Program1 lets play with objects
Create instance and access its public data use set.
Access a static method to sort 
Visual Cobol the JList after sort : 
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

Create instance and access its public data use declare and create.
Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

test3 execute the main method of a java jar file
Java the JList at start :
using List::tostring : [one, Three, two, four]
using JList::tostring : 
<one>
<Three>
<two>
<four>

Java the JList after sort :
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

test4 execute the main method of a VC jar file
Visual Cobol the VCList at start :
using List::tostring : [one, Three, two, four]
using VCList::tostring : 
<one>
<Three>
<two>
<four>

Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

/home/products/vceclipse21/lib/mfcobol.jar:/home/products/vceclipse21/lib/mfcobolrts.jar:/home/products/vceclipse21/lib/mfsqljvm.jar:
test 5 should fail know jar on classpath
Program1 start :::
java.lang.NoClassDefFoundError: com/microfocus/jexamples/list/JList
	at Program1.Program1(Program1.cbl:19)
	at Program1.main(Program1.cbl)
Caused by: java.lang.ClassNotFoundException: com.microfocus.jexamples.list.JList
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
	... 2 more
test6 should fail know jar on classpath
Error: Could not find or load main class com.microfocus.jexamples.list.JList
test7 should fail know jar on classpath
Error: Could not find or load main class com.microfocus.vcexamples.list.VCList
/home/tonyt/test/jar/unixjar/VCList.jar:/home/tonyt/test/jar/unixjar/JList.jar:/home/products/vceclipse21/lib/mfcobol.jar:/home/products/vceclipse21/lib/mfcobolrts.jar:/home/products/vceclipse21/lib/mfsqljvm.jar:
test 8 using the unix built jar files see buildit.sh
Program1 start :::
Java the JList at start :
using List::tostring : [one, Three, two, four]
using JList::tostring : 
<one>
<Three>
<two>
<four>

Java the JList after sort :
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

Visual Cobol the VCList at start :
using List::tostring : [one, Three, two, four]
using VCList::tostring : 
<one>
<Three>
<two>
<four>

Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

back in Program1 lets play with objects
Create instance and access its public data use set.
Access a static method to sort 
Visual Cobol the JList after sort : 
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

Create instance and access its public data use declare and create.
Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

test9 execute the main method of a java jar file
Java the JList at start :
using List::tostring : [one, Three, two, four]
using JList::tostring : 
<one>
<Three>
<two>
<four>

Java the JList after sort :
using List::tostring : [four, one, Three, two]
using JList::tostring : 
<four>
<one>
<Three>
<two>

test10 execute the main method of a VC jar file
Visual Cobol the VCList at start :
using List::tostring : [one, Three, two, four]
using VCList::tostring : 
<one>
<Three>
<two>
<four>

Visual Cobol the VCList after sort :
using List::tostring : [four, one, Three, two]
using VCList::tostring : 
<four>
<one>
<Three>
<two>

Source code

Program1.cbl

      $set sourceformat(variable)      
      $set ooctrl(+p-f) intlevel"4"
      $set ilusing"java.util"
      $set ilusing"java.lang"
      $set ilusing"com.microfocus.vcexamples.list"
      $set ilusing"com.microfocus.jexamples.list"

       program-id. Program1 as "Program1".

       data division.
       working-storage section.
       
       01 tstJList type JList.
       01 result type void.
       01 args type String[].
       
       procedure division.
           Display "Program1 start :::"
           invoke type JList::main(args)
           invoke type VCList::main(args)
           
           display "back in Program1 lets play with objects"
           Display "Create instance and access its public data use set."
           set tstJList to new JList()
           display "Access a static method to sort "
           invoke type Collections::sort(tstJList::ls, String::CASE_INSENSITIVE_ORDER)
           display "Visual Cobol the JList after sort : "
           display "using List::tostring : ",  tstJList::ls
           display "using JList::tostring : "
           display tstJList

           Display "Create instance and access its public data use declare and create."
           declare tstVCList as type VCList
           create tstVCList
           invoke type Collections::sort(tstVCList::ls, String::CASE_INSENSITIVE_ORDER)  
           display "Visual Cobol the VCList after sort :"
           display "using List::tostring : ",  tstVCList::ls
           display "using VCList::tostring : "
           display tstVCList

           goback.

       end program Program1.

VCList.cbl

      $set sourceformat(variable)      
      $set ooctrl(+p-f) intlevel"4"
      $set ilusing"java.util"
      $set ilusing"java.lang"
      $set ilusing"com.microfocus.vcexamples.list"
        
       class-id com.microfocus.vcexamples.list.VCList public.
       
       01 ls type List public.
       
       *> no argument constructor
       method-id new public.
       procedure division.
           set ls to new ArrayList[String]
           invoke ls::add("one")
           invoke ls::add("Three")
           invoke ls::add("two")
           invoke ls::add("four")
       end method.

       *> constructor passing a List
       method-id new public.
       procedure division using by reference ls as type List.
           set self::ls to new ArrayList(ls);
       end method.
    	*> just exercise class for getting lists about
       method-id toString override.
       01 sb type StringBuffer.
       01 val string.
       
       procedure division returning lnkmessage as string.
            set sb to new StringBuffer
            perform varying val through ls
                invoke sb::append("<")
                invoke sb::append(val)
                invoke sb::append(">")
                invoke sb::append(x'0d0a') *> dont handle \n
            end-perform   
            set lnkmessage to sb::toString()
            
       end method.
		
       
      *>
      *> main entry point
      *>
       method-id main public static.
       local-storage section.
       linkage section.
       01 args type String occurs any.
       
       procedure division using by value args.
           *> Create the VCList
           *> use the declare and create syntax
           declare tstVCList as type VCList
           create tstVCList
           
           display "Visual Cobol the VCList at start :"
           display "using List::tostring : ",  tstVCList::ls
           display "using VCList::tostring : "
           display tstVCList
           *> Fire of a core java static method to sort 
           invoke type Collections::sort(tstVCList::ls, String::CASE_INSENSITIVE_ORDER)  
           display "Visual Cobol the VCList after sort :"
           display "using List::tostring : ",  tstVCList::ls
           display "using VCList::tostring : "
           display tstVCList
           

       end method.
       end class.

JList.java

package com.microfocus.jexamples.list;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;

public class JList {
	// just exercise class for getting lists about
	
	public List<String> ls;
    
	public JList() {
		// nothing given so lets create one
		ls = new ArrayList<String>();
		
		ls.add("one");
		ls.add("Three");
		ls.add("two");
		ls.add("four");

	}
	
	public JList(List<String> ls) {
		this.ls = new ArrayList<String>(ls);
	}

	// just exercise class for getting lists about
	public String toString() {
		
		StringBuffer sb = new StringBuffer();
		Iterator<String> it = ls.iterator();

		while (it.hasNext()) {
			sb.append("<" + it.next() + ">\n");
		}
		return sb.toString();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// create the JList
		JList tstJList = new JList();
		System.out.println("Java the JList at start :");
		System.out.println("using List::tostring : " + tstJList.ls);
		System.out.println("using JList::tostring : \n" + tstJList);
		// Fire of a core java static method to sort
		Collections.sort(tstJList.ls, String.CASE_INSENSITIVE_ORDER);
		System.out.println("Java the JList after sort :");
		System.out.println("using List::tostring : " + tstJList.ls);
		System.out.println("using JList::tostring : \n" + tstJList);
		        		
	}

}

Main points

The main point is to understand packaging. This demo shows you the syntax required to achieve this and also how to build and deploy and execute your JVM code.

From this understanding you should be able to implement this example in Visual COBOL for eclipse using three projects 2 COBOL JVM projects for Program1 and VCList and JAVA project for JList.

Tags: JARFILE

Example Visual COBOL .NET program sending an e-mail with attachment using Microsoft Outlook

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 4/19/2013 7:47:58 AM

Problem

Does anyone have an example of sending an e-mail including an attachment using Microsoft Outlook by using a managed code .NET program?

Resolution:

Here is an example:

     $set ilusing"System.Net.Mail"
     $set ilusing"System.Net"     
     $set ilusing"Microsoft.Office.Interop.Outlook"
      program-id. Program1 as "testemail.Program1".
      data division.
      working-storage section.
      01 oApp type Microsoft.Office.Interop.Outlook.ApplicationClass.
      01 omsg type Microsoft.Office.Interop.Outlook.MailItem.
      01 oAttach type Microsoft.Office.Interop.Outlook.Attachment.
      01 oRecips type Microsoft.Office.Interop.Outlook.Recipients.
      01 oRecip type Microsoft.Office.Interop.Outlook.Recipient.
      01 sDisplayName string.
      01 iPosition binary-long.
      01 iAttachType binary-long.
      procedure division.
            try
       *> Create the Outlook application.
             set oApp to new type Microsoft.Office.Interop.Outlook.ApplicationClass
       *> Create a new mail item.
             set oMsg to oApp::CreateItem(type
                Microsoft.Office.Interop.Outlook.OlItemType::olMailItem)
                       as type Microsoft.Office.Interop.Outlook.MailItem
       *> Set HTMLBody.
       *> add the body of the email
             set oMsg::HTMLBody to "Hello, your message body will go here!!"
       *> Add an attachment.
             set sDisplayName to "MyAttachment"
             set iPosition to oMsg::Body::Length + 1
             set iAttachType to type Microsoft.Office.Interop.Outlook.OlAttachmentType::olByValue
                as binary-long
       *> now attach the file
             set oAttach to oMsg::Attachments::Add("C:\\temp\\testfile.txt", iAttachType, iPosition, sDisplayName)        *> Subject line
             set oMsg::Subject to "Your Subject will go here."
       *> Add a recipient.
             set oRecips to oMsg::Recipients
       *> Change the recipient in the next line if necessary
              set oRecip to oRecips::Add(chris.glazier@microfocus.com)
             invoke oRecip::Resolve
       *> Send.
             invoke oMsg::Send
       *> Clean up.
             set oRecip to null
             set oRecips to null
             set oMsg to null
             set oApp to null
          catch ex as type System.Exception
             display ex::Message
          end-try
          goback.
      end program Program1


Increasing performance of index file I-O using sharing modes

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 4/19/2013 7:48:15 AM

Problem

Customer is running a large batch process that performs a lot of file I-O on indexed files and they would like to know if there is an option available that would help to speed up the performance when reading these files.

Resolution:

They might want to look at using sharing modes for their file processing.
Sharing modes inform the file handler how others will be accessing the files while the current process is accessing the files.

The default is that the file handler assumes that files open for input or i-o will be sharable by all other processes. This means that the file handler has to be constanly checking to ensure that the file has not been updated by someone else since the last time it was read and this can be time consuming.This is true even on a standalone single-user system where the file is not being shared.

By setting a sharing mode to allow no other then this will give you exclusive access to the file and the file handler will know that the file will not be changed by another process so it can speed processing time quite a bit. Likewise if you set the sharing mode to allow read only, then the file can be shared by others but cannot be updated.

These sharing modes can be set either in the select statement:

    select test-file assign to...
                           sharing with all other/no other

or on the open statement:

    open input sharing with all other/no other/read only test-file

In a recent test the following timings were returned while reading 8 million records sequentially from an indexed file.

sharing with all other   = 8 mins 40 secs
sharing with read only = 4 mins 23 secs
sharing with no other   = 2 mins 02 secs

 

Increasing performance when sequentially reading an indexed file

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 4/19/2013 7:48:41 AM

Problem

A customer has noticed that on a rather large indexed file, the performance seems to suffer when reading sequential through the entire file.

Is there a way to increase the performance of indexed file I-O when doing sequential reads?

Resolution:

They might look into using the extfh.cfg option called NODESIZE.
This controls the size of the index nodes that are used for a file when it is created.

The larger the value, the more keys that can be stored into a single node and this can speed up sequential processing quite a bit.

In a recent test when reading sequentially through an indexed file containing 8 million records, the following timings were achieved by setting the NODESIZE and recreating the file:

NODESIZE     Timing
1024                3 mins 55 secs
4096                3 mins 03 secs
16384              1 mins 59 secs

 

 

Increasing performance when using alternate keys in an indexed file

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 4/19/2013 7:49:03 AM

Problem

Customer has an indexed file that has several alternate keys defined.
They noticed that the performance of the file I-O seems to get worse as they add more keys.

Is there anyway to improve this performance?

Resolution:

There is an extfh.cfg option called INDEXCOUNT that can help to improve performance when a large number of keys are defined for a file.

For example, in a test where a file was being created with 8 million records the following results were found:

2 alternate keys =   5 mins 48 secs
3 alternate keys =   6 mins 19 secs
4 alternate keys =   6 mins 29 secs
5 alternate keys = 30 mins 08 secs

So the access time gets a little slower with each additional key until the file handler reaches a point where the performance suffers tremendously.

The INDEXCOUNT option controls the number of index nodes that will be cached for the file.
The default value in Visual COBOL is 32 but you can get better results when using a large number of alternate keys if you set this to a higher value.

For example, by raising this up to a value of 42 the timings for the test above for 5 alternate keys was reduced to 7 mins and 32 secs.

The ideal value for INDEXCOUNT can be calculated using the formula:

INDEXCOUNT= (Max Tree Depth * Number of keys) + Number of keys
The Max Tree Depth value can be found by running the rebuild /f command against the desired file.

 

OpenESQL database driver support

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 4/19/2013 7:49:30 AM

Problem

Customer is moving from Net Express 5.1 native code to Visual COBOL 2.1 managed .NET code and they need to know what database driver should they use in order to access their SQL Server database.

Resolution:

In Visual COBOL you can create three types of applications each as 32-bit or 64-bit.

1. Native code, which includes int/.gnt and native Windows .EXE/.DLL formats or native Unix/Linuz executables and .so files.

2. Managed code .NET on Windows, .EXE/.DLL assemblies which run under the .NET Framework Common Language Runtime system.

3. Managed code JVM on Windows or Unix/Linux, generates Java .class files that will run under the Java Virtual Machine platform.

The type of database driver that you use depends upon the type of executable you are running.

Native Code = ODBC Drivers
Managed .NET = ADO Providers
Managed JVM = JDBC Drivers

These are not interchangable so if you are moving from Native code under Net Express to managed .NET code under Visual COBOL then you must change from using an ODBC driver to using an ADO Provder for the same database vendor. ADO Providers are available for SQL Server, Oracle and DB2.

 

Problem with SQL(DATE=EXTERNAL) directive no longer recognized in Visual COBOL 2.1 Update 1

$
0
0
Current Revision posted to Visual COBOL Knowledge Base by Angela on 4/19/2013 7:49:47 AM

Problem

In Visual COBOL 2.1 Hotfix 2 a new OpenESQL directive called sql(date=external) was added to allow for the date format to use when accessing an Oracle database to be set using the environment variable NLS_DATE_FORMAT.

This was working fine in Hotfix 2 but after upgrading to Visual COBOL 2.1 Update 1 this no longer appears to be recognized and the following error occurs:

COBCH0801 : Compiler directive SQL(DATE = EXTERNAL) is invalid or badly sequenced - all SQL statements ignored.

What happened?

Resolution

Development has added a new directive called sql(OPTION=PROCOB) which needs to be set if the DATE=EXTERNAL directive is to be used. Actually when setting OPTION=PROCOB on it will automatically set the DATE=EXTERNAL behavior on so the DATE=EXTERNAL is no longer required.

 

Viewing all 214 articles
Browse latest View live