‎2007 Feb 21 3:38 AM
<b>Hi,</b>
How to use loop/endloop in table controls what's the use of loop/endloop in tablecontrols?
How can we select one row information by double clicking on table control and to select that data to another screen.
‎2007 Feb 21 4:04 AM
Hi Lakshmi,
this code will helps u,,
PROCESS BEFORE OUTPUT.
MODULE STATUS_9000.
LOOP AT IT_STR WITH CONTROL TC.
MODULE FILL_MODULE_9OOO.
MODULE ICON_9000.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE CANCEL AT EXIT-COMMAND.
LOOP AT IT_STR.
CHAIN.
FIELD IT_STR-MNO.
FIELD IT_STR-QTY.
MODULE FILL_TABLE_9000 ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
****************************************************
MODULE FILL_TABLE_9000 ON CHAIN-REQUEST.
DATA : V_LINECOUNT TYPE I, "TO FIND NO OF LINES IN INTERNAL TABLE
V_PAGECOUNT TYPE I, "TO ADD LINES WHEN SCROLLING
V_ABS_LINE TYPE I. "FOR CURRENT LINE
IF SY-DATAR = 'X'. "CLICK IS ON MESSAGE OR IN SCROLL.
DESCRIBE TABLE IT_STR LINES V_LINECOUNT. "TO GET THE NO OF LINES
IF SY-SUBRC = 0.
V_ABS_LINE = TC-TOP_LINE + SY-STEPL - 1. "GETTING THE CURRENT LINE
IF V_ABS_LINE LE V_LINECOUNT. "CHECKING WHEATHER CURRENT LINE IS GT LINECOUNT
MODIFY IT_STR INDEX V_ABS_LINE. "SY-STEPL.
ELSE.
IT_STR-ZINO = V_ABS_LINE.
APPEND IT_STR.
ENDIF.
ENDIF.
*tc-lines = sy-tfill + 1.
V_PAGECOUNT = SY-STEPL DIV SY-LOOPC. "CHECKING WHEATHER TO ADD LINES OR NOT
IF V_PAGECOUNT > 0.
TC-LINES = V_LINECOUNT + SY-LOOPC.
ENDIF.
ENDMODULE.
ENDIF.
Check these.
https://forums.sdn.sap.com/click.jspa?searchID=239682&messageID=2773115
https://forums.sdn.sap.com/click.jspa?searchID=239682&messageID=2337199
Regards,
Priyanka.
‎2007 Feb 21 3:50 AM
HI,
YOu need to use LOOP ENDLOOP USING.. in both PBO and PAI of the screen in which you have your table contorol.
IN PBO it is need to to push the data you have in your internal table on to the screen.
IN PAI it is needed to get back the changed data from the screen on to your own internal table.
You can make the table control with Lead Selection option by having one more filed say MARK of type CHAR 1. When you select this row mark will have value 'X' you just need to process the rows which have mark = 'X' in loop and loop of PAI.
Once you got the selected row I think its easy to move the data on to a structure that you define using TABLES statement and which you would have used to create the next screen.
Also see some of the example programs in the package SLIS.
Regards,
Sesh
Message was edited by:
Seshatalpasai Madala
‎2007 Feb 21 4:04 AM
Hi Lakshmi,
this code will helps u,,
PROCESS BEFORE OUTPUT.
MODULE STATUS_9000.
LOOP AT IT_STR WITH CONTROL TC.
MODULE FILL_MODULE_9OOO.
MODULE ICON_9000.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE CANCEL AT EXIT-COMMAND.
LOOP AT IT_STR.
CHAIN.
FIELD IT_STR-MNO.
FIELD IT_STR-QTY.
MODULE FILL_TABLE_9000 ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
****************************************************
MODULE FILL_TABLE_9000 ON CHAIN-REQUEST.
DATA : V_LINECOUNT TYPE I, "TO FIND NO OF LINES IN INTERNAL TABLE
V_PAGECOUNT TYPE I, "TO ADD LINES WHEN SCROLLING
V_ABS_LINE TYPE I. "FOR CURRENT LINE
IF SY-DATAR = 'X'. "CLICK IS ON MESSAGE OR IN SCROLL.
DESCRIBE TABLE IT_STR LINES V_LINECOUNT. "TO GET THE NO OF LINES
IF SY-SUBRC = 0.
V_ABS_LINE = TC-TOP_LINE + SY-STEPL - 1. "GETTING THE CURRENT LINE
IF V_ABS_LINE LE V_LINECOUNT. "CHECKING WHEATHER CURRENT LINE IS GT LINECOUNT
MODIFY IT_STR INDEX V_ABS_LINE. "SY-STEPL.
ELSE.
IT_STR-ZINO = V_ABS_LINE.
APPEND IT_STR.
ENDIF.
ENDIF.
*tc-lines = sy-tfill + 1.
V_PAGECOUNT = SY-STEPL DIV SY-LOOPC. "CHECKING WHEATHER TO ADD LINES OR NOT
IF V_PAGECOUNT > 0.
TC-LINES = V_LINECOUNT + SY-LOOPC.
ENDIF.
ENDMODULE.
ENDIF.
Check these.
https://forums.sdn.sap.com/click.jspa?searchID=239682&messageID=2773115
https://forums.sdn.sap.com/click.jspa?searchID=239682&messageID=2337199
Regards,
Priyanka.
‎2007 Feb 21 6:17 AM
Hi,
Table Controls are labeled screen elements to display and process table-like data on dynpros. In a table control, a maximum of 255 screen elements is summarized in a table control row, which can be repeated multiple times within the table control on the screen . The fields of a row have to be created only once as dynpro-fields in the dynpro and as global data object in the ABAP-programm. Table controls offer an area on the screen to edit the displayed table control rows which offers column headers, marking of rows and columns, horizontal and vertical scrolling via scroll bars, the definition of lead columns and saving of the current settings (see DEMO_DYNPRO). Parts of the user actions in table controls are processed from the presentation server. Vertical scrolling, saving of settings, and changes of screen size (if the Resizing properties have been set accordingly when defining the table controls) trigger the event PAI.
A column of the table controls can be defined as marking column , in which the screen element is displayed like a pushbutton and treated like a checkbox (see the first column of the table control in DEMO_DYNPRO). A checked selection key sets the content of the assigned dynpro-field to "X", an unchecked key sets the content to " ". The state of the selection key is transported at the event PAI to a data object of the same name in the ABAP-program and at PBO, you can set the marker via the content of the data object.
Table Controls encapsulate steploops and make their independent use obsolete. The processing of table controls in the dynpro flow logic accordingly bases on the steploop technique using the statement LOOP. In contrary to the processing of independent steploops, the loops of the dynpro flow logic are linked with the addition WITH CONTROL with the table controls of the dynpros during the processing of table controls.
In the ABAP-program, table controls must be declared with the statement CONTROLS, whereat a special structure for handling of table controls is created.
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.
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.
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.
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 contrl.
...
ENDLOOP.
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.
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.
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 AT itab CURSOR cur INTO wa
[CURSOR top_line] [FROM n1] [TO n2]
WITH CONTROL contrl.
...
ENDLOOP.
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.
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.
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).
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.
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.
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.
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.
Regards
Gaurav