IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to read record from mixed format file?


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top