Application Development and Automation 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: 
Read only

Item locked by user problem

Former Member
0 Likes
1,399

Hi experts,

The program is using BAPI " BAPI_GOODSMVT_CREATE" in a loop ( that is single item everytime )

and then BAPI TRANSACTION COMMIT has used ( with no parameters) . When we are selecting more than one item for the same material , for the first item its get posted successfully but for other it shows error that "ponumber/itemnumber is locked by the user" .

Now I guess this error is due to the system load as when I am running this in debugging mode all the items get posted successfully . So I think we need to put some time delay between two items.

Please provide me some solutions and ways to resolve it asap.

I will definetly ..... if helpful

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,055

Hi ,

Please use this code may be it solve ur probelm

LOOP AT it_output INTO wa_output WHERE mark = 'X'.

CLEAR s_goodsmvt_header.

s_goodsmvt_header-pstng_date = '20090228'. "s_xmkpf-budat.

s_goodsmvt_header-doc_date = '20090228'. "s_xmkpf-bldat.

s_goodsmvt_header-header_txt = 'Auto Scrap'.

s_goodsmvt_header-pr_uname = sy-uname.

*-Fill the item

CLEAR s_goodsmvt_item.

REFRESH t_goodsmvt_item.

*->Ver 1.2

  • READ TABLE it_mtyp_id INTO wa_mtyp_id WITH KEY wa_output-mtart.

  • IF wa_mtyp_id-mat_type_id = 'AS'.

  • CLEAR: wa_mast, wa_stpo.

  • READ TABLE it_mast INTO wa_mast WITH KEY matnr = wa_output-matnr.

  • READ TABLE it_stpo INTO wa_stpo WITH KEY stlnr = wa_mast-stlnr.

  • s_goodsmvt_item-material = wa_stpo-idnrk.

s_goodsmvt_item-material = wa_output-idnrk.

s_goodsmvt_item-spec_stock = 'O'.

  • s_goodsmvt_item-entry_uom = wa_OUTPUT-meins.

s_goodsmvt_item-entry_uom = wa_output-meins_c.

  • ELSE.

  • s_goodsmvt_item-material = wa_output-matnr.

  • s_goodsmvt_item-spec_stock = ' '.

  • s_goodsmvt_item-entry_uom = wa_output-meins.

  • ENDIF.

*-<Ver 1.2

s_goodsmvt_item-plant = wa_output-werks.

*->Ver 1.2

  • s_goodsmvt_item-stge_loc = wa_output-lgort.

  • s_goodsmvt_item-batch = wa_output-charg.

s_goodsmvt_item-batch = wa_output-charg_c.

*-<Ver 1.2

s_goodsmvt_item-move_type = c_mvt_typ.

  • s_goodsmvt_item-costcenter = p_kostl.

s_goodsmvt_item-vendor = wa_output-lifnr.

s_goodsmvt_item-entry_qnt = wa_output-input.

s_goodsmvt_item-po_number = wa_output-ebeln.

s_goodsmvt_item-po_item = wa_output-ebelp.

s_goodsmvt_item-mvt_ind = ' '. "Original 'B' but not maintain in Update Control

APPEND s_goodsmvt_item TO t_goodsmvt_item.

REFRESH t_return.

*-Call the goods movement BAPi for Vendor Location Scrap

DO 5 times.

clear t_return[].

CALL FUNCTION 'BAPI_GOODSMVT_CREATE' "in background task

EXPORTING

goodsmvt_header = s_goodsmvt_header

goodsmvt_code = '03' "Goods Movement "MB1A

testrun = p_test "Production run

IMPORTING

materialdocument = v_materialdocument

TABLES

goodsmvt_item = t_goodsmvt_item

return = t_return.

IF NOT t_return IS INITIAL.

  • PERFORM refresh_data .

READ TABLE t_return WITH KEY type = 'E' id = 'M3' number = '897' .

IF sy-subrc = 0.

runbapi = 'X'.

count = count + 1.

IF count = 5.

CONCATENATE '-' wa_output-ebeln '/' wa_output-ebelp '->' INTO t_return-message_v1.

PERFORM append_message_table USING 'M7' 'E'

'895' t_return-message_v1 t_return-message_v2

t_return-message_v3 t_return-message_v4.

LOOP AT t_return.

PERFORM append_message_table USING t_return-id t_return-type

