Posted: Sat Oct 13, 2007 12:51 pm Post subject: Parked/Posted Document Detail
Code:
REPORT: ZFIR00112 LINE-SIZE 1023 LINE-COUNT 65
NO STANDARD PAGE HEADING MESSAGE-ID ZV.
*=======================================================================
* Program Name: ZFIR00110
* Create Date: 07/19/2005
* Author: Rajib Das / Tracy Ferguson
* ----------------------------------------------------------------------
* Description: Parked/Posted Document Detail
*
*=======================================================================
* TABLES
*=======================================================================
**DECLARE ALL TABLES HERE
tables: bkpf, " Accounting Document Header
lfa1, " Vendor Master (General Section)
rbkp, " Document Header: Invoice Receipt
rseg, " Document Item: Incoming Invoice
rlgrap. " Program Fields/Screen Fields for SAPLGRAP
selection-screen begin of block a1 with frame title text-001.
select-options : s_bukrs for rbkp-bukrs, " Company Code
s_ent_dt for rbkp-cpudt, " Entry Date
s_ent_by for rbkp-erfnam, " Entered By
s_ptd_by for rbkp-usnam, " Posted By
s_post for rbkp-budat, " Posting Date
s_amt for rbkp-rmwwr, " Amount
s_d_dt for rbkp-budat. " new calculated date field
selection-screen end of block a1.
selection-screen begin of block a2 with frame title text-002.
parameters : p_parked radiobutton group 001, " Parked Documents
p_posted radiobutton group 001, " Posted Documents
p_all radiobutton group 001. " All Documents
selection-screen end of block a2.
selection-screen begin of block a3 with frame title text-003.
parameters : p_sort_d radiobutton group 002, " Discount Due Date
p_sort_a radiobutton group 002, " Assignment
p_sort_v radiobutton group 002, " Vendor
p_sort_t radiobutton group 002, " Document Type
p_doc_ty radiobutton group 002, " Text (first 4)
p_pst_by radiobutton group 002. " Posted by
selection-screen end of block a3.
*selection-screen begin of block a4 with frame title text-004.
*
*parameters : p_d_exl as checkbox default 'X',
* p_file like rlgrap-filename default 'C:\temp\report.xls'.
*
*selection-screen end of block a4.
************************************************************************
*INITIALIZATION.
************************************************************************
data : cal_awkey(20) type C, " reference key for accounting doc nbr
accounting_doc_nbr like bkpf-belnr, " accounting doc nbr
ebeln like rseg-ebeln. " purchase doc nbr
* join data
data: begin of it_rbkp occurs 0,
belnr like rbkp-belnr, " Document number of an invoice doc
bktxt like rbkp-bktxt, " Document Header Text
blart like rbkp-blart, " Document type
bldat like rbkp-bldat, " Document Date in Document
budat like rbkp-budat, " Posting Date in the Document
bukrs like rbkp-bukrs, " Company Code
cpudt like rbkp-cpudt, " Accounting Document Entry Date
erfnam like rbkp-erfnam, " Name of the Proc Who Entered the obj
gjahr like rbkp-gjahr, " Fiscal Year
lifnr like rbkp-lifnr, " Different invoicing party
rbstat like rbkp-rbstat, " Invoice document status
rmwwr like rbkp-rmwwr, " Gross invoice amount in document curr
sgtxt like rbkp-sgtxt, " Item Text
usnam like rbkp-usnam, " User name
name1 like lfa1-name1, " name1
wskto like rbkp-wskto, " Cash discount amount in document curr
xblnr like rbkp-xblnr, " Reference Document Number
zbd1p like rbkp-zbd1p, " Cash discount percentage 1
zbd1t like rbkp-zbd1t, " Cash discount days 1
zbd2t like rbkp-zbd2t, " Cash discount days 2
zfbdt like rbkp-zfbdt, " Baseline date for due date calc
zterm like rbkp-zterm, " Terms of payment key
zuonr like rbkp-zuonr, " Assignment number
end of it_rbkp.
* final data
data: begin of it_alldata occurs 0,
belnr like rbkp-belnr, " Document number of an invoice doc
bktxt like rbkp-bktxt, " Document Header Text
blart like rbkp-blart, " Document type
bldat like rbkp-bldat, " Document Date in Document
budat like rbkp-budat, " Posting Date in the Document
bukrs like rbkp-bukrs, " Company Code
cpudt like rbkp-cpudt, " Accounting Document Entry Date
erfnam like rbkp-erfnam, " Name of the Proc Who Entered the obj
gjahr like rbkp-gjahr, " Fiscal Year
lifnr like rbkp-lifnr, " Different invoicing party
rbstat like rbkp-rbstat, " Invoice document status
rmwwr like rbkp-rmwwr, " Gross invoice amount in document curr
sgtxt like rbkp-sgtxt, " Item Text
usnam like rbkp-usnam, " User name
name1 like lfa1-name1, " name1
wskto like rbkp-wskto, " Cash discount amount in document curr
xblnr like rbkp-xblnr, " Reference Document Number
zbd1p like rbkp-zbd1p, " Cash discount percentage 1
zbd1t like rbkp-zbd1t, " Cash discount days 1
zbd2t like rbkp-zbd2t, " Cash discount days 2
zfbdt like rbkp-zfbdt, " Baseline date for due date calc
zterm like rbkp-zterm, " Terms of payment key
zuonr like rbkp-zuonr, " Assignment number
accounting_doc_nbr like bkpf-belnr, " acct doc number
ebeln like rseg-ebeln, " Purchasing Document Number
end of it_alldata.
data : wa_it_alldata like it_alldata.
type-pools: slis. "ALV Declarations
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
*&---------------------------------------------------------------------*
*& Form data_retrieval
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM data_retrieval .
* only parked docs
if p_parked = 'X'.
select rbkp~belnr
rbkp~bktxt
rbkp~blart
rbkp~bldat
rbkp~budat
rbkp~bukrs
rbkp~cpudt
rbkp~erfnam
rbkp~gjahr
rbkp~lifnr
rbkp~rbstat
rbkp~rmwwr
rbkp~sgtxt
rbkp~usnam
lfa1~name1
rbkp~wskto
rbkp~xblnr
rbkp~zbd1p
rbkp~zbd1t
rbkp~zbd2t
rbkp~zfbdt
rbkp~zterm
rbkp~zuonr
into corresponding fields of table it_rbkp
from
( rbkp inner join lfa1 on rbkp~lifnr = lfa1~lifnr )
where rbkp~bukrs in s_bukrs
and rbkp~cpudt in s_ent_dt
and rbkp~erfnam in s_ent_by
and rbkp~usnam in s_ptd_by
and rbkp~budat in s_post
and rbkp~rmwwr in s_amt
and rbkp~rbstat in ('A','B','C','D','E').
* only posted docs
elseif p_posted = 'X'.
select rbkp~belnr
rbkp~bktxt
rbkp~blart
rbkp~bldat
rbkp~budat
rbkp~bukrs
rbkp~cpudt
rbkp~erfnam
rbkp~gjahr
rbkp~lifnr
rbkp~rbstat
rbkp~rmwwr
rbkp~sgtxt
rbkp~usnam
lfa1~name1
rbkp~wskto
rbkp~xblnr
rbkp~zbd1p
rbkp~zbd1t
rbkp~zbd2t
rbkp~zfbdt
rbkp~zterm
rbkp~zuonr
into corresponding fields of table it_rbkp
from
( rbkp inner join lfa1 on rbkp~lifnr = lfa1~lifnr )
where rbkp~bukrs in s_bukrs
and rbkp~cpudt in s_ent_dt
and rbkp~erfnam in s_ent_by
and rbkp~usnam in s_ptd_by
and rbkp~budat in s_post
and rbkp~rmwwr in s_amt
and rbkp~rbstat in ('5').
* all docs
else.
select rbkp~belnr
rbkp~bktxt
rbkp~blart
rbkp~bldat
rbkp~budat
rbkp~bukrs
rbkp~cpudt
rbkp~erfnam
rbkp~gjahr
rbkp~lifnr
rbkp~rbstat
rbkp~rmwwr
rbkp~sgtxt
rbkp~usnam
lfa1~name1
rbkp~wskto
rbkp~xblnr
rbkp~zbd1p
rbkp~zbd1t
rbkp~zbd2t
rbkp~zfbdt
rbkp~zterm
rbkp~zuonr
into corresponding fields of table it_rbkp
from
( rbkp inner join lfa1 on rbkp~lifnr = lfa1~lifnr )
where rbkp~bukrs in s_bukrs
and rbkp~cpudt in s_ent_dt
and rbkp~erfnam in s_ent_by
and rbkp~usnam in s_ptd_by
and rbkp~budat in s_post
and rbkp~rmwwr in s_amt
and rbkp~rbstat in ('A','B','C','D','E','5').
endif.
loop at it_rbkp.
select ebeln up to 1 rows into ebeln from rseg
where belnr = it_rbkp-belnr.
endselect.
* the awkey(bkpf) is a combination of
* belnr(invoice#) and gjahr(fiscal year)
concatenate it_rbkp-belnr it_rbkp-gjahr into cal_awkey.
select single belnr into accounting_doc_nbr
from bkpf
where awkey = cal_awkey.
it_alldata-belnr = it_rbkp-belnr. " LIV Nbr
it_alldata-bktxt = it_rbkp-bktxt. " Header Text
it_alldata-blart = it_rbkp-blart. " DT
it_alldata-bldat = it_rbkp-bldat. " Inv Date
it_alldata-budat = it_rbkp-budat. " Post Date
it_alldata-bukrs = it_rbkp-bukrs.
it_alldata-cpudt = it_rbkp-cpudt. " Entry Date
it_alldata-erfnam = it_rbkp-erfnam.
it_alldata-gjahr = it_rbkp-gjahr.
it_alldata-lifnr = it_rbkp-lifnr. " Vendor
it_alldata-rbstat = it_rbkp-rbstat. " Status
it_alldata-rmwwr = it_rbkp-rmwwr. " Amount
it_alldata-sgtxt = it_rbkp-sgtxt. " Text
it_alldata-usnam = it_rbkp-usnam. " Entered by
" Posted by
it_alldata-name1 = it_rbkp-name1. " Name
it_alldata-wskto = it_rbkp-wskto. " Dis Amt
it_alldata-xblnr = it_rbkp-xblnr. " Reference
it_alldata-zbd1p = it_rbkp-zbd1p. " Pct
it_alldata-zbd1t = it_rbkp-zbd1t. " Days 1
" Disc Due Date
" # of Days
it_alldata-zbd2t = it_rbkp-zbd2t. " Net Days
" Net Due Date
" # of Days
it_alldata-zfbdt = it_rbkp-zfbdt. " Bline Date
it_alldata-zterm = it_rbkp-zterm. " PayTerm
it_alldata-zuonr = it_rbkp-zuonr. " Assignment
it_alldata-accounting_doc_nbr = accounting_doc_nbr. " Doc Nbr
it_alldata-ebeln = ebeln. " Purch Doc
append it_alldata.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
form build_fieldcatalog.
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* Display report using ALV grid
*----------------------------------------------------------------------*
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
* is_variant = z_template
tables
t_outtab = it_alldata
exceptions
program_error = 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.
endform. " DISPLAY_ALV_REPORT
*-------------------------------------------------------------------*
* Form TOP-OF-PAGE *
*-------------------------------------------------------------------*
* ALV Report Header *
*-------------------------------------------------------------------*
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'Parked/Posted Document Detail'.
append wa_header to t_header.
clear wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
* Total No. of Records Selected
describe table it_alldata lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
*------------------------------------------------------------------*
* FORM USER_COMMAND *
*------------------------------------------------------------------*
* --> R_UCOMM *
* --> RS_SELFIELD *
*------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
** Read data table, using index of row user clicked on
* READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
** Set parameter ID for transaction screen field
* SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
** Execute transaction ME23N, and skip initial data entry screen
* CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form BUILD_EVENTS
*&---------------------------------------------------------------------*
* Build events table
*----------------------------------------------------------------------*
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*&---------------------------------------------------------------------*
*& Form BUILD_PRINT_PARAMS
*&---------------------------------------------------------------------*
* Setup print parameters
*----------------------------------------------------------------------*
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*&---------------------------------------------------------------------*
*& Form END_OF_PAGE
*&---------------------------------------------------------------------*
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
*&---------------------------------------------------------------------*
*& Form END_OF_LIST
*&---------------------------------------------------------------------*
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.