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 display data in Table control?

Former Member
0 Kudos

Hi Experts,

Can anyone please explain me how to display the data from two different tables(those two table is related with 1 field) into a single table control?

For Example: T1 has fields (F1,F2) and

T2 has fields (F3,F4) --> here F3 is foreign key for F1

I need to display the data F1,F2,F3,F4 into the table control.

Can anyone explain me?

Thanks in Advance,

Regards,

Raghu

5 REPLIES 5

Former Member
0 Kudos

Hi,

If F3 is foreign key for F1, then both fields will have same values. Then why do you need to display both F1 and F3? Either one of them is enough. Try the following code.

types: begin of t_table,

F1 type T1-F1,

F2 type T1-F2,

F4 type T2-F4,

end of t_table.

data: i_table type standard table of t_table with header line.

select F1 F2 F4 into table i_table from T1 inner join T2 on T1F1 = T2F3.

You should create three columns in the table control with names i_table-F1, i_table-F2, i_table-F3.

After populating the internal table, refresh the control with the following statement.

REFRESH CONTROL <NAME> FROM SCREEN <SCREEN_NO>.

All the above statements should be in your PBO Module.

Regards,

Hema

Message was edited by:

Sorry, Declarations can be in the common include. Select statement and refresh statement should be in PBO.

Hema Nagarajan

0 Kudos

Hi Hema,

Really cool answer from you.Sorry for the late reply becoz I need to implement and then only confirm here.So why I replied late.Anyway among I like your answer for this particular question.

And I need to know Can I use simply "JOIN" instead of "INNER JOIN"? Whats the difference between those?

And another point can I use the select statement here as a loop? (Becoz if my internal table fields is not similar to database table then I can use "CORRESPONDING FIELDS OF <INTERNAL TABLE NAME>") or how can I the "CORRESPONDING FIELDS OF <INTERNAL TABLE NAME>" in the select statement u said?

Once a again thanks for good answer.

0 Kudos

Hi,

Generally INNER JOIN is used. Better to follow standards. Infact, I worked mostly in Oracle, in Oracle we don't use word join at all.

It is better to avoid SELECT....ENDSELECT constructs in the programs unless tables are buffered tables by default and have less number of records.

INTO CORRESPONDING FIELDS is also one of the statements that can reduce performance.

Since you are working with internal table, declare internal table with fields that you require and use INTO TABLE clause.

If you are declaring internal table with reference to database table, if table is with less number of fields use * INTO TABLE in the select statement. But add only those columns in the table control in the screen that you require to display.

If your database table has say, 20+ columns, always declare internal table and use it with INTO TABLE clause in the select statement.

Hope I cleared your doubt.

Regards,

Hema

0 Kudos

Hi Hema,

Thanks for your prompt reply.

Regards,

Raghuraman.K

Former Member
0 Kudos

hi,

First merge these two tables into one table, and then use thatone into tablecontrol for diplaying purpose.

thanks

Dharmishta