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

Problem in getting selected row in table control

former_member1292715
Participant
0 Likes
2,883

Hi guys,

I am really frustrated of getting the row, selected in table control. I can see hudreds of post in the same topic in SDN. But I can't figure out where I went wrong.

I have table control, in that I set the attribute w/Sel Column as MARK and I created the same field in my internal table.

And on the execution, I selected a row and that row is not getting the value as X for the field mark in my internal table. Please have a look at my code and guide me where I was going wrong.

Please note that GET CURSOR LINE doesn't suit for my requirement.

PROCESS BEFORE OUTPUT.
  MODULE status_2000.
  LOOP AT gt_main INTO gwa_main WITH CONTROL tc_main.
    MODULE fill_table_control.
  ENDLOOP.
*

PROCESS AFTER INPUT.
  LOOP AT gt_main.
    MODULE read_table_conrol.
  ENDLOOP.
  MODULE user_command_2000.


CONTROLS: tc_main TYPE TABLEVIEW USING SCREEN 2000.

TYPES: BEGIN OF ty_main,
        rmsno  TYPE zmm_spa_item-rmsno,
        reqno  TYPE zmm_spa_item-reqno,
        mfnam  TYPE zmm_spa_item-mfnam,
        mfpcd  TYPE zmm_spa_item-mfpcd,
        magnt  TYPE zmm_spa_item-magnt,
        crdat  TYPE zmm_spa_item-crdat,
        fstat  TYPE zmm_spa_item-fstat,
        sirst  TYPE zmm_spa_item-sirst,
        purst  TYPE zmm_spa_item-purst,
        tecst  TYPE zmm_spa_item-tecst,
        qcvst  TYPE zmm_spa_item-qcvst,
        plnst  TYPE zmm_spa_item-plnst,
        prdst  TYPE zmm_spa_item-prdst,
        aslgr  TYPE zmm_spa_item-aslgr,
        lifnr  TYPE zmm_spa_item-lifnr,
        mark   TYPE c,
       END OF ty_main.



MODULE fill_table_control OUTPUT.

  READ TABLE gt_main INTO gwa_main INDEX tc_main-current_line.
  IF sy-subrc EQ 0.
    MOVE-CORRESPONDING gwa_main TO zmm_spa_item.
  ENDIF.

ENDMODULE.                 " FILL_TABLE_CONTROL  OUTPUT


MODULE read_table_conrol INPUT.

*      GET CURSOR LINE gv_curline.

      READ TABLE gt_main INTO gwa_main WIH KEY mark = 'X'.
      IF sy-subrc EQ 0.
        MOVE-CORRESPONDING gwa_main TO zmm_spa_item.
      ELSE.
        MESSAGE e001 WITH 'Please select a request number'.
      ENDIF.
      CALL SCREEN 2200.


ENDMODULE.                 " READ_TABLE_CONROL  INPUT

4 REPLIES 4
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
968

Before read control you need to modify the table control value with 'X'.

Read only

guilherme_frisoni
Contributor
0 Likes
968

Hi,

i think its missing a modify inside a chain for each line.

Try following:


PROCESS AFTER INPUT.
  LOOP AT gt_main.
    CHAIN.
      gwa_main-mark.
      MODULE update_fields ON CHAIN-REQUEST.
    ENDCHAIN.
  ENDLOOP.
  MODULE read_table_conrol.
  MODULE user_command_2000.

MODULE update_fields INPUT.
  MODIFY gtmain
    FROM gwa_main
    INDEX tc_main-current_line.
ENDMODULE.


MODULE read_table_conrol INPUT.
  LOOP AT gt_main INTO gwa_main
    WHERE mark = 'X'.
    ...
  ENDLOOP.
ENDMODULE.

Regards,

Frisoni

Read only

0 Likes
968

Hi Frisoni & Keshav,

I found out the problem. Instead of MARK, I made the field name as gwa_main-mark in the table control attributes and it is capturing now. And changed the code as below.

MODULE read_table_conrol INPUT.
  MODIFY gt_main FROM gwa_main INDEX tc_main-current_line.
ENDMODULE.

Thanks for your quick replies.

Yasin.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
968

In PAI

LOOP AT itab_table .

MODULE modify_int_table.

ENDLOOP.

In the MODULE call modify_int_table we can use

MODIFY int_table FROM workarea INDEX tab_con-CURRENT_LINE

i think this will solve your issue.