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 ABAP - beginner

abaper_guy
Active Participant
0 Likes
2,000

I am not able to fill data from database in TABLE CONTROL.The table is displayed with columns(which i added in layout using dict option) but on runtime there is no data in it.I am trying this for the first time so kindly guide me.

Here is PBO and PAI code.

PROCESS BEFORE OUTPUT.
 LOOP AT ITAB WITH CONTROL EMPTABLE CURSOR EMPTABLE-CURRENT_LINE.
  
 ENDLOOP.
 MODULE STATUS_0001.
*
PROCESS AFTER INPUT.
 LOOP AT ITAB.
 ENDLOOP.
 MODULE USER_COMMAND_0001.

And here is Main Code.

REPORT  ZDATA_FORM1.

TABLES: ZEMPLOYEE_MASTER.

CONTROLS EMPTABLE TYPE TABLEVIEW USING SCREEN 0001.

data: begin of itab occurs 0,
       emp_no like zemployee_master-emp_no,
       name like zemployee_master-name,
       city like zemployee_master-city,
      end of itab.

select emp_no name city from zemployee_master into table itab.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0001  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0001 OUTPUT.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_0001  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0001 INPUT.
 CASE SY-UCOMM.
   WHEN 'EXIT'.
     LEAVE PROGRAM.
 ENDCASE.
ENDMODULE.                 " USER_COMMAND_0001  INPUT

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,957

Hi

How have you made fields on table control using Get from program or get from dictionary ?

Make it using get from program

I am not able to fill data from database in TABLE CONTROL.The table is displayed with columns(which i added in layout using dict option) but on runtime there is no data in it.I am trying this for the first time so kindly guide me.

Here is PBO and PAI code.

PROCESS BEFORE OUTPUT.
 LOOP AT ITAB WITH CONTROL EMPTABLE CURSOR EMPTABLE-CURRENT_LINE.
  
 ENDLOOP.
 MODULE STATUS_0001.
*
PROCESS AFTER INPUT.
 LOOP AT ITAB.
 ENDLOOP.
 MODULE USER_COMMAND_0001.

And here is Main Code.

REPORT  ZDATA_FORM1.

TABLES: ZEMPLOYEE_MASTER.

CONTROLS EMPTABLE TYPE TABLEVIEW USING SCREEN 0001.

data: begin of itab occurs 0,
       emp_no like zemployee_master-emp_no,
       name like zemployee_master-name,
       city like zemployee_master-city,
      end of itab.

select emp_no name city from zemployee_master into table itab.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0001  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0001 OUTPUT.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_0001  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0001 INPUT.
 CASE SY-UCOMM.
   WHEN 'EXIT'.
     LEAVE PROGRAM.
 ENDCASE.
ENDMODULE.                 " USER_COMMAND_0001  INPUT

17 REPLIES 17
Read only

frank_zoor3
Explorer
0 Likes
1,957

Hi,

e.g. directly after line "PROCESS BEFORE OUTPUT" and before line "LOOP AT..." implement a module "MODULE set_data".

Within this module select your information from dtab and fill your <table-control-itab> with lines...

Basically, move your select-statement from report ZDATA_FORM1 to the PBO section of your screen!

Kind regards

Frank

Read only

0 Likes
1,957

@Frank : I did exactly the way u said but still the table does not show any data. I checked in the database table , the records are there

Read only

0 Likes
1,957

Hi,

You check in debug mode that itab got entries or not.

Read only

0 Likes
1,957

I tried in debug mode , itab is fetching values correctly

Read only

0 Likes
1,957

How is the setup of your table-contlol columns and fields? (active, input, output, invisible)

Do you "MODIFY SCREEN" anything?

Have also a look into report "RSDEMO02"... Good example!

Good Luck

Frank

Edited by: Frank Zoor on May 9, 2011 3:34 PM

Read only

0 Likes
1,957

@ Frank : All properties are default only.I m not using MODIFY SCREEN either . I have just an EXIT button and a table control and whatever code i have written above is all what i have written in my program.

I wil try to look into the example code u have given.Till then if you have any suggestions please let me know

THANKS

Read only

Former Member
0 Likes
1,957

Hi,

1. Check wether entries are there in itab.

2. table control column name should be as below

itab-emp_no

itab-name.

3. set table control property as below

EMPTABLE-lines = 10.

notes: 10 is number of lines in itab

Read only

0 Likes
1,957

Hi,

Please check the below code, MODULE should be in between Loop and End loop.

PROCESS BEFORE OUTPUT.

LOOP AT ITAB WITH CONTROL EMPTABLE CURSOR EMPTABLE-CURRENT_LINE.

MODULE STATUS_0001.

ENDLOOP.

*

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0001.

LOOP AT ITAB.

ENDLOOP.

Thanks,

Sriram.

Read only

Former Member
0 Likes
1,958

Hi

How have you made fields on table control using Get from program or get from dictionary ?

Make it using get from program

Read only

0 Likes
1,957

@Akanksha : Thanks for your reply. I m using get from dict because i actually want to get the fields automatically from data dict. I m sure there must be a way to bring data into the table control by "getting fields from dict".

THANKS a lot

Read only

0 Likes
1,957

Yes, You can do it with dictionary also

use this statement instead of your statement in flow logic :---

LOOP at <internal-table name> into < dictionary table name > WITH CONTROL <table control name>.

ENDLOOP.

Read only

0 Likes
1,957

Thanks Akanksha and others. It worked

Read only

0 Likes
1,957

Great

Read only

0 Likes
1,957

Just 1 more problem. There are some 20 records in the database.But in the table control only some 7 are shown and there is no vertical scrollbar to show the remaining records. (Although there is a horizontal scrollbar which works fine).

THANKS

Read only

0 Likes
1,957

Hi,

You have to pass the number of lines of data in the table control to the LINES attribute of table control.

Try this:

DESCRIBE TABLE <internal table name> LINES <table control name>-lines.

Regards,

rahul Muraleedharan.

Read only

0 Likes
1,957

Thanks

Read only

0 Likes
1,957

Do two things:-

1. check the Resizing option in table control properties (horizontal and vertical)

2 add this code

< table_control_namel-v_scroll = 'X'.

DESCRIBE TABLE <internal table>.

< table_control_name>-lines = sy-tfill .