1

我很抱歉这是一个非常简单的问题,但作为 ABL 开放边缘的第一次用户并且我被卡住了。我已经将值输入到这样的表中

METHOD PRIVATE VOID POPULATETABLE ( ):
    DEFINE VARIABLE I AS INTEGER. 
    DO I = 0 TO 100:
    CREATE TEST.

    ASSIGN TEST.CUSTOMER_NAME="SMITH"
    TEST.ORDER_NUMBER=I  
    TEST.ORDER="BOOKS" 
    TEST.COST=45.00  
    TEST.CUSTOMER_NAME = "JACKSON" 
    TEST.ORDER_NUMBER=I 
    TEST.ORDER="PAPER CLIPS"  
    TEST.COST=1.7. 
    ASSIGN TEST.CUSTOMER_NAME="JONES"  
    TEST.ORDER_NUMBER =I 
    TEST.ORDER="PENCILS"
    TEST.COST=2.50
    TEST.CUSTOMER_NAME = "TURNER"
    TEST.ORDER_NUMBER = I  
    TEST.ORDER="PENS"
    TEST.COST=0.7. 
    END.
    END METHOD.

我正在尝试使用它来显示它们

 FOR EACH TEST:   
        DISPLAY TEST.COST TEST.CUSTOMER_NAME TEST.ORDER TEST.ORDER_NUMBER.
        RETURN.
END.

然而,结果只显示输入的最后一行数据。谁能帮忙,我什至不确定显示功能是否正确或分配是否正确。

4

3 回答 3

4

FOR EACH 中的“返回”导致代码在第一条记录后离开循环。删除该语句,您将看到所有记录。

FOR EACH TEST:
DISPLAY TEST.COST 
        TEST.CUSTOMER_NAME 
        TEST.ORDER 
        TEST.ORDER_NUMBER. 
RETURN.   /* this is why you're only seeing one record -  */
          /* get rid of this and you'll see all the records */
END.
于 2012-08-09T12:58:44.153 回答
3

我会避免将订单编号指定为 0。这只是为了让人们感到困惑。

define variable i as integer no-undo.

do i = 1 to 100:

  create test.

  assign
    test.order_number = i
    test.customer     = "smith"             /* you need some way to get   */
    test.order        = "books"             /* actual data for the rest   */
    test.cost         = random( 10, 100)    /* of the fields...           */
  .

end.

然后通过以下方式查看订单:

for each test no-lock:
  display test.
end.
于 2012-08-09T12:13:26.573 回答
1

是的,我所需要的只是为每条记录的每个分配创建一个声明,并且有效。谢谢大家,工作代码如下:

 CREATE TEST.

ASSIGN TEST.CUSTOMER_NAME="SMITH"
TEST.ORDER_NUMBER=I  
TEST.ORDER="BOOKS" 
TEST.COST=45.00.  
CREATE TEST.
ASSIGN  TEST.CUSTOMER_NAME = "TAYLOR" 
TEST.ORDER_NUMBER=I 
TEST.ORDER="PAPER CLIPS"  
TEST.COST=1.7.
CREATE TEST.
ASSIGN TEST.CUSTOMER_NAME="THOMPSON"  
TEST.ORDER_NUMBER =I 
TEST.ORDER="PENCILS"
TEST.COST=2.50.
CREATE TEST.
ASSIGN TEST.CUSTOMER_NAME = "TURNER"
TEST.ORDER_NUMBER = 2 
TEST.ORDER="PENS"
TEST.COST=0.7. 

对于 TEST.COST > 1.3 BY TEST.ORDER_NUMBER 的每个测试:显示测试。结尾。

于 2012-08-10T09:14:38.337 回答