Reputation: 35
I need to split two different types of records in a Perl program. Every record comes with a distinct code (ZBKPF_W and ZBUS2081_W) so they have different processing depending on that.
The information comes from parsing the file name and at the end I should get the right command based on the right parsed fields. However, the if command in Perl apparently does not obey it and in half of the cases, I get the wrong data.
Please allow me to show the process: 2 different types of documents to process that need to be split:
# get info from filename and process each file
# BO-CC-FY-DOCID-KOFAX#.PDF
# ZBKPF_W-DE10-2020-1900000001-00034113.PDF and
# ZBUS2081_W-DE10-2019-5106000000-00034114.PDF
( $fileindex, $filetype) = split( '\.', $dir[i] );
$fname = $dir[i];
$BO = "";
$CCode = "";
$FY = "";
$DocNo = "";
$KofaxNo = "";
$CCDocNoFY = "";
$CCFYDocNo = "";
# Get the index values from filename
( $BO, $CCode, $FY, $DocNo, $KofaxNo ) = split( '\-', $fileindex );
if ( $BO == "ZBKPF_W" ) {
$R3_SAP_OBJ = "ZBKPF_W";
$CCDocNoFY = $CCode.$DocNo.$FY;
$CCFYDocNo = $CCode.$FY.$DocNo;
}
else {
if ( $BO == "ZBUS2081_W" ) {
$R3_SAP_OBJ = "ZBUS2081_W";
$CCDocNoFY = $DocNo.$FY;
$CCFYDocNo = $FY.$DocNo;
}
}
So, at the end, all the records look like ZBUS2081_W Results:
$R3_SAP_OBJ = "ZBBUS2081_W"
$CCDocNoFY = $DocNo.$FY
$CCFYDocNo = $FY.$DocNo
always provides the else of the if command.
The correct results should be:
For ZBKPF_W-DE10-2020-1900000001-00034113.PDF
$R3_SAP_OBJ = "ZBKPF_W"
$CCDocNoFY = "DE1019000000012020"
$CCFYDocNo = "DE1020201900000001"
For ZBUS2081_W-DE10-2019-5106000000-00034114.PDF
$R3_SAP_OBJ = "ZBUS2081_W"
$CCDocNoFY = "51060000002019"
$CCFYDocNo = "20195106000000"
I have tried to use nested IF, ELSEIF and also using local variables with MY Same results... I don't usually prefer Perl, so I far from an expert but this is a requirement for ArchiveLink, so I need it to run smoothly.
Please, if you have an idea why could be the root cause of the issue, I will appreciate that.
Upvotes: 1
Views: 74