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: 

Old and new exceptions cannot be used the same time, what does this mean???

Former Member
0 Kudos

Hi

I just wrote a little routine and after testing it I wanted to implement it in an extractor structure.

However after implementing it appropriately and trying the syntax check I get the error:

<i>Old and new exceptions cannot be used the same time</i>

What does this mean??? I have no clue what they are reffering to.....

21 REPLIES 21

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Are you using any exception classes or raising any exceptions? Please post your code.

Regards,

Rich Heilman

former_member188685
Active Contributor
0 Kudos

Hi Nana,

write the relevant code where it is giving that exception. i think you told some time back it is from <b>Provide.</b>

regards

vijay

0 Kudos

The error occurs right in front of the provide function. As far as I know I am not using any exceptions. My own code starts from the select statement and everything else is taken from a demo extractor.

I am rather new to ABAP so I am a bit lost here, anybody got an idea?

FUNCTION z_bw_hcm_emp_del.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     REFERENCE(X_DATEFROM) TYPE  RSDATEFROM
*"     REFERENCE(X_DATETO) TYPE  RSDATETO
*"     REFERENCE(NATCO) TYPE  /BIC/OIC_MM_001
*"     REFERENCE(I_INITFLAG) TYPE  SRSC_S_IF_SIMPLE-INITFLAG
*"     REFERENCE(I_MAXSIZE) TYPE  SRSC_S_IF_SIMPLE-MAXSIZE
*"     REFERENCE(I_DSOURCE) TYPE  SRSC_S_IF_SIMPLE-DSOURCE
*"     REFERENCE(I_REQUNR) TYPE  SRSC_S_IF_SIMPLE-REQUNR
*"     REFERENCE(I_READ_ONLY) TYPE  SRSC_S_IF_SIMPLE-READONLY
*"     REFERENCE(I_REMOTE_CALL) TYPE  SBIWA_FLAG
*"  TABLES
*"      I_T_SELECT TYPE  SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
*"      I_T_FIELDS TYPE  SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
*"      E_T_DATA STRUCTURE  ZBW_HCM_EMP_DEL OPTIONAL
*"  EXCEPTIONS
*"      NO_MORE_DATA
*"      ERROR_PASSED_TO_MESS_HANDLER
*"----------------------------------------------------------------------

* Daten definieren
*----ITABS
  DATA: itab_qemp LIKE TABLE OF /bic/qemployee,
       itab_sub_qemp LIKE TABLE OF /bic/qemployee,
       itab_sub_sub_qemp LIKE TABLE OF /bic/qemployee,
       itab_out LIKE TABLE OF /bic/qemployee,
       itab_statu LIKE TABLE OF /bic/qemployee .

*-----WorkingAreas
  DATA: wa_qemp LIKE LINE OF itab_qemp,
        wa_statu LIKE LINE OF itab_qemp.

*----DataTypes
  DATA: wkh TYPE p DECIMALS 2,
        wkhdelta TYPE p DECIMALS 2,
        count1 TYPE i,
        count TYPE c,
*--------Variables
        x LIKE /bic/qemployee-/bic/emplstatu.

* Auxiliary Selection criteria structure
  DATA: L_S_SELECT TYPE SRSC_S_SELECT.

* Maximum number of lines for DB table
  STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,

* counter
          S_COUNTER_DATAPAKID LIKE SY-TABIX,

* cursor
          S_CURSOR TYPE CURSOR.





* Select ranges
* Initialization mode (first call by SAPI) or data transfer mode
* (following calls) ?
  IF i_initflag = sbiwa_c_flag_on.

************************************************************************
* Initialization: check input parameters
*                 buffer input parameters
*                 prepare data selection
************************************************************************

* Check DataSource validity
    CASE i_dsource.
      WHEN 'HCMDE_DEL_EMP'.
      WHEN OTHERS.
        IF 1 = 2. MESSAGE e009(r3). ENDIF.
