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

Former Member
0 Likes
818

hai,

i dont know how to delete,insert the records using table control wizards.pls tell me the solution as soon as possible.

with regards ,

R.dhinesh raj.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
799

hi,

Refer to the link.

http://www.sap-img.com/ab031.htm

Regards

Sumit Agarwal

7 REPLIES 7
Read only

Former Member
0 Likes
799

HI raj,

This link have a step-by-step information on using table control wizard:-

http://help.sap.com/saphelp_nw04/helpdata/en/6d/150d67da1011d3963800a0c94260a5/content.htm

Best of luck,

Bhumika

Read only

Former Member
0 Likes
800

hi,

Refer to the link.

http://www.sap-img.com/ab031.htm

Regards

Sumit Agarwal

Read only

Former Member
0 Likes
799

HI ,

i am here pasting the whole table control code .....which hav many more functinality ...which you want ....so please check the Code ..

TABLE CONTROL

&----


*& Module Pool SAPMZTAB1

*&

&----


*&

*&

&----


include mztab1top . " global Data

include mztab1o01 . " PBO-Modules

include mztab1i01 . " PAI-Modules

include mztab1f01 . " FORM-Routines

&----


*& Include MZTAB1TOP Module Pool SAPMZTAB1

*&

&----


program sapmztab1.

tables: mara.

data: ok_code type sy-ucomm,

ln type i,

flag. " TO SET CHANGE MODE

controls: tab1 type tableview using screen '0100'.

data: begin of it_mara occurs 0,

sel,

matnr type mara-matnr,

mbrsh type mara-mbrsh,

mtart type mara-mtart,

  • KZSEL type mara- KZSEL,

maktx type makt-maktx,

meins type mara-meins,

end of it_mara.

data: begin of it_mara_del occurs 0,

sel,

matnr type mara-matnr,

mbrsh type mara-mbrsh,

mtart type mara-mtart,

  • KZSEL type mara- KZSEL,

maktx type makt-maktx,

meins type mara-meins,

end of it_mara_del.

*data: cnt1 type i value 0, cnt2 type i value 0,

  • cnt3 type i value 0.

data : limit type i.

data : lines type i value 14 .

data: cols like line of tab1-cols.

data : flag1 type i value 0.

data : sel.

&----


*& Include MZTAB1O01

&----


&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


module status_0100 output.

set pf-status 'Z_PF'.

set titlebar 'Z_TITLE'.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module get_data OUTPUT

&----


  • text

----


module get_data output.

if flag1 = 0.

select * from mara into corresponding fields of table it_mara.

endif.

describe table it_mara lines ln.

  • To make the vertical scroll bar to come on runtime

tab1-lines = ln + 50.

endmodule. " get_data OUTPUT

&----


*& Include MZTAB1I01

&----


&----


*& Module exit_input INPUT

&----


  • text

----


module exit_input input.

case ok_code.

when 'BACK' or 'EXIT' or 'CANC'.

clear ok_code.

set screen 0.

endcase.

endmodule. " exit_input INPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module user_command_0100 input.

case ok_code.

when 'BDC'.

call transaction 'ZABC'.

  • LEAVE TO TRANSACTION 'ZVR02'.

submit sapmztab1.

when 'SORT_UP'.

clear ok_code.

read table tab1-cols into cols with key selected = 'X'.

if sy-subrc = 0.

sort it_mara stable by (cols-screen-name+8) ascending .

cols-selected = ' '.

modify tab1-cols from cols index sy-tabix.

endif.

when 'SORT_DOWN'.

clear ok_code.

read table tab1-cols into cols with key selected = 'X'.

if sy-subrc = 0.

sort it_mara stable by (cols-screen-name+8) descending.

cols-selected = ' '.

modify tab1-cols from cols index sy-tabix.

endif.

when 'PREPAGE'.

clear ok_code.

tab1-top_line = tab1-top_line - lines.

if tab1-top_line <= lines.

tab1-top_line = 0.

endif.

when 'FIRSTPAGE'.

