Monday, August 13, 2007

Account Generator Custom Error Messages

One of my top 8 Oracle Applications (eBiz) developer hooks is workflow.

Most commonly workflow is used for Approvals and Account Generators.

The Account Generators are very specific little critters with a couple of subtleties, one of which is how they pass back error messages to the user. It ain't hard, just a straightforward 1-2-3 procedure.

  1. Set the Error Message node attribute of the "Abort Generating Code Combination" item attribute "Error Message"
  2. Ensure the workflow goes to "Abort Generating Code Combination" when an error occurs in your custom code
  3. Make sure your code calls FND_MESSAGE and sets the ERROR_MESSAGE item attribute (internal identifier) to fnd_message.get_encoded

Lets do it for the Purchase Order (PO) Account Generator POWFPOAG, process Generate Default Charge Account.

1. Abort Generating Code Combination Error Message attribute.

  • Open up the PO Account Generator in Workflow Builder
  • Navigate to and open process "Generate Default Charge Account".
  • Find and right click to get properties of "Abort Generating Code Combination" after the flow from Generate Default Expense AccountClick the Node Attributes tab
  • Select Error Message from the Name dropdown
  • Choose Type Item Attribute
  • Choose Value "Error Message". NB: This is not in alphabetical order.
  • Save

2. and 3. Code the "Failure" and set the message in your custom code.

In your custom procedure that generates the account, ensure you have code that looks something like the following code. Note we "borrow" the existing generic FND message ERROR_MESSAGE to save having to create a new message and generate message files. Also note that in this specific example we are generating the account based on some component of the Employee's default expense account, which if not setup correctly will set success = 'N'. Of course your logic will be different here, and I don't recommend multiple returns in a function, but this code is presented for simplicity.

if (success = 'N') then
 FND_MESSAGE.set_name('FND', 'ERROR_MESSAGE');
 FND_MESSAGE.set_token('MESSAGE',
   'The PO Account Generator failed to generate the default account. ' ||
   'Please ask your System Administrator to check your ' ||
   'Employee Default Expense Account is setup correctly.');
 wf_engine.SetItemAttrText
         ( itemtype=> itemtype,
           itemkey => itemkey,
           aname   => 'ERROR_MESSAGE',
           avalue  => fnd_message.get_encoded);
 result := 'COMPLETE:FAILURE';
 return;
end if;

All done, test it out! You should see something like the second screenshot when you hit an error.

PS. Persistence and Account Generators showing in Status Monitor

As a side note account generators persistence is "temporary" and also they don't appear under the Status Monitor in Workflow Administrator unless you switch a couple of debug profile options to Yes:

  • PO: Set Debug Workflow ON
  • Account Generator:Run in Debug Mode

PPS. Show workflows to all users with Workflow Admininstrator

For development and test environments, the following may come in handy to enable ALL users with access to Workflow Administrator Status Monitor to see ALL permanent workflows.

prompt Remember what the value was so we can set it back if needed.
select text
from   wf_resources
where  name = 'WF_ADMIN_ROLE';

TEXT
--------------------------------------------------------------------------------
SYSADMIN

update wf_resources
set    text = '*'
where  name = 'WF_ADMIN_ROLE';

1 row updated.

commit;

Happy Account Generating!

16 comments:

iamchandru said...

Hi
I am following the same method what you suggested, but still i could not get the error message in apps.
Do you guess where the problem will be?

Gareth said...

Hi,
1. Make sure your PO Account Generator is using "Generate Default Accounts". You can see this in GL, Setup, Financials, Flexfield, Key, Accounts. Query Title "Accounting Flexfield" and then Item Type PO Account Generator. Note this will also be verfied in 2.
2. Use status monitor to follow the workflow and check that the workflow went to "Abort Generating Code Combination"
3. Put debug call in your code and make sure your code calls FND_MESSAGE and sets the ERROR_MESSAGE item attribute (internal identifier) to fnd_message.get_encoded. Make sure you don't use "when others" or similar construct, as your custom procedure must return the COMPLETE:FAILURE and NOT go any exception handler.

If you're still struggling email me your code and workflow defintion.

Gareth

Maria Imelda said...

hi,
i have done the same thing but no luck. Do you know why is this happening.

if some of you knows about this you can post your answer here. thanks,

maria

Gareth said...

Hi Maria,

Are you using an online account generator like PO Account Generator?

Have you followed the green line to make sure the workflow is getting to the Abort Generating Code Combination?

Have you put debug code in to make sure you are setting the error message correctly?

Gareth

Maria Imelda said...

Hi gareth,

