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

Short Dump on Aggregate Function Count

former_member295881
Contributor
0 Likes
1,025

Hello Experts,

I'm trying to write a simple Aggregate Select statement to count POSNR from VBAP but having a short dump saying 'Error in module RSQL of the database interface'. Can anybody see what's wrong with the following statement.

select vbeln posnr kdmat cuobj

into table t_sales_order

from vbap

where vbeln = pv_pin_number (user input parameter)

describe table t_sales_order lines lv_lin.

read table t_sales_order into lwa_sales_order index lv_lin.

-


> Error select count( distinct posnr ) from vbap

into gv_posnr

where vbeln = lwa_sales_order-vbeln.

Many thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
820

Hi

gv_posnr has to be an integer, so TYPE I

Max

4 REPLIES 4
Read only

Former Member
0 Likes
820

There should be further information about the error. Please share it.

Rob

Read only

Former Member
0 Likes
821

Hi

gv_posnr has to be an integer, so TYPE I

Max

Read only

Former Member
0 Likes
820

HI

I copied the same code and did some small modificatio.

I have replaced the GV_POSNR with V_COUNT and declared it as INT4. The COUNT holds only upto INT4 values.

It is working for me. Please change the data type of VG_POSNR to INT4.

Please a break on select count statement and check the index of LV_LIN value and also the VBELN.

Check how many entries are there for the same VBELN.


types : begin of ty_vbap,
        vbeln type vbak-vbeln,
        posnr type vbap-posnr,
        kdmat type vbap-kdmat,
        cuobj type vbap-cuobj,
        end of ty_vbap.

        Data : t_vbap  type table of ty_vbap,
               wa_vbap type ty_vbap,
               lv_lin  type i,
               v_count type int4.


select vbeln posnr kdmat cuobj
into table t_vbap
from vbap
up to 2000 rows.

describe table t_vbap lines lv_lin.
read table t_vbap into wa_vbap index lv_lin.

*----> Error
select count( distinct posnr ) from vbap
into v_count
where vbeln = wa_vbap-vbeln.

write : v_count.

SHIVA

Read only

former_member295881
Contributor
0 Likes
820

Many thanks folks, It was data type which caused error. Instead of keep gv_posnr as type i I'd it type posnr.

Thanks again