Application Development 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: 

Table control in ABAP - beginner

amber_garg
Active Participant
0 Kudos

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

Former Member
0 Kudos

Hi

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

Make it using get from program

17 REPLIES 17

frank_zoor3
Explorer
0 Kudos

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

0 Kudos

@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

0 Kudos

Hi,

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

0 Kudos

I tried in debug mode , itab is fetching values correctly

0 Kudos

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

0 Kudos

@ 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

Former Member
0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

Hi

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

Make it using get from program

0 Kudos

@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

0 Kudos

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.

0 Kudos

Thanks Akanksha and others. It worked

0 Kudos

Great

0 Kudos

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

0 Kudos

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.

0 Kudos

Thanks

0 Kudos

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 .