Application Development 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: 

calling CDS view with parameters in Report

madhu21vari
Explorer
0 Kudos
Hi , I have created a CDS view with parameters but when the CDS view is calling in the report, i am getting the below error as <Field> is not bound . Please help did i missing anything .
Define view :

@AbapCatalog.sqlViewName: 'ZCDSBASICVW1'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck:#NOT_REQUIRED 
@EndUserText.label: 'CDS Basic view'
@VDM.viewType: #CONSUMPTION
@OData.publish: true
define view zCDS_basic1 as select from dfkk_vt_h {
    vtkey,
    gpart,
erdat,
ertim
}

Report calling the view :

REPORT zdemo_cds_join.
TABLES: dfkk_vt_h.
PARAMETERS : pvtkey LIKE dfkk_vt_h-vtkey,
             pgpart LIKE dfkk_vt_h-gpart.


START-OF-SELECTION.
  SELECT * FROM zcdsbasicvw1
    ( pvtkey = @pvtkey , pgpart = @pgpart )
  INTO TABLE @DATA(it_tab).













8 REPLIES 8

DoanManhQuynh
Active Contributor
0 Kudos

The problem is, there is no parameter in your view defination. or this is new CDS syntax? look at this link:

https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenselect_cds_para_abexa.htm

madhu21vari
Explorer
0 Kudos

Parameters are maintained, i missed in the code.

Did you figure out the reason for the error 'parameter was not bound' when calling a cds view with parameter in a report?

former_member564522
Active Participant
0 Kudos

Try to use DDLS source name (zCDS_basic1) in select query rather than view name.

tlvnsaikumar81
Discoverer
*** CDS VIEW WITH PARAMETRES ****


@AbapCatalog.sqlViewName: 'zcds_param_view'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'cds view with parameters'
define view zcds_parameters2
    with parameters p_matnr : matnr,
                    p_item  : posnr_va
as select from vbap {
    vbeln,
    posnr,
    matnr,
    matkl,
    zmeng,
    netwr
} where matnr = :p_matnr and 
        posnr = $parameters.p_item 
 
*******************************************************

*** CDS VIEW WITH PARAMETRES IN REPORT PROGRAM****

*&---------------------------------------------------------------------*
*& Report zr_cds_sai1
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zr_cds_sai1.


PARAMETERS: p_matnr TYPE matnr,
            p_item TYPE posnr_va.

*select * from zcds_parameters2( p_matnr = @p_matnr,p_item = @p_item )  into TABLE @data(lt_final) . "by suing cds view name

select * from zcds_param_view( p_matnr = @p_matnr,p_item = @p_item )  into TABLE @data(lt_final) where matnr = @p_matnr.  "BY USING  SQL CDS VIEW NAME

*select * from zcds_param_view  into TABLE @data(lt_final) WHERE MATNR = @P_MATNR AND POSNR_VA = @P_ITEM . "THIS IS NOT WORKING AS A CDS VIEW  
 cl_demo_output=>display( lt_final ).

*********************************************************************
* Developer Name : T L V N SAI KUMAR**
* Mobile Number :  +91 9553667049  
* youtube Channel :https://www.youtube.com/channel/UCFnPVjp6ZfJ9jI48of3FczQ/playlists?view_as=subscriber


 

tlvnsaikumar81
Discoverer
0 Kudos
*** BASIC CDS VIEW  ****


@AbapCatalog.sqlViewName: 'zcds_ddefine_sql'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'data define'
define view zcds_ddefine as select from vbap {


vbeln,
posnr,
matnr,
zmeng,
netwr
    
} 
 

 
*******************************************************

*** USING BASIC CDS VIEW WITH PARAMETRES IN REPORT PROGRAM****

*&---------------------------------------------------------------------*
*& Report zr_cds_sai1
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Report zr_cds_sai_basic
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zr_cds_sai_basic.


PARAMETERS: p_matnr type matnr,
            p_vbeln type vbeln_va.


*select * from zcds_ddefine into TABLE @DATA(lt_final) WHERE matnr = @p_matnr and
*                                                            vbeln = @p_vbeln. 

" by using cds view


select * from zcds_ddefine_sql into TABLE @DATA(lt_final) WHERE matnr = @p_matnr and
                                                            vbeln = @p_vbeln. 

" by using sql cds view

cl_demo_output=>display( lt_final ).


*********************************************************************
* Developer Name : T L V N SAI KUMAR**
* Mobile Number :  +91 9553667049  
* youtube Channel :https://www.youtube.com/channel/UCFnPVjp6ZfJ9jI48of3FczQ/playlists?view_as=subscriber

0 Kudos

First create basic view

@AbapCatalog.sqlViewName: 'ZNAPARAMETER'

@AbapCatalog.compiler.compareFilter: true

@AbapCatalog.preserveKey: true

@AccessControl.authorizationCheck: #CHECK

@EndUserText.label: 'parameter'

define view ZNA_PARAMETER as select from vbap

{

mandt as Mandt,

vbeln as Vbeln,

posnr as Posnr

}

after creating basic view in report program write below code

REPORT zna_parameter_program.

tables: vbap.

parameters : p_vbeln like vbap-vbeln.

select * from ZNA_PARAMETER into table @data(ITAB) where vbeln = @P_VBELN. cl_demo_output=>display( itab ).

0 Kudos

#cds view.

@AbapCatalog.sqlViewName: 'zraj_para'

@AbapCatalog.compiler.compareFilter: true

@AbapCatalog.preserveKey: true

@AccessControl.authorizationCheck: #CHECK

@EndUserText.label: 'for parameter'

define view zraj_parameter with parameters p_vbeln : vbeln_va as select from

vbap {

key posnr,

matnr,

matwa,

pmatn } where vbeln = $parameters.p_vbeln

#report code

REPORT ZRAJ_PROGRAM.

PARAMETERS: P_VBELN TYPE vbeln_va.

SELECT * FROM zraj_para INTO TABLE @data(lT_FINAL) WHERE VBELN = @P_VBELN.

CL_DEMO_OUTPUT=>DISPLAY(lT_FINAL).