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

Adding field names in the extract file


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

New User


Joined: 31 Jul 2006
Posts: 8
Location: TCS, INDIA

PostPosted: Fri Feb 02, 2007 10:24 am
Reply with quote

hi all
iam facing a problem in adding some fields in the extract file, which is created through cobol.
i have to add some field names to the existing record in the extract
can anyone tell
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Fri Feb 02, 2007 10:31 am
Reply with quote

Hi Vinit,

Would u please elaborate ur question by providing example
Back to top
View user's profile Send private message
vinit

New User


Joined: 31 Jul 2006
Posts: 8
Location: TCS, INDIA

PostPosted: Fri Feb 02, 2007 11:17 am
Reply with quote

output of a cobol prog
in the extract file



no. name add so on <== to be added

121 sdds 3232 sdfsdfs

i want to add a row which shows the records actual name
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Fri Feb 02, 2007 11:20 am
Reply with quote

Hi Vinit,

Still its not clear
Quote:

I have to add some field names to the existing record in the extract


Quote:
no. name add so on <== to be added

121 sdds 3232 sdfsdfs

i want to add a row which shows the records actual name
Back to top
View user's profile Send private message
vinit

New User


Joined: 31 Jul 2006
Posts: 8
Location: TCS, INDIA

PostPosted: Fri Feb 02, 2007 11:26 am
Reply with quote

suppose i have writen a cobol program which produces an extract file with some records in it
example:

Code:
121     sdds              3232             sdfsdfs



now i want to add a row which identifies each record through cobol prog.

Code:
no.     name             addre.           city                  <== row to be added


i have to do this through cobol
i hope it is clear now
Back to top
View user's profile Send private message
Aji

New User


Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

PostPosted: Fri Feb 02, 2007 3:13 pm
Reply with quote

Hi

Take the backup of the existing extract file.
Create a new FD with the appended fileds.
read first file with old FD, and write into newfile with new fd.

Aji Cherian
Back to top
View user's profile Send private message
mani_jnumca

New User


Joined: 18 Jan 2006
Posts: 16
Location: PUNE

PostPosted: Fri Feb 02, 2007 3:17 pm
Reply with quote

i means to say that u want to add a row as header
simply fist populate the field with the header value
with the appropriate positions....
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Feb 02, 2007 3:28 pm
Reply with quote

Terminology problems...
vinit wrote:
extract file with some records in it
example:
Code:
121     sdds              3232             sdfsdfs
Does the above represent one record with 4 fields or 4 records?
Quote:
now i want to add a row which identifies each record through cobol prog.
Code:
no.     name             addre.           city                  <== row to be added
Rows are in tables, not extract files, why the change in terminology?
Quote:
i hope it is clear now
Not yet, but we're working on it.... icon_smile.gif
Back to top
View user's profile Send private message
vinit

New User


Joined: 31 Jul 2006
Posts: 8
Location: TCS, INDIA

PostPosted: Fri Feb 02, 2007 3:50 pm
Reply with quote

Thanks ALL
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Feb 02, 2007 4:03 pm
Reply with quote

vinit wrote:
Thanks ALL
Huh? icon_rolleyes.gif
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: Sat Feb 03, 2007 2:33 am
Reply with quote

Hi Vinit,

Is your problem solved?

If not, in the COBOL program, after opening the output file, write one record that is all of the header info. You can do this by defining a "header" record in working-storage and writing from it. Just line up the values so they come out over the correct positions in your data records.

My understanding is shaky sometimes, so if that will not do what you need, just let us know. icon_smile.gif
Back to top
View user's profile Send private message
sachin_star3
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Mon Feb 05, 2007 2:05 am
Reply with quote

first write the records that you want and add new that you want
check following programe
Code:
                    -         ID DIVISION.
                              PROGRAMME-ID. ADDITION.
                              ENVIRONMENT DIVISION.
                                   SELECT FILE1 ASSIGN TO DD1
                                    FILE STATUS IS FS1.
                                   SELECT FILE2 ASSIGN TO DD2
                                   FILE STAUS IS FS2.
                              DATA DIVISION.
                              FD FILE1.
                              01 INPUT
                                 02  X PIC X(80).
                              FD FILE2
                               01 OUTPUT.
                           [---     02 ECODE  PIC X(3).
                 OLD RECORD[        02 FILLER  PIC X.
                           [        02 ESAL    PIC X(4)
                           [        02 FILLER   PIC X.
                                    02 NEW1    PIC X(8)
                                    02 FILLER   PIC X(67).
                              PROCEDURE DIVISION.
                                  OPEN FILE1 OUTPUT MODE.
                                   READ FILE1
                                     IF FS1=0
                                        THEN
                                     MOVE INPUT TO OUTPUT
                                       MOVE "URBRILLIANT" TO NEW1
                                       WRITE OUTPUT
                                      STOP RUN.

======================================
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: Mon Feb 05, 2007 4:06 am
Reply with quote

Hello,

Please re-post the code "solution" to include the data Vinit provided. Assume that there are more than one input records because while there may be only 1 example record, it is likely that when this runs for "real" there will be multiples.

The "solution" as posted will not do what Vinit needs. I doubt that FILE1 would be opened as output. FILE2 is not opened at all. If the posted code was eventually made to run, it would add a literal to whatever data was in the first input record possibly moving the literal over some of the good data.

We'll be here for version2 icon_smile.gif
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 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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top