Sage X3 how get the ‘available quantity’

The function below returns the available quantity of an item in a site

Funprog GET_STODISP(XXFCY,XXITM)
   Value Char XXFCY   #Stock Site
   Value Char XXITM   #Item code

   #Opens the tables
   If clalev([F:YITV]) = 0 Then Local File ITMMVT [F:YITV] : Endif
   If clalev([F:ITM]) = 0 Then Local File ITMMASTER [F:ITM] : Endif
   If clalev([F:ITG]) = 0 Then Local File ITMCATEG [F:ITG] : Endif
   Filter [F:ITM]
   Read [F:ITM]ITM0 = XXITM
   Filter [F:ITG]
   Read [F:ITG]ITG0 = "";[F:ITM]TCLCOD
   Filter [F:YITV]
   Read [F:YITV]ITV0=XXITM;XXFCY

   Local Integer WSTA
   Local Decimal YSTODIS
   WSTA=0
   YSTODIS=0
   If [F:ITG]GLOAAAFLG = 2 WSTA += 1 Endif
   If [F:ITG]GLOQQQFLG = 2 WSTA += 2 Endif
   If [F:ITG]GLORRRFLG = 2 WSTA += 4 Endif

   #Call the X3 standard procedure for X3 version 1.4.x and 5
   Call STODISPO("[F:YITV]",XXFCY,XXITM,"*","*",1,WSTA,"","",YSTODIS) From STKLIB

   #Call the X3 standard procedure for X3 Version 6
   #Call STODISPO("[F:YITV]",XXFCY,XXITM,"*","*",1,WSTA,"","","",YSTODIS) From STKLIB
End YSTODIS
Advertisements

