#!/devtool/local/bin/perl
#	@(#)err	6.2.7	1996-08-01	    dia1:dialadm
#
#	Ausgabe des Meldungstextes zu einer Fehlernummer
#
#    ========== licence begin  GPL
#    Copyright (C) 2001 SAP AG
#
#    This program is free software; you can redistribute it and/or
#    modify it under the terms of the GNU General Public License
#    as published by the Free Software Foundation; either version 2
#    of the License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#    ========== licence end
#


use Env;

if ( $RELVER eq "R61" ) {
   $BASEDIR="$DBROOT/env";
} else {
   $BASEDIR="$DBROOT/env/en";
}


if  ( @ARGV != 1 ) {
     print "Usage: err <msgno>";
     exit 100;
}

$no=$ARGV[0];

chdir( $BASEDIR );

opendir(DIR, "$BASEDIR");

if ( $RELVER eq "R61" ) {
   @Files = grep /.enm$/, readdir(DIR);
} else {
   @Files = grep /M\.en$/, readdir(DIR);
}


closedir(DIR);

foreach $File (@Files) {
       open (INFILE, "<$File");
       while (<INFILE>) {
	  if ( /(DEU|ENG)\s+$no/ ) {
	      @list = split / +/, $_;
              foreach $field (@list) {
                 if ( $field == $no ) {
                 print "$File: $_";
                 close (INFILE);
                 exit;
	         }
	     }
          }
       }
       close ($INFILE);
}

print "msgno is not defined";


