lunes, 4 de julio de 2016

[JD Edwards] Object Reserve

When a user is working and editing a document, we shouldn't allow other users can modify to avoid inconsistences. It is know as Object Reserve o Document Reserve in JD Edwards.

In the most standard JDE Applications it is implment, but when we create a custom application we should keep in mind

How it's made?

It's easy, jde simply insert a row in F00095 table when a user edit the document, and not deleted until user exit from edition. In this way, when other user in in another application instance check if exist the row in F00095 table, if is true show a error and blocking fields for not allow edit.

What is there to do?


Using "F00095 Reserve Object" business function standard with the UKID "RRESERVE", and normally with document keys values, this function doing 2 things: check if it is reserved or not, if not it reserverd insert a row and reserve. If it reserved, use the bsfn "Set Object Reservation Text Substitution Error" for set a error, and blocking all field of application.
Sample:


0080       //
0081       //  # Reserva #
0082       //
0083       // Cogemos un UKID (RRESERVE) de la F00022
0084       //
0085       Get Next Unique Key ID
              "RRESERVE" -> BF szObjectName
              VA frm_UniqueKeyIDInternal_UKID <- BF mnUniqueKeyID
0086       //
0087       // Lo convertimos a string para pasarselo a la función de reserva parámetro
0088       // PID
0089       //
0090       Math Numeric to String, Convert
              VA frm_UniqueKeyIDInternal_UKID -> BF mnMathNumeric01
              VA frm_szUniqueIDRecReserve_PID <- BF szVideoConstant30A
0091       //
0092       // Cogemos como clave el id de incidencia
0093       //
0094       VA frm_GenericKey_GENKEY = [FI mnIdentificadorIncidencia]
0095       //
0096       // Lo reservamos, pasándole usuario, clave, tabla, PID Único
0097       //
0098       F00095 Reserve Object
              "F55N42IC" -> BF szNameObject
              VA frm_UserId_USER -> BF szUserId
              "1" -> BF cSuppressErrorMessage
              VA frm_szRecordReserveErrMsg_DTAI <- BF szErrorMessageID
              VA frm_ReserversNameAlpha_ALPH <- BF szReserversNameAlpha
              VA frm_GenericKey_GENKEY -> BF szGenericKey
              VA frm_szUniqueIDRecReserve_PID -> BF szApplication
              VA frm_szReserversAplication_PID <- BF szReserversApplication
              "1" -> BF cWarningError
0099       //
0100       // Si está reservado, nos lo indicará en ErrorMesageID. Entonces mostramos
0101       // error y deshabilitamos el OK y los campos
0102       //
0103       If VA frm_szRecordReserveErrMsg_DTAI is not equal to <Blank> And VA frm_szRecordReserveErrMsg_DTAI is not equal to <Null>
0104          Set Object Reservation Text Substitution Error
                 VA frm_ReserversNameAlpha_ALPH -> BF szReserversNameAlpha
                 VA frm_GenericKey_GENKEY -> BF szGenericKey
                 VA frm_szReserversAplication_PID -> BF szApplication
                 "2" -> BF cWarningError
0105          Disable Control(HC &OK)
0106          Disable Control(FC 2nd Address Number)
0107          Disable Control(FC Address Book Name)
0108          Disable Control(FC Electronic Address)
0109          Disable Control(FC Phone Number)
0110          Disable Control(FC Fuente Incidencia)
0111          Disable Control(FC Motivo Incidencia)
0112          Disable Control(FC Estado Incidencia)
0113          Disable Control(FC Departamento Incidencia)
0114          Disable Control(FC Comment)
0115          Disable Control(FC Conclusión)
0116       End If

Of course, when user finished edition (when click OK or cancel button normally), we have to remove reserve (F00095 row) for not blocking and the users could edit in a future by the BSFN "F00095 Remove Business Object Reservation".

Sample:

0040    // # Quitamos la reserva
0041    //
0042    // Si la variable PID devuelta es blanco, es porque lo hemos reservado, por lo
0043    // tanto quitamos la reserva pasando el usuario, tabla, clave y PID con el UKI
0044    // unico
0045    //
0046    If VA frm_szReserversAplication_PID is equal to <Blank>
0047       F00095 Remove Business Object Reservation
              VA frm_UserId_USER -> BF szUserId
              "F55N42IC" -> BF szNameObject
              VA frm_GenericKey_GENKEY -> BF szGenericKey
              VA frm_szUniqueIDRecReserve_PID -> BF szApplication
0048    End If
0049    //


And This minimize the impact of multiple users to simultaneously work with the same document, it's very simple and we have avoid a lot of problems in the future!
And with this funcionality, minimaze the impact for edit some users in the same time

No hay comentarios:

Publicar un comentario