Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to using lock object by row

jandrivay
Participant
0 Kudos

Hi all,
i need your advice,

i have screen and i create lock object,

i need when user1 open no.bill ex : 1-10 and change it, screen will input = 1.
and then when user 2 open no.bill ex : 8 - 12 , screen output no.bill 8-10 equal = 0 because user 1 opened it and no.bill 11-12 screen output = 1.

how can lock object inside loop ?

this is my code.

PROCESS BEFORE OUTPUT.
  MODULE status_0100.
  MODULE init.
  LOOP AT it_show WITH CONTROL tc_0001
  CURSOR tc_0001-current_line.
    MODULE icon_status.
    MODULE lock_object.
    MODULE screen_control.
    MODULE moveback_to_screen.
  ENDLOOP.


"------------------
MODULE lock_object.
DATA : lv_uname TYPE sy-msgv1,
       lv_msg   TYPE c LENGTH 40.

  CALL FUNCTION 'ENQUEUE_EZLOSD_TRIP_BBO2'
    EXPORTING
      mode_zsdtb_trip_bbo2 = 'E'
      mandt                = sy-mandt
      no_bill              = it_show-no_bill
    EXCEPTIONS
      foreign_lock         = 1
      system_failure       = 2
    OTHERS                 = 3.
  IF sy-subrc <> 0.
*    lv_uname = sy-msgv1.
*    CONCATENATE 'Data has been locked by :' lv_uname INTO lv_msg
*    SEPARATED BY space.
*    MESSAGE i000(zmm) WITH lv_msg DISPLAY LIKE 'E'.
    gv_error2 = 'X'.
  ENDIF.
ENDMODULE.

Thank You

5 REPLIES 5

venkateswaran_k
Active Contributor

Hi

You can make it disable as below

  CALL FUNCTION 'ENQUEUE_EZLOSD_TRIP_BBO2'
    EXPORTING
      mode_zsdtb_trip_bbo2 = 'E'
      mandt                = sy-mandt
      no_bill              = it_show-no_bill
    EXCEPTIONS
      foreign_lock         = 1
      system_failure       = 2
    OTHERS                 = 3.
  IF sy-subrc <> 0.
       LOOP AT screen.               "<===== screen loop
           SCREEN-INPUT = 0.    " Disable for input
           MODIFY SCREEN.
      ENDLOOP.                         "<=== screen loop
    gv_error2 = 'X'.
  ENDIF.

DoanManhQuynh
Active Contributor
0 Kudos

so after get data from table and before display it on screen, you should check if record is locked then set input = 0.

Sandra_Rossi
Active Contributor

Your question is unclear as you mix normal language and ABAP elements. Try to spend more time on describing clearly in full English.

Decoding and rephrasing your question:

Requirement:

  • When user 1 selects bills 1 to 10, the screen fields for all bills can be input because nobody maintained them yet.
  • When user 2 selects bills 8 to 12, the screen fields for bills 8 to 10 cannot be input because user 1 opened/locked them, and bills 11 and 12 can be input.

Question:

  • Does anybody know how to make fields input-capable or output-only depending on success or failure of lock.

Sandra_Rossi
Active Contributor

Not related to your question, but please don't lock during the PBO because you shouldn't lock at each input of the user, or at each scroll of the screen.

Instead, I propose that you lock before displaying the screen, store the lock status in an intermediate field of the internal table IT_SHOW, don't display that field, and in PBO test this field to make fields input-capable or output-only.

jandrivay
Participant
0 Kudos

Hi sandra.rossi ,
Thank you for correcting me .
yeah, i mean like that.
Thank you so much.