Difference between Sage X3 ACTIONS – APRES_MODIF v/s AM_XXX

By | February 18, 2012

We have come across many technical queries regarding the actions of Sage ERP X3, one of them was
“Could anybody tell me what is the major difference between field after the change (AM_XXX) and APRES_MODIF events, and which of them better to use?”

It quite true that in X3 with so many events at our disposable, sometimes it can be difficult to choose from actions that virtually are same but are quite different. So I saw a point in writing a blog on this.

The APRES_MODIF action:
It is an object action that is called as and when a field is modified. We have defined the action which occurs just before the APRES_MODIF is fired.

  • After the field AM_ (After Change) action.
  • Before the [M] class is updated with the new value.

Following are the available variables with this action:

COUZON: Name of current field.
CZ: Current value of field.
COUIND: Current index (Array fields).

The AM_XXX action:
This action fires After Modification of the screen fields XXX on the screen, but to trace this action user need to define the action type against the respective field.

The Action type selected is ‘After Change’ the Screen Dictionary. This action comes with a default parameter ‘VALUER’. The VALUER contains current field value whereas [M] XXX contains the value before the field was modified.

Difference between the 2 actions:
APRES_MODIF:
APRES_MODIF is an object action. Object actions are global events that are executed when users maintain or navigate through records in an object. Object Actions are triggered any time a user accesses an object, navigates through records, any event triggered using the action buttons, refreshes the screen, changes the left browser, creates, modifies or deletes an object etc.
Code View:
####################################################################################
$ACTION
Case ACTION
When   ‘APRES_MODIF’   :   Gosub   APRES_MODIF
When   Default
Endcase
RETURN

####################################################################################
####################################################################################
$APRES_MODIF
For I=0 To 2
If evalue(“dim([M:ZPH”+num$(I)+”]DACDIA)>0 & [M:ZPH”+num$(I)+”]DACDIA<>'”+[F:ZPH]DACDIA+”‘”)
Case I
When 0 : [M:ZPH0]DACDIA=[F:ZPH]DACDIA : Affzo [ZPH0]DACDIA
When 1 : [M:ZPH1]DACDIA=[F:ZPH]DACDIA : Affzo [ZPH1]DACDIA
When 2 : [M:ZPH2]DACDIA=[F:ZPH]DACDIA : Affzo [ZPH2]DACDIA
Endcase
Break
Endif
Next I
RETURN

####################################################################################
Here, we are checking three fields on three different screens for change in value and are accordingly enabling it. This way, APRES_MODIF can be used when we need to validate or execute a function on update of any field on the screen (not only one.)

AM_XXX:
The AM_XXX is a field action assigned against any specific field of the screen dictionary. Thus the action is fired whenever any change is registered against the specific field.

Code View:
####################################################################################
## Section automatically added (screen XDM0)
####################################################################################
Subprog AM_REGDAT (VALUER)
Variable Date VALUER
If VALUER > date$
                Infbox “The registration date cannot be greater than current date.”       
                mkstat = 2                          
Endif     
End
####################################################################################
This way, the AM_XXX action can be used for the validation of a specific field or to fire functions specific to that field.
Hope this clarifies the confusion between the 2 actions.

Enjoy Coding in X3.  For some quick help please free to contact us on x3@greytrix.com

About Us
Greytrix – a globally recognized Premier Sage Gold Development Partner is a one-stop solution provider for Sage ERP and Sage CRM needs. Being recognized and rewarded for multi-man years of experience, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third-party add-on development and implementation expertise.

Greytrix caters to a wide range of Sage Enterprise Management (Sage X3) offerings – a Sage Business Cloud Solution. Our unique GUMU™ integrations include Sage Enterprise Management (Sage X3) for Sage CRMSalesforce.com and Magento eCommerce along with Implementation and Technical Support worldwide for Sage Enterprise Management (Sage X3). Currently we are Sage Enterprise Management Implementation Partner in East Africa, Middles East, Australia, Asia. We also offer best-in-class Sage X3 customization and development services, integrated applications such as POS | WMS | Payment Gateway | Shipping System | Business Intelligence | eCommerce and have developed add-ons such as Catch – Weight  and Letter of Credit for Sage Enterprise Management to Sage business partners, end users and Sage PSG worldwide.

Greytrix is a recognized Sage Rockstar ISV Partner for GUMU™ Sage Enterprise Management – Sage CRM integration also listed on Sage Marketplace; GUMU™ integration for Sage Enterprise Management – Salesforce is a 5-star app listed on Salesforce AppExchange.

For more information on Sage X3 Integration and Services, please contact us at x3@greytrix.com. We will be glad to assist you.