02-08-2013 8:55 AM
I am very much new to ABAP, kindly help me in the following issue -
I want to display the count of records of values selected from selection screen in an ALV.
EX : I want to use select options to get CARRID from SFLIGHT table and display the count of values obtained for that CARRID in an ALV
CARRID : AA
No.of Records : 50
Please help me with the code in OOPS concepts...
Moderator Message: Unmarked as question due to its basic nature. Please try to search in SCN before posting.
Message was edited by: Kesavadas Thekkillath
02-08-2013 9:00 AM
Hi,
one of the most common question
so, put a column "count" with "1" at each line
sum the line
and make a intermediate sum in the column CARRID
Fred
02-08-2013 9:07 AM
Kindly help me with a sample code....with the exact fields. Please post the code snippet and which works......also the ALV display in OOPS concepts....
02-08-2013 9:21 AM
Hi,
Hope you have completed the rest of the report correctly. In the fieldcatalog of carrid add the following line.
ls_fieldcat-do_sum = 'X'.
When you will add this parameter it show automatically show you the sum at the end.
If you face any issues, do let us know.
Regards
Purnand
02-08-2013 10:22 AM
hi,
I have actually did all the select statements and got the records.....What i require is the count of the records.
From SFLIGHT table i want to fetch CARRID's in selection screen using SELECT-OPTIONS.
Then for these CARRID's i have obtained.......I want to display the no:of records available for each CARRID in an ALV.
ex : CARRID : AA,AZ,LH *This in selection screen
AA - 30 * These should be shown in an ALV
AZ - 40
LH - 36
Kindly send me a code Snippet which works for this requirement.
Regards,
Hari
02-08-2013 9:33 AM
Hi Hari,
Are you asking the total number of records after fetching from the table.
This is what i understood from your question.If yes, you can use the "Describe table" statement to achieve the same.
Thanks.
02-08-2013 10:24 AM
From SFLIGHT table i want to fetch CARRID's in selection screen using SELECT-OPTIONS.
Then for these CARRID's i have obtained.......I want to display the no:of records available for each CARRID in an ALV.
ex : CARRID : AA,AZ,LH *This in selection screen
AA - 30 * These should be shown in an ALV
AZ - 40
LH - 36
Kindly send me a code Snippet which works for this requirement.
Regards,
Hari
02-08-2013 10:44 AM
Hi hari,
After fetching all the records into an internal table, sort the internal table by "Carrid".
Loop at the internal table and by using if or while statement you can put some logic to count the records.
For example, if the records are in internal table IT, then loop at this and count the number of records according to carrid.
sort it by carrid.
loop at it into wa.
if wa-carrid = 'AA'.
cnt_aa = cnt_aa + 1.
elseif wa-carrid = 'AZ'.
cnt_az = cnt_az + 1.
endif.
endloop.
The variables cnt_aa will hold the total number of records for carrid "AA" and variable cnt_az will hold for carrid "AZ.
This logic should work.
Hope this helps.
Thanks.
02-08-2013 9:43 AM
Hi,
create the container and try the below code.
tables:mara.
data: g_alv1 TYPE REF TO cl_gui_alv_grid,
c_cont1 TYPE REF TO cl_gui_custom_container.
data: it_fieldcat TYPE lvc_t_fcat ,
ty_fieldcat TYPE lvc_s_fcat ,
it_mara type table of mara,
wa_mara like line of it_mara.
select-options:s_matnr for mara-matnr.
start-of-selection.
select * from mara into it_mara
where matnr in s_matnr.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module pbo_100 OUTPUT
*&---------------------------------------------------------------------*
MODULE pbo_100 OUTPUT.
*set pf-status 'XXX'.
*set titlebar 'XXX'.
ENDMODULE. " PBO_100 OUTPUT
*&---------------------------------------------------------------------*
*& Module alv_100 OUTPUT
*&---------------------------------------------------------------------*
MODULE alv_100 OUTPUT.
*Check if there is no custom container in screen 100
IF c_cont1 IS INITIAL.
*Creating object of container
CREATE OBJECT c_cont1
EXPORTING
container_name = 'CCONT'.
*Creating object of alv
CREATE OBJECT g_alv1
EXPORTING
i_parent = c_cont1.
ENDIF.
data:lv_count type i.
*- count the total no of records going to display
describe the it_mara lines into lv_count.
*Displaying the ALV grid
CALL METHOD c_alv1->set_table_for_first_display
EXPORTING
is_layout = ty_lay1
CHANGING
it_outtab = it_mara
structure = mara.
for more help check this linke http://scn.sap.com/thread/144338.
Regards,
Gurunath kumar D