psci (PeopleSoft-CCC/Harvest checkin)

The PeopleSoft checkin Perl script is used by developers to modify their batch interface programs (batch programs that interface between the PeopleSoft system and the mainframe). The SCM tool that this script interacts with is CCC/Harvest.
#!/usr/local/bin/perl
#*************************************************************************
#* Script Name:      psci  (PeopleSoft checkin)
#* Creation Date:    8/1/98 
#* Location:         
#* Calling Routine:  NONE
#* Input Parameters: NONE
#* Associated Files: listpackages.sql listitems.sql
#* Description:      Checks in files that have been previously been checked
#*                   out in Harvest.
#* Change Log
#* Name            Date   Change
#* --------------- ------ ------------------------------------------------
#* Paul McKinney   8/1/98 Creation
#*                   
#*************************************************************************

#********************************************************************
#* MAINLINE 
#*
#* -set base directory where files will be checked in to  
#* -clear screen
#* -call subroutine to have user select package
#* -call subroutine to have user select item to check in from package
#* -if item is a type of "pco" then
#*    compile cobol program
#* -call subroutine to check in module into Harvest
#* -synchronize module out to appropriate directory
#********************************************************************
$sqlpath="/usr/local/bin";
$repository="ISAS";

system("clear");
&select_environment;
&select_package;
while (1) {
   &select_harvest_item;

&select_checkin_mode;

   &checkin_module;
   if ($envbase ne "" )  {
      &synchronize_module;
   }
}


#********************************************************************
#* select_environment
#*
#********************************************************************
sub select_environment {
   print "Check In\n\n";
   print "1) PS-Sybase v7.5 Baseline\n";
   print "2) PS-Sybase v7.5 with ISAS Mods\n";
   print "3) PS-Sybase v7 Baseline\n";
   print "4) PS-Sybase v7 with ISAS Mods\n\n";
   print "5) PS-Oracle v7.5 Baseline\n";
   print "6) PS-Oracle v7.5 with ISAS Mods\n";
   print "7) PS-Oracle v7 Baseline\n";
   print "8) PS-Oracle v7 with ISAS Mods\n\n";

   print "Select a environment: ";
   $selection = <STDIN>;
   chop($selection);

   if($selection  eq "1") {
      $environmentname = "PS-Sybase v7.5 Baseline";
      $statename = "Receive";
      $envbase=""; 
      $environmentcode = "s75bas"
   } elsif ($selection eq "2") {
      $environmentname = "PS-Sybase v7.5 with ISAS Mods";
      $statename = "Development";
      $envbase="/psoftSYD/ps75/syb/dev";
      $environmentcode = "s75dev"
   } elsif ($selection eq "3") {
      $environmentname = "PS-Sybase v7 Baseline";
      $statename = "Receive";
      $envbase=""; 
      $environmentcode = "s7bas"
   } elsif ($selection eq "4") {
      $environmentname = "PS-Sybase v7 with ISAS Mods";
      $statename = "Development";
      $envbase="/psoftSYD/ps70/syb/dev";
      $environmentcode = "s7dev"
   } elsif ($selection eq "5") {
      $environmentname = "PS-Oracle v7.5 Baseline";
      $statename = "Receive";
      $envbase=""; 
      $environmentcode = "s75bas"
   } elsif ($selection eq "6") {
      $environmentname = "PS-Oracle v7.5 with ISAS Mods";
      $statename = "Development";
      $envbase="/psoftSYD/ps75/ora/dev";
      $environmentcode = "s75dev"
   } elsif ($selection eq "7") {
      $environmentname = "PS-Oracle v7 Baseline";
      $statename = "Receive";
      $envbase=""; 
      $environmentcode = "s7bas"
   } elsif ($selection eq "8") {
      $environmentname = "PS-Oracle v7 with ISAS Mods";
      $statename = "Development";
      $envbase="/psoftSYD/ps70/ora/dev";
      $environmentcode = "s7dev"
   } else {
      exit;
   }

}


#********************************************************************
#* select_package
#*
#* -call harvest hsql program to list packages
#* -while  there are more packages
#*    store package names in an array
#* -get input from user
#* -if selection equal "q" then exit
#* -based on user selection store package name
#********************************************************************
sub select_package {
   print "\nIn order to check in a module the changed module must be\n";
   print "associated with a package. Retrieving packages...\n\n";
   open(CMD, "cat $sqlpath/listpackages.sql | sed \"s/\\[environmentname\\]/$environmentname/g\" | sed \"s/\\[statename\\]/$statename/g\" | /tools/Harvest/bin/hsql -t -s -nh |");
   $i = 1;
   while (<CMD>) {
      @packages = (@packages, $_);
      print "$i) $_";
      ++$i;
   }
   close(CMD);
   print "q) Quit\n\n";

   print "Select a package: ";
   $selection = <STDIN>;
   chop($selection);
   if ($selection  eq "q") {
      exit;
   }
   print "\n";
   $packagename = $packages[$selection - 1];
   chop($packagename);
}


#********************************************************************
#* select_harvest_item
#*
#* -modify sql statement to include package name in WHERE clause and 
#*  send have hsql call the sql to return the Harvest items in the package
#* -while there are more items
#*     get itemstatus, item name, and the item's view path in Harvest
#*     append information into items array
#*     list out informaiton to screen
#* -have user select item from list
#* -store name and viewpath
#* -put "/" in front of viewpath
#********************************************************************
sub select_harvest_item {
   open(CMD, "cat $sqlpath/listitems.sql | sed \"s!\\[packagename\\]!$packagename!g\" | sed \"s/\\[environmentname\\]/$environmentname/g\" | /tools/Harvest/bin/hsql -t -s -nh |");
   $i = 1;
   while (<CMD>) {
     ($itemstatus, $item, $viewpath, $creator) = split /\t/, $_;
     @items = (@items, $item);
     @viewpathlist = (@viewpathlist, $viewpath);
     print "$i) $_";
     ++$i;
   }
   close(CMD);
   print "q) Quit\n\n";
   print "(N)ormal, (R)eserved, (M)erged, (D)eleted\n\n";

   print "Select a module for check in: ";
   $selection = <STDIN>;
   chop($selection);

   if ($selection  eq "q" || $selection eq "") {
      exit;
   }

   print "\n\n";
   $itemname = $items[$selection - 1];
   $viewpathname = $viewpathlist[$selection - 1];
   chop ($viewpathname);
   $viewpathname = "/$viewpathname"
}


#********************************************************************
#* select_checkin_mode
#*
#* 
#*
#********************************************************************
sub select_checkin_mode {

   print "1) Update and Release\n";
   print "2) Update and Keep\n";
   print "3) Release Only\n\n";

   print "Select check in mode: ";
   $selection = <STDIN>;
   chop($selection);

   if($selection  eq "1") {
      $checkin_mode = "-ur"
   } elsif ($selection eq "2") {
      $checkin_mode = "-uk"
   } elsif ($selection eq "3") {
      $checkin_mode = "-ro"
   } else {
      exit;
   }
}


#********************************************************************
#* checkin_module
#*
#* -use Harvest hci to check in module
#********************************************************************
sub checkin_module {
   print "Checking in module: $itemname\n";
   if ($viewpathname =~ /^\/$repository\/tools/) {
      chmod(0550,$itemname);
   } else {
      chmod(0440,$itemname);
   }
   $flag = FALSE;
   open(CMD,"hci -en \"$environmentname\" -st \"$statename\"                                            -p \"$packagename\" -vp \"$viewpathname\" $checkin_mode                         -op p \"$itemname\" |");
   while (<CMD>) {
      $printline = $_;
      print "$printline";
      if (substr($_, 0, 1) eq "E") {
         $flag = TRUE;
      }
   }
   close(CMD);
   if ($flag eq "TRUE") {
       exit;
   }
   print "Check in successful.\n";
}
 

#********************************************************************
#* synchonize_module
#*
#* -change directories and use sudo to call hco command to check out
#*  Harvest item
#* -if a pco file then 
#*    move object code and file listing to appropriate directories
#* -if item from sqr path then checkout to sqr directory
#* -if item from tools path then checkout to tools directory
#* -if item from cust path then checkout to cust directory
#********************************************************************
sub synchronize_module {
   print "synchronizing...\n";
   if ($viewpathname =~ /^\/$repository\/src/) {
      system ("cd $envbase/src; sudo -u psoft /tools/Harvest/bin/hco                            -en \"$environmentname\" -st \"$statename\"                                           -pn \"Synchronize\" -p \"$packagename\"                           -vp \"/$repository/src/\" -sy -op p -r -s $itemname");
   }
   if ($itemname =~ /\.sh$/) {
      system ("sudo -u psoft /home/psoft/scripts/harpsrun $environmentcode                     putshell $itemname")
                     && die "putshell of $itemname failed";
   }
   if ($viewpathname =~ /^\/$repository\/sqr/) {
      system ("cd $envbase/sqr; sudo -u psoft /tools/Harvest/bin/hco                         -en \"$environmentname\" -st \"$statename\"                                            -pn \"Synchronize\" -p \"$packagename\"                                         -vp \"/$repository/sqr/\" -sy -op p -r -s $itemname");
   }
   if ($viewpathname =~ /^\/$repository\/tools/) {
      system ("cd $envbase/tools; sudo -u psoft /tools/Harvest/bin/hco                       -en \"$environmentname\" -st \"$statename\"                                           -pn \"Synchronize\" -p \"$packagename\"                                         -vp \"/$repository/tools/\" -sy -op p -r -s $itemname");
   }
   if ($viewpathname =~ /^\/$repository\/cust/) {
      system ("cd $envbase/cust; sudo -u psoft /tools/Harvest/bin/hco                        -en \"$environmentname\" -st \"$statename\"                                            -pn \"Synchronize\" -p \"$packagename\"                                         -vp \"/$repository/cust/\" -sy -op p -r -s $itemname");
   }
}