ABAP Table control and Step Loops (Step-loop).

Source: Internet
Author: User
Tags table name
ZZ "http://moonfly2004.javaeye.com/blog/200328"



Table control and step loops     1. Two standard demo:sapmtz60, SAPMTZ61 2. Introduction 3. Establish the basic process of the Table control program 4. Using Step loops 5. Table control and step loop considerations 6. The difference between looping in a screen table and looping between a table and a screen table 7. Determine the record entry for the screen loop 8. MODIFY2. Introduction table controls and step loops are the objects that are used for the display of the screen table. Table control is just an enhanced step loop that can display data using the "look" and "feel" of the table tools in the desktop application. Table control also provides a feature of a dedicated formatting feature step loop that makes tables easy to see and use: Their table rows can span multiple lines on the screen. In contrast, rows in table control are always single row, but can be very long. (table-controlled rows can be scrolled.) Often table control provides many of the features that are manipulated by the SAPgui front end of the system, so you do not have to compile any features in the ABAP/4 transaction (except for vertical scrolling). The Loop statement's task loop is responsible for reading the screen table values between a round trip and a ABAP/4 program. Therefore, the loop statement must be compiled for each of the screens in the PBO and PAI events at the same time. At least there should be an empty loop ... The Endloop statement. The LOOP statement is also used to drive scrolling. In the PBO event, Loop uses a parameter to tell where to start the loop from the table. This parameter therefore causes the next screen table to display an update (for tabular control, the Top_line field in the table control structure; For a step loop, this parameter is the cursor parameter for the Loop statement.) )。 This parameter can be set by both the ABAP/4 program and the system. Note that the number of rows displayed in the screen table can be changed. This can happen when the screen table is resizable and the user changes the height of the window. In this case, the next loop in Pai changes the number of table rows that are passed to the ABAP/4 program in Pai.        There are two important formats for loop statements: If you are using Table control, you must include the additional with control parameter: loop with control <table-control>. <actions&gt, ..... Endloop. The statement loops in the screen table row (How many rows the Table Control has to cycle through) , transferring data between each block and the corresponding ABAP/4 field of the program. You can declare a screen table field as any type (database table, structure, or individual field) in Abap/4, with the exception of the inner table fields. For a step loop, you must use this statement if you are performing its own scrolling (for example, using F21-f24). LOOP at <internal Table>. The statement can be looped in both the inner table and the screen table row. This screen table field is often declared as inner table fields, but this is not necessarily the case. For this loop, the step loop display has scroll bars. The scroll is automatically manipulated by the system. 7.     at the time of the controls declaration, the corresponding screen can manipulate the objects defined by the controls Eg.   loops directly in the ABAP/4 module in the screen table, using SY-STEPL to find the index of the screen table row currently being processed. Once per loop, the system sets the variable once. The value of SY-STEPL is always between 1 and the number of rows currently displayed. You can declare a table offset (often called BASE, usually initialized with SY-LOOPC) in your program and use it with SY-STEPL to get the inner table row that corresponds to the current screen table row. (IND = BASE + sy-stepl-1.) Keep in mind that SY-STEPL is only in loop ... The scope of endloop processing is meaningful. Loop loops at <internal table> [CURSOR <scroll-var>] in the inner table.                               [with CONTROL <table-control>]                              [From <line1>] [to <line2>].     ... <actions&gt     endloop. Represents a loop in both the inner table and the screen table. This form of loop statement loops through the table, executing <actions> for each row. For each inner table row, the program field is routed to the corresponding screen table row, or the corresponding screen table row is routed back to the corresponding program field. When using a step loop, omit the cursor parameter from the Pai event. The From and to parameters can only be used for step loops. The with control parameter can only be used for table control. Set <scroll-var> to tell the system where to start the display. For Table control,<scroll-var> is the Top_line field in the TableView structure (the system is automatically set if omitted). For a step loop, declare the local program variable to be used as the cursor parameter.     Establish the basic flow of the Table control program. Main program 1.     declaration Form controls Eg. CONTROLS:CTRL1 TYPE TABLEVIEW USING screen 0901. 2.     define the Itab DATA SP1 like SPFL1 occurs 0 with HEADER line to show out. DATA SP1 like TABLE of SPFL1 with HEADER line. Equivalent 3.     Add Itab Data//Logic stream 4.     Loop Read Itab writes row by line to the current row of table control. (BPO) LOOP with CONTROL <table-control> [cursor tab1-current_line]. 5.     Update ITAB LOOP at <ITAB>  chain when data changes. FIELD Sp1-carrid. ...         MODULE tab1_modify onChain-request.      endchain.    Endloop. Use step loops. Step loops are divided into two categories: static and dynamic. The static step loop has a fixed size and cannot be changed at run time. Dynamic step loops are variable in size. If the user resets the window size, the system automatically increases or decreases the number of step loop blocks displayed. You can define any number of static step loops, but there can be only one dynamic step loop. You can specify the type of step loop in the Screen builder. Each loop in the screen has a loop type (fixed= static, variable= dynamic) and cycle count properties. If the loop is fixed, cycle times tells the system the number of loop blocks to display. The value can be permanently unchanged. The method of developing dynamic and static step loops is exactly the same. Both types can use loop and loop at statements. The screen operation as shown in Figure 1.    into field 2.    Select the field to group, and the field defines the group
Table control and step loop considerations 1.     The I/O field placed in the layout designer can be from Dbtab or from Itab, which is actually a screen-aware <work area> 2.     I/O placed on screen field and other controls such as the table control must be consistent with the name declared in the main program, if you place a field that is not defined before, the runtime will appear Error or cannot be activated at all. 3. The Pbo/pai logic flow is triggered by     whether the scrollbar or the down button is triggered.   4. The difference between looping in the screen table and looping between the table and the screen table     only in the screen table, will be based on the screen table, in the display, you need to display the inner table to fit the screen, if the screen table more than the number of rows in the table will still show some empty rows such as//logical flow LOOP with CONTROL CTRL1.    MODULE display_ctrl1_101. Endloop. Program READ TABLE imakt INDEX ctrl1-current_line.  if SY-SUBRC = 0.     Makt-spras = Imakt-spras.     MAKT-MAKTX = imakt-maktx.     Ctrl1-flag = Imakt-ckbox.  endif.     the simultaneous loop between the table and the screen table allows both the screen table and the inner table to loop simultaneously. Do not have to strictly control the inner table to read the line (the individual efficiency is higher than the former, because there is no need to search and judge), and will not show more blank lines. Logical flow LOOP at Imakt with CONTROL CTRL1 CURSOR ctrl1-top_line.    MODULE display_ctrl1_101. Endloop. Program     Makt-spras = Imakt-spras.     MAKT-MAKTX = ImakT-maktx. Ctrl1-flag = Imakt-ckbox. 5. Put the inner table (workspace) in the screen table. is the screen table and the In-Program Table Association. l          The itab to be put must make the table head (in fact, the screen is WA) l         Note Select the time to write the inner table name, select the Back button l        The user's update is automatically recognized by the modify system directly when the operation is in action. Just loop, pay attention to the movement of the pointer, try to make the screen and the inner table loop together. l        because the screen table is associated with the in-app table, the various parameters of the screen table can still be used when loop at <ITAB> in Pai. Index Ctrl1-current_line//Logical Flow (PAI) LOOP at Imakt.     MODULE set_line_count_0901. Endloop. Program Module set_line_count_0901 input MODIFY imakt index ctrl1-current_line. Endmodule.
Again table controller 1. The table controller set in layout is a bit like the GridView in. NET, where each column must be the same as the field name of the inner table that is associated with it, otherwise it will not be accessible, or it cannot be removed.     2. In addition, the/selcolumn option can be associated with a field of type C in Itab to determine the selection of a table row.     ABAP---Read the first N rows in db SELECT * up to <N> rows .... Set the field that must be entered in the screen editor to determine the record entry for the screen loop use SY-STEPL to find the index of the screen table row that is currently being processed. Once per loop, the system sets the variable once. The value of SY-STEPL is always between 1 and the number of rows currently displayed. You can declare a table offset (often called BASE, usually initialized with SY-LOOPC) in your program and use it with SY-STEPL to get the inner table row that corresponds to the current screen table row. (IND = BASE + sy-stepl-1.) MODIFY MODIFY <itab> [from <wa>] [INDEX <idx>]. The work area specified in the From option <wa> the row in place of <itab>. If the table has header rows, you can omit the From option. In this way, the table work area is substituted for rows. If you use the index option, the new row replaces the existing row that is indexed as <idx>. If the substitution succeeds, the SY-SUBRC is set to 0. If the inner table contains fewer than <idx> rows, no rows are changed and SY-SUBRC contains 4. If you use a MODIFY statement that does not have an index option, the system can only handle it in the Loop-endloop block by changing the current row (for example, the row whose index is returned by Sy-tabix).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.