Objeto de Bloqueio
Autor: Ricardo Moura Braga | Publicado: 2014-12-23T11:04:00-02:00

Coisinha bobinha mas que toma um tempo quando não funciona direito......

Objeto de Bloqueio com parâmetro errado pode causar uma dor de cabeça se não estiver feito a chamada de acordo com a sua necessidade....segue....

Atentar parâmetro _scope



CALL&nbsp;FUNCTION&nbsp;'ENQUEUE_EZTBCO0029'&nbsp;&nbsp;&nbsp;&nbsp;EXPORTING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;repid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;sy-repid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_scope&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;'1'&nbsp;&nbsp;&nbsp;&nbsp;EXCEPTIONS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreign_lock&nbsp;&nbsp;&nbsp;=&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system_failure&nbsp;=&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OTHERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;3.&nbsp;&nbsp;IF&nbsp;sy-subrc&nbsp;&lt;&gt;&nbsp;0.*&nbsp;Implement&nbsp;suitable&nbsp;error&nbsp;handling&nbsp;here&nbsp;&nbsp;&nbsp;&nbsp;MESSAGE&nbsp;ID&nbsp;sy-msgid&nbsp;TYPE&nbsp;sy-msgty&nbsp;NUMBER&nbsp;sy-msgno&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WITH&nbsp;sy-msgv1&nbsp;sy-msgv2&nbsp;sy-msgv3&nbsp;sy-msgv4.&nbsp;&nbsp;ENDIF.



segue a fonte:&nbsp;http://scn.sap.com/thread/1974118 /&nbsp;http://scn.sap.com/thread/346975



If you have _SCOPE = 1 you can have a COMMIT WORK after each update (or one COMMIT after both updates) and have to DEQUEUE it afterwards; if _SCOPE is 2 or 3 a COMMIT WORK automatically dequeues the lock and in this case you need no DEQUEUE fm before COMMIT WORK.

-----------------------------------------------------------------------------------------------------------------------------------------------------------
Mais uma opção.....

fiunção: ENQUEUE_EGMSPPROGRAM


*&nbsp;Chama&nbsp;função&nbsp;de&nbsp;bloqueio&nbsp;de&nbsp;programa
&nbsp;&nbsp;call&nbsp;function&nbsp;'ENQUEUE_EGMSPPROGRAM'
&nbsp;&nbsp;&nbsp;&nbsp;exporting
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MODE_GMSPPROGRAM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;'E'
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CLIENT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;SY-MANDT
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sponsored_prog&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;pi_program
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X_SPONSORED_PROG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;'&nbsp;'
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_SCOPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;'2'
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_WAIT&nbsp;&nbs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