2010 Jul 17 8:43 AM
Hi, friends
I try to compare tow fields from the same table, but no result,
For example, this
data: cptotchek tyep i.
select count(*) into cptotchek
from aufk where erdat = aufk-idat2 .
The result is cptotchek = 0, but there are the records in aufk , where, aufk-erdat = aufk-idat2.
Please, help me, i don't use the loop statement for optimize my program.
Regards
Hi, friends
I try to compare tow fields from the same table, but no result,
For example, this
data: cptotchek tyep i.
select count(*) into cptotchek
from aufk where erdat = aufk-idat2 .
The result is cptotchek = 0, but there are the records in aufk , where, aufk-erdat = aufk-idat2.
Please, help me, i don't use the loop statement for optimize my program.
Regards
2010 Jul 17 11:45 AM
Hi ,
it will not return any value when you are using column of same table
such as Date Field , Because while Using Aggregate Function it will not check with self column
. For that you have to take data in one internal table and then you can work on it .
And if you are worried about Performance it will not affect , untill you are selecting only required data .
you can try this way .
data: cptotchek type i.
types : begin of w_aufk.
include structure aufk .
types : end of w_aufk .
data : it_aufk type standard table of w_aufk with header line .
select * into corresponding fields of table it_aufk
from aufk .
loop at it_aufk .
if it_aufk-erdat = it_aufk-idat2 .
write : / it_aufk-erdat , it_aufk-idat2 .
else .
delete it_aufk .
endif .
endloop.
Regards
Deepak.
2010 Jul 17 1:00 PM
The ABAP help is your friend, just do the F1 on the SELECT statement. Let me give you the jump start now, so you're prepared for the next time...
Look at the [SELECT|http://help.sap.com/abapdocu_70/en/ABAPSELECT.htm] statement, drill down into the [WHERE|http://help.sap.com/abapdocu_70/en/ABAPWHERE.htm] clause and then into the [sql_cond|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP.htm]. There you'll see the following comment:
You can specify the same column names (comp, dbtabcomp, tabaliascomp) for col as are listed in the specification of single columns after SELECT.
The SELECT statement you've listed is only syntactically correct, if you have defined a variable or table with name AUFK. Most likely the variable is initial and thus you're searching for entries with a blank creation date (and naturally none should exist). So change your query to this:
select count(*) into cptotchek from aufk where erdat = aufk~idat2.
Note that for this single statement there's no need to define AUFK as a variable (via DATA or TABLES).
Cheers, harald
2010 Jul 17 3:32 PM
Thinks, problem solved, as the last's answer.
select count(*) into cptotchek from aufk where erdat = aufk~idat2.
Regards again.
2010 Jul 17 3:33 PM
Thinks, problem solved, as the last's answer.
select count(*) into cptotchek from aufk where erdat = aufk~idat2.
Regards again. Youu2019re the best.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |