cancel
Showing results for 
Search instead for 
Did you mean: 

Select query is not working Data is not getting pulled, Blank Alv grid is displayed

former_member848290
Discoverer
0 Kudos

Hi,

I am not able to see data in ALV report,its a blank window with column names only.

TABLES hrp1001.
TYPE-POOLS: slis.

TYPES: BEGIN OF ty_hrp,
otype TYPE hrp1001-otype,
sobid TYPE hrp1001-sobid,
objid TYPE hrp1001-objid,
adatanr TYPE hrp1001-adatanr,
END OF ty_hrp.

DATA : it_hrp TYPE TABLE OF ty_hrp,
wa_hrp TYPE ty_hrp.

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv.

SELECT-OPTIONS : s_otype FOR hrp1001-sobid.


SELECT sobid
otype
objid
adatanr
INTO TABLE it_hrp
FROM hrp1001
WHERE otype = s_otype AND
adatanr EQ '.00'.


wa_fieldcat-fieldname = 'SOBID'. " Fieldname in the data table
wa_fieldcat-tabname = 'it_hrp'.
wa_fieldcat-seltext_m = 'SOBID'. " Column description in the output
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'OTYPE'.
wa_fieldcat-tabname = 'it_hrp'.
wa_fieldcat-seltext_m = 'OTYPE'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'OBJID'.
wa_fieldcat-tabname = 'it_alv'.
wa_fieldcat-seltext_m = 'OBJID.'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ADATANR'.
wa_fieldcat-tabname = 'it_hrp'.
wa_fieldcat-seltext_m = 'ADATANR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
* is_layout = layout
it_fieldcat = it_fieldcat
TABLES
t_outtab = it_hrp
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

raymond_giuseppi
Active Contributor
  • Read online documentation on WHERE clause for sql_cond - IN ranges table
  • Also consider using a class such as CL_SALV_TABLE and not an obsolete REUSE FM.

Accepted Solutions (1)

Accepted Solutions (1)

shantraj
Explorer

Yes, select query is wrong for Select-Options, use 'IN' not '='.

SELECT sobid
otype
objid
adatanr
INTO TABLE it_hrp
FROM hrp1001
WHERE otype IN s_otype AND
adatanr EQ '.00'.

Answers (2)

Answers (2)

callagiannis
Explorer

Your select is wrong. You have select option. You need "in s_otype[]" not "= s_otype"

BR,Christos

Sandra_Rossi
Active Contributor
0 Kudos

even "in s_otype" works (without [ ]), as the potential Header Line is ignored by "in".

callagiannis
Explorer
0 Kudos

of course it does. the point here is to use "in", with or without "[]"

former_member848290
Discoverer
0 Kudos

Thank you for the ans, it helped 🙂

TarunTakshak
Participant
0 Kudos

Hi vrush09,

Your query was wrong

For select-option you have to use 'IN' and for parameters 'EQ'.

WHERE otype IN s_otype.

Thanks

Tarun