Sage X3 how get a list of client running processes

The following Subprog returns into an Integer array the list of all running processes of clients connected to X3 application server.

The Subprog needs this two local variables as parameters:
XPROCID, an Integer array in which are inserted the numbers of running processes
XNUM, an Integer which returns the count of running processes

#Restituisce una lista con tutti gli ID dei processi attivi sul server 
Variable Integer XPROCID 
Variable Integer XNUM 

    Local Char     RESULT(250)(1..dim(XPROCID)) 
    Local Integer STAT 
    Local Char  ORDSYS(250) 
    Local Integer J , I, T 
    Local Char CHAINE(250) 
    Local Char PROCESS(250) 
    ORDSYS = "psadx -afghimnopxt -l"-GLANGUE 
    Call SYSTEME2(adxmac(0),ORDSYS,"",STAT,RESULT) From ORDSYS 

    I = 3 
    XNUM = 0 
    While I<=STAT-1 
        If I>=dim(RESULT) Then 
            Call ERREUR(mess(161,115,1)) From GESECRAN : # Trop de lignes 
        CHAINE = RESULT(I) 
        PROCESS = vireblc(mid$(CHAINE,1,instr(1,CHAINE," ")),2) 
        If PROCESS <> "" Then 
            T = val(PROCESS) 
            If T > 0 Then 
                XPROCID(XNUM) = T 
                XNUM += 1 
        I += 1 


Here an example how to use the Subprog

    Local Integer XNUM
    Local Integer XPRCID(100)


    Infbox "there are " + num$(XNUM) + " running client processes"

and a second one that show how delete records of a work table for all non-running processes

   #Delete record not owned by running processes:
   #YVP is a table used as temporary container for cosultations and/or report,
   #the field YADXUID contains the value of variable adxuid(1)
   Local Integer XNUM
   Local Integer XPRCID(100)


   Delete [F:YVP] Where find(YADXUID,XPRCID(0..XNUM))=0

Leave a Reply

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

You are commenting using your 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