‎2008 May 22 10:53 AM
Hi All,
I have an internal table with following structure.
Name of Internal table: ITAB
Fields: userid login date number
Values: abc 01012008
abc 02012008
abc 02012008
abc 03012008
Now i should store the value for the field itab-number, based on the ita-logindate.
If the field logindate is having same date for 2 times (for the user 'abc'),
the field itab-number should have the value as '2' .
Basically i want to display a report to show how many times a user has logged into SAP system for a given date.......
How to incorporate this logic?
Regards
Pavan
‎2008 May 22 2:35 PM
Hi,
Use the below logic.
data: begin of itab1 occurs 0,
uid like sy-uname,
date like sy-datum,
end of itab1.
data: begin of itab2 occurs 0,
uid like sy-uname,
date like sy-datum,
count type i,
end of itab2.
data v_count type i.
start-of-selection.
itab1-uid = 'abc'.
itab1-date = '20080101'.
append itab1.
itab1-uid = 'abc'.
itab1-date = '20080102'.
append itab1.
itab1-uid = 'abc'.
itab1-date = '20080102'.
append itab1.
itab1-uid = 'abc'.
itab1-date = '20080103'.
append itab1.
itab1-uid = 'abc'.
itab1-date = '20080104'.
append itab1.
sort itab1 by uid date.
loop at itab1.
v_count = v_count + 1.
at end of date.
itab2-uid = itab1-uid.
itab2-date = itab1-date.
itab2-count = v_count.
append itab2.
clear v_count.
endat.
endloop.
‎2008 May 22 11:27 AM
first sort the table on user id and date.
Next loop over internal table.
LOOP AT itab ASSIGNING <line>.
AT NEW date.
CLEAR: lv_number.
ENDAT.
<line>-number = lv_number + 1.
ENDLOOP.
Something like this???
‎2008 May 22 12:31 PM
‎2008 May 22 12:34 PM
Hi pavan,
1. We have to use COLLECT for this.
2. Declare another itab, exactly similar to ITAB.
egs. STAB.
3.
Loop at ITAB.
STAB = ITAB.
Collect STAB.
Endloop.
regards,
amit m.
‎2008 May 22 12:57 PM
hi,
try in this way,
first sort the internal table on user id and date.
loop at itab into wa.
l_tabix = sy-tabix.
number = number + 1.
wa-number = number.
modify itab from wa index l_tabix transporting number.
at end of date.
clear number.
endat.
endloop.
regards,
muralidhar.
‎2008 May 22 1:28 PM
Hi,
Try the following
DATA : g_date TYPE sy-datum,
g_count(2) TYPE c,
g_id(10) TYPE c.
**After populating the internal table
g_count = 1.
CLEAR g_id.
LOOP AT itab.
IF itab-date EQ g_date AND g_id = itab-id.
g_count = g_count + 1.
ENDIF.
g_date = itab-date.
g_id = itab-id.
AT END OF date.
itab-number = g_count.
CLEAR g_id.
WRITE : / itab-id,itab-date,itab-number.
clear : g_id.
g_count = 1.
ENDAT.
ENDLOOP.
Regards,
Hema.
‎2008 May 22 2:35 PM
Hi,
Use the below logic.
data: begin of itab1 occurs 0,
uid like sy-uname,
date like sy-datum,
end of itab1.
data: begin of itab2 occurs 0,
uid like sy-uname,
date like sy-datum,
count type i,
end of itab2.
data v_count type i.
start-of-selection.
itab1-uid = 'abc'.
itab1-date = '20080101'.
append itab1.
itab1-uid = 'abc'.
itab1-date = '20080102'.
append itab1.
itab1-uid = 'abc'.
itab1-date = '20080102'.
append itab1.
itab1-uid = 'abc'.
itab1-date = '20080103'.
append itab1.
itab1-uid = 'abc'.
itab1-date = '20080104'.
append itab1.
sort itab1 by uid date.
loop at itab1.
v_count = v_count + 1.
at end of date.
itab2-uid = itab1-uid.
itab2-date = itab1-date.
itab2-count = v_count.
append itab2.
clear v_count.
endat.
endloop.