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

Multiple record description entries.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
akshathan

New User


Joined: 18 Aug 2006
Posts: 45

PostPosted: Tue Oct 09, 2007 5:28 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Oct 09, 2007 6:28 pm
Reply with quote

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
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Tue Oct 09, 2007 6:36 pm
Reply with quote

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
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Tue Oct 09, 2007 6:45 pm
Reply with quote

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.. icon_question.gif

Thanks & Regards
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Oct 09, 2007 7:09 pm
Reply with quote

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
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Tue Oct 09, 2007 7:30 pm
Reply with quote

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 icon_question.gif

Thanks & Regards
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Oct 09, 2007 7:30 pm
Reply with quote

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
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Oct 09, 2007 7:34 pm
Reply with quote

Hemantha,

Quote:
But for current requirement, how will you declare variable and code logic

I believe Dick had already answered this.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Oct 09, 2007 9:06 pm
Reply with quote

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
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top