Custom Report - Only parts received this year

Version Relevance: All

Issue: A more complex custom report requirement. I want to do a parts report (e.g. stock valuation) only for parts where we have had a purchase or work receipt within the last year.

Oct 30th, 2002

Feedback: This is a requirement that calls for a $printrecord report class method. The $printrecord is an Omnis built-in method that can be overwritten by creating a class method and naming it $printrecord. This method will run instead of the built-in method. Within the method you must have a Do default command to pass control back to the buit-in method. If no Do default is encountered, the record will not print. In this example the Do default is only encountered if an appropriate purchase or works receipt date is found for the part. Note that I am using an instance variable of type Date which can be added to the report as a last received date column. I am also using a local variable named lList of type List. Both these variables need to be defined before you can paste in the code.

The commented out lines are optional if you want to read additional history data.

Do lList.$define(PUHSEQ,PUHDATE)
Begin reversible block
  Set main file {PUHFILE}
  Set search as calculation {PUHDATE>=dadd(kYear,-1,#D)}
  Set current list lList
End reversible block
Build list from file on PUHPTNO (Exact match,Use search)
If lList.$linecount
  Do lList.$sort(PUHDATE,kFalse,PUHSEQ,kFalse)
  Calculate iLastDate as lList.[lList.$linecount].PUHDATE
  ; Find on PUHSEQ (Exact match) {lList.[lList.$linecount].PUHSEQ}
  Do default
  Do lList.$define(WOHSEQ,WOHCDAT)
  Set main file {WOHFILE}
  Set search as calculation {WOHCDAT>=dadd(kYear,-1,#D)}
  Calculate WOHPTNO as PTMPTNO
  Build list from file on WOHPTNO (Exact match,Use search)
  If lList.$linecount
    Do lList.$sort(WOHCDAT,kFalse,WOHSEQ,kFalse)
    Calculate iLastDate as lList.[lList.$linecount].WOHCDAT
    ; Find on WOHSEQ (Exact match) {lList.[lList.$linecount].WOHSEQ}
    Do default
  End If
End If

Chris Ross - Caliach Design