Automatically print a report in a network directory

Hello,

I would like to be able to automatically generate invoice in PDF format in a specific directory right after validating it.

I was thinking of using "Call ETAT(ZINVOICE,PDF) From AIMP3" and EXEBOUT in my invoice script (SPESIH)

Where ZINVOICE is my report and PDF my destination.

I don't really understand how to do that nor how to define the directory where the file should be generated.

could you help me?

Thanks

  • Good day,

    The function to print works as follows, there are 6 inputs (listed below). The report will by default print into the [tmp] directory of the folder you are in, from there you can move it to another storage location using "Call MOVE("CUR_LOC","DEST_LOC", STAT) From ORDSYS"

    Input parameters

    1. The report code

    2. The destination as setup in X3

    3. The language of the report

    4. Trace indicator, 1 - Print log, 0 - No log

    5. Print message

    6. Input parameter definition (as defined on the report)

    7. Input parameter value (require by report)

    Example input.

    TBPAR(1) = "" : TBVAL(1) = ""

    Call ETAT("LISREG","EMAIL","ENG",0,"",TBPAR,TBVAL) From AIMP3

  • in reply to Regard Hulsbos

    Hello,

    Here is what I tried:


    $EXEBOUT_

    If BOUT="Z" Then
    #    Infbox "Bout"
        Local Char ZTBPAR (50) (1..50), ZTBVAL(30) (1..50)
        Local Char ZDEST ([V]GLONAIM)    , ZETAT(100)
        ZDEST="YPDF"
        ZETAT="INVOICE3"
        
        Call ETAT(ZETAT,ZDEST,"",0,"",[L]ZTBPAR(1..10),[L]ZTBVAL(1..10)) From  AIMP3
        Infbox "Done"
    Endif
    Return

    Yet nothing is printed into the TMP folder.

  • in reply to N2XF3

    What are the normal parameters on your report, i.e. when you go to Reports > Reports, what are the parameters needed for you report? If you print the report from here with destination of YPDF, where does is print to?

    In this example there of report PINVOICE you need to set parameters needed by the report:

    ZTBPAR(1) = 'Company' : ZTBVAL(0) = 'CORP'

    .......

      

  • You could Defile a FILE destination on YOUR Destinations and once that is done you can then specify the folder where you want to print your report to.

    See below example snippets: 

    Funprog ZPOH(POHNUM,ZFLG)
    Value Char POHNUM
    Value Integer ZFLG
    Local Integer ZSTA
    Local Char ZFILNAM(250)

    [L]ZFILNAM = filpath("tmp/ZPOHDRAFT",POHNUM+"_"+date$,"pdf",nomap(0),"")

    If ZFLG =2
    Call PRINTRPT(POHNUM, ZFILNAM)
    Sleep 3
    Endif

    End [L]ZFILNAM

    Subprog PRINTRPT(ZPOH,FILNAM)
    Value Char ZPOH # PO NUMBER
    Value Char FILNAM # OUTPUT FILE NAME
    # Local Char FONCTION
    Local Char TBPAR(150) (150) #PARAMETER NAME
    Local Char TBVAL(150) (150) #PARAMETER VALUE
    Local Char ETAT #REPORT CODE

    TBPAR(0) ="commandedeb"
    TBVAL(0) = ZPOH
    TBPAR(1) ="filnam"
    TBVAL(1) = FILNAM

    GSERVEUR = 1
    GSILENCE = 1
    ETAT = "ZPOH" #report code 
    Call ETAT(ETAT,"FILE","eng",0,"",TBPAR,TBVAL) From AIMP3 # file is the print destination which prints to file
    End

  • If this was not achieved, you can for the below. I may have forgotten to mention it

    You then need to specify the file name of the report. To do this, you need to attache a script to the report to define the FICHIER parameter. See below example:

    $ACTION
    Case ACTION
    When "FICHIER" : Gosub FICHIER
    When Default
    Endcase
    Return


    $FICHIER
    Local Integer YTEMP
    For YTEMP = 0 To 10
    If [M:AIP]TBPAR(YTEMP) ="filnam"
    FICHIER = [M:AIP]TBVAL(YTEMP):#Infbox FICHIER #filpath("tmp", "test","pdf",nomap(0),""): Infbox FICHIER
    #Break
    Endif
    Next
    Return

    Subprog IMPRIME(NBPAR,PARAMETRE)
    Variable Integer NBPAR
    Variable Char PARAMETRE()()
    Call EXEC(NBPAR,PARAMETRE)
    End

    Subprog EXEC(NBPAR,PARAMETRE)
    Variable Integer NBPAR
    Variable Char PARAMETRE()()
    End

    So what the above snippet does, is that if gives the filename on the above field, since it is required to print when printing to a file destination.