‎2010 Jan 06 12:03 PM
Hi all,
I am new to abap. I am getting the employee no as an input in the screen from the user.If the employee no is present i m trying to display it in the same screen else i am using the function module POPUP_TO_CONFIRM_STEP to display a pop up.
The sample code is:
TABLES : ZSAMP.
Data : itab type zsamp occurs 0 with HEADER LINE.
READ TABLE itab
WITH KEY ENO = ZSAMP-ENO
BINARY SEARCH.
IF sy-subrc = 0.
SELECT SINGLE ENAME AGE DEPT FROM ZSAMP INTO (ZSAMP-ENAME,ZSAMP-AGE,ZSAMP-DEPT ) WHERE ENO = ZSAMP-ENO.
else.
call function 'POPUP_TO_CONFIRM_STEP'.
The problem is even when i give an no which is already present it display's the popup.
Can anyone pls guide me in getting it fixed. Pls tell me if the read stt is correct or any changes req.
Thanks in advance.
‎2010 Jan 06 9:41 PM
HI,
you never fill or append your table itab so you will never find anything in this table.
Regards,
Clemens
‎2010 Jan 06 12:09 PM
Hi Neela,
TABLES : ZSAMP.
Data : itab type zsamp occurs 0 with HEADER LINE.
sort itab by eno ascending " Add this and Check the Sy-subrc for the
" below Read statement.
READ TABLE itab
WITH KEY ENO = ZSAMP-ENO
BINARY SEARCH.
IF sy-subrc = 0.
SELECT SINGLE ENAME AGE DEPT FROM ZSAMP INTO (ZSAMP-ENAME,ZSAMP-AGE,ZSAMP-DEPT ) WHERE ENO = ZSAMP-ENO.
else.
call function 'POPUP_TO_CONFIRM_STEP'.Cheerz
Ram
‎2010 Jan 06 12:16 PM
few things to check...
1. before binary search the table should be sorted properly with ascending order.
2. check if any conversion exit present of ENO.
just put a break point of the read statement and see the values in the table and in zsamp-eno. every thing will be clear.
‎2010 Jan 06 5:43 PM
You have to sort the table before using binary search.
Press F1 on BINARY SEARCH to know more.
Hope this resolves your issue.
‎2010 Jan 06 9:41 PM
HI,
you never fill or append your table itab so you will never find anything in this table.
Regards,
Clemens
‎2010 Jan 07 5:02 AM
Hi,
I have sorted the table but when i debug i can c that no values are found in the internal table. Pls guide me to solve this issue.
Thanks in advance,
Neela
‎2010 Jan 07 5:24 AM
hi
In your coding
r u selecting the data from zsamp?
itab internal table having the same data (zsamp data).
TABLES : ZSAMP.
Data : itab type zsamp occurs 0 with HEADER LINE.
select
from zsamp into table itab.
sort itab byeno.
READ TABLE itab WITH KEY ENO = ZSAMP-ENO BINARY SEARCH.
IF sy-subrc = 0.
SELECT SINGLE ENAME AGE DEPT FROM ZSAMP INTO (ZSAMP-ENAME,ZSAMP-AGE,ZSAMP-DEPT ) WHERE ENO = ZSAMP-ENO.
else.
call function 'POPUP_TO_CONFIRM_STEP'.
‎2010 Jan 07 5:30 AM
hi,
first see that there are no null values in your internal table.
Secondly as per your requirement, place a input box in the screen with some name as 'var_emp' then in the top include or in the report declare this variable with the same name 'var_emp' and its type should be same as the field in the database table(ie., employee number).
then when you execute,
if var_emp is not initial.
SELECT SINGLE ENAME AGE DEPT FROM ZSAMP INTO (ZSAMP-ENAME,ZSAMP-AGE,ZSAMP-DEPT ) WHERE ENO = var_emp.
if sy-subrc ne 0.
call function 'POPUP_TO_CONFIRM_STEP'.
endif.
endif.hope this helps you.
Regards
Sajid