‎2007 Jan 25 6:04 AM
Hi all,
I have written a code in the following manner.
data : wa type zaett, (zaett is my table)
itab2 type zaett occurs 0 with header line.
write / :sy-uname. (Initial output)
select * from zaett into table itab2.
loop at itab2 into wa.
if wa-username eq sy-uname.
write / wa-username.
else.
write : 'wrong'.
endif.
endloop.
My initial ouput is inf64624 (which is my sy-uname).The table also has inf64624 value in its username field , but in the "if statement "some problem is there it is always giving me output as wrong .wa-username is having the value inf64624 but I think some logical error is there.Please Help.
Regards,
Ruby.
‎2007 Jan 25 6:15 AM
Hi Ruby ,
Why dont you use READ TABLE instead of loop endloop.
READ TABLE itab2 WITH KEY <USERNAME_FEILD> = SY-UNAME.
Regards
Arun
Assign points if reply is useful
‎2007 Jan 25 6:13 AM
Hi,
The code is correct.
Try a Clear wa. before endloop.
But your code executes fine for me, when i replaced the tablename and the username.
Regards
Subramanian
‎2007 Jan 25 6:15 AM
Hi Ruby ,
Why dont you use READ TABLE instead of loop endloop.
READ TABLE itab2 WITH KEY <USERNAME_FEILD> = SY-UNAME.
Regards
Arun
Assign points if reply is useful
‎2007 Jan 25 6:25 AM
Hi all,
The mistake what I found is sy-uname is always in upper case.What i entered in my table was in lower case so it was not comparing .Any way .Thanks
Regards,
Ruby.
‎2007 Jan 25 6:28 AM
In the select query itself u can specify the condition.
select * from zaett into table itab2 where username = sy-uname.
or use read statement next to ur select query.
READ TABLE itab2 INTO WA WITH KEY USERNAME = sy-uname .
‎2007 Jan 25 6:37 AM
Hi
try this
data : wa type zaett, (zaett is my table)
itab2 type zaett occurs 0 with header line.
write / :sy-uname. (Initial output)
select * from zaett into table itab2
where username = sy-uname.
if sy-subrc = 0.
write : / wa-username.
else.
write : 'wrong'.
endif.
thanks
shiva