t_return-number t_return-message_v1 t_return-message_v2

t_return-message_v3 t_return-message_v4.

ENDLOOP.

ENDIF.

ELSE.

CONCATENATE '-' wa_output-ebeln '/' wa_output-ebelp '->' INTO t_return-message_v1.

PERFORM append_message_table USING 'M7' 'E'

'895' t_return-message_v1 t_return-message_v2

t_return-message_v3 t_return-message_v4.

LOOP AT t_return.

PERFORM append_message_table USING t_return-id t_return-type

t_return-number t_return-message_v1 t_return-message_v2

t_return-message_v3 t_return-message_v4.

ENDLOOP.

ENDIF.

  • CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'

    • IMPORTING

  • RETURN =

.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

CONCATENATE '-' wa_output-ebeln '/' wa_output-ebelp '->' v_materialdocument ' posted'

INTO t_return-message_v1.

PERFORM append_message_table USING 'M7' 'S'

'895' t_return-message_v1 t_return-message_v2

t_return-message_v3 t_return-message_v4.

CLEAR runbapi.

ENDIF.

IF runbapi = 'X'.

CLEAR runbapi.

DO 100 TIMES.

ENDDO.

ELSE.

EXIT.

ENDIF.

ENDDO.

clear count.

ENDLOOP.

Hi experts,

The program is using BAPI " BAPI_GOODSMVT_CREATE" in a loop ( that is single item everytime )

and then BAPI TRANSACTION COMMIT has used ( with no parameters) . When we are selecting more than one item for the same material , for the first item its get posted successfully but for other it shows error that "ponumber/itemnumber is locked by the user" .

Now I guess this error is due to the system load as when I am running this in debugging mode all the items get posted successfully . So I think we need to put some time delay between two items.

Please provide me some solutions and ways to resolve it asap.

I will definetly ..... if helpful

5 REPLIES 5
Read only

former_member242255
Active Contributor
0 Likes
1,055

call a FM for waiting for some secs..and this should be solved...

FM 'BAPI_TRANSACTION_COMMIT ' and pass WAIT = 'X'.

regards,,,

sravan

Edited by: Sravan Kumar on Feb 27, 2009 6:05 AM

Edited by: Sravan Kumar on Feb 27, 2009 6:06 AM

Read only

0 Likes
1,055

Hi,

I have done following things:

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

STARTING NEW TASK '001'

PERFORMING f_task ON END OF TASK

EXPORTING

wait = 'X'.

FORM f_task using u_task.

data : lv_mssg(80).

DO.

RECEIVE RESULTS FROM FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXCEPTIONS

resource_failure = 1

communication_failure = 2 message lv_mssg

system_failure = 3 message lv_mssg

OTHERS = 4.

IF sy-subrc EQ 0.

EXIT.

ENDIF.

ENDDO.

ENDFORM. " F_TASK

But when I run the program , I am getting following stop error message :

" Function module MB_CREATE_GOODS_MOVEMENT cannot be executed"

Can you tell me what is the problem .

Read only

Former Member
0 Likes
1,055

Anandita,

It is not good practice to Post the goods item wise, all should post in single shot. You can do that through this bapi because you have itemdata in Tables so you can pass all items in single go. Change your design first. Your issue will solve automatically.

Read only

0 Likes
1,055

Ok , it was the existing code actually . I will post for all the materials at one go in BAPI_GOODSMVT_CREATE and will check the output . But tell me one thing do we need to pass wait parameter in the BAPI _TRANSACTION _COMMIT in this case or it will automatically take the time delay?

I will check with your logic and will get back to you once its tested as we are able to check only in the production .Lets hope for the best .

Read only

Former Member
0 Likes
1,056

Hi ,

Please use this code may be it solve ur probelm

LOOP AT it_output INTO wa_output WHERE mark = 'X'.

CLEAR s_goodsmvt_header.

s_goodsmvt_header-pstng_date = '20090228'. "s_xmkpf-budat.

s_goodsmvt_header-doc_date = '20090228'. "s_xmkpf-bldat.

s_goodsmvt_header-header_txt = 'Auto Scrap'.

s_goodsmvt_header-pr_uname = sy-uname.

*-Fill the item

CLEAR s_goodsmvt_item.

REFRESH t_goodsmvt_item.

