Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program Inserting Hex Char for some reason.

Status
Not open for further replies.

supra94red

Programmer
Nov 27, 2002
11
0
0
US
Hello all,
I have an 11 byte hex field used for barcode purposes
and when I come across an x'11' I get an x'00' byte
inserted before it and the field now becomes a 12 byte
field. I have tried defining the field as PIC X(11),
PIC 9(11), PIC 9(11) COMP, and PIC 9(11) COMP-3 with no
luck. PLEASE HELP!!!.
 
Platform and compiler please. And give more detail. Are you writing to a file?
 
Microfocus COBOL in Windows NT. I've narrowed all the
code down to nothing but read the file into a work area
and write the file from the same work area. I'm not even
moving anything.
 
By default, Micro Focus COBOL inserts a low-value character before each byte written to a line-sequention file which is less than X'1B'. You can turn this feature off on the command line by specifying (-N) after the program name and before any program command line parameters, or put the string "-N" in the environment variable COBSW. You can also do it in the program with the following code:
Code:
 CALL X'91' USING 1-byte-ws-field, X'2F', file-name

You can turn this feature on regardless of the (N) switch setting with the following code:
Code:
 CALL X'91' USING 1-byte-ws-field, X'30', file-name

Be aware, however, that if you turn this feature off, you may not be able to read the resulting file into a Micro Focus COBOL program.
 
Thanks for the quick response, I never would have figured
out that one.
 
[tt]Supra94red, (fyi;Webrabbit,)

Try adding [,BSAM] (without the []s) to File-Identifier-1 of the assign clause, or if internally naming files, to the value of Data-Name-1 referenced by the Assign clause.

Example;

[/tt]
Code:
        SELECT IN-FILE ASSIGN TO “FILENAME.TXT,BSAM”
[tt]OR;[/tt]
Code:
        SELECT IN-FILE ASSIGN TO INFILE-NAME
        . . .
        01 WK-LOCAL
            02  INFILE-NAME       PIC X(17)
        . . .
        PROCEDURE DIVISION
        . . .
            MOVE “FILENAME.TXT,BSAM” TO INFILE-NAME
            OPEN INPUT IN-FILE
        . . .
[tt]This is an extension (undocumented?) found to be incorporated in the several versions of Micro Focus’s p.c. Cobol compilers that I’ve run. It’s been a rock solid method to stop zero-byte insertion and other conversions (like x'09' tabs) both when writing and reading files. It may be incorporated in the version you are using.

Steve[/tt]
 
CobolKid, do you also specify LINE SEQENTIAL? What does BSAM do with CR & LF?
 
[tt]Webrabbit,

Yes, line sequential works. Pardon me; besides the periods, I chopped “Line Sequential” off the example too. When Line Sequential is coded, the X'0D0A' (CRLF) is treated as the end of line/record delimiter like usual. I’ve successfully used this with Record Sequential files as well, note that a Record Sequential REWRITE in conjunction with “,BTAM” caused exceptions at execution time. Compilers; Micro Focus COBOL2 Version 3.0.23 & Fujitsu COBOL97 Version 6.1L10, no others in use at this loc. .

The only reference to this context (of BTAM) I have found to date is contained in Fujitsu’s Cobol 97 User’s Guide for Windows (cob_ug.pdf as provided with PowerCobol 6) Chapter Seven; File Processing, High-Speed File Processing, which provides very little (and somewhat inaccurate) detail.

This is why the “Try” of my previous post. Although I first discovered and utilized this to handle a situation where large quantities of X’08’s thru X’0C’s and the resultant zero-byte insertion had became a major pain, it is still to my knowledge, an undocumented extension. Any use of such mandates careful application and proper verification of results. Even so, this has become standard methodology for handling X’09’ tabs (pc type) here.

If anyone knows of additional documentation, please post the particulars, like title/author/vendor.
Thank you,
Steve[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top