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 content

Former Member
0 Likes
1,446

hello

i start with sap .i want to create a screen displaying the content of a database table.

i want to know how to do .

thinks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,409

hi karim,

welcome to sdn,

create one module pool program with screen consist of table control and two push buttons called 'DISPLAY' and 'EXIT'.

then in PAI event u can write code for Disply and Exit commands...

regards...

seshu.

14 REPLIES 14
Read only

Former Member
0 Likes
1,409

Hi Karim,

Goto se51 create a screen using layout editor.

Drag & drop a table control into it.

In PBO(Process Before Output) event of the screen write the coding.

Regds,

Younus

<b>Reward Helpful Answers!!!</b>

Read only

Peter_Inotai
Active Contributor
0 Likes
1,409

Hi,

Check transaction ABAPDOCU, you can find some example there, like program demo_select_single, which help you to play around with the system.

Peter

Read only

Former Member
0 Likes
1,409

Hi Karim,

Please refer this trans. <b>ABAPDOCU</b> - Under Processing Screens -> Screen Fields with Dictiionary Reference.

Regards,

Ramki.

Read only

Former Member
0 Likes
1,410

hi karim,

welcome to sdn,

create one module pool program with screen consist of table control and two push buttons called 'DISPLAY' and 'EXIT'.

then in PAI event u can write code for Disply and Exit commands...

regards...

seshu.

Read only

0 Likes
1,409

hi maddipatla

this is exactly what i want to do (a module pool program).

but i dont have much experience .please if you have an exemple (step by step)

thinks

Read only

0 Likes
1,409

Hi friends,

Could u please tell me how to create a module pool program to display the content of a databasetable. Please provide me step by step Process or link of file.

thinks .

Read only

0 Likes
1,409

Hi Karim ,

Here you go with the steps :

open se51, choose the icon like a table for table control . drag it and then place it in your screen . click on F6 and you will get a screen where youi need to provide the table name / field name that ( fields ) you are going to use in the screen and table control. after giving the ztable name click on get it from dictionary . you will get the list of available fields in a table. next choose the fields you wish to place in the table control , and if you want to place all fields in your table control then select every fields . after this you will get a structure which you should drag place inside the table control area .

double click on the table control , set the proper attributes, tickmark the horizontal and vertical scroll bars to appear in your TC in the screen . save , check and activate ..

following are the sample code you should follow to display datas in your table control ..

write the following code in the flow logic of the screen ............

process before output.

module tc_01_init.

loop at g_tc_01_itab

into g_tc_01_wa

with control tc_01

cursor tc_01-current_line.

module tc_01_move.

module tc_01_get_lines.

endloop.

module status_0001.

process after input.

loop at g_tc_01_itab.

chain.

field sflight-carrid.

field sflight-connid.

field sflight-fldate.

module tc_01_modify on chain-request.

endchain.

endloop.

module tc_01_user_command.

Write the following code in your Zmodulepool program !!

program z_tst_mpool_tc_01.

data: begin of l_tab_sflight occurs 10,

carrid like sflight-carrid,

connid like sflight-connid,

fldate like sflight-fldate,

end of l_tab_sflight.

tables: sflight.

types: begin of t_tc_01,

carrid like sflight-carrid,

connid like sflight-connid,

fldate like sflight-fldate,

end of t_tc_01.

data: g_tc_01_itab type t_tc_01 occurs 0,

g_tc_01_wa type t_tc_01. "work area

data: g_tc_01_copied. "copy flag

controls: tc_01 type tableview using screen 0001.

data: g_tc_01_lines like sy-loopc.

data: ok_code like sy-ucomm.

include z_tst_mpool_tc_01_pbo .

include z_tst_mpool_tc_01_pai .

include z_tst_mpool_tc_01_incl01 .

include z_tst_mpool_tc_01_status_0001.

include Z_TST_MPOOL_TC_01_PBO .

  • inside include

module tc_01_init output.

if g_tc_01_copied is initial.

select * from sflight

into corresponding fields

of table g_tc_01_itab.

g_tc_01_copied = 'X'.

refresh control 'TC_01' from screen '0001'.

endif.

endmodule.

module tc_01_move output.

move-corresponding g_tc_01_wa to sflight.

endmodule.

module tc_01_get_lines output.

g_tc_01_lines = sy-loopc.

endmodule.

Hope this helps .....

for any further clarification respond back ..

Reward if helpful

Regards,

Ranjita

Read only

0 Likes
1,409

hi ranjita .

thank u very much .but i don't know where place the codes .

because i have :

1-include_top

2-module_statut_output

3-module_user_command_input

Read only

0 Likes
1,409

karim ,

i'll tell you the general process to place the codes in module pools ..

In the XXXTOP inlcude you place all the declarations you have made as its globally available for the progarm .

In your program you have

1) inlcude_top --- place all the declarations inside the include .

2)module_statut_output -


here you place the GUI-status and titlebar for your screen .

3)module_user_command_input --- here you place operations related to user command .

for any other coding required in your program you need to create different modules and inside them you need to write the logic .

I'm placing another easier sample code with all the details , and hope this will make you understand .

Go through each sentence in details ...

In the FLOW LOGIC of your screen :

<B>process before output.</B>

module status_3000. <-- this will be present once you create yopur screen

( but you need to give the details)

loop at g_tab_con_01_itab <-- you need to write

into g_tab_con_01_wa

with control tab_con

cursor tab_con-current_line.

module tab_con_move. <-- you need to write

endloop.

<B> Process after input </B>

module exit at exit-command. (<-- you need to code for exit and cancel operations.)

  • module user_command_3000. ( system provides this but logic will be yours ( optional ) )

