Application Development 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: 

Table Control

Former Member
0 Kudos

HI,

My requirement is to create a table control where the standard features of Scrolling , Page Up /Down, Adding/Deleting rows should be included.

Can anyone provide me with the code snippet for this.

thanks

Aviroop

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

use this standard program and go through the code .

demo_dynpro_tabcont_loop

regards,

vikky.

6 REPLIES 6

Former Member
0 Kudos

Hi Aviroop,

refer these for the steps..

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/d1/802338454211d189710000e8322d00/content.htm">Creating and Modifying Table Controls</a>

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/6d/150d67da1011d3963800a0c94260a5/content.htm">Using the Table Control Wizard</a>

regards

satesh

Former Member
0 Kudos

hi,

use this standard program and go through the code .

demo_dynpro_tabcont_loop

regards,

vikky.

Former Member
0 Kudos

A table control comes with the default feature of scrolling and Page up/down. No code is required for the same.

As for the insert/ delete functionality you will have to code for it.

Add 2 buttons on your screen for insert and delete, and check for their ok-code in the program.


CASE ok_code.
WHEN 'INSERT'.
APPEND itab.

WHEN 'DELETE'.
DELETE itab WHERE sel = 'X'. "Add sel field in the tctrl
ENDCASE.

Sudha

Former Member
0 Kudos

Hi Aviroop ,

Please find the sample code for the same:

Table control : TC1

Internal table : it_zsd00003

*In the attributes of the table control, select w/SelColumn to get a selection column on the table control, and give a name

(In this example IT_ZSD00003-LINESEL).

*Remember to include the field IT_ZSD00003-LINESEL in the internal table ( linesel(1) type c, ).

*When used with an internal table, remember to program

the update functionality of the database tables. Update and validation can be done when leaving the screen or in PAI using controlname- current_line (E.g. TC1-current_line ) to indentify the entry in the internal table.

<b>process before output.</b>

module status_0100.

loop at it_zsd00003 with control tc1 cursor tc1-

current_line.

module tc1_set_field_attr. "Optional

endloop.

module status_0100 output.

set pf-status 'SCREEN0100'.

  • OPTIONAL: If it_zsd00003 hasn't allready been filled with

  • data, you can do it the first time PBO is called

module read_data.

  • Setting the number of lines of the table control

describe table it_zsd00003 lines tc1-lines.

  • Optional: Place the cursor on line g_current_line e.g. after a

  • validation error has occured

if not ( g_current_line is initial ).

tc1-top_line = g_current_line.

clear g_current_line.

endif.

endmodule. " STATUS_0100 OUTPUT

module read_data.

if flag is initial.

perform read_data.

flag = 1.

endif.

endmodule.

module tc1_set_field_attr output.

  • Optional: Protect some of the columns on the

  • table control

loop at screen.

if screen-group1 = 'X'.

screen-input = 0.

modify screen.

endif.

endloop.

endif.

endmodule. " tc1_set_field_attr OUTPUT

<b>process after input.</b>

loop at it_zsd00003.

module modify_tc1.

endloop.

module user_command_0100.

module modify_tc1 input.

  • Modify an existing entry

modify it_zsd00003 index tc1-current_line.

  • OR

  • Appending a new entry

append it_zsd00003.

endmodule. " modify_tc1 INPUT

*Deleting a single line selected with the selection column:

form delete_record.

loop at it_zsd00003.

if it_zsd00003-linesel = 'X'.

exit.

endif.

endloop.

delete from zsd00003

where zdriftscenter = it_zsd00003-zdriftscenter

endform.

While <b>scrolling do remember </b> to put this code in PBO.

in PBO, code like this.

select the total number of records which u r outputting.

now.

TC1-LINES = SY-DBCNT (Where TC1 is ur control name)

I think this will suffice your need.

If you are satisfied , please close this thread by rewarding appropriate points to the helpful answers.

Cheers

Sunny

0 Kudos

Hi Aviroop,

As per the form etiquettes .

If satisfied,Please close this thread by rewarding appropraite points to the helpful answers .

Cheers

Sunny

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Check this link for sample code.Kindly reward points if it helps.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap-co... control in abap.pdf