UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21. Read more.
UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21.Read more.
Absent Member.
Absent Member.
3870 views

RM vs Visual Cobol RM Relative Files

Jump to solution

I'm in the slow process of migrating from RM w/Linux to Visual Cobol RM ... with DevHub to allow use of the Linux while coding in Windows/Eclipse.

I've just encountered a problem with Relative Files. In "Standard" RM the relative file ... if you "read next" is in Sequence.

1,2,3,4,5,6,7,8,9 erc.

Via Visual Cobol RM ... the Relative Key is a bit of a mess.

1,6,7,8,9,10,11,12,19,23,24,25 ...

I really discovered this problem when my transitioned code tried to access Record #2, which doesn't exist according to VC.

Any ideas on what I will need to do to get the program to work as written? I don't, unfortunately, have the time to do a file migration on all the systems and files.

I've attached the simple program, and the file that proves my point. RM when set of results Visual Cobol RM different set.

Any help would be appreciated.

0 Likes
2 Solutions

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

I'm not an expert in this area, but you said IDXFORMAT"21".  That only affects indexed files.  Did you try FILETYPE"21" like Elmer suggested?

View solution in original post

0 Likes
Absent Member.
Absent Member.

I didn’t … I saw the “21” and just assumed the command was the same.

My mistake … And yes this fixed it ... THANK YOU!!! for pointing out something I overlooked.

Does FILETYPE"21" replace IDXFORMAT"21", or will I need to do both?

View solution in original post

0 Likes
6 Replies
Absent Member.
Absent Member.

Hi Eric,

I have reproduced exactly the behavior you reported.  The problem is that you were reading the relative file with the Micro Focus File Handler and not the RM File Manager.  Unfortunately it is hard to tell that's what happened.  I don't know which version of Visual COBOL you are using but if you are embarking on a migration from RM/COBOL to Visual COBOL I strongly recommend upgrading to Visual COBOL version 2.2 Update 2.  The Visual COBOL compiler directives you need are DIALECT(RM) and FILETYPE(21).  You can put a line at the beginning of each COBOL program source like this:

    $SET  DIALECT(RM)  FILETYPE(21)

or you can specify the directives on the command line like this:

    cob -i Test.cbl -C "dialect(rm) filetype(21)"

That command line is the one I used to compile your test program on Linux.

On Windows the equivalent command line would be:

    cobol Test.cbl noobj dialect(rm) filetype(21);

The FILETYPE(21) directive tells the compiler that all files are RM files (sequential, relative, and indexed).  But the FILETYPE directive can be used in the source on a per file basis as well.  If you have your SELECT clauses and FD definitions in copy books then you might find it convenient to specify a different value for the FILETYPE directive for each file.  You might do this if you want to convert some files to Micro Focus format files while simultaneously having other files still be RM files (e.g., because they are also being accessed via RM/COBOL programs).  Any given Visual COBOL program can open both RM files and MF files simultaneously.

The FILETYPE(21) directive works in Visual COBOL 2.1 and later, but not in Visual COBOL 2.0 or earlier.  There are other (older, messier) ways to configure the use of RM files in older versions of Visual COBOL (search for the word INTEROP in Visual COBOL documentation).  If you must use a version of Visual COBOL prior to 2.1 and you need help then you can re-post here and we can probably help you configure that; but my strong recommendation to use Visual COBOL 2.2 Update 2 stands.  You'll be doing yourself a favor and avoiding trouble if you use the latest Visual COBOL.  In fact, version 2.3, which is due to be released later this year, will be even better in supporting RM/COBOL programs via DIALECT(RM).

One more "secret" that I'll share.  If you set the following two environment variables then the RM File Manager running for Visual COBOL will produce a trace file:

    FILE_TRACE=3

    RMFM_TRACE_FILE=trace.out

You can choose whatever file name you want instead of trace.out.  Doing that is one of the ways to tell that the RM File Manager was actually used to access the file.  Running your test program with those env vars set produces the following file:

[]cat trace.out

rmfm_ropen opened Input  REL file ESTINFOFL

rmfm_rclose    closing   REL file ESTINFOFL

If your program successfully opens and closes a file and there are no lines like the above in the trace file then the RM File Manager was not used to access the file.  You can also use the Consolidated Trace Facility (CTF) which you can read all about in Visual COBOL documentation (but my "secret" is easier).

Hopefully, this reply will solve your problem.

0 Likes
Absent Member.
Absent Member.

These are the Compiler Directives I'm using right now ... I switched from Dialect"RM" to RM because it was effecting other code I had.

idxformat"21"

& DIALECT"RM"

RM

ADDRSV"COMP-6"

COMP-6"2"

& ASSIGN-PRINTER()

SETTINGS

preprocess"window1"

When I get a chance, I'll switch back to Dialect"RM" for this and see if it gives different results on my end.

0 Likes
Absent Member.
Absent Member.

I've used Dialect"RM" or RM as compiler directives.

And Visual Cobol RM still sees the records as 1,6,7,8,9,10 instead of 1,2,3,4,5,6.

0 Likes
Micro Focus Expert
Micro Focus Expert

I'm not an expert in this area, but you said IDXFORMAT"21".  That only affects indexed files.  Did you try FILETYPE"21" like Elmer suggested?

View solution in original post

0 Likes
Absent Member.
Absent Member.

I didn’t … I saw the “21” and just assumed the command was the same.

My mistake … And yes this fixed it ... THANK YOU!!! for pointing out something I overlooked.

Does FILETYPE"21" replace IDXFORMAT"21", or will I need to do both?

View solution in original post

0 Likes
Absent Member.
Absent Member.

FILETYPE"21" applies to sequential, relative, and indexed files.  IDXFORMAT"21" only applies to indexed files.  If you use the FILETYPE directive then you do not need the IDXFORMAT directive.

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.