201704 F-02创建财务凭证
一、F-02 创建财务凭证-BDC 期初余额导入程序
程序:ZFIU_LDV_F_02_UPLOAD
创建F-02 凭证:
*&---------------------------------------------------------------------------------------------------- CALL TRANSACTION 'F-02'
USING it_bdcdata
MODE mode_f
UPDATE 'S'
MESSAGES INTO it_bdcmsge.
READ TABLE it_bdcmsge INDEX .
it_msg_tab-msgtyp = it_bdcmsge-msgtyp.
it_msg_tab-msgid = it_bdcmsge-msgid.
it_msg_tab-msgnr = it_bdcmsge-msgnr.
IF it_bdcmsge-msgid NE space.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = it_bdcmsge-msgid
msgnr = it_bdcmsge-msgnr
msgv1 = it_bdcmsge-msgv1
msgv2 = it_bdcmsge-msgv2
msgv3 = it_bdcmsge-msgv3
msgv4 = it_bdcmsge-msgv4
IMPORTING
message_text_output = msg_text.
it_msg_tab-text = msg_text.
ELSE.
it_msg_tab-text = '======成功创建======'.
ENDIF.
* MOVE it_upload_data-col01 TO it_msg_tab-saknr.
APPEND it_msg_tab.
*&----------------------------------------------------------------------------------------------------
SAPMF05A |
100 |
X |
||
0 |
BDC_OKCODE |
/00 |
||
0 |
BKPF-BLDAT |
20170411 |
||
0 |
BKPF-BLART |
SA |
||
0 |
BKPF-BUKRS |
CV00 |
||
0 |
BKPF-BUDAT |
20170411 |
||
0 |
BKPF-MONAT |
4 |
||
0 |
BKPF-WAERS |
CNY |
||
0 |
BKPF-XBLNR |
参照 |
||
0 |
BKPF-BKTXT |
凭证抬头文本 |
||
0 |
BKPF-KURSF |
1 |
||
0 |
RF05A-NEWBS |
40 |
||
0 |
RF05A-NEWKO |
6608990200 |
||
0 |
RF05A-NEWUM |
|||
SAPMF05A |
300 |
X |
||
0 |
BDC_OKCODE |
/00 |
||
0 |
BSEG-WRBTR |
30 |
||
0 |
BSEG-ZUONR |
|||
0 |
BSEG-SGTXT |
|||
0 |
RF05A-NEWBS |
|||
0 |
RF05A-NEWKO |
|||
SAPLKACB |
2 |
X |
||
0 |
BDC_OKCODE |
#NAME? |
||
SAPMF05A |
300 |
X |
||
0 |
BDC_OKCODE |
#NAME? |
||
0 |
BSEG-WRBTR |
|||
0 |
BSEG-ZUONR |
|||
0 |
BSEG-SGTXT |
|||
SAPLKACB |
2 |
X |
||
0 |
BDC_OKCODE |
#NAME? |
二、BAPI_ACC_DOCUMENT_POST
创建供应商,客户,总账凭证,
*&---------------------------------------- FUNCTION zfifm_receipt_posting .
*"----------------------------------------------------------------------
*"*"Local interface:
*" EXPORTING
*" VALUE(ERRCODE) TYPE CHAR8
*" VALUE(ERRDESC) TYPE CHAR250
*" TABLES
*" IT_HEAD STRUCTURE ZSFI_DOC_HEAD OPTIONAL
*" IT_ITEM STRUCTURE ZSFI_DOC_ITEM OPTIONAL
*" OT_HEAD STRUCTURE ZSFI_DOC_HEAD_O OPTIONAL
*"----------------------------------------------------------------------
DATA: t_head TYPE STANDARD TABLE OF ztfi_doc_head WITH HEADER LINE,
t_item TYPE STANDARD TABLE OF ztfi_doc_item WITH HEADER LINE.
DATA: lt_item TYPE STANDARD TABLE OF ztfi_doc_item WITH HEADER LINE.
g_datum = sy-datum.
g_uzeit = sy-uzeit. *---- Mapping Data
PERFORM frm_mapping_data TABLES t_head
t_item
it_head
it_item. LOOP AT t_head.
idx_tabix = sy-tabix. CLEAR: lt_item , lt_item[].
LOOP AT t_item WHERE zsernr = t_head-zsernr.
MOVE-CORRESPONDING t_item TO lt_item.
APPEND lt_item.
ENDLOOP. *---- 数据检查
PERFORM frm_check_data1 TABLES lt_item USING t_head. IF t_head-proce <> ''.
MODIFY t_head INDEX idx_tabix.
CONTINUE.
ENDIF. *---- 创建会计凭证
PERFORM frm_create_fi_doc TABLES lt_item USING t_head. MODIFY t_head INDEX idx_tabix.
ENDLOOP. LOOP AT t_head.
MOVE-CORRESPONDING t_head TO ot_head.
IF ot_head-proce = 'W' AND ot_head-belnr <> ''.
ot_head-proce = 'S'.
ENDIF.
APPEND ot_head.
ENDLOOP. *---- 自定义表更新
MODIFY ztfi_doc_head FROM TABLE t_head.
MODIFY ztfi_doc_item FROM TABLE t_item.
COMMIT WORK AND WAIT. *---- 返回码
IF t_head[] IS NOT INITIAL.
READ TABLE t_head INDEX .
IF t_head-proce = 'S'.
errcode = 'S0000000'.
ELSE.
errcode = 'E0468001'.
errdesc = t_head-message.
ENDIF.
ENDIF. ENDFUNCTION. *&---------------------------------------------------------------------------------------------------- FORM frm_create_fi_doc TABLES lt_item STRUCTURE ztfi_doc_item
USING wa_head STRUCTURE ztfi_doc_head.
DATA: documentheader LIKE bapiache09.
DATA: customercpd LIKE bapiacpa09.
DATA: accountgl TYPE STANDARD TABLE OF bapiacgl09 WITH HEADER LINE,
accountreceivable TYPE STANDARD TABLE OF bapiacar09 WITH HEADER LINE,
accountpayable TYPE STANDARD TABLE OF bapiacap09 WITH HEADER LINE,
accounttax TYPE STANDARD TABLE OF bapiactx09 WITH HEADER LINE,
currencyamount TYPE STANDARD TABLE OF bapiaccr09 WITH HEADER LINE,
criteria TYPE STANDARD TABLE OF bapiackec9 WITH HEADER LINE,
lt_return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE. DATA: obj_type LIKE bapiache09-obj_type,
obj_key LIKE bapiache09-obj_key,
obj_sys LIKE bapiache09-obj_sys. documentheader-username = sy-uname.
documentheader-doc_type = wa_head-blart.
documentheader-header_txt = wa_head-bktxt.
documentheader-comp_code = wa_head-bukrs.
documentheader-doc_date = wa_head-bldat.
documentheader-pstng_date = sy-datum."wa_head-budat.
documentheader-ref_doc_no = wa_head-xblnr. LOOP AT lt_item. documentheader-neg_postng = lt_item-xnegp. *---- 金额
CLEAR: currencyamount.
currencyamount-itemno_acc = lt_item-buzei.
currencyamount-currency = wa_head-waers.
currencyamount-amt_doccur = lt_item-wrbtr.
currencyamount-exch_rate = wa_head-kursf.
IF lt_item-shkzg ='H'." lt_item-bschl = '50' OR lt_item-bschl = '11' OR lt_item-bschl = '39' OR lt_item-bschl = '31'.
currencyamount-amt_doccur = - currencyamount-amt_doccur.
ENDIF.
APPEND currencyamount. CASE lt_item-flag.
WHEN 'D'.
*---- 客户
accountreceivable-itemno_acc = lt_item-buzei.
accountreceivable-customer = lt_item-hkont.
* ACCOUNTRECEIVABLE-gl_account = lt_item-hkont.
accountreceivable-item_text = lt_item-sgtxt.
accountreceivable-alloc_nmbr = lt_item-zuonr.
accountreceivable-bline_date = lt_item-zfbdt.
accountreceivable-sp_gl_ind = lt_item-umskz.
* ACCOUNTRECEIVABLE-costcenter = lt_item-kostl.
APPEND accountreceivable. *----- 一次性客户信息
SELECT SINGLE * FROM kna1 WHERE kunnr = lt_item-hkont.
IF kna1-xcpdk = 'X'.
customercpd-name = lt_item-sgtxt.
customercpd-city = lt_item-sgtxt.
customercpd-country = 'CN'.
customercpd-bank_ctry = 'CN'.
ENDIF.
WHEN 'K'.
*---- 供应商
accountpayable-itemno_acc = lt_item-buzei.
accountpayable-vendor_no = lt_item-hkont.
* ACCOUNTRECEIVABLE-gl_account = lt_item-hkont.
accountpayable-item_text = lt_item-sgtxt.
accountpayable-alloc_nmbr = lt_item-zuonr.
accountpayable-bline_date = lt_item-zfbdt.
accountpayable-sp_gl_ind = lt_item-umskz.
* accountpayable-costcenter = lt_item-kostl.
APPEND accountpayable. WHEN OTHERS.
*---- 总帐科目
accountgl-itemno_acc = lt_item-buzei.
accountgl-gl_account = lt_item-hkont.
accountgl-item_text = lt_item-sgtxt.
accountgl-alloc_nmbr = lt_item-zuonr.
accountgl-costcenter = lt_item-kostl.
APPEND accountgl. ENDCASE.
ENDLOOP. CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = documentheader
customercpd = customercpd
* CONTRACTHEADER = CONTRACTHEADER
IMPORTING
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
TABLES
accountgl = accountgl
accountreceivable = accountreceivable
accountpayable = accountpayable
accounttax = accounttax
currencyamount = currencyamount
* CRITERIA = CRITERIA
* VALUEFIELD = VALUEFIELD
* EXTENSION1 = EXTENSION1
return = lt_return
* PAYMENTCARD = PAYMENTCARD
* CONTRACTITEM = CONTRACTITEM
* EXTENSION2 = EXTENSION2
* REALESTATE = REALESTATE
* ACCOUNTWT = ACCOUNTWT
. READ TABLE lt_return WITH KEY type = 'E'.
IF sy-subrc = .
LOOP AT lt_return WHERE type = 'E'.
wa_head-proce = 'E'.
CONCATENATE wa_head-message lt_return-message INTO wa_head-message SEPARATED BY ' '.
ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
wa_head-belnr = obj_key+().
wa_head-gjahr = obj_key+().
wa_head-proce = 'S'.
wa_head-message = '凭证创建成功!'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'. ENDIF.
ENDFORM. "FRM_CREATE_FI_DOC
三、SE37 函数创建凭证,测试使用
1.SE37初始界面,
2.菜单:FUNCTION MODULE-> TEST-> TEST sequences
3. BAPI_ACC_DOCUMENT_POST
+BAPI_TRANSACTION_COMMIT (提交数据)
*&------------------------------------------------------------------------------------------------
BAPI_TRANSACTION_COMMIT (测试)
*&------------------------------------------------------------------------------------------------
创建F-02 凭证 测试参数
- 运行第一个函数
得到 财务凭证:100000035
2.运行第二个函数,提交凭证,
201704 F-02创建财务凭证的更多相关文章
- 【三石jQuery视频教程】02.创建 FontAwesome 复选框和单选框
视频地址:http://v.qq.com/page/m/8/c/m0150izlt8c.html 大家好,欢迎来到[三石jQuery视频教程],我是您的老朋友 - 三生石上. 今天,我们要通过基本的H ...
- mysql笔记02 创建高性能的索引
创建高性能的索引 1. 索引(在MySQL中也叫做"键(key)")是存储引擎用于快速找到记录的一种数据结构. 2. 索引可以包含一个或多个列的值.如果索引包含多个列,那么列的顺序 ...
- pl/sql programming 02 创建并运行plsql代码
/* * chap 02 * ------------------------------------------------- */ create or replace function wordc ...
- 【Linux常用工具】02. 创建启动定时任务工具cron
一. cron 1. cron是一个守护程序,它提供定时器的功能,让用户在特定的时间得以执行默认的指令或程序.只要用户会编辑定时器的设置文件,就可以使用定时器的功能. 定时器文件格式: 2. cron ...
- Angular问题02 创建模块失败、 angular-cli名称问题、升级angular-cli
1 创建模块失败 1.1 问题描述 利用 ng g m 模块名 创建新模块时出错 1.2 错误信息 1.3 问题原因 angular-cli 版本出现问题 1.4 解决办法 卸载掉之前使用的 angu ...
- Python小游戏——外星人入侵(保姆级教程)第一章 01创建Pygame窗口 02创建设置类Setting()
系列文章目录 第一章:武装飞船 01:创建Pygame窗口以及响应用户输入 02:创建设置类Setting() 一.前期准备 1.语言版本 Python3.9.0 2.编译器 Pycharm2022 ...
- Swift游戏实战-跑酷熊猫 02 创建熊猫类
要点: 如何继承SKSpriteNode :子类必须调用SKSpriteNode的一个指定构造器 init(){ super.init(texture:texture,color:UIColor.wh ...
- cxf的使用及安全校验-02创建简单的客户端接口
上一篇文章中,我们已经讲了如果简单的创建一个webservice接口 http://www.cnblogs.com/snowstar123/p/3395568.html 现在我们创建一个简单客户端接口 ...
- 【UiPath 中文教程】02 - 创建自定义 Activity
在 UiPath Studio 中,活动 (Activity) 是流程自动化的基石,是构成自动化程序的最小模块.它们被包含在一个个 NuGet 包中. UiPath Studio 中有 3 类包: 官 ...
随机推荐
- javascript 中对象的拷贝
http://blog.csdn.net/i10630226/article/details/52431562 在javascript中,对象都是值引用,也就是说,如果你常规的使用 "=&q ...
- unity, UGUI Text fadeIn
错误写法: Color color = m_text.GetComponent<Text> ().color; Color startColor = new Color (c ...
- 安卓开发之玩美解决ADT和SDK不一致问题
提示:This Android SDK requires Android Developer Toolkit version 21.1.0 or above. Current version is ...
- 影子寄存器(shadow register)
1.以下仅供参考:有阴影的寄存器,表示在物理上这个寄存器对应2个寄存器,一个是程序员可以写入或读出的寄存器,称为preload register(预装载寄存器),另一个是程序员看不见的.但在操作中真正 ...
- [ci] 基于1 上文实现拉取代码后能自动触发sonar-runner实现代码扫描评测,job1完成
基于1 上文实现拉取代码后能自动触发sonar-runner实现代码扫描评测,job1完成 添加sonar插件 SonarQube Plugin 配置: 系统设置à告知jenkins,sona ...
- 关于ZBarReaderView 打开闪光灯
关于ZBarReaderView 打开闪光灯 ZBarReaderView *readerView; - (void)changeLight:(id)sender{ UIButton *btn = ( ...
- hud项目lcd调试
lcd规格: 像素:480x280 bpp:16 pix_format:RGB565 在开发板终端中执行: ls /dev/fb0 -l ---> crw-rw---- 1 root ...
- 第一百八十八节,jQuery,选项卡 UI
jQueryUI,选项卡 UI 学习要点: 1.使用 tabs 2.修改 tabs 样式 3.tabs()方法的属性 4.tabs()方法的事件 5.tabs 中使用 on 选项卡(tab),是一种能 ...
- Eclipse 窗口说明
Eclipse 窗口说明 Eclipse 工作台(Workbench) 首先,让我们来看一下Eclipse 作台用户界面,和它里面的各种组件. 工作台是多个窗口的集合.每个窗口包含菜单栏,工具栏,快捷 ...
- cobbler 更换dns和dhcp服务器为dnsmasq
1) 需要配置/etc/cobbler/module.conf, 把manage_dns和manage_dhcp改为manage_dnsmasq 2) 重启cobbler和dnsmasq服务,dnsm ...