COBOL Copybook - Unknown values

I have created a COBOL copybook file. When i tried to execute the job, i’m getting below error:

Record number <3> in COBOL data file contains unknown value in the Record ID field

After analyzing the data file, found unknown values in the input file. Is it a way to handle any unknown values in the COBOL copybook like Oracle Case statement? Example: REC_TYPE=‘A’ then insert into table A, if REC_TYPE=‘B’ then insert into table B, else NO_ACTION.


rajeshvr06 (BOB member since 2012-10-05)

This is not allowed in Cobol.


Werner Daehn :de: (BOB member since 2004-12-17)

In my experience, this message actually means that there is something wrong with the record prior to the one mentioned i.e. in this example, record 2.
Can you give us a bit more information about your data? What record type are you expecting in record 2 and what are you actually getting?


Nemesis :australia: (BOB member since 2004-06-09)

My sample data file is like this:

EEMP_NAME DESIGNATION DOJ
DDEPT_NAME DEPT_ID
XUNKNOWN_VALUEXXDDDDDDDDDD

and my .cpy file will has the below info:
01 EMP.
02 RECORD_TYPE PIC X(1).
02 EMP_NAME PIC X(30).
02 DESIGNATION PIC X(20).
02 DOJ PIC X(10).

01 DEPT.
02 RECORD_TYPE PIC X(1).
02 DEPT_NAME PIC X(18).
02 DEPT_ID PIC S9(5).

In the bods tool i’ve defined RECORD_TYPE=‘E’ then load to EMP table and RECORD_TYPE=‘D’ then load to DEPT table.


rajeshvr06 (BOB member since 2012-10-05)

Could you type the actual records (including spaces) for data rows 1,2 and 3?


Nemesis :australia: (BOB member since 2004-06-09)

Sorry, i can’t post the actual data it’s confidential data.

Could you please tell me, is it possible to handle if unknown record types are exists in the data file?


rajeshvr06 (BOB member since 2012-10-05)

That’s my point. I don’t think you’ve got an unknown record type. I think you’ve got a previous record that’s either too long or too short for your copybook definition.
If you can’t put the actual data into the post can you anonymise it (keeping the same lengths) and put it here?


Nemesis :australia: (BOB member since 2004-06-09)

Thank you trying to solve my issue.

Could you please confirm about the follow setting in the “Edit COBOL Copybook”

Format:
Expand OCCURS: [Checked]
Ignore redefines: [Unchecked]
Source format: Smart mode
Source codes [start]: 1
Source codes [end]: 9999

Data File:
Record Size: 0
Record Trailer Length: 1
Has Record Mark: [Unchecked]
Integer Format: Big endian
Code page: cp1252
Skip First: {none}
Read Total: {no limit}
Low Value: 0x40
Action: No conversion
High Value: 0xFF
Action: No conversion


rajeshvr06 (BOB member since 2012-10-05)

No problem. I’ve had enough trouble with copybooks in my time so I like to try and help others who are also suffering.
I think your trailer length is incorrect. All the files that I’ve processed with copybooks needed a trailer length of 2. This is because the end of a line has a line feed and a carriage return control character.


Nemesis :australia: (BOB member since 2004-06-09)

I also tried with value 2, but it didn’t even starts to process the row number 1. Value with 1 only worked for me.

what’s your email id?


rajeshvr06 (BOB member since 2012-10-05)

best is to open the source file in a hex editor. Then you can see the file byte by byte and will see if there is a \n char or a \r\n sequence or nothing.


Werner Daehn :de: (BOB member since 2004-12-17)