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: 

how to show data through table control

Former Member
0 Kudos
3,036

Hi Experts,

I have created an table control through wizard using table EKKO.

I have to populate one internal table( type ekko ), and then show it in output through table control.

Please advise, how to do that and in where i have to write the codes.

I will reward points for every suggestion

Thanks in advance.

regards

1 ACCEPTED SOLUTION

gopi_narendra
Active Contributor
0 Kudos
273

Check these programs

demo_dynpro_tabcont_loop

demo_dynpro_tabcont_loop_at

You will have a better idea on table controls.

Regards

Gopi

7 REPLIES 7

gopi_narendra
Active Contributor
0 Kudos
274

Check these programs

demo_dynpro_tabcont_loop

demo_dynpro_tabcont_loop_at

You will have a better idea on table controls.

Regards

Gopi

Former Member
0 Kudos
273

hi saubrab,

This is kiran kumar.G.I am sending some sample code to populate data into table control check it once.

i will give input in 100 screen. and display table control in 200 screen.check it once once ..ok....

SE38 :(CODE)

&----


*& Module pool YMODULEPOOL_TABLECONTROL1 *

*& *

&----


*& DEVELOPER : KIRAN KUMAR.G *

*& PURPOSE : TABLE CONTROL DEMO *

*& CREATION DT : 17/12/2007 *

*& T.CODE : YMODTABLECONTROL1 *

*& REQUEST : ERPK900035 *

&----


PROGRAM ymodulepool_tablecontrol1.

----


  • Tables

----


TABLES: yvbap, "Sales Document: Item Data

vbak. "Sales Document: Header Data

----


  • Controls

----


CONTROLS: my_table TYPE TABLEVIEW USING SCREEN 200.

----


  • Global Variables

----


DATA: gv_lines TYPE i,

gv_lines1 type i,

gv_temp type i,

gv_flag(20) TYPE c VALUE 'DISP',

gv_mode1 TYPE c,

gv_mode TYPE c VALUE 'C'. " C: Change, D :Display

----


  • Internal Table

----


DATA: BEGIN OF gt_item OCCURS 0,

vbeln LIKE vbap-vbeln, "Sales Document Number

posnr LIKE vbap-posnr, "Sales Document Item

matnr LIKE vbap-matnr, "Material Number

matkl LIKE vbap-matkl, "Material Group

arktx LIKE vbap-arktx, "Short Text for Sales Order Item

cflag, "Deletion Indicator

END OF gt_item.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'ZTABLECONTROL' OF PROGRAM 'YMODULEPOOL_TABLECONTROL'.

  • SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

CASE sy-ucomm.

WHEN 'DISP'.

SELECT single vbeln

erdat

angdt

bnddt

FROM vbak

INTO (vbak-vbeln,vbak-erdat,

vbak-angdt,vbak-bnddt)

WHERE vbeln = vbak-vbeln.

IF sy-subrc EQ 0.

*Fetch the table control data and place them in Internal Table

SELECT vbeln

posnr

matnr

matkl

arktx

FROM yvbap

INTO TABLE gt_item

WHERE vbeln = vbak-vbeln.

IF sy-subrc EQ 0.

*NO OF line in the Internal Table

DESCRIBE TABLE gt_item LINES gv_lines.

my_table-lines = gv_lines + 20.

ENDIF.

ENDIF.

*Call Screen 200.

SET SCREEN 200.

WHEN 'EXIT' OR 'BACK' OR 'CANCEL'.

*Exit from the Program

CALL TRANSACTION 'SESSION_MANAGER'.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

module STATUS_0200 output.

SET PF-STATUS 'ZTABLECONTROL1'.

endmodule. " STATUS_0200 OUTPU

&----


*& Module copy_data OUTPUT

&----


  • text

----


module copy_data output.

*Fetch the current line data from the Table control

read table gt_item index my_table-current_line.

if sy-subrc eq 0.

*Populating data into screen fields

gt_item-vbeln = gt_item-vbeln.

gt_item-posnr = gt_item-posnr.

gt_item-matnr = gt_item-matnr.

gt_item-matkl = gt_item-matkl.

gt_item-arktx = gt_item-arktx.

endif.

SE51:CODE (SCREEN 100)

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.

SE51 :CODE (SCREEN 200)

PROCESS BEFORE OUTPUT.

MODULE STATUS_0200.

loop at gt_item with control my_table cursor my_table-current_line.

module copy_data.

endloop.

PROCESS AFTER INPUT.

loop at gt_item.

MODULE USER_COMMAND_0200.

endloop.

HAVE A NICE DAY..

Award points if helpful,kiran kumar.G

Kanagaraja_L
Active Contributor
0 Kudos
273

Former Member
0 Kudos
273

Hi,

we can create tablecontrol of a particular fields in EKKO table.

we select that fields in dictionary and design that table control. we activate and save the layout.

for this layout we have a flow logic.

for that flow logic we have a PBO,PAI.

in this we write the code for table control.

in top include we write the logic for tablecontrol.

To handle table controls in ABAP programs, you must declare a control in the declaration part of the program for each table control using the following statement:

CONTROLS <ctrl> TYPE TABLEVIEW USING SCREEN <scr>.

where <ctrl> is the name of the table control on a screen in the ABAP program. The control allows the ABAP program to read the attributes of the table control and to influence the control. The statement also declares a deep structure of name <ctl>. The data type of the structure corresponds to the type CXTAB_CONTROL defined in the type group CXTAB in the ABAP Dictionary.

At runtime the components of the structure contain the attributes of the table control. Several of the initial values are determined in the Screen Painter. The initial value for the control <ctl> is taken from the screen which is determined using the addition USING.

If you write the statement

REFRESH CONTROL <ctrl> FROM SCREEN <scr>.

you can initialize a table control at any time with the initial value of a screen <scr>. Values that are not taken from the settings in the Screen Painter, are set to the current status of the table control at PAI.

The following statement loops through an internal table and a screen table in parallel.

LOOP AT <internal table>.

In particular, LOOP AT loops through the portion of the internal table that is currently visible in the screen. You can use this form of the LOOP statement for both table controls and step loops.

The complete syntax for this form of the LOOP statement is:

LOOP AT <internal table> CURSOR <scroll-var>

[WITH CONTROL <table-control> ]

[FROM <line1> ] [TO <line2> ].

...<actions>...

ENDLOOP.

This form of LOOP loops through the internal table, performing <actions> for each row. For each internal table row, the system transfers the relevant program fields to or from the corresponding screen table row.

When using step loops, omit the CURSOR parameter in the PAI event. The FROM and TO parameters are only possible with step loops. (For further information, refer to Using Step Loops.) The WITH CONTROL parameter is only for use with table controls

please reward points if it useful.

Regards,

satish.

Former Member
0 Kudos
273

hi

good

go through this link, hope this would help you to solve your problem

http://sap.niraj.tripod.com/id29.html

thanks

mrutyun^

Former Member
0 Kudos
273

Hi Saurabh,

TABLE CONTROL

These are the screen elements used to display tabular data they can be called

as screen tables( like STEP LOOP).To use table control we have to create it on the screen using SCREEN PAINTER(SE51) and declare a control variable of TYPE TABLEVIEW using CONTROLS statement in the ABAP program. We have to use LOOP .. ENDLOOP statement in both PBO and PAI with or without AT int_table parameter. IF AT int_table parameter is not used than we have to place a MODULE call between the LOOP...ENDLOOP statement to fill the screen table rows from the ABAP program in PBO and program our own scrolling functions

using OK_CODE field.

Having a parallel loop(at screen table rows & int table rows) by using parameter

AT int_table makes the ABAP code simple.

A special structure of type CXTAB_CONTROL is used to set/get various

attributes of table control at runtime like CURRENT_LINE ,TOP_LINE.

ABAP declaration

CONTROLS: tab_con TYPE TABLEVIEW USING SCREEN nnnn

Here tab_con is the same name we used in screen for the table control.

This ABAP statement will declare a control variable that will be used to access

the table control , and set it's various attributes like number of fixed columns(tab_con-FIXED_COLS) ,total number of records it will display(tab_con-LINES).It is of type CXTAB_CONTROL and is a deep structure(structure containing structures).

REFRESH CONTROL tab_con FROM SCREEN nnnn

This ABAP statement will initialize the table control on the screen nnnn to its initial values.

PBO processing

In PBO we have to use the screen LOOP ...ENDLOOP statement , with or without

intenal table.

LOOP WITH CONTROL tab_con.

MODULE fill_tab_con.

ENDLOOP.

Here a module should be called between the loop endloop statement to transfer

data from th ABAP program to the screen table through a structure.This module

should use the CURRENT_LINE attribute of the table control variable to get the

current screen table record index to read the data from the internal table into a work area.

e.g.

READ TABLE int_table INDEX tab_con-CURRENT_LINE

The record read will be placed in the header line of the internal table and will be available to the similarly named screen fields or if these are different it can be written explicitly. e.g.

screen_field_name = int_table-field_name

...

.

LOOP AT int_table INTO workarea WITH CONTROL tab_con CURSOR i FROM

n1 TO n2.

ENDLOOP.

Here the module call is not required to fill the screen table.The CURSOR parameter is a integer of type I indicating which absolute internal table line

should be the first to display on the table control .FROM n1 TO n2 can be used

to restrict the starting line and ending line number of the internal table , they are of type SY-TABIX.

In both cases before the LOOP statement a module should be called which

is generally for setting of status ,in which we should fill the LINES attribute

(tab_con-LINES ) of the control with the total number of internal table records,doing this ensures correct and automatic scrolling.

The ABAP statement DESCRIBE TABLE int_table LINES lines can be used

to get the total lines in an int table.

PAI Processing

We have to use LOOP ... ENDLOOP in PAI so that data can transfer fro table control to ABAP program. If we want to write changes to the data we should

call a module between the LOOP ... ENDLOOP. The MODULE call to process user commands (SY-UCOM) should be called after the ENDLOOP statement.

e.g.

PROCESS AFTER INPUT

MODULE mod AT EXIT-COMMAND.

LOOP AT itab_table or LOOP "depending on whether we are using AT int_table

MODULE modify_int_table.

ENDLOOP.

MODULE user_command.

In the MODULE call modify_int_table we can use

MODIFY int_table FROM workarea INDEX tab_con-CURRENT_LINE

or we can use

int_table-field_name = screen_field_name.

Regards,

Chandru

Former Member
0 Kudos
273

Thanks.

Its a great help from you all.

All replies had cleared many of my doubts