Hi, I'm going to show how to unlock transaction SM30 when using to admin data.
By default, SAP locks the entire table when a user edits a single entry which is annoying when several users try to use it.
To avoid this behaviour we must unlock the table to let others to add, update and delete data.
Check this link for a more complete example.
Ok, let's code ABAP:
1. First of all create a table.
2. Goto Utilities/Table Maintenance Generator.
3. Set in Authorization Group the value '&NC&'.
4. In the 'Maintenance Screens' section select 'two step' and set as 'Overview screen' the value '100' and for 'Single screen' the value '101'.
5. Double click on screen '100'. You'll see a warning message but click on the ok button.
6. In PBO type 'MODULE unlock_table' like this:
1 2 3 4 5 6 7 | process before output. module unlock_table. " ---------------------> Type this code module liste_initialisieren. loop at extract with control tctrl_ztesttab cursor nextline. module liste_show_liste. endloop. |
7. Double click the word 'unlock_table' and add the following code. Send as a parameter your table name:
1 2 3 | MODULE UNLOCK_TABLE OUTPUT. perform unlock using 'ZTESTTAB'. " Use your table name as parameter ENDMODULE. |
8. In the same include copy and paste the code for the form 'unlock_table':
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | form unlock using p_table. data begin of seltab occurs 1. include structure vimsellist. data end of seltab. data begin of excl_cua_funct occurs 1. include structure vimexclfun. data end of excl_cua_funct. data: it_enq_del type standard table of seqg3, it_enq_read type standard table of seqg7, wa_enq_read type seqg7, wa_enq_del type seqg3, lv_subrc type sy-subrc. call function 'ENQUE_READ2' " Buscar todos los bloqueos exporting gclient = sy-mandt gname = ' ' guname = '*' tables enq = it_enq_read. * Buscar el bloqueo de la tabla que viene como parĂ¡metro loop at it_enq_read into wa_enq_read where gname eq 'RSTABLE' and garg cs p_table. move-corresponding wa_enq_read to wa_enq_del. append wa_enq_del to it_enq_del. endloop. * Eliminar bloqueo del objeto call function 'ENQUE_DELETE' exporting check_upd_requests = 1 importing subrc = lv_subrc tables enq = it_enq_del. endform. |
Well, that's it, now you can make modifications on the table in different sessions at the same time.
Next time we will lock a single record to avoid anyone else modify the same row when other user is handling it.
See you on the next.
Hope it helps.
No comments :
Post a Comment