Comparing files OE6100.dbl and OE6100.DBL_VT
***** OE6100.dbl
;==Changes==============================================================;
; 08/10/2005 tah - Close output files when no open orders exist.
; 04/16/2004 tah - Add starting/ending location selection.
; 11/12/1996 tah - Skip cancelled orders.
***** OE6100.DBL_VT
;==Changes==============================================================;
; 11/12/1996 tah - Skip cancelled orders.
*****

***** OE6100.dbl
        oxorno          ,d6             ; order number
        oxitem          ,a24            ; item
        oxlocn          ,a3             ; location
        oxline          ,d3             ; order line

***** OE6100.DBL_VT
        oxorno          ,d6             ; order number

*****

***** OE6100.dbl
        scr_endslsm     ,a3             ; ending salesman
        scr_strlocn     ,a3             ; starting location
        scr_endlocn     ,a3             ; ending location
        scr_strdate     ,d8             ; starting date
***** OE6100.DBL_VT
        scr_endslsm     ,a3             ; ending salesman
        scr_strdate     ,d8             ; starting date
*****

***** OE6100.dbl
                    call print_report_totals
                  end
***** OE6100.DBL_VT
                    call print_report_totals
                    case scr_outtype of
                      begincase
                      'E': xcall ascfil ('F',,,,,,,,,opcde)
                      'R': xcall clslp ('Open Orders by Customer')
                      endcase
                  end
*****

***** OE6100.dbl
              end
            case scr_outtype of
              begincase
              'E': xcall ascfil ('F',,,,,,,,,opcde)
              'R': xcall clslp ('Open Orders by Customer')
              endcase
          end
***** OE6100.DBL_VT
              end
          end
*****

***** OE6100.dbl
        xcall lodtoolbar ('AB',8)
        clear lines
        return
***** OE6100.DBL_VT
        xcall lodtoolbar ('AB',8)
        return
*****

***** OE6100.dbl
        if ((scr_strcust.gt.scr_endcust) .or.
        &   (scr_endlocn.ne.UT_ALL .and. scr_strlocn.gt.scr_endlocn) .or.
        &   (scr_endslsm.ne.UT_ALL .and. scr_strslsm.gt.scr_endslsm))
***** OE6100.DBL_VT
        if ((scr_strcust.gt.scr_endcust) .or.
        &   (scr_endslsm.ne.UT_ALL .and. scr_strslsm.gt.scr_endslsm))
*****

***** OE6100.dbl
            reads (work_chan,ordidx,print_report_eof)
            if (oxcust.ne.nam_id)
              begin
                call end_lines
                call new_customer
              end
            if (oxorno.ne.oem_order)
              begin
                call end_lines
                call get_order_header
                prorno = oem_order, 'XXXXXX'
                xcall dtdsp (oem_orddate,prdate)
              end
            oel_comp = oem_comp
            oel_order = oem_order
            oel_lineno = oxline
            xcall db_read (oeline_chan,oeline,oel_key(1:11),0,'M',,,opcde)
            if (.not.opcde)
              begin
                xcall dtdsp (oel_reqdate,prrqdt)
                prlocn = oel_locncode
                pritem = oel_item
                prdesc = oel_descr
                case in_cmqdec of
                  begincase
                  0: begin
                        prorqt = oel_ordqty, mask0
                        prshqt = (oel_shpqty + oel_pckqty), mask0
                     end
                  3: begin
                        prorqt = oel_ordqty, mask3
                        prshqt = (oel_shpqty + oel_pckqty), mask3
                     end
                  endcase
                boqt = oel_boqty
                if (oel_shpqty + oel_pckqty.ge.oel_boqty)
                  begin
                    boqt = oel_ordqty - (oel_shpqty + oel_pckqty)
                    if (boqt.lt.0) clear boqt
                  end
                case in_cmqdec of
                  begincase
                  0: prboqt = boqt, mask0
                  3: prboqt = boqt, mask3
                  endcase
                qty = oel_ordqty - (oel_shpqty + oel_pckqty)
                amount = (qty * oel_uprice) / oel_pfactor          ; extd price
                amount = amount - ((amount * oel_discpct) / 100.0) ; less disc
                pramnt = amount, mask
                call print
                incr lines
                oorqt = oorqt + oel_ordqty
                oshqt = oshqt + (oel_shpqty + oel_pckqty)
                oboqt = oboqt + boqt
                oamnt = oamnt + amount
                corqt = corqt + oel_ordqty
                cshqt = cshqt + (oel_shpqty + oel_pckqty)
                cboqt = cboqt + boqt
                camnt = camnt + amount
                forqt = forqt + oel_ordqty
                fshqt = fshqt + (oel_shpqty + oel_pckqty)
                fboqt = fboqt + boqt
                famnt = famnt + amount
              end
