Jul 30 2010

Working with the C API – Error Text Substitution

VN:F [1.9.22_1171]
Rating: 5.0/5 (3 votes cast)

“A fault confessed is half redressed” – Old English Saying

Trapping errors and providing helpful feedback are a number of those mundane tasks which the developer must, sooner rather than later, come to terms with. Proper error management and recovery remain at the heart of our programming responsibilities, and if applied correctly, will pay out future dividends on the time invested in its appropriation.

One technique available to us is that of substituting a portion of the error notification with text appropriate for the actual setting. For example, we may have a defined glossary text which states: “Error opening table”. When triggered in an application our response to this message may very well be: “Yes but which one?” A more helpful message will be “Error opening table F4211”, immediately pointing us in the right direction. However, we want a generic solution; imagine creating an error message for every single table! Fortunately, E1 provides a suitable solution and we need apply only a little time and effort to get it to work efficiently.

To set up text substitution the following steps are required:

• Create the Error Message with a Substitute Parameter(s)

• Create a Data Structure with Substitution Text Members

• Link the Data Structure to the Error Message

• Write a C Function incorporating the jdeErrorSet API

• Call the Function from an E1 Application

This exercise assumes that you have Visual Studio installed and properly configured in the jde.ini.

Create the Error Message with Substitute Parameter(s)

In P92002 – Work with Glossary Items, define a new error message by clicking Add. In this example we will use error code LL010

Create New Error Message

Note that the ampersand symbol (“&”) is used in conjunction with numeric values to define the position of the text substitution.

On the Item Glossary tab enter informative information positioning the “&1”, “&2” etc. parameters appropriately:

Insert Glossary Text

Note the Data Structure Template tab. This is where we will associate the Error Message with our Data Structure, once we have created it.

Data Structure Unlinked

Create a Data Structure with Substitution Text Members

In the OMW create a new structure and name it D55E0022. Use AA10, ALPH and PH1 or other valid items. Name them appropriately. These fields will be used to move the actual substitute text segments into the business function, requiring the input/output arrows to point to the right.

Create New Data Structure

The definition of this structure will be pasted into our .h file when we create the C function. The next step is to link this function to our error message.

Link the Data Structure to the Error Message

Back in P92002 select the Data Structure Template tab, click on Text Substitution, then on the Browse button and select D55E0022.

Data Structure Linked

Write a C Function incorporating the jdeErrorSet API

Many of you may never have written a C function in JDE. I will therefore include the basic steps which may serve as an introduction to the topic.

From the OMW create a new C function. Let’s call it B55E0022 with description “Call Error with Text Substitution”. Select “C” as the Source Language and “Client/Server” as the Function Location.

Create New C Business Function

Click OK and select the Design Tools tab. Click on Select Business Functions Design Aid. For the purpose of this demonstration we will name this function “CallErrorWithSub” (no spaces allowed) with description “Call Error with Substitution Text”. Select the row and click the “Parameter” Row Exit:

Business Function Definition

In the “Select Business Function Parameters” find the D55E0022 structure and select it. Back on the “Business Function Design” screen you will notice that the template name has been added to the definition.

Business Function With DS Template

It is time to generate our basic C function files. Click on the Create button in the main toolbar. Select “Yes” on all prompts to ensure that the function skeletons are created. We now have a B55E0022.c and a B55E0022.h file in our Source and Include directories respectively (these will be listed in the path code we are signed into – for this example it is DEMO).

Header File in Include Directory

Next, click the Typedef button in the Row Exit. This action will display “Your typedef is in the clipboard”, in the message bar at the bottom of the screen. This “typedef” describes our data structure and needs to be pasted in the .h header file.

Select the row containing the function definition in the grid, and on the Form Exit click Edit. Visual Studio should open and load the .h and .c files. Place your cursor just below this section in the .h file:

Press Ctrl + V to paste the typedef into the header file. The result should be as below:

It is important to understand that the mere association of a data structure with a C function (as achieved in Business Function Design) does not make the parameters available to the source file. One has to define the structure in the .h file as we have done above, for C to “see” it.

Save the .h file.

Now select the source .c file. For the purposes of this exercise we will keep the coding to an absolute minimum, in fact we will add one line to the source file only.

Place the cursor just below the comment Main Processing:

Type in the following line:

jdeErrorSet(lpBhvrCom, lpVoid,(ID)0, _J(“LL010”), lpDS);

Typically you don’t need to worry about the first three parameters and can almost always pass them in the same way.

