move force 901 block so it happens outside of the adding holdings
authorJames Fournie <jfournie@sitka.bclibraries.ca>
Fri, 7 Oct 2011 20:48:35 +0000 (13:48 -0700)
committerJames Fournie <jfournie@sitka.bclibraries.ca>
Fri, 7 Oct 2011 20:48:35 +0000 (13:48 -0700)
Signed-off-by: James Fournie <jfournie@sitka.bclibraries.ca>
marc_export_custom/marc_export_custom

index 75178af..d6993c8 100755 (executable)
@@ -241,6 +241,18 @@ sub export_record {
             add_bib_holdings($bib, $r);
         }
 
+        if($force901){
+            $r->delete_field( $r->field('901') );
+            $r->append_fields(
+                MARC::Field->new(
+                    '901', ' ', ' ',
+                    a => $bib->tcn_value,
+                    b => $bib->tcn_source,
+                    c => $bib->id
+                )
+            );
+        }
+
         if ($format eq 'XML') {
             my $xml = $r->as_xml_record;
             $xml =~ s/^<\?.+?\?>$//mo;
@@ -268,6 +280,18 @@ sub export_record {
             try {
                 my $r = MARC::Record->new_from_xml( $mfhd->marc, $encoding, $format );
 
+                if($force901){
+                    $r->delete_field( $r->field('901') );
+                    $r->append_fields(
+                        MARC::Field->new(
+                            '901', ' ', ' ',
+                            a => $bib->tcn_value,
+                            b => $bib->tcn_source,
+                            c => $bib->id
+                        )
+                    );
+                }
+
                 if ($format eq 'XML') {
                     my $xml = $r->as_xml_record;
                     $xml =~ s/^<\?.+?\?>$//mo;
@@ -554,18 +578,7 @@ sub add_bib_holdings {
                         )
                     );
 
-                    if($force901){
-                        $r->delete_field( $r->field('901') );
-                        $r->append_fields(
-                            MARC::Field->new(
-                                '901', ' ', ' ',
-                                a => $bib->tcn_value,
-                                b => $bib->tcn_source,
-                                c => $bib->id
-                            )
-                        );
 
-                    }
 
                     stats() if (! ($count{cp} % 100 ));
                 } # for cnmap