08-13-2008 2:39 PM
hi,
im using a badi which is performing a lot of methods. Each method changes an Error_Table if something is going wrong.
Is there an easier way than this ?
if table is initial.
method1
else.
exit.
endif.
if table is initial.
method2
else.
exit.
endif.
I would like to exit the badi if the table contains an entry.
note: there is no loop step over the methods.
What about using "catch" or "while" or something else ?
Thx,
Gordon
08-13-2008 2:42 PM
try this...
if table[] is initial.
method1.
method2.
else.
exit.
endif.
08-13-2008 2:46 PM
May be you can try with macro.
Please find a the following macro i have used in on the program for updating tables
* Macro for controling the update tables
define updatetable.
if v_eflg ne c_y.
if not &2[] is initial.
modify &1 from table &2.
if sy-subrc ne 0.
move c_y to v_eflg.
if not &2[] is initial.
i_idoc_status-docnum = v_docnum.
i_idoc_status-status = '51'.
i_idoc_status-msgty = 'E'.
i_idoc_status-msgid = 'YCC'.
i_idoc_status-msgno = '733'.
i_idoc_status-msgv1 = &3.
i_idoc_status-msgv2 = ' '.
i_idoc_status-msgv3 = ' '.
i_idoc_status-msgv4 = ' '.
append i_idoc_status.
endif.
else.
i_idoc_status-docnum = v_docnum.
i_idoc_status-status = '53'.
i_idoc_status-msgty = 'S'.
i_idoc_status-msgid = 'YCC'.
i_idoc_status-msgno = '736'.
i_idoc_status-msgv1 = &3.
i_idoc_status-msgv2 = ' '.
i_idoc_status-msgv3 = ' '.
i_idoc_status-msgv4 = ' '.
append i_idoc_status.
endif.
endif.
endif.
end-of-definition.
updatetable yattrid i_yattrid 'YATTRID'.
a®
08-13-2008 3:03 PM
Yes, you can use exceptions classes and TRY..CATCH staetments to do this. Each method would need to raise an exception after writing to the ERROR_TAB, then in your main method, it would catch these exceptions.
try.
call method method1
call method method2
call method method3
call method method4
catch cx_some_exception.
return
endtry.
So basically, if any of the methods raise the exception, then the rest of the methods will not be called.
Regards,
Rich Heilman
08-13-2008 3:28 PM
Rich,
can you describe me more detailed about "catch cx_some_exception" ?
how to configure cx_someexception ?
Thx,
Gordon
08-13-2008 3:39 PM
I find this document very useful in learning how to catch exception in.
a®