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 in module pool

Former Member
0 Likes
934

Hi,

In Module pool programing iam using table control.

As soon as i enter into the screen ( PBO), in table control the first item number default value should start with the value 10 and after i fill all the details for that particular row and press enter then the item number should get incremented to 20 and soon on.

I also have a Refresh button, when i press this every thing (data) gets refreshed ( header and also item data).

Now if i click on refresh button, table control data should be cleared but the first item number should be 10 by default.

Please let me know.

Regards,

Mahesh.

1 ACCEPTED SOLUTION
Read only

former_member632729
Contributor
0 Likes
699

Hi Dude,

Check the programs in ABAP Docu, program names

  • DEMO_DYNPRO_TABLE_CONTROL_1

  • DEMO_DYNPRO_TABLE_CONTROL_2



report demo_dynpro_table_control_1  message-id sabapdocu.

data: begin of itab occurs 10,
        mark,
        col1 type i,
        col2 type i,
      end of itab.


data ok_code type sy-ucomm.
data ok_save type sy-ucomm.
data tab_lines type i.
data step_lines type i.
data offset type i.

controls table type tableview using screen 100.

call screen 100.

module init output.
  set pf-status 'BASIC'.
endmodule.

module fill_itab output.
  describe table itab lines tab_lines.
  if tab_lines = 0.
    do 40 times.
      itab-col1 = sy-index.
      itab-col2 = sy-index ** 2.
      append itab.
    enddo.
    describe table itab lines tab_lines.
    table-lines = tab_lines.
  endif.
endmodule.

module transp_itab output.
  read table itab index table-current_line.
endmodule.

module lines output.
  step_lines = sy-loopc.
endmodule.

module exit input.
  leave program.
endmodule.

module check_pai input.
  ok_save = ok_code. clear ok_code.
  message s888 with 'TOP_LINE: ' table-top_line
                    ', LINES: '  step_lines.
endmodule.

module check_table input.
  case ok_save.
    when 'MARK'.
      if itab-mark = 'X'.
        message i888 with 'Zeile' table-current_line 'markiert'.
      endif.
    when 'SETM'.
      modify itab index table-current_line.
  endcase.

endmodule.

module check_all input.
  case ok_save.
    when 'ALLM'.
      loop at itab.
        if itab-mark = 'X'.
          message i888 with 'Zeile' sy-tabix 'markiert'.
        endif.
      endloop.
    when 'DELE'.
      loop at itab.
        if itab-mark = 'X'.
          itab-mark = ' '.
          modify itab.
        endif.
      endloop.
  endcase.
endmodule.

module scroll input.
  case ok_save.
    when 'PGDO'.
      offset = table-lines - step_lines.
      if table-top_line lt offset.
        table-top_line = table-top_line + step_lines.
      endif.
    when 'PGUP'.
      offset = step_lines.
      if table-top_line gt offset.
        table-top_line = table-top_line - step_lines.
      else.
        table-top_line = 1.
      endif.
    when 'PGLA'.
      table-top_line = table-lines - step_lines + 1.
    when 'PGTO'.
      table-top_line = 1.
  endcase.
endmodule.

4 REPLIES 4
Read only

Former Member
0 Likes
699

Try this logic:

Top Include:
Data: w_item type i,
         Fl_flag type c.

In PAI:
  CASE SY-ucomm.
       When Refresh.
               FL_FLAG = 'X'.
  ENDCASE.

In PBO :

If FL_FLAG = 'X'.
Clear table appart from First row.
ENDIF.
Loop at Itab with table control.
Increment line item with 10 everytime.
Endloop.

Regards,

Gurpreet

Read only

0 Likes
699

Hi,

Can u please provide the logic for incrementing the item number when i press enter .

When i click on refresh button it should clear the table control complete data and it should look like as you refreshed the screen and should contain the table control first item number should be 10.

Read only

0 Likes
699
Make the Item Field as part of you internal table.
Top Include.
data: W_item type i,
        w_row type i value 1.
If PBO:

If Flag = 'X'.
w_item = 10.
w_row = 1.
ENDIF.

Module itab_increment.
Itab-itemno = w_item + 10.
Modify itab index w_row.                      " Every time when you add a new row get row no/Add 1 to row
endmodule.

Loop at itab with table control.
Module ITAB.
Endloop.

Regards,

Gurpreet

Read only

former_member632729
Contributor
0 Likes
700

Hi Dude,

Check the programs in ABAP Docu, program names

  • DEMO_DYNPRO_TABLE_CONTROL_1

  • DEMO_DYNPRO_TABLE_CONTROL_2



report demo_dynpro_table_control_1  message-id sabapdocu.

data: begin of itab occurs 10,
        mark,
        col1 type i,
        col2 type i,
      end of itab.


data ok_code type sy-ucomm.
data ok_save type sy-ucomm.
data tab_lines type i.
data step_lines type i.
data offset type i.

controls table type tableview using screen 100.

call screen 100.

module init output.
  set pf-status 'BASIC'.
endmodule.

module fill_itab output.
  describe table itab lines tab_lines.
  if tab_lines = 0.
    do 40 times.
      itab-col1 = sy-index.
      itab-col2 = sy-index ** 2.
      append itab.
    enddo.
    describe table itab lines tab_lines.
    table-lines = tab_lines.
  endif.
endmodule.

module transp_itab output.
  read table itab index table-current_line.
endmodule.

module lines output.
  step_lines = sy-loopc.
endmodule.

module exit input.
  leave program.
endmodule.

module check_pai input.
  ok_save = ok_code. clear ok_code.
  message s888 with 'TOP_LINE: ' table-top_line
                    ', LINES: '  step_lines.
endmodule.

module check_table input.
  case ok_save.
    when 'MARK'.
      if itab-mark = 'X'.
        message i888 with 'Zeile' table-current_line 'markiert'.
      endif.
    when 'SETM'.
      modify itab index table-current_line.
  endcase.

endmodule.

module check_all input.
  case ok_save.
    when 'ALLM'.
      loop at itab.
        if itab-mark = 'X'.
          message i888 with 'Zeile' sy-tabix 'markiert'.
        endif.
      endloop.
    when 'DELE'.
      loop at itab.
        if itab-mark = 'X'.
          itab-mark = ' '.
          modify itab.
        endif.
      endloop.
  endcase.
endmodule.

module scroll input.
  case ok_save.
    when 'PGDO'.
      offset = table-lines - step_lines.
      if table-top_line lt offset.
        table-top_line = table-top_line + step_lines.
      endif.
    when 'PGUP'.
      offset = step_lines.
      if table-top_line gt offset.
        table-top_line = table-top_line - step_lines.
      else.
        table-top_line = 1.
      endif.
    when 'PGLA'.
      table-top_line = table-lines - step_lines + 1.
    when 'PGTO'.
      table-top_line = 1.
  endcase.
endmodule.