10-08-2013 12:32 PM
Hi Experts,
I have a problem in updating the status in loop.
iam looping at orders and updating the User status of the Operation depending on the requirement.
Iam using STATUS_CHANGE_EXTERN to update the status(there are more than one status to be updated for an operation) and then if all updates are successfull I have used BAPI_TRANSACTION_COMMIT to commit.
The Problem is User status is getting updated only for the first order(record in internal tale) even though iam committing in loop.
Please Help..
10-08-2013 12:36 PM
Hi,
please call fm STATUS_BUFFER_REFRESH in your loop to initialize the function group's remaining data.
Regards,
Klaus
10-08-2013 12:40 PM
Thanks for the quick reply,
Should i use it after BAPI_TRANSACTION_COMMIT
10-08-2013 12:44 PM
Hi,
I don't know your program code, but it sounds like a good place for that.
Regards,
Klaus
10-08-2013 1:34 PM
The FM din't help,
My program is like this:
loop at lt_data in l_wa_data.
*** code for getting objnr of Operation in l_wa_data-vornr.***
*** For Updating User Status(This code may be called many time depending on the requirement for each record in lt_data)
*********************
CALL FUNCTION 'STATUS_CHANGE_EXTERN'
EXPORTING
client = sy-mandt
objnr = l_v_objnr
user_status = l_v_status
set_inact = l_v_stat_flag
set_chgkz = g_c_flag_x
no_check = g_c_flag_x
EXCEPTIONS
object_not_found = 1
status_inconsistent = 2
status_not_allowed = 3
OTHERS = 4.
IF sy-subrc <> 0.
CASE sy-subrc.
WHEN 1. l_wa_alvdata-status_check = text-021.
WHEN 2. l_wa_alvdata-status_check = text-022.
WHEN 3. l_wa_alvdata-status_check = text-023.
WHEN OTHERS. l_wa_alvdata-status_check = text-024.
ENDCASE.
ENDIF.
**************************
if l_wa_alvdata-status is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = l_c_bapiwait_x.
CALL FUNCTION 'STATUS_BUFFER_REFRESH'.
endif.
endloop.
10-09-2013 9:21 AM
Hi,
your call of fm STATUS_CHANGE_EXTERN is independent from workarea l_wa_data.
But these are the only values changing in loop.
At least the object number should be diifferent Is it part of l_wa_data?
Regards,
Klaus.
10-09-2013 9:41 AM
I have fetched all the objnr in a separate internal table(lt_objnr) for all orders and operations lt_data.
STATUS_CHANGE_EXTERN is in subroutine and i am passing the Objnr value for each vornr in l_wa_data-vornr by reading the internal table lt_objnr. i think the objnr will be different for each execution of loop.
The problem is all the status updates for the first record in lt_data ie.. Order and Operation are working and when the second record comes the code executes but the status is not updated.
There are some Update tasks created in FM status_change_extern and these tasks executes only for first record.
10-09-2013 10:05 AM
Hi,
please make sure that l_wa_alvdata-status will be cleared in each loop.
Check field content in line
if l_wa_alvdata-status is initial.
Fm STATUS_BUFFER_REFRESH should be called everytimes (no IF around that!).
Regards,
Klaus
10-09-2013 1:10 PM
sorry for updating it so late.
There is a BAPI_ALM_ORDER_MAINTAIN also being called.
Now if i put one BAPI_TRASACTION_COMMIT after changing all the User statuses, and then call BAPI_ALM_ORDER_MAINTAIN and call BAPI_TRASACTION_COMMIT again, the program is working as expected.
the problem is, with the first commit data is being saved but if the BAPI_ALM_ORDER_MAINTAIN have any error i should not save anything.
************************************************************************************
loop at lt_data in l_wa_data.
*** code for getting objnr of Operation in l_wa_data-vornr.***
*** For Updating User Status(This code may be called many time depending on the requirement for each record in lt_data)
*********************
CALL FUNCTION 'STATUS_CHANGE_EXTERN'
EXPORTING
client = sy-mandt
objnr = l_v_objnr
user_status = l_v_status
set_inact = l_v_stat_flag
set_chgkz = g_c_flag_x
no_check = g_c_flag_x
EXCEPTIONS
object_not_found = 1
status_inconsistent = 2
status_not_allowed = 3
OTHERS = 4.
IF sy-subrc <> 0.
CASE sy-subrc.
WHEN 1. l_wa_alvdata-status_check = text-021.
WHEN 2. l_wa_alvdata-status_check = text-022.
WHEN 3. l_wa_alvdata-status_check = text-023.
WHEN OTHERS. l_wa_alvdata-status_check = text-024.
ENDCASE.
ENDIF.
**************************
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = lt_methods
it_header = lt_header
it_header_up = lt_header_up
extension_in = lt_extension_in
return = lt_return.
if l_wa_alvdata-status is initial." Iam passing message to status field if any errors occurs during the call to STATUS_CHANGE_EXTERN.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = l_c_bapiwait_x.
CALL FUNCTION 'STATUS_BUFFER_REFRESH'.
endif.
endloop.
10-09-2013 1:23 PM
Hi,
what about
if l_wa_alvdata-status is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
endif.
CALL FUNCTION 'STATUS_BUFFER_REFRESH'.
CLEAR l_wa_alvdata-status.
before ENDLOOP ? Why don't you evalute table lt_return from call of BAPI_ALM_ORDER_MAINTAIN ?
Please check, when you want to commit and when you want to rollback, in any case call fm STATUS_BUFFER_REFRESH and clear l_wa_alvdata-status.
Regards,
Klaus
10-09-2013 9:15 AM
10-09-2013 1:51 PM
Hi Syed,
I don't think there is any problem with calling BAPI and Commit simultaneously, as I have done the same thing recently.
There is no need of calling FM STATUS_BUFFER_REFRESH after Commit.
Check return message from BAPI for error, if error exists do not go with Commit.
Clear all the variables at the end of loop: like check error return from BAPI call before commit, etc.
Please check Destinations of BAPI call. and do not lock the table while executing the BAPI..
Hope it will give some ideas...
Regards,
Chandan