16 thoughts on “Sage X3 how get the ‘available quantity’

  1. Hi,

    It’s a proprietary language interpreted and executed by the X3 application server.

    It’s a language focused on the data manipulation. Adonix (the company who created X3 ) consider it a fourth generation language (4GL)

    Regards

    Matteo

    1. Hi,

      STODISPO is a subroutine and STKLIB is the file module containing the STODISPO subroutine.

      If you know VB6, is quite similar

      STKLIB is an X3 standard module, peraphs you have not the source but only the compiled file. Without the source (.src extention) you can’t browse the code.

      Matteo

      1. Thank you Matteo.

        How can I use your function in “SUBSQH” such that system can display ‘available qty’ on the bottom status bar when I move the keyboard cursor to “Quoted” field during Quote creation?

      2. Hi,

        Personally, to do that, I prefer proceed in this way:

        1) Open the form SQH2 and add an ‘After change’ action at the field ITMREF with SPE as Action

        2) Validate the form

        3) Put this piece of code into te body of Subprog AM_ITMREF

        Subprog AM_ITMREF(VALEUR)
        Variable Char    VALEUR()
            
            Local Double YQTYDISP
            YQTYDISP = func YFUNC.GET_STODISP([M:SQH0]SALFCY,VALEUR)
        
            Inftxt "Available qty: " + num$(YQTYDISP) At 2
        
        End
        

        4) Validate all the ‘Offer’ transactions

        Matteo

  2. Hi, I received 2 error messages “st_val:Type incompatibility” and “@DEMO.TRT/YFUNC$adx(25): Call STODISPO(“[F:YITV]”,XXFCY,XXITM,”*”,”*”,1,WSTA,””,””,YSTODIS) From STKLIB”.

      1. Hi,
        In V6 the STODISPO Subprogs has one more parameter than the same of V5 (and V 1.4.x).

        so you have to change my function like that

           ....
        
           #Call the X3 standard procedure
           Call STODISPO("[F:YITV]",XXFCY,XXITM,"*","*",1,WSTA,"","","",YSTODIS) From STKLIB
        End
        
        

        This is the list of the parameters of V6 version:

        ########################################################################
        # STODISPO     Calcul stock disponible d'un article
        #              filtré sur lot, emplacement, statut, dépôt
        ########################################################################
        # Paramètres E : AITV       = Abrév table cumuls article-site (défaut:[F:ITV])
        #                LFCY       = Site
        #                LITM       = Article
        #                LLOT       = No lot / Préfixe avec "*" 
        #                             Tous les lots : "*" / Lot blanc seul : ""
        #                LLOC       = No emplacement / Préfixe avec "*"
        #                             Tous les emplacements : "" ou "*"  
        #                LTYPLOC  = Type d'emplacement:
        #                           >= 0 Tous les emplacements internes
        #                           + les combinaisons exploitant les poids suivants 
        #                              1 = attente rangement
        #                              2 = clients
        #                              4 = sous-traitants
        #                           < 0 Aucun emplacements internes
        #                           + les combinaisons exploitant les poids suivants 
        #                             -1 = attente rangement
        #                             -2 = clients
        #                             -4 = sous-traitants
        #                           Exemple :
        #                              5 = interne & attente rangement & sous-traitants
        #                             -5 = attente rangement & sous-traitants
        #                LSTA       = Statuts (M.2701) (si 0 alors "A") 
        #                LLIV       = "" ou client livré (formatté : 15x+3x)
        #                                si consommation réservation client
        #                             Inactif si LOWNLFCY
        #                LOWN       = Propriétaire (si "" alors LFCY)
        #                LWRH       = Dépôt ou ""
        #            S : LSTUACTDIS = Quantité disponible en unité active
        #
        # Prérequis    : La classe [F:ITM] de ITMMASTER doit être chargée
        #                La classe [F:]    de ITMMVT    doit être chargée
        #                La classe [F:ITG] de ITMCATEG  doit être chargée
        #
        # Remarque     : Si le propriétaire est renseigné, on prendra :
        #                le stock du propriétaire + le stock du site
        #                Si le propriétaire n'est pas renseigné, on ne prendra
        #                que le stock du site, mais on ne déduira du disponible 
        #                que l'alloué global non imputable au stock tiers
        #                afin de calculer un disponible le moins contraignant possible  
        #
        ########################################################################
        

        Please let me know if it works

        Thanks

        Matteo

      2. Hi Matteo

        Thank you very much for your help!

        Your code works!

        One last question: Where can I find the standard X3 module (e.g. STKLIB)? I can’t seem to find it in the ‘TRT’ directory. In fact there are only a handful of modules in the ‘TRT’ directory!

        Thank you in advance.

      3. Hi,

        STKLIB is a standard module, normally it’s in the X3\TRT folder, but only the Sage partners have the sources of this kind of modules.

        Regards

        Matteo

  3. Hi Matteo

    Thank you for your help!

    Can you also assist how to call out the “Sales text” maintained in Product master directly by right clicking on the “Description” field during Quote creation?

    Thank you in advance!

    1. Hi,

      there is already this functionality, if I understand well your needs.

      After inserting a row in a offer, right click the row and you’ll find in the menu the item ‘Line text entry’ which shows you the text of product inserted in the ‘Sales Text’ of products’ window.

      Matteo

  4. Hi matteo,

    Your code seems really interresting and i’ve tried it in different ways but i’m still stuck with my “problem”. What i’m trying to do is to add a column in the selection window called when adding an article in a sale order for example (right click then selection in the article field).
    The column i’m trying to add must show the available quantity on the site that has been typed in the “stock site” field of the sale order.

    I tried to modify the action called by the selection item with no success.

    Do you have any clue on how to do this ?

    NB : i’m using X3 in french, my translation may not be completely accurate. Sorry.

    Thanks in advance,

    Seb

    1. Hi,

      a solution could be to fill a new specific table with info about items (eg. Code and Description) and a numeric field in which put the available quantity calculated by this function.

      The problem is that this solution needs a lot of computation time because you have to loop over each record of ITMMASTER and call the function to get the available quantity, write in the new table and at end read all records written on it.

      If you need suggestions about how write a customized selection action, tell me, I’ll explain in a new articles

      Regards

      Matteo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s