Execute ACTION from STD on Sage X3

Using Sage X3 v12 (2021R3), I try to execute on a TRT the $APRES_CHOI action from STD and SPE.

My process is the following : Object called ZDK, I'm opening an action AZDK1 that opening a custom selection popup (with screens and backend-code).

GACTION = "AZDK1"
Call SAISIE_CHAR(VALBOUT,PARBOUT,"OZDK1","SUBZDK1","SPEZDK1") From GSAISIE

After selecting all field to load, it runs a code that generate element in database. Then I when it come back to the main object ZDK, I want to launch the $APRES_CHOI forcing the RESPONSE var to GSTARAF (1799) that is used to run the screen reload.

In the SPE (SPEZDK) after the field generation, there is a flag that force the $APRES_CHOI to 1799. If I execute any action like : press ENTER, click on a buton... it will reload the screen as I wanted to.

$APRES_CHOI
(...)
If TEST = "OK" Then
  REPONSE = GSTARAF
Endif
Return

I tried to run the standard call that I need like this:

Local Char ACTION
ACTION = "APRES_CHOI"
Gosub ACTION From GOBJSUB

But an error meaning that RESPONSE var isn't set appears :

The point is not to declare all the STD var in my SPE as we can find on this post :  https://www.sagecity.com/us/sage_erp_x3/f/sage-x3-general-discussion-forum/103996/hot-to-invoke-refresh-button

I just want to run the STD that initialise the var before runing the Gosub ACTION From GOBJET/GOBJSUB/GTRAITE.

This post is also avaiable on https://stackoverflow.com/questions/74385935/execute-action-from-std-on-sage-x3


How to call ACTION from STD runing from SPE.

  • Hello Damien. Search for entry points sage x3. STD trataments shouldn't be used in development. Always use SPE for good practices. With the entry point you can call specific code that you develop on standard code.

    https://www.rklesolutions.com/blog/sage-x3-entry-points#:~:text=Identifying%20Available%20Entry%20Points&text=To%20access%20the%20Sage%20ERP,module%20to%20view%20Entry%20Points.

    https://www.greytrix.com/blogs/sagex3/tag/entry-points/

  • 0

    You can try the following:

    ...
    If TEST = "OK" Then
      # Refresh
      Gosub RAFFRAICHIR From GOBJSUB
      Gosub RELIT From GOBJSUB
    Endif
    ...


  • 0 in reply to RobertoMSNascimento

    I tried, but got the following error :

    @X3.TRT/GOBJSUB$adx (2090) Erreur 6 : Variable inexistante FILTRE

    I find out a way to do it as suggested in this post:
    https://www.sagecity.com/us/sage_x3/f/general-discussion/103996/hot-to-invoke-refresh-button    
    In SPEZDK code, I saved all the needed STD var in the $OUVRE.
    In the $AVANT_OK from SPEZDK1 I override all thoses global var to force the refresh with:

    ACTION = "APRES_CHOI"
    Gosub RAFFRAICHIR From GOBJSUB


    This, is working well, but my question is more about which method from the STD I could run to declare all the needed vars before executing "Gosub RAFFRAICHIR From GOBJSUB".

  • 0 in reply to Damien Auvray

    Could you explain when you are attempting to make the call to refresh the left list? You mention that in your object ZDK you call an action, which opens a window, but when you close this window, you want the left list to refresh? How and when do you call this action? Is it via a button on the window or Icon on a screen? Depending on where you call it, you need to save the value of ACTION before setting it to a new value. For example in the in the APRES_CHOI label, if you want to refresh the screen on a specific button, there is no need to set REPONSE variable, simply call "Call RELIT from GOBJSUB" as the context of the action will allow you to that.

  • 0 in reply to Regard Hulsbos

    "which opens a window, but when you close this window, you want the left list to refresh?" -> Yes
    When I close the ZDK1 action by clicking on "OK", this run a code in the $AVANT_OK from SPEZDK1, and I want it to refresh the ZDK object but all the context var are set to the ZDK1 and not to ZDK, so the RELIT dosen't worked.
    To make it work, I overrited all the needed globar in my SPE (in the $APRES_CHOIX from SPEZDK1) with the context var from the $OUVRE from SPEZDK, in this way the call RAFFRAICHIR work well.

    The subject of this question, is more about how can I call the initialisation of all those context vars to prevent this : 

    TYPGES = YTYPGES
    CLECUR = YCLECUR
    CLECUR1 = YCLECUR1
    CLECUR2 = YCLECUR2
    ABFIC = YABFIC
    CLEPRIM = YCLEPRIM
    PROGOBJ = YPROGOBJ
    VERROU = YVERROU
    OVERROU = YOVERROU
    SYMBOLE = YSYMBOLE
    NBMASK = YNBMASK
    WINPROG = YWINPROG
    AMA = YAMA
    AIMGLCK = YAIMGLCK
    FILTRE = YFILTRE
    FILGAUCHE = YFILGAUCHE
    IFILGAUCHE = YIFILGAUCHE

  • 0 in reply to Damien Auvray

    When entering an object window, the default variables are set and store in label DEFVAR either during the launch of labels DEBUT or VARIANTE in process GOBJET. The variables mentioned are stored in local variables with the prefix of SAV*. You can refresh the stored variable to your context using "Gosub SORT from GOBJET".

    The question I have is, are both of these windows Object managed? What is the action AZDK1 defined type? Normally you do not need to save or restore these variables as the supervisor manages this for you, in both instances either process GTRAITE or GOBJET should store and restore the context variables unless for some reason there is a premature termination and it does not complete the code execution.

  • 0 in reply to Regard Hulsbos

    AZDK1 is a windows type ("saisie de fenêtre") which is a non-object managed : OZDK1. It just disp a table with parameters that will generate data (write in table) for the ZDK object.
    After that the user selected all the data to generate, he just have to valid, this come back on the ZDK object, automatically refresh it thanks to $RAFFRAICHIR on the $AVANT_OK from ZDK1, and the user can start using the ZDK object.

    So ZDK1 is a non object, that explain why all the global env vars arn't set in context.

  • 0 in reply to Damien Auvray

    You can try the following, open the mask as a local instance and the call the following, I am assuming the mask on the screen is ZDK1:

    $APRES_CHOI

    Local Mask ZDK1 [ZDK]
    # SET THE VALUES ON THE MASK AND CALL THE FOLLOWING TO OPEN THE WINDOW
    # THE FUNCTION BELOW TAKES TWO VALUES, FIRST IS WINDOW TITLE AND SECOND IS WINDOW TO OPEN
    Call AFFWIN("MESSAGE YOU WANT TO DISPLAY ON THE WINDOW", "OZDK1") From GESECRAN

    # PERFORM WHAT NEEDS TO BE DONE ON THE SCREEN, AND CLOSE IT

    Close local Mask [ZDK]

    # FORCE  A REFRESH

    Gosub RELIT from GOBJSUB

    Return

  • 0 in reply to Regard Hulsbos

    The action AZDK1 that is calling all the code behind the OZDK1 windows insn't call with the AFFWIN (like button, loading elements ...).