Professional Documents
Culture Documents
* Specifications:
* This report checks whether there exists
* manual postings on stock accounts (table t_non_bsx)
************************************************************************
*
DEFINITION PART
************************************************************************
* tables
TABLES:
bseg,
bkpf,
mbew,
t001,
t001k,
t030,
t030r,
t025.
* types
TYPES:
BEGIN OF ty_account_det,
bwkey LIKE t001k-bwkey,
bklas LIKE mbew-bklas,
konto LIKE t030-konth,
waers LIKE t001-waers,
END OF ty_account_det.
TYPE i,
"account of t030
f_no_material TYPE i,
f_summarization TYPE c.
* ranges
RANGES:
r_saknr FOR bseg-hkont.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) co_ccode FOR FIELD p_bukrs.
PARAMETER: p_bukrs LIKE bseg-bukrs MEMORY ID buk OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN COMMENT 1(33) co_saknr FOR FIELD p_saknr.
PARAMETER: p_saknr LIKE bseg-hkont MEMORY ID sak no-display.
SELECTION-SCREEN END OF LINE.
SELECT-OPTIONS: r_gjahr FOR bseg-gjahr NO-EXTENSION.
************************************************************************
*
INITIALIZATION
************************************************************************
INITIALIZATION.
co_ccode = 'Company code'.
************************************************************************
*
START-OF-SELECTION
************************************************************************
START-OF-SELECTION.
PERFORM
PERFORM
PERFORM
PERFORM
get_accounts.
clear_data.
get_bseg_data.
output_data.
************************************************************************
*
FORM ROUTINES
************************************************************************
***********************************************************************
* get accounts
***********************************************************************
FORM get_accounts.
DATA:
BEGIN OF lt_t030 OCCURS 0,
bklas LIKE t030-bklas,
bwmod LIKE t030-bwmod,
konts LIKE t030-konts,
konth LIKE t030-konth,
END OF lt_t030.
REFRESH lt_t030.
CLEAR r_saknr.
REFRESH r_saknr.
r_saknr-option = 'EQ'.
r_saknr-sign = 'I'.
* account entered? if not, use all accounts in company with processing
* key 'BSX'
*
*
*
*
*
ENDFORM.
" GET_ACCOUNTS
************************************************************************
* fill table t_account_det with acount determination info
************************************************************************
FORM account_determination.
CLEAR ls_account_det.
* find all possible combinations of valuation area/valuation class
SELECT * FROM t001k WHERE bukrs = p_bukrs.
* ls_account_det-bukrs = p_bukrs.
ls_account_det-bwkey = t001k-bwkey.
* all defined valuation classes
SELECT * FROM t025.
ls_account_det-bklas = t025-bklas.
APPEND ls_account_det TO t_account_det.
ENDSELECT.
ENDSELECT.
* make account determination for all entries in t_account_det
LOOP AT t_account_det INTO ls_account_det.
SELECT SINGLE * FROM t001k WHERE bwkey = ls_account_det-bwkey.
SELECT SINGLE * FROM t001 WHERE bukrs = p_bukrs.
ls_account_det-waers = t001-waers.
SELECT SINGLE * FROM t030r WHERE ktopl = t001-ktopl
AND ktosl = 'BSX'.
* If no valuation modification, delete BWMOD of valuation key
IF t030r-xbwmo IS INITIAL AND NOT t001k-bwmod IS INITIAL.
CLEAR t001k-bwmod.
ENDIF.
* If valuation class irrelevant, clear valuation class.
IF t030r-xbkla IS INITIAL.
CLEAR ls_account_det-bklas.
ENDIF.
* main account determination
SELECT SINGLE * FROM t030 WHERE ktopl = t001-ktopl
AND ktosl = 'BSX'
AND bwmod = t001k-bwmod
" ACCOUNT_DETERMINATION
************************************************************************
* clear flags and counters
************************************************************************
FORM clear_data.
CLEAR:
f_summarization,
f_num_bseg,
f_no_material.
ENDFORM.
" CLEAR_DATA
************************************************************************
* get entries of table BSEG
************************************************************************
FORM get_bseg_data.
DATA: c1 TYPE cursor.
OPEN CURSOR WITH HOLD c1 FOR
SELECT gjahr shkzg dmbtr belnr buzei ktosl
matnr bwkey bwtar hkont
FROM bseg WHERE bukrs = p_bukrs
AND hkont IN r_saknr
AND gjahr IN r_gjahr.
DO.
FETCH NEXT CURSOR c1 INTO
(bseg-gjahr, bseg-shkzg, bseg-dmbtr, bseg-belnr,
bseg-buzei, bseg-ktosl,
bseg-matnr, bseg-bwkey, bseg-bwtar, bseg-hkont).
IF sy-subrc <> 0.
EXIT.
ENDIF.
PERFORM check_fimm.
ENDDO.
CLOSE CURSOR c1.
ENDFORM.
" GET_BSEG_DATA
************************************************************************
* checks on bseg for check FI-MM
* fill table itabw with total value posted per material
* and t_non_bsx with non BSX postings
* seg f_summarization if document with missing material found
************************************************************************
FORM check_fimm.
* number of documents checked
f_num_bseg = f_num_bseg + 1.
* Summarization active?
IF bseg-matnr = space AND bseg-ktosl = 'BSX'.
f_summarization = 'X'.
f_no_material = f_no_material + 1.
ENDIF.
* documents from R/2 have no ktosl! matnr should be filled
IF bseg-ktosl = 'BSX' OR
( bseg-matnr <> space AND bseg-ktosl = space ).
* one document with summarization found, no sense to collect data
CHECK f_summarization IS INITIAL.
* collect total of values per material
MOVE-CORRESPONDING bseg TO itabw.
IF bseg-shkzg = 'H'.
itabw-dmbtr = 0 - itabw-dmbtr.
ENDIF.
COLLECT itabw.
ENDIF.
* non-bsx posting:
IF bseg-ktosl <> 'BSX'.
MOVE-CORRESPONDING bseg TO t_non_bsx.
APPEND t_non_bsx.
ENDIF.
ENDFORM.
" CHECK_FIMM
***********************************************************************
* output data
***********************************************************************
FORM output_data.
* input data
PERFORM out_input_data.
* checked accounts
SUMMARY.
WRITE: / 'Account checked:'.
DETAIL.
LOOP AT r_saknr.
WRITE: / r_saknr-low.
ENDLOOP.
SKIP 1.
ULINE.
* Number of BSEG entries
SUMMARY.
WRITE:/'Number of BSEG-entries checked:', f_num_bseg.
SKIP 1.
ULINE.
* non BSX-postings
PERFORM out_non_bsx_posting.
ENDFORM.
" OUTPUT_DATA
************************************************************************
" OUT_INPUT_DATA
************************************************************************
* output of postings without processing key 'BSX'
************************************************************************
FORM out_non_bsx_posting.
DATA:
total_dif LIKE mbew-salk3,
total_s LIKE mbew-salk3,
total_h LIKE mbew-salk3,
l_index_z LIKE sy-tabix,
f_euro(1) type c.
DESCRIBE TABLE t_non_bsx LINES l_index_z.
IF l_index_z > 0.
SORT t_non_bsx BY hkont.
SUMMARY.
WRITE:/ 'Postings with processing key <> BSX'.
SKIP 1.
WRITE: / 'Acc.Doc',
14 'Year',
20 'Line',
25 'Post.key',
40 'Amount',
49 'Debit/credit'.
LOOP AT t_non_bsx.
AT NEW hkont.
SKIP 1.
WRITE:/ 'Account', t_non_bsx-hkont.
CLEAR: total_h, total_s, l_index_z.
ENDAT.
l_index_z = l_index_z + 1.
clear f_euro.
* sum debit/credit values
IF t_non_bsx-shkzg = 'H' and f_euro is initial.
total_h = total_h + t_non_bsx-dmbtr.
ELSEIF t_non_bsx-shkzg = 'S' and f_euro is initial.
total_s = total_s + t_non_bsx-dmbtr.
ENDIF.
DETAIL.
WRITE: / t_non_bsx-belnr,
14 t_non_bsx-gjahr,
20 t_non_bsx-buzei,
25 t_non_bsx-ktosl.
write:
" OUT_NON_BSX_POSTING