‎2009 Jun 29 2:36 PM
Hi Gurus,
Please find the below code and let me know, whether this is correct or not.
TRY.
LOOP AT git_tc INTO gwa_tc.
IF gwa_tc-oldqty NE gv_old_qty.
IF NOT gwa_tc-newqty1 IS INITIAL.
gwa_tc-newqty1 = gwa_tc-newqty1 * gv_old_qty.
ENDIF.
IF NOT gwa_tc-newqty2 IS INITIAL.
gwa_tc-newqty2 = gwa_tc-newqty2 * gv_old_qty.
ENDIF.
IF NOT gwa_tc-newqty3 IS INITIAL.
gwa_tc-newqty3 = gwa_tc-newqty3 * gv_old_qty.
ENDIF.
IF NOT gwa_tc-newqty4 IS INITIAL.
gwa_tc-newqty4 = gwa_tc-newqty4 * gv_old_qty.
ENDIF.
IF NOT gwa_tc-newqty5 IS INITIAL.
gwa_tc-newqty5 = gwa_tc-newqty5 * gv_old_qty.
ENDIF.
SHIFT gwa_tc-newqty1 LEFT DELETING LEADING space.
SHIFT gwa_tc-newqty2 LEFT DELETING LEADING space.
SHIFT gwa_tc-newqty3 LEFT DELETING LEADING space.
SHIFT gwa_tc-newqty4 LEFT DELETING LEADING space.
SHIFT gwa_tc-newqty5 LEFT DELETING LEADING space.
ENDIF.
MODIFY git_tc FROM gwa_tc TRANSPORTING newqty1 newqty2 newqty3 newqty4 newqty5.
ENDLOOP.
CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 4.
RAISE exception.
ENDCATCH.Please correct the above code, if needed. I need to handle any kind of Overflow errors.
Thanks,
Chandan
‎2009 Jun 29 2:47 PM
‎2009 Jun 29 2:39 PM
Why not read the F1 help onCATCH SYSTEM-EXCEPTIONS, which even has an example on how to use it.
matt
‎2009 Jun 29 2:47 PM
‎2009 Jun 29 2:52 PM
Hi Experts,
I have already been through the SAP help documentation. Just needed some help immediately, therefore I posted here.
I removed the TRY as TRY and CATCH SYSTEM-EXCEPTIONS wont work simultaneously.
Is this correct now:
CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 4.
LOOP AT git_tc INTO gwa_tc.
IF gwa_tc-oldqty NE gv_old_qty.
IF NOT gwa_tc-newqty1 IS INITIAL.
gwa_tc-newqty1 = gwa_tc-newqty1 * gv_old_qty.
ENDIF.
IF NOT gwa_tc-newqty2 IS INITIAL.
gwa_tc-newqty2 = gwa_tc-newqty2 * gv_old_qty.
ENDIF.
IF NOT gwa_tc-newqty3 IS INITIAL.
gwa_tc-newqty3 = gwa_tc-newqty3 * gv_old_qty.
ENDIF.
IF NOT gwa_tc-newqty4 IS INITIAL.
gwa_tc-newqty4 = gwa_tc-newqty4 * gv_old_qty.
ENDIF.
IF NOT gwa_tc-newqty5 IS INITIAL.
gwa_tc-newqty5 = gwa_tc-newqty5 * gv_old_qty.
ENDIF.
SHIFT gwa_tc-newqty1 LEFT DELETING LEADING space.
SHIFT gwa_tc-newqty2 LEFT DELETING LEADING space.
SHIFT gwa_tc-newqty3 LEFT DELETING LEADING space.
SHIFT gwa_tc-newqty4 LEFT DELETING LEADING space.
SHIFT gwa_tc-newqty5 LEFT DELETING LEADING space.
ENDIF.
MODIFY git_tc FROM gwa_tc TRANSPORTING newqty1 newqty2 newqty3 newqty4 newqty5.
ENDLOOP.
RAISE exception.
ENDCATCH.
‎2009 Jun 29 3:07 PM
DATA : exp TYPE REF TO cx_root .
TRY.
LOOP AT git_tc INTO gwa_tc.
IF gwa_tc-oldqty NE gv_old_qty.
IF NOT gwa_tc-newqty1 IS INITIAL.
gwa_tc-newqty1 = gwa_tc-newqty1 * gv_old_qty.
ENDIF.
IF NOT gwa_tc-newqty2 IS INITIAL.
gwa_tc-newqty2 = gwa_tc-newqty2 * gv_old_qty.
ENDIF.
IF NOT gwa_tc-newqty3 IS INITIAL.
gwa_tc-newqty3 = gwa_tc-newqty3 * gv_old_qty.
ENDIF.
IF NOT gwa_tc-newqty4 IS INITIAL.
gwa_tc-newqty4 = gwa_tc-newqty4 * gv_old_qty.
ENDIF.
IF NOT gwa_tc-newqty5 IS INITIAL.
gwa_tc-newqty5 = gwa_tc-newqty5 * gv_old_qty.
ENDIF.
SHIFT gwa_tc-newqty1 LEFT DELETING LEADING space.
SHIFT gwa_tc-newqty2 LEFT DELETING LEADING space.
SHIFT gwa_tc-newqty3 LEFT DELETING LEADING space.
SHIFT gwa_tc-newqty4 LEFT DELETING LEADING space.
SHIFT gwa_tc-newqty5 LEFT DELETING LEADING space.
ENDIF.
MODIFY git_tc FROM gwa_tc TRANSPORTING newqty1 newqty2 newqty3 newqty4 newqty5.
ENDLOOP.
CATCH cx_root INTO exp.
DATA : cl_name TYPE abap_abstypename .
CALL METHOD cl_abap_classdescr=>get_class_name
EXPORTING
p_object = exp
RECEIVING
p_name = cl_name.
IF cl_name = '\CLASS=CX_SY_ARITHMETIC_OVERFLOW' .
* Your code here
ENDIF.
ENDTRY.
‎2009 Jun 29 5:39 PM
>
> Hi Experts,
>
> I have already been through the SAP help documentation. Just needed some help immediately, therefore I posted here.
>
But you didn't read the syntax of the statement, and if you had you would have seen a sample program. These forums are not for people who can't be bothered to put the effort in.
matt