IMS status code

IMS status LB: Segment already exists in load

IMS status code LB means an ISRT in a load program (PROCOPT=L or LS) tried to add a segment that already exists. Either a twin with the same sequence field is already loaded, or the segment type allows only one occurrence per parent.

Other names for this code

Also written as status code LB, IMS LB, DL/I status LB, LB status code, IMS load duplicate.

What it means

A database is first built by a load program. The load PCB has PROCOPT=L or LS, and the program issues only ISRT calls, feeding segments in hierarchic order. IMS checks each one as it arrives. If the new segment duplicates one already loaded under the same parent, IMS returns LB and doesn't load it.

Two situations produce LB. The first is a twin with the same sequence field value as one already loaded under the same parent. The second is a second occurrence of a segment type that has no physical twin forward pointer, which means the DBD allows only one occurrence of that type per parent. LB is the load-mode cousin of II, which ISRT returns in normal processing.

Load mode has its own family of L status codes. LB means duplicate. Out-of-sequence keys, missing parents and segments out of hierarchic order get other L codes. Only ISRT through a load PCB returns LB, and it's an error in the input data or the load logic.

Common causes

  • The load input file has two records with the same key for the same parent, often after merging files or a bad extract.
  • The input contains two occurrences of a segment type that the DBD defines with no twins.
  • The load program writes the same segment twice, for example in a loop that doesn't advance.
  • A reorganization reload is fed an unload file that contains duplicates, because it was concatenated with another or edited.

How to find the problem

  1. Display the key in the I/O area at the failing ISRT and find the record in the load input.
  2. Search the input for other records with the same key under the same parent.
  3. Look at the segment's definition in the DBD. Check whether its sequence field is unique and whether the segment's pointer options allow twins.
  4. If a reload utility reported LB, check its report for the segment and key, and check how the unload file was built.

How to fix it

  • Remove or merge the duplicate records in the input, then rerun the load from the start.
  • If the segment type really needs more than one occurrence per parent, the DBD must allow twins. That's a DBD change and needs a full unload and reload.
  • Fix the load program's loop so each input record is inserted once.
  • Rebuild the unload file from a clean unload rather than editing it.

IBM documentation

IBM documentation: status LB. Use the documentation for your installed release.

Report a correction to WND Software.

Questions

What is the difference between LB and II?

Both mean a duplicate segment. LB comes back in load mode (PROCOPT=L or LS), and II in normal update processing.

Can I just skip the duplicate and keep loading?

IMS doesn't load the segment that got LB, so a program can report it and carry on. Whether that's acceptable depends on whether the duplicate was a true repeat or two different records with a bad key.

Which calls return LB?

Only ISRT through a load-mode PCB.