代码来自跟踪FB03会计凭证查看里的利润中心会计凭证查看:
先贴代码
DATA: lw_awtyp TYPE acchd-awtyp, lw_awref TYPE acchd-awref, lw_aworg TYPE acchd-aworg, lt_documents TYPE STANDARD TABLE OF acc_doc. lw_awtyp = 'BKPFF'. lw_awref = ls_alv-belnr. CONCATENATE ls_alv-rbukrs ls_alv-ryear INTO lw_aworg. CALL FUNCTION 'AC_DOCUMENT_RECORD' EXPORTING i_awtyp = lw_awtyp i_awref = lw_awref i_aworg = lw_aworg x_dialog = space TABLES t_documents = lt_documents EXCEPTIONS no_reference = 1 no_document = 2 OTHERS = 3. READ TABLE lt_documents ASSIGNING FIELD-SYMBOL(<fs_documents>) WITH KEY awtyp = 'COPCA'. IF sy-subrc = 0. <fs_documents>-display = abap_true. ENDIF. CALL FUNCTION 'COPCA_DOCUMENT_RECORD' EXPORTING i_awtyp = lw_awtyp i_awref = lw_awref i_aworg = lw_aworg i_awtyp_incl = 'COPCA' TABLES t_documents = lt_documents.
函数AC_DOCUMENT_RECORD可获取所有的会计凭证衍生出来的所有的控制凭证、利润中心凭证、物料账凭证等等,COPCA_DOCUMENT_RECORD则是对利润中心报表的一个展示。