Actually i am doing this for the 4 account generators:
POWFPQAG:PO Account Generator(PO and iPROC)/
POWFRQAG:PO Requisition Account Generator(PO and iPROC)/
PAAPINVW:Project Supplier Invoice Account Generation(AP)/
PAAPWEBX:Project Expense Report Account Generator(iExpense)

And only PO that is not working. It will just give a blank error message.

The code are the same in sending error message to ERROR_MESSAGE attribute in the aborting the accounting generator:

FND_MESSAGE.set_name('FND', 'ERROR_MESSAGE');
FND_MESSAGE.set_token('MESSAGE',
'The Account Generator failed to generate the charge account. ' ||
'Please check your Charge Account Rules if it is setup correctly.' ||
'Failed Account:'||x_segment1_aentity||'.'||x_segment2_naccount||'.'||x_segment3_businessc||'.'||x_segment4_market||'.'||x_segment5_ccenter||'.'||x_segment6_interco||'.'||x_segment7_future);

wf_engine.SetItemAttrText
( itemtype=> p_itemtype,
itemkey => p_itemkey,
aname => 'ERROR_MESSAGE',
avalue => fnd_message.get_encoded);


I have encountered in metalink that this does not work in PO. Bug 3587681 is this true?

By the way, i am doing this in R12 environment.

Yes it going to the abort part and yes i am also using the debug for this which stores in PO_WF_DEBUG table and i am sure of this.

Thanks,
Maria

Gareth said...

Hi Maria,

Per my post this was working in 11.5.10. The bug you mention was closed as not a bug in 11.5.9, but the underlying bug suggested there was an issue, but again in 11.5.9. Haven't tried in R12 as yet.

Either trace your way through the code to see why its failing or log an SR.

PS. Keep the debug option on so the data is stored in wf tables, and purge regularly (as long as performance is not a concern).

Gareth

Maria Imelda said...

Hi,
I have figured out the problem. It has something to do with the standard workflow. This is resolved.

Thanks,
Maria

maity said...

Hi Maria,

Could you please tell how it is resolved. I am facing same issue.

Thanks
Amit

Rajesh said...

Hi
In 11 5 10 we can get the requesition number in a worklow with the help of document id.
But in R12 account generator workflow we dont have any attribute like document id... we have source documet id.. this can give reference of abnket PO not po or req num.... how can we fetch req or PO number

Thanks

Gareth said...

Hi Rajesh,
Not sure on this. If you don't find an answer post a thread on Oracle forums or log an SR.
Regards,
Gareth

Hilde Hage said...

Hi!

I have the same problem as Maria had – it’s only an empty error message that is returned to the application.
I see that the message is populated into the ERROR_MESSAGE attribute, however it does not get displayed in the application.

Do you have any suggestions?

FND_MESSAGE.set_name('FND', 'ERROR_MESSAGE');
FND_MESSAGE.set_token('MESSAGE',
'The PO Account Generator failed to generate the default account. ' ||
p_fnd_message );

wf_engine.SetItemAttrText
( itemtype=> itemtype,
itemkey => itemkey,
aname => 'ERROR_MESSAGE',
avalue => fnd_message.get_encoded);

result := 'COMPLETE:FAILURE';

return;

Hilde Hage said...

I have the same problem as Maria had – it’s only an empty error message that is returned to the application.
I see that the message is populated into the ERROR_MESSAGE attribute, however it does not get displayed in the application.

Do you have any suggestions?

FND_MESSAGE.set_name('FND', 'ERROR_MESSAGE');
FND_MESSAGE.set_token('MESSAGE',
'The PO Account Generator failed to generate the default account. ' ||
p_fnd_message );

wf_engine.SetItemAttrText
( itemtype=> itemtype,
itemkey => itemkey,
aname => 'ERROR_MESSAGE',
avalue => fnd_message.get_encoded);

result := 'COMPLETE:FAILURE';
return;

Niladri Banerjee said...

Maria,

Can u pls post the solution for Rel 12. I am also facing the same issue like many others who posted. But no luck..

Niladri Banerjee

Rajeev Singh said...

Hi Niladri,

Try assign the full error message in a variable and then use that variable in place of fnd_message.get_encoded

See if this works.
This had worked for me.

Thanks,
Rajeev

Sridevi Koduru said...

Regards
Sridevi Koduru (Senior Oracle Apps Trainer Oracleappstechnical.com)
LinkedIn profile - https://in.linkedin.com/in/sridevi-koduru-9b876a8b

Unknown said...

Hello,

Can anyone please post the solution for Rel 12. I am facing the same issue and the only Error message I get back is the Seeded FND Message ICX_POR_INVALID_ACCOUNT.

Please let me know if anyone overcame this.

-- SK