‎2008 Feb 05 8:18 AM
hi
while getting data to table control , what is the use of keeping loop and endloop in both PBO and PAI
‎2008 Feb 05 8:20 AM
‎2008 Feb 05 8:21 AM
Hi,
table control is used to put data on screen in table form
and same is the case to get data from screen entered in form of table..
so there are multiple entries to display on screen
And multiple enteries to get from screen.
so we use loop-endloop in both PBO and PAI
ABAP Tableview Control
Basic form
CONTROLS ctrl TYPE TABLEVIEW USING SCREEN scr.
Effect
Creates a table control ctrl of the type TABLEVIEW. The reference screen for the initialization is the screen scr.
Purpose
The table control (referred to here as TC ) facilitates the display and entry of one-line, tabular data in dialog transactions.
The functional scope has been defined so that you can use the standard methods of a TC to easily implement many typical set operations, which are usually handled by an elementary STEP-LOOP.
Functional scope
· Tabular area for displaying and editing data.
· Column width and column position modifiable by user and by program.
· Storing and loading of user-specific column layout.
· Selection column for line selection with color selection display.
· Variable column headers as pushbuttons for column selection.
· Single selection, multiple selection, Select/deselect all.
· Scrolling functions (horizontal and vertical) using the scroll bar.
· Fixing of any number of key columns.
· Setting attributes for each cell at runtime.
Programming
The data exchange between the application and the SAPgui is achieved with a STEP-LOOP, that is an ABAP module is called to transfer data line-by-line for each page.
Example
Processing without an internal table
PROCESS BEFORE OUTPUT.
LOOP WITH CONTROL ctrl.
MODULE ctrl_pbo.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP WITH CONTROL ctrl.
MODULE ctrl_pai.
ENDLOOP.
In this case, the module ctrl_pbo OUTPUT is called once for each output line before the screen is displayed, in order to fill the output fields.
After the user has entered data on the screen, the module ctrl_pai INPUT is executed to check the input and copy the new contents.
Example
Processing with an internal table
PROCESS BEFORE OUTPUT.
LOOP AT itab WITH CONTROL ctrl CURSOR ctrl-CURRENT_LINE.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT itab WITH CONTROL ctrl.
MODULE ctrl_pai.
ENDLOOP.
Here, the system fills the output fields before displaying the screen by reading the internal table itab.
When the user has entered data, the module ctrl_pai INPUT must be executed to check the input and to refresh the contents of the internal table.
If there are several table controls on one screen, the order of the loop statements in the flow logic must correspond to the order of the controls on the screen (from top left to bottom right).
Vertical scrolling with the scroll bar is followed by the event PAI for the displayed page. Then, cntl-TOP_LINE is increased and PBO is processed for the next page.
Program-driven scrolling and most of the functions described above are achieved by manipulating the control attributes.
Attributes
The CONTROLS statement creates a complex data object of the type CXTAB_CONTROL with the name of the control.
You maintain the initial values in the Screen Painter and assign the screen with the initial values for a control using the addition USING SCREEN.
A further dynamic initialization occurs in the "1st access to the control" (setting or reading values). However, the time of the "1st access" is not clearly specified. This is especially important for the LINES component, which controls the scroll bar of the table control.
For a description of individual components of the structure CXTAB_CONTROL, refer to:
Table Controls in ABAP Programs
When displaying the control, the system uses the current contents at the time when all PBO modules have run. The modified values (changed by the user on the screen) are set directly before the first PAI is called.
Reward if helpful
Gaurav J.
Edited by: Gaurav Juneja on Feb 5, 2008 9:21 AM
‎2008 Feb 05 8:21 AM
loop and endloop are used to populate your screen table with internal table contents in PBO
and in PAI it is used to to populate your database table with contents displayed on your screen.
plz reward if useful
vivek
‎2008 Feb 05 12:21 PM
hi vivek,
but can u tell me why we need it in both...
suppose i am making my table control only output enable and data display in table control from internal table so as per ur answer loop endloop needed only in PBO but if we dont write loop endloop in PAI, it gives error...
Can u give me reason for this?
‎2008 Feb 05 8:22 AM
Hi
The cycle LOOP/ENDLOOP of PBO is to transfer the data from memory (so from an internal table) to screen (so to table control).
The cycle LOOP/ENDLOOP of PAI is to transfer the data from screen (so from table control) to memory (so to an internal table).
U should consider the table control is a particular screen table having a number of records can be dispalyed on the screen only.
So if you design a table control with 10 rows by screen painter, your table control can have 10 rows only. If you need to display a data of a table with 100 records, the LOOP/ENDLOOP loads (to the screen) or downloads (from the screen) only a package of 10 records.
Max
‎2008 Apr 03 7:44 AM
HI ,
how can i enable the fields in table controle, thouse i had disable whole fields already and i had created one pussbutton show that when ever i press that "puss" some of my fields should enable show that i can make edit or modify that fields.
plz revert back soon .
regards,
wasim
‎2008 Apr 03 7:45 AM
HI ,
how can i enable the fields in table controle, thouse i had disable whole fields already and i had created one pussbutton show that when ever i press that "puss" some of my fields should enable show that i can make edit or modify that fields what is the code for that ?.
plz revert back soon .
regards,
wasim
‎2008 Apr 08 6:21 AM
HI ,
thax i got the answer...but not from sap guru by my own buz no one has reply me ....! by