Hi IAM DEVELOPING A REPORT
to display information on a monthly basis about
the Number of vendor invoices processed per month .
i want to get data data from bseg based on data from bkpf.but iam missing some records in this process
can any body help with the logic.
DATA: BEGIN OF tbl_bkpf OCCURS 0,
bukrs Type bkpf-bukrs, "Company Code
belnr Type bkpf-belnr, "Accounting Documentnumber
tcode Type bkpf-tcode, "Transaction Code
cpudt Type bkpf-cpudt, "Created on
usnam Type bkpf-usnam,
END OF tbl_bkpf.
DATA: BEGIN OF tbl_bseg OCCURS 0,
bukrs Type bseg-bukrs, "Company Code
belnr Type bseg-belnr, "Accounting Documentnumber
werks Type bseg-werks, "Transaction Code
ebeln Type bseg-ebeln,
ebelp Type bseg-ebelp,
buzid Type bseg-buzid,
END OF tbl_bseg.
DATA: BEGIN OF tbl_output occurs 0,
g_bukrs LIKE bkpf-bukrs, "Company Code
g_belnr LIKE bkpf-belnr, "Accounting Documentnumber
g_tcode LIKE bkpf-tcode, "Transaction Code
g_cpudt LIKE bkpf-cpudt, "Created on
g_usnam LIKE bkpf-usnam, "User Name
g_ebeln LIKE bseg-ebeln, "Purchasing Document Number
g_ebelp LIKE bseg-ebelp, "Item Number
g_ekgrp LIKE ekko-ekgrp, "Purchasing Group
END OF tbl_output.
select bukrs belnr tcode cpudt usnam
from bkpf
into table tbl_bkpf
where
bukrs in s_bukrs and
cpudt in s_cpudt and
usnam in s_usnam and
tcode eq p_tcode.
if not tbl_bkpf[] is initial.
loop at tbl_bkpf.
select bukrs belnr ebeln ebelp buzid
from bseg
into table tbl_bseg
where bukrs eq tbl_bkpf-bukrs
and belnr eq tbl_bkpf-belnr.
loop at tbl_bseg into wa_bseg
where ( buzid in r_buzid
and ebeln ne ' ' ) or buzid eq 'S' AND EBELN EQ ' '.
IF SY-SUBRC eq 0.
DATA:l_ebeln LIKE ekko-ebeln.
MOVE wa_bseg-ebeln TO l_ebeln.
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
PI_EBELN = l_ebeln
IMPORTING
PO_EKKO = po_ekko
EXCEPTIONS
NO_RECORDS_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
if po_ekko is not initial.
tbl_output-g_ekgrp = po_ekko-ekgrp.
tbl_output-g_bukrs = wa_bseg-bukrs.
tbl_output-g_belnr = wa_bseg-belnr.
tbl_output-g_ebeln = wa_bseg-ebeln.
tbl_output-g_ebelp = wa_bseg-ebelp.
sort tbl_bkpf.
read table tbl_bkpf with key
belnr = wa_bseg-belnr
bukrs = wa_bseg-bukrs binary search.
if sy-subrc = 0.
tbl_output-g_tcode = tbl_bkpf-tcode.
tbl_output-g_cpudt = tbl_bkpf-cpudt.
tbl_output-g_usnam = tbl_bkpf-usnam.
APPEND tbl_output.
clear tbl_output.
endif.
endif.
endif.
endloop.
endloop.
endif.
ENDFORM. " GET_DATA