Customizing Sales Order Entry – P42101. Lessons learned

Recently, in Nextper, we received the requirement to enhance the Sales Order Entry P42101, the Sales Order Entry that uses power form. We faced a few challenges and wanted to share what we found; hoping that this will help in case you need to customize it.

Let's explain what was learned using the following example.

Add new field in Header (P421007 Sub form) and copy the header field for each sales order line. We will use User Reserved Reference field (URRF) for the example. This field exists on P42101 grid.

The architecture of Sales Order Detail (P42101 application) is based on the Model-View-Controller (MVC) pattern. It’s critical that you understand this architecture in order to customize it properly.

MODEL VIEW CONTROLLER ARCHITECTURE

Model-View-Controller (MVC) is a design programming scheme that proposes to separate the code of the program by their different responsibilities.

Its foundation is the separation of the code into three different layers, limited by their responsibility: Model, Views & Controllers.

1. Model: For maintaining data (data and its surrounding Business Logic).

2. View Controller: Displaying all or a portion of the data (C functions). Enable the separation of User Interface Logic from the Business Logic.

The views contain the code of our application that will produce the visualization of the user interfaces.

In the view, generally we work with the data; however, a direct access to the data is not made here. The views will require the data to the models and they will generate the output, as our application requires.

3. Application Controller: For handling events that affect the model or view(s). Orchestrate execution of the business logic in the model.

It contains the code needed to respond to the actions that are requested in the application, such as displaying an item, making a purchase, searching for information, etc.

It is actually a layer that serves as a link between views and models, responding to the mechanisms that may be required to implement the needs of our application. However, its responsibility is not to directly manipulate data, nor to show any kind of output, but to serve as a link between the models and the views to implement the various development needs.

Let see how it work the base application following a flow example for better understanding:


User changes a value of the header (P42107). This value will be updated on all sales order lines.

Events typically cause a controller to change a model, or view, or both. Whenever a controller changes a model's data or properties, all dependent views are automatically updated.

1. User edits an order using P42101.

2. CONTROLLER ACTION- P42101 initializes a new JDE Controller session

The controller communicates with both models and views.

3. User changes a value on header

4. VIEW ACTION - P421007 Application Controller updates the header on cache using the View Controller business function

Models request data or have them perform data updates. The models request to the views to show the output, once the relevant operations have been carried out according to the logic of the business.

5. CONTROLLER ACTION - The P421007 sends a message to the P42101 Controller to update the lines

6. CONTROLLER ACTION - The P42101 sends a message to the P421002 Controller to update the lines

7. VIEW ACTION The P421002 receive the message and update the lines using the business function View Controller on cache

To produce the output, sometimes the views can request more information from the models. The controller will be responsible for requesting all data to the models and sending them to the views, bridging each other.

8. The user eventually triggers P42101 to call the JDE controller functions to save the order which eventually calls one of the B4200310 functions.

Let see how it can be customized:

As usual, our goal was to try to modify standard objects as little as possible. So most of the code was added outside the standard functions

User will have new functionality on P42101 Custom application

· New field “User Reserved Reference” on header sales order

· New button “Update User Reserved Reference on Lines” on header sales order

1. Problem Solved: Add new line to sales order

1. User adds a sales order,

2. The new field and button appear on header

3. User enters a value on “User Reserved Reference” field

4. User enters each sales order line and the system will show the value from the header

2. Problem Solved: Change User Reserved Reference value to all sales order lines

1. User selects a sales order to update it

2. A new field “User Reserved Reference” appears on header

3. User enters a value on “User Reserved Reference” field

4. User presses the “Update User Reserved Reference on Lines” button

5. The system updates all sales order line with the header value

How to solve it

Copy P421001, P421002, P421007 applications to custom applications.

Custom P421007 Header Subform Changes

1. Add new field “User Reserved Reference (URRF)” on Custom P421007 Header application

2. Create a new button “Update User Reserved Reference on Lines”. When user presses this button, the system sends a message frm_nMSG_UPDATE_URRF to Custom P42101 application

3. Create the new Msg frm_nMSG_UPDATE_URRF on initialize section

4. Add/Update value on custom cache using SESSION KEY as Cache key when:

a. Exit from the “User Reserved Reference” field

b. Process header

c. Refresh header

The objective is to make available the URRF value on header and detail forms

5. Retrieve the value from the custom cache on FC Initialize Header. This is done to have the value available on the header when it is a change of the order.

Custom P42101 Sales Order Entry Changes

1. Create new msgs frm_nMSG_UPDATE_URRF and frm_nMSG_URRFTOLINES on initialize section

2. FC SOCreate: If copy operation, get value of original order and copy to cache

3. FC Message Dispatcher: When receive VA frm_nMSG_UPDATE_URRF , Notify Detail Subform (Custom S421002A Detail) to update values for all lines (VA frm_nMSG_URRFTOLINES )

Custom P421002 Detail Subform Changes

1. On FC Initialize Subform, Create new msg frm_nMSG_URRFTOLINES

2. On Notified By Parent, if message received is frm_nMSG_URRFTOLINES, the system will update sales order lines with header value

A new button FC URRFTOLINES can be created. This button will retrieve User Reserved Reference value from cache and update all sales order lines

To update each line

1. The line is marked as dirty

2. Sales order view controller is called to VA frm_nPROCESS_SALES_ORDER_LINE

3. The cache line is updated with header value

4. On Row Exit & Changed – Async retrieve value from cache

Hope you find this helpful for your customizations. If you need further detail, please do not hesitate to contact us.

Regards

Contact us at any moment you need help!