Create a 001 field if it doesn't exist in marc_export
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 7 Mar 2011 19:30:04 +0000 (19:30 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 7 Mar 2011 19:30:04 +0000 (19:30 +0000)
Real data has a way of surprising you sometimes, like by not having 001 fields.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@19626 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/support-scripts/marc_export

index ecd79a5..3fe5ec1 100755 (executable)
@@ -278,7 +278,12 @@ sub export_record {
 
         if ($replace_001) {
             my $tcn = $r->field('001');
-            $tcn->update($id);
+            if ($tcn) {
+                $tcn->update($id);
+            } else {
+                my $new_001 = MARC::Field->new('001', $id);
+                $r->insert_fields_ordered($new_001);
+            }
         }
 
         if ($format eq 'XML') {