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: 

Help on table control

Former Member
0 Kudos

Hi,

I cretaed my own Z table and i ve to insert new records as well update them when necessary..

now i ve a table control for that..so how i can insert and update my ztable with table control..?

In PBO and PAI. what should i mention in Loop at ........?

Normally it allows only Itab which contains Ztable data. But here itab is empty. since i am not populating itab from Ztable,

I need to populate the Ztable from Table ctrl datas.

Is there any parameter which holds the number of rows entered in table Ctrl?

help me in this regard.

3 REPLIES 3

Former Member
0 Kudos

Former Member
0 Kudos

Hi Ram Mohan,

Table controls indirectly relate to an internal table.

It is only form an internal table in a program that you access the table control.

And when displaying values in a table control, it will be done through an internal table from the program.

Even in the table control,the field names are given in the format <internal_table_name>-<field_name>.

If the value is being retrieved form a standard program,then the values need to be passed into the internal table and thus they would be displayed on the table control.

The format that you need to follow in the PBO and PAI of the screen of the table control is :

PROCESS BEFORE OUTPUT.

LOOP WITH <table_control_name>.

MODULE user_command_0100.

ENDLOOP.

PROCESS AFTER INPUT.

LOOP WITH CONTROL <table_control_name>.

module read_table_control.

ENDLOOP.

To handle table controls in ABAP programs, you must declare a control in the declaration part of the program for each table control using the following statement:

CONTROLS <ctrl> TYPE TABLEVIEW USING SCREEN <scr>.

where <ctrl> is the name of the table control on a screen in the ABAP program. The control allows the ABAP program to read the attributes of the table control and to influence the control. <scr> is the screen number where the initial values of the table are loaded.

To insert and update a ZTable using table control,these codes might help you .

Here ztm09_ekko,ztm09_eket are the Ztables.tb_schedule is the name of the internal table used for table control and tb_schedule_del is the internal table used to store the record that were deleted from the table control.These records which are deleted ar thus in tb_schedule_del.Now using this internal table we can delete the records from the ZTable by moving them in to the work area of the ZTable and deleting the work area as explained in the code below :

CASE SY-UCOMM.

WHEN 'DELETE'.

****To delete the seleceted line from table control****

LOOP AT tb_schedule.

IF tb_schedule-mark = 'X'.

MOVE-CORRESPONDING tb_schedule TO tb_schedule_del.

APPEND tb_schedule_del.

DELETE tb_schedule.

ENDIF.

ENDLOOP.

LOOP AT tb_schedule.

ztm09_eket-ebeln = ztm09_ekko-ebeln.

ztm09_eket-ebelp = tb_schedule-ebelp.

ztm09_eket-etenr = tb_schedule-etenr.

ztm09_eket-menge = tb_schedule-menge.

ztm09_eket-eindt = tb_schedule-eindt.

*****update the entries into schedule table*****

MODIFY ztm09_eket.

ENDLOOP.

LOOP AT tb_schedule_del.

ztm09_eket-ebeln = ztm09_ekko-ebeln.

ztm09_eket-ebelp = tb_schedule_del-ebelp.

ztm09_eket-etenr = tb_schedule_del-etenr.

ztm09_eket-menge = tb_schedule_del-menge.

ztm09_eket-eindt = tb_schedule_del-eindt.

****Delete the entries into schedule table***

Delete ztm09_eket.

ENDLOOP.

To find the number of rows entered in table control :

***To find out the number of lines in internal table****

DESCRIBE TABLE tb_schedule LINES s_lin.

tcl_schedule-lines = s_lin.

Please revert for any querries.

Reward points if helpfull.

Regards,

Kashyap

Former Member
0 Kudos

hi Ram mohan,

refer to this for a sample code of dialog program we uses ztable to insert data using screens.it may be helpful

regards,

sravanthi