【发布时间】:2015-04-22 22:53:30
【问题描述】:
我现在很困惑。我要做的是,当主循环正在读取 aaord# 的订单时,我们需要在这个子例程中统计所有其他具有箱子重量的订单行。运输表是这样的:对于输出,我们可以将 ord_wt 放在每一行,我想不出任何其他方式。
PHORD# PHWGHT PHBNO#
04924920 1.05 1
05012409 27.40 2
05012409 27.40 3
05012409 27.40 4
05012409 27.40 5
05012409 27.40 6
05012409 27.40 7
05012409 27.40 8
05012409 20.00 9
05012421 26.90 2
05012421 26.90 3
05012421 26.90 4
05012430 13.70 2
05036997 21.60 1
05036997 21.60 2
05036997 21.60 3
05036997 21.60 4
05037155 14.55 1
05037173 12.25 1
05037173 12.20 2
05039479 8.10 1
所以在这段代码中,我要做的是查看订单号是否不等于之前的订单号,然后我将执行此代码来计算发货表中的所有订单重量。当有这样的新订单号时,我还需要清除持有字段。\但我的输出在 ord_wt 中只有零
c eval mhcmno4= aacom#
c* eval wkrel@ = %EDITC(aarel#:'X')
c* eval wkrel2 = %subst(wkrel@:4:2)
c eval mhordr4 = aaord#
c eval wkvsf='N'
c* endif
c z-add 0 phwtno 702
c*
c mhordr4 ifne prvord
c z-add 0 phwtot
c mhkey4 setll pshipLL4
c read pshipLL4
c* loop thru all orders in the ship table and add the weight to get a
c* total weight per order #
c dow not %eof(pshipLL4)
c if mhcmno4 = PHCOM# and
c mhordr4 = PHORD#
c* phwght is 11 char
c**
c eval prvord = mhordr4
c eval phwtno = %dec(PHWGHT:7:2)
c add phwtno phwtot
c else
c leave
c endif
c read pshipLL4
c enddo
c endif
c endsr
OUTPUT: packages of course cannot be 0.
05475731 0
05475731 0
05475731 0
05475731 0
05475731 0
05475731 0
05475731 0
05475731 0
05475731 0
05476179 0
05476179 0
05476179 0
05476179 0
05476179 0
05476179 0
05476179 0
05476179 0
05476179 0
05476179 0
05476179 0
05476179 0
05476179 0
05476179 0
05476179 0
05476179 0
05475736 0
05475736 0
05475736 0
05475736 0
05475736 0
05475736 0
05475736 0
05475736 0
05475736 0
05475736 0
05475750 0
05475750 0
05475750 0
05475750 0
05475750 0
05475750 0
【问题讨论】:
-
mhkey4的结构是什么?和mhordr4有什么关系? -
这看起来像是在调试模式下编译程序然后使用 STRDBG 会有所帮助的情况之一。另外,PSHIPLL4 的关键是什么?
-
键是公司和订单号。这里只有 1 家公司
-
那么
mhkey4是 DS 或 KLIST 或类似的。您能否展示程序如何定义它以及如何设置子字段值?顺便说一句,你为什么要在这个循环中使用 READ 而不是 READE?此外,我没有看到任何错误检查,也没有看到任何检查 SETLL 是否成功的内容。怎么知道它按你预期的那样工作?也就是说,你怎么知道你正在访问正确的记录? -
没有什么是真正突出问题的根源。这绝对是调试器会立即显示真正问题的情况之一。
标签: ibm-midrange db2-400 rpgle