Skip to main content
Solved

Error Handling of errors RAISED on ERROR_SYS


msurasky-price
Sidekick (Customer)
Forum|alt.badge.img+8

Hello Community!

I have the following Code

-- In this block we perform the actual change.
DECLARE
   PARTTYPEERROR EXCEPTION;

   [SOME_OTHER_VARIABLES]
BEGIN

   FOR sale_part_to_update_rec IN (    
      [SOME_SQL_TO_PERFORM_LOOP]
   ) LOOP      
     p0_ := NULL;
     p1_ := sale_part_to_update_rec.OBJID;
     p2_ := sale_part_to_update_rec.OBJVERSION;
     client_sys.add_to_attr(name_ => 'SOURCING_OPTION', value_ => sale_part_to_update_rec.SOURCING_OPTION, attr_ => p3_);
     client_sys.add_to_attr(name_ => 'RULE_ID', value_ => '', attr_ => p3_);
     p4_ := 'DO';

     BEGIN     
            IFSAPP.SALES_PART_API.MODIFY__( p0_ , p1_ , p2_ , p3_ , p4_ );     
            COMMIT;
     EXCEPTION
        WHEN PARTTYPEERROR THEN 
               [MY_ERROR_HANDLING_CODE]
     END;          
   END LOOP;
END;

I have noticed that even when the IFSAPP.SALES_PART_API.MODIFY code I execute results in an PARTTYPEERROR Exception...

… The block to handle that type of errors is never invoked. The exception is treated as an unhandled exception and the message displayed by PL/SQL Developer and the execution is halted.

 

What am I doing wrong? Should I not IFS Erorrs in this manner? should I catch them using some other approach?

Thanks!

Best answer by dsj

msurasky-price wrote:

It definitely helps @dsj!

 

I managed to implement the code that I needed with the code error handling that was necessary.

The only thing is that I didn’t want to handle all the exceptions using the same logic, that is what I initially wanted to avoid using WHEN OTHERS THEN for all the exceptions and use a WHEN [EXCEPTION_TYPE] instead. I managed to selectively use a different approach but I ended up using the SQLCODE function like this

 

        WHEN OTHERS THEN
             err_code := SQLCODE;
             err_msg := SUBSTR(SQLERRM, 1, 200);
             IF err_code = -20110 THEN
                 [CODE_LOGIC THAT IS SPECIFIC TO -20110]
             ELSE
                -- Simple raise Other exceptions that are NOT -20110
                RAISE;
             END IF;

Would you say this is the best practice?

 

Thanks!

 

Hi @msurasky-price 

 

ORA-20110 is IFS defined exception. All IFS defined exceptions are defined in ERROR_SYS.

A simpler way to do this is

DECLARE
BEGIN
...
WHEN Error_SYS.Err_Appl_General THEN
 [YOUR ERROR HANDLING]
WHEN OTHERS
  RAISE; -- Raise the exception
END;

 

Read more on Error handling in IFS documentation: Error Handling - Technical Documentation For IFS Cloud

 

Cheers!

Damith

View original
Did this topic help you find an answer to your question?

3 replies

dsj
Ultimate Hero (Partner)
Forum|alt.badge.img+22
  • Ultimate Hero (Partner)
  • 855 replies
  • January 22, 2024

Hi @msurasky-price

 

Here you have declared your own exception. Exception block only will hit if you raise your declared exception. Since you are calling standard IFS method, only system/IFS defined exceptions may occur here.

Use WHEN OTHERS since there can be different exceptions can occur during execution 

-- In this block we perform the actual change.
DECLARE
--  PARTTYPEERROR EXCEPTION; no need to declare exception

   [SOME_OTHER_VARIABLES]
BEGIN

   FOR sale_part_to_update_rec IN (    
      [SOME_SQL_TO_PERFORM_LOOP]
   ) LOOP      
     p0_ := NULL;
     p1_ := sale_part_to_update_rec.OBJID;
     p2_ := sale_part_to_update_rec.OBJVERSION;
     client_sys.add_to_attr(name_ => 'SOURCING_OPTION', value_ => sale_part_to_update_rec.SOURCING_OPTION, attr_ => p3_);
     client_sys.add_to_attr(name_ => 'RULE_ID', value_ => '', attr_ => p3_);
     p4_ := 'DO';

     BEGIN     
            IFSAPP.SALES_PART_API.MODIFY__( p0_ , p1_ , p2_ , p3_ , p4_ );     
            COMMIT;
     EXCEPTION
        WHEN OTHERS THEN 
               [MY_ERROR_HANDLING_CODE]
     END;          
   END LOOP;
END;

Hope it helps!

Damith


msurasky-price
Sidekick (Customer)
Forum|alt.badge.img+8
  • Author
  • Sidekick (Customer)
  • 44 replies
  • January 22, 2024

It definitely helps @dsj!

 

I managed to implement the code that I needed with the code error handling that was necessary.

The only thing is that I didn’t want to handle all the exceptions using the same logic, that is what I initially wanted to avoid using WHEN OTHERS THEN for all the exceptions and use a WHEN [EXCEPTION_TYPE] instead. I managed to selectively use a different approach but I ended up using the SQLCODE function like this

 

        WHEN OTHERS THEN
             err_code := SQLCODE;
             err_msg := SUBSTR(SQLERRM, 1, 200);
             IF err_code = -20110 THEN
                 [CODE_LOGIC THAT IS SPECIFIC TO -20110]
             ELSE
                -- Simple raise Other exceptions that are NOT -20110
                RAISE;
             END IF;

Would you say this is the best practice?

 

Thanks!


dsj
Ultimate Hero (Partner)
Forum|alt.badge.img+22
  • Ultimate Hero (Partner)
  • 855 replies
  • Answer
  • January 23, 2024
msurasky-price wrote:

It definitely helps @dsj!

 

I managed to implement the code that I needed with the code error handling that was necessary.

The only thing is that I didn’t want to handle all the exceptions using the same logic, that is what I initially wanted to avoid using WHEN OTHERS THEN for all the exceptions and use a WHEN [EXCEPTION_TYPE] instead. I managed to selectively use a different approach but I ended up using the SQLCODE function like this

 

        WHEN OTHERS THEN
             err_code := SQLCODE;
             err_msg := SUBSTR(SQLERRM, 1, 200);
             IF err_code = -20110 THEN
                 [CODE_LOGIC THAT IS SPECIFIC TO -20110]
             ELSE
                -- Simple raise Other exceptions that are NOT -20110
                RAISE;
             END IF;

Would you say this is the best practice?

 

Thanks!

 

Hi @msurasky-price 

 

ORA-20110 is IFS defined exception. All IFS defined exceptions are defined in ERROR_SYS.

A simpler way to do this is

DECLARE
BEGIN
...
WHEN Error_SYS.Err_Appl_General THEN
 [YOUR ERROR HANDLING]
WHEN OTHERS
  RAISE; -- Raise the exception
END;

 

Read more on Error handling in IFS documentation: Error Handling - Technical Documentation For IFS Cloud

 

Cheers!

Damith


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings