2008 Jul 29 7:42 AM
hi,
i have 5 fields in my internal table to display.(date n1 n2 n3 n4 n5)
n1 n2... are basically counters.
i am getting records like this 200807 1 0 0 0 0.
i may get the similar records.
but finaly i need to disply the total count i.e if i have 2 records output will be 200807 2 0 0 0 0.
please help me in this issue..
pradeep
2008 Jul 29 7:48 AM
Hi,
you can implement your alv with sub totals on date field then all the corresponding values have been added and displayed in the sub totals column. For this you can create one work area of type 'slis_sortinfo_alv' and internal table of type SLIS_T_SORTINFO_ALV
then
gx_sort-fieldname = 'DATE'.
gx_sort-up = 'X'.
gx_sort-subtot = 'X'.
APPEND gx_sort TO gt_sort.
Before do this make sure that you have to pass 'X' to the do_sum field in the field catelog for the corresponding field.
and pass this gt_sort to the corresponding it_sort of the import parameter of the FM.
Regards,
Bujji
hi,
i have 5 fields in my internal table to display.(date n1 n2 n3 n4 n5)
n1 n2... are basically counters.
i am getting records like this 200807 1 0 0 0 0.
i may get the similar records.
but finaly i need to disply the total count i.e if i have 2 records output will be 200807 2 0 0 0 0.
please help me in this issue..
pradeep
2008 Jul 29 7:45 AM
Hi,
1. sort your table by field 2 ascending
2. use describe table to get the number of records in table
3. retrieve the last record.
here is an example
SORT itab BY n2.
DESCRIBE TABLE itab LINES ld_lines.
READ TABLE itab INDEX ld_lines.
regards,
Peter
2008 Jul 29 7:48 AM
Hi,
you can implement your alv with sub totals on date field then all the corresponding values have been added and displayed in the sub totals column. For this you can create one work area of type 'slis_sortinfo_alv' and internal table of type SLIS_T_SORTINFO_ALV
then
gx_sort-fieldname = 'DATE'.
gx_sort-up = 'X'.
gx_sort-subtot = 'X'.
APPEND gx_sort TO gt_sort.
Before do this make sure that you have to pass 'X' to the do_sum field in the field catelog for the corresponding field.
and pass this gt_sort to the corresponding it_sort of the import parameter of the FM.
Regards,
Bujji
2008 Jul 29 7:49 AM
before passing the internal table to reuse_alv_grid_dispaly
do this
describe table itab lines v_line.
loop at itab
itab-n1 = v_line
itab-n2 = sy-tabix
modify itab
endloop
try with this, reward points if helpful
2008 Jul 29 7:49 AM
2008 Jul 29 8:11 AM
Hi Guys,
I think the requirement of pradeep is to print a counter in the 2nd column of the ALV. It is not to print when it reaches a certain number.
Regards,
Sai
2008 Jul 29 8:19 AM
Hi Pradeep,
here in the situation what u can do is...
1: loop at the internal table and check for the same records if u get same records on particular field then append those into new internal table suppose itab1 and rest of the records into another itab2.
2: use collect statement on itab1.
3: finally merge the two tables itab1 after collect and itab2 into final_itab and then pass it to FM.
Thanks & Regards
Ashu Singh.
2008 Jul 29 10:45 AM
hi,
can u plesae explain how to merge the 2 internal table....
2008 Jul 29 11:28 AM
Hi Pradeep,
You do in the following way...
suppose u have data in itab .... now what u do is declare itab1 like itab and also declare wa for itab1...
loop at itab into wa.
wa1-name = wa-name.
wa1-address = wa-address.
wa1-dob = wa-dob.
wa1-salary = wa-salary.
collect wa1 into itab1.
here is the small example i have given... now u have the itab1 in which u have records which have common as u told as well as uncommon records.
Just use this logic and i m sure u will get the solution
Thanks & Regards
Ashu Singh.
2008 Jul 29 11:10 AM
Hi,
--sort internal table on date descending order
--read each record and check with next record if it matches increase counter otherwise update another intrnal table to display in ALV.
Refer below code:-
TABLES ZAP_COUNT.
DATA : BEGIN OF ITAB OCCURS 0,
L_DATE LIKE ZAP_COUNT-L_DATE,
N1 LIKE ZAP_COUNT-N1,
END OF ITAB.
.
DATA: N1 TYPE ZAP_COUNT-N1 VALUE 1,
L_DATE LIKE ZAP_COUNT-L_DATE,
IT_ITAB LIKE ITAB OCCURS 0 WITH HEADER LINE.
SELECT L_DATE N1 FROM ZAP_COUNT INTO TABLE ITAB.
SORT ITAB BY L_DATE DESCENDING.
LOOP AT ITAB.
IF ITAB-L_DATE EQ L_DATE.
N1 = N1 + 1.
ELSE.
IF L_DATE IS NOT INITIAL.
IT_ITAB-N1 = N1.
IT_ITAB-L_DATE = L_DATE.
APPEND IT_ITAB.
N1 = 1.
ENDIF.
ENDIF.
L_DATE = ITAB-L_DATE.
ENDLOOP.
IT_ITAB-N1 = N1.
IT_ITAB-L_DATE = L_DATE.
APPEND IT_ITAB.
Reward if useful
2008 Jul 29 11:29 AM
Hi,
if u get problem then let me know...
Thanks & Regards
Ashu Singh
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |