marcosomizu wrote:The question is: what are the steps to make Jiwa sets the parameters automatically to the Stored Procedure, like it does in the Invoice for example?
Cheers!
The GRN form by default will inject into the record selection formula "{RE_Main.PackSlipID}=<value>" - but it also looks for a Pass_SP_StartingSlipNo and Pass_SP_EndingSlipNo formula and sets those.
So, you need to create a formula named Pass_SP_StartingSlipNo - you don't need anything in here, it just has to exist - the GRN form will set the contents when the user prints. You don't need to worry about the Pass_SP_EndingSlipNo formula - that's optional - it was designed to allow the same report to be used either from printing on the form, or the menu (range based report).
Then you need to add a JiwaRanges forumula - in there put the text:
- Code: Select all
//{@Pass_SP_StartingSlipNo}
Note the comment at the start - the print engine in Jiwa will wire this up to the stored proc parameter.
You will also have to alter your stored procedure to have a parameter named SP_StartingSlipNo instead of your SP_PackSlipID. Note you'll also have to modify your query(ies) in your stored proc to deal with being passed the SlipNo instead of the ID.
If you
must have the parameter in the stored proc SP_PackSlipID instead of SP_StartingSlipNo, then you'll need to have a plugin to override the print tool click on the GRN form and set the appropriate formula. Let us know if you need that, but It would be better if you modified your stored proc to suit the form instead.
To give you an idea what happens when the print tool is clicked on the GRN form - here is the code from that form:
- Code: Select all
Public Overrides Sub PrintRecord(ByVal ReportDefinition As JiwaApplication.PrintGroup.FormReports.ReportDefinition)
Dim PrintUIObject As JiwaApplication.JiwaPrintReportUI.MainForm
Dim MyLoop As Integer
PrintUIObject = JiwaApplication.Manager.Instance.CreateReport(ReportDefinition, 1, True, False, True, "{RE_Main.PackSlipID}=" & JiwaApplication.Manager.Instance.Database.FormatChar(_InventoryReceival.RecID))
If Not (PrintUIObject Is Nothing) Then
For MyLoop = 1 To PrintUIObject.PrintReportObject.JiwaReportRangeCollection.Count
If UCase(PrintUIObject.PrintReportObject.JiwaPrintFormulaCollection(PrintUIObject.PrintReportObject.JiwaReportRangeCollection(MyLoop).FormulaKey).Name) = UCase("Pass_SP_StartingSlipNo") Or UCase(PrintUIObject.PrintReportObject.JiwaPrintFormulaCollection(PrintUIObject.PrintReportObject.JiwaReportRangeCollection(MyLoop).FormulaKey).Name) = UCase("Pass_SP_EndingSlipNo") Then
PrintUIObject.PrintReportObject.JiwaReportRangeCollection(MyLoop).Value = _InventoryReceival.GRNNo
End If
Next MyLoop
PrintUIObject.UpdateReport()
PrintUIObject.chkDrill.Checked = True
PrintUIObject.PrintReportToScreen()
PrintUIObject.Show()
End If
End Sub
Note the overrides the PrintRecord of the base class - which is JiwaFinancials.Jiwa.JiwaApplication.Maintenence.UserInterface. We override it to support legacy reports from version 6. If it wasn't overridden, then the base class PrintRecord would have been invoked - which looks like this:
- Code: Select all
Public Overridable Sub PrintRecord(ByVal ReportDefinition As JiwaApplication.PrintGroup.FormReports.ReportDefinition)
Dim PrintUIObject As JiwaApplication.JiwaPrintReportUI.MainForm
Dim SelectionFormula As String = ""
SelectionFormula = "{" & BusinessLogic.RecIDFieldName & "} = " & JiwaApplication.Manager.Instance.Database.FormatChar(BusinessLogic.RecID)
PrintUIObject = JiwaApplication.Manager.Instance.CreateReport(ReportDefinition, 1, True, ReportDefinition.Report.ReportType = Report.Configuration.Report.ReportTypes.Menu, True, SelectionFormula)
If Not (PrintUIObject Is Nothing) Then
PrintUIObject.UpdateReport()
PrintUIObject.PrintReportToScreen()
PrintUIObject.Show()
End If
End Sub
As you can see, by default we simply set the record selection formula.
Mike