05-13-2008 6:52 PM
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.
05-13-2008 7:03 PM
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
05-13-2008 7:03 PM
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