• 【転載】LOOP


    本文的原文章:https://www.cnblogs.com/clsoho/archive/2010/01/22/1654379.html

    LOOP - WITH CONTROL

    Syntax  语法

    LOOP [AT itab INTO wa [CURSOR top_line] [FROM n1] [TO n2]] 
         WITH CONTROL contrl. 
      ... 
    ENDLOOP. 

    Variants: 变式

    1. LOOP WITH CONTROL contrl.
    
    2. LOOP AT itab CURSOR cur INTO wa 
           [CURSOR top_line] [FROM n1] [TO n2] 
           WITH CONTROL contrl. 

    Effect 作用

    Definition of a loop in the dynpro flow logic, which is linked to a table control contrl. The loop sequentially processes the presented rows of table control contrl by executing one loop pass per table control row. For contrl, you must directly specify the name of a table control of the dynpro. If the table control does not exist, the loop is ignored. The statement block between LOOP and ENDLOOPcan contain the keywords FIELD, MODULE, CHAIN and ENDCHAIN of the flow logic. You cannot nest loops. You can execute loops either with or without reference to an internal table.

    在屏幕逻辑流中定义一个和表控件control 联系在一起的LOOP循环,这个LOOP循环通过每执行一次循环通过表控件的一行来处理表控件control的当前行。对于表控件control ,你必须直接指定这个屏幕表控件的名字。如果表控件不存在,Loop循环被忽略。在LOOP和ENDLOOP之间的语句可以包含逻辑流的FIELD, MODULE, CHAINENDCHAIN关键字。在这里不能进行循环嵌套。你可以在参照或者不参照内表的情况下执行循环。

    If table controls are defined in a dynpro, you must define one loop for each table control both in the PBO processing block and in the PAI processing block.

    如果表控件被定义在一个屏幕中,你必须在PBO处理块和PAI处理块为每一个表控件定义一个LOOP循环。

    System Fields 系统字段

    Within the loop pass, the system field sy-stepl contains the number of the current table control row, started at the top visible row. The system field sy-loopc contains the total number of table control rows displayed on the screen.

    在LOOP循环中,系统字段sy-stepl 保存着当前表控件的行数,从最顶部的可见行开始。系统字段sy-loopc保存着表控件显示在屏幕上的总行数。

    Note

    To link the loop to a table control, use the addition WITH CONTROL. The statement LOOP without this addition processes stand-alone step loops and is obsolete.

    为了把LOOP和表控件联接起来,使用with control 附加项。不包含这个附加项的LOOP语句独立处理每步循环并且已经很被废弃了。

    Variant 1变式1

    LOOP WITH CONTROL contrl.
      ...

    ENDLOOP.

    Effect 作用

    If the addition AT itab is not specified, during a loop pass the contents of the screen fields of the current row of table control contrl are transported from (at event PBO) or to (at event PAI) the data objects with the same names of the ABAP program. During PBO processing, the transport is done at the end of, during PAI processing at the beginning of the loop pass. The addition WITH CONTROL must be specified both at PBO and PAI.

     

    如果没有指定AT itab条件,在一个LOOP循环期间表控件control的当前行的屏幕字段内容传送从(事件PBO)或者到(事件PAI)ABAP程序中具有相同名字的数据对象中。在PBO处理期间,传送在结束时完成,在PAI处理期间在LOOP循环开始时完成。WITH CONTROL条件必须在PBO和PAI模块都被指定。

     

    Notes 注释

    • For screen fields of the table control that are defined with a reference to the ABAP Dictionary, the data objects with the same names of the ABAP program must be declared exactly like normal screen fields with TABLES, otherwise there will be no data transport.

    对于参照ABAP字典定义的表控件上的屏幕字段,与ABAP程序中有相同名字的数据对象必须像普通的屏幕字段一样用TABLES准确地进行声明,否则将不会传递数据。

    • In the loop, you can call dialog modules to process the relevant data objects of the ABAP program. For example, you can read data from an internal table at PBO and write it back to this internal table at PAI, after processing it on the screen.

    在LOOP循环中,你可以调用会话模块来处理和ABAP程序相关的数据对象。例如,你可以在PBO模块从一个内表中读取数据并且在屏幕处理结束后在PAI模块把他写回内表中。

    Variant 2变式2

    LOOP AT itab CURSOR cur INTO wa
         [CURSOR top_line] [FROM n1] [TO n2]

         WITH CONTROL contrl.
      ...
    ENDLOOP.

    Effect 作用

    If you specify addition AT itab, during loop processing of the table control the internal table itab of the corresponding ABAP program is processed sequentially in parallel. For each row of the table control, one row of the internal table is processed. The internal table itab must be an index table. You can specify the additions INTO, CURSOR, FROM, TO and WITH CONTROL only at PBO, but not at PAI. At PAI, the internal table is used for reference to the table control.

    如果你指定AT itab 项,在表控件的循环处理期间,ABAP程序中相一致的内表itab也同时被处理了。对于表控件的每一行,处理内表中的一行。内表itab必须是索引表。你只能在PBO模块指定INTO, CURSOR, FROM, TOWITH CONTROL些项,而不能在PAI模块指定。在PAI模块,内表用于表控件的参考。

    Use addition INTO to specify a work area wa, to which at PBO at the end of each loop pass the current row of the internal table is assigned. If you do not specify the addition wa, an internal table with header row must be used, which will then be used implicitly instead of wa. The content of wa or of the header row is transported after the assinment to the fields with the same names in the current row of the table control. The work area wa must be a global data object of the ABAP program matching the row type of the internal table. At the event PAI, only the work area wa or the header row of the internal table is filled with the content of the table control rows at the beginning of each loop pass. The content of the internal table is not automatically changed.

    使用INTO项来指定一个工作区WA,wa在每个LOOP循环结束通过内表的当前行时被指定。如果你不指定wa项,必须使用带表头的内表,表头用来在后台代替wa。Wa的内容或者是表头行的内容在这个作业结束后被传输到表控件的当前行具有相同名字的字段中。Wa工作区必须是ABAP程序的一个和内表的行类型相匹配的全局数据对象。在PAI事件中,只有工作区wa或者是内表的表头被表控件的行在每次循环开始时被填充。内表的数据不会自动改变。

    The syntax of additions CURSOR, FROM and TO is identical to the processing of step loops. When looping on table controls, you are allowed to use additions, but they are not really necessary, because the table controls are designed to be controlled by the structure of type CXTAB_CONTROL created via CONTROLS in the ABAP program. Here, top_line of component TOP_LINE corresponds to this structure while the number of rows to be displayed can be controlled using component LINES instead of n1 and n2. If n1 is still specified for table controls, the content of component CURRENT_LINE is calculated as follows, differing from the method shown at CONTROLS: sy-stepl+ (TOP_LINE - 1) + (n1 - 1).

    语法中的CURSOR, FROM 和 TO项与循环处理相同。当在表控件上执行loop循环时,你可以使用附加项,但它们也并不是必须的,因为表控件被设计用于被结构类型CXTAB_CONTROL 在ABAP程序中通过生成CONTROLS控制。这里,字段TOP_LINE 的top_line相当于这个结构当行数被显示出来时能够用字段LINES控制从而取代了n1和n2。如果n1仍然被指定了,字段CURRENT_LINE的值通过如下方法计算得到,和在CONTROLS中出现的方法不相同。

    Notes 注释

    • For screen fields of the table control defined with a reference to flat structures in the ABAP Dictionary, the data objects with the same names of the ABAP program must be declared identically to normal screen fields using TABLES, otherwise there will be no data transport.

    对于表控件上参照ABAP字典的扁平结构定义的屏幕字段,和ABAP程序具有相同名字的数据对象必须和普通屏幕字段一样用TABLES进行声明,否则将不会有数据传递。

    • Between LOOP and ENDLOOP, at PBO no dialog module must be called to read the data from the internal table. At PAI, however, this is necessary provided you want to evaluate the transported data. For example, you can modify the internal table according to the user entries.

    在LOOP和ENDLOOP之间,在PBO不必调用会话模块来从内表中读取数据。然而,在PAI,如果想取到传递来的数据你必须提供会话模块。例如,你可以通过用户记录修改内表。

    Example

    If on the screen of a dynpro a table control FLIGHT_TAB is defined, the relevant flow logic may look like this. The loop is executed with reference to the internal table spfli_tab. At PBO, the loop calls a dialog module prepare_tab to fill the internal table. In the loop, at PBO no dialog module is called, because the table control in this case is filled automotically. At PAI, in the loop a dialog module modify_tab is called to store the changes the user entered in the table control in the internal table. You can find the relevant programming section of the ABAP program in the example for CONTROLS.

    如果在主屏幕上定义一个表控件FLIGHT_TAB,相关的流逻辑可能是这样的。LOOP循环参照内表spfli_tab执行。在PBO,LOOP循环调用一个会话模块prepare_tab来填充内表,在LOOP循环中,在PBO块没有调用会话模块,因为在这个例子中的表控件被自动填充了。在PAI,LOOP循环调用了modify_tab会话模块用来保存用户在表控件上的输入修改到内表中。你可以找到ABAP程序示例CONTROLS中相关的程序块。

    PROCESS BEFORE OUTPUT.
      MODULE prepare_tab.
      LOOP AT spfli_tab INTO spfli WITH CONTROL flight_tab.
      ENDLOOP.
    PROCESS AFTER INPUT.
      LOOP AT spfli_tab.
        MODULE modify_tab.
      ENDLOOP.

    本文的原文章:https://www.cnblogs.com/clsoho/archive/2010/01/22/1654379.html

  • 相关阅读:
    3.1.3、控制结构
    3.1.2、变量
    3.1.1、渲染模板
    3.1、Jinja2模板引擎
    第3章 模板
    2.6、Flask扩展
    2.5.4、响应
    2.5.3、请求钩子
    2.5.2、请求调度
    2.5.1、程序和请求上下文
  • 原文地址:https://www.cnblogs.com/yjyongil/p/11856375.html
Copyright © 2020-2023  润新知