# Finding an error in ABAP code
# One branch of a large CASE ... WHEN was incorrect
use strict;
use warnings;
my @fields = qw(dismm zz_fnsch mtvfp rdprf mmsta);
my %chgfld;
my $cnt = 0;
my @mask;
foreach my $line (<DATA>) {
chomp $line;
if ($line =~ /when '(.*)'/) {
if ($cnt!=0) {
printf "Error with mask @mask \n";
}
@mask = split '',$1;
%chgfld = ();
$cnt = 0;
foreach my $i (0..4) {
if ($mask[$i] eq 'X') {
$cnt++;
$chgfld{$fields[$i]} = 1;
}
}
next;
}
if ($line =~ /(dismm|zz_fnsch|mtvfp|rdprf|mmsta)/i) {
if (exists $chgfld{lc $1}) {
$cnt--;
}
}
}
__DATA__
when 'X0000'.
* 1 Keine Änderung bei Dispomerkmal
if p_p_dismm eq p_g_t_marc-dismm.
delete p_g_t_marc.
endif.
when '0X000'.
* 2 Keine Änderung bei Nachschubformel
if p_p_fnsch eq p_g_t_marc-zz_fnsch.
delete p_g_t_marc.
endif.
when '00X00'.
* 3 Keine Änderung bei Verfügbarkeit
if p_p_mtvfp eq p_g_t_marc-mtvfp.
delete p_g_t_marc.
endif.
when '000X0'.
* 4 Keine Änderung bei Rundungsprofil
if p_p_rdprf eq p_g_t_marc-rdprf.
delete p_g_t_marc.
endif.
when '0000X'.
* 5 Keine Änderung bei Artikelstatus
if p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'XX000'.
* 6 Keine Änderung bei Dispomerkmal und bei Nachschubformel
if p_p_dismm eq p_g_t_marc-dismm and
p_p_fnsch eq p_g_t_marc-zz_fnsch.
delete p_g_t_marc.
endif.
when '0XX00'.
* 7 Keine Änderung bei Nachschubformel und bei Verfügbarkeit
if p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_mtvfp eq p_g_t_marc-mtvfp.
delete p_g_t_marc.
endif.
when '00XX0'.
* 8 Keine Änderung bei Verfügbarkeit und bei Rundungsprofil
if p_p_mtvfp eq p_g_t_marc-mtvfp and
p_p_rdprf eq p_g_t_marc-rdprf.
delete p_g_t_marc.
endif.
when '000XX'.
* 9 Keine Änderung bei Rundungsprofil und bei Artikelstatus
if p_p_rdprf eq p_g_t_marc-rdprf and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'X0X00'.
* 10 Keine Änderung bei Dispomerkmal und bei Verfügbarkeit
if p_p_dismm eq p_g_t_marc-dismm and
p_p_mtvfp eq p_g_t_marc-mtvfp.
delete p_g_t_marc.
endif.
when '0X0X0'.
* 11 Keine Änderung bei Nachschubformel und bei Rundungsprofil
if p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_rdprf eq p_g_t_marc-rdprf.
delete p_g_t_marc.
endif.
when '00X0X'.
* 12 Keine Änderung bei Verfügbarkeit und bei Artikelstatus
if p_p_mtvfp eq p_g_t_marc-mtvfp and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'X00X0'.
* 13 Keine Änderung bei Dispomerkmal und bei Rundungsprofil
if p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_rdprf eq p_g_t_marc-rdprf.
delete p_g_t_marc.
endif.
when '0X00X'.
* 14 Keine Änderung bei Nachschubformel und bei Artikelstatus
if p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'X000X'.
* 15 Keine Änderung bei Dispomerkmal und bei Artikelstatus
if p_p_dismm eq p_g_t_marc-dismm and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'XXX00'.
* 16 Keine Änderung bei Dispomerkmal, bei Nachschubformel und bei
* Verfügbarkeit
if p_p_dismm eq p_g_t_marc-dismm and
p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_mtvfp eq p_g_t_marc-mtvfp.
delete p_g_t_marc.
endif.
when '0XXX0'.
* 17 Keine Änderung bei Nachschubformel, bei Verfügbarkeit und
* bei Rundungsprofil
if p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_mtvfp eq p_g_t_marc-mtvfp and
p_p_rdprf eq p_g_t_marc-rdprf.
delete p_g_t_marc.
endif.
when '00XXX'.
* 18 Keine Änderung bei Verfügbarkeit, bei bei Rundungsprofil und
* bei Artikelstatus
if p_p_mtvfp eq p_g_t_marc-mtvfp and
p_p_rdprf eq p_g_t_marc-rdprf and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'XX0X0'.
* 19 Keine Änderung bei Dispomerkmal bei Nachschubformel und
* bei Rundungsprofil
if p_p_dismm eq p_g_t_marc-dismm and
p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_rdprf eq p_g_t_marc-rdprf.
delete p_g_t_marc.
endif.
when '0XX0X'.
* 20 Keine Änderung bei Nachschubformel, bei Verfügbarkeit und
* bei Artikelstatus
if p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_mtvfp eq p_g_t_marc-mtvfp and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'X0XX0'.
* 21 Keine Änderung bei Dispomerkmal, bei Verfügbarkeit und
* bei Rundungsprofil
if p_p_dismm eq p_g_t_marc-dismm and
p_p_mtvfp eq p_g_t_marc-mtvfp and
p_p_rdprf eq p_g_t_marc-rdprf.
delete p_g_t_marc.
endif.
when '0X0XX'.
* 22 Keine Änderung bei Nachschubformel, bei Rundungsprofil und
* bei Artikelstatus
if p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_rdprf eq p_g_t_marc-rdprf and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'XX00X'.
* 23 Keine Änderung bei Dispomerkmal, bei Nachschubformel und
* bei Artikelstatus
if p_p_dismm eq p_g_t_marc-dismm and
p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'X00XX'.
* 24 Keine Änderung bei Dispomerkmal, bei Rundungsprofil und
* bei Artikelstatus
if p_p_dismm eq p_g_t_marc-dismm and
p_p_rdprf eq p_g_t_marc-rdprf and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'X0X0X'.
* 25 Keine Änderung bei Dispomerkmal, bei Verfügbarkeit und
* bei Artikelstatus
if p_p_dismm eq p_g_t_marc-dismm and
p_p_mtvfp eq p_g_t_marc-mtvfp and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'XXXX0'.
* 26 Keine Änderung bei Dispomerkmal, bei Nachschubformel, bei
* Verfügbarkeit und bei Rundungsprofil
if p_p_dismm eq p_g_t_marc-dismm and
p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_mtvfp eq p_g_t_marc-mtvfp and
p_p_rdprf eq p_g_t_marc-rdprf.
delete p_g_t_marc.
endif.
when '0XXXX'.
* 27 Keine Änderung bei Nachschubformel, bei Verfügbarkeit, bei
* Rundungsprofil und Artikelstatus
if p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_mtvfp eq p_g_t_marc-mtvfp and
p_p_rdprf eq p_g_t_marc-rdprf and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'X0XXX'.
* 28 Keine Änderung bei Dispomerkmal, bei Verfügbarkeit, bei
* Rundungsprofil und Artikelstatus
if p_p_dismm eq p_g_t_marc-dismm and
p_p_mtvfp eq p_g_t_marc-mtvfp and
p_p_rdprf eq p_g_t_marc-rdprf and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'XX0XX'.
* 29 Keine Änderung bei Dispomerkmal, bei Nachschubformel, bei
* Rundungsprofil und Artikelstatus
if p_p_dismm eq p_g_t_marc-dismm and
p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_rdprf eq p_g_t_marc-rdprf and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'XXX0X'.
* 30 Keine Änderung bei Dispomerkmal, bei Nachschubformel, bei
* Verfügbarkeit und bei Artikelstatus
if p_p_dismm eq p_g_t_marc-dismm and
p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_mtvfp eq p_g_t_marc-mtvfp and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.
when 'XXXXX'.
* 31 Keine Änderung bei Dispomerkmal, bei Nachschubformel, bei
* Verfügbarkeit, bei Rundungsprofil und Artikelstatus
if p_p_dismm eq p_g_t_marc-dismm and
p_p_fnsch eq p_g_t_marc-zz_fnsch and
p_p_mtvfp eq p_g_t_marc-mtvfp and
p_p_rdprf eq p_g_t_marc-rdprf and
p_p_mmsta eq p_g_t_marc-mmsta.
delete p_g_t_marc.
endif.