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

Displaying field names along with its value


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

New User


Joined: 08 Jun 2006
Posts: 53

PostPosted: Tue Jun 02, 2009 12:22 am
Reply with quote

Hi,

Input to the program :

1) File Layout
2) File having Data

Outout would be :
Record Counter Field Name Field Value

Record counter will be running sequence and field name will be as given in the layout and Value will be picked up from the data file.

Is it possible to write a COBOL or rexx program to achieve this?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jun 02, 2009 12:49 am
Reply with quote

Is File Aid available at your site?
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Tue Jun 02, 2009 4:01 pm
Reply with quote

@ Sahoo

>> Is it possible to write a COBOL or rexx program to achieve this???

Answer: Sir, yes Sir, Sir !!!
Back to top
View user's profile Send private message
Sahoo

New User


Joined: 08 Jun 2006
Posts: 53

PostPosted: Thu Jun 04, 2009 7:41 am
Reply with quote

If yes, can you provide some guideline on how to do 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: Thu Jun 04, 2009 7:47 am
Reply with quote

Hello,

The easiest way with cobol is probably to read a record and then issue a display like this:
Code:
DISPLAY 'FIELD-NAME   =  ' FIELD-NAME.
and repeat for each field.

If you want a more formal output, you could define an FD for an output file and write headings and generate page breaks, etc.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Jun 04, 2009 8:50 am
Reply with quote

If you use DISPLAYs, you can avoid confusion of leading or trailing spaces by coding something like:
Code:
DISPLAY 'FIELD-NAME: '<' FIELD-NAME '>'
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: Thu Jun 04, 2009 8:56 am
Reply with quote

Hello,

One more thought. . .

If you DISPLAY the fields in the file, it would be best to not display group fields that have packed or binary numeric elementary fields.
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Thu Jun 04, 2009 7:53 pm
Reply with quote

I believe that he wants to read the file layout from an input file not hard code it in the displays. As stated if you have File Aid it could do it for you. Otherwise it can be done in a COBOL program, but depending on the format of the file layout file it may not be easy. 1) read the file layout file and store it in working storage in occurs. 2) read each record from the data file loop through the layout table using reference modification extract the data values, convert it as needed for readable output and write the field name and value. It will help if the file with the file layout contains the starting location, length and type of each field not just the COBOL copybook, otherwise you will need to parse the copybook and calculate the starting location and length of each field.
Back to top
View user's profile Send private message
Sahoo

New User


Joined: 08 Jun 2006
Posts: 53

PostPosted: Fri Jun 05, 2009 5:37 am
Reply with quote

Douglas Wilder
What you mentioned is write. I need a generic program which will work for any layout i give....
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: Fri Jun 05, 2009 5:44 am
Reply with quote

Hello,

I believe everyone understands what you want. It is available in FileAid.

Quote:
I need a generic program which will work for any layout i give....
If you write your own, it will probably be no small effort. . .

Quote:
It will help if the file with the file layout contains the starting location, length and type of each field not just the COBOL copybook, otherwise you will need to parse the copybook and calculate the starting location and length of each field
As Douglas mentioned, if the displacement, length, and type are not available, you will need to either write the equivalent of the compiler to parse data division entries or find some way to otherwise obtain them. Two other ways are using the output from a compile or converting the cobol copybook to an Easytrieve layout (if your system uses Easytrieve).
Back to top
View user's profile Send private message
Sahoo

New User


Joined: 08 Jun 2006
Posts: 53

PostPosted: Sat Jun 06, 2009 10:45 pm
Reply with quote

It is available in file-aid but can it be saved to a file?
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: Sun Jun 07, 2009 2:51 am
Reply with quote

Hello,

The output from a batch job can be written to dasd instead of sysout.

FileAid can run in batch. . .

If i remember correctly, you may be able to do all of the setup online and then submit to batch which would generate the necessary jobstream for you.
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts IBM OnDemand Folders displaying to al... IBM Tools 6
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
Search our Forums:

Back to Top