The fourth and fifth parameters need to be commented on: The “LL010” is the id of the error message we created at the beginning of this exercise. The _J () macro transforms the CHAR data type (i.e. “LL0101”) to the Unicode compliant JCHAR type. The fifth parameter passes the pointer itself i.e. the memory address of our data structure to the jdeErrorSet API. The rest of the work is done by the API – once it obtains the location in memory it will find the various members of our structure and work the segments into the error message.

Save the source file and return to “Business Function Design”. Exit the form if necessary to return to the Design Tools tab. From here build the function; hopefully your output will list 0 errors as below:

Build Output

Call the Function from an E1 Application

The final step is to test the function – write a simple application using a Fix Inspect form. Add three appropriate data dictionary items to pass values into the B55E0022 function. Attach the function to a Button control, map the values from the form and Bob’s your uncle!

Test Business Function

It should be noted that the above type of error message is used primarily in interactive applications (forms) where the E1 runtime engine manages and displays it. Grid and UBE error messages are handled differently.

In conclusion, it is clear that with very little effort, one can enhance E1 application error management. I hope that this exercise illuminates more that it confuses. The C API is huge and knowledge of C programming a requirement to using it effectively. However, a small introduction is better than none, and by studying existing E1 examples things eventually become clear. Learning the ins and outs of pointers, data structures and memory management is essential towards developing a sound technical foundation, since these topics form part of the very core of E1 C Programming.

Published under the license.

VN:F [1.9.22_1171]
Rating: 5.0/5 (3 votes cast)
Working with the C API – Error Text Substitution, 5.0 out of 5 based on 3 ratings
(Visited 812 times, 1 visits today)

About the author

Leo Luyendijk

Leo Luyendijk is a Senior Developer for JDE with 16 years exeperience. He has serviced about 35 sites in South Africa and internationally. Leo is one of the Technical Authors on JDE Source.

Appletiser (Fruit and Beverages), BOE (Financial Services), COSI (Printing Supplies)
Donaldsons (Filtration Systems), Electrolux (Electric Appliances),Federal Marine (Fisheries), Gensec (Asset Management), Group Five (Construction), JD Edwards South Africa, Kineses (Pharmaceuticals), Lafarge (Cement), Mondi (Paper and Packaging), MRC (Medical Research), OCEANA (Fisheries), Orthomedics (Orthopedics), Penbev (Beverages), Pernod Ricard (Wine and Spirits), Rand Refinery (Gold Refinery), Rogers Group Mauritius (Finance, Shipping, Aviation etc.), SA Biomedical (Medical), Santam (Insurance and Finance), Seagram (Alcoholic Beverages), Shell (Petrochemicals), Sim (Investment Management), Smiths Manufacturing (Air-conditioning), Supergroup (Supply Chain Management)
Tasc (Asset Management), Tiger Brands (Sweets and Beverages), Usabco (Plastics)
V&A Waterfront (Property), GlaxoSmithKline (Pharmaceuticals).


