Menu

#327 conditional mapping

4.0
open
nobody
5
2015-02-18
2012-03-20
Anonymous
No

It might be smarter to allow some validation within the field mapping itself (to make this less confusing) but also, need a function to more easily collect the row's data to write to an error log.

<trans>

//Main If condition

If(

If(Length(PER_L_NAME_FIRST) > 35,WriteToOperationLog("PER_L_NAME_FIRST exceeds 35 characters: " + PER_L_NAME_FIRST + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true) &&
If(Length(PER_L_NAME_MIDDLE) > 100,WriteToOperationLog("PER_L_NAME_MIDDLE exceeds 100 characters: " + PER_L_NAME_MIDDLE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true) &&
If(Length(PER_L_NAME_LAST) > 40,WriteToOperationLog("PER_L_NAME_LAST exceeds 40 characters: " + PER_L_NAME_LAST + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true) &&
If(Length(PER_L_NAME_SUFFIX) > 6,WriteToOperationLog("PER_L_NAME_SUFFIX exceeds 6 characters: " + PER_L_NAME_SUFFIX + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true) &&
If(Length(PER_GENDER) > 1,WriteToOperationLog("PER_GENDER exceeds 1 character: " + PER_GENDER + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true) &&
If(RegExMatch(PER_DOB,"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$","0002_perdob","0002_perdob_result") == 3,WriteToOperationLog("PER_DOB is not a valid date format: " + PER_DOB + " APP_ID: " +
APP_ID + " Error Message: " + GetLastError());false,true) &&
If(Length(STREET_ADDRESS) > 175,WriteToOperationLog("STREET_ADDRESS exceeds 40 characters: " + STREET_ADDRESS + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true) &&
If(Length(CITY) > 40,WriteToOperationLog("CITY exceeds 40 characters: " + CITY + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true) &&
If(Length(ZIP) > 40,WriteToOperationLog("ZIP exceeds 40 characters: " + ZIP + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true) &&
If(Length(EMAIL) > 150,WriteToOperationLog("EMAIL exceeds 150 characters: " + EMAIL + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(PRIOR_SERVICE) > 1,WriteToOperationLog("PRIOR_SERVICE exceeds 1 character: " + PRIOR_SERVICE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(BASE_CODE) > 2,WriteToOperationLog("BASE_CODE exceeds 2 characters: " + BASE_CODE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(SERVICE_BRANCH_CODE) > 2,WriteToOperationLog("SERVICE_BRANCH_CODE exceeds 2 characters: " + SERVICE_BRANCH_CODE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(RegExMatch(TAFMS,"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$","0002_tafms","0002_tafms_result") == 3,WriteToOperationLog("TAFMS is not a valid date format: " + TAFMS + " APP_ID: " + APP_ID +
" Error Message: " + GetLastError());false,true) &&
If(Length(TAFMS_DAYS) > 100,WriteToOperationLog("TAFMS_DAYS exceeds 100 characters: " + TAFMS_DAYS + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(TAFMS_MONTHS) > 100,WriteToOperationLog("TAFMS_MONTHS exceeds 100 characters: " + TAFMS_MONTHS + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(TAFMS_YEARS) > 100,WriteToOperationLog("TAFMS_YEARS exceeds 100 characters: " + TAFMS_YEARS + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(SPECIALTY_CODE) > 7,WriteToOperationLog("SPECIALTY_CODE exceeds 7 characters: " + SPECIALTY_CODE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(HP_DEGREE) > 1,WriteToOperationLog("HP_DEGREE exceeds 1 characters: " + HP_DEGREE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(LS_CODE) > 3,WriteToOperationLog("LS_CODE exceeds 3 characters: " + LS_CODE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(LSD_CODE) > 4,WriteToOperationLog("LSD_CODE exceeds 4 characters: " + LSD_CODE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(RACE) > 15,WriteToOperationLog("RACE exceeds 15 characters: " + RACE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(PER_HISPANIC_IND) > 1,WriteToOperationLog("PER_HISPANIC_IND exceeds 1 characters: " + PER_HISPANIC_IND + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(ORG_CODE) > 15,WriteToOperationLog("ORG_CODE exceeds 15 characters: " + ORG_CODE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(RegExMatch(LED,"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$","0002_led","0002_led_result") == 3,WriteToOperationLog("LED is not a valid date format: " + LED + " APP_ID: " + APP_ID +
" Error Message: " + GetLastError());false,true) &&
If(RegExMatch(LAR,"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$","0002_lar","0002_lar_result") == 3,WriteToOperationLog("LAR is not a valid date format: " + LAR + " APP_ID: " + APP_ID +
" Error Message: " + GetLastError());false,true) &&
If(RegExMatch(CLOSED,"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$","0002_closed","0002_closed_result") == 3,WriteToOperationLog("CLOSED is not a valid date format: " + CLOSED + " APP_ID: " +
APP_ID + " Error Message: " + GetLastError());false,true) &&
If(RegExMatch(ACT_EAD,"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$","0002_actead","0002_actead_result") == 3,WriteToOperationLog("ACT_EAD is not a valid date format: " + ACT_EAD + " APP_ID: " +
APP_ID + " Error Message: " + GetLastError());false,true) &&
If(Length(SD_TEXT) > 60,WriteToOperationLog("SD_TEXT exceeds 60 characters: " + SD_TEXT + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(RD_TEXT) > 60,WriteToOperationLog("RD_TEXT exceeds 60 characters: " + RD_TEXT + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(RegExMatch(SUSP,"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$","0002_SUSP","0002_SUSP_result") == 3,WriteToOperationLog("SUSP is not a valid date format: " + SUSP + " APP_ID: " + APP_ID +
" Error Message: " + GetLastError());false,true) &&
If(RegExMatch(CONTACT,"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$","0002_CONTACT","0002_CONTACT_result") == 3,WriteToOperationLog("CONTACT is not a valid date format: " + CONTACT + " APP_ID: " +
APP_ID + " Error Message: " + GetLastError());false,true) &&
If(RegExMatch(PIR,"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$","0002_PIR","0002_PIR_result") == 3,WriteToOperationLog("PIR is not a valid date format: " + PIR + " APP_ID: " + APP_ID +
" Error Message: " + GetLastError());false,true) &&
If(Length(CREDIT_RECRUITER) > 200,WriteToOperationLog("CREDIT_RECRUITER exceeds 200 characters: " + CREDIT_RECRUITER + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(!IsInteger(CONTACTS),WriteToOperationLog("CONTACTS should be numeric: " + CONTACTS + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(RegExMatch(ASVAB_TEST_DATE,"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$","0002_ASVAB_TEST_DATE","0002_ASVAB_TEST_DATE_result") == 3,
WriteToOperationLog("ASVAB_TEST_DATE is not a valid date format: " + ASVAB_TEST_DATE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true) &&
If(Length(QT) > 100,WriteToOperationLog("QT exceeds 100 characters: " + QT + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(RegExMatch(PHY_DATE,"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$","0002_PHY_DATE","0002_PHY_DATE_result") == 3,WriteToOperationLog("PHY_DATE is not a valid date format: " + PHY_DATE +
" APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true) &&
If(Length(SD_TEXT_1) > 60,WriteToOperationLog("SD_TEXT_1 exceeds 60 characters: " + SD_TEXT_1 + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(RD_TEXT_1) > 60,WriteToOperationLog("RD_TEXT_1 exceeds 60 characters: " + RD_TEXT_1 + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(RAW_GS) > 2,WriteToOperationLog("RAW_GS exceeds 2 characters: " + RAW_GS + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(RAW_AR) > 2,WriteToOperationLog("RAW_AR exceeds 2 characters: " + RAW_AR + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(RAW_WK) > 2,WriteToOperationLog("SD_TEXT exceeds 2 characters: " + SD_TEXT + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(RAW_PC) > 2,WriteToOperationLog("RD_TEXT exceeds 2 characters: " + RD_TEXT + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(RAW_MK) > 2,WriteToOperationLog("ORG_CODE exceeds 2 characters: " + ORG_CODE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(RAW_EI) > 2,WriteToOperationLog("RAW_EI exceeds 2 characters: " + RAW_EI + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(RAW_AS) > 2,WriteToOperationLog("RAW_AS exceeds 2 characters: " + RAW_AS + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(RAW_MC) > 2,WriteToOperationLog("RAW_MC exceeds 2 characters: " + RAW_MC + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(RAW_AO) > 2,WriteToOperationLog("RAW_AO exceeds 2 characters: " + RAW_AO + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(AFQT) > 2,WriteToOperationLog("AFQT exceeds 2 characters: " + AFQT + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(ASVAB_M) > 3,WriteToOperationLog("ASVAB_M exceeds 3 characters: " + ASVAB_M + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(ASVAB_A) > 3,WriteToOperationLog("ASVAB_A exceeds 3 characters: " + ASVAB_A + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(ASVAB_G) > 3,WriteToOperationLog("ASVAB_G exceeds 3 characters: " + ASVAB_G + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(ASVAB_E) > 3,WriteToOperationLog("ASVAB_E exceeds 3 characters: " + ASVAB_E + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(ASVAB_VERSION) > 3,WriteToOperationLog("ASVAB_VERSION exceeds 3 characters: " + ASVAB_VERSION + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(INTEREST_CODE) > 9,WriteToOperationLog("INTEREST_CODE exceeds 9 characters: " + INTEREST_CODE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(RegExMatch(ASVAB_DATE,"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$","0002_ASVAB_DATE","0002_ASVAB_DATE_result") == 3,WriteToOperationLog("ASVAB_DATE is not a valid date format: " + ASVAB_DATE +
" APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true) &&
If(Length(SCHOOL_CODE) > 9,WriteToOperationLog("SCHOOL_CODE exceeds 9 characters: " + SCHOOL_CODE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(SCHOOL_NAME) > 75,WriteToOperationLog("SCHOOL_NAME exceeds 75 characters: " + SCHOOL_NAME + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true)&&
If(Length(ED_YEARS) > 2,WriteToOperationLog("ED_YEARS exceeds 2 characters: " + ED_YEARS + " APP_ID: " + APP_ID + " Error Message: " + GetLastError());false,true);
//If(Length(REFERRAL_CODE) > 4,WriteToOperationLog("REFERRAL_CODE exceeds 4 characters: " + REFERRAL_CODE + " APP_ID: " + APP_ID + " Error Message: " + GetLastError()),WriteToOperationLog("GOOD REFERRAL_CODE: "
// + REFERRAL_CODE); true;)
,
Set("ScanRecordResult",true);
,
Set("ScanRecordResult",false);
WriteFile("<TAG>Targets/0002_AFRISS TO LPC LOOPBACK MODIFIED Bad Records</TAG>",
APP_ID+ "|" + PER_L_NAME_FIRST + "|" + PER_L_NAME_MIDDLE + "|" + PER_L_NAME_LAST + "|" + PER_L_NAME_SUFFIX+ "|" + PER_GENDER+"|" + PER_DOB+ "|" + STREET_ADDRESS+ "|" + CITY+ "|" + STATE+ "|" + ZIP+ "|"
+ PHONE+ "|" + EMAIL+ "|" + CITIZENSHIP+ "|" + PRIOR_SERVICE+ "|" + BASE_CODE+ "|" + SERVICE_BRANCH_CODE+ "|" + TAFMS+ "|" + TAFMS_DAYS+ "|" + TAFMS_MONTHS+ "|" + TAFMS_YEARS+ "|" + SPECIALTY_CODE+ "|"
+ HP_DEGREE+ "|" + GRAD_DATE+ "|" + LS_CODE+ "|" + LSD_CODE+ "|" + PROGRAM_CODE+ "|" + PROG_ID_SUBPROG+ "|" + RACE+ "|" + PER_HISPANIC_IND+ "|" + ORG_CODE+ "|" + LED+ "|" + LAR+ "|" + CLOSED+ "|" +
SD_TEXT+ "|" + RD_TEXT+ "|" + SUSP+ "|" + CONTACT+ "|" + PIR+ "|" + ACT_EAD+ "|" + CREDIT_RECRUITER+ "|" + CONTACTS+ "|" + ASVAB_TEST_DATE+ "|" + QT+ "|" + PHY_DATE+ "|" + AFSC+ "|" + SD_TEXT_1+ "|" +
RD_TEXT_1+ "|" + RAW_GS+ "|" + RAW_AR+ "|" + RAW_WK+ "|" + RAW_PC+ "|" + RAW_MK+ "|" + RAW_EI+ "|" + RAW_AS+ "|" + RAW_MC+ "|" + RAW_AO+ "|" + AFQT+ "|" + ASVAB_M+ "|" + ASVAB_A+ "|" + ASVAB_G+ "|" +
ASVAB_E+ "|" + ASVAB_VERSION+ "|" + INTEREST_CODE+ "|" + ASVAB_DATE+ "|" + SCHOOL_CODE+ "|" + SCHOOL_NAME+ "|" + ED_YEARS+ "|" + LPC_UNIQUE_ID+ "|" + LS_CODE_1+ "|" + LSD_CODE_1 //+ "|" +
//REFERRAL_CODE
,"Text.Txt"
);
FlushFile("<TAG>Targets/0002_AFRISS TO LPC LOOPBACK MODIFIED Bad Records</TAG>");
//Set("BadRecordCount",$BadRecordCount + 1);
//WriteToOperationLog("Bad Record Count: " + $BadRecordCount);
);

$ScanRecordResult
</trans>

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.