0
votes

I have the following code which should do a simple if-else statement using Progress ABL.

I cannot get the program to reach the ELSE statement even when the substring "UK" cannot be found. Can anyone see what I am missing:

FIND FIRST ttShipHead WHERE ttShipHead.ShipToCustCustID = "1404".
IF ttShipHead.AddrList Matches "*UK*" THEN
    assign ttShipHead.CheckBox01 = (false).
ELSE
    assign ttShipHead.CheckBox01 = (true).
4

4 Answers

1
votes

I suggest that you add some debugging:

FIND FIRST ttShipHead WHERE ttShipHead.ShipToCustCustID = "1404" no-error.

message available( ttShipHead ).
pause.

message ttShipHead.AddrList ( ttShipHead.AddrList Matches "*UK*" ).
pause.

IF ttShipHead.AddrList Matches "*UK*" THEN
        assign ttShipHead.CheckBox01 = (false).
    ELSE
        assign ttShipHead.CheckBox01 = (true).

message ttShipHead.Checkbox01.
pause.

This should make it clear what is going wrong.

0
votes

I don't know a whole lot about ABL. But I think the syntax is IF expression THEN DO: work. So try adding a DO: after your THEN

0
votes

If there's a message on the screen about record ttshiphead not found, then it's not running the IF statement at all.

Typically FINDs have a "NO-ERROR" followed by an "IF AVAILABLE ttshiphead THEN " where required.

0
votes

Your code looks correct. Maybe some small changes to make sure you have record.

FIND FIRST ttShipHead WHERE ttShipHead.ShipToCustCustID = "1404" NO-ERROR.

IF AVAILABLE ttShipHead THEN 
    IF ttShipHead.AddrList MATCHES "*UK*":U THEN 
    assign ttShipHead.CheckBox01 = (false).
    ELSE
        assign ttShipHead.CheckBox01 = (true).

if you want to can add and else to show if record not available.

FIND FIRST ttShipHead WHERE ttShipHead.ShipToCustCustID = "1404" NO-ERROR.

IF AVAILABLE ttShipHead THEN 
    IF ttShipHead.AddrList MATCHES "*UK*":U THEN 
    assign ttShipHead.CheckBox01 = (false).
    ELSE
        assign ttShipHead.CheckBox01 = (true).
ELSE
    MESSAGE "NO RECORD FOUND".