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

select query

Former Member
0 Likes
1,395

hi all,

my query is like this, i am extracting some data from table bsid.

parameters:p_kunnr like bsid-kunnr

select kunnr zuonr xblnr from bsid into table itab where kunnr = p_kunnr.

its showing dump.error in select statement.

in table bsid suppose customer no is 1(input)

in table we can find 5 custome numbers with 1.

thanks in advance

venkat

1 ACCEPTED SOLUTION
Read only

gopi_narendra
Active Contributor
0 Likes
1,371
DATA : BEGIN OF itab OCCURS 0,
         kunnr LIKE bsid-kunnr,
         zuonr LIKE bsid-zuonr,
         xblnr LIKE bsid-xblnr,
       END OF itab.

PARAMETER : p_kunnr LIKE bsid-kunnr.

SELECT kunnr zuonr xblnr
       FROM bsid
       INTO TABLE itab
       WHERE kunnr = p_kunnr.
IF sy-subrc = 0.
  WRITE : 'Success..!'.
ENDIF.

this worked for me... check out if this is what u missed the itab declaration.

Regards

Gopi

13 REPLIES 13
Read only

Former Member
0 Likes
1,371

Hi,

what is structure of itab,

try, into corressponding field of itab.

regards

deepak

Read only

Former Member
0 Likes
1,371

Hi,

How did you declare the internal table itab..

try using 'into corresponding fields of'

select kunnr zuonr xblnr from bsid into into corresponding fields of table itab where kunnr = p_kunnr. (or)..

declare the internal table only with these three fields..

Regards,

Vidya.

Read only

Former Member
0 Likes
1,371

Hi Venkat,

may be your itab is having different fields than your selction, check it or otherwise put the whole code here.

Reward points if useful.

Regards,

Atish

Read only

Former Member
0 Likes
1,371

what is the structure of itab??

if there are other fields than mentioned in select statement in itab, then try this..

select kunnr zuonr xblnr from bsid into <b>CORRESPONDING FIELDS OF</b> table itab where kunnr = p_kunnr.

Read only

Former Member
0 Likes
1,371

hi

how have you declared your itab? if your internal table declaration order and the order in which you select fields from the database are not of the same sequence, then you have to use "into corresponding fields of" addition in your select

select kunnr zuonr xblnr from bsid into corresponding fields of table itab where kunnr = p_kunnr.

if helpful, reward

Sathish. R

Read only

Former Member
0 Likes
1,371

give yopur dump errors

we can solve it..

regards,

nazeer

Read only

Former Member
0 Likes
1,371

Hi

Check the sequence of the fields in Internal table and in the select Query

both should be same

may be you have declared wrongly, the sequence

see the sample select query

  • Select the Customer Open Items data from bsid

SELECT l~kunnr

l1~name1

b~waers

b~dmbtr

b~zfbdt

b~zbd1t

b~zbd2t

b~zbd3t

b~belnr

b~xblnr

b~shkzg

b~blart

INTO CORRESPONDING FIELDS OF TABLE int_bsid

FROM knb1 AS l INNER JOIN kna1 AS l1

ON lkunnr = l1kunnr

INNER JOIN bsid AS b

ON lkunnr = bkunnr AND

lbukrs = bbukrs

WHERE l~kunnr IN s_kunnr AND

l~bukrs = p_bukrs and

b~zfbdt le p_allgst.

Reward points if useful

Regards

Anji

Read only

gopi_narendra
Active Contributor
0 Likes
1,372
DATA : BEGIN OF itab OCCURS 0,
         kunnr LIKE bsid-kunnr,
         zuonr LIKE bsid-zuonr,
         xblnr LIKE bsid-xblnr,
       END OF itab.

PARAMETER : p_kunnr LIKE bsid-kunnr.

SELECT kunnr zuonr xblnr
       FROM bsid
       INTO TABLE itab
       WHERE kunnr = p_kunnr.
IF sy-subrc = 0.
  WRITE : 'Success..!'.
ENDIF.

this worked for me... check out if this is what u missed the itab declaration.

Regards

Gopi

Read only

0 Likes
1,371

hi all,

thanks for ur response

my requirement is like this,

i had to extract

input is kunnr(parameter)

kunnr,name1,name2,adrnr from kna1

and kunnr zuonr,bldat,xblnr,wrbtr from bsid

and bktxt from bkpf

output table

kunnr name1 name2 adrnr zuonr bldat xblnr wrbtr bktxt

Read only

0 Likes
1,371

Hi

<b>Select

akunnr aname1 aname2 aadrnr

bzuonr bbldat bxblnr bwrbtr

c~bktxt

Into table ITAB

from kna1 as a join bsid as b

on akunnr = bkunnr join bkpf as c

on bbelnr = cbelnr and

bgjahr = cgjahr and

bbukrs = cbukrs

where a~kunnr = p_kunnr.</b>

Reward points if useful

Regards

Anji

Read only

0 Likes
1,371

selct a~kunnr

a~zuonr

a~bldat

a~xblnr

a~wrbtr

b~name1

b~name2

b~adrnr

into corresponding fields of itab

from bsid as a inner join kna1 as b

on akunnr = bkunnr

where a~kunnr = p_kunnr.

regards,

Vidya.

Read only

0 Likes
1,371

declare the internal tables accordingly.

PARAMETER : p_kunnr LIKE bsid-kunnr.

SELECT kunnr belnr zuonr bldat xblnr wrbtr
       FROM bsid
       INTO TABLE itab
       WHERE kunnr = p_kunnr.

SELECT kunnr name1 name2 adrn
       FROM kna1
       INTO TABLE it_kna1
       FOR ALL ENTRIES IN it_bsid
       WHERE kunnr = it_bsid-kunnr.

SELECT belnr bktxt
       FROM bkpf
       INTO TABLE it_bkpf
       FOR ALL ENTRIES IN it_bsid
       WHERE belnr = it_bsid-belnr.

LOOP AT it_bsid.
  move-corresponding it_bsid into it_final.
  READ TABLE it_kna1 WITH KEY kunnr = it_bsid-kunnr.
  IF sy-subrc = 0.
    MOVE it_kna1-name1 TO it_final-name1.
    MOVE it_kna1-it_kna1-name2 TO it_final-name2.
    MOVE adrnr TO it_final-adrnr.
  ENDIF.
  READ TABLE it_bkpf WITH KEY belnr = it_bsid-belnr.
  IF sy-subrc = 0.
    MOVE it_bkpf-bktxt TO it_final-bktxt.
  ENDIF.
  APPEND it_final.
ENDLOOP.

Regards

Gopi

Read only

Former Member
0 Likes
1,371

REPORT ZNN001_OTHERS.

data itab type STANDARD table OF bsid.

parameters:p_kunnr like bsid-kunnr.

select kunnr zuonr xblnr from bsid into corresponding fields of table itab where kunnr = p_kunnr.

REWARDS IF HELPFUL