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: 

Corresponding FI Document of a MM Document

Former Member
0 Kudos

Dear Friends,

How can I find the corresponding Accounting document of a Material Document. Kindly tell in terms of table entries.

Regards,

Alok.

9 REPLIES 9

Former Member
0 Kudos

Hi Alok,

Any document created, has its entry in table BSEG.

Please check.

thank you.

h_senden2
Active Contributor
0 Kudos

BKPF and BSEG.

Check BKPF-AWTYP (reference procedure) and BKPF-AWKEY (reference key)

regards,

Hans

Former Member
0 Kudos

hi,

material document are in table mseg and accounting document are in table bkpf and bseg..

in table bkpf in field object key i.e AWKEY

material document is stored.just enter material doc no here like: 400000001*

0 Kudos

Thanks for responding to my query. I know that AWKEY field is there but I am finding it difficult to write the code for the same.

Please have a look at the following piece of code .

****************************************************For Road Permit No. etc......

Select bukrs werks mblnr matnr bktxt rpno ablad_amt

into corresponding fields of table i_zft_regdel

from zft_regdel

for all entries in ITAB_TOTAL

where matnr = ITAB_TOTAL-matnr.

loop at i_zft_regdel.

loop at ITAB_TOTAL where matnr = i_zft_regdel-matnr.

ITAB_TOTAL-bukrs = i_zft_regdel-bukrs.

ITAB_TOTAL-mblnr = i_zft_regdel-mblnr.

ITAB_TOTAL-bktxt = i_zft_regdel-bktxt.

ITAB_TOTAL-ebeln = i_zft_regdel-ebeln.

ITAB_TOTAL-rpno = i_zft_regdel-rpno.

ITAB_TOTAL-ablad_amt = i_zft_regdel-ablad_amt.

MODIFY ITAB_TOTAL INDEX SY-TABIX.

ENDLOOP.

ENDLOOP.

***********************For Material Document, year etc.

if ITAB_TOTAL[] is not initial.

select mblnr mjahr bldat budat xblnr

into corresponding fields of table i_mkpf

from mkpf

for all entries in ITAB_TOTAL

where

mblnr = ITAB_TOTAL-mblnr.

endif.

loop at i_mkpf.

loop at ITAB_TOTAL where mblnr = i_mkpf-mblnr.

ITAB_TOTAL-xblnr = i_mkpf-xblnr.

ITAB_TOTAL-bldat = i_mkpf-bldat.

ITAB_TOTAL-budat = i_mkpf-budat.

ITAB_TOTAL-mjahr = i_mkpf-mjahr.

MODIFY ITAB_TOTAL INDEX SY-TABIX.

ENDLOOP.

ENDLOOP.

I am capturing material doc & doc year in i_mkpf. Further I am modifying my main table (ITAB_FINAL) with i_mkpf.

Now from here onwards I have to get the A/c Document---->Amount and -


>G/L A/c.

Can you suggest how to go about it.

Regards,

Alok.

My material internal table has the Material Document

Former Member
0 Kudos

Try this:

  SELECT belnr gjahr
    FROM ekbe
    INTO TABLE ekbe_int
    WHERE ebeln = p_ebeln
    AND vgabe IN ('1', '2').                      "1 - GR, 2 - IR

  CHECK sy-subrc = 0.

  SORT ekbe_int.
  DELETE ADJACENT DUPLICATES FROM ekbe_int.

  LOOP AT ekbe_int INTO ekbe_wa.
    v_objectkey+00(10) = ekbe_wa-belnr.
    v_objectkey+10(10) = ekbe_wa-gjahr.           "BELNR+YEAR

    IF ekbe_wa-vgabe = '1'.
      v_reference = 'MKPF'.
    ELSE.
      v_reference = 'RMRP'.
    ENDIF.

    SELECT SINGLE bukrs belnr gjahr               "Accounting Doc Header
      FROM bkpf
      INTO doc_int
      WHERE awtyp =  v_reference
        AND awkey =  v_objectkey.
    IF sy-subrc = 0.
      APPEND doc_int.
    ENDIF.
  ENDLOOP.

Rob

0 Kudos

Dear Rob,

Thanks a lot for responding to my query.

The piece of code sent by you uses v_objectkey & v_reference. Kindly provide me respective definitions of the same so that I can try the same with my program also.

Regards,

Alok.

0 Kudos

They are the GR/IR numbers retrieved from EKBE (purchase order history).

Rob

0 Kudos

Kindly let me know how shall I define them in the declaration part. As I receive a message of their being unknown.

Regards,

Alok.

0 Kudos

Just define them like the corresponding fields of BKPF.

Rob