Tuesday 9 June 2015

APEX 4.2.6 and g_print_success_message issue

Apex_application.g_print_success_message limitations

Hope this saves you some time

The other day I was working on one of our report applications and encountered the weirdest problem ever. At least it turned out to be and just because it took me a while to understand where the problem is I decided to blog about it.

The story goes like this, users set up a parameters run a report and they receive a success message as the end result. All was fine until I was running a loop for 40+ reports then I started getting some weird error messages at the end of the process. Report files would generate perfectly fine but I would still get an error on my screen.

After whole lot of testing I managed to trace it down to g_print_success_message that was used within one of my packages.

To demonstrate this I created a simple page with a button that executes a simple process. 

Process on this page is nothing but
begin
apex_application.g_print_success_message :='Successfully completed';
end;
Now we come to the point to what story is about. In my package what I would do is 
apex_application.g_print_success_message := apex_application.g_print_success_message|| '<br> Successfully completed for file:' || Filename_x;
concatenate messages so that user would be presented with list of all successfully completed report filenames. 

As mentioned previously I had no reason to believe this would ever fail. Boy was I wrong. 

For demo purposes try doing something like this, change your g_print_success_ message to include a long text such as this one below. 

By long I mean more than 2890 rows at least this is a figure I managed to get to. 
:)

apex_application.g_print_success_message :='<br> Your report <font color="blue">BIS_01052015-31052015_BIS0002.RTF </font> has been successfully saved.<br> Your report <font color="blue">BIS_01052015-31052015_BIS0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">CIVO_01052015-31052015_CIVO0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">MANA_01052015-31052015_MANA0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">ASCO_01052015-31052015_ASCO001.RTF </font> has been successfully saved.<br> Your report <font color="blue">ASCO_01052015-31052015_ASCO002.RTF </font> has been successfully saved.<br> Your report <font color="blue">STOC_01052015-31052015_STOC0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">SAH_01052015-31052015_SAH0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">TBH_01052015-31052015_TBH0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">LLE_01052015-31052015_LLE0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">STVM_01052015-31052015_STVM0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">AMPC_01052015-31052015_AMP0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">NETT_01052015-31052015_NETT0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">BKL_01052015-31052015_BKL0002.RTF </font> has been successfully saved.<br> Your report <font color="blue">GPC_01052015-31052015_GPC0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">GSL_01052015-31052015_GSL0002.RTF </font> has been successfully saved.<br> Your report <font color="blue">WOTI_01052015-31052015_WOTI0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">FOXT_01052015-31052015_FOXT0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">LNS_01052015-31052015_LNS0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">SPBS_01052015-31052015_SPBS0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">SPBS_01052015-31052015_SPBS0002.RTF </font> has been successfully saved.<br> Your report <font color="blue">SPBS_01052015-31052015_SPBS0003.RTF </font> has been successfully saved.<br> Your report <font color="blue">ICMS_01052015-31052015_ICMS0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">APTM_01052015-31052015_APTM0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">APTM_01052015-31052015_APTM0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">APTM_01052015-31052015_APTM0001.RTF </font> has been successfully saved.<br> Your report <font color="blue">APTM_01052015-31052015_APTM0001.RTF </font>  has been  successfully!';
Please notice here this exclamation mark at the end. If you try to run this you now get: 
But where does this come from? Try running without this exclamation mark at the end and your page would render perfectly fine. Understandably you would argue what is the whole point in displaying something long as this to a user, which is a fair point, but I never expected to get an error for this in a first place.

Obviously after long day of thinking and debugging your "brilliant" code you come to a conclusion that there is nothing wrong with it and that there must be some character conversion issue taking place within the core APEX engine. 

If you had a look at definition of g_print_success_message in APEX_040200. wwv_flow package you would find something like this:



Why would this then fail when it can be 4000 bytes? I am still not sure but it is something you should be aware of.

Cheers,
SLino

No comments:

Post a Comment