View previous topic :: View next topic
|
Author |
Message |
shanhsar
New User
Joined: 25 Sep 2012 Posts: 2 Location: India
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
shanhsar
New User
Joined: 25 Sep 2012 Posts: 2 Location: India
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
ezio vin
New User
Joined: 16 Aug 2012 Posts: 44 Location: india
|
|
|
|
yes i agree that dick |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
|