简体   繁体   English

使用X ++ AX 2012 R2在视图中循环浏览记录

[英]Loop Through Records in a view using X++ AX 2012 R2

Loop through records in a View Ax 2012 R2( Need a job to achieve this) 循环浏览View Ax 2012 R2中的记录(需要完成这项工作)

I have a viewA where i have three fields Destination , Source, FieldX 我有一个viewA,其中我有三个字段Destination,Source和FieldX

I have a table where i have master list for Source This table contains S1, S2..... 我有一个表,其中有源的主列表。此表包含S1,S2 .....

In the view for each S1 i need to find the final Destination Value Example: Destination Source Type D1 S1 D2 D1 D2 No record found Explanation for above example: I took S1 from master list and placed in Source field in View. 在每个S1的视图中,我需要找到最终的目标值示例:目标源类型D1 S1 D2 D1 D2未找到记录上面的示例的解释:我从主列表中获取了S1,并将其放在View的Source字段中。 then I read Destination value for that Record which is D1. 然后我读取该记录的目标值D1。 Now I placed D1 in the source field filter and i found a record with destination value D2. 现在,我将D1放置在源字段过滤器中,并找到了目标值为D2的记录。 Now i took D2 and i placed it in the source field filter and i didnt find a record. 现在我拿了D2并将其放在源字段过滤器中,但没有找到记录。 i stop the loop here and i had to save D2 value. 我在这里停止循环,我不得不保存D2值。

For S1 , the final Destination value is D2. 对于S1,最终的目标值是D2。

Example 2: 范例2:

Destination Source Type da s2 db da dc db dc No record found 目标源类型da s2 db da dc db dc找不到记录

For S2, the final Destination value is Dc. 对于S2,最终的目标值是Dc。

I am not sure how i should loop in view for S1 to find the D2. 我不确定如何在S1中循环寻找D2。 I had to do this process one by one for all S1,s2.....Sn. 我必须对所有S1,s2 ..... Sn逐个执行此过程。

I tried few things using while/for or other loops with no luck. 我尝试了一些使用while / for或其他循环的事情,但是没有运气。 Can someone help me with a base code to acheive this? 有人可以通过基本代码帮助我实现这一目标吗?

How is the "final Destination Value" determined? 如何确定“最终目的地价值”? What logic are you using to determine if a value is a "final Destination Value"? 您使用什么逻辑来确定值是否为“最终目标值”? Is it complex logic or is it simply the largest value for that Source? 它是复杂的逻辑还是仅仅是该来源的最大价值? Could you just join the view to the table and use a maxOf(Destination) on the view with a group by on the Source field? 您能否仅将视图加入表并在视图上使用maxOf(Destination)并在Source字段中使用group by?

Assuming it is not complex logic, something like this might be possible: 假设它不是复杂的逻辑,则可能是这样的:

ViewA viewA;
Table table;

while select maxOf(Destination) from viewA
    group by viewA.Source
    join table
        where viewA.Source == table.Source

info(strFmt("%1", ViewA.Destination));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM