View Full Version: Work File Type Recommendation

LawsonTalk > Coding, Program Errors and Bugs > Work File Type Recommendation


Title: Work File Type Recommendation


cd_dotdot - March 31, 2006 11:27 PM (GMT)
Hi folks,

I have a file that I have to read using a 4gl program that I have to write. This file has fixed width records with carriage returns at the end of each record. There are text, numeric and date fields in there. Its all inventory control data ...

Should I use and Ext Seq file type to read this in or Tape file? And why?

Also I have to use this same program to write out a very similar file, which type should I use to write to that file? If you could show me a code snippet for opening, writing, reading and closing this files ...

Thanks

Milo - April 3, 2006 06:18 PM (GMT)
My 2-cents'-worth: The source for what you're looking for is the API manual -- "Application Program Interfaces". The section you need is called, "CSV File Processing Routines". All of the examples that you'll need are right there. I'd quote some of that stuff, but it's copyrighted by Lawson.

The manual does not tell you several things. You have to create a work file in PgmDef's F6 / E - Work File. A CSV work file can be further set up with F6 / B - Define File Attributes. Check out all of the different ways that your CSV file can be delimited!

Also, F6 / B - Define File Attributes gives you a single place to specify file location by filling in "External Name." If you leave "External Name" blank, you can specify CSV file attributes when you set up individual jobs. Which method you use depends on your users' needs. (We prefer defining the file location in WrkDef, because the location stays stable no matter who is running the job.)

cd_dotdot - April 3, 2006 07:55 PM (GMT)
Thank Milo,
Yes I am aware of all the features and the API document and how to add a work file ...
My question was more specifically about the difference between a Tape file and a Ext Seq file type.
The API document doesn't address that neither does the dev toolkit book or the workbench book. That's why I thought someone here might now.

If anyone knows of a program in Lawson that uses the Ext Seq file time please let me know that might be enough for me to go on.

Thanks


wsb2624 - April 3, 2006 08:49 PM (GMT)
We use Ext Seq mostly for imports - flat file - all fields are defined as alpha - so you have to convert numeric in working storage.
- sign is also seperate and trailing.
Used primarily for importing/exporting data to other systems.
I thought AP520 used Ext Seq - but it doesn't - the programs that we use it on
are all custom. I have used tape before if data contained a lot of numeric
fields - the only difference i know of is tape can have variable length records.

Hope this helps.

cd_dotdot - April 4, 2006 02:17 AM (GMT)
Thanks wsb2624,

Based on that I'll probably switch to tape cause I do have a few numeric fields I don't really want to convert. What exactly does it mean to have a variable length record though, how does the file know which field its on? Does it mean that you have different kinds of records within the file?

If anyone knows of a program that uses Ext Seq please let me know.
Along those same lines, does anyone know where that parameter is stored for each workfile? Its got to be in one of the GEN tables but I can't seem to find it.

Thansk

wsb2624 - April 4, 2006 02:46 PM (GMT)
Answer to question #1 - Yes you can have different kinds of records within the file.
the length can be different.
suggestion: try to quick paint a program using a ext seq work file - then build a shell on the program - maybe you can find what you are looking for there.
command - bldsh - this will create a .cbl file containing the entire program.
don't have time to try it - but you might get what you are looking for .

Phil Feller - April 4, 2006 03:51 PM (GMT)
QUOTE (cd_dotdot @ Apr 3 2006, 06:17 PM)
What exactly does it mean to have a variable length record though, how does the file know which field its on?

It's what we old-timers would call line sequential. The records are line delimited, so they can be of variable length. It does not mean that the fields within the record are of variable length.

QUOTE (cd_dotdot @ Apr 3 2006, 06:17 PM)
If anyone knows of a program that uses Ext Seq please let me know.

It depends on which systems you have. If you have PR, PR293 uses Ext Seq for two of its work files.

QUOTE (cd_dotdot @ Apr 3 2006, 06:17 PM)
Along those same lines, does anyone know where that parameter is stored for each workfile?

It's the MEDIA field in GEN/WORKFILE1. You can find out for yourself which programs on your system use Ext Seq work files by querying: rngdbdump -ct gen workfile1 -v media=4

BTW, the com.lawson.rdtech.constants.LawsonConstants class in lawsonrt.jar is a great source of information about what the numeric codes in many GEN files translate to. In this case:
public static final byte WT_PRINT = 0;
public static final byte WT_SEQ = 1;
public static final byte WT_INDSEQ = 2;
public static final byte WT_RANDOM = 3;
public static final byte WT_EXTSEQ = 4;
public static final byte WT_TAPE = 5;
public static final byte WT_CSV = 6;

trezaei - April 4, 2006 05:51 PM (GMT)
Here's some more programs that use Ext Seq, but it sounds like you're gonna need a Tape file for what you're doing. My experience has been that converting numbers back and forth from an Ext Seq file is a pain in the neck.

CB CB185
IC IC800
IC IC811
IC IC812
IC IC812
IC IC850
IC IC851
NY NY500
NY NY500
PR PR293
PR PR293
RQ RQ500

tghost - April 4, 2006 07:17 PM (GMT)
Hi all,

Here's a quick trick that not too many people know about, but it's saved me a ton of work in the past. I personally code nearly everything with work-files using the type CSV. Here's the trick, if you define a file type as CSV, and leave the delimiter set to none, and the quote characters left off (set to none), the CSV file will be created as a fixed length file with return characters. This enables me to use the other fun things with the type CSV without having to jump through hoops in formatting fields.

Have fun all,
Ted

trezaei - April 4, 2006 08:51 PM (GMT)
Wow I have never tried that. Man, we should write a little book on how to do all these little tricks. I have a bunch of time saving tricks that I use these days including our text editor that saves enough time to do coding twice.



Hosted for free by InvisionFree