* this is a typical log call. Please write every error message like this
*        LOG_WRITE 'E'                  "message type
*                  'R3'                 "message class
*                  '009'                "message number
*                  I_DSOURCE   "message variable 1
*                  ' '.                 "message variable 2
*        RAISE ERROR_PASSED_TO_MESS_HANDLER.
    ENDCASE.

    APPEND LINES OF i_t_select TO s_s_if-t_select.

* Fill parameter buffer for data extraction calls
    s_s_if-requnr    = i_requnr.
    s_s_if-dsource = i_dsource.
    s_s_if-maxsize   = i_maxsize.

* Fill field list table for an optimized select statement
* (in case that there is no 1:1 relation between InfoSource fields
* and database table fields this may be far from beeing trivial)
    APPEND LINES OF i_t_fields TO s_s_if-t_fields.

  ELSE.                 "Initialization mode or data extraction ?

************************************************************************
* Data transfer: First Call      OPEN CURSOR + FETCH
*                Following Calls FETCH only
************************************************************************

* First data package -> OPEN CURSOR
    IF s_counter_datapakid = 0.

* Fill range tables BW will only pass down simple selection criteria
* of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.



* Determine number of database records to be read per FETCH statement
* from input parameter I_MAXSIZE. If there is a one to one relation
* between DataSource table lines and database entries, this is trivial.
* In other cases, it may be impossible and some estimated value has to
* be determined.

* Copy table into ITAB
      SELECT * FROM /bic/qemployee INTO wa_qemp WHERE /bic/c_mm_001 EQ natco AND objvers EQ 'A'.
        APPEND wa_qemp TO itab_qemp.
      ENDSELECT.

*___Clear wa
      CLEAR wa_qemp.

* Sort table
      SORT itab_qemp BY /bic/employee /bic/c_mm_001 dateto.

* split table into ID & NATCO-dependent subtables
      LOOP AT itab_qemp INTO wa_qemp.
        APPEND wa_qemp TO itab_sub_qemp.

*---process subtables
        AT END OF /bic/employee.
          LOOP AT itab_sub_qemp INTO wa_qemp.

            APPEND wa_qemp TO itab_sub_sub_qemp.
* ------check if set of active period ends.
            IF x NE wa_qemp-/bic/emplstatu AND x EQ '3'.
* ------reduce to relevant selection according to time-window and

              PROVIDE FIELDS * FROM itab_sub_sub_qemp INTO wa_qemp
                VALID count
                BOUNDS datefrom AND dateto
                BETWEEN x_datefrom AND x_dateto.

                IF wa_qemp-/bic/emplstatu = '3'.
                  APPEND wa_qemp TO itab_statu.
                ENDIF.
              ENDPROVIDE.

*      ------Calculate deltas for working hours
              LOOP AT itab_statu INTO wa_statu.
*      ---------Remove initial change (starting to work in period 1)
                IF sy-tabix = '1'.
                  wkh = wa_statu-/bic/hcmglwhrs.
                ENDIF.

*      ---------calculate delta workinghours
                wkhdelta = wa_statu-/bic/hcmglwhrs - wkh.
*      ---------store current working hours to calculate delta in next
*circle
                wkh = wa_statu-/bic/hcmglwhrs.
*      ---------insert Delta in line
                wa_statu-/bic/hcmglwhrs = wkhdelta.
*      ---------append line into itab
                APPEND wa_statu TO itab_out.

              ENDLOOP.

              CLEAR itab_statu.

              CLEAR itab_sub_sub_qemp.
            ENDIF.
            x = wa_qemp-/bic/emplstatu.
          ENDLOOP.
          CLEAR itab_sub_sub_qemp.
*______Clear ID dependent sub-table
          CLEAR itab_sub_qemp.
        ENDAT.

      ENDLOOP.


*---Write TABLES

*___Clear wa
      CLEAR wa_qemp.
*--Printe results
      LOOP AT itab_out INTO wa_qemp.
        IF wa_qemp-/bic/hcmglwhrs NE 0.
          MOVE wa_qemp into corresponding fields of table e_t_data.
        ENDIF.
      ENDLOOP.
    ENDIF.
  ENDFUNCTION.

