How to Set Up a print Filter for a Print Event with one parameter

  • Updated

Problem: print events trigger printing actions for each and every document upon the occurrence of the event. That’s not always convenient if we have different document types we want to print or not depending on a factor.

 

Solution: print event filters provide an alternative to check whether or not a document should be printed.

 

Prerequisites:

-Reports and Print Event configurations are set.

-Print event input parameters contains the object we want to filter, for example LUID id. Check Print event parameters on: List of Print Events [] (produmex.name)

 

Real Scenarios:

Find bellow a table with different examples:

Print Event Default Report Input Parameter Scenario Filter
200-Picking: new LU full DefaultShippingLabel.rpt LUID Filter picked LUID's within a Pick List PRFSCRIP
204-Picking:after item is picked DefaultPickingItemCompleted.rpt Pick List Number @DocEntry Pick List Line @lineNum Filter picked Pick List Lines within a Pick List PRFSCRIP
300-Shipping:sales delivery note created DefaultSalesDeliveryNoteCreatedEvent.rpt  @SalesDeliveryNoteDocEntry Filter Customer Collect Sales Orders PRFCUCO
202-Picked after wave is packed DefaultPackList.rtp and DefaultLogisticLabel.rpt @waveKey Print LUID's contained at the Wave Use Crystal Subreport for LUID's

We are representing the first line example where the print event 200 we have an UDF in the shipping type OSHP.U_USERDEF_FIELD (‘True’ or ‘False’), we need to read this UDF and depending on its value the Shipping Label report will be printed or not.

 

How to:

  1. Creation of a new print filter for your print event
  2. Running of SELECT QUERY to get needed info for document. We recommend to create a VIEW on the database to get the dataset.
  3. Check dataset returned by the query and determination of TRUE or FALSE value
  4. Return the TRUE or FALSE RESULT

Now step by step with the example provided:

1. Create new print event filter.

2. Running of SELECT QUERY at print event filter to get needed info for document.

We recommend to create a database view to select the dataset will go through the filter. In our example the view is PMX_CUSTOMVIEW_CUST is only selecting LUID’s where OSHP.U_USERDEF_FIELD = 'UserDefinedValue_TRUE'

CREATE VIEW AS PMX_CUSTOMVIEW_CUST

SELECT    

       PMX_LUID.SSCC,

       PMX_MVLI."DestLogUnitIdentKey"  LUID,

       PMX_PLPL."BaseType",

       ORDR.TrnspCode--,

       --OSHP.*

FROM        

PMX_LPLM WITH(NOLOCK)

       INNER JOIN

PMX_PLLI WITH(NOLOCK)

       ON PMX_LPLM."PickListDocEntry" = PMX_PLLI."DocEntry" AND PMX_LPLM."PickListLineNum" = PMX_PLLI."LineNum"

       INNER JOIN

PMX_PLHE WITH(NOLOCK)

       ON PMX_PLLI."DocEntry" = PMX_PLHE."DocEntry"   -- AND PMX_PLLI."LineStatus" = 'O'

       INNER JOIN

PMX_MVLI WITH(NOLOCK)

       ON PMX_LPLM."MoveDocEntry" = PMX_MVLI."DocEntry" AND PMX_LPLM."MoveLineNum" = PMX_MVLI."LineNum"          

       INNER JOIN

PMX_LUID WITH(NOLOCK)

       ON PMX_LUID."InternalKey" = PMX_MVLI."DestLogUnitIdentKey"

       LEFT JOIN

PMX_ITRI WITH(NOLOCK)

       ON PMX_MVLI."ItemTransactionalInfoKey" = PMX_ITRI."InternalKey"

       INNER JOIN

OITM WITH(NOLOCK)

       ON OITM."ItemCode" = PMX_MVLI."ItemCode"

       INNER JOIN

PMX_PLPL WITH(NOLOCK)

       ON PMX_PLPL."DocEntry" = PMX_PLLI."BaseEntry" AND PMX_PLPL."LineNum" = PMX_PLLI."BaseLine" AND PMX_PLLI."BaseType" = 'PMX_PLPH'

       LEFT JOIN

OINV WITH(NOLOCK)

       ON PMX_PLPL."BaseType" = OINV."ObjType" AND PMX_PLPL."BaseEntry" = OINV."DocEntry"

       LEFT JOIN

ORDR WITH(NOLOCK)

       ON ORDR."DocEntry" = PMX_PLPL."BaseEntry" AND ORDR."ObjType" = PMX_PLPL."BaseType"

             LEFT JOIN

OWTQ WITH(NOLOCK)

       ON OWTQ."DocEntry" = PMX_PLPL."BaseEntry" AND OWTQ."ObjType" = PMX_PLPL."BaseType"

             LEFT JOIN

OSHP  WITH(NOLOCK)

       ON ORDR.TrnspCode = OSHP.TrnspCode

 

       WHERE OSHP.U_USERDEF_FIELD = 'UserDefinedValue_TRUE'

 

3.&4. If there is any data at the dataset (LUID is not null) return TRUE, means print. Otherwise do not print.

using System;

using System.Reflection;

using Produmex.Foundation.Data.Sbo;

using Produmex.Foundation.Diagnostics;

using Produmex.Sbo.Logex.Data.BusinessObjects;

using Produmex.Sbo.Logex.Data.Providers;

using Produmex.Foundation.Data.Sbo.BusinessObjects;

using Produmex.Foundation.Data.Sbo.Utilities;

using Produmex.Foundation.Data.SqlClient;

 

public class Script

{

    private static readonly ILog s_log =

              LogProvider.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType);

 

    public static bool PrintReport(PmxPrintReportEventType eventType, int key, PmxDbConnection dbConn)

    {

        //Create the query you want to use

        //2. string query = "SELECT LEN(COALESCE(U_EUM_FORWARDER,'')) FWRDR FROM ODLN WHERE DocEntry = "

      string query = "SELECT LEN(COALESCE(LUID,'')) LUID FROM PMX_CUSTOMVIEW_CUST WHERE LUID = "

+ key.ToString();

 

        //Run the query

        using (ISboRecordset rs = SboRecordsetHelper.RunQuery(s_log, query, dbConn))

        {

            if (!rs.EoF)//Check if you get result from the query

            {

               // string var1 = rs.GetTypedValue<string>("COLUMNAME");//Get a string value

                int var2 = rs.GetTypedValue<int>("LUID");//Get an int value

 

                //3. Possibility to add a check on the result

                //In this case if the value of var2=LUID extracted from the View is not NULL

                //a label should be printed

                if (var2 > 0)

                {

                    return true; //4. Label will be printed

                }

                else

                {

                    return false; //4. Label will not be printed

                }

            }

        }

        return false; //4. Label will not be printed

    }

}

Find attached .txt files with View and .net Script Filter and other example of print filter in the WMS Wiki documentation: 2.7. Print Events tab [] (produmex.name)

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.