View previous topic :: View next topic
|
Author |
Message |
sandeep.kumar
New User
Joined: 16 Aug 2021 Posts: 11 Location: India
|
|
|
|
Hello Everyone,
Hope all doing good.
Can someone please help me to read and append the record in the same file in cobol ?
Thanks |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
You want to duplicate the record ? Why ? |
|
Back to top |
|
|
sandeep.kumar
New User
Joined: 16 Aug 2021 Posts: 11 Location: India
|
|
|
|
Rohit Umarjikar wrote: |
You want to duplicate the record ? Why ? |
Thanks much for you reply.
I am trying to search the record in the file
one by one until EOF, if record not found append that record in the same file.
Thanks |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
There are many ways .. It’s very simple question so I will move to students forum. Can you not use DFSORT or SYNCSORT and do this task ?
Start from here and also use SEARCH button to find related posts.
ibmmainframes.com/about21963.html |
|
Back to top |
|
|
sandeep.kumar
New User
Joined: 16 Aug 2021 Posts: 11 Location: India
|
|
|
|
Rohit Umarjikar wrote: |
There are many ways .. It’s very simple question so I will move to students forum. Can you not use DFSORT or SYNCSORT and do this task ?
Start from here and also use SEARCH button to find related posts.
ibmmainframes.com/about21963.html |
Thanks for reply.
I am trying to read a file and search the record in the file, if record not found in that file then append that search record in the Same file.
Note- I don’t want to use two steps for this. I am trying to do using cobol in one step.
Thanks. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
I am not quite sure what you are trying to do here. If you have two data sets to work on and one being the master and other is finder then if record from master don’t present in finder then you want to write to master ? If found then what ? Tell us the complete Pictor the requirement. |
|
Back to top |
|
|
sandeep.kumar
New User
Joined: 16 Aug 2021 Posts: 11 Location: India
|
|
|
|
Sir,
I have only one dataset. The record need to be search are passing from ‘JCL PARM’ in COBOL.
1. Search string passing through PARM
2. Open input file1
2. Read a file1, search the strings in the file until eof.
If ws-record of file1 = search string
Move ‘ Y’ to EOF.
Close file1
Else
Perform Append-para through exit- append
End-if.
Append-para.
Open extend file1
Move ‘search string’ to ws-file1.
Write file1-record.
Close file1.
Exit-append.
Exit.
Something like above, I am trying to do. Is it possible? What would be the Jcl disp parameter? Can I use two DD name for the same file name?
File1 DD DSN=abc, disp=shr
File2 DD DSN=abc, disp=mod
Thanks |
|
Back to top |
|
|
sandeep.kumar
New User
Joined: 16 Aug 2021 Posts: 11 Location: India
|
|
|
|
Sir,
I have only one dataset. The record need to be search are passing from ‘JCL PARM’ in COBOL.
1. Search string passing through PARM
2. Open input file1
2. Read a file1, search the strings in the file until eof.
If ws-record of file1 = search string
Move ‘ Y’ to EOF.
Close file1
Else
Perform Append-para through exit- append
End-if.
Append-para.
Open extend file1
Move ‘search string’ to ws-file1.
Write file1-record.
Close file1.
Exit-append.
Exit.
Something like above, I am trying to do. Is it possible? What would be the Jcl disp parameter? Can I use two DD name for the same file name?
File1 DD DSN=abc, disp=shr
File2 DD DSN=abc, disp=mod
Thanks |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2141 Location: USA
|
|
|
|
sandeep.kumar wrote: |
Sir,
I have only one dataset. The record need to be search are passing from ‘JCL PARM’ in COBOL.
1. Search string passing through PARM
2. Open input file1
2. Read a file1, search the strings in the file until eof.
If ws-record of file1 = search string
Move ‘ Y’ to EOF.
Close file1
Else
Perform Append-para through exit- append
End-if.
Append-para.
Open extend file1
Move ‘search string’ to ws-file1.
Write file1-record.
Close file1.
Exit-append.
Exit.
Something like above, I am trying to do. Is it possible? What would be the Jcl disp parameter? Can I use two DD name for the same file name?
File1 DD DSN=abc, disp=shr
File2 DD DSN=abc, disp=mod
Thanks |
In order to use datasets in this manner, IBM has introduced the VSAM datasets, about 40+ years ago.
For a physically sequential dataset it is not normal way of use. It is possible, but is as inconvenient as walking on your head rather than on your feet. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2141 Location: USA
|
|
|
|
sandeep.kumar wrote: |
Something like above, I am trying to do. Is it possible? What would be the Jcl disp parameter? Can I use two DD name for the same file name?
Code: |
//ddname1 DD DSN=abc,disp=shr
//ddname2 DD DSN=abc,disp=mod
|
Thanks |
Even in this case you don’t need two different ddnames.
Use only one single ddname with DISP=MOD
First time OPEN it for input in your COBOL code. For input, MOD is equivalent to OLD.
When your record has been found, or you have reached EOF, then do not forget to CLOSE it.
Next re-OPEN with the same ddname, but for output (as separate one within COBOL code). In this case DISP=MOD takes its effect, and the dataset after OPEN would be positioned after its last record. Whatever you WRITE at this moment should become the very last (new) record of your dateset.
As I mentioned in my previous message, this is possible but is not considered as normal way of usage for a sequential (PS) dataset.
P.S. You are kindly requested to format your messages in an accurate manner. Use code tags when needed, use CAPS characters when needed - especially when it is strictly required by the programming language syntax.
Otherwise the readers would not consider you as a serious software engineer… |
|
Back to top |
|
|
sandeep.kumar
New User
Joined: 16 Aug 2021 Posts: 11 Location: India
|
|
|
|
sergeyken wrote: |
sandeep.kumar wrote: |
Something like above, I am trying to do. Is it possible? What would be the Jcl disp parameter? Can I use two DD name for the same file name?
Code: |
//ddname1 DD DSN=abc,disp=shr
//ddname2 DD DSN=abc,disp=mod
|
Thanks |
Even in this case you don’t need two different ddnames.
Use only one single ddname with DISP=MOD
First time OPEN it for input in your COBOL code. For input, MOD is equivalent to OLD.
When your record has been found, or you have reached EOF, then do not forget to CLOSE it.
Next re-OPEN with the same ddname, but for output (as separate one within COBOL code). In this case DISP=MOD takes its effect, and the dataset after OPEN would be positioned after its last record. Whatever you WRITE at this moment should become the very last (new) record of your dateset.
As I mentioned in my previous message, this is possible but is not considered as normal way of usage for a sequential (PS) dataset.
P.S. You are kindly requested to format your messages in an accurate manner. Use code tags when needed, use CAPS characters when needed - especially when it is strictly required by the programming language syntax.
Otherwise the readers would not consider you as a serious software engineer… |
Thanks much for your help and suggestion. It’s worked. And sorry for format, i use phone. Can’t cut and paste exact format code. But next time will try to type in correct format with proper indentation. |
|
Back to top |
|
|
|