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

Parents
  • 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

Reply
  • 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

Children
  • 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.