***** OE6100.DBL_VT
            reads (work_chan,ordidx,print_report_eof)
            if (oxcust.ne.nam_id) call new_customer
            oem_comp = ut_cmcomp
            oem_order = oxorno
            xcall db_read (oehedr_chan,oehedr,oem_key,0,'M',,,opcde)
            if (opcde.eq.0)
              begin
                case scr_outtype of
                  begincase
                  'E': begin
                        exp_order = oem_order, 'XXXXXX'
                        exp_soldid = oem_cust, 'XXXXXXXX'
                        exp_soldname = nam_name
                        exp_soldaddr1 = nam_addr1
                        exp_soldaddr2 = nam_addr2
                        exp_soldcity = nam_city
                        exp_soldstate = nam_state
                        exp_soldzip = nam_zip
                        exp_shipid = oem_shipid, 'XXXXXXXX'
                        exp_shipname = oem_shipname
                        exp_shipaddr1 = oem_shipaddr1
                        exp_shipaddr2 = oem_shipaddr2
                        exp_shipcity = oem_shipcity
                        exp_shipstate = oem_shipstate
                        exp_shipzip = oem_shipzip
                        exp_contact = oem_confirm
                        xcall phone (nam_phone,exp_phone)
                        xcall phone (nam_fax,exp_fax)
                        xcall ascfil ('D',,export,cformat,'"','"',',','Y','Y',opcde)
                       end
                  'R': begin
                        prorno = oem_order, 'XXXXXX'
                        xcall dtdsp (oem_orddate,prdate)
                        clear lines
                        call print_lines
                       end
                  endcase
              end
*****

***** OE6100.dbl

get_order_header,
        oem_comp = ut_cmcomp
        oem_order = oxorno
        xcall db_read (oehedr_chan,oehedr,oem_key,0,'M',,,opcde)
        if (opcde)
         then clear oehedr
         else
          case scr_outtype of
            begincase
            'E': begin
                  exp_order = oem_order, 'XXXXXX'
                  exp_soldid = oem_cust, 'XXXXXXXX'
                  exp_soldname = nam_name
                  exp_soldaddr1 = nam_addr1
                  exp_soldaddr2 = nam_addr2
                  exp_soldcity = nam_city
                  exp_soldstate = nam_state
                  exp_soldzip = nam_zip
                  exp_shipid = oem_shipid, 'XXXXXXXX'
                  exp_shipname = oem_shipname
                  exp_shipaddr1 = oem_shipaddr1
                  exp_shipaddr2 = oem_shipaddr2
                  exp_shipcity = oem_shipcity
                  exp_shipstate = oem_shipstate
                  exp_shipzip = oem_shipzip
                  exp_contact = oem_confirm
                  xcall phone (nam_phone,exp_phone)
                  xcall phone (nam_fax,exp_fax)
                  xcall ascfil ('D',,export,cformat,'"','"',',','Y','Y',opcde)
                 end
            'R': begin
                  prorno = oem_order, 'XXXXXX'
                  xcall dtdsp (oem_orddate,prdate)
                  clear lines
                 end
            endcase
        return

        ;       pull records to work file
