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 doesnt return any data

Former Member
0 Likes
3,050

Hello,

i was trying out some ABAP code and with the following select statement i am not fecthing any rows from the database table BSEG.

could anyone point out what is wrong with this code?

the document number which is being filled in ld_docnum exists in BSEG table.

what i think the problem is with statement ld_docnum = ld_intercomp+1(9).

is this converting the data into any other format that the bseg-belnr is not able to match?

data ls_bseg type table of bseg.

Data ld_docnum type bseg-belnr.

data ld_intercomp type bkpf-bvorg.

.....

.....

ld_docnum = ld_intercomp+1(9).

select * from BSEG into corresponding fields of table ls_bseg where belnr = ld_docnum.

Thanks,

Shilpa

12 REPLIES 12
Read only

rainer_hbenthal
Active Contributor
0 Likes
2,361

That just means that there are no table entries corresponding to your where condition.

Read only

Former Member
0 Likes
2,361

Hi Rainer,

Thanks for your reply but as i initially said there are document with my where condition.. i have check it in se16n.

Thanks

Read only

0 Likes
2,361

No it isnt. In that case i trust SAP. So there must be a difference between you values in SE16 and in your where condition. Maybe leading zeroes.

If sy-dbcnt is zero and sy-subrc is 4 there are definitly no rows corresponding to your where condtion.

Read only

sravya_ch
Participant
0 Likes
2,361

Hi Shilpa

Just Remove this and try

ld_docnum = ld_intercomp.

If then also ita not working means check weather the data is there in database

Sravya

Read only

Former Member
0 Likes
2,361

Hi,

While I don't know the specifics of your data it seems strange to take ld_intercomp+1(9) (i.e. 9 digits) and use this to read a field defined as 10 digits.

If the document number is held in the second to tenth digits of ld_intercomp then you may need to apply the conversion exit function module before using it in the SELECT.

Regards,

Nick

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,361

Why do you do this MOVE, from one BKPF-BVORG you select the records from BVOR with same Number of Cross-Company Code Posting Transaction and then select from BSEG with full document key with data from BVOR (GJAHR, BUKRS, BELNR)

BKPF (1 record) -> BVOR (n records) -> BKPF (n records) -> BSEG (> n records)

NB: In your code you move internally (no conversion exit) nine characters to BELNR, which is ten character long and has the conversion exit ALPHA, so as those are usually number, the conversion exit (in SE16 and other transactions) align characters to the right and add leading zeroes. Also even if you manage to solve this remember that (taking whole ten characters or adding a leading zero), BELNR is not sufficient to get the right document, you need BUKRS and GJHAR too.

Regards,

Raymond

Read only

Former Member
0 Likes
2,361

Hi,

If you are trying to get the first 10 characters of Id_intercomp, then you will have to use

ld_docnum = ld_intercomp+0(10).

Also, check in debug mode before select query what data is populated in ld_docnum. That should help.

Thanks,

Shiva

Read only

Former Member
0 Likes
2,361

Thank you my problem is solved.

as i said the problem was with the statement ld_docnum = ld_intercomp+1(9)

replaced it with ld_docnum = ld_intercomp(10) and it works fine

Read only

0 Likes
2,361

So youre where condition was different to you select in SE16. Sometimes the computer is right.

Read only

0 Likes
2,361

plz give points if my answer was helpful

Read only

0 Likes
2,361

Begging for points is against forum rules. What can you do with points? Get a cup or a t-shirt... yeah thats really important

Read only

0 Likes
2,361

Dear Rainer,

Its not just for a cup or a t-shirt... Its one of my goal set in objectives for appraisal to gather particular number of points on SDN. So just trying to gather the same with my knowledge.

Regards,

Shiva