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

ALV report using custom table

Former Member
0 Likes
4,390

i have small dought, that is i created custom table with 3 fields

                             

                      lowpercentage   high.per    user
                            1                  10            GM
                          11                 25             CFO    

                          26                99999999   MD
--

        Like this i prepared.
  my dought is Iam storing the percentage value WA_FINAL-PERCENTAGE in this work area, and then i add the column in ALV grid column Name is 'CHANGED BY' in that column i want to display Who is changed by Throgh reffer the custom table(above table).
                          percentage      changed by
                             11        %             GM
                             45.32%                  MD    like that i want to display out put screen.

how to display the alv output screen.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,589

Please try this.

data: itab type table of <custom table>,

          wa like line of itab.

data : lv_percentage. " Your value wa_final-percentage.

select * from custom table into itab.

loop at itab into wa.

IF lv_percentage between wa-lowerpercentage AND wa-high.per.

write  : wa-user.

endif.

endloop.

Hope it solves your issue.

Regards,

J. Rajbarath

12 REPLIES 12
Read only

satyabrata_sahoo3
Contributor
0 Likes
2,589

Declare the final output structure like this:

TYPESBEGIN OF ty_final.

         INCLUDE STRUCTURE <custom table>.

TYPES: percentage TYPE i,

               changed_by  TYPE bname,

            end of ty_final.

data: wa_final type ty_final.

Pass the Percentage and User to workarea field. Append to internal table.. Then Display ALV.

-SS-



Read only

Former Member
0 Likes
2,589

Hi Piya,

If you want to display the data from the workarea. if it is single record use write statement.

ex :  write : / wa-name,

                   wa-no,

                   wa-address.

if the record are more in number to dispaly, append the workarea record to the internal table and then display the data using the function module ALV_GRID_DISPLAY.

Thanks.

Pavan.

Read only

Former Member
0 Likes
2,589

Hi Priya,

take the final table inbelow type :

TYPES: BEGIN OF TY_FINAL,

        PERCENTAGE TYPE CHAR20,

        USER TYPE ZUSER,

        END OF TY_FINAL.

DATA : I_FINAL TYPE STANDARD TABLE OF TY_FINAL,

        W_FINAL TYPE TY_FINAL.

NOW LOOP THE CUSTOME TABLE.

AND CONCATENATE CUSTOMATABLE-PERCENTAGE '%' INTO WA_FINAL-PERCENTAGE SEPARATED BY SPACE.

APPEN W_FINAL TO I_FINAL.

ENDLOOP.

nOW DISPLAY INTO alv ,

It will work

Thanks

Tarak

Read only

0 Likes
2,589

Hi, i knw concattenate, my dought is if percentage is 12% means i want to select the data from custom table and display the changed by column.(12% means CFO changed, so i want to display below like this).custom table already i mentioned with my first dicussion forum

    PERCENTAGE  CHANGED BY

          12                    CFO

Read only

Former Member
0 Likes
2,589

Hi,

As suggested above, store the value in the internal table and pass it to the FM 'REUSE_ALV_GRID_DISPLAY'.

Following is the sample for the fieldcatalog:

fieldcatalog-fieldname   = 'LOWER'.

   fieldcatalog-seltext_m   = 'Lower Percentage'.

   fieldcatalog-col_pos     = 1.

   fieldcatalog-row_pos     = 2.

   fieldcatalog-outputlen   = 15.

   append fieldcatalog to fieldcatalog.

   clear  fieldcatalog.

   fieldcatalog-fieldname   = 'HIGHER'.

   fieldcatalog-seltext_m   = 'Higher Percentage'.

   fieldcatalog-col_pos     = 2.

   fieldcatalog-row_pos     = 2.

   append fieldcatalog to fieldcatalog.

   clear  fieldcatalog.

fieldcatalog-fieldname   = 'USER'.

   fieldcatalog-seltext_m   = 'User'.

   fieldcatalog-col_pos     = 2.

   fieldcatalog-row_pos     = 2.

   append fieldcatalog to fieldcatalog.

   clear  fieldcatalog.

Regards

Purnand

Read only

0 Likes
2,589

i dnt want to dispaly like that

custom table dnt have the percentage, i run time we willget %, and pick the changed by value from database in custom table based up on percentage(percentage 14% means CFO).

Read only

gaurab_banerji
Active Participant
0 Likes
2,589

use the following

clear <customworkarea>.

loop at <customtable> into <customworkarea>

where lowpercentage LE <currentpercentage>

and highpercentage  GT <currentpercentage>.

exit.

endloop.

if <customworkarea> is not initial.

<changedby> = <customworkarea>-user.

endif.

hope this helps.

Read only

0 Likes
2,589

OK BUT NOT GET THE DATA FROM DATABASE

Read only

0 Likes
2,589

then that is easier

clear <username>.

select user

up to 1 rows

from <customtable>

into <username>

where lowpercentage LE <currentpercentage>

and highpercentage  GT <currentpercentage>.

endselect.

if sy-subrc = 0.

<changedby> = <username>.

endif.

Read only

0 Likes
2,589

Hello Ss priya,

if u need this database table then you have to use TMG event. select the event no 05. click on editor....

then put your logic like this:

screen-fieldname = sy-uname.

when some one created a new record or change a existing record then user name assigned.....

in Alv report,

fetch data from database table and processing......if you cant reach at TMG event then let me know......i will tell you..

Thanks

Sabyasachi

Read only

Former Member
0 Likes
2,590

Please try this.

data: itab type table of <custom table>,

          wa like line of itab.

data : lv_percentage. " Your value wa_final-percentage.

select * from custom table into itab.

loop at itab into wa.

IF lv_percentage between wa-lowerpercentage AND wa-high.per.

write  : wa-user.

endif.

endloop.

Hope it solves your issue.

Regards,

J. Rajbarath

Read only

0 Likes
2,589

THANK u,

  i got the result