Hierarchical COBOL file with Parent/Child relations
Posted: Thu Oct 01, 2015 6:39 pm
Hi All,
I am trying to read a COBOL File with CFF stage. The file has multiple record types (AB00,AB01,AB02 etc). Each record type will have different length. Sample data is below.
Header -> Abc.txt20150210
Parent -> 00000AB00XXXXXXXX99TTTT
Child 1 -> 00000AB01yy1234
child 2 -> 00000AB02pp123456789
Parent -> 00000AB00ppppppppp77TTTT
Child 1 -> 00000AB01pp2345
child 2 -> 00000AB02ab123456789
Trailer -> Count AB00 2 AB01 2 AB02 2
So I want to add 18,2 position (99 / 77 value) of parent record to the immediate child records. Sample outout as below.
Child 1 -> 9900000AB01yy1234
child 2 -> 9900000AB02pp123456789
Child 1 -> 7700000AB01pp2345
child 2 -> 7700000AB02ab123456789
I have the copybooks for each record types and could able to read the data each record type-wise but I am not able to match parent record value to child as there is no common field between parent and its child so I need to go by the order of parent and child records present in the file.
I tried to read the entire file as single field and dump to sequential file and then loop through the file based on the parent record to make the desired output but due to different field lengths could not able to read the file properly. The order and fields position of records are interchanging (COMP fields also present).
My record schema for CFF stage is below.
{record_format={type=implicit}, delim=none, quote=none, binary, ebcdic, native_endian, charset='ASCL_ISO8859-1', round=round_inf, nofix_zero}
Can any one please let me know how can I get the desired output?
I am trying to read a COBOL File with CFF stage. The file has multiple record types (AB00,AB01,AB02 etc). Each record type will have different length. Sample data is below.
Header -> Abc.txt20150210
Parent -> 00000AB00XXXXXXXX99TTTT
Child 1 -> 00000AB01yy1234
child 2 -> 00000AB02pp123456789
Parent -> 00000AB00ppppppppp77TTTT
Child 1 -> 00000AB01pp2345
child 2 -> 00000AB02ab123456789
Trailer -> Count AB00 2 AB01 2 AB02 2
So I want to add 18,2 position (99 / 77 value) of parent record to the immediate child records. Sample outout as below.
Child 1 -> 9900000AB01yy1234
child 2 -> 9900000AB02pp123456789
Child 1 -> 7700000AB01pp2345
child 2 -> 7700000AB02ab123456789
I have the copybooks for each record types and could able to read the data each record type-wise but I am not able to match parent record value to child as there is no common field between parent and its child so I need to go by the order of parent and child records present in the file.
I tried to read the entire file as single field and dump to sequential file and then loop through the file based on the parent record to make the desired output but due to different field lengths could not able to read the file properly. The order and fields position of records are interchanging (COMP fields also present).
My record schema for CFF stage is below.
{record_format={type=implicit}, delim=none, quote=none, binary, ebcdic, native_endian, charset='ASCL_ISO8859-1', round=round_inf, nofix_zero}
Can any one please let me know how can I get the desired output?