Create a 001 field if it doesn't exist in marc_export
authorgmc <gmc@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 20 Apr 2011 14:50:14 +0000 (14:50 +0000)
committergmc <gmc@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 20 Apr 2011 14:50:14 +0000 (14:50 +0000)
Real data has a way of surprising you sometimes, like by not having 001 fields.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_1@20241 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') {