1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
REPORT ztest. *--------------------------------------------------------------------* * INTERNAL TABLE DECLARATION *--------------------------------------------------------------------* DATA: it_blntab TYPE TABLE OF blntab WITH HEADER LINE, it_ftclear TYPE TABLE OF ftclear WITH HEADER LINE, it_ftpost TYPE TABLE OF ftpost WITH HEADER LINE, it_fttax TYPE TABLE OF fttax WITH HEADER LINE. *--------------------------------------------------------------------* * START-OF-SELECTION *--------------------------------------------------------------------* START-OF-SELECTION. DEFINE populate_ftpost. it_ftpost-stype = &1. it_ftpost-count = &2. it_ftpost-fnam = &3. it_ftpost-fval = &4. append it_ftpost. END-OF-DEFINITION. DEFINE populate_ftclear. it_ftclear-agkoa = 'D'. it_ftclear-agbuk = 'XXXX'. "company code it_ftclear-selfd = 'BELNR'. it_ftclear-xnops = 'X'. it_ftclear-selvon = &1. append it_ftclear. END-OF-DEFINITION. CALL FUNCTION 'POSTING_INTERFACE_START' EXPORTING i_function = 'C' i_keep = 'X' i_mode = 'A' EXCEPTIONS client_incorrect = 1 function_invalid = 2 group_name_missing = 3 mode_invalid = 4 update_invalid = 5 OTHERS = 6. populate_ftpost: 'K' 1 'BKPF-BUKRS' 'BUKRS', "Company code 'K' 1 'BKPF-BLART' 'DA', 'K' 1 'BKPF-BLDAT' '16.09.2010', 'K' 1 'BKPF-BUDAT' '16.09.2010', 'K' 1 'BKPF-WAERS' 'RMB', 'K' 1 'BKPF-XBLNR' 'Test', 'P' 1 'RF05A-NEWBS' '11', 'P' 1 'BSEG-HKONT' '0090000052', 'P' 1 'BSEG-SGTXT' '20100916-01', 'P' 1 'BSEG-WRBTR' '52'. populate_ftclear '78000020772008001'. "concatenate doc number + fiscal year + line number CALL FUNCTION 'POSTING_INTERFACE_CLEARING' EXPORTING i_auglv = 'UMBUCHNG' i_tcode = 'FB05' i_sgfunct = 'C' IMPORTING e_msgid = sy-msgid e_msgno = sy-msgno e_msgty = sy-msgty e_msgv1 = sy-msgv1 e_msgv2 = sy-msgv2 e_msgv3 = sy-msgv3 e_msgv4 = sy-msgv4 * E_SUBRC = SY-SUBRC TABLES t_blntab = it_blntab t_ftclear = it_ftclear t_ftpost = it_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. CALL FUNCTION 'POSTING_INTERFACE_END' EXCEPTIONS session_not_processable = 1 OTHERS = 2. |
本文作者: GavinDong
版权属于: GavinDong博客
文章链接: https://gavindong.com/1707.html
如果使用过程中遇到问题,可 **点击此处** 交流沟通。
版权所有,转载时必须以链接形式注明作者和原始出处及本声明。
评论列表(2条)
*宏.
DEFINE populate_ftclear.
it_ftclear-agkoa = ‘D’. “科目类型,D为客户.
it_ftclear-agbuk = lv_ftclear_agbuk. “公司代码.
it_ftclear-selfd = ‘BELNR’. “凭证索引中的字段名.
it_ftclear-xnops = ‘X’. “只选择不是特定总帐的未清项目.
it_ftclear-selvon = &1. “会计凭证抬头参考号(BKPF-AWKEY).
append it_ftclear.
END-OF-DEFINITION.
DEFINE populate_ftpost.
it_ftpost-stype = &1. “K为header,P为item.
it_ftpost-count = &2. “凭证抬头或行项目的计数器(记帐界面).
it_ftpost-fnam = &3. “BDC 字段名.
it_ftpost-fval = &4. “BDC 字段值.
append it_ftpost.
END-OF-DEFINITION.
CALL FUNCTION ‘POSTING_INTERFACE_START’
EXPORTING
i_function = ‘C’ “B= BDC, C= Call Trans.
i_mode = ‘N’ “N表示BDC执行于后台.
i_update = ‘S’ “S: 数据更新完成后执行下一个操作
i_keep = ‘X’ “用于已处理会话的队列删除标志.
EXCEPTIONS
client_incorrect = 1
function_invalid = 2
group_name_missing = 3
mode_invalid = 4
update_invalid = 5
OTHERS = 6.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.