Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to read record from mixed format file?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
shaham25

New User


Joined: 20 Apr 2006
Posts: 6
Location: chennai

PostPosted: Fri Aug 04, 2006 2:39 pm    Post subject: How to read record from mixed format file?
Reply with quote

inputfile:-

1 xxxxxx 060306 1981
2 beer 002 60.00 2
2 brandi 004 190.00 1
2 whisky 003 140.00 1
1 yyyyy 070306 1982
2 beer 002 60.00 2
2 brandi 004 190.00 1
2 whisky 003 140.00 1
1 zzzz 110306 1982
2 beer 002 60.00 2
2 brandi 004 190.00 1
2 whisky 003 140.00 1

input file contains 2 structures:

structure 1:- for rec_id = 1

Rec_id
name
date
orderno

structure 2:- for rec_id = 2

Rec_id
item
item_code
rate
quantity

OUtput:-
-----------------------------------------------------
customer: xxxxx date:060306
order: 1981
---------------------------------------------------
slno item item_code rate quantity amount
1 beer 002 60.00 2 120.00
2 brandi 004 190.00 1 190.00
3 whisky 003 140.00 1 140.00
---------------------------------------------------
Total: 450.00
----------------------------------------------------


Question:-
-----------
How to read the record from the mixed format file(file contains two informations)?...
Back to top
View user's profile Send private message

shaham25

New User


Joined: 20 Apr 2006
Posts: 6
Location: chennai

PostPosted: Tue Aug 08, 2006 6:57 pm    Post subject: Re: How to read record from mixed format file?
Reply with quote

Here is the answer for my question.

Record structure:-
------------------
DCL 1 INREC1,
5 REC_ID CHAR(1),
5 FILLER CHAR(79);

DCL 1 OUTREC,
5 SL_NO CHAR(2),
5 FILLER1 CHAR(8),
5 ITEM1 CHAR(10),
5 FILLER2 CHAR(7),
5 RATE1 PIC 'ZZ9V.99',
5 FILLER3 CHAR(10),
5 QUANTITY1 PIC 'ZZ9V.99',
5 FILLER4 CHAR(13),
5 AMOUNT PIC 'ZZZZ9V.99';
/* 5 FILLER5 CHAR(3);*/

DCL 1 OUTREC1,
5 REC_ID1 CHAR(1),
5 CUST_NAME1 CHAR(20),
5 YEAR CHAR(2),
5 MONTH CHAR(2),
5 DAY CHAR(2),
5 ORDERNO1 CHAR(4),
5 FILLER CHAR(49);

To get the record1:-
-------------------

IF INREC1.REC_ID = 1
THEN DO;
OUTREC1 = ' ';
OUTREC1.CUST_NAME1 = SUBSTR(INREC1.FILLER, 1,20);
OUTREC1.YEAR = SUBSTR(INREC1.FILLER, 21,2);
OUTREC1.MONTH = SUBSTR(INREC1.FILLER, 23,2);
OUTREC1.DAY = SUBSTR(INREC1.FILLER, 25,2);
OUTREC1.ORDERNO1 = SUBSTR(INREC1.FILLER, 27,4);

To get the record2:-
-------------------

IF INREC1.REC_ID = 2
THEN DO;
OUTREC = ' ';
OUTREC.ITEM1 = SUBSTR(INREC1.FILLER, 1,10);
OUTREC.RATE1 = SUBSTR(INREC1.FILLER, 11,3);
OUTREC.QUANTITY1 = SUBSTR(INREC1.FILLER, 14,3);

Incase of any clarification , please ask me
Back to top
View user's profile Send private message
Murali krishna

New User


Joined: 17 Feb 2006
Posts: 9
Location: chennai

PostPosted: Tue Sep 19, 2006 5:19 pm    Post subject:
Reply with quote

Declare a structure with the extact LRECL.
Declare Structure one as input1 format and while declaring use Based on parameter.
Do the same for structure two.

Hope it works.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 0 Tue Jan 17, 2017 4:26 pm
No new posts Summing on Mixed Case Literals Roy Ware SYNCSORT 3 Tue Jan 03, 2017 10:18 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts A not very Christmassy PL/I tale, wit... prino PL/I & Assembler 3 Mon Dec 26, 2016 1:01 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us