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

Former Member
0 Likes
1,456

Hi,

I have a table control in a module pool program. It displays 10 lines at a time. The internal table has 25 lines. But just 10 are displayed. When I scroll down, the rows are blank. And when I try to scroll up, data is deleted from internal table. I tried debugging, and found that when its looping at internal table in PBO it just loops for 10 passes.

LOOP AT gt_inv_faxemail INTO rec_inv_faxemail

WITH CONTROL ctrl_faxemail

CURSOR ctrl_faxemail-current_line.

MODULE screen_chg.

ENDLOOP.

Table gt_inv_faxemail is without a header line & fields of rec_inv_faxemail are displayed on screen

ctrl_faxemail-lines = 40

ctrl_faxemail-v_scrol = 'X'

Could you please let me knoe what could be the problem?

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,426

The problem is that just 10 records are being displayed. I am able to scroll, but rows are just blank.

18 REPLIES 18
Read only

Former Member
0 Likes
1,426

Hi

The number of displayed lines depends on how many rows you've inserted in your table control by screen painter.

So if your table control has 10 rows you can see only 10 records, u need to scroll up (down) it in order to see the next 10 records.

It's very strange the data are deleted from internal table, u should past the code of PAI.

Max

Read only

0 Likes
1,426

Hi Max,

The code in the PAI is as below:

PROCESS AFTER INPUT.

MODULE exit_command AT EXIT-COMMAND.

MODULE clear_data_pai.

LOOP at gt_inv_faxemail."WITH CONTROL ctrl_faxemail.

CHAIN.

FIELD rec_inv_faxemail-cont_acct.

FIELD rec_inv_faxemail-line_num.

FIELD sel.

MODULE read_data.

ENDCHAIN.

ENDLOOP.

First 10 records are displayed properly. But when I scroll down, rest of the rows are blank. When I try to scroll up again, all the records are balnk.

Read only

0 Likes
1,426

Hi

Your code seems to be right, anyway can u past the code of MODULE read_data?

Max

Read only

0 Likes
1,426

Hi Max,

Code for read_data is given below:

MODULE read_data INPUT.

IF NOT rec_inv_faxemail-fax IS INITIAL

OR NOT rec_inv_faxemail-email IS INITIAL

PERFORM check_record USING rec_inv_faxemail.

CASE gv_error.

WHEN '1'.

MESSAGE e402(zauto).

WHEN '2'.

MESSAGE e403(zauto).

WHEN '3'.

MESSAGE e404(zauto).

ENDCASE.

ENDIF.

APPEND rec_inv_faxemail TO gt_inv_faxemail_temp.

ENDMODULE.

Read only

0 Likes
1,426

Hi

U're appending a record from table control every time the line has a value: very strange code, u risk to append the same records many many times.

I think the right code should be like this:

MODULE read_data INPUT.
      IF      NOT rec_inv_faxemail-fax IS INITIAL
         OR NOT rec_inv_faxemail-email IS INITIAL

         PERFORM check_record USING rec_inv_faxemail.

        CASE gv_error.
           WHEN '1'. MESSAGE e402(zauto). 
           WHEN '2'. MESSAGE e403(zauto).
           WHEN '3'. MESSAGE e404(zauto).
        ENDCASE.
    ENDIF.
   
    modify gt_inv_faxemail_temp from rec_inv_faxemail index ctrl_faxemail-current_line.
    if sy-subrc <> 0.
      APPEND rec_inv_faxemail TO gt_inv_faxemail_temp.
    endif.
ENDMODULE.

Max

Read only

0 Likes
1,426

Hey Max!!

Thanks for ur reply. The idea is for table 'gt_inv_faxemail_temp' to have all the records after user has made changes in the table control. (Multiple records can be edited). For table control we are looping at a different table 'gt_inv_faxemail'.

I wanted to paste a simplified form of PAI code, so missed an 'ENDIF'.

Read only

0 Likes
1,426

Hi

Strange, very strange!

I try to run a code like your and it works fine:

REPORT ZTABLE_CONTROL.

CONTROLS T_CTRL TYPE TABLEVIEW USING SCREEN 100.

TYPES: BEGIN OF TY_WA,
         FIELD1,
         FIELD2,
       END   OF TY_WA.

DATA: ITAB TYPE STANDARD TABLE OF TY_WA.

DATA: WA TYPE TY_WA.

DO 25 TIMES.
  WA-FIELD1 = WA-FIELD2 = 'A'.
  APPEND WA TO ITAB.
ENDDO.


T_CTRL-LINES = 40 .
T_CTRL-V_SCROLL = 'X'.


CALL SCREEN 100.

* I used work area WA to design the fields of table control:

PROCESS BEFORE OUTPUT.
  LOOP AT ITAB INTO WA
  WITH CONTROL T_CTRL
  CURSOR T_CTRL-CURRENT_LINE.
  ENDLOOP.

PROCESS AFTER INPUT.


  LOOP AT ITAB.
  ENDLOOP.

Max

Read only

0 Likes
1,426

Thanks Max!!

Now its working!!

Read only

Former Member
0 Likes
1,426

You might want to count the number of lines in the internal tanle that you are using to write the output.

Suppose your internal table is itab.

Data : NO_LINES type c.

DESCRIBE TABLE ITAB LINES NO_LINES.

And then you have to use the no_lines for your table control and will have all the lines now.

Hope this answers.

Shreekant

Read only

0 Likes
1,426

Hi Shreekant,

In PBO, there is a module above this loop which counts the number of rows in itab & assigns it to TC-lines.

Read only

0 Likes
1,426

Please check the demo Porgram i specified

Check in debug mode.

Its pretty clear.

Shreekant

Read only

Former Member
0 Likes
1,426

Check the demo Program.

DEMO_DYNPRO_TABCONT_LOOP

Shreekant

Read only

ferry_lianto
Active Contributor
0 Likes
1,426

Hi,

Please check this demo programs perhaps they may help.

DEMO_DYNPRO_TABLE_CONTROL_1

DEMO_DYNPRO_TABLE_CONTROL_2

Regards,

Ferry Lianto

Read only

0 Likes
1,426

Hi Ferry,

Inside the PBO loop they use a module:

MODULE lines OUTPUT.

step_lines = sy-loopc.

ENDMODULE.

Could you please let me know what exactly is it for?

Read only

ferry_lianto
Active Contributor
0 Likes
1,426

Hi,

Please check this link which will explain in detaill with sample codes on step loop processing.

http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbacac35c111d1829f0000e829fbfe/content.htm

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
1,427

The problem is that just 10 records are being displayed. I am able to scroll, but rows are just blank.

Read only

0 Likes
1,426

How the table controls works is, When ever you create the table in screen based on the size it will assign number of rows. In ur case seems like it has 10 rows.

Let say you have an internal table which has all the rows. When you execute for the first time you have to read the first 10 rows from the main internal table to another table and display the results.

When you hit the scroll bar on the screen

MODULE fill_table_control OUTPUT.

READ TABLE itab INTO demo_conn INDEX flights-current_line.

ENDMODULE.

is triggered and the current line is line 2.

So you will read from line 2 to line 11 into demo_conn and is displayed.

So basically whats hapenning is everytime you hit the scroll bar the data in demo_conn is changed based on the current line and is diaplayed.

Put a break point on line 15 of the program DEMO_DYNPRO_TABCONT_LOOP and look it ur self in the debug mode.

Shreekant

Read only

0 Likes
1,426

Thanks Everyone!!!

Just found a bug & fixed it...