Focal Point
[CLOSED] How to calculate FILEDEF LRECL for variable length fields

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6737008436

November 20, 2013, 10:25 PM
Tomsweb
[CLOSED] How to calculate FILEDEF LRECL for variable length fields
I have a master file in which a few fields are defined as variable length ( e.g., A3V).
This is unusable, however, as the data is still being loaded from an oracle warehouse.
Regardless, I am creating a report with these fields (and their formats) and made-up data.

I have created a MFD with -WRITE, like this:

 
SET HOLDLIST=PRINTONLY
-RUN

FILEDEF MASTER DISK labelf.mas
-RUN

-WRITE MASTER FILENAME=LABELF, SUFFIX=FIX, $
-WRITE MASTER SEGNAME=LABELF, $
-WRITE MASTER FIELDNAME=LABELN, FORMAT=I4, ACTUAL=A4, $
-WRITE MASTER FIELDNAME=FILLER, FORMAT=A1, ACTUAL=A1, $
-WRITE MASTER FIELDNAME=LABELA, FORMAT=A2, ACTUAL=A2V, $

-SET &XLEN = ?? ;

FILEDEF LABELF DISK LABELF.txt (LRECL &XLEN RECFM V
-RUN

-WRITE LABELF 0001 A
-WRITE LABELF 0002 B
-WRITE LABELF 0003 C
-WRITE LABELF 0004 D
-WRITE LABELF 0005 E

 -RUN

-EXIT


My question is, do I code the LREC by totaling up the FORMAT values, or the
ACTUAL values?

Thanks,

This message has been edited. Last edited by: <Kathryn Henning>,


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
November 21, 2013, 08:46 AM
Tom Flynn
  
APP FILEDEF MASTERNAME DISK Drive:\ibi\apps\FOLDER\LABELF.txt
-RUN
CHECK FILE MASTERNAME HOLD
-EXIT

Generates:
  
 0 NUMBER OF ERRORS=     0
 NUMBER OF SEGMENTS=   1  ( REAL=    1  VIRTUAL=   0 )
 NUMBER OF FIELDS=     1  INDEXES=   0  FILES=     1
 TOTAL LENGTH OF ALL FIELDS=  197



Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
November 22, 2013, 11:55 AM
Tomsweb
thanks Tom. I have been working on this and it looks like I may not need to account for the A3V etc., fields in my mfd created by -WRITE.


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
November 25, 2013, 08:00 AM
<JG>
Tomsweb

You do need to accomodate the variablility.

Each variable length field adds 6 bytes to the saved data when you go from
a relational source to a flat file or a FOCUS .foc

so Oracle varchar2 (2)

becomes FORMAT=2V ,ACTUAL A2W

WebFOCUS does not use real variable length storage, it holds the physical length of the column
as 6 unreferenced bytes

So when you hold a varchar (2) containing A, it actualy holds 000001A
AB, it actualy holds 000002AB

That means for your example you have an LRECL of 13

4 + 1 + 6 + 2 = 13

Also the ACTUAL is AnW not AnV
Your FORMAT can be either A2 or A2V depending on how you want to use it

FILEDEF MASTER DISK labelf.mas
-RUN

-WRITE MASTER FILENAME=LABELF, SUFFIX=FIX, $
-WRITE MASTER SEGNAME=LABELF, $
-WRITE MASTER FIELDNAME=LABELN, FORMAT=I4, ACTUAL=A4, $
-WRITE MASTER FIELDNAME=FILLER, FORMAT=A1, ACTUAL=A1, $
-WRITE MASTER FIELDNAME=LABELA, FORMAT=A2V, ACTUAL=A2W, $

-SET &XLEN = 13 ;

FILEDEF LABELF DISK LABELF.txt (LRECL &XLEN RECFM V
-RUN

-WRITE LABELF 0001 000001A
-WRITE LABELF 0002 000001B
-WRITE LABELF 0003 000001C
-WRITE LABELF 0004 000001D
-WRITE LABELF 0005 000001E

TABLE FILE LABELF
PRINT *
END