Macro recorded to printing Picking Slips prints blank report

By | July 14, 2011
Recently while working on OE Picking slip’s customization for a client we recorded a macro for Print Picking Slips routine, but when executed, the macro would just print a blank report. On further investigation I figured out that problem is due to Parameter “SESHNDL” (below is the code of recorded Macro)
[SNIP]
Dim rpt As AccpacCOMAPI.AccpacReport
Set rpt = ReportSelect(“OEPICK01[OEPICKSHIPMENT1.RPT]”, ”      “, ”      “)
Dim rptPrintSetup As AccpacCOMAPI.AccpacPrintSetup
rpt.SetParam “SELECTBY”, “1”
rpt.SetParam “SORTBY”, “0”
rpt.SetParam “FROMSELECT”, “”
rpt.SetParam “TOSELECT”, “”
rpt.SetParam “FROMLOC”, ” ZZZZZZZZZZZZ”
rpt.SetParam “TOLOC”, “ZZZZZZ”
rpt.SetParam “PRINTBY”, “0”
rpt.SetParam “SERIALLOTNUMBERS”, “0”
rpt.SetParam “PRINTKIT”, “0”
rpt.SetParam “PRINTBOM”, “0”
rpt.SetParam “REPRINT”, “1”
rpt.SetParam “QTYDEC”, “0”
rpt.SetParam “COMPLETED”, “0”
rpt.SetParam “SESHNDL”, “538988”
rpt.NumOfCopies = 1
rpt.Destination = PD_PREVIEW
rpt.PrintDir = “”
rpt.PrintReport
[\Snip]
The parameter “SESHNDL” is auto generated using the OEFLAG (Flag printed records) view (View ID – OE0270). So when we print the picking slip report at runtime new number for “SESHNDL” (Print Picking Slips Session Hand) is generated and stored in the OEFLAG view; all this is temporary and on completion of printing the report data from this view is cleared.
So for our Macro to execute properly we must be able to generate the accurate Picking Slips Session number and pass it to our macro every time it wants to print a Picking Slip.
For this we must INIT and Process the OEFLAG view by passing certain parameter as shown in below Snippet.
[Snip]
Public vw_OEFLAG   As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView “OE0270”, vw_OEFLAG
With vw_OEFLAG
        .Init
        .Fields(“OPTYPE”).PutWithoutVerification (15) ‘If Header Location selected
        .Fields(“FROMSHI”).PutWithoutVerification (str_ShipFrom) ‘From Location
        .Fields(“TOSHI”).PutWithoutVerification (str_ShipTo) ‘To Location
        .Fields(“FROMLOC”).PutWithoutVerification (str_Loc) ‘From Location        .Fields(“TOLOC”).PutWithoutVerification (str_Loc)   ‘To Location        .Fields(“LBLREQUIRE”).PutWithoutVerification (0)        .Fields(“REPRINT”).PutWithoutVerification (1)
.Process
        str_Sch = .Fields(“SESHNDL”).Value
    End With
[\Snip]
So the newly auto generated printed Print Picking Slips Session Hand number is now captured in variable “str_Sch” which can be passed to our report parameter “SESHNDL” and our problem should be solved.
Happy Coding J

If you find this content useful, please drop us an email at accpac@greytrix.com