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

Commit Work

UmaArjunan
Active Participant
0 Likes
1,419

Hi experts,

I should do the error handling for commit work.

These are the statements used in my program.

Could you please suggest how to handle this for commit work

error handling or exeception. Put your valuable suggestions.

LOOP AT it_header INTO wa_header WHERE va_load EQ space.

MOVE-CORRESPONDING wa_header TO wa_header1.

wa_header1-va_load = co_on.

READ TABLE it_purord INTO wa_purord

WITH KEY object_id = wa_header-object_id.

CALL FUNCTION 'BBP_PD_PO_UPDATE'

EXPORTING

i_header = wa_header1

i_save = co_on

IMPORTING

es_header = wa_header.

*

  • Save the download status in the header

*

CALL FUNCTION 'BBP_PD_PO_SAVE'

EXPORTING

iv_header_guid = wa_purord-guid.

COMMIT WORK.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

former_member195383
Active Contributor
0 Likes
1,183

before writing commit work..check if sy-subrc eq 0. then write commit work.

7 REPLIES 7
Read only

former_member195383
Active Contributor
0 Likes
1,184

before writing commit work..check if sy-subrc eq 0. then write commit work.

Read only

Former Member
0 Likes
1,183

hi

good

commit work is used mainly in case of database changes...

if in the report at certain point you want to make chages to databasethen you can use commit work....to update changes to your database.....

The Commit work is a default process what would happen whenever you try to update the database.

I would suggest you to use the sy-subrc before the function module to check the status of the commit work.

Thanks

mrutyun^

Read only

0 Likes
1,183

What happens if the commit work fails . how to handle that exeception. or in other words.

If i use commit work or any other related commit work statments in my program , i have to handle that exception if its failed to commit

See also the following code which uses commit work . i want to handle exclusively for the commit work statment alone....

CREATE OBJECT prxy.

TRY.

  • do asynchronous client proxy call

CALL METHOD prxy->execute_asynchronous

EXPORTING

output = it_grinfo.

COMMIT WORK.

MESSAGE i015(zebp).

  • Error handling

CATCH cx_ai_system_fault INTO fault.

CREATE OBJECT fault.

lv_msg_text = fault->get_text( ).

MESSAGE i012(zebp) WITH lv_msg_text.

RETURN.

  • WRITE:/ fault->errortext.

ENDTRY.

ENDIF.

ENDFORM. "USER_COMMAND

Read only

0 Likes
1,183

Also let me know how to use commit work and wait

and the corresponding exception / error handling for this statmement

Read only

0 Likes
1,183

Can we use commit work inside a try catch statment.

If so how do use that inside a try catch . Please give an example

Useful answers will sure be rewarded

Read only

Former Member
Read only

Former Member
0 Likes
1,183

Hi,

You can take the help of below code.

UPDATE zo9_user_status
                SET  sub_date = sy-datum
                     sub_time = sy-uzeit
                     status = g_wa_outtab-status
                WHERE  representative = g_wa_outtab-representative AND
                       selection_id = g_wa_outtab-selection_id AND
                       sub_date = g_wa_outtab-sub_date AND
                       sub_time = g_wa_outtab-sub_time AND
                       superior = g_wa_outtab-superior.

        IF sy-subrc EQ 0.
          COMMIT WORK.
          l_error = 'X1'.

        ELSE.
          l_error = 'X2'.
          CLEAR l_error.
          ROLLBACK WORK.
        ENDIF.

IF l_error = 'X2'.
      MESSAGE e031.
      CLEAR l_error.

    ELSEIF l_error = 'X1'.
      MESSAGE s022.
      CLEAR l_error.

    ENDIF.

hope this helps out.

plz reward if useful.

thanks,

dhanashri