Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Create and update same file in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
shanhsar

New User


Joined: 25 Sep 2012
Posts: 2
Location: India

PostPosted: Tue Sep 25, 2012 11:20 am    Post subject: Create and update same file in cobol
Reply with quote

Hi Friends,

I need your urgent experts on below issue that am facing..

I am trying to create 1 output file in cobol program when it exeutes first time, and update the same output file when I execute it second time.... thereafter file should update like second time in every execution of program.

O/p file on first run..

Code:
# Issuer Code: HBC.WHLRSA                   
# Job Type: ADDUPDEL                         
# Sequence Number: 000000000000000001       
# Number of Fields: 6                       
# Delimiter: |                               
# FI ID: hsbca                               

O/p file on second run or so..(Sequence Number shud increase everytime with 2 and rest of fileds will be same.

Code:
# Issuer Code: HBC.WHLRSA                   
# Job Type: ADDUPDEL                         
# Sequence Number: 000000000000000003       
# Number of Fields: 6                       
# Delimiter: |                               
# FI ID: hsbca   



My code.. opened the file in I-O mode then
Code:
      READ OUTPUT-FILE             INTO  WS-OUNTPUT-FILE 
      IF  WS-ISSUER-CODE NOT EQUAL 'HBC.WHLRSA'                     
          ADD +1                   TO WS-SEQ-NBR             
          MOVE 'HBC.WHLRSA'        TO WS-ISSUER-CODE           
          PERFORM D1100-WRITE-OUPTUT-FILE       
            THRU D1100-WOF-EXIT                                 
      ELSE                                                     
           ADD +2                   TO WS-SEQ-NBR         
           MOVE 'HBC.WHLRSA'        TO WS-ISSUER-CODE
           PERFORM D1100-WRITE-OUPTUT-FILE       
              THRU D1100-WOF-EXIT           


In D1100-WRITE-OUPTUT-FILE am moving rest of the fields.

I am able to create the correct o/p file from above code but unable to update it..It never went to else para..I tried multiple ways but still failing to achieve the result.

Please let me know your suggestion on this issue.

Code'd
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Sep 25, 2012 11:41 am    Post subject: Reply to: Create and update same file in cobol
Reply with quote

Your posted has been Code'd and the title edited for readability.

Can you show the definition of WS-OUNTPUT-FILE. Also your SELECT and the FD with everything associated with it.

Why is there no fullstop/period associated with the IF that you have shown?
Back to top
View user's profile Send private message
shanhsar

New User


Joined: 25 Sep 2012
Posts: 2
Location: India

PostPosted: Tue Sep 25, 2012 12:04 pm    Post subject:
Reply with quote

Thanks for your quick reply Bill..
Please find the details below..also i have properly closed the loop in my code.


Select statement..

Code:
001400     SELECT  OUTPUT-FILE                                         
001500             ASSIGN              TO OUTPUT                       
001600             ORGANIZATION        IS SEQUENTIAL                   
001700             ACCESS MODE         IS SEQUENTIAL                         
001900*                                                     

FD Section..
Code:
FD  OUTPUT-FILE                               
      RECORDING MODE IS F.                       
01  OUTPUT-RECORD               PIC X(121).   

WS section...
Code:
01  WS-OUNTPUT-FILE.               
  02  WS-RSA-EMP-HEADER1.                                     
    05  WS-ISSUER           PIC X(15)   VALUE             
                                            '# Issuer Code: '.
    05  WS-ISSUER-CODE          PIC X(10).                     
  02  WS-RSA-EMP-HEADER2.                                     
    05  FILLER                  PIC X(12)   VALUE             
                                            '# Job Type: '.   
    05  FILLER                  PIC X(10)   VALUE             
                                            'ADDUPDEL'.       
  02  WS-RSA-EMP-HEADER3.                                       
    05  FILLER                  PIC X(19)   VALUE               
                                      '# Sequence Number: '.     
    05 WS-SEQ-NBR             PIC 9(18).                       
  02  WS-RSA-EMP-HEADER4.                                       
    05  FILLER                  PIC X(20)   VALUE               
                                      '# Number of Fields: '.   
    05  FILLER                  PIC X(02)   VALUE               
                                            '6'.                 
  02  WS-RSA-EMP-HEADER5.                                       
    05  FILLER                  PIC X(13)   VALUE               
                                            '# Delimiter: '.     
    05  FILLER                  PIC X(01)   VALUE               
                                            '|'.                 
  02  WS-RSA-EMP-HEADER6.                                   
    05  FILLER                  PIC X(09)   VALUE           
                                            '# FI ID: '.     
    05  FILLER                  PIC X(20)   VALUE           
                                            'hsbca'.         
                                         

populating para..
Code:
D1100-WRITE-OUPTUT-FILE.                                         
      WRITE HRDEMH-RECORD      FROM WS-RSA-EMP-HEADER1.       
      WRITE HRDEMH-RECORD      FROM WS-RSA-EMP-HEADER2.       
      WRITE HRDEMH-RECORD      FROM WS-RSA-EMP-HEADER3.       
      WRITE HRDEMH-RECORD      FROM WS-RSA-EMP-HEADER4.       
      WRITE HRDEMH-RECORD      FROM WS-RSA-EMP-HEADER5.       
      WRITE HRDEMH-RECORD      FROM WS-RSA-EMP-HEADER6.       
D1100-WOF-EXIT.


Code'd (again)
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Sep 25, 2012 1:51 pm    Post subject: Reply to: Create and update same file in cobol
Reply with quote

Please use the Code tags to preserve formatting of anything which you want to appear as you have formatted it. If you don't know how, press Quote on the above and you'll see.

This is thoroughly confusing.

You read one record. Then you do you test. Then you WRITE six records.

You don't do a REWRITE at any point, so I don't know how you expect to update anything.

What does your actual output dataset look like?

You don't do any error-checking (you haven't specified FILE-STATUS), does your site use DECLARATIVES?
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue Sep 25, 2012 7:00 pm    Post subject:
Reply with quote

Hello,

Rarely (if ever) should a sequential file be input and output to the same step.

Suggest you simply copy the file making the needed changes to the new output file.

If the process ends unexpectedly in the middle, you have destroyed the input file.
Back to top
View user's profile Send private message
ezio vin

New User


Joined: 16 Aug 2012
Posts: 44
Location: india

PostPosted: Wed Sep 26, 2012 2:38 pm    Post subject:
Reply with quote

yes i agree that dick
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1894
Location: UK

PostPosted: Wed Sep 26, 2012 3:47 pm    Post subject:
Reply with quote

Code:
READ OUTPUT-FILE             INTO  WS-OUNTPUT-FILE

Somewhat confusing - if not to you then to those who follow. We ars till not clear as to what you are trying to do but it looks lioke you need a program to create the file which would feed into another program that would update that first file and create a second file which would then go into the second program which would update it by creating a third file etc.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us