Skip to comment form

  1. Gavin

    Nice Article – Will be very useful.


    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  2. Renzo

    This is so handy, escpecially if your app has multiple table. Debugging becomes a nightmare to track the error. Here you can go straight to the problem !

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  3. Deepesh M Divakaran

    A very good article. I agree with Renzo, it very much helps to show the exact error, actually meaningful errors.
    One question, instead of creating a new BSFN, can’t we use the existing one – “Text Substitution Error” (B0800366) for setting the error?

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  4. Leo Luyendijk

    Thanks for the feedback guys.

    Yes, one can use the B0800366 which provides 5 slots. jdeErrorSet will match the slots from the top down to the Error message substitution codes, and ignore the bottom ones.

    However, if mastering the C API is the objective, jdeErrorSet and related functions are part of the skillset.

    The same is true for calling UBE’s; both system and businesss functions exist which can do the job, but utilizing the C API’s provides not only insight, but also more control over printing, displaying and bypassing the usual prompts. I hope to do an article on this aspect next.

    Thanks again.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    1. Deepesh M Divakaran

      Could you also do a tutorial on using Cache in BSFN? Actually to say, most technical developers do not like C BSFN’s at all. Probably do not understand it much – Me included

      VN:F [1.9.22_1171]
      Rating: +1 (from 1 vote)
  5. sonal

    hey Leo,

    I liked the starting phrase “A fault confessed is half redressed”..how true and the cover up too..sucha informative article…

    Like what Deepesh said…it would be real cool if you start tuts on basic C ApI’s and Cache..for many of us BSFN’s are a fear factor :)..

    Thanks Pal

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  6. Leo Luyendijk

    Hi Sonal, thanks for the feedback. Yes, when times allows I will submit further topics. Thanks again.

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  7. JJ Du Plessis

    Hi Leo … thank you for great and very informative article. Any tutorials relating to C API’s I find very useful.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  8. jdeman

    I tried the following but receive an error on click/ OK save to return back to Design Tab.

    Parent DLL CCUSTOM, invalid value. I click search Visual Assist but did not found CCUSTOM.

    What Parent DLL can i choose?

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  9. Leo

    Theoreticaly you can use any existing dll such as CFIN etc. However, all custom development should be linked into a new non-standard JDE dll. Use OMW to create a new dll, exit OneWorld and run Busbuild.exe standalone from your bin directory and select Build and then Rebuild Libraries


    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  10. jdeman

    Thanks leo,

    following your instructions, i use a custom dll.

    Im new to C, and following the step i encounter the following on Build Business Function.

    c:\e900\DV900\include\b55er001.h(78) : error C2061: syntax error : identifier ‘ErrorMessageWithTextSubstitution’
    c:\e900\DV900\include\b55er001.h(78) : error C2059: syntax error : ‘;’
    c:\e900\DV900\include\b55er001.h(78) : error C2059: syntax error : ‘type’
    c:\e900\DV900\source\B55ER001.c(44) : error C2061: syntax error : identifier ‘ErrorMessageWithTextSubstitution’
    c:\e900\DV900\source\B55ER001.c(44) : error C2059: syntax error : ‘;’
    c:\e900\DV900\source\B55ER001.c(44) : error C2059: syntax error : ‘type’

    Adjusting DLL load addresses . . .

    ************Build Finished************

    BL560100.dll – 6 error(s), 0 warning(s): Build failed. Restored previous dll.

    Also what is the difference between Buidl Business Function and BusBuild Standalone?

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  11. Leo Luyendijk

    It looks like you have forgotten some semi-colons on lines 44 in the source, and 78 in the header files.

    Busbuild standalone ensures the building of the dll’s outside of a running OneWorld thread i.e. nothing will be use or locked.

    By the way, there are two useful manuals regarind C Programming – BF Programming Guide and API’s and BF Guide These manuals can be found on this very site. Look at JD Edwards EnterpriseOne Documentation – Online & PDF submitted by Deepesh.


    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  12. Gowthami

    Hi Leo,
    I am encountering the following error in Oneworld XE,SP 23

    Error Desc:
    Event Rules Error
    [Invalid Override or Read] The system may become unstable Please debug the application using the Event Rule debugger.
    Application: P0411 Event: Button Clicked
    This error is occurring particularly in Invoice Referral application(P0411-Version WBC0002). Users in a single country having this problem users at others counties are not facing this problem. All are connecting through same set of Citrix servers.
    How to resolve this persisting error? what is the root cause?
    Please help me out ..


    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  13. Leo Luyendijk

    Hi Gowthami

    Sorry for the late reply. Your error could really mean many things. My suggesition is that you ask a CNC specialist to look at your installation.



    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  14. sridhar

    Hi Loe, Thank you somuch for the doc I could create a bsfn on my own for the first time , looking forward for more excercise I feel like i got a good teacher for C bsfns

    thank you somuch

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  15. sheeba

    Leo, do you have any documentation to get the “set ube error” messages to show on the report/batch?

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  16. alfredo


    I used the bussiness function B0800366 TextSubstituionError to customized the error message.The process is right and shows well but I do not know how to remove the message Can you help me?

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    1. Deepesh M Divakaran

      Hi Alfredo,
      Please use the Clear Control Error system function to clear the errors.

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  17. alfredo

    Hello Deepsesh M Divakaran,

    The bussiness function B0800366 is not assigned to any form control, but the funcion C jdeErrorSet assigns to ID 0 wich is the form, and the system function Clear Control Error needs to be passed as a parameter control. Then I need a function that clear all errors to form or a bussiness function that substitution a text error and it assigned the error to form control.


    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  18. Leo Luyendijk

    Hi Alfredo

    Unfortunately there is no system function to clear Form level errors. You can do this for individual controls and for the grid (per cell, record or globally), but not for the Form. This has to do with architecture of ensuring data integrity and uncompromising validation at application level. Form level errors usually involve “fixing” of issues outside the application first e.g. AR record does not exist, or Fetch on F0101 failed etc. Form level errors are usually cleared on Find.

    If you were programming your error substitution in C, the jdeErrorClearEx api becomes available. This will clear the errors as long as the api is called from the business function used to generate the errors itself. However, this defeats the object of generating the errors in the first place.

    I hope this gives better insight. I reckon it is as per design.

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply