Skip to Content
avatar image
Former Member

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

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    May 13, 2008 at 06: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

    Add comment
    10|10000 characters needed characters exceeded

  • May 13, 2008 at 06: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

    Add comment
    10|10000 characters needed characters exceeded