cancel
Showing results for 
Search instead for 
Did you mean: 

how to select a row in table control..

Former Member
0 Kudos

hi..

we created a table control and given a selction colom as itab-mark,

but while running the prog itab-mark = 'x' is not taking any value.

and it is displaying the last row instead of the selected row...

as we r new to abap will anyone pls make it clear for us asap.

thanking u.

Accepted Solutions (0)

Answers (9)

Answers (9)

former_member635387
Discoverer
0 Kudos

PROCESS BEFORE OUTPUT.

Step 1 - Declare ABAP variable to store line selection indicator.     DATA: MARK TYPE C.
Step 2 - Assign created variable to dynpro table control. 


Step 3 - Modify dialog screen Flow logic in-order to capture users line selection. 
PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
  module data_retrieval.
  loop at it_ekko into wa_ekko with control TC100.
    module populate_screen.
  endloop.
*

PROCESS AFTER INPUT.
  loop at it_ekko.
       module update_table.
     endloop.
* MODULE USER_COMMAND_0100.
 

To create module update_table please Double click on it and select yes to the next pop-up. Ensure that a new include is created to hold all the PAI modules (default) and Press enter.

Now insert the following ABAP code into this PAI module!
*&---------------------------------------------------------------------*
*&      Module  update_table  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module update_table input.

read table it_ekko into wa_ekko index tc100-CURRENT_LINE.
 if not mark is initial.
   wa_ekko-SEL = 'X'.
   modify it_ekko from wa_ekko index tc100-CURRENT_LINE.
 endif.

endmodule.                 
 


Former Member
0 Kudos

hello narashima..

this is ur floe logic...

process before output.

module status_0100.

loop at itab with control tc cursor tc-current_line.

module fill_table_control.

MODULE SET_SELECTED_ROW.

endloop.

process after input.

loop at itab.

module read_table_control.

field ITAB-mark MODULE GET_SELECTED_ROW.

endloop.

module user_command_0100.

Former Member
0 Kudos

Hi,

This program code may help you.its also working same as you mentioned.try to implement you code in this by modifying the.

control name

flag

etc..

In this example look the PBO and PAI and the last module in the the below program.its about which element is marked

PROCESS BEFORE OUTPUT.

MODULE status_0120.

MODULE auswahl_ferti_change_tc_attr.

LOOP AT it_temp_fauf WITH

CONTROL auswahl_ferti

CURSOR auswahl_ferti-current_line.

MODULE fill_table_control.

ENDLOOP.

CALL SUBSCREEN area1 INCLUDING sy-repid number1.

*

PROCESS AFTER INPUT.

LOOP AT it_temp_fauf.

FIELD it_temp_fauf-flag

MODULE tabcon_mark ON REQUEST.

MODULE read_table_control.

ENDLOOP.

CALL SUBSCREEN: area1.

MODULE user_command_0120.

*&----


*

*& Module STATUS_0120 OUTPUT

*&----


*

  • text

*----


*

MODULE status_0120 OUTPUT.

SET PF-STATUS '120'.

SET TITLEBAR 'ENTNAHMEDETAIL1'.

ENDMODULE. " STATUS_0120 OUTPUT

*DECLARATION OF TABLECONTROL 'AUSWAHL_FERTI' ITSELF

CONTROLS: auswahl_ferti TYPE TABLEVIEW USING SCREEN 0120.

*DATA:g_auswahl_ferti_lines LIKE sy-loopc.

----


  • MODULE AUSWAHL_FERTI_CHANGE_TC_ATTR OUTPUT

----


*

----


MODULE auswahl_ferti_change_tc_attr OUTPUT.

DESCRIBE TABLE it_temp_fauf LINES auswahl_ferti-lines.

ENDMODULE. "AUSWAHL_FERTI_CHANGE_TC_ATTR OUTPUT

----


  • MODULE AUSWAHL_FERTI_GET_LINES OUTPUT

----


*

----


*

MODULE auswahl_ferti_get_lines OUTPUT.

  • g_auswahl_ferti_lines = sy-loopc.

ENDMODULE. "AUSWAHL_FERTI_GET_LINES OUTPUT

*&----


*

*& Module FILL_TABLE_CONTROL OUTPUT

*&----


*

  • text

*----


*

MODULE fill_table_control OUTPUT.

READ TABLE it_temp_fauf INTO /cmd/wa_s_fauf

INDEX auswahl_ferti-current_line.

ENDMODULE. " FILL_TABLE_CONTROL OUTPUT

*&----


*

*& Module read_table_control INPUT

*&----


*

  • text

*----


*

MODULE read_table_control INPUT.

lines = sy-loopc.

MODIFY it_fauf FROM /cmd/wa_s_fauf INDEX

auswahl_ferti-current_line.

ENDMODULE. " read_table_control INPUT

*&----


*

*& Module USER_COMMAND_0120 INPUT

*&----


*

  • text

*----


*

MODULE user_command_0120 INPUT.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'BACK'.

CALL SCREEN 100.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'CANCEL'.

CALL SCREEN 100.

WHEN 'F5'.

LOOP AT it_aus_pos.

DELETE it_aus_pos.

ENDLOOP.

  • Moving the corresponding fields of the selected order.

SELECT * FROM resb WHERE rsnum = afko-rsnum.

MOVE-CORRESPONDING resb TO it_aus_pos.

SELECT * FROM makt WHERE matnr = it_aus_pos-matnr.

MOVE-CORRESPONDING makt TO it_aus_pos.

ENDSELECT.

APPEND it_aus_pos.

ENDSELECT.

CALL SCREEN 120.

ENDCASE.

ENDMODULE. " USER_COMMAND_0120 INPUT

*&----


*

*& Module TABCON_MARK INPUT

*&----


*

  • text

*----


*

MODULE tabcon_mark INPUT.

MODIFY it_temp_fauf

INDEX auswahl_ferti-current_line

TRANSPORTING flag.

IF it_temp_fauf-flag = 'X'.

temp_aufnr = it_temp_fauf-aufnr.

SELECT SINGLE * FROM afko WHERE aufnr = temp_aufnr.

ENDIF.

ENDMODULE. " TABCON_MARK INPUT

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Check this link.It will help you regarding the selection.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/table control in abap.pdf

Kindly reward points by clicking the star on the left of reply,if it helps.

Message was edited by: Jayanthi Jayaraman

Former Member
0 Kudos

Hi

You should have a module to fix mark field (PAI) and a module to dysplay (PBO).

Max

Former Member
0 Kudos

Hi naveen,

welcome to SDN.

check this link it may help you...

reward points for helpfull answers and close the thread if your question is solved by clicking radio buttons on the top left.

regards,

venu.

Former Member
0 Kudos

hi,

in the table control property did you mark the line sel - Multiple

cheers,

sasi

Former Member
0 Kudos

hi..

u can find following useful to get ur query solved..

reward if it solves ur problem

Former Member
0 Kudos

Hi,

In you PBO...

you have maybe done that

loop at itab with control myControl cursor myControl-current_line.

module fill_screen.

endloop.

But in your process after input you have to do that.

loop at itab.

module update_internal_table.

endloop.

If you do not do that, the internal table never contains 'X' in the field mark.

do you see the point ?

If helped plz do not forget the rewrad.

Former Member
0 Kudos

hello...

can u figur out what might gone wrong in our code...

REPORT ZOOM10000 .

controls tc type tableview using screen 100.

data index type i.

data: itab type table of demo_conn with header line,

ftab type table of demo_conn with header line,

fill type i.

data: lines type i,

limit type i.

DATA MARK TYPE C.

tables demo_conn.

select * from spfli into table itab.

call screen 100.

&----


*& Module status_0100 OUTPUT

&----


  • text

----


module status_0100 output.

set pf-status 'SCREEN_100'.

describe table itab lines fill.

tc-lines = fill.

endmodule. " status_0100 OUTPUT

&----


*& Module read_table_control INPUT

&----


  • text

----


module read_table_control input.

read table itab into demo_conn index tc-current_line.

lines = sy-loopc.

endmodule. " read_table_control INPUT

&----


*& Module user_command_0100 INPUT

&----


  • text

----


module user_command_0100 input.

modify itab from demo_conn index tc-current_line.

case sy-ucomm.

when 'GO'.

perform naveen.

endcase.

endmodule. " user_command_0100 INPUT

&----


*& Module fill_table_control OUTPUT

&----


  • text

----


module fill_table_control output.

read table itab into demo_conn index tc-current_line.

endmodule. " fill_table_control OUTPUT

&----


*& Module SET_SELECTED_ROW OUTPUT

&----


  • text

----


module SET_SELECTED_ROW output.

*IF TC-CURRENT_LINE = SELECTED_LINE.

IF MARK = 'X'.

MARK = 'X'.

ELSE.

MARK = SPACE.

ENDIF.

endmodule. " SET_SELECTED_ROW OUTPUT

&----


*& Module GET_SELECTED_ROW INPUT

&----


  • text

----


module GET_SELECTED_ROW input.

*IF SY-STEPL = 1.

*SELECTED_LINE = 0.

*ENDIF.

*CHECK MARK = 'X'.

*SELECTED_LINE = TC-CURRENT_LINE.

MARK = MARK.

endmodule. " GET_SELECTED_ROW INPUT

form naveen.

loop at itab.

if mark = 'X'.

exit.

endif.

endloop.

leave to list-processing.

suppress dialog.

select mandt carrid connid from spfli into itab

where

connid = itab-connid.

write:/ itab-mandt,itab-carrid,itab-connid.

endselect.

*

endform.

Former Member
0 Kudos

hello...

can u figur out what might gone wrong in our code...

REPORT ZOOM10000 .

controls tc type tableview using screen 100.

data index type i.

data: itab type table of demo_conn with header line,

ftab type table of demo_conn with header line,

fill type i.

data: lines type i,

limit type i.

DATA MARK TYPE C.

tables demo_conn.

select * from spfli into table itab.

call screen 100.

&----


*& Module status_0100 OUTPUT

&----


  • text

----


module status_0100 output.

set pf-status 'SCREEN_100'.

describe table itab lines fill.

tc-lines = fill.

endmodule. " status_0100 OUTPUT

&----


*& Module read_table_control INPUT

&----


  • text

----


module read_table_control input.

read table itab into demo_conn index tc-current_line.

lines = sy-loopc.

endmodule. " read_table_control INPUT

&----


*& Module user_command_0100 INPUT

&----


  • text

----


module user_command_0100 input.

modify itab from demo_conn index tc-current_line.

case sy-ucomm.

when 'GO'.

perform naveen.

endcase.

endmodule. " user_command_0100 INPUT

&----


*& Module fill_table_control OUTPUT

&----


  • text

----


module fill_table_control output.

read table itab into demo_conn index tc-current_line.

endmodule. " fill_table_control OUTPUT

&----


*& Module SET_SELECTED_ROW OUTPUT

&----


  • text

----


module SET_SELECTED_ROW output.

*IF TC-CURRENT_LINE = SELECTED_LINE.

IF MARK = 'X'.

MARK = 'X'.

ELSE.

MARK = SPACE.

ENDIF.

endmodule. " SET_SELECTED_ROW OUTPUT

&----


*& Module GET_SELECTED_ROW INPUT

&----


  • text

----


module GET_SELECTED_ROW input.

*IF SY-STEPL = 1.

*SELECTED_LINE = 0.

*ENDIF.

*CHECK MARK = 'X'.

*SELECTED_LINE = TC-CURRENT_LINE.

MARK = MARK.

endmodule. " GET_SELECTED_ROW INPUT

form naveen.

loop at itab.

if mark = 'X'.

exit.

endif.

endloop.

leave to list-processing.

suppress dialog.

select mandt carrid connid from spfli into itab

where

connid = itab-connid.

write:/ itab-mandt,itab-carrid,itab-connid.

endselect.

*

endform.

Former Member
0 Kudos

Hi u need to define the mark in the internal table then only u can find which line is marked and can you please post your floww logic so that only i can solve your problem

Message was edited by: Narasimha