*->Ver 1.2

  • READ TABLE it_mtyp_id INTO wa_mtyp_id WITH KEY wa_output-mtart.

  • IF wa_mtyp_id-mat_type_id = 'AS'.

  • CLEAR: wa_mast, wa_stpo.

  • READ TABLE it_mast INTO wa_mast WITH KEY matnr = wa_output-matnr.

  • READ TABLE it_stpo INTO wa_stpo WITH KEY stlnr = wa_mast-stlnr.

  • s_goodsmvt_item-material = wa_stpo-idnrk.

s_goodsmvt_item-material = wa_output-idnrk.

s_goodsmvt_item-spec_stock = 'O'.

  • s_goodsmvt_item-entry_uom = wa_OUTPUT-meins.

s_goodsmvt_item-entry_uom = wa_output-meins_c.

  • ELSE.

  • s_goodsmvt_item-material = wa_output-matnr.

  • s_goodsmvt_item-spec_stock = ' '.

  • s_goodsmvt_item-entry_uom = wa_output-meins.

  • ENDIF.

*-<Ver 1.2

s_goodsmvt_item-plant = wa_output-werks.

*->Ver 1.2

  • s_goodsmvt_item-stge_loc = wa_output-lgort.

  • s_goodsmvt_item-batch = wa_output-charg.

s_goodsmvt_item-batch = wa_output-charg_c.

*-<Ver 1.2

s_goodsmvt_item-move_type = c_mvt_typ.

  • s_goodsmvt_item-costcenter = p_kostl.

s_goodsmvt_item-vendor = wa_output-lifnr.

s_goodsmvt_item-entry_qnt = wa_output-input.

s_goodsmvt_item-po_number = wa_output-ebeln.

s_goodsmvt_item-po_item = wa_output-ebelp.

s_goodsmvt_item-mvt_ind = ' '. "Original 'B' but not maintain in Update Control

APPEND s_goodsmvt_item TO t_goodsmvt_item.

REFRESH t_return.

*-Call the goods movement BAPi for Vendor Location Scrap

DO 5 times.

clear t_return[].

CALL FUNCTION 'BAPI_GOODSMVT_CREATE' "in background task

EXPORTING

goodsmvt_header = s_goodsmvt_header

goodsmvt_code = '03' "Goods Movement "MB1A

testrun = p_test "Production run

IMPORTING

materialdocument = v_materialdocument

TABLES

goodsmvt_item = t_goodsmvt_item

return = t_return.

IF NOT t_return IS INITIAL.

  • PERFORM refresh_data .

READ TABLE t_return WITH KEY type = 'E' id = 'M3' number = '897' .

IF sy-subrc = 0.

runbapi = 'X'.

count = count + 1.

IF count = 5.

CONCATENATE '-' wa_output-ebeln '/' wa_output-ebelp '->' INTO t_return-message_v1.

PERFORM append_message_table USING 'M7' 'E'

'895' t_return-message_v1 t_return-message_v2

t_return-message_v3 t_return-message_v4.

LOOP AT t_return.

PERFORM append_message_table USING t_return-id t_return-type

t_return-number t_return-message_v1 t_return-message_v2

t_return-message_v3 t_return-message_v4.

ENDLOOP.

ENDIF.

ELSE.

CONCATENATE '-' wa_output-ebeln '/' wa_output-ebelp '->' INTO t_return-message_v1.

PERFORM append_message_table USING 'M7' 'E'

'895' t_return-message_v1 t_return-message_v2

t_return-message_v3 t_return-message_v4.

LOOP AT t_return.

PERFORM append_message_table USING t_return-id t_return-type

t_return-number t_return-message_v1 t_return-message_v2

t_return-message_v3 t_return-message_v4.

ENDLOOP.

ENDIF.

  • CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'

    • IMPORTING

  • RETURN =

.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

CONCATENATE '-' wa_output-ebeln '/' wa_output-ebelp '->' v_materialdocument ' posted'

INTO t_return-message_v1.

PERFORM append_message_table USING 'M7' 'S'

'895' t_return-message_v1 t_return-message_v2

t_return-message_v3 t_return-message_v4.

CLEAR runbapi.

ENDIF.

IF runbapi = 'X'.

CLEAR runbapi.

DO 100 TIMES.

ENDDO.

ELSE.

EXIT.

ENDIF.

ENDDO.

clear count.

ENDLOOP.