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

Table Control

Former Member
0 Likes
761

Hello all,

Am working on SAP R/3 4.6C. Am trying to work out with the table control in Dialog Programming. Can anybody give me an idea on how i can work manually with this control. Say for example i have to add rows, delete rows, select all, deselect all from table control using code. Then the entries added should also be entered in my standard table.

Thanks a lot.

1 ACCEPTED SOLUTION
Read only

Former Member
7 REPLIES 7
Read only

Former Member
Read only

Former Member
0 Likes
691

Hello Wojciech. Thanks Dear. But i have already gone to that part of the documentation and it only talks about the things such as deleting and reading to an table control from an internal table. The problem am facing is to add rows and delete rows into table control dynamically. The link only gives me a start but am stuck for further answers.

Thank you.

Read only

0 Likes
691

Hi,

Isn't it better in this case to go for ALV?

/wg

Read only

Former Member
0 Likes
691

The requirement is to go for a table control.

Read only

0 Likes
691

>

> The requirement is to go for a table control.

so you need to play around with the table controls:

from SAP course:

"If you want to change the attributes of the columns in a table control, you must change the respective

entries in the <control>-cols table. Note that the table has no header lines. This means that

you have to create an explicit work area."

/wg

Read only

Former Member
0 Likes
691

ABAP Code Sample for Table Controls

Code samples are intended for educational use only, not deployment. They are untested and unsupported by SAP. SAP disclaims all liability to any person in respect to any damage that is incurred, whether wholly or partially, from use of the code.

Applies To:

ABAP

Summary

This code sample illustrates how to use table controls to display records from database tables, modify the records, and insert new records to database tables via table control. It is simple and easy to understand for all levels of ABAP programmers. It illustrates the basics involved in using table control.

By: Kavitha Bhuvaneswaran

Company: Wipro Technologies

Date: 7 Feb 2005

Code


program z_k_table1 .

*tables declaration

tables : zemploykk.

*data declaration

data : ok_code type sy-ucomm.	
data : v_lines type i.
data : i_final type table of zemploykk.

*for using table control

controls : tabcont type tableview using screen '3000'.

*for pbo event in screen programming

include z_k_table1_pbo.

*for pai event in screen programming

include z_k_table1_pai.


INCLUDE PROGRAM FOR PBO


*----------------------------------------------------------------------*
*   INCLUDE Z_K_TABLE1_PBO                                             *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  STATUS_3000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_3000 output.
  set pf-status 'DEMO'.
  set titlebar 'TABLE1'.
  describe table i_final lines tabcont-lines.

endmodule.                 " STATUS_3000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  output  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
               " output  OUTPUT


INCLUDE PROGRAM FOR PAI
*----------------------------------------------------------------------*
*   INCLUDE Z_K_TABLE1_PAI                                             *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_3000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_3000 input.
  case ok_code.
    when 'DISPLAY'.

      if i_final is initial.
        select * from zemploykk into table i_final.
      endif.
    when 'BACK'.
      leave to screen '0'.
    when 'CLEAR'.
      clear i_final.
    when 'MODIFY'.
      update  zemploykk  from table i_final.
      clear i_final.
    when 'INSERT'.
       insert zemploykk from table i_final.
       clear i_final.
  endcase.

endmodule.                 " USER_COMMAND_3000  INPUT
*&---------------------------------------------------------------------*
*&      Module  update_tab_control1  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module update_tab_control1 input.
  describe table i_final lines v_lines.
  if v_lines < tabcont-current_line.
    append zemploykk to i_final.
  else.
    modify i_final from zemploykk index tabcont-current_line.
  endif.
endmodule.                 " update_tab_control1  INPUT


Screen Design
 

Flow Logic
process before output.

  module status_3000.

  loop at i_final into zemploykk with control tabcont.
  endloop.

process after input.
  loop at i_final.

    module update_tab_control1.

endloop.	

module user_command_3000.

Output

When the user enters the transaction code associated for this module pool program , we get the below screen.

when the user clicks display button, the table contents are displayed.

Clear button clears the screen.

When the user enters a new record after clearing the contents and presses insert button , the record gets inserted.

When the user makes modifications to existing records and clicks modify button , modifications get updated.

Disclaimer & Liability Notice

This document may discuss sample coding, which does not include official interfaces and therefore is not supported. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing of the code and methods suggested here, and anyone using these methods, is doing it under his/her own responsibility.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of the technical article, including any liability resulting from incompatibility between the content of the technical article and the materials and services offered by SAP. You agree that you will not hold SAP responsible or liable with respect to the content of the Technical Article or seek to do so.

Copyright © 2004 SAP AG, Inc. All Rights Reserved. SAP, mySAP, mySAP.com, xApps, xApp, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product, service names, trademarks and registered trademarks mentioned are the trademarks of their respective owners.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Feb 21, 2008 10:40 AM

Read only

Former Member
0 Likes
691

Hello.

The code example shows how I will add entries into my z standard table from a control table.

My requirment is that a add button will add a blank row dynamically to the control table. then user will enter the values in the row. On a create button this entry by user will then be added to database (after all updations) and the row from the control table will also get cleared and then again it will wait for user entry.