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

read the selected entries from table control

Former Member
0 Likes
598

Hi all,

can you plz help me how to read the selected records from a table control to internal table

1 ACCEPTED SOLUTION
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
572

Hi,

Use this code, its working:-

it_zekpo is my internal table w/o header line,

wa_zekpo is work area.

Name of input/output fields on screen are:-

wa_zekpo-field1,

wa_zekpo-field2, and so on...

Include a field in type for internal table and work area as flag(1) type c.

Also in the attributes of the table control take the name of SELCOL as wa_zekpo-flag

Maintain another internal table and work area of same structure as used for the above internal table ( it_zekpo and wa_zekpo ) as ( it_temp and wa_temp )

At screen flow-logic


PROCESS BEFORE OUTPUT.
*  MODULE status_8003.
 
  LOOP WITH CONTROL po_tb.
    MODULE read_data. "<-- read data from internal table to table control
  ENDLOOP.
 
PROCESS AFTER INPUT.
*  MODULE user_command_8003.
 
  LOOP WITH CONTROL po_tb.
    MODULE modify_data. "<-- modify data form table control to internal table
  ENDLOOP.
 
  MODULE copy_data. "<-- select some records click COPY button to copy records into another internal table

In PBO


*&---------------------------------------------------------------------*
*&      Module  READ_DATA  OUTPUT
*&---------------------------------------------------------------------*
MODULE read_data OUTPUT.
  READ TABLE it_zekpo INTO wa_zekpo INDEX po_tb-current_line. "po_tab is table control name
 
  data : line_count type i.
 
  describe it_zekpo
  lines line_count.
 
  po_tb-lines = line_count + 10.
  "to increase the number of lines in table control dynamically
ENDMODULE.                 " READ_DATA  OUTPUT

In PAI


*&---------------------------------------------------------------------*
*&      Module  MODIFY_DATA  INPUT
*&---------------------------------------------------------------------*
MODULE MODIFY_DATA INPUT.
  MODIFY IT_ZEKPO FROM WA_ZEKPO INDEX po_tb-currentline.
  "this will modify the contents of existing line into internal table
ENDMODULE.                 " MODIFY_DATA  INPUT
 
*&---------------------------------------------------------------------*
*&      Module  COPY_DATA  INPUT
*&---------------------------------------------------------------------*
MODULE COPY_DATA INPUT.
  CASE sy-ucomm.
    WHEN 'COPY'.
      sort it_zekpo by flag ascending.
      loop at it_zekpo into wa_zekpo.
        if wa_zekpo-flag = 'X'.
          wa_temp = wa_zekpo.
          append wa_temp to it_temp.
          clear wa_temp.
        endif.
        clear wa_zekpo.
      endloop.
  ENDCASE.
ENDMODULE.                 " COPY_DATA  INPUT

Now when you click COPY button, all the selected records will be copied into another internal table it_temp.

Now you can use this internal table it_temp as per your requirement.

Hope this solves your problem.

Thanks & Regards,

Tarun

Hi all,

can you plz help me how to read the selected records from a table control to internal table

3 REPLIES 3
Read only

Former Member
0 Likes
572

Hi,

Try this.

You may be maintaining an internal table which has the data in the same order as the data displayed in the table control.

There is a system field 'SY-LOOPC' which has the index of the selected row in the table control, with that u can read the selected entries in the table control from the internal table.

May be its helpful.

Regards,

Sharin.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
573

Hi,

Use this code, its working:-

it_zekpo is my internal table w/o header line,

wa_zekpo is work area.

Name of input/output fields on screen are:-

wa_zekpo-field1,

wa_zekpo-field2, and so on...

Include a field in type for internal table and work area as flag(1) type c.

Also in the attributes of the table control take the name of SELCOL as wa_zekpo-flag

Maintain another internal table and work area of same structure as used for the above internal table ( it_zekpo and wa_zekpo ) as ( it_temp and wa_temp )

At screen flow-logic


PROCESS BEFORE OUTPUT.
*  MODULE status_8003.
 
  LOOP WITH CONTROL po_tb.
    MODULE read_data. "<-- read data from internal table to table control
  ENDLOOP.
 
PROCESS AFTER INPUT.
*  MODULE user_command_8003.
 
  LOOP WITH CONTROL po_tb.
    MODULE modify_data. "<-- modify data form table control to internal table
  ENDLOOP.
 
  MODULE copy_data. "<-- select some records click COPY button to copy records into another internal table

In PBO


*&---------------------------------------------------------------------*
*&      Module  READ_DATA  OUTPUT
*&---------------------------------------------------------------------*
MODULE read_data OUTPUT.
  READ TABLE it_zekpo INTO wa_zekpo INDEX po_tb-current_line. "po_tab is table control name
 
  data : line_count type i.
 
  describe it_zekpo
  lines line_count.
 
  po_tb-lines = line_count + 10.
  "to increase the number of lines in table control dynamically
ENDMODULE.                 " READ_DATA  OUTPUT

In PAI


*&---------------------------------------------------------------------*
*&      Module  MODIFY_DATA  INPUT
*&---------------------------------------------------------------------*
MODULE MODIFY_DATA INPUT.
  MODIFY IT_ZEKPO FROM WA_ZEKPO INDEX po_tb-currentline.
  "this will modify the contents of existing line into internal table
ENDMODULE.                 " MODIFY_DATA  INPUT
 
*&---------------------------------------------------------------------*
*&      Module  COPY_DATA  INPUT
*&---------------------------------------------------------------------*
MODULE COPY_DATA INPUT.
  CASE sy-ucomm.
    WHEN 'COPY'.
      sort it_zekpo by flag ascending.
      loop at it_zekpo into wa_zekpo.
        if wa_zekpo-flag = 'X'.
          wa_temp = wa_zekpo.
          append wa_temp to it_temp.
          clear wa_temp.
        endif.
        clear wa_zekpo.
      endloop.
  ENDCASE.
ENDMODULE.                 " COPY_DATA  INPUT

Now when you click COPY button, all the selected records will be copied into another internal table it_temp.

Now you can use this internal table it_temp as per your requirement.

Hope this solves your problem.

Thanks & Regards,

Tarun

Read only

Former Member
0 Likes
572

Refer this [Table Control|http://www.scribd.com/doc/7202603/Table-Control]