Ok, I will accept that, not sure of the time-table, may be a week; I have just started some other changes;
also it is easier if you login to sourceforge
Last edit: Bruce Martin 2016-08-09
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Bruce,
Thanks for providing the update. I will try it
To answer your questions
providing both of the below will be useful
---- provide a field and have it inserted in the correct place with fields shuffled down
---- provide an Index and name/type/length
Also one more use case that I can think which may be useful is merging of two copybooks
essentially a application of add field operation
Append fields from 2 ExternalRecord
public ExternalRecord merge(ExternalRecord ext1, ExternalRecord ext2)
Append 2 field lists
public ExternalRecord merge(ExternalField []ef1, ExternalField []ef2)
Thanks
Immanuel
Last edit: Bruce Martin 2016-08-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
provide a field and have it inserted in the correct place with fields shuffled down. It provides three shuffle options
No shuffle
Shuffle by field-length
Calculate shuffle amount based on the insert option
With regards to the first option - Append 2 ExternalRecords, there is the newMultiCopybookIOBuilder builder. It allows multiple Cobol copybooks to be loaded into the one ExternalRecord. Usage:
"Append 2 field lists" is similar to newMultiCopybookIOBuilder mentioned in your response.
say ef1 has 10 fields and ef2 has 5 fields, then the method will create a new ExternalRecord having 15 fields with ef2 added to the end of ef1 with their positions adjusted. But for now I think the newMultiCopybookIOBuilder should suffice for my requirements
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Bruce,
My ask is simple. A single record in a file is represented by 2 copybooks ie., 1 to 200 bytes is copybook A and 201 to 900 bytes is copybook B. So when I have this file as input, I would require to combine these 2 copybooks to format the records. Let me know if you want me to explain further
Last edit: Immanuel Stephen 2016-08-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I will update the newMultiCopybookIOBuilder so that you can set an initial position for the copybook
Initially I allow setting an integer starting position; but will ultimately support
Regarding newMultiCopybookIOBuilder you had mentioned that "It will create a multi-record copybook". But I want to create a single record copybook created out of these multiple copybooks. is that possible ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"Do you really need to insert fields and have subsequent fields shuffle down ???" ..... this is required in a use case where I visually display a copybook and allow the user insert fields.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can add a new field into a ExternalRecord e.g.
But -
Constructing an IOBuilder from an ExternalRecord:
View and moderate all "support-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Support Requests"
Ok I would like to insert the field in the middle so that the offsets get adjusted automatically. Can this be provided as an enhancement ?
Ok, I will accept that, not sure of the time-table, may be a week; I have just started some other changes;
also it is easier if you login to sourceforge
Last edit: Bruce Martin 2016-08-09
How do you want it to work
I have created a updated version of JRecord (JRecord_Version_0.81.1_update1.7z) with the requested changes. You can download from:
https://sourceforge.net/projects/jrecord/files/jrecord/Version_0.81.1
Subversion ( https://sourceforge.net/p/jrecord/code/HEAD/tree/ ) has also been updated
Bruce,
Thanks for providing the update. I will try it
To answer your questions
providing both of the below will be useful
---- provide a field and have it inserted in the correct place with fields shuffled down
---- provide an Index and name/type/length
Also one more use case that I can think which may be useful is merging of two copybooks
essentially a application of add field operation
Append fields from 2
ExternalRecord
public ExternalRecord merge(ExternalRecord ext1, ExternalRecord ext2)
Append 2 field lists
public ExternalRecord merge(ExternalField []ef1, ExternalField []ef2)
Thanks
Immanuel
Last edit: Bruce Martin 2016-08-17
I have provided
shuffle
optionsWith regards to the first option - Append 2 ExternalRecords, there is the newMultiCopybookIOBuilder builder. It allows multiple Cobol copybooks to be loaded into the one ExternalRecord. Usage:
It will create a
multi-record
copybooknot sure if anyone has used that option though..
Not sure I understand the usage case of "merging" 2 lists or how the merge would work. I can understand adding fields / records
at a certain point
I will think about
provide an Index and name/type/length
Last edit: Bruce Martin 2016-08-17
"Append 2 field lists" is similar to
newMultiCopybookIOBuilder
mentioned in your response.say ef1 has 10 fields and ef2 has 5 fields, then the method will create a new
ExternalRecord
having 15 fields with ef2 added to the end of ef1 with their positions adjusted. But for now I think thenewMultiCopybookIOBuilder
should suffice for my requirementsCan you explain the situations you are facing ???
I would like to think about
the best way to handle it before I start coding ???
Bruce,
My ask is simple. A single record in a file is represented by 2 copybooks ie., 1 to 200 bytes is copybook A and 201 to 900 bytes is copybook B. So when I have this file as input, I would require to combine these 2 copybooks to format the records. Let me know if you want me to explain further
Last edit: Immanuel Stephen 2016-08-18
It depends,
if you have a filler at the start of the second copybook:
Then use newMultiCopybookIOBuilder
If the second copybook does not contain the 200 byte filler but starts with
03 level
Read both copybooks into a string variables, concentan
:::cobol
03 Cobpybook-2.
:::java
if the 2nd copybook starts with 01 and does not contain the filler at the start. Let me know
and I will look at changes. But You could do
Then update all the fields in the second record
ioBulder = JRecordInterface1.COBOL
.newMultiCopybookIOBuilder("Merged-Copybooks")
.addCopyBook("Copybook1.cbl")
....
.addCopyBook("Copybook2.cbl")
....;
xRecord = ioBuilder.getExternalRecord();
ExternalField[] fields = xRecord.getRecord(1).getRecordFields();
for (ExternalField f : fields) {
f.setPos(f.getPos() + 200);
}
my case is "if the 2nd copybook starts with 01 and does not contain the filler at the start."
I will update the newMultiCopybookIOBuilder so that you can set an initial position for the copybook
Initially I allow setting an integer starting position; but will ultimately support
What you some times see in cobol is
Where the variable part is described by multiple copybooks.
You seem to have a variation on this. The above changes should
handle this situation.
Hopefully have something next week.
Regarding
newMultiCopybookIOBuilder
you had mentioned that "It will create a multi-record copybook". But I want to create a single record copybook created out of these multiple copybooks. is that possible ?It returns a multiple record layout, but it should not matter if you are accessing by field / field-name.
you can do
Internally JRecord tries to follow Cobol rather than Java. It encodes/decodes fields when they are accessed.
Last edit: Bruce Martin 2016-08-17
ok I will try using
newMultiCopybookIOBuilder
and see if it meets my requirements. Have outlined my requirement in my previous responseI have added JRecord_Version_0.81.1_update2.7z at https://sourceforge.net/projects/jrecord/files/jrecord/Version_0.81.1/
This version allows you to set Starting-Position of a Cobol copy e.g.
or using a field:
Do you really need to
insert fields
and have subsequent fields shuffle down ???I do not understand why you need this ???
Will this upgrade (JRecord_Version_0.81.1_update2.7z) provide the following which was mentioned in one of your previous answers
How does
setStartingPosition
help to achieve this ?Last edit: Bruce Martin 2016-08-23
What you would do is:
"Do you really need to insert fields and have subsequent fields shuffle down ???" ..... this is required in a use case where I visually display a copybook and allow the user insert fields.
I tried something like this :
Last edit: Immanuel Stephen 2016-08-22
That should pretty much work, The one potential problem is if you have a Copybook like
in which case the length is determines by redefined-field which is not the last field.
you would be better to search for the length
with Update2 you can do
to convert the ExternalRecord back into a IOBuilder.