首页 > 其他分享 >F-02会计凭证和冲销

F-02会计凭证和冲销

时间:2023-05-25 16:15:01浏览次数:38  
标签:02 会计凭证 lw lt 冲销 criteria currencyamount accountgl LIKE

*&---------------------------------------------------------------------*
*& Report ZPOST_DOCUMENT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zpost_document.

DATA: lw_documentheader LIKE  bapiache09,
      lw_customercpd    LIKE  bapiacpa09,
      lw_contractheader LIKE  bapiaccahd.

DATA: lt_accountgl         LIKE  STANDARD TABLE OF bapiacgl09, "S总帐/A资产
      lt_accountreceivable LIKE  STANDARD TABLE OF bapiacar09, "D客户
      lt_accountpayable    LIKE  STANDARD TABLE OF bapiacap09, "K供应商
      lt_accounttax        LIKE  STANDARD TABLE OF bapiactx09,
      lt_currencyamount    LIKE  STANDARD TABLE OF bapiaccr09,
      lt_criteria          LIKE  STANDARD TABLE OF bapiackec9,
      lt_valuefield        LIKE  STANDARD TABLE OF bapiackev9, "CO 获利字段
      lt_extension1        LIKE  STANDARD TABLE OF bapiacextc,
      lt_return            LIKE  STANDARD TABLE OF bapiret2,
      lt_paymentcard       LIKE  STANDARD TABLE OF bapiacpc09,
      lt_contractitem      LIKE  STANDARD TABLE OF bapiaccait,
      lt_extension2        LIKE  STANDARD TABLE OF bapiparex,  "
      lt_realestate        LIKE  STANDARD TABLE OF bapiacre09,
      lt_accountwt         LIKE  STANDARD TABLE OF bapiacwt09.

DATA: lw_accountgl         LIKE  bapiacgl09,
      lw_accountreceivable LIKE  bapiacar09,
      lw_accountpayable    LIKE  bapiacap09,
      lw_accounttax        LIKE  bapiactx09,
      lw_currencyamount    LIKE  bapiaccr09,
      lw_criteria          LIKE  bapiackec9,
      lw_valuefield        LIKE  bapiackev9,
      lw_extension1        LIKE  bapiacextc,
      lw_return            LIKE  bapiret2,
      lw_paymentcard       LIKE  bapiacpc09,
      lw_contractitem      LIKE  bapiaccait,
      lw_extension2        LIKE  bapiparex,
      lw_realestate        LIKE  bapiacre09,
      lw_accountwt         LIKE  bapiacwt09.


DATA: wa_zexten         LIKE yfs0006."增强

DATA: lv_obj_type LIKE  bapiache09-obj_type,
      lv_obj_key  LIKE  bapiache09-obj_key,
      lv_obj_sys  LIKE  bapiache09-obj_sys.


CLEAR lw_documentheader.
lw_documentheader-username    = sy-uname.
*lw_documentheader-fisc_year   = '2022'.
lw_documentheader-doc_date    = '20230310'."Document Date
lw_documentheader-pstng_date  = '20230306'."Posting Date
*lw_documentheader-fis_period  = '12'.
lw_documentheader-doc_type    = 'RV'."Document Type
lw_documentheader-comp_code   = 'A101'."Company code
*lw_documentheader-ref_doc_no  = ''."Reference


"D
CLEAR:lw_accountreceivable.
lw_accountreceivable-itemno_acc = 10.
lw_accountreceivable-customer = 'A110000916' .
lw_accountreceivable-comp_code = 'A101' .
lw_accountreceivable-gl_account = '110202ZZZZ'.
lw_accountreceivable-item_text =  '37111791'.
APPEND lw_accountreceivable TO lt_accountreceivable.

"S
CLEAR: lw_accountgl.
lw_accountgl-itemno_acc = 20.
lw_accountreceivable-comp_code = 'A101' .
lw_accountgl-gl_account = '23040102ZZ'.
lw_accountgl-item_text =  '37111791'.
APPEND lw_accountgl TO lt_accountgl.

CLEAR: lw_accountgl.
lw_accountgl-itemno_acc = 30.
lw_accountreceivable-comp_code = 'A101' .
lw_accountgl-gl_account = '51010401ZZ'.
lw_accountgl-profit_ctr = 'U1CS1030'.
lw_accountgl-doc_type   = 'RV'.
lw_accountgl-pstng_date = '20230306'.
lw_accountgl-item_text =  '37111791'.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    input  = lw_accountgl-costcenter
  IMPORTING
    output = lw_accountgl-costcenter.
APPEND lw_accountgl TO lt_accountgl.


CLEAR: lw_currencyamount.
lw_currencyamount-itemno_acc = 10.
lw_currencyamount-curr_type   =  '00'.
lw_currencyamount-currency   =  'CNY'.  "货币
lw_currencyamount-amt_doccur =  '100'.  "金额
APPEND lw_currencyamount TO lt_currencyamount.


CLEAR: lw_currencyamount.
lw_currencyamount-itemno_acc = 20.
lw_currencyamount-curr_type   =  '00'.
lw_currencyamount-currency   =  'CNY'.  "货币
lw_currencyamount-amt_doccur =  '-50'.  "金额
APPEND lw_currencyamount TO lt_currencyamount.


CLEAR: lw_currencyamount.
lw_currencyamount-itemno_acc = 30.
lw_currencyamount-curr_type   =  '00'.
lw_currencyamount-currency   =  'CNY'.  "货币
lw_currencyamount-amt_doccur =  '-50'.  "金额
APPEND lw_currencyamount TO lt_currencyamount.


CLEAR lw_criteria .
lw_criteria-itemno_acc = 30 .
lw_criteria-fieldname = 'PRCTR'.
lw_criteria-character = 'U1CS1030'.
APPEND lw_criteria TO lt_criteria .


CLEAR lw_criteria .
lw_criteria-itemno_acc = 30 .
lw_criteria-fieldname = 'KNDNR'.
lw_criteria-character = 'A110000916'.
APPEND lw_criteria TO lt_criteria .

CLEAR lw_criteria .
lw_criteria-itemno_acc = 30 .
lw_criteria-fieldname = 'ARTNR'.
lw_criteria-character = 'A71V782'.
APPEND lw_criteria TO lt_criteria .


CLEAR lw_criteria .
lw_criteria-itemno_acc = 30 .
lw_criteria-fieldname = 'FKART'.
lw_criteria-character = 'ZD01'.
APPEND lw_criteria TO lt_criteria .

CLEAR: wa_zexten.
wa_zexten-posnr   = 10.  "行号
wa_zexten-bschl = '01'.        "记帐码
lw_extension2-structure  = 'YFS0006'.
lw_extension2-valuepart1 = wa_zexten.
APPEND lw_extension2 TO lt_extension2.



CLEAR: wa_zexten.
wa_zexten-posnr   = 20.  "行号
wa_zexten-bschl = '50'.  "记帐码
lw_extension2-structure  = 'YFS0006'.
lw_extension2-valuepart1 = wa_zexten.
APPEND lw_extension2 TO lt_extension2.

CLEAR: wa_zexten.
wa_zexten-posnr   = 30.  "行号
wa_zexten-bschl = '50'.  "记帐码
lw_extension2-structure  = 'YFS0006'.
lw_extension2-valuepart1 = wa_zexten.
APPEND lw_extension2 TO lt_extension2.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
  EXPORTING
    documentheader    = lw_documentheader
*   customercpd       = lw_customercpd
*   contractheader    = lw_contractheader
  IMPORTING
    obj_type          = lv_obj_type
    obj_key           = lv_obj_key
    obj_sys           = lv_obj_sys
  TABLES
    accountgl         = lt_accountgl
    accountreceivable = lt_accountreceivable
    accountpayable    = lt_accountpayable
*   accounttax        = lt_accounttax
    currencyamount    = lt_currencyamount
    criteria          = lt_criteria
    valuefield        = lt_valuefield
