query+report达到user的需求

2020-03-05 11:31:30 浏览数 (3)

前几天应USER需求,要查看某一物料当前库存多少,库存在哪个仓库,两周之内对此物料的需求是多少。

写了一query,然后在报表中加如下列内容,达到要求。

select whwmd215.item          | Item from whwmd215               | Item Inventory by Warehouse where  whwmd215.item >= whwmd215.item.f and whwmd215.item <= whwmd215.item.t group by whwmd215.item order by whwmd215.item

报表中的descript:

declaration:

 table twhwmd215  table tgdrmp001  table ttcibd001

     extern domain tcqiv1  wip_162030      extern domain tcqiv1  wip_162035

     extern domain tcqiv1  nor_162012      extern domain tcqiv1  nor_162013      extern domain tcqiv1  nor_162020      extern domain tcqiv1  nor_162025      extern domain cpcom.quan  pdemg_1      extern domain cpcom.quan  pdemg_2

 domain cpcom.dydt  pdate.g  domain tcmcs.long  count

before.program:   pdate.g = date.num() 

detail.1: before.layout:

| message (Str$(pdate.g))

 select  whwmd215.stoc, whwmd215.cwar, whwmd215.item  from  whwmd215  where  whwmd215._index2 = {:whwmd215.item}  order by  whwmd215._index2  selectdo

  if strip$(whwmd215.cwar)  = "162030" then    wip_162030 = 0    wip_162030 = whwmd215.stoc   endif

  if strip$(whwmd215.cwar)  = "162035" then    wip_162035 = 0    wip_162035 = whwmd215.stoc   endif

  if strip$(whwmd215.cwar)  = "162012" then    nor_162012 = 0    nor_162012 = whwmd215.stoc   endif

  if strip$(whwmd215.cwar)  = "162013" then    nor_162013 = 0    nor_162013 = whwmd215.stoc   endif

  if strip$(whwmd215.cwar)  = "162020" then    nor_162020 = 0    nor_162020 = whwmd215.stoc   endif

  if strip$(whwmd215.cwar)  = "162025" then    nor_162025 = 0    nor_162025 = whwmd215.stoc   endif  endselect

 count =0  select gdrmp001.pdem.g, gdrmp001._index1  from gdrmp001  where gdrmp001._index3 = {"162", 1}  and (gdrmp001.plni.g = :whwmd215.item or    gdrmp001.sitm.g = :whwmd215.item )  and (gdrmp001.pdat.g >= :pdate.g or    gdrmp001.pdat.g <= :pdate.g)  order by gdrmp001._index1  as set with 2 rows  selectdo   count = count 1   if count = 1 then    pdemg_1 = 0    pdemg_1 = gdrmp001.pdem.g   endif   if count = 2 then    pdemg_2 = 0    pdemg_2 = gdrmp001.pdem.g   endif  endselect

 select  tcibd001.dsca  from tcibd001  where tcibd001._index1 = {:whwmd215.item}  selectdo  selectempty   tcibd001.dsca = ""  endselect

0 人点赞