Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to Retriev data from database view through select statement?

Need code to Retrieve data from database view through select statement

REPORT zfi_v1.

tables : bkpf,bseg.

TYPES : BEGIN OF ty_vbsegs,

belnr TYPE belnr_d,

gjahr TYPE gjahr,

bukrs TYPE bukrs,

buzei TYPE buzei,

bschl TYPE bschl,

mwskz TYPE mwskz,

wrbtr TYPE wrbtr,

sgtxt TYPE sgtxt,

saknr TYPE saknr,

blart TYPE blart,

budat TYPE budat,

xblnr TYPE xblnr1,

END OF ty_vbsegs.

DATA : it_vbsegs TYPE TABLE OF ty_vbsegs,

wa_vbsegs TYPE ty_vbsegs.

SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS : p_bukrs TYPE bseg-bukrs.

PARAMETERS : p_hkont TYPE bseg-hkont.

SELECT-OPTIONS : s_budat FOR bkpf-budat OBLIGATORY.

SELECTION-SCREEN : END OF BLOCK b1 .

START-OF-SELECTION.

BREAK-POINT.

SELECT belnr

gjahr

bukrs

buzei

bschl

mwskz

wrbtr

sgtxt

saknr

blart

budat

xblnr

FROM v_vbsegs

INTO TABLE it_vbsegs

WHERE bukrs = p_bukrs

AND saknr = p_hkont

AND budat IN s_budat.

END-OF-SELECTION.

LOOP AT it_vbsegs INTO wa_vbsegs.

WRITE:/ wa_vbsegs-belnr,

wa_vbsegs-gjahr,

wa_vbsegs-bukrs,

wa_vbsegs-buzei,

wa_vbsegs-bschl,

wa_vbsegs-mwskz,

wa_vbsegs-wrbtr,

wa_vbsegs-sgtxt,

wa_vbsegs-saknr,

wa_vbsegs-blart,

wa_vbsegs-budat,

wa_vbsegs-xblnr.

CLEAR : wa_vbsegs.

ENDLOOP.

At run time we are not getting data into the internal table( created on database view)

Former Member
Not what you were looking for? View more on this topic or Ask a question