*   extension1        = lt_extension1
    return            = lt_return
*   paymentcard       = lt_paymentcard
*   contractitem      = lt_contractitem
    extension2        = lt_extension2.
*    realestate        = lt_realestate
*    accountwt         = lt_accountwt.



*IF lv_obj_key = '$'.
*  lv_obj_key = ''.
*  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
*
*ELSE.
*
*  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*    EXPORTING
*      wait = 'X'.
*
*ENDIF.
*
*LOOP AT lt_return INTO lw_return.
*
*ENDLOOP.



*冲销FB08

DATA: lt_bdcdata TYPE TABLE OF bdcdata,
      ls_bdcdata TYPE bdcdata,
      lt_messtab TYPE TABLE OF bdcmsgcoll,
      ls_messtab TYPE bdcmsgcoll,
      lt_return1 TYPE TABLE OF bapiret2.

DATA lv_mode TYPE char4 VALUE 'N'.
DATA lv_update TYPE char4 VALUE 'S'.
DATA lv_message TYPE string.

REFRESH: lt_bdcdata,lt_messtab,lt_return1.
CLEAR:ls_bdcdata,ls_messtab.

PERFORM bdc_dynpro      USING 'SAPMF05A' '0105'.
PERFORM bdc_field       USING 'BDC_CURSOR'
                              'RF05A-BELNS'.
PERFORM bdc_field       USING 'BDC_OKCODE'
                              '=BU'.
PERFORM bdc_field       USING 'RF05A-BELNS'
                              '2100000009'.
PERFORM bdc_field       USING 'BKPF-BUKRS'
                              'A101'.
PERFORM bdc_field       USING 'RF05A-GJAHS'
                              '2023'.
PERFORM bdc_field       USING 'UF05A-STGRD'
                              '02'.
PERFORM bdc_field       USING 'BSIS-BUDAT'
                              sy-datum.

CALL TRANSACTION 'FB08' USING lt_bdcdata
                        MODE lv_mode
                        UPDATE lv_update
                        MESSAGES INTO lt_messtab.

CALL FUNCTION 'CONVERT_BDCMSGCOLL_TO_BAPIRET2'
  TABLES
    imt_bdcmsgcoll = lt_messtab
    ext_return     = lt_return1.


READ TABLE lt_messtab INTO ls_messtab WITH KEY msgtyp = 'S'.
IF sy-subrc = 0.

*  READ TABLE lt_return1 INTO ls_return1 INDEX 1.


ELSE.
*  LOOP AT lt_return1 INTO DATA(ls_return1) WHERE type = 'E'.
*     gs_info-icon_light_info = 'E'.
*     gs_info-message_info = '失败!' && ls_bapi_return-MESSAGE.
*  ENDLOOP.

ENDIF.




BREAK-POINT.


*----------------------------------------------------------------------*
*        Start new screen                                              *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
  CLEAR ls_bdcdata.
  ls_bdcdata-program  = program.
  ls_bdcdata-dynpro   = dynpro.
  ls_bdcdata-dynbegin = 'X'.
  APPEND ls_bdcdata TO lt_bdcdata.

ENDFORM.

*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
*  IF FVAL <> NODATA.
  CLEAR ls_bdcdata.
  ls_bdcdata-fnam = fnam.
  ls_bdcdata-fval = fval.
  APPEND ls_bdcdata TO lt_bdcdata.

*  ENDIF.
ENDFORM.

 

标签:02,会计凭证,lw,lt,冲销,criteria,currencyamount,accountgl,LIKE
From: https://www.cnblogs.com/Anyohh233/p/17431586.html