***** OE6100.DBL_VT

        ;       pull records to work file
*****

***** OE6100.dbl
              begin
                xcall db_find (oeline_chan,oem_key,0,'M',,,opcde)
                if (.not.opcde) call pull_line_items
              end
***** OE6100.DBL_VT
              begin
                oxcust = oem_cust
                oxorno = oem_order
                writes (work_chan,ordidx)
                incr wrtcnt
              end
*****

***** OE6100.dbl
          end
        
        ;       loop for processing line items
pull_line_items,
        repeat
          begin
            xcall db_next (oeline_chan,oeline,'F','M',,,opcde)
            if (opcde) .or.
            &  (oem_key.ne.oel_key) return
            if (oel_linestatus.ne.'D' .and. oel_linestatus.ne.'C') .and.
            &  (scr_strlocn.eq.UT_ALL .or. oel_locncode.ge.scr_strlocn) .and.
            &  (scr_endlocn.eq.UT_ALL .or. oel_locncode.le.scr_endlocn)
              begin
                boqt = oel_boqty
                oxcust = oem_cust
                oxitem = oel_item
                oxlocn = oel_locncode
                oxorno = oel_order
                oxline = oel_lineno
                writes (work_chan,ordidx)
                incr wrtcnt
              end
          end

***** OE6100.DBL_VT
          end

*****

***** OE6100.dbl

        ;       end of order line items
***** OE6100.DBL_VT

print_lines,
        xcall db_find (oeline_chan,oem_key,0,'M',,,opcde)
        if (opcde) return
        repeat
          begin
            xcall db_next (oeline_chan,oeline,'F','M',,,opcde)
            if (opcde) .or. (oem_key.ne.oel_key(1:8))
              begin
                call end_lines
                return
              end
            if (oel_linestatus.ne.'D' .and. oel_linestatus.ne.'C')
              begin
                xcall dtdsp (oel_reqdate,prrqdt)
                prlocn = oel_locncode
                pritem = oel_item
                prdesc = oel_descr
                case in_cmqdec of
                  begincase
                  0: begin
                        prorqt = oel_ordqty, mask0
                        prshqt = (oel_shpqty + oel_pckqty), mask0
                     end
                  3: begin
                        prorqt = oel_ordqty, mask3
                        prshqt = (oel_shpqty + oel_pckqty), mask3
                     end
                  endcase
                boqt = oel_boqty
                if (oel_shpqty + oel_pckqty.ge.oel_boqty)
                  begin
                    boqt = oel_ordqty - (oel_shpqty + oel_pckqty)
                    if (boqt.lt.0) clear boqt
                  end
                case in_cmqdec of
                  begincase
                  0: prboqt = boqt, mask0
                  3: prboqt = boqt, mask3
                  endcase
                qty = oel_ordqty - (oel_shpqty + oel_pckqty)
                amount = (qty * oel_uprice) / oel_pfactor          ; extd price
                amount = amount - ((amount * oel_discpct) / 100.0) ; less disc
                pramnt = amount, mask
                call print
                incr lines
                oorqt = oorqt + oel_ordqty
                oshqt = oshqt + (oel_shpqty + oel_pckqty)
                oboqt = oboqt + boqt
                oamnt = oamnt + amount
                corqt = corqt + oel_ordqty
                cshqt = cshqt + (oel_shpqty + oel_pckqty)
                cboqt = cboqt + boqt
                camnt = camnt + amount
                forqt = forqt + oel_ordqty
                fshqt = fshqt + (oel_shpqty + oel_pckqty)
                fboqt = fboqt + boqt
                famnt = famnt + amount
              end
          end

        ;       end of order line items
*****

***** OE6100.dbl
          end
        clear oorqt, oshqt, oboqt, oamnt, lines
        return
***** OE6100.DBL_VT
          end
        clear oorqt, oshqt, oboqt, oamnt
        return
*****

