|
Please help with writing to an externally described file using a data
structure.
I have been to the archives, googled, RFMd (which appears to have some
inconsistent info concerning 'WRITE'),
and not found what I was looking for.
I am running at V5R2.
Situation:
I have 2 externally defined files with some common field names.
Common names are: Prt#, CYMD, and Cost.
I am reading/accumulating values from the first file and filling the
qualified DS fields before writing to the second.
At some point I have read a record, 'unqualified' field names contain
values from this record, and the 'qualified DS'
field names contain the values to be posted.
Problem:
I cannot figure out how to get the data structure written to the file
using the
free-form "WRITE{(E)} name {data-structure}" method as shown in the
manual.
I realize I could do this other ways, "Prefix", another DS, etc., but I
like the concept of 'qualified data structure'
to differentiate fields, and really want to make this work, if possible.
*****************
Specifications for 'output' file:
FSrcCst UF A E K Disk
*****************
DDS for file SrcCst:
R SRCCSTR
PRT# 7S 0
SOUR 2A
CYMD 8S 0
FOTG 8S 0
COST 12S 4
K PRT#
K SOUR
K CYMD
*****************
Data structure definition:
(PDM/SEU allows either of these)
D ScRecd E DS ExtName(SrcCst:SrcCstR:*Output) Inz
D Qualified
...or...
D ScRecd E DS ExtName(SrcCst:*Output) Inz
D Qualified
*****
(PDM/SEU does NOT allow these)
D ScRecd E DS LikeRec(SrcCst:SrcCstR:*Output) Inz
D Qualified
The LIKEDS keyword is not valid with an externally-described
data structure.
(What LIKEDS ????)
D ScRecd E DS LikeDS(SrcCst:SrcCstR:*Output) Inz
D Qualified
The LIKEDS keyword is not valid with an externally-described
data structure.
D ScRecd DS LikeDS(SrcCst:SrcCstR:*Output) Inz
D Qualified
A right parenthesis is expected but is not found.
(To match with what ????)
D ScRecd DS LikeDS(SrcCst:*Output) Inz
D Qualified
A right parenthesis is expected but is not found.
(To match with what ????)
*****************
Compilation attempts and resulting errors:
040200 Write(E) SrcCstR ScRecd;
*RNF7701 30 040200 Data structure SCRECD is not allowed
for the operation.
040300 Write(E) SrcCst ScRecd;
*RNF5155 20 040300 The Result-Field operand is not
allowed for specified operation.
*RNF5063 30 040300 Factor 2 operand must not be an
externally described file for this operation.
From ILE RPG Reference manual for "Write":
If name refers to an
externally-described file or a record format
from an externally
described file, the data structure must be a
data structure defined
with EXTNAME(...:*OUTPUT) or LIKEREC(...:*OUTPUT).
???????
040400 Write(E) SrcCst SrcCstR;
*RNF5155 20 040300 The Result-Field operand is not
allowed for specified operation.
*RNF5063 30 040300 Factor 2 operand must not be an
externally described file for this operation.
040500 Write(E) ScRecd;
*RNF7260 30 040500 The Factor 2 operand is not valid for
the specified operation.
040600 Write(E) SrcCst;
*RNF5063 30 040600 Factor 2 operand must not be an
externally described file for this operation.
040700 Write(E) SrcCstR;
Compiles........ and in debug immediately before "Write(E)
SrcCstR;":
> EVAL screcd
SCRECD.PRT# = 0000010.
SCRECD.SOUR = 'SI'
SCRECD.CYMD = 20040401.
SCRECD.FOTG = 00030039.
SCRECD.COST = 00000001.3975
>EVAL Prt#
PRT# = 0000010. (value is from input file field Prt#)
>EVAL Sour
SOUR = ' ' (non-common field)
> EVAL cymd
CYMD = 20040202. (value is from input file field CYMD)
> EVAL Fotg
FOTG = 00000000. (non-common field)
> EVAL Cost
COST = 00000001.4116 (value is from input file field Cost)
File before "Write" had no records.
File after Write:
PRT# = 10 (correct, 'accidentally', from input
file)
SOUR = ' ' (incorrect, non-common, no SrcCst record
had been read to fill)
CYMD = 20040202 (incorrect, from input file)
FOTG = 0 (incorrect, non-common, no SrcCst record
had been read to fill)
COST = 14116 (incorrect, from input file)
Thanks for any help or insight.
Tim Kredlo
Exterior Wood, Inc
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.