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: 

How to get BKPF-BELNR or BSEG-BELNR using ANEP-BELNR as reference?

Former Member
0 Kudos

Hello all you experts!

I am having a problem with a Z report. I need to access BSEG using BELNR, but the only Document number (BELNR) I have at runtime is ANEP-BELNR that is not the same Document number (BELNR) that the one in BKPF or in BSEG.

I tried to access BSEG using BUKRS, GJAHR, ANLN1 and ANLN2 (I already have those values in an internal table) but it is taking forever since I didn't specified BELNR.

Is there a relationship with ANEP and BKPF/BSEG?

Please help, it is kind of urgent!

Many thanks in advance.

2 REPLIES 2

Former Member
0 Kudos

Hi,

You can use ANEK table. Check this code:

IF anek-awtyp = 'BKPF'.

  • reading doc. type from BKPF only necessary, if no NF is found

IF outrec-doc_type IS INITIAL.

SELECT SINGLE blart FROM bkpf INTO outrec-doc_type

WHERE bukrs = bukrs-low

AND belnr = anek-belnr

AND gjahr = anek-gjahr.

ENDIF.

ELSE. " searching for the FI document with the AWKEY

CONCATENATE anek-belnr anek-aworg INTO help_awkey.

SELECT SINGLE belnr blart FROM bkpf

INTO (outrec-doc_number, help_doc_type)

WHERE awtyp = anek-awtyp

AND awkey = help_awkey

AND awsys = anek-awsys.

ENDIF.

Regards,

Fernando

naimesh_patel
Active Contributor
0 Kudos

Generally Both BKPF-BELNR and ANEP-BELNR must match with each other.

Try to find out from your FI consultant the reason behind why they are not matching.

Regards,

Naimesh Patel