Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Issue with screen painter

Former Member
0 Likes
781

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.

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
747

HI,

you never fill or append your table itab so you will never find anything in this table.

Regards,

Clemens

7 REPLIES 7
Read only

Former Member
0 Likes
747

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

Read only

Former Member
0 Likes
747

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.

Read only

0 Likes
747

You have to sort the table before using binary search.

Press F1 on BINARY SEARCH to know more.

Hope this resolves your issue.

Read only

Clemenss
Active Contributor
0 Likes
748

HI,

you never fill or append your table itab so you will never find anything in this table.

Regards,

Clemens

Read only

Former Member
0 Likes
747

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

Read only

Former Member
0 Likes
747

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'.

Read only

Former Member
0 Likes
747

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