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

Regarding Table Control - Need a code to delete , select a row frm IT

Former Member
0 Likes
2,447

Hi All,

I have a table control displayed on screen with fields from MEPO1211. The table control contains one fields for row wise selection of data i.e TCSELFLAG field of MEPO1211.

Now the problem is i don't know how to capture the selected row and perform deletion from internal table based on selected row and display the updated internal table and also it would be helpful for me if you can provide the code to capture the row selected from internal table.

Regards,

Parag Gavkar.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,829

hi,

do u want to delete one by one or select many record and delete them at once?

Hi All,

I have a table control displayed on screen with fields from MEPO1211. The table control contains one fields for row wise selection of data i.e TCSELFLAG field of MEPO1211.

Now the problem is i don't know how to capture the selected row and perform deletion from internal table based on selected row and display the updated internal table and also it would be helpful for me if you can provide the code to capture the row selected from internal table.

Regards,

Parag Gavkar.

11 REPLIES 11
Read only

Former Member
0 Likes
1,829

In screen painter, Give one value/name in table control attribute in field w/selection.

after that write code in input event.

ex:

&----


*& Module DEL_REC INPUT

&----


  • text

----


MODULE DEL_REC INPUT.

data: txt(50) type c,

ans(1).

OK_CODE = SY-UCOMM.

S_CODE = OK_CODE.

CLEAR OK_CODE.

*Check if the record is selected and Delete but is used then delete the

*record

*SL is name given in Table Attricbue w/Selection col field.

IF SL = 'X' AND S_CODE = 'DEL'.

CLEAR G_IDX.

DELETE TABLE G_TC1_ITAB FROM G_TC1_WA.

IF SY-SUBRC = 0.

DELETE FROM ZBRCODE_TEMP WHERE ZSRNO = G_TC1_WA-ZSRNO.

DESCRIBE TABLE G_TC1_ITAB LINES TC1-LINES.

ENDIF.

clear: SL, ans, S_CODE.

ENDIF.

ENDMODULE. " DEL_REC INPUT

Read only

Former Member
0 Likes
1,829

Hi Parag Gavkar,

There is no matter to capture the selected filed it is quite simple do the following things

  • Take a char type field in the internal table (Length is 1)

  • When you create your table control ( In SE51 ) give that field as selection file ( It will fill as X when you select the row

  • Now write a module for delete in the PAI of your code by double clicking on the in your program write the following code.

Example code in your program (SE38)

Module delete input.

loop at it_table where it_table-selfield = 'X'. ( First field in your internal table i.e is char 1 field )

delete it_table index sy-tabix..

endloop.

End module.

Note : When you delete the record in your internal table automatically it will be deleted in the table control also

Regards.

Mahi.

Read only

Former Member
0 Likes
1,830

hi,

do u want to delete one by one or select many record and delete them at once?

Read only

0 Likes
1,829

Hi,

If you can provide the sample code for the same , it would be great.

Regards,

Parag

Read only

0 Likes
1,829

hi,

i have code to delete rows but one at a time means u cant select more than one and delete them togather but u can select one and press delete button then again same....

will it work?

Read only

0 Likes
1,829

Hi,

Could u pls send ur code ??

I can check it out to suits my requrements.

Regards;

Parag

Read only

0 Likes
1,829

hi,

ya try like this

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

here my delete button name in DEL...

now u would have some module in PBO in which u fetching data from data base....

write this in that module...

MODULE get_data OUTPUT.

IF f1 <> 1.

SELECT kunnr name1

INTO CORRESPONDING FIELDS OF TABLE mytab

FROM kna1.

ENDIF.

IF f1 = 1.

IF lin_no IS NOT INITIAL.

DELETE mytab INDEX lin_no.

FREE lin_no.

FREE f1.

ENDIF.

ENDIF.

ENDMODULE. " get_data OUTPUT

reward me back if not getting

Read only

Former Member
0 Likes
1,829

hi,

do u have first column for line selection?

and do u want code for selecting more rows and delete them at once?

Read only

0 Likes
1,829

hi,

do like this

In PAI make one module....

PROCESS AFTER INPUT.

*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TAB1'

LOOP AT itab.

CHAIN.

FIELD itab-matnr.

FIELD itab-matkl.

FIELD itab-mark.

MODULE TAB1_MODIFY ON CHAIN-REQUEST.

ENDCHAIN.

ENDLOOP.

here itab-mark is my field for line selection....

MODULE tab1_modify INPUT.

IF sy-ucomm = 'DEL' AND itab-mark = 'X'.

MODIFY itab INDEX tab1-current_line TRANSPORTING mark.

ENDIF.

ENDMODULE. " TAB1_MODIFY INPUT

MODULE user_command_1000 INPUT.

CASE sy-ucomm.

WHEN 'BACK' OR 'UP' OR 'CANC'.

LEAVE PROGRAM.

WHEN 'FND'.

CALL SCREEN 1001 STARTING AT 37 5 ENDING AT 87 22.

WHEN 'DEL'.

DELETE itab where mark = 'X'. ENDCASE.

ENDMODULE. " user_command_1000 INPUT

And in module of PBO in which u fetching data from database.....

write this

MODULE fetch_data OUTPUT.

IF sy-ucomm <> 'DEL'.

SELECT matnr matkl INTO CORRESPONDING FIELDS OF TABLE itab

FROM mara

WHERE matnr BETWEEN '000000000000000101' AND '000000000000000115'.

ENDIF.

ENDMODULE. " fetch_data OUTPUT

reward if usefull...

Read only

0 Likes
1,829

Hi,

Yes, I want to delete more than one row at a time .

Regards,

Parag

Read only

0 Likes
1,829

ya

just look at my previous thread....

There is answer in it...