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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNSTRING Tab delimited input file - Need Help

Status
Not open for further replies.

dgalle

Programmer
Oct 21, 2003
2
US
I'm trying to unstring an input record that is tab delimited. It brings is the first field and leaves everything else blank. Any suggestions?

FD C102-AST-CUST
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD.
01 C102-AST-CUST-REC PIC X(50).

10 C-DELIM PIC X(01) VALUE X'09'.

05 C102-AST-CUST-GRP.
10 C102-EXTERNAL-ID PIC X(09).
10 C102-EXTERNAL-ID-TYPE PIC X(01).
10 C102-TAX-TYPE-CODE PIC X(02).
10 C102-ACCOUNT-SUFFIX PIC X(03).
10 C102-AST-VOUCHER-AMT PIC 9(15).

UNSTRING C102-AST-CUST-REC
DELIMITED BY C-DELIM
INTO C102-EXTERNAL-ID
C102-EXTERNAL-ID-TYPE
C102-TAX-TYPE-CODE
C102-ACCOUNT-SUFFIX
C102-AST-VOUCHER-AMT
END-UNSTRING
 
Well, I sorta wish you had told us the compiler that you are using on UNIX. However, POR (press on regardless)...

My guess is that the file is a line sequential (i.e. text) file and that the file system is removing/expanding the tab character before the data record is stored in the 01 record area.

Tom Morrison
 
Or you have a blank or otherwise non-conforming line (i.e. no tabs) in your input file.

Does it fail for all the input records or does it work for some subset of the input?

"Code what you mean,
and mean what you code!
But by all means post your code!"

Razalas
 
Okay, so what is the resolution here?
I have the same problem as degalle above stated.

I viewed my sequential file in Vim editor and the file does have tabs delimiting the fields.

So, why is it that my first field is the only one getting a value in it still?

On Linux, RMCOBOL-85 version 8.
 
Tom mentioned:

"My guess is that the file is a line sequential (i.e. text) file and that the file system is removing/expanding the tab character before the data record is stored in the 01 record area. "

I'll bet he's right about this.
The reason I think he is right, is because I have 2 sessions open, one viewing the raw data which still has the tabs between the fields, the other with my running program that reads in the file.
On each iteration, I DISPLAY the record read in and do an ACCEPT to be able to view and compare the layout of the DISPLAYed record with the layout of the same record in the raw data. The DISPLAY does indeed show the whole record, but it appears to be removing some of the space on each TAB.

So, is there a workaround to this problem?

I need to be able to work with reading in a tab delimited file in my Linux environment using RMCOBOL-85. And this problem seemed to not get solved in this post - if it did I don't see the solution yet.

Thanks for any help on this matter.
-David

 
There is an option on the runtime configuration file (see your runtime users manual) that allow the RM filesystem to remove the tabs. Have a look at it. (configuration section on the manual)


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Great, I'll do that.
I was starting to think that they may not be a way to handle this.
 
I have the User's Guide Version 8.0 for Unix and Windows and I have Language Reference Manual version 8.0.

I assume you're talking about Chapter 10 in the User's Guide manual, but I can't find the features for setting the switch to for removing tabs.

Where is it?

Thanks.
-David
 
thread209-620147 mentions something for MicroFocus
Saginaw stated:
"The default for Micro Focus COBOL is to expand the tabs to spaces when reading a LINE SEQUENTIAL file. However, this feature can be turned OFF by creating a configuration file for the file handler. The configuration file should contain the following two statements.
[XFH-DEFAULT]
EXPANDTAB=OFF
Next, you need to set an environment variable to point to your configuration file as follows.
SET EXTFH=myconfigfile.cfg
If you are using Net Express this can be set in the Project Properties item from the tool bar."

I don't know how to do this in RMCOBOL-85.

This is aggravating.



 
David,

It is on page 10-52 of the User's Guide.

Create a configuration file containing the following:
Code:
RUN-SEQ-FILES TAB-STOPS=0

