2008 Feb 07 7:52 PM
Hi Everyone,
I am able to display the data from the internal table for the values of fiscyear and compcode and at the same time I want to display the rowcount for each combination.
Say Fiscyear Compcode Rowcount
2000 1000 8000
2000 2000 200
etc
But so far successful only with fiscyear and compcode, how do i achieve this any help will be of great use to me.
All my data I am getting it in a internal table itab. From that only I am able to sort and display distinct vvalues.
Please advise,
Thanks,
Prashant.
2008 Feb 07 8:48 PM
Hi Pradanth
you can create another table of same type and use it as below:
data: lv_count type i.
itab_buff [ ] = data_table[ ].
delete itab_buff where fiscear NE '2000'.
describe table itab_buff lines lv_count.
"move this lv_count to the table you wanted...
2008 Feb 07 10:08 PM
Hi Jay,
Thanks for the suggestion, but it did not work, here is the code below:
After getting the data into the internal table g_t_data, I have given it as suggested by you.
*************************
FORM print_result.
data: lv_count type i.
itab_temp[] = g_t_data[].
SORT itab_temp BY fiscyear comp_code.
delete adjacent duplicates from itab_temp comparing fiscyear comp_code.
g_t_data[] = itab_temp[].
itab_temp[] = g_t_data[].
delete itab_temp where fiscyear NE '2000'.
describe table itab_temp lines lv_count.
g_t_data[] = itab_temp[].
LOOP AT g_t_data INTO g_s_data.
WRITE: /(10) g_s_data-fiscyear,
(25) g_s_data-comp_code,
g_s_data-rowcount.
ENDLOOP.
ENDFORM.
******************************************************
I have print the result in the column rowcount as explained in the begginning.
For fiscyear 2000 and comp code 1000 the rowcount is 8000 records,
for fisyear 2000 and comp code 2000 the rwocount is 300 records.
Please advise,
thanks,
Prashant.
2008 Feb 07 10:22 PM
Hi
Where are you writing the variable lv_count in ur code??
Write:/ 'No: of records equals: ' lv_count.
LOOP AT g_t_data INTO g_s_data.
WRITE: /(10) g_s_data-fiscyear,
(25) g_s_data-comp_code,
ENDLOOP
Cheers
~Arun
2008 Feb 07 10:28 PM
Hi ,
I guess u did not understand what i am planning to get here, I want to get the rowcount of the combination of fiscyear and compcode and put it is one column which is rowcount. So how I query the data which is in internal table to get the rowcount for the required combination.
Read table also did not work.
Regards,
Prashant.
2008 Feb 07 10:35 PM
Hi
here p_FY and p_CC are user input parameters
LOOP AT g_t_data in g_s_data.
IF g_s_data-FY = p_FY and g_s_CC = p_CC.
count = count + 1.
flag = 1.
ENDIF.
ENDLOOP.
IF flag = 1
Append g_s_data to itab_temp.
ENDIF.
Now in count u wll get the number of records and itab_temp will have the required data
Cheers
~Arun
2008 Feb 07 10:50 PM
Hi Arun,
It did not work, here is the code which u suggested.
FORM print_result.
data: count type i.
itab_temp[] = g_t_data[].
SORT itab_temp BY fiscyear comp_code.
delete adjacent duplicates from itab_temp comparing fiscyear comp_code.
g_t_data[] = itab_temp[].
LOOP AT g_t_data INTO g_s_data.
IF g_s_data-fiscyear = '2000' and g_s_data-comp_code = '2000'.
count = count + 1.
Append g_s_data to itab_temp.
clear g_s_data.
ENDIF.
WRITE: /(10) g_s_data-fiscyear,
(25) g_s_data-comp_code,
g_s_data-rowcount.
g_s_data-0CACQ_VL_YR,
g_s_data-0COR_DEP_YR,
g_s_data-0CRES_TR_YR.
ENDLOOP.
For this combination fiscyear = 2000 and compcode = 2000 I must get 8000 records. But not getting it. What could be the problem.
2008 Feb 07 10:57 PM
Hello
U r clearing the g_s_data...then how will you get it???
LOOP AT g_t_data INTO g_s_data.
IF g_s_data-fiscyear = '2000' and g_s_data-comp_code = '2000'.
count = count + 1.
Append g_s_data to itab_temp.
clear g_s_data. <<<<<<<<<<<<<<<<< u r clearing it.
write like this
LOOP AT g_t_data in g_s_data.
IF g_s_data-FY = '2000' and g_s_CC = '2000'.
count = count + 1.
flag = 1.
ENDIF.
ENDLOOP.
IF flag = 1
Append g_s_data to itab_temp.
ENDIF.
Loop at itab_temp.
WRITE: /(10) itab_temp-fiscyear,
(25) itab_tempcomp_code,
(30) lv_count.
endloop.
2008 Feb 07 11:04 PM
FORM print_result.
data: count type i.
itab_temp] = g_t_data[.
SORT itab_temp BY fiscyear comp_code.
delete adjacent duplicates from itab_temp comparing fiscyear comp_code.
itab_temp_1[ ] = itab_temp [ ].
delete itab_temp_1 where fiscear NE '2000'. " create another temp table
describe table itab_temp_1 lines lv_count.
g_t_data[ ] = itab_temp[ ].
LOOP AT g_t_data INTO g_s_data where fiscyear = '2000' and comp_code = '2000' .
g_s_data-rowcount = lv_count. " <<<< move the total to str.
Append g_s_data to itab_temp.
clear g_s_data.
WRITE: /(10) g_s_data-fiscyear,
(25) g_s_data-comp_code,
g_s_data-rowcount.
* g_s_data-0CACQ_VL_YR,
* g_s_data-0COR_DEP_YR,
* g_s_data-0CRES_TR_YR.
ENDLOOP.