Midrange News for the IBM i Community


Posted by: Chris Proctor
Programmer Analyst
Columbia Sports Company
Portland, OR
Moving a data structure to a record format
has no ratings.
Published: 01 Jun 2016
Revised: 02 Jun 2016 - 2878 days ago
Last viewed on: 19 Apr 2024 (4563 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Moving a data structure to a record format Published by: Chris Proctor on 01 Jun 2016 view comments(3)

Good morning

What is the easiest way to move a data structure to a record format? I've been told that if the data structure length is the same as the record format I can just do the following, but for some reason it doesn't seem to be working:

write rcdfmt dsname;

It's telling me that a data structure cannot be used in the second parm. Any ideas? Thanks in advance! 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: chrisp
Premium member *
Portland, OR
Comment on: Moving a data structure to a record format
Posted: 7 years 10 months 18 days 11 hours 6 minutes ago

Here's more detail on my issue. This is how it's coded. I'm trying to move the DS to a 512 char flat file.

dcl-f workfile usage(*output) rename(workfile:rworkfile) usropn;

As you can see below, I tried both defining the DS internally and externally with no luck.

dcl-ds ds_workfile extname('CSC530ED') qualified end-ds;

//dcl-ds ds_workfile len(512);

//dstyp char(1);

//dssku zoned(9:0);

//dsiamt zoned(13:0);

//dsvnd zoned(6:0);

//dsvpn char(15);

//dvamt zoned(13:0);

//dssvn zoned(6:0);

//dssty char(15);

//dssamt zoned(13:0);

//dsucd char(1);

//dsupc zoned(18:0);

//dsuamt zoned(13:0);

//dsccod char(3);

//dsprtp char(3);

//dsamt zoned(13:3);

//end-ds;

 

Here's where I'm trying to populate the DS with the necessary fields and write the WORKFILE record using the DS.

// load the EVN660P file from the CSC530P records

setll s1evnt csc530p;

reade s1evnt csc530p;

dow not %eof(csc530p);

reset rworkfile;

reset ds_workfile;

// load WORKFILE record based on price change type

select;

when sctyp = 'I'; // SKU level price change

dssku = scsku;

dsiamt = sciamt;

dsccod = sccod;

dsprtp = sccptp;

dsamt = scprice;

write rworkfile ds_workfile;

when sctyp = 'S'; // style level price change

dssty = scstyle;

dssamt = scsamt;

dsccod = sccod;

dsprtp = sccptp;

dsamt = scprice;

write rworkfile ds_workfile;

endsl;

reade s1evnt csc530p;

enddo;

It will not compile, the error says a data structure is not allowed for the operation.

 

Posted by: Ringer
Premium member *
Comment on: Moving a data structure to a record format
Posted: 7 years 10 months 17 days 13 hours 29 minutes ago

I believe WRITE requires a DS defined using LIKEREC. 

LikeRec(rworkfile:*output) 

Ringer

Posted by: BrianR
Premium member *
Green Bay, WI
Comment on: Moving a data structure to a record format
Posted: 7 years 10 months 17 days 10 hours 54 minutes ago
Edited: Thu, 02 Jun, 2016 at 12:28:56 (2878 days ago)

If the output file is a flat file (no field definitions) then try specifying the length on the file definition:

dcl-f workfile(512) usage(*output) rename(workfile:rworkfile) usropn;