View previous topic :: View next topic
|
Author |
Message |
akshathan
New User
Joined: 18 Aug 2006 Posts: 45
|
|
|
|
Hi All,
I have 3 record layouts for an input file.One for header record,the other one for trailer record and lastly for detail record.I need to split the records in the input file based on record type.In this scenario can some one help me out in defining the FD section and also how the READ should be done.Plz provide an example.It will help me out to get a better view.
Regards,
Akshatha |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Create an FD with 3 01's in it.
Read the file (no magic, just a simple READ f_n AT END etc).
Compare the record read to see if it is a header, detail, or trailer.
Process the record according to type.
Stop when end of file. . . .
Write your code and if you get stuck, post the part of the code that you have questions about. |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi Akshata,
Quote: |
I have 3 record layouts for an input file.One for header record,the other one for trailer record and lastly for detail record.I need to split the records in the input file based on record type.In this scenario can some one help me out in defining the FD section and also how the READ should be done.Plz provide an example.It will help me out to get a better view |
Use Like this,
Code: |
FD INFILE-A
RECORDING MODE IS VB
LABEL RECORDS ARE STANDARD
01 INREC-A PIC X(MAX LENGHT).
WORKING-STORAGE SECTION.
01 WS-INREC-A
05 WS-REC-TYPE PIC X(2)
88 HD-INREC VALUES 'HEADER VALUE'.
88 TR-INREC VALUES 'TRAILER VALUE'.
88 DT-INREC VALUES 'DETAILED VALUE'.
05 UR-NEXT-FIELD X(DECLARE FURTHER).
|
Declare variables Accordingly, Then Perform your READ in loop in two step.
In Procedure Division Do Like this,
Code: |
PERFORM 1000-INIT-PARA THRU 1000-EXIT.
PERFORM 2000-PROCESS-PARA THRU EXIT UNTIL UR-CONDITION OR EOF.
GOBACK.
1000-INIT-PARA.
INITIALIZE WHATEVER-YOU-WANT.
ACCEPT WS-SYS-DATE FROM DATE * IF IT IS NUCCESSARY.
READ INFILE-A
AT END SET EOF TO TRUE
NOT AT END
MOVE INREC-A TO WS-INREC-A
EVALUATE TRUE
WHEN HD-INREC
PERFORM 1010-UR-PROCESS THRU 1000-EXIT
WHEN OTHER
PERFORM 9999-ABEND-PARA THRU 1001-EXIT
END-EVALUATE.
IF EOF
DISPLAY 'INPUT FILE IS EMPTY, FILE NAME IS:' DDNAME
PERFORM 9999-ABEND-PARA THRU EXIT
END-IF.
1000-EXIT.
EXIT.
2000-PROCESS-PARA.
READ INFILE-A INTO WS-INREC-A
AT END
SET EOF TO TRUE
NOT AT END
PERFORM 2100-UR-PROCESS-REQUIREMENMT THRU 2100-EXIT.
DISPLAY 'PROCESS DONE'.
2000-EXIT.
EXIT. |
I hope it will be helpfull to you.
Let us know If you have any doubt.
Thanks & Regards |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi Dick,
Quote: |
Create an FD with 3 01's in it.
|
Is it possible create three 01's FD declaration?
Please let us once you tried with this..
Thanks & Regards |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Is it possible create three 01's FD declaration?
Please let us once you tried with this.. |
Yes. Not only is it possible, but it is most common.
I believe i'll not "try it" (again) as it has worked for many, many years. |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi Dick,
Quote: |
I believe i'll not "try it" (again) as it has worked for many, many years |
That's fine, Currently I am on bench so that I couldn't able to check it out and hence I requested for you.
But for current requirement, how will you declare variable and code logic
Thanks & Regards |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Hemantha,
Quote: |
Is it possible create three 01's FD declaration?
Please let us once you tried with this.. |
As Dick highlighted, its a very common practice in projects.
I had been discussed earlier. Search the forum. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Hemantha,
Quote: |
But for current requirement, how will you declare variable and code logic |
I believe Dick had already answered this. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
But for current requirement, how will you declare variable and code logic |
If, in the FD, multiple records (level 01) are defined, a "record type" field (much like you used) is near the front of the record within the FD (rather than in ws).
Usually "key" info is the first part of the record and the "record type" is the next field - it can be named in the first record and set as filler in other record types or it can have a different name in each record type.
If this is not clear, please post a reply. |
|
Back to top |
|
|
|