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

About table control

Former Member
0 Likes
752

I am newbie in dialog program, i would like to know how to control the table control. In the screen which have a table control and two button which are add item and delete item, when i selected one anyone item in the table control and click add item button, it will copy selected item and paste it. If click del item, it will remove the item from table control. How to do that. Thanks!

6 REPLIES 6
Read only

Former Member
0 Likes
717

hi,

for delete u can do this...

write this in USER_COMMAND of PAI,

MODULE user_command_9000 INPUT.

CASE ok_code.

WHEN 'BACK' OR 'UP' OR 'CANCEL'.

LEAVE PROGRAM.

WHEN 'DIS'.

WRITE 'DEV'.

CALL SCREEN 9001 STARTING AT 10 10 ENDING AT 20 20.

WHEN 'DEL'.

GET CURSOR LINE lin_no.

f1 = 1.

WHEN ''.

f = 1.

ENDCASE.

ENDMODULE. " USER_COMMAND_9000 INPUT

and in the module of PBO, in which u fetching data

write like this,

MODULE get_data OUTPUT.

IF f1 <> 1.

SELECT kunnr name1

INTO CORRESPONDING FIELDS OF TABLE mytab

FROM kna1.

ENDIF.

IF f1 = 1.

DELETE mytab INDEX lin_no.

FREE lin_no.

FREE f1.

ENDIF.

ENDMODULE. " get_data OUTPUT

reward if useful...

Read only

Kanagaraja_L
Active Contributor
0 Likes
717
Read only

Former Member
0 Likes
717

Hi,

You can use the standard program RSDEMO02 to learn the various functionalities of Table Controls.

Regards,

Renjith Michael.

Read only

Former Member
0 Likes
717

Hi,

I also had a similar requirement in one of my projects.

First you will have to create a table control using a table control wizard or you can create in manually in the screen layout.

Then you can add your own fileds if required to the table control.This can be done by slecting a text field and placing it in the header of the table control.Give a name to it and save it.Now select an input/output field and place it in the table control just below the text field.Now give the name of the input/output field as <table_name>-<field_name>.This will automatically link the field to the field in the table.

Now coming to the push buttons add and delete,

To delete an item from the table control on clicking delete button,go to the PAI module of that screen and use this code:

Here,tb_line is the internal table associated with the table control.The statement if tb_line-mark = 'X'. will check which line in table control is selected.This line which is selected is moved into tb_line_del.

tb_line_del is now appended with the new line.

The row that was selected is deleted from tb_line will now be deleted.

Hence it will also be deleted from the table control.

Now suppose if you are using a Z table to store the values,then the deletd values should also be deleted from the Z table.For that we will use.

delete from ztm09_ekpo where ebeln eq tb_line_del-ebeln.

MODIFY ZTM09_EKPO.

The values are deleted from the Ztable by checking with the tb_line_del and then the table is modified to update the change.

The complete code is :

CASE SY-UCOMM.

when 'DELETE'.

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

loop at tb_line.

if tb_line-mark = 'X'.

move-corresponding tb_line to tb_line_del.

append tb_line_del.

delete tb_line.

delete from ztm09_ekpo where ebeln eq tb_line_del-ebeln.

MODIFY ZTM09_EKPO.

endif.

endloop.

Now to add a row to the table control when clicking on add button,

Here we are looping at the internal table tb_line.It is the internal table used for the table control.

We are checking if there are any values in the table control.If there are any values then we will insert the new row after the last row.

The code is:

CASE SY-UCOMM.

when 'ADD'.

***To insert or append an initial line into table control****

loop at tb_line.

if tb_line-mark = 'X'.

insert initial line into tb_line.

flag = '1'.

endif.

endloop.

if flag <> '1'.

append initial line to tb_line.

endif.

clear ok_code1.

Now to update the new entry in the Z table you will have to use the following code.

Here we are looping at the internal table used for the table control and moving the values into the Z table.

LOOP AT tb_line.

ztm09_ekpo-ebeln = ztm09_ekko-ebeln.

ztm09_ekpo-ebelp = tb_line-ebelp.

ztm09_ekpo-matnr = tb_line-matnr.

ztm09_ekpo-menge = tb_line-menge.

ztm09_ekpo-meins = tb_line-meins.

ztm09_ekpo-netpr = tb_line-netpr.

ztm09_ekpo-waers = tb_line-waers.

*****Update the entries into item table*****

MODIFY ztm09_ekpo.

ENDLOOP.

Reward if helpfull.

Thanks,

Kashyap

Edited by: Kashyap Ivaturi on Jan 11, 2008 10:43 AM

Read only

Former Member
0 Likes
717

Hi,

syntax:

CONTROLS .

if you only want to determine the row of the table control. SY´-SUBRC allows you to check if the cursor is placed in a row of a table control.

u need to comment the performs of table control fields and write ur own perform statements. And u have to declare the table control fields as separate internal tables.

Go through this urls.

www.saptechnical.com

www.sap-img.com

Check the below links.

just refer to the link below

http://www.sapmaterial.com/tablecontrol_sap.html

step by step procedure with screen shots

http://www.planetsap.com/howdo_a.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac5135c111d1829f0000e829fbfe/content.htm

http://sap.niraj.tripod.com/id25.html

Also you can see the below examples...

Go to se38 and give demodynpro and press F4.

YOu will get a list of demo module pool programs.

One more T-Code is ABAPDOCU.

YOu can find more examples there.

See the prgrams:

DEMO_DYNPRO_TABLE_CONTROL_1 Table Control with LOOP Statement

DEMO_DYNPRO_TABLE_CONTROL_2 Table Control with LOOP AT ITAB

http://www.geocities.com/ZSAPcHAT

http://www.allsaplinks.com/files/using_table_in_screen.pdf

Best Regards,

Rajesh.

Please reward points if found helpful.

Read only

Former Member
0 Likes
717

You can make use of a Table Control Wizard.

>1. Go to layout of a screen.

> 2. take element TABSTRIP with WIZARD.

> 3. continue

> 4. give name

> 5. than give tab text ( give different text as per need of tabs)

> 6. it will create subscreens automatically for that tabs... , continue

> 7. it will show list of includes..., continue

> 8. complete

>here in subscreen u can create all the elements as normal screen