创建新的记录结果运行错误块

时间:2018-12-12 09:06:01

标签: openedge progress-4gl

我正在尝试根据交易是否失败从1-4返回一个值。添加新记录将显示在数据库中,但是代码返回4,这表示正在运行错误块,为什么会发生这种情况?

我正在从Java发送输入参数,并从ABL返回一个数字作为输出参数。

/*Input parameters*/
DEFINE INPUT PARAMETER i_cCode LIKE Unit.Code NO-UNDO.
DEFINE INPUT PARAMETER i_iTransactionType AS INTEGER NO-UNDO.
DEFINE INPUT PARAMETER i_cName LIKE UNIT.Name NO-UNDO.
/*Output parameters*/ 
DEFINE OUTPUT PARAMETER o_iStatus AS INTEGER NO-UNDO. 
/*Local variables*/
DEFINE VARIABLE iModifySuccess AS INTEGER INITIAL 1.
DEFINE VARIABLE iModifyFailed AS INTEGER INITIAL 2.
DEFINE VARIABLE iAddedSuccessful AS INTEGER INITIAL 3.
DEFINE VARIABLE iCreateFailed AS INTEGER INITIAL 4.
/*Transaction types*/
DEFINE VARIABLE iCreate AS INTEGER INITIAL 1.
DEFINE VARIABLE iModify AS INTEGER INITIAL 2.

FIND FIRST Unit WHERE Unit.Code = i_cCode EXCLUSIVE-LOCK NO-ERROR.
            IF AVAIL(Unit) AND i_iTransactionType = iModify THEN DO:

                ASSIGN
                    Unit.Name = i_cName
                    /*Other fields as well*/
                NO-ERROR.
                MESSAGE "Unit has been modified".
                o_iStatus = iModifySuccess.

                IF ERROR-STATUS:ERROR THEN DO:
                    MESSAGE "Error Modifying Unit" + ERROR-STATUS:GET-MESSAGE(1).    
                    o_iStatus = iModifyFailed.
                END.   

            END.
            ELSE DO:
                IF i_iTransactionType = iCreate THEN DO:
                    /*Create new record*/
                    CREATE Unit NO-ERROR.
                        ASSIGN
                        Unit.Name = i_cName
                        /*Other fields as well*/
                            NO-ERROR.
                        MESSAGE "New Unit Created"
                        o_iStatus = iAddedSuccessful.

                        IF ERROR-STATUS:ERROR THEN DO:
                            MESSAGE "ERROR creating a new Unit" + ERROR-STATUS:GET-MESSAGE(1).
                            o_iStatus = iCreateFailed.
                        END. 
                END.   
            END.

1 个答案:

答案 0 :(得分:0)

似乎.之后缺少MESSAGE "New Unit Created",这导致错误块运行。构建项目没有发出任何警告。