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

selecting data in the table control

Former Member
0 Likes
2,020

Hi Friends,

I have final data in my table control now the user wants to select only few records from the displayed data, for that I kept a check box for selection, But my question is I am unable to read the selected data.

Actually user requirement is he has to update only the selected data from the displayed data in the table control.

Can any one tell me how to read the selected records after displaying in the table control.

Thanx in advance,

Line

15 REPLIES 15
Read only

gopi_narendra
Active Contributor
0 Likes
1,441

for the table control properties u have an option called W/SelColumn.

Give in some name (ROW_SEL)to that and also include a field CHK in the internal which is being passed to the table control.

and in the PAI of the table control module wirte like this...

module read_tablecontrol_data.

....

if ROW_SEL = 'X'.

itab-CHK = 'X'.

endif.

endmodule.

this logic will enable you to check the selected records in the table control. and then you can perfom you logic as

loop at itab where CHK = 'X'.

........

endlooop.

for this you should also enable the Multiple Linesel Option to select multiple lines. You can find it in the table control properties.

Regards

Gopi

Read only

0 Likes
1,441

Thanx Gopi,

For your response can u pls send me the code for my reference, As Ii got strucked with this and tried all the ways but cannot solve this issue.

Regards,

Line

Read only

0 Likes
1,441

row_sel is the name which is to be given to the W/SelColumn in the table control properties.

and enable the radio button for the multiple lines select in the table control properties.

data :row_sel(1) type C

data : begin of itab occurs 0,

chk(1) type C,

continue ur fields.....

end of itab.

in the PAI module of your internal table include these statements.

module read_data.

if row_sel = 'X'.

itab-chk = 'X'.

endif.

....

....

modify itab index tabc-current_line.

endmodule.

now in the ur user command

you can update ur selected rows as

loop at itab where CHK= 'X'.

do the update for those rows.....

endloop.

this will enable you to check the rows selected

<b>If you can paste your part of code i will suggest you of what to be done</b>.

Regards

Gopi

Read only

0 Likes
1,441

Hi Gopi,

PROCESS AFTER INPUT.

  • PAI FLOW LOGIC FOR TABLECONTROL 'TABCONTROL'

LOOP AT LT_FINAL.

ENDLOOP.

MODULE TABCONTROL_USER_COMMAND.

  • MODULE TABCONTROL_CHANGE_TC_ATTR.

  • MODULE TABCONTROL_CHANGE_COL_ATTR.

MODULE USER_COMMAND_0101.

I have selected a check box in my internal table,

I am confused where to write the code for reading the data from the table control.

Regards, Line

Read only

0 Likes
1,441

the module shoudl be wiht in the loop endloop in the flowlogic

  • Flowlogic of screen

LOOP AT LT_FINAL.

MODULE TABCONTROL_USER_COMMAND.

ENDLOOP.

MODULE USER_COMMAND_0101.

*moduel tabcontrol_user_command

MODULE TABCONTROL_USER_COMMAND input.

if row_sel = 'X'.

lt_tab-chk = 'X'.

endif.

ENDMODULE.

MODULE USER_COMMAND_0101 input.

case sy-ucomm.

when 'SAVE'.

loop at lt_tab where CHK = 'X'.

perform your logic to save.

endloop.

endcase.

make sure you have some action button to SAVE.

Check these programs for better understanding

<b>demo_dynpro_tabcont_loop

demo_dynpro_tabcont_loop_at

RSDEMO02</b>

Regards

Gopi

Read only

0 Likes
1,441

Hi Gopi,

I checked with the logic provided by even though it is not reading the record, can u please suggest me.

PROCESS AFTER INPUT.

  • PAI FLOW LOGIC FOR TABLECONTROL 'TABCONTROL'

LOOP AT lt_final.

MODULE read_data.

ENDLOOP.

&----


*& Module read_data INPUT

&----


  • text

----


module read_data input.

IF row_sel = 'X'.

lw_final-chek = 'X'.

ENDIF.

endmodule. " read_data INPUT

pls suggest me what to do.

Regards,

Line

Read only

0 Likes
1,441

Hi Gopi,

This is my code I am getting error message at the input,

Please correct the code,

PROCESS BEFORE OUTPUT.

  • PBO FLOW LOGIC FOR TABLECONTROL 'TABCONTROL'

  • MODULE TABCONTROL_CHANGE_TC_ATTR.

  • MODULE TABCONTROL_CHANGE_COL_ATTR.

LOOP AT lt_final

INTO lw_final

WITH CONTROL tabcontrol

CURSOR tabcontrol-current_line.

MODULE tabcontrol_get_lines.

  • MODULE TABCONTROL_CHANGE_FIELD_ATTR

ENDLOOP.

MODULE status_0101.

*

PROCESS AFTER INPUT.

  • PAI FLOW LOGIC FOR TABLECONTROL 'TABCONTROL'

LOOP AT lt_final.

  • MODULE read_data.

MODULE tabcontrol_user_command.

ENDLOOP.

  • MODULE TABCONTROL_CHANGE_TC_ATTR.

  • MODULE TABCONTROL_CHANGE_COL_ATTR.

MODULE user_command_0101.

MODULE tabcontrol_user_command input.

if row_sel = 'X'.

lt_final-chek = 'X'.

endif.

endmodule.

thanx in advance,

Line

Read only

0 Likes
1,441

Hello Line,

As gopi has suggested do the following..

for the table control properties u have an option called W/SelColumn.

Give in some name (ROW_SEL)to that and also include a field CHK in the internal which is being passed to the table control.

and in the PAI of the table control module wirte like this...

Then in your code..

PROCESS BEFORE OUTPUT.

  • PBO FLOW LOGIC FOR TABLECONTROL 'TABCONTROL'

  • MODULE TABCONTROL_CHANGE_TC_ATTR.

  • MODULE TABCONTROL_CHANGE_COL_ATTR.

LOOP AT lt_final

INTO lw_final

WITH CONTROL tabcontrol

CURSOR tabcontrol-current_line.

MODULE tabcontrol_get_lines.

  • MODULE TABCONTROL_CHANGE_FIELD_ATTR

ENDLOOP.

MODULE status_0101.

*

PROCESS AFTER INPUT.

  • PAI FLOW LOGIC FOR TABLECONTROL 'TABCONTROL'

LOOP AT lt_final.

  • MODULE read_data.

MODULE tabcontrol_user_command.

ENDLOOP.

  • MODULE TABCONTROL_CHANGE_TC_ATTR.

  • MODULE TABCONTROL_CHANGE_COL_ATTR.

MODULE user_command_0101.

MODULE tabcontrol_user_command input.

if lt_final-chek = 'X'.

*put your logic here something like

move corresponding lt_final to gt_final.

*now you have selcted rows data in gt_final.

endif.

endmodule.

Regards

Read only

0 Likes
1,441

Hello,

Some correction.

I hope you included a additional field chk/ some thing in your internal table as suggested by Gopi..

Then In PAI..

PROCESS AFTER INPUT.
* PAI FLOW LOGIC FOR TABLECONTROL 'TABCONTROL'
LOOP AT lt_final.
* MODULE read_data.
<b>filed  lt_final-chk</b> MODULE tabcontrol_user_command.
ENDLOOP.
* MODULE TABCONTROL_CHANGE_TC_ATTR.
* MODULE TABCONTROL_CHANGE_COL_ATTR.


MODULE user_command_0101.

MODULE tabcontrol_user_command input.
<b>  IF lt_final-chk= 'X'.
    MODIFY lt_final INDEX tab_cntl-current_line.
    APPEND lt_final TO gt_final.
  ENDIF.
endif.</b>
end module.

Read only

0 Likes
1,441

Hello Gopi,

I saw this forum and i have the same problem. I already followed evrything in here but still i can't have my <W/SelColumn name> equal to 'X', eventhoug I already select 1 row in my wizard table and when i debug it still my <W/SelColumn name> is equal to no value or blank.

Can help me with this Gopi..PLEASE.

THANK YOU SO MUCH

Read only

Former Member
0 Likes
1,441

Hi Line,

Refer this code :

loop at i_tab1 .

IF Chk_box = 'Y'.

CLEAR i_tab2.

READ TABLE i_tab1 INDEX tab_cntrl-current_line.

i_tab2-matnr = i_tab1-matnr.

i_tab2-mtart = i_tab1-mtart.

i_tab2-meins = i_tab1-meins.

i_tab2-doc = i_tab1-doc.

i_tab2-maktx = i_tab1-maktx.

APPEND i_tab2.

endif.

endloop.

<REMOVED BY MODERATOR>

Regards,

Hemant

Edited by: Alvaro Tejada Galindo on Jul 21, 2008 12:14 PM

Read only

Former Member
0 Likes
1,441

First know the cursor control position and then u can find the index whose value is checked and then u can take this values into table control(Table control will be having the index if it is in the table).

Read only

Former Member
0 Likes
1,441

Hi Line,

Refer this code .

loop at i_tab1 .

IF chkbox = 'X'.

CLEAR i_tab2.

READ TABLE i_tab1 INDEX tab_cntrl-current_line.

i_tab2-matnr = i_tab1-matnr.

i_tab2-mtart = i_tab1-mtart.

i_tab2-meins = i_tab1-meins.

i_tab2-doc = i_tab1-doc.

i_tab2-maktx = i_tab1-maktx.

APPEND i_tab2.

ENDIF.

endloop.

Use update or insert command to update data of itab2.

<REMOVED BY MODERATOR>

Regards,

Hemant

Edited by: Alvaro Tejada Galindo on Jul 21, 2008 12:15 PM

Read only

Former Member
0 Likes
1,441

CALL METHOD (node reference here)lo_nd_sel_doc->GET_SELECTED_ELEMENTS

RECEIVING

SET = (Your result set.) lt_test.

if you want in a different internal table type.

just loop at this set and append to internal table of any type by assigning each field.

Thanks,

Rahul.

Read only

0 Likes
1,441

Line,

sorry this is for webdynpro control, i guess yours is the regular screen programming.

I thought your requirement was in webdynpro.

Thanks,

Rahul.