Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem with table control

Former Member
0 Likes
1,249

Hi,

This is the first time I am working in table control.I have made a table control named tab_cntrl.

this tab_cntrl have 6 columns and 5 row..Now each row will have different values as I will be selecting it from 5 different database table and display it in each row.I just wanted to know how can we access different row in table control..is there any system field which stores the line no or row number and column number of table control...as well as how can I write in it. Any sample code will be of grt help.

Thanx

8 REPLIES 8
Read only

Former Member
0 Likes
840

hi Priya!!

you can find the solution on Forum as well ..... her is the link i hope this will help u

http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbac9f35c111d1829f0000e829fbfe/content.htm

Thanks

Ashu

Read only

Former Member
0 Likes
840

Check program DEMO_DYNPRO_TABCONT_LOOP

Read only

Former Member
0 Likes
840

Hello Priya,

Any control that we represent on screen has equvalent field in ABAP code that means

table control will also have some internal table representing in ABAP code.

So, You can manipulate that internal table and Table control will display those content accordingly.

Please refre SAP help for more information on table control and internal table working.

It is pretty simple! Just try once!

Thanks,

Augustin.

Read only

Former Member
0 Likes
840

Hi,

have a look on this link,

hope it will help.

regards,

Archana

Read only

Former Member
0 Likes
840

Hi!

In the table control to access the fields for click the code goes as

On the screen there is a checkbox for table control to respond on double click check that.

Sample Code


data:
  w_tabix     TYPE sy-tabix.         " Stores Tabix Value
  w_data      TYPE likp-vbeln  ,     " Stores data on Cusor
  line_sel    TYPE sy-stepl ,        " Stores Line Number


FORM call_screen_300.

 GET CURSOR FIELD fs_likp-vbeln LINE line_sel VALUE w_data.

IF fs_likp-vbeln  NE 'FS_LIKP-VB'.

   MESSAGE 'Click on Delivery Number Only'(004) TYPE 'E'.

  ENDIF.                               " IF FS_LIPS-VLELN...

  w_tabix =  table_control-top_line + line_sel - 1 .

  CALL  SCREEN 300.

ENDFORM

Or you can give a mark field for the leads for the row....

W_MARK TYPE C VALUE 'X'.

you need to define a variable of 1 char like below which will return the selected row in the PAI where through read statement you can get the corresponding row values.

https://wiki.sdn.sap.com/wiki/display/ABAP/LearnMakingFirstTableControl

also u can give a look to DEMO_DYNPRO program for getting the current line in table mark and ither functionality in table control.

Read only

Former Member
0 Likes
840

Hi,

Here is a description of how to play with rows and columns in a table controll

SORTING BY COLUMN

We have to first determine which column of table control was selected for sorting.Then we have to determine the name of the field from this information to use in SORT itab STABLE BY field command.

e.g.

DATA: col LIKE LINE OF tab_con-COLS "tab_con is name of table control,
                                                            "COLS field is an internal table of TYPE
                                                            "CXTAB_COLUMN  .This variable will 
                                                            "be used to access column attributes of
                                                            "the table control. 
 
*We will read the column properties of selected column into col variable from
*collection of columns COLS. 
*SELECTED is the field of structure CXTAB_COLUMN and indicates selection.
 
READ TABLE tab_con-COLS INTO col WITH KEY selected = 'X' .
 
IF SY_SUBRC EQ 0.
*col-SCREEN-NAME(+offset)  is used to determine the actual field name(like *PHONE) as*col-SCREEN-NAME will return the screen name like ADDRESS-*PHONE.
*the value of offset depends upon the length of the name of the structure.
 
SORT itab STABLE BY col-SCREEN-NAME(+offset) 
ENDIF.

DELETING SELECTED ROWS

Deletion of selected rows is simple. To delete selected rows first we will determine the rows which have been selected through selection column .

FOR SINGLE ROW SELECTION

IF mark EQ 'X' .             "mark is the name of selection column field
DELETE itab FROM workarea .  
ENDIF.

FOR MULTIPLE ROW SELECTION

*To deetermine the rows selected we will use the selection column field to loop

*through the internal table.

LOOP AT itab WHERE mark EQ 'X'.  "mark is the name of selection column field
DELETE itab                                    " and is part of the internal table . 
ENDLOOP.

HIDING A COLUMN

To hide a column we will use the INVISIBLE field of the structure CXTABA_CONTROL and set its value to 'X'.

e.g. To hide column number 3.

DATA col LIKE LINE OF tab-con-COLS .
READ TABLE tab_con-COLS INTO col WHERE index = 3. "tab_con is the name                                                                                
" of table control.
col-INVISIBLE = 3.
MODIFY  tab-con-COLS FROM col INDEX 3.

NOTE: Similarly other operations can be performed by changing the value of various fields of structure CXTAB_CONTROL.

Thank You,

Pavan.

Read only

Former Member
0 Likes
840

Hi Priya,

Data in a Table Control come from an internal Table. In the Process Before Output you populate the Dynpro Table from the ABAP Internal Table. So, you are left with the possibilities of manipulating the table control accordingly and can populate the data.

Have a look at the demo code for table control where in which it populates the data:

DEMO_DYNPRO_TABCONT_LOOP.

Hope this will help.

Thanks,

Samantak.

Read only

Former Member