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
#
Subprog GET_ALLPROCESS(XPROCID,XNUM)
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
      Break
    Endif
    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
      Endif
    Endif
    I += 1
  Wend

End

Here an example how to use the Subprog

Local Integer XNUM
Local Integer XPRCID(100)

Call GET_ALLPROCESS(XPRCID,XNUM)

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)

Call GET_ALLPROCESS(XPRCID,XNUM)

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

 

Leave a Reply