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: Computing values(columns) from different Database

Former Member
0 Kudos

Hi masters so i want to get different columns from different database and compute them but in my Module Data_Retrieve i don't know how to exactly get the respective columns they all have common pk:id for their values but once i call them i can't seem to get the values of the columns of the different tables

ex

table 1-Name | table1-quarter1 | table 2 - quarter2 | table 3 -quarter3 | table 4 - quarter4| Total |

      Josh       |          55          |             2           |             7          |        3              |    67  |  

9 REPLIES 9

deepak_sharma_sap
Active Participant
0 Kudos

Hi Joshua,

Can you please explain the issue in more details.

Thanks

Deepak

0 Kudos

uhm yes so i have for example a student list it is connected to four database which is 1st 2nd 3rd and 4th quarter .... now i want to compute the column "TotalGrade" which the 4 tables has and (add the 1st - TotalGrade 2nd - TotalGrade 3rd - TotalGrade 4th - TotalGrade) .... and also has a similar structure so looping at a single IT isn't a problem .... but the 1st 2nd 3rd and 4th quarter "Total Grade" won't appear in the data retrieval of the table control don't really know how to do it

so basically i want the column of the

Student_Names-zstudentnames *from database

TotalGrade_zfirstquarter *from database

TotalGrade_zsecondquarter *from database

TotalGrade_zthirdquarter *from database

TotalGrade_zfourthquarter *from database

FinalGrade - *user Defined I/O inside the Table control.


it's a bit hard to explain basically it's just adding 4 quarters and showing the 4 fields in the tablecontrol

0 Kudos

I assume you have four tables with following structure: ID, NAME, GRADE

Whereby you have for each quarter a table.

And now you want the following result structure:

NAME, GRADE_Q1, GRADE_Q2, GRADE_Q3, GRADE_Q4, TOTAL

Further I assume TOTAL should be the average value of all the GRADEs.

I would select the data with a SQL-Statement. Maybe it's also possible to calculate the TOTAL field (I didn't try it yet), depending on your Netweaver release.

Example:

SELECT tab1~name, tab1~grade AS grade_q1, tab2~grade AS grade_q2, tab3~grade AS grade_q3, tab4~grade AS grade_q4, ( tab1~grade + tab2~grade + tab3~grade + tab4~grade ) / 4 AS total FROM tab1 INNER JOIN tab2 ON tab1~id = tab2~id INNER JOIN tab3 ON tab1~id = tab3~id INNER JOIN tab4 ON tab1~id = tab4~id INTO TABLE @data(lt_result).

As mentioned before, I've not tried the part "( tab1~grade + tab2~grade + tab3~grade + tab4~grade ) / 4" for TOTAL. Possibility it works on your release. If not, you have to calculate it afterwards.

Hint: If I recognized your case correctly, I have to say that it is a bad ER-Model you use.

0 Kudos

yes sir .. well im still trying to learn only been 3 weeks but i know my ER is really bad ... hmm yes that's the idea but im trying to do it in a table control i did the same query of inner join but it only populated 1 field since i have 5 fields in the table control including the Total.

Oh and my mistake on the 1st post the  StudenList isn't in the same table as 1stquarter

5 database

zstudentnames = Student List / subject (connected to zsubjectgrading ) / section (connected to zsectiongrading) etc...

zfirstquarter = Records Quiz / exam etc..

zsecondquarter = Records Quiz / exam etc..

zthirdquarter = Records Quiz / exam etc..

zfourthquarter =  Records Quiz / exam etc..

0 Kudos

If you are taking a class then why don't you ask the trainer this question? Also if you have access to an SAP system, why don't you simply look at an existing screen in SAP to see how it's done there? Do you not have a book or training material with some examples? Have you tried to analyze at all what the problem could be?

0 Kudos

hmm yes i only took 1 week training kinda like an open house event and been kinda interested in it ever since  and i want to do a simple grading system if it will work efficiently with this programming language. like i said looping at table control can only have one populate screen in the flow logic but i'm trying to populate from 5 different database in the table control looping at the flow logic to populate more than 1 that corresponds the database table but defining more than one will give an error ... most of the the things that were taught in that event was pretty much basic call functions/alv/table etc.. weren't included much .. hmm if i did not analyze the question i wouldn't be asking this thing like i said TABLE Control Populate Module can only hold one WA moving/displaying it to the  corresponding fields of the ztable ..

0 Kudos

To use the single table control I suggest to use a structure. Define it as you need it for your table control. You can use it also with the TABLES statement. At a certain point of time you select the data through the SELECT with the JOINS into an internal table with the line type of your new structure.

0 Kudos

It does not matter whether the data comes from 1 table or 25. All you need to do is read it and put the data into the right variable. Table control might be not the simplest thing to comprehend in ABAP but there is wizard available. Filling in the generated code requires only simple understanding of internal tables, structures and variables in ABAP. I suspect you might still have difficulty understanding those basic concepts, so it might be a better idea to start with a simpler program.

Make sure to use Google: "ABAP table control example site:sap.com" finds tons of posts.

Building custom old-fashioned screens (called "dynpro" in ABAP) is not a very popular task already as they are becoming obsolete. I haven't used table controls since 2006 or so. You might be better off looking into an editable ALV instead. There are many posts on that as well.

0 Kudos

yeah i can but generating the values will the problem cause the statement line for it will be

IF sy-stepl = 1.

     <controler>-lines =  <controler>-top_line + sy-loopc - 1.

   ENDIF.

   MOVE-CORRESPONDING <workarea> TO <data structure>.

so will the structure really work when it's using database as a reference to populate the screen