S
sander
Guest
I'm attempting to return a value from 1-4 depending on whether the transaction failed or not. Adding a new record shows up in the database but the code returns 4 which means that the error block is being run, why does this happen?
I'm sending input parameters from java and returning a number as output parameter from 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.
Continue reading...
I'm sending input parameters from java and returning a number as output parameter from 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.
Continue reading...