LOOP WITH CONTROL 用法
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 ENDLOOP can 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.
在屏幕邏輯流中定義一個(gè)和表控件control 聯(lián)系在一起的LOOP循環(huán),這個(gè)LOOP循環(huán)通過每執(zhí)行一次循環(huán)通過表控件的一行來處理表控件control的當(dāng)前行。對(duì)于表控件control ,你必須直接指定這個(gè)屏幕表控件的名字。如果表控件不存在,Loop循環(huán)被忽略。在LOOP和ENDLOOP之間的語句可以包含邏輯流的FIELD, MODULE, CHAIN和ENDCHAIN關(guān)鍵字。在這里不能進(jìn)行循環(huán)嵌套。你可以在參照或者不參照內(nèi)表的情況下執(zhí)行循環(huán)。
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.
如果表控件被定義在一個(gè)屏幕中,你必須在PBO處理塊和PAI處理塊為每一個(gè)表控件定義一個(gè)LOOP循環(huán)。
System Fields 系統(tǒng)字段
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循環(huán)中,系統(tǒng)字段sy-stepl 保存著當(dāng)前表控件的行數(shù),從最頂部的可見行開始。系統(tǒng)字段sy-loopc保存著表控件顯示在屏幕上的總行數(shù)。
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和表控件聯(lián)接起來,使用with control 附加項(xiàng)。不包含這個(gè)附加項(xiàng)的LOOP語句獨(dú)立處理每步循環(huán)并且已經(jīng)很被廢棄了。
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條件,在一個(gè)LOOP循環(huán)期間表控件control的當(dāng)前行的屏幕字段內(nèi)容傳送從(事件PBO)或者到(事件PAI)ABAP程序中具有相同名字的數(shù)據(jù)對(duì)象中。在PBO處理期間,傳送在結(jié)束時(shí)完成,在PAI處理期間在LOOP循環(huán)開始時(shí)完成。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.
對(duì)于參照ABAP字典定義的表控件上的屏幕字段,與ABAP程序中有相同名字的數(shù)據(jù)對(duì)象必須像普通的屏幕字段一樣用TABLES準(zhǔn)確地進(jìn)行聲明,否則將不會(huì)傳遞數(shù)據(jù)。
- 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循環(huán)中,你可以調(diào)用會(huì)話模塊來處理和ABAP程序相關(guān)的數(shù)據(jù)對(duì)象。例如,你可以在PBO模塊從一個(gè)內(nèi)表中讀取數(shù)據(jù)并且在屏幕處理結(jié)束后在PAI模塊把他寫回內(nèi)表中。
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 項(xiàng),在表控件的循環(huán)處理期間,ABAP程序中相一致的內(nèi)表itab也同時(shí)被處理了。對(duì)于表控件的每一行,處理內(nèi)表中的一行。內(nèi)表itab必須是索引表。你只能在PBO模塊指定INTO, CURSOR, FROM, TO 和 WITH CONTROL這些項(xiàng),而不能在PAI模塊指定。在PAI模塊,內(nèi)表用于表控件的參考。
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項(xiàng)來指定一個(gè)工作區(qū)WA,wa在每個(gè)LOOP循環(huán)結(jié)束通過內(nèi)表的當(dāng)前行時(shí)被指定。如果你不指定wa項(xiàng),必須使用帶表頭的內(nèi)表,表頭用來在后臺(tái)代替wa。Wa的內(nèi)容或者是表頭行的內(nèi)容在這個(gè)作業(yè)結(jié)束后被傳輸?shù)奖砜丶漠?dāng)前行具有相同名字的字段中。Wa工作區(qū)必須是ABAP程序的一個(gè)和內(nèi)表的行類型相匹配的全局?jǐn)?shù)據(jù)對(duì)象。在PAI事件中,只有工作區(qū)wa或者是內(nèi)表的表頭被表控件的行在每次循環(huán)開始時(shí)被填充。內(nèi)表的數(shù)據(jù)不會(huì)自動(dòng)改變。
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項(xiàng)與循環(huán)處理相同。當(dāng)在表控件上執(zhí)行loop循環(huán)時(shí),你可以使用附加項(xiàng),但它們也并不是必須的,因?yàn)楸砜丶辉O(shè)計(jì)用于被結(jié)構(gòu)類型CXTAB_CONTROL 在ABAP程序中通過生成CONTROLS控制。這里,字段TOP_LINE 的top_line相當(dāng)于這個(gè)結(jié)構(gòu)當(dāng)行數(shù)被顯示出來時(shí)能夠用字段LINES控制從而取代了n1和n2。如果n1仍然被指定了,字段CURRENT_LINE的值通過如下方法計(jì)算得到,和在CONTROLS中出現(xiàn)的方法不相同。
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.
對(duì)于表控件上參照ABAP字典的扁平結(jié)構(gòu)定義的屏幕字段,和ABAP程序具有相同名字的數(shù)據(jù)對(duì)象必須和普通屏幕字段一樣用TABLES進(jìn)行聲明,否則將不會(huì)有數(shù)據(jù)傳遞。
- 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不必調(diào)用會(huì)話模塊來從內(nèi)表中讀取數(shù)據(jù)。然而,在PAI,如果想取到傳遞來的數(shù)據(jù)你必須提供會(huì)話模塊。例如,你可以通過用戶記錄修改內(nèi)表。
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.
如果在主屏幕上定義一個(gè)表控件FLIGHT_TAB,相關(guān)的流邏輯可能是這樣的。LOOP循環(huán)參照內(nèi)表spfli_tab執(zhí)行。在PBO,LOOP循環(huán)調(diào)用一個(gè)會(huì)話模塊prepare_tab來填充內(nèi)表,在LOOP循環(huán)中,在PBO塊沒有調(diào)用會(huì)話模塊,因?yàn)樵谶@個(gè)例子中的表控件被自動(dòng)填充了。在PAI,LOOP循環(huán)調(diào)用了modify_tab會(huì)話模塊用來保存用戶在表控件上的輸入修改到內(nèi)表中。你可以找到ABAP程序示例CONTROLS中相關(guān)的程序塊。
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.
由于水平有限,并且也是剛接觸這些不久,所以翻譯顯得很生硬,請(qǐng)諒解。翻譯也是旨在提高自己的英語水平,希望自己能有所提高,這樣堅(jiān)持下去吧……
希望大家批評(píng)指正,謝謝。轉(zhuǎn)載于:https://www.cnblogs.com/clsoho/archive/2010/01/22/1654379.html
總結(jié)
以上是生活随笔為你收集整理的LOOP WITH CONTROL 用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: do...while(0)的妙用
- 下一篇: 谈谈分布式事务(Distributed