0 Kudos

You have another opened for the same issue. Please close that one or this one so that you get the answers in one place.

I am posting an extract from your code here. You are using the same work area in your LOOP statement and then again in your PROVIDE statement. See if using different work areas may solve your problem.


LOOP AT itab_sub_qemp <b><u>INTO wa_qemp</u></b>.
 
            APPEND wa_qemp TO itab_sub_sub_qemp.
* ------check if set of active period ends.
            IF x NE wa_qemp-/bic/emplstatu AND x EQ '3'.
* ------reduce to relevant selection according to time-window and
 
              PROVIDE FIELDS * FROM itab_sub_sub_qemp <u><b>INTO wa_qemp</b></u>
                VALID count
                BOUNDS datefrom AND dateto
                BETWEEN x_datefrom AND x_dateto.
 
                IF wa_qemp-/bic/emplstatu = '3'.
                  APPEND wa_qemp TO itab_statu.
                ENDIF.
              ENDPROVIDE.

0 Kudos

Srinivas,

Why would using the same work area throw a syntax error? It might not give the expected/correct results but shouldn't be a syntax issue.. unless the syntax checker in BW is that intelligent..

Regards,

Suresh Datti

0 Kudos

Actually using the work area twice is not a problem, I basically override it. The Program runs fine if I use it without the extractor framework.

Is there anybody who has an idea on where I can find information on this issue?

Greetings,

Nana

0 Kudos

Suresh,

To be frank, I too think it should not be the cause. But looking at the code, I didn't see anything wrong. Also, I haven't heard of this error before and there seems to be no such error in R/3. So I was just trying to eliminate all the possibilities.

0 Kudos

it looks like a BW issue.. pl post it in & try your luck..

Regards,

Suresh Datti

0 Kudos

Hi,

its not BW specific, this error is about class based exception.

i couldnt go thru your whole code to see where you have the expception.

for using class based exception you should follow the following syntax.

raise exception type <exception Class>.

for more on this check out this document on using ABAP (page 35)

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1be1003-0701-0010-3795-f87...

Regards

Raja

0 Kudos

The reason why I called it BW issue is because of the fact that it is an extractor and may be the exception is something specific to BW. I didn't find this exception in R/3, at least, not in 47 version. Also, I don't see any classes being used.

0 Kudos

it was new to me as well as i starte dto use class based expection, i just hit the error and found the right syntax.

Regards

Raja

0 Kudos

Thanks Raja, I haven't used it yet. I guess, a question now is whether the BW system that this is written on is on netweaver 2004s or not.

0 Kudos

I thing the class based exception was introduced from was6.20 (i am not sure), but i tried my code on a WAS6.40 system

Regards

Raja

0 Kudos

Hi everybody

I found some info regarding this problem. It seems that there are two versions of provide, on using the old exception method and one the new oo based. As the FB uses the old it must be that my provide uses the new exception method.

I have to investigate a bit further but I will let you know as soon as I found some more info.

Regards,

Nana

0 Kudos

Thanks Nana, it is really encouraging to see that people are sharing their solutions here not just asking questions.

Please do let us know if you find the solution.

Srinivas

0 Kudos

Hi Nana,

When you defined the function, did you check the

"Exceptn Classes" checkbox on?

This will be on the Exceptions tab. A checkbox next to the Cut,Copy,Paste etc. icons.

If so, please uncheck that and see.

Being an extractor, I don't think you can use Class based exceptions (Unless you are calling this function in your own code).

If you want to use Exception based classes, then call the function in a TRY. ENDTRY. block and handle exceptions there.

You said that you copied this function from a demo extractor.

What is the name of the demo extractor?

Hope this helps.

Cheers,

-Ramesh

Former Member
0 Kudos

Hi,

There are two ways of raising exceptions.

1. <b>Message E000 Raising INVALID_DATA.</b>

2. <b>RAISE class based exception.</b>

In your case you have to use the first method. all need is to declare the message-id in the function group and raise the exception.

If you want to include the class based exception in your function module then check the CHECK BOX - EXCEPTN CLASSES in the Exception Tab of the function module.

Now.... handling exception using a class is a new concept.

<b>Exceptions in Function Modules and Methods</b>

To enable error situations in procedures to be handled by the caller, exceptions have been defined in the interface of function modules and methods. For global procedures, the exceptions were defined in the ABAP Workbench. For local methods, they were defined with the EXCEPTIONS addition of the METHODS statement. Exceptions defined in this way can be raised within the procedure with the RAISE statements and with the RAISING addition of the MESSAGE statement.

Exceptions that are defined like this in the interface are handled using the EXCEPTIONS additions of the corresponding CALL statements. These exceptions cannot be forwarded in the call hierarchy. Not handling them leads to a runtime error.

By using the predefined exception ERROR_MESSAGE after the EXCEPTIONS addition of a procedure call, messages of type E and A sent with the MESSAGE statement can also be handled as exceptions.

The principle of these self-defined exceptions are raised as mentioned below

<b>Raising Exceptions</b>

There are two ABAP statements for raising exceptions. They can only be used in function modules:

RAISE <except>.

and

MESSAGE..... RAISING <except>.

The effect of these statements depends on whether the calling program handles the exception or not. If the name <except> of the exception or OTHERS occurs in the EXCEPTIONS addition of the CALL FUNCTION statement, the exception is handled by the calling program.

If the calling program does not handle the exception

The RAISE statement terminates the program and switches to debugging mode.

The MESSAGE ..... RAISING statement display the specified message. How the processing continues depends on the message type.

If the calling program handles the exception, both statements return control to the program. No values are transferred. The MESSAGE ..... RAISING statement does not display a message. Instead, it fills the system fields SY-MSGID, SY-MSGTY, SY-MSGNO, and SY-MSGV1 to SY-MSGV4.

Check the below links for the Documentation on exception

Exception in Function Modules.

http://help.sap.com/saphelp_47x200/helpdata/en/9e/d58167116711d5b2f40050dadfb92b/content.htm

Class Based Exception

http://help.sap.com/saphelp_47x200/helpdata/en/55/bff20efe8c11d4b54a006094b9456f/content.htm

I hope the links provide you with the useful information.

Regards,

Vara

Former Member
0 Kudos

Hi, Nana,

It seems that I have the same problem. If you have solved yours can you please share the solution?

Thanks, Marko.

0 Kudos

If I remember it correctly it is related to an exception which was used in the framework. The problem is that it is not possible to combine ABAP OO exceptions (used in the framework) with the traditional exceptions (used in your coding).

I will try look it up tonight.

Greetings,

Nana

Former Member
0 Kudos

<<E: Old and new exceptions cannot be used at the same time.>>

Hi Nana and others,

I had the same problem and found the solution.

Though I realize I am answering this thread 2 years after its creation, I find it useful because Nana's problem is BW specific. Anyone involved in an upgrade to BW 7.0 will be confronted with the OO ABAP concept for so-called Routine Based Transformations.

Search your code for statements starting with the keyword "RAISE".

Anywhere you use this statement, replace it to set a value for the parameter ABORT.

This parameter is passed on to the routine where your code is placed in, after the routine is finished the value for ABORT is passed back and further handled by the method start_routine/inverse_start_routine/compute_<characteristic>.

The only thing left to say is that Nana mentioned he found documentation about 2 ways (old and new) to handle exceptions on the PROVIDE statement. This I have not investigated as I did no use the PROVIDE statement.

Wendy

Former Member
0 Kudos

Hi,

You are using EXCEPTIONS statement in function definition:

FUNCTION z_bw_hcm_emp_del.

....

....

*"  EXCEPTIONS

*"      NO_MORE_DATA

*"      ERROR_PASSED_TO_MESS_HANDLER

and RAISE statement for "throw" this exception in program. This is not possible. You should use the RAISING statement instead of EXCEPTIONS in function or method definition.