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: 

Do while int_table is empty

Former Member
0 Kudos

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

5 REPLIES 5

Former Member
0 Kudos

try this...

if table[] is initial.

method1.

method2.

else.

exit.

endif.

former_member194669
Active Contributor
0 Kudos

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'.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

0 Kudos

Rich,

can you describe me more detailed about "catch cx_some_exception" ?

how to configure cx_someexception ?

Thx,

Gordon

0 Kudos

I find this document very useful in learning how to catch exception in.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f86c9290-0201-0010-7a93-dda...