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
835

Hi all,

I have created a table control with five coloum. Now i want to want to insert record, validate record, change record and delete record.

Please can any one help me on that. Where to insert code for validation. does any body have an example or dummy program.

Thanx in adv

9 REPLIES 9
Read only

Former Member
0 Likes
794

See these demo examples in se38

DEMO_DYNPRO_TABLE_CONTROL_1

DEMO_DYNPRO_TABLE_CONTROL_2

Read only

andreas_mann3
Active Contributor
0 Likes
794

hi,

or analyse if you can solve your problem with maint. view

(transactions se11 / se54)

regards Andreas

Read only

0 Likes
794

hi,

Check this out

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

Hope this Helps..

Regards,

Santosh

Read only

Former Member
0 Likes
794
Read only

Former Member
0 Likes
794

Hi Sanjay,

1. In order to perform the operations of changing data etc, you need to have a field named 'mark' (which is a single character field) in the db table with which you perform operations.

2. The line selction option of the TC needs to be selected. Theres a checkbox for that.

3. For inserting records into db from TC, in the PAI event, move records into a workarea and modify db table from this work area. Perform any validations here

4. For deleting records - Here, I display all records in the TC and allow user to select whcih record he wants to delete by selecting the particular line. For this, in the PAI event, check which reocrds have mark set to 'x'. These records are the ones that have been selected for deletion.(This is one of the reasons why the line selection option needs to be set)



loop at itab into wa where mark = 'X'.
        move itab to wa.
        delete zak_presc from wa.
        delete itab.
       endloop.

Regards,

Aniket

Read only

Former Member
0 Likes
794

hi,

check the demo program <b>RSDEMO02</b>

Regards

vijay

Read only

0 Likes
794

Hi Sanjay,

Just check this link.This will explain how you can add, delete records in table control

http://www.esnips.com/doc/48bd95e8-facc-4932-b923-465ba59bad24/Table-Control.pdf

Regards,

SP.

Read only

Former Member
0 Likes
794

Hi,

I am giving the example program which I did recently.plz try with this code.

Thanks,

suma.

Read only

Former Member
0 Likes
794

report ztransactionsv7 message-id zz.

tables: knbk,mara.

data: v_tabix type sy-tabix.

ranges: r_kunnr for kna1-kunnr,r_matnr for mara-matnr.

data: v_ucomm type sy-ucomm,

v_dynnr type sy-dynnr,

v_table(5) type c,

sel type c.

data: begin of itab occurs 0,

ernam like mara-ernam,

aenam like mara-aenam,

matkl like mara-matkl,

sel type c,

end of itab.

data:begin of itab1 occurs 0,

banks like knbk-banks,

bankl like knbk-bankl,

bankn like knbk-bankn,

sel type c,

end of itab1.

controls: tc1 type tableview using screen 0300.

controls: tc2 type tableview using screen 0400.

&----


*& Module m_validation INPUT

&----


  • text

----


module m_validation input.

if ( mara-matnr is initial ) and ( knbk-kunnr is initial ).

message e000(zz) with 'please enter any one'.

elseif ( mara-matnr is initial ) and ( not knbk-kunnr is initial ).

select single kunnr from kna1 into knbk-kunnr where kunnr = knbk-kunnr.

if sy-subrc <> 0.

message e000(zz) with 'invalid field entry ' .

elseif sy-subrc = 0.

message w000(zz) with 'Dont enter in Material number field' .

endif.

elseif ( not mara-matnr is initial ) and ( knbk-kunnr is initial ).

select single matnr from mara into mara-matnr where matnr = mara-matnr.

if sy-subrc <> 0.

message e000(zz) with 'invalid field entry mara-matnr ' .

elseif sy-subrc = 0.

message w000(zz) with 'Dont enter in customer number field' .

endif.

elseif ( not mara-matnr is initial ) and ( not knbk-kunnr is initial ).

message e000(zz) with 'only one field has to enter' .

endif.

endmodule. " m_validation INPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module user_command_0100 input.

move sy-ucomm to v_ucomm.

if not mara-matnr is initial.

v_dynnr = 0300.

v_table = 'itab'.

select ernam aenam matkl from mara into corresponding fields of table

itab where matnr = mara-matnr.

else.

v_dynnr = 0400.

v_table = 'itab1'.

select banks bankl bankn from knbk into corresponding fields of table

itab1 where kunnr = knbk-kunnr.

endif.

leave to screen 0200.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Module STATUS_0200 OUTPUT

&----


  • text

----


module status_0200 output.

set pf-status 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

endmodule. " STATUS_0200 OUTPUT

&----


*& Module mb1_300 OUTPUT

&----


  • text

----


module mb1_300 output.

read table itab index tc1-current_line.

if sy-subrc = 0.

mara-ernam = itab-ernam.

mara-aenam = itab-aenam.

mara-matkl = itab-matkl.

endif.

endmodule. " mb1_300 OUTPUT

&----


*& Module mb1_200 OUTPUT

&----


  • text

----


module mb1_200 output.

if v_ucomm = 'DISPLAY'.

if sy-ucomm <> 'INSERT'.

loop at screen.

if screen-group1 = 'G2'.

screen-input = 0.

endif.

modify screen.

endloop.

endif.

endif.

if v_ucomm = 'CHANGE'.

if sy-ucomm <> 'INSERT'.

loop at screen.

if screen-group1 = 'G2'.

screen-input = 1.

endif.

modify screen.

endloop.

endif.

endif.

endmodule. " mb1_200 OUTPUT

&----


*& Module mb2_300 OUTPUT

&----


  • text

----


module mb2_300 output.

case v_ucomm.

when 'DISPLAY'.

if sy-ucomm <> 'INSERT'.

loop at screen.

if screen-group1 = 'G3' or screen-group1 = 'G1' .

screen-input = 0.

endif.

modify screen.

endloop.

endif.

when 'CHANGE'.

if sy-ucomm <> 'INSERT'.

loop at screen.

if screen-group1 = 'G1'.

screen-input = 0.

else.

screen-input = 1.

endif.

modify screen.

endloop.

endif.

endcase.

endmodule. " mb2_300 OUTPUT

&----


*& Module mb2_400 OUTPUT

&----


  • text

----


module mb2_400 output.

case v_ucomm.

when 'DISPLAY'.

if sy-ucomm <> 'INSERT'.

loop at screen.

if screen-group1 = 'G3' or screen-group1 = 'G1' .

screen-input = 0.

endif.

modify screen.

endloop.

endif.

when 'CHANGE'.

if sy-ucomm <> 'INSERT'.

loop at screen.

if screen-group1 = 'G1'.

screen-input = 0.

endif.

if screen-group1 = 'G3'.

screen-input = 1.

endif.

modify screen.

endloop.

endif.

endcase.

endmodule. " mb2_400 OUTPUT

&----


*& Module mb1_400 OUTPUT

&----


  • text

----


module mb1_400 output.

read table itab1 index tc2-current_line.

if sy-subrc = 0.

knbk-banks = itab1-banks.

knbk-bankl = itab1-bankl.

knbk-bankn = itab1-bankn.

endif.

endmodule. " mb1_400 OUTPUT

&----


*& Module ma1_400 INPUT

&----


  • text

----


module ma1_400 input.

if sel = 'X'.

itab1-sel = sel.

itab1-banks = knbk-banks.

itab1-bankl = knbk-bankl.

itab1-bankn = knbk-bankn.

modify itab1 index tc2-current_line.

endif.

endmodule. " ma1_400 INPUT

&----


*& Module ma1_300 INPUT

&----


  • text

----


module ma1_300 input.

if sel = 'X'.

itab-sel = sel.

itab-ernam = mara-ernam.

itab-aenam = mara-ernam.

itab-matkl = mara-matkl.

modify itab index tc1-current_line.

endif.

endmodule. " ma1_300 INPUT

&----


*& Module ma1_200 INPUT

&----


  • text

----


module ma1_200 input.

case sy-ucomm.

when 'BACK'.

leave to screen 0100.

when 'DELETE'.

if v_dynnr = 300.

delete itab where sel = 'X'.

describe table itab lines tc1-lines.

elseif v_dynnr = 400.

delete itab1 where sel = 'X'.

describe table itab1 lines tc2-lines.

endif.

when 'SAVE'.

if v_dynnr = 300.

describe table itab lines tc1-lines.

else.

describe table itab1 lines tc2-lines.

endif.

when 'REPORT'.

if v_dynnr = 300.

refresh r_matnr.

r_matnr-low = mara-matnr.

r_matnr-sign = 'I'.

r_matnr-option = 'EQ'.

append r_matnr.

submit zswareport1 with s_matnr in r_matnr and return.

else.

refresh r_kunnr.

r_kunnr-low = knbk-kunnr.

r_kunnr-sign = 'I'.

r_kunnr-option = 'EQ'.

append r_kunnr.

submit zswareport1 with s_kunnr in r_kunnr and return.

endif.

when 'INSERT'.

if v_dynnr = 300.

loop at itab.

v_tabix = sy-tabix + 1.

if itab-sel = 'X'.

clear itab.

insert itab index v_tabix.

endif.

endloop.

describe table itab lines tc1-lines.

else.

loop at itab1.

v_tabix = sy-tabix + 1.

if itab1-sel = 'X'.

clear itab1.

insert itab1 index v_tabix.

endif.

endloop.

describe table itab1 lines tc2-lines.

endif.

endcase.

endmodule. " ma1_200 INPUT

&----


*& Module mb0_300 OUTPUT

&----


  • text

----


module mb0_300 output.

if sy-ucomm = 'INSERT'.

if v_ucomm = 'DISPLAY'.

loop at screen.

if itab is initial.

screen-input = 1.

else.

if screen-group1 = 'G1' or screen-input = 'G3' .

screen-input = 0.

else.

screen-input = 1.

endif.

endif.

modify screen.

endloop.

elseif v_ucomm = 'CHANGE'.

loop at screen.

if itab is initial.

screen-input = 1.

else.

if screen-group1 = 'G1'.

screen-input = 0.

else.

screen-input = 1.

endif.

endif.

modify screen.

endloop.

endif.

endif.

endmodule. " mb0_300 OUTPUT

&----


*& Module mb0_400 OUTPUT

&----


  • text

----


module mb0_400 output.

if sy-ucomm = 'INSERT'.

if v_ucomm = 'DISPLAY'.

loop at screen.

if itab1 is initial.

screen-input = 1.

else.

if screen-group1 = 'G1' or screen-input = 'G3' .

screen-input = 0.

else.

screen-input = 1.

endif.

endif.

modify screen.

endloop.

elseif v_ucomm = 'CHANGE'.

loop at screen.

if itab1 is initial.

screen-input = 1.

else.

if screen-group1 = 'G1'.

screen-input = 0.

else.

screen-input = 1.

endif.

endif.

modify screen.

endloop.

endif.

endif.

endmodule. " mb0_400 OUTPUT

_____________________________________________________________________________________________

screen 100 flow logic

_____________________________________________________________________________________________

process before output.

  • MODULE STATUS_0100.

*

process after input.

chain.

field: mara-matnr,knbk-kunnr.

module m_validation.

endchain.

module user_command_0100.

_____________________________________________________________________________________________

screen 200 flow logic

_____________________________________________________________________________________________

process before output.

  • MODULE STATUS_0200.

call subscreen sub1 including 'ZTRANSACTIONSV7' v_dynnr.

module mb1_200.

*

process after input.

  • MODULE USER_COMMAND_0200.

call subscreen sub1.

module ma1_200.

_____________________________________________________________________________________________

screen 300 flow logic

_____________________________________________________________________________________________

process before output.

  • MODULE STATUS_0300.

loop.

module mb1_300.

module mb0_300.

endloop.

module mb2_300.

process after input.

  • MODULE USER_COMMAND_0300.

loop.

module ma1_300.

endloop.

_____________________________________________________________________________________________

screen 400 flow logic

_____________________________________________________________________________________________

process before output.

  • MODULE STATUS_0400.

loop.

module mb1_400.

module mb0_400.

endloop.

module mb2_400.

process after input.

  • MODULE USER_COMMAND_0400.

loop.

module ma1_400.

endloop.