[X3v12-4GL] In Script editor, how to open a X3 Storage Area folder to reads its filelist names?

SOLVED

Hi,

4GL Development question. Not sure the keyword to find for these.

In 4GL, I know I can just manually put in the hardcode filepath to open through SYSTEME2 raw OS cmd call but it is very annoying to maintain (about 5+ scripts to update) every time the folder is duplicated to test server.

If I want to access to a defined X3 volume, how to [1] call the defined X3 volume in 4GL and then [2] read a list of the file name inside?

Assume the defined X3 volume is YTEST.

Inside the X3 volume folder are just `.txt` files (1.txt, 2.txt, hello.txt). These files are expected to be imported in as an import template file using 4GL directly through its filename (for example, import `1.txt` file to YTESTIMP import template code).

Additional refs for X3 Volume creation:

https://www.sagecity.com/us/sage_x3/b/sageerp_x3_product_support_blog/posts/creating-storage-areas-for-the-masses-quick-guide-to-adding-custom-storage-areas-to-sage-x3

https://www.sagecity.com/us/sage_x3/b/sageerp_x3_product_support_blog/posts/getting-started-with-x3-storage-areas

Additional details I found while googling:

- From Greytrix (the one I am using; Seems like old way?): www.greytrix.com/.../

- From online help: https://online-help.sageerpx3.com/erp/12/staticpost/x3script-keywords-glossary/

  • +1
    verified answer

    I would recommend you do no use the System's command due to security restrictions in V12. Instead you can use the following subprogram I wrote a while ago, it takes in three parameters, the first is the full path of the X3 Storage area, which can be constructure by making use of the filpath command (in your example filpath('YTEST','','','') will return 'X:\Sage\Some\Location'. I have a hardcoded file extension filter (aka 'txt' included in my SYSTEM call) as I am only looking for txt files, but it can be updated to other functions as well. The return variable ZNBFIC is the number of files in the folder, and the variable ZFILES contains the names of the files in the directory. Hope it helps. Slight smile

    # FIND ALL TXT FILES IN A SPECIFIC FOLDER
    ###########################################################################################
    # PARAMETERS : 
    # ZFOLD - X3 STORAGE LOCATION (EXPRESSED USING filpath COMMAND)
    # ZNBFIC - NUMBER OF FILES FOUND IN THE FOLDER
    # ZFILES - LIST OF NAMES OF TXT FILES IN THE FOLDER
    #
    ###########################################################################################
    Subprog FIND_FILES(ZFOLD, ZNBFIC, ZFILES)
    Value Char ZFOLD
    Variable Integer ZNBFIC
    Variable Char ZFILES()(1..)

    # USE A X3 SYSTEMS CALL TO PERFORM A DIR *.txt ON THE FOLDER PROVIDED IN ZFOLD
    Call SYSTEME2(adxmac(0),"lsadx"-'"'+ZFOLD+'" "txt"',"", ZNBFIC, ZFILES) From ORDSYS

    End

  • 0 in reply to Regard Hulsbos

    Hi Mr. Regard,

    Thanks for the Subprogram. Working well at the moment.

    Is there a function reference for ORDSYS file?

    I would like to know how the SYSTEME2 works since what I am lacking is old reference whose keywords were written in French.

    I have the online-help reference (https://online-help.sageerpx3.com/erp/12/wp-static-content/static-pages/en_US/v7dev/4gl_system.html) but some of the older development were still written in old way which I have no idea how the function works due to no public documentation.

  • 0 in reply to chunheng

    The ORDSYS is a core Sage X3 source file and will not be shared by Sage R&D. My recommendation is that if is something specific you want to launch, make use of the Callui function within 4GL or create a JavaScript Bundle that can be executed by the Syracuse node. 

    online-help.sageerpx3.com/.../how-to_how-to-launch-exe-from-classic-session.html