반응형
반응형
*&---------------------------------------------------------------------*
*& Report Z_CLEARING
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_clearing.
DATA : it_blntab LIKE blntab OCCURS 0 WITH HEADER LINE,
gt_ftclear LIKE ftclear OCCURS 0 WITH HEADER LINE,
gt_ftpost LIKE ftpost OCCURS 0 WITH HEADER LINE,
it_fttax LIKE fttax OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
PERFORM interface_start.
PERFORM interface_clearing.
PERFORM interface_end.
*&---------------------------------------------------------------------*
*& Form interface_start
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM interface_start.
DATA : lv_function LIKE rfipi-funct VALUE 'C', " B= BDC, C= Call Trans
lv_mode LIKE rfpdo-allgazmd VALUE 'N', "
lv_update LIKE rfpdo-allgvbmd VALUE 'S'.
CALL FUNCTION 'POSTING_INTERFACE_START'
EXPORTING
i_client = sy-mandt
i_function = lv_function
i_mode = lv_mode
i_update = lv_update
i_user = sy-uname
EXCEPTIONS
client_incorrect = 1
function_invalid = 2
group_name_missing = 3
mode_invalid = 4
update_invalid = 5
OTHERS = 6.
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.
*&---------------------------------------------------------------------*
*& Form interface_clearing
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM interface_clearing.
PERFORM prepare_ftpost.
PERFORM prepare_ftclear.
CALL FUNCTION 'POSTING_INTERFACE_CLEARING'
EXPORTING
i_auglv = 'UMBUCHNG'
i_tcode = 'FB05'
i_sgfunct = 'C'
TABLES
t_blntab = it_blntab
t_ftclear = gt_ftclear
t_ftpost = gt_ftpost
t_fttax = it_fttax
EXCEPTIONS
clearing_procedure_invalid = 1
clearing_procedure_missing = 2
table_t041a_empty = 3
transaction_code_invalid = 4
amount_format_error = 5
too_many_line_items = 6
company_code_invalid = 7
screen_not_found = 8
no_authorization = 9
OTHERS = 10.
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.
*&---------------------------------------------------------------------*
*& Form interface_end
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM interface_end.
CALL FUNCTION 'POSTING_INTERFACE_END'
EXPORTING
i_bdcimmed = 'X'
EXCEPTIONS
session_not_processable = 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.
*&---------------------------------------------------------------------*
*& Form prepare_ftpost
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM prepare_ftpost.
* Batch Input Values
gt_ftpost-stype = 'K'. " K:Header, P:Items
gt_ftpost-count = '001'. "number of Dynpro
gt_ftpost-fnam = 'BKPF-BLDAT'.
gt_ftpost-fval = sy-datum.
APPEND gt_ftpost.
gt_ftpost-fnam = 'BKPF-BUDAT'.
gt_ftpost-fval = sy-datum.
APPEND gt_ftpost.
gt_ftpost-fnam = 'BKPF-BLART'.
gt_ftpost-fval = 'SA'.
APPEND gt_ftpost.
gt_ftpost-fnam = 'BKPF-BUKRS'.
gt_ftpost-fval = '1000'.
APPEND gt_ftpost.
gt_ftpost-fnam = 'BKPF-BKTXT'.
gt_ftpost-fval = 'Document Header Text'.
APPEND gt_ftpost.
gt_ftpost-fnam = 'BKPF-WAERS'.
gt_ftpost-fval = 'KRW'.
APPEND gt_ftpost.
* gt_ftpost-FNAM = 'BKPF-XBLNR'.
* gt_ftpost-FVAL = PA_XBLNR.
* APPEND gt_ftpost.
* items
gt_ftpost-stype = 'P'.
gt_ftpost-count = '002'.
gt_ftpost-fnam = 'RF05A-NEWKO'.
gt_ftpost-fval = '115501231'. " 반제할 GL계정 (Clearing GL account)
APPEND gt_ftpost.
gt_ftpost-stype = 'P'.
gt_ftpost-count = '002'.
gt_ftpost-fnam = 'RF05A-NEWBS'.
gt_ftpost-fval = '50'.
APPEND gt_ftpost.
gt_ftpost-stype = 'P'.
gt_ftpost-count = '002'.
gt_ftpost-fnam = 'BSEG-WRBTR'.
gt_ftpost-fval = 500000.
SHIFT gt_ftpost-fval LEFT DELETING LEADING space.
APPEND gt_ftpost.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form prepare_ftclear
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM prepare_ftclear.
*Documents to be cleared
gt_ftclear-agkoa = 'K'. "Account Type
gt_ftclear-xnops = 'X'. "Indicator: Select only open items which are not
gt_ftclear-agbuk = '1000'. "Example company code
gt_ftclear-agkon = '0021138133'. "Example Customer
gt_ftclear-selfd = 'BELNR'."Selection Field
gt_ftclear-selvon = lt_belnr-belnr. " 하한 (low)
* gt_ftclear-selbis = '1400002309'. " 상한 (high)
APPEND gt_ftclear.
ENDFORM.
반응형