clear ok_code.

tab1-top_line = 0.

when 'LASTPAGE'.

clear ok_code.

tab1-top_line = tab1-lines - lines + 1.

when 'NEXTPAGE'.

*

  • CLEAR ok_code.

*

  • limit = tab1-lines - lines + 1 .

*

  • IF tab1-top_line <= limit.

*

  • tab1-top_line = tab1-top_line + lines.

clear ok_code.

tab1-top_line = tab1-top_line + lines.

limit = tab1-lines - lines + 1.

if tab1-top_line > limit.

tab1-top_line = limit.

endif.

  • TAB1-TOP_LINE = tab1-top_line.

when 'FSAVE'.

clear ok_code.

when 'ALL'.

clear ok_code.

loop at it_mara.

sel = 'X'.

it_mara-sel = sel.

modify it_mara .

clear it_mara.

endloop.

when 'DESL'.

clear ok_code.

loop at it_mara.

sel = ' '.

it_mara-sel = sel.

modify it_mara.

clear it_mara.

endloop.

when 'FNEXT'.

clear ok_code.

tab1-top_line = tab1-top_line + 1.

limit = tab1-lines - lines + 1.

if tab1-top_line > limit.

tab1-top_line = limit.

endif.

when 'FPRE'.

clear ok_code.

tab1-top_line = tab1-top_line - 1.

if tab1-top_line < 0.

tab1-top_line = 0.

endif.

when 'FDEL'.

loop at it_mara .

delete it_mara where sel = 'X'.

endloop.

endcase.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Module save_data INPUT

&----


  • text

----


module save_data input.

if tab1-current_line gt ln.

read table it_mara with key matnr = it_mara-matnr.

if sy-subrc ne 0.

append it_mara.

endif.

endif.

flag1 = 1.

it_mara-sel = sel.

modify it_mara index tab1-current_line .

endmodule. " save_data INPUT

Regards

Priyank Dixit

Read only

Former Member
0 Likes
799

Hi,

Here is the sample code just take help from this...

include mztab1top . " global Data

include mztab1o01 . " PBO-Modules

include mztab1i01 . " PAI-Modules

include mztab1f01 . " FORM-Routines

&----


*& Include MZTAB1TOP Module Pool SAPMZTAB1

*&

&----


program sapmztab1.

tables: mara.

data: ok_code type sy-ucomm,

ln type i,

flag. " TO SET CHANGE MODE

controls: tab1 type tableview using screen '0100'.

data: begin of it_mara occurs 0,

sel,

matnr type mara-matnr,

mbrsh type mara-mbrsh,

mtart type mara-mtart,

  • KZSEL type mara- KZSEL,

maktx type makt-maktx,

meins type mara-meins,

end of it_mara.

data: begin of it_mara_del occurs 0,

sel,

matnr type mara-matnr,

mbrsh type mara-mbrsh,

mtart type mara-mtart,

  • KZSEL type mara- KZSEL,

maktx type makt-maktx,

meins type mara-meins,

end of it_mara_del.

*data: cnt1 type i value 0, cnt2 type i value 0,

  • cnt3 type i value 0.

data : limit type i.

data : lines type i value 14 .

data: cols like line of tab1-cols.

data : flag1 type i value 0.

data : sel.

&----


*& Include MZTAB1O01

&----


&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


module status_0100 output.

set pf-status 'Z_PF'.

set titlebar 'Z_TITLE'.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module get_data OUTPUT

&----


  • text

----


module get_data output.

if flag1 = 0.

select * from mara into corresponding fields of table it_mara.

endif.

describe table it_mara lines ln.

  • To make the vertical scroll bar to come on runtime

tab1-lines = ln + 50.

endmodule. " get_data OUTPUT

&----


*& Include MZTAB1I01

&----


&----


*& Module exit_input INPUT

&----


  • text

----


module exit_input input.

case ok_code.

when 'BACK' or 'EXIT' or 'CANC'.

clear ok_code.

set screen 0.

endcase.

endmodule. " exit_input INPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module user_command_0100 input.

case ok_code.

when 'BDC'.

call transaction 'ZABC'.

  • LEAVE TO TRANSACTION 'ZVR02'.

submit sapmztab1.

when 'SORT_UP'.

clear ok_code.

read table tab1-cols into cols with key selected = 'X'.

if sy-subrc = 0.

sort it_mara stable by (cols-screen-name+8) ascending .

cols-selected = ' '.

modify tab1-cols from cols index sy-tabix.

endif.

when 'SORT_DOWN'.

clear ok_code.

read table tab1-cols into cols with key selected = 'X'.

if sy-subrc = 0.

sort it_mara stable by (cols-screen-name+8) descending.

cols-selected = ' '.

modify tab1-cols from cols index sy-tabix.

endif.

when 'PREPAGE'.

clear ok_code.

tab1-top_line = tab1-top_line - lines.

if tab1-top_line <= lines.

tab1-top_line = 0.

endif.

when 'FIRSTPAGE'.

clear ok_code.

tab1-top_line = 0.

when 'LASTPAGE'.

clear ok_code.

tab1-top_line = tab1-lines - lines + 1.

when 'NEXTPAGE'.

*

  • CLEAR ok_code.

*

  • limit = tab1-lines - lines + 1 .

*

  • IF tab1-top_line <= limit.

*

  • tab1-top_line = tab1-top_line + lines.

clear ok_code.

tab1-top_line = tab1-top_line + lines.

limit = tab1-lines - lines + 1.

if tab1-top_line > limit.

tab1-top_line = limit.

endif.

  • TAB1-TOP_LINE = tab1-top_line.

when 'FSAVE'.

clear ok_code.

when 'ALL'.

clear ok_code.

loop at it_mara.

sel = 'X'.

it_mara-sel = sel.

modify it_mara .

clear it_mara.

endloop.

when 'DESL'.

clear ok_code.

loop at it_mara.

sel = ' '.

it_mara-sel = sel.

modify it_mara.

clear it_mara.

endloop.

when 'FNEXT'.

clear ok_code.

tab1-top_line = tab1-top_line + 1.

limit = tab1-lines - lines + 1.

if tab1-top_line > limit.

tab1-top_line = limit.

endif.

when 'FPRE'.

clear ok_code.

tab1-top_line = tab1-top_line - 1.

if tab1-top_line < 0.

tab1-top_line = 0.

endif.

when 'FDEL'.

loop at it_mara .

delete it_mara where sel = 'X'.

endloop.

endcase.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Module save_data INPUT

&----


  • text

----


module save_data input.

if tab1-current_line gt ln.

read table it_mara with key matnr = it_mara-matnr.

if sy-subrc ne 0.

append it_mara.

endif.

endif.

flag1 = 1.

it_mara-sel = sel.

modify it_mara index tab1-current_line .

endmodule. " save_data INPUT

Read only

Former Member
0 Likes
799

Hi,

Here is the sample code... just go through this..

&----


*& Module Pool SAPMZTAB1

*&

&----


*&

*&

&----


include mztab1top . " global Data

include mztab1o01 . " PBO-Modules

include mztab1i01 . " PAI-Modules

include mztab1f01 . " FORM-Routines

&----


*& Include MZTAB1TOP Module Pool SAPMZTAB1

*&

&----


program sapmztab1.

tables: mara.

data: ok_code type sy-ucomm,

ln type i,

flag. " TO SET CHANGE MODE

controls: tab1 type tableview using screen '0100'.

data: begin of it_mara occurs 0,

sel,

matnr type mara-matnr,

mbrsh type mara-mbrsh,

mtart type mara-mtart,

  • KZSEL type mara- KZSEL,

maktx type makt-maktx,

meins type mara-meins,

end of it_mara.

data: begin of it_mara_del occurs 0,

sel,

matnr type mara-matnr,

mbrsh type mara-mbrsh,

mtart type mara-mtart,

  • KZSEL type mara- KZSEL,

maktx type makt-maktx,

meins type mara-meins,

end of it_mara_del.

*data: cnt1 type i value 0, cnt2 type i value 0,

  • cnt3 type i value 0.

data : limit type i.

data : lines type i value 14 .

data: cols like line of tab1-cols.

data : flag1 type i value 0.

data : sel.

&----


*& Include MZTAB1O01

&----


&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


module status_0100 output.

set pf-status 'Z_PF'.

set titlebar 'Z_TITLE'.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module get_data OUTPUT

&----


  • text

----


module get_data output.

if flag1 = 0.

select * from mara into corresponding fields of table it_mara.

endif.

describe table it_mara lines ln.

  • To make the vertical scroll bar to come on runtime

tab1-lines = ln + 50.

endmodule. " get_data OUTPUT

&----


*& Include MZTAB1I01

&----


&----


*& Module exit_input INPUT

&----


  • text

----


module exit_input input.

case ok_code.

when 'BACK' or 'EXIT' or 'CANC'.

clear ok_code.

set screen 0.

endcase.

endmodule. " exit_input INPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module user_command_0100 input.

case ok_code.

when 'BDC'.

call transaction 'ZABC'.

  • LEAVE TO TRANSACTION 'ZVR02'.

submit sapmztab1.

when 'SORT_UP'.

clear ok_code.

read table tab1-cols into cols with key selected = 'X'.

if sy-subrc = 0.

sort it_mara stable by (cols-screen-name+8) ascending .

cols-selected = ' '.

modify tab1-cols from cols index sy-tabix.

endif.

when 'SORT_DOWN'.

clear ok_code.

read table tab1-cols into cols with key selected = 'X'.

if sy-subrc = 0.

sort it_mara stable by (cols-screen-name+8) descending.

cols-selected = ' '.

modify tab1-cols from cols index sy-tabix.

endif.

when 'PREPAGE'.

clear ok_code.

tab1-top_line = tab1-top_line - lines.

if tab1-top_line <= lines.

tab1-top_line = 0.

endif.

when 'FIRSTPAGE'.

clear ok_code.

tab1-top_line = 0.

when 'LASTPAGE'.

clear ok_code.

tab1-top_line = tab1-lines - lines + 1.

when 'NEXTPAGE'.

*

  • CLEAR ok_code.

*

  • limit = tab1-lines - lines + 1 .

*

  • IF tab1-top_line <= limit.

*

  • tab1-top_line = tab1-top_line + lines.

clear ok_code.

tab1-top_line = tab1-top_line + lines.

limit = tab1-lines - lines + 1.

if tab1-top_line > limit.

tab1-top_line = limit.

endif.

  • TAB1-TOP_LINE = tab1-top_line.

when 'FSAVE'.

clear ok_code.

when 'ALL'.

clear ok_code.

loop at it_mara.

sel = 'X'.

it_mara-sel = sel.

modify it_mara .

clear it_mara.

endloop.

when 'DESL'.

clear ok_code.

loop at it_mara.

sel = ' '.

it_mara-sel = sel.

modify it_mara.

clear it_mara.

endloop.

when 'FNEXT'.

clear ok_code.

tab1-top_line = tab1-top_line + 1.

limit = tab1-lines - lines + 1.

if tab1-top_line > limit.

tab1-top_line = limit.

endif.

when 'FPRE'.

clear ok_code.

tab1-top_line = tab1-top_line - 1.

if tab1-top_line < 0.

tab1-top_line = 0.

endif.

when 'FDEL'.

loop at it_mara .

delete it_mara where sel = 'X'.

endloop.

endcase.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Module save_data INPUT

&----


  • text

----


module save_data input.

if tab1-current_line gt ln.

read table it_mara with key matnr = it_mara-matnr.

if sy-subrc ne 0.

append it_mara.

endif.

endif.

flag1 = 1.

it_mara-sel = sel.

modify it_mara index tab1-current_line .

endmodule. " save_data INPUT

Thanks & Regards

Ashu Singh