{
    "header": {
        "version": 1,
        "type": "record"
    },
    "body": {
        "record1": {
            "<1>": "declare function start_window, relational_call, security_check, msg, key_sort\r\ndeclare function rowexists, Get_Status, Popup\r\ndeclare subroutine security_err_msg, ErrMsg, obj_Appwindow, Btree.Extract, Set_Status, ErrMsg\r\n$insert msg_equates\r\n$insert security_rights_equ\r\n$INSERT POPUP_EQUATES\r\n\r\nif .co_type->value = 'C' then\r\n\tif security_check( 'Annual Contracts', Read$ ) then\r\n\t    CustNo = .co_no->text\r\n\t    if CustNo then\r\n\t        if rowexists( 'COMPANY', CustNo ) then\r\n\t\t\t\tOPEN 'DICT.ANNUAL_CONTRACTS' TO DictVar THEN\r\n\t\t\t\t\tSearchString = 'CUST_NO':@VM:CustNo:@FM\r\n\t\t\t\t\tBtree.Extract(SearchString,'ANNUAL_CONTRACTS',DictVar,ACIDs,'',Flag)\r\n\t\t\t\t\tIF Get_Status(errCode) THEN\r\n\t\t\t\t\t\tErrMsg(errCode)\r\n\t\t\t\t\t\tRETURN\r\n\t\t\t\t\tEND\r\n\t\t\r\n\t\t\t\t\tIF ACIDs= '' THEN\r\n\t\t\t\t\t\tErrMsg('No Annual Contracts on file for Customer Number ':CustNo)\r\n\t\t\t\t\t\tRETURN 0\r\n\t\t\t\t\tEND ELSE\r\n\t\t\t\t\t\tIF INDEX(ACIDs,@VM,1) THEN\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tACIDs := @VM\r\n\t\t\t\t\t\t\tCONVERT @VM TO @RM IN ACIDs\r\n\t\t\t\t\t\t\tCALL V119('S','','D','R',ACIDs,'')\r\n\t\t\t\t\t\t\tIF Get_Status(errCode) THEN DEBUG\r\n\t\t\t\t\t\t\tCONVERT @RM TO @VM IN ACIDs\r\n\t\t\t\t\t\t\tACIDs[-1,1] = ''\t\t\t\t\t;* Strip trailing delimiter\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tTypeOver = ''\r\n\t\t\t\t\t\t\tTypeOver<PDISPLAY$> = ACIDs\r\n\t\t\t\t\t\t\tTypeOver<PTITLE$>\t= 'Annual Contracts for ':XLATE('COMPANY',CustNo,4,'X')\r\n\t\t\t\t\t\t\tTypeOver<PSELECT$>\t= 2\r\n\t\t\t\t\t\t\tACID = Popup(@WINDOW,TypeOver,'COMP_ANN_CONT')\r\n\t\t\t\t\t\tEND ELSE\r\n\t\t\t\t\t\t\tACID = ACIDs\r\n\t\t\t\t\t\tEND\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tIF ACIDs NE '' THEN\r\n\t\t\t\t\t\t\tobj_Appwindow('ViewRelated','ANN_CONT':@RM:ACID)\r\n\t\t\t\t\t\tEND\r\n\t\t\t\t\tEND\r\n\t\t\t\tEND ELSE\r\n\t\t\t\t\tErrMsg('Unable to open DICT.ANNUAL_CONTRACTS in COMM_PROD_ORD routine.')\r\n\t\t\t\t\tRETURN 0\r\n\t\t\t\tEND\r\n\t\t    end else\r\n\t\t        MsgInfo = ''\r\n\t\t        MsgInfo<mtext$> = 'You must save this company first.'\r\n\t\t        MsgInfo<micon$> = '!'\r\n\t\t        Void = msg( '', MsgInfo )\r\n\t\t    end\r\n\t    end else\r\n\t        MsgRec = ''\r\n\t        MsgRec<mtext$> = 'You must retrieve a company first...' \r\n\t        MsgRec<micon$> = '!'\r\n\t        Void = msg( '', MsgRec )    \r\n\t    end\r\n\tend else\r\n\t    security_err_msg( 'Annual Contracts', Read$ )\r\n\tend\r\nend else\r\n   MsgInfo = ''\r\n   MsgInfo<mtext$> = 'You cannot setup an annual contract for a company unless they are defined as a customer...'\r\n   MsgInfo<micon$> = '!'\r\n   Void = msg( '', MsgInfo )\r\nend\r\nRETURN 0"
        }
    }
}