The use the C option on the runcobol command to point to the configuration file.

That should do it.

You can get fancy and have the configuration file autoloaded, obviating the need for the C option on the runcobol command. This is also described in the beginning of Chapter 10.

Tom Morrison
 
Thanks, Tom.
I've tried this. I wonder if for some reason it doesn't work may be because the program that is reading the raw data is a subprogram/"CALL"ed program from the one I use the C=config.txt on the runcobol.

See, I have a main menu cobol program called fp_main.cob.
On one of its menu options when selected it does a CALL to fp_subpgm.cob.

So, what I've tried is running runcobol fp_main.cob C=config.txt
and I still get bad results. the fp_subprgm.cob is the one that deals with the UNSTRING of my TAB delimited data. Shouldn't the C option you speak of that I use on my runcobol fp_main.cob cover for all run(including the subprograms called from this main program).

Does my config.txt file need to contain anything other than:

RUN-SEQ-FILES TAB-STOPS=0

I really can not get this to work and it's baffling.
And I know that you've mentioned in another thread that you got it to work even though the fella requesting help was still not getting the correct results following the instructions to build a config.txt file and use it with the C option upon runtime.

I did submit this challenge to support at Liant and am awaiting response.

I'm not trying to be difficult here. I put the config.txt in the same directory as my fp_main.cob program. I'm wondering if I'm missing something here in the overall picture.

Thanks for the help - I know this is a worn out issue.
 
David,

Perhaps you can post the code here, or if you prefer due to length or proprietary concerns, send it to my email address. But lets try a few things first...

The
Code:
RUN-SEQ-FILES TAB-STOPS=0
will affect all line sequential files within the run unit.

Try placing another line that contains an error (such as a bad configuration record-type) in your config.txt file. Then runcobol and see if you get an error message. If you don't get an error message, then there is some operational issue that we haven't diagnosed.

Another thing you may try, assuming you get the error message on the previous test, is to do something such as
Code:
RUN-SEQ-FILES tab-stops=1,5,15,20,25,30,35,40,45,50
in order to change the number of spaces introduced by tab substitution.

Let's see how these work...

Tom Morrison
 
Okay, I'll try all those different tab-stops.
HOw would I implement error messaging in my config.txt. Is there instructions for that at 10-52 in the User's Guide?
 
To create an error message resulting from a configuration error place a nonsense record in the configuration file:
Code:
RUN-SEQ-FILES TAB-STOPS=0
K5TM-KNOWS-NOTHING TAB-STOPS=0

One hopes that the second record should make runcobol complain with a 404 (or perhaps 407) error.

This is an attempt to be sure that the configuration file is processed (something that is normally accomplished without any messages).

Tom Morrison
 
AmarilloElvis,

Whenever I encounter a problem like this I always find it quicker in the long run to just do a simple experiment. For example here I created a line-sequential file and in the first and only record I typed FIELD1*FIELD2*FIELD3 where * is a tab. A quick program provides the solution.

I used MicroFocus COBOL in a windows environment.

I found that tab characters are converted to two spaces on a read when no other directives are used.

IDENTIFICATION DIVISION.
PROGRAM-ID. TABSTEST.
AUTHOR. CLIVE CUMMINS.
INSTALLATION. DATE-WRITTEN. DEC 5,2003.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT TABSTEST-FILE ASSIGN TO TABSTEST-FILE-ID
FILE STATUS IS TABSTEST-RETURN-CODE
ACCESS MODE IS SEQUENTIAL
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD TABSTEST-FILE.
01 TABSTEST-RECORD PIC X(72).
WORKING-STORAGE SECTION.
01 TABSTEST-PARAMETERS.
05 TABSTEST-FILE-ID PIC X(12)
VALUE "TABSTSTI.TXT".
05 TABSTEST-RETURN-CODE PIC X(2).
05 TABSTEST-RECORD-WORK PIC X(72).
05 TABSTEST-FILE-ID-OUT PIC X(12)
VALUE "TABSTSTO.TXT".
01 UNSTRING-FIELDS.
05 UNSTRING-1 PIC X(24).
05 UNSTRING-2 PIC X(24).
05 UNSTRING-3 PIC X(24).
PROCEDURE DIVISION.
OPEN INPUT TABSTEST-FILE.
READ TABSTEST-FILE INTO TABSTEST-RECORD-WORK.
CLOSE TABSTEST-FILE.