相关文章

  • 《AutoCAD2020中文版基础教程》和《从零开始—AutoCAD 2020中文版基础教程》配套资源
    《AutoCAD2020中文版基础教程》作者:姜春峰//武小紅//魏春雪中国青年出版社配套资源链接:https://pan.baidu.com/s/1kPGNKZEw2kOTGqZyXjpG7A?pwd=ux06提取码:ux06 《从零开始—AutoCAD2020中文版基础教程》配套资源链接:https://pan.baidu.com/s/1GRA57IbIVyeM17qMkkzugw提取码:q......
  • ICML 2023 | 轻量级视觉Transformer (ViT) 的预训练实践手册
    前言 本文介绍一下最近被ICML2023接收的文章:ACloserLookatSelf-SupervisedLightweightVisionTransformers.文章聚焦在轻量级ViT的预训练上,相当于为相关方向的研究提供了一个benchmark,相关的代码与模型也都会开源,方便后续大家在这一方向上继续探索。文章的研究也打破......
  • 2020年下半年--学习量化监测保证进展
    感觉好久没用博客了,还是需要一个这样的记录,来量化学习情况,进行监测,保证进展以下链接为我学习的脑图,可以说是我学习笔记的精华了,内容很多,大家可以自行打开,展开看链接:http://note.youdao.com/noteshare?id=cc2a896077547b8ee77853a7801508fd&sub=738D6A43ABAF44D187A74BE274B67F63QA......
  • 2021 ICPC 江西省大学生程序设计竞赛(正式赛)
    链接:https://ac.nowcoder.com/acm/contest/21592BC++Code#include"bits/stdc++.h"usingnamespacestd;usingi64=longlong;voidsolve(){intx,y;cin>>x>>y;intcnt=0;vector<int>ans;while(1)......
  • Altium Designer 2023软件安装包下载AD2023安装教程
    安装步骤1、将下载好的安装包鼠标右击,选择解压2、解压得到一个安装文件夹,打开它3、继续打开 【setup】文件夹4、鼠标右击【Installer】,选择 以管理员身份运行5、点击【Next】6、语言选择到【Chinese】勾选【同意条款】,点击【Next】7、点击【Next】8、点击小文件夹图标,选择安装位......
  • Altium Designer 2022软件安装包下载AD2022安装教程
    安装步骤1、将下载好的安装包鼠标右击,选择解压2、解压得到一个安装文件夹,打开它3、鼠标右击【Installer】,选择 以管理员身份运行4、点击【Next】5、语言选择到【Chinese】勾选【同意条款】,点击【Next】6、点击【Next】7、点击小文件夹图标,选择安装位置,可以把安装盘C直接改成D或其......
  • Altium Designer 2021软件安装包下载AD2021安装教程
    安装步骤1、将下载好的安装包鼠标右击,选择解压2、解压得到一个安装文件夹,打开它3、鼠标右击【AltiumDesigner21Setup】,选择 以管理员身份运行4、点击【Next】5、语言选择到【Chinese】勾选【同意条款】,点击【Next】6、点击【Next】7、点击小文件夹图标,选择安装位置,可以把安装盘C......
  • Kotlin学习 02
    在前一次只能选择省份简称的基础上,增加了输入车牌号码的交互这次主要是自己动手写代码实现:1、动态生成7位的车牌输入框EditText2、省份是选择的,车牌号是手动输入的3、点击清除实现了最后一位的删除,并自动将焦点移动到前面框中自己实现一些功能之后,确实发现kotlin能剩下很多......
  • C/C++图书信息管理系统[2023-05-25]
    C/C++图书信息管理系统[2023-05-25]图书信息管理系统主要内容:整个图书管理系统采用结构体作为基本数据结构,最终数据一定要保存到数据文件中。主函数通过switch语句来根据用户的需求跳转到各个模块,以实现用户的需要。系统要求能进行图书信息的浏览、添加、查询、修改、删除......
  • 成功加冕!用友大易获评2023最佳招聘管理软件供应商
    人力资源服务业旗帜性商业奖项2023金帜奖(HRFLAGAWARDS)颁奖典礼于近日隆重举行。经过3个月的评选,用友大易从615家人力资源服务机构中脱颖而出,最终荣获「2023最佳招聘管理软件供应商」奖项。2023金帜奖(HRFLAGAWARDS)是人力资源服务行业旗帜性的商业奖项,遵循「寻找旗帜性人力资源......