module clear_ok_code. ( <-- you should code )

loop at g_tab_con_01_itab. (<-- you should code )

module read_tab_con. (<-- you should write the lopgic )

endloop.

IN YOUR ABAP PROGRAM ( M TYPE ) .........

in your ABAP program you will have the top include , ok . do all the declarations there .

in the PBO of flow logic of your screen you have module status_3000, now when you double click in this module ,syst will ping you for creating of this , choose your program name and the module will be placed in your program . you should write the code there . and you shoiuld do the same thing for all the modules present in the flow logic .

Below is how its coded n look ..

IN THE ABAP Program ....

MODULE status_3000 OUTPUT.

SET PF-STATUS 'ST100'.

SET TITLEBAR 'T100'.

ENDMODULE.

module tab_con_move output.

move-corresponding g_tab_con_01_WA to sflight.

endmodule.

MODULE update_table_control INPUT.

DESCRIBE TABLE g_tab_con_01_itab LINES tab_con-lines.

ENDMODULE.

MODULE exit INPUT.

ok_code = sy-ucomm.

IF ok_code EQ 'BACK' OR ok_code EQ 'EXIT' OR ok_code EQ 'CANCEL'.

LEAVE PROGRAM .

ENDIF.

ENDMODULE.

module read_tab_con input.

*lines = sy-loopc.

READ TABLE g_tab_con_01_itab INTO g_tab_con_01_WA INDEX tab_con-current_line.

IF SY-SUBRC EQ 0.

MOVE-CORRESPONDING SFLIGHT TO g_tab_con_01_WA.

modify g_tab_con_01_itab from g_tab_con_01_WA index tab_con-current_line.

ELSE.

MOVE-CORRESPONDING SFLIGHT TO g_tab_con_01_WA.

APPEND g_tab_con_01_WA TO g_tab_con_01_itab.

ENDIF.

endmodule. " read_tab_con INPUT

module fill_tab_con output.

read table g_tab_con_01_itab into zsflight index tab_con-current_line.

endmodule.

module tab_con_get_lines output.

g_tab_con_01_lines = sy-loopc.

endmodule. " tab_con_get_lines OUTPUT

module tab_con_modify input.

move-corresponding sflight to g_tab_con_01_wa.

modify g_tab_con_01_itab

from g_tab_con_01_wa

index tab_con-current_line.

endmodule. " tab_con_modify INPUT

module clear_ok_code input.

clear ok_code.

endmodule.

Try to understand from above ... if you need further guidence,please respond ..

good luck ...

Ranjita

Read only

0 Likes
1,409

think u very much .

i will try.

Read only

0 Likes
1,409

Once you are done , do not forget to reward points for the answers in your list and mark the thread as answered ..

Regards,

Ranjita

Read only

former_member196299
Active Contributor
0 Likes
1,409

Hi Karim ,

Welcome to SDN !

There are two ways of doing this , one using tsble controls and one simply displaying the table values with some formattings !

you have got the logic in the responses ... next you can display the records of the db table in a list , for that , write a select querry for getting all the data from the db table ,populate it to a itab . loop at the itab and then write them using some formattings like uline and vline ... you can display the db table data on your list ...

Reward if helpful !

Regards,

Ranjita

Read only

Former Member
0 Likes
1,409

u can use (Notice that Example programs were underlined.)

1) <b>Table Controls</b>

Table Control with LOOP - ENDLOOP - <u>demo_dynpro_tabcont_loop</u>

PBO.

flights-lines = fill. "DESCRIBE TABLE itab LINES fill.

LOOP WITH CONTROL FLIGHTS.

READ TABLE itab INTO demo_conn INDEX flights-current_line.

ENDLOOP.

PAI.

LOOP WITH CONTROL FLIGHTS.

lines = sy-loopc.

MODIFY itab FROM demo_conn INDEX flights-current_line.

ENDLOOP.

Table Control with LOOP AT ITAB - <u>demo_dynpro_tabcont_loop_at</u>

Table Control Modificatinos

PBO.

flights-lines = fill. "DESCRIBE TABLE itab LINES fill.

LOOP AT ITAB INTO DEMO_CONN WITH CONTROL FLIGHTS.

ENDLOOP.

PAI.

LOOP AT ITAB.

MODIFY itab FROM demo_conn INDEX flights-current_line.

ENDLOOP.

2) <b>Step loops.</b>

Step Loop - <u>demo_dynpro_step_loop</u>

PBO.

LOOP.

idx = sy-stepl + line.

READ TABLE itab INTO wa INDEX idx.

ENDLOOP.

PAI.

LOOP.

lines = sy-loopc.

idx = sy-stepl + line.

MODIFY itab FROM wa INDEX idx.

ENDLOOP.

3) <b>ALV Grid(using FM Reuse_alv_List_Display)</b>

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid.htm

4) <b>ALV Grid(using FM Reuse_alv_Grid_Display)</b>

http://www.sapdevelopment.co.uk/reporting/alv/alvlist.htm

5) <b>ALV Grid(Using ABAP Objects, class CL_GUI_ALV_GRID)</b>

<u>DEMO_ABAP_OBJECTS_CONTROLS

DEMO_ABAP_OBJECTS_SPLIT_SCREEN</u>

Hope this will solve ur problem..

<b><u>Dont forget to reward all the useful replies</u></b>

Sudheer

Read only

0 Likes
1,409

Hi Karim,

Assuming you know how to create a screen.

In the screen layout there is a button called Dictionary/Program Fields Window (F6), click on that and enter the table same.

Select the fields to be displayed on scree.

Save and activate.

Thanks & Regards

Sastry