MOVE TABSTEST-FILE-ID-OUT TO TABSTEST-FILE-ID.
OPEN OUTPUT TABSTEST-FILE.
WRITE TABSTEST-RECORD FROM TABSTEST-RECORD-WORK.
CLOSE TABSTEST-FILE.

UNSTRING TABSTEST-RECORD-WORK DELIMITED BY X"09"
INTO UNSTRING-1 UNSTRING-2 UNSTRING-3.
EXHIBIT NAMED UNSTRING-1 UNSTRING-2 UNSTRING-3.

UNSTRING TABSTEST-RECORD-WORK DELIMITED BY " "
INTO UNSTRING-1 UNSTRING-2 UNSTRING-3.
EXHIBIT NAMED UNSTRING-1 UNSTRING-2 UNSTRING-3.
GOBACK.

Clive
 
David, it works for me (on WIndows...no Linux handy at the moment). Here is a simple test program that uses the test data you sent thru private email:
Code:
	identification division.
	program-id. simple.
	environment division.
	configuration section.
	special-names.
	    symbolic horizontal-tab is 10.
	input-output section.
	file-control.
	    select t assign "ACHTestB.txt"
		organization line sequential.
            select c assign config-filename
		organization line sequential.
	data division.
	file section.
	fd  t.
	01  t-record pic x(500).
        fd  c.
        01  c-record pic x(70).
	working-storage section.
	01  i pic 999 value 0.
        01  config-filename pic x(70) value spaces.
	01 WS-ENV-VARIABLES.
	   03 ENV-NAME                  PIC X(21) VALUE "RM_RUNTIME_OPTIONS".
	   03 ENV-VALUE                 PIC X(50).
	   03 ENV-RETURN                PIC 9(5) BINARY VALUE ZERO.
	procedure division.
	a.
	    CALL "C$GetEnv" USING ENV-NAME, ENV-VALUE, ENV-RETURN.
	    DISPLAY "Runtime command options = " ENV-VALUE. 
	    move 3 to i.
	    inspect ENV-VALUE tallying i for characters 
		              before initial 'c='.
	    unstring ENV-VALUE DELIMITED BY SPACE OR X"00"
		into config-filename pointer i.
	    open input c t.
	    read c.
	    display "1st configuration record:"
	    display c-record.
	    read t.
	    move 0 to i.
            inspect t-record tallying i for all horizontal-tab.
	    display "1st test record tab count: " i convert.
	    stop run.
(NOTE: This is using an undocumented feature of RM/COBOL to get the command line parameters that we use for testing purposes. It will remain undocumented.)

I tested using two different configuration files the content of which is display in the output. First the normal configuration, explicitly coded in a configuration file:
Code:
RM/COBOL Runtime - Version 8.00.00 for 32-Bit Windows.
 
Runtime command options =    c=normal.txt
1st configuration record:
RUN-SEQ-FILES TAB-STOPS=8,12,16,20,24,28,32,36,40,50,60,70
1st test record tab count: 0
COBOL STOP RUN at line 44 in program SIMPLE

And now with TAB-STOPS=0:
Code:
RM/COBOL Runtime - Version 8.00.00 for 32-Bit Windows.

Runtime command options =    c=config.txt
1st configuration record:
RUN-SEQ-FILES TAB-STOPS=0
1st test record tab count: 14
COBOL STOP RUN at line 44 in program SIMPLE

I will send a copy of the program via email. Hope this helps.


Tom Morrison
 
David and I have been communicating via email. His problem is solved. I hope he will come back here to report.

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top