`
Jack Wu
  • 浏览: 892001 次
  • 来自: ...
社区版块
存档分类
最新评论

Accounting Docs Automatically Created from MM

阅读更多

This program lists accounting documents that were automatically created from MM, and also lists the MM source documents. It can take several minutes to run, depending on the amount of data in the database, because it has to access (slow) cluster tables.

Accounting Docs Automatically Created from MM

 

*&---------------------------------------------------------------------*
*& Report  ZFIMMDOC                                                    *
*& Listing of accounting docs and the material docs from which they    *
*& were automatically created.                                         *
*&---------------------------------------------------------------------*
REPORT  ZFIMMDOC  MESSAGE-ID Z1 LINE-COUNT 65 NO STANDARD PAGE HEADING.
TABLES: BKPF, MSEG, MKPF, T001, BSIM, T001K, MARA, BSEG, SKAT,
        MAKT, T156T.
INCLUDE: ZFIMMTOP.                     "types mymseg_type

PARAMETERS: COMPANYC LIKE BKPF-BUKRS OBLIGATORY, " default '1101',
            YEAR LIKE BKPF-GJAHR OBLIGATORY, " default '1998'.
            POSTDATE LIKE BKPF-BUDAT OBLIGATORY.
SELECT-OPTIONS: VAL_AREA FOR BSIM-BWKEY NO-DISPLAY,
                S_MBLNR FOR MSEG-MBLNR NO-DISPLAY,
                S_BELNR FOR BSEG-BELNR NO-DISPLAY.

DATA: MYBUTXT LIKE T001-BUTXT,
      LINES TYPE I,
      PREVIOUS_BELNR LIKE BKPF-BELNR,
      PREVIOUS_AWKEY LIKE BKPF-AWKEY,
      MYTXT50 LIKE SKAT-TXT50,
      BEGIN OF X001K OCCURS 20.
        INCLUDE STRUCTURE T001K.
DATA: END OF X001K.
DATA: BEGIN OF MYBKPF OCCURS 100,
        BLART LIKE BKPF-BLART,         "doc type
        BELNR LIKE BKPF-BELNR,         "doc no
        WAERS LIKE BKPF-WAERS,         "currency key
        AWKEY LIKE BKPF-AWKEY,
      END OF MYBKPF.
DATA: BEGIN OF MYBSIM  OCCURS 500.
INCLUDE TYPE MYBSIM_TYPE.
DATA: END OF MYBSIM.
DATA: BEGIN OF MYBSEG OCCURS 1200,
        BELNR LIKE BSEG-BELNR,
        BUZEI LIKE BSEG-BUZEI,
        BSCHL LIKE BSEG-BSCHL,
        HKONT LIKE BSEG-HKONT,
        WRBTR LIKE BSEG-WRBTR,
        SHKZG LIKE BSEG-SHKZG,         "debit/credit
      END OF MYBSEG.
  DATA:  BEGIN OF MYMSEG OCCURS 500.
  INCLUDE TYPE MYMSEG_TYPE.
  DATA: END OF MYMSEG.

PERFORM GET_BKPF.
PERFORM GET_BSIM.
PERFORM COLLECT_BELNR.
PERFORM GET_BSEG.
PERFORM COLLECT_MBLNR.
PERFORM GET_MSEG.

SORT MYBSIM BY BELNR.
SORT MYMSEG BY MBLNR ZEILE.
SORT MYBSEG BY BELNR BUZEI.
LOOP AT MYBSIM.
  IF MYBSIM-SHKZG = 'H'.               "negative value
    MYBSIM-DMBTR = ( -1 ) * MYBSIM-DMBTR.
  ENDIF.
  PERFORM WRITE_BSIM_DATA USING MYBSIM.
  AT END OF BELNR.  "new belnr record: get bseg recs
      PERFORM WRITE_BSEG_DATA USING MYBSIM-BELNR.
  ENDAT.
  AT END OF AWKEY.
    PERFORM WRITE_MSEG_DATA USING MYBSIM-AWKEY(10).
  ENDAT.
  WRITE: SY-ULINE.
ENDLOOP.
WRITE: / 'number of records accessed'.
DESCRIBE TABLE MYBKPF LINES LINES.
WRITE: / 'bkpf:', LINES.
DESCRIBE TABLE MYBSIM LINES LINES.
WRITE: / 'bsim:', LINES.
DESCRIBE TABLE MYMSEG LINES LINES.
WRITE: / 'mseg:', LINES.
DESCRIBE TABLE MYBSEG LINES LINES.
WRITE: / 'bseg:', LINES.

AT SELECTION-SCREEN.
* get company text
  SELECT SINGLE BUTXT FROM T001 INTO MYBUTXT
         WHERE BUKRS = COMPANYC.
* get valuation areas from company code
  REFRESH VAL_AREA. CLEAR VAL_AREA.
  SELECT * FROM T001K INTO TABLE X001K
                      WHERE BUKRS = COMPANYC.
  LOOP AT X001K.
    VAL_AREA-SIGN = 'I'. VAL_AREA-OPTION = 'EQ'.
    VAL_AREA-LOW = X001K-BWKEY.
    APPEND VAL_AREA.
  ENDLOOP.
  READ TABLE VAL_AREA INDEX 1.

TOP-OF-PAGE.
  PERFORM WRITE_HEADER.

*&---------------------------------------------------------------------*
*&      Form  GET_BKPF
*&---------------------------------------------------------------------*
FORM GET_BKPF.
* get bkpf records
* should perform authority check here **
  SELECT BLART BELNR WAERS AWKEY
         INTO CORRESPONDING FIELDS OF TABLE MYBKPF
         FROM BKPF
         WHERE BUKRS = COMPANYC AND GJAHR = YEAR AND BUDAT = POSTDATE
         ORDER BY BELNR.
ENDFORM.                               " GET_BKPF

*&---------------------------------------------------------------------*
*&      Form  GET_BSIM
*----------------------------------------------------------------------*
FORM GET_BSIM.
  LOOP AT MYBKPF.
    MYBSIM-BLART = MYBKPF-BLART.
    MYBSIM-BELNR = MYBKPF-BELNR.
    MYBSIM-WAERS = MYBKPF-WAERS.
    MYBSIM-AWKEY = MYBKPF-AWKEY.
* should perform authority check here **
*   select bsim records using conditions gjahr, bwkey, belnr
    SELECT BELNR BUZEI DMBTR MATNR BUDAT MENGE MEINS
           INTO CORRESPONDING FIELDS OF MYBSIM
           FROM BSIM
           WHERE GJAHR = YEAR AND
              BELNR = MYBKPF-BELNR AND
              BWKEY IN VAL_AREA.
      APPEND MYBSIM.
    ENDSELECT.
  ENDLOOP.
ENDFORM.                               " GET_BSIM

*&---------------------------------------------------------------------*
*&      Form  get_bseg
*&---------------------------------------------------------------------*
FORM GET_BSEG.
* should perform authority check here **
*   select bseg records using conditions bukrs, belnr, gjahr
  SELECT BELNR BUZEI BSCHL HKONT WRBTR SHKZG
         INTO CORRESPONDING FIELDS OF TABLE MYBSEG
         FROM BSEG
    WHERE GJAHR = YEAR AND
          BUKRS = COMPANYC AND
          BELNR IN S_BELNR.
ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  GET_MSEG
*&---------------------------------------------------------------------*
FORM GET_MSEG.
* should perform authority check here **
    SELECT MBLNR
           ZEILE BWART MATNR LGORT MENGE MEINS WAERS SHKZG DMBTR WERKS
           KOSTL SOBKZ KZBEW KZZUG KZVBR
           INTO CORRESPONDING FIELDS OF TABLE MYMSEG
           FROM MSEG
           WHERE MJAHR = YEAR AND MBLNR IN S_MBLNR.
  WRITE:  SY-ULINE.
ENDFORM.                               " GET_AND_WRITE_MATDOC
*&---------------------------------------------------------------------*
*&      Form  WRITE_HEADER
*----------------------------------------------------------------------*
FORM WRITE_HEADER.
  DATA: MYOPTION(11) TYPE C, MYSIGN(7) TYPE C, "explain select criteria
        SELECT_TEXT(60) TYPE C, SELECT_POSITION TYPE I.
  WRITE: TEXT-000,
         TEXT-001.                     "company and report header
  IF SY-PAGNO = 1.                     "**** first page
    WRITE: / 'Company Code', COMPANYC, MYBUTXT,
             'Accounting Year', YEAR, 'Posting Date:', POSTDATE.
  ENDIF.                               "**** first page
  WRITE: / 'Generated', SY-DATUM, SY-UZEIT,
           'Page', SY-PAGNO, SY-ULINE.
* format for accounting docs
  FORMAT COLOR COL_GROUP.
  WRITE: / 'DT',
       4 'acct doc',
       15 'material',
       25 'item',
       31 'Posted',
       42(12) 'Quantity',
          'Unit',
       61 '         balance'.
  FORMAT COLOR OFF.
  WRITE: / 'item' UNDER 'item', 30 'Code', 35 'Account',
                45 'Description',
          61 '         balance'.
* format for material docs
  FORMAT COLOR COL_TOTAL.
  WRITE: / 'MatrialDoc' UNDER 'acct doc',
           'Posted' UNDER 'Posted', 'Entered' UNDER 'Description',
            76 ' '.
  FORMAT COLOR OFF.
  WRITE: /10 'item',
             'Material' UNDER 'Material',
             25 'Plant',
             'Stor' UNDER 'Code',
             'Mvmt' UNDER 'Account',
             42(12) 'Quantity',
             'Unit',
          61 '         balance',
         /11 'MaterialDesc',
             'MovementType' UNDER 'Quantity',
          60  'CostCtr'.
  WRITE: SY-ULINE.
ENDFORM.                               " WRITE_HEADER
*&---------------------------------------------------------------------*
*&      Form  WRITE_MKPF_DATA
*&---------------------------------------------------------------------*
FORM WRITE_MKPF_DATA USING F_MSEG TYPE MYMSEG_TYPE
                           F_MAKTX LIKE MAKT-MAKTX
                           F_BTEXT LIKE T156T-BTEXT.
  WRITE: /    F_MSEG-ZEILE UNDER 'item',
              F_MSEG-MATNR UNDER 'material',
              F_MSEG-WERKS UNDER 'Plant',
              F_MSEG-LGORT UNDER 'Stor',
              F_MSEG-BWART UNDER 'Mvmt',
          (12)F_MSEG-MENGE UNDER 'Quantity' DECIMALS 2,
              F_MSEG-MEINS UNDER 'Unit',
              F_MSEG-DMBTR UNDER '         balance'.
  WRITE: /    F_MAKTX UNDER 'MaterialDesc',
              F_BTEXT UNDER 'MovementType',
              F_MSEG-KOSTL UNDER 'CostCtr'.
ENDFORM.                               " WRITE_MKPF_DATA

*&---------------------------------------------------------------------*
*&      Form  WRITE_MKPF_HEADER
*&---------------------------------------------------------------------*
FORM WRITE_MKPF_HEADER USING P_MBLNR LIKE MKPF-MBLNR.
  DATA: MYBUDAT LIKE MKPF-BUDAT, MYCPUDT LIKE MKPF-CPUDT.
  SELECT SINGLE BUDAT CPUDT FROM MKPF
         INTO (MYBUDAT, MYCPUDT)
         WHERE MBLNR = P_MBLNR AND MJAHR = YEAR.
  IF SY-SUBRC = 0. "got record
    FORMAT COLOR COL_TOTAL.
    WRITE: / P_MBLNR UNDER 'acct doc',
             MYBUDAT UNDER 'Posted',
             MYCPUDT UNDER 'Entered',
          76 ' '.
    FORMAT COLOR OFF.
  ENDIF.
ENDFORM.                               " WRITE_MKPF_HEADER
*&---------------------------------------------------------------------*
*&      Form  WRITE_BSIM_DATA
*&---------------------------------------------------------------------*
FORM WRITE_BSIM_DATA USING F_BSIM TYPE MYBSIM_TYPE.
  FORMAT COLOR COL_GROUP.
  WRITE: / F_BSIM-BLART UNDER 'DT',
           F_BSIM-BELNR UNDER 'acct doc',
           F_BSIM-MATNR UNDER 'material',
           F_BSIM-BUZEI UNDER 'Plant', "item
           F_BSIM-BUDAT UNDER 'Posted',
           (12)F_BSIM-MENGE UNDER 'Quantity' DECIMALS 2,
           F_BSIM-MEINS UNDER 'Unit',
           F_BSIM-DMBTR UNDER '         balance' RIGHT-JUSTIFIED.
  FORMAT COLOR OFF.
ENDFORM.                               " WRITE_BSIM_DATA

*&---------------------------------------------------------------------*
*&      Form  WRITE_BSEG_DATA
*&---------------------------------------------------------------------*
FORM WRITE_BSEG_DATA USING P_BELNR.
  LOOP AT MYBSEG WHERE BELNR = P_BELNR.
    SELECT SINGLE TXT50 INTO MYTXT50 FROM SKAT
           WHERE SPRAS = '1' AND KTOPL = 'HFCA' AND
                 SAKNR = MYBSEG-HKONT.
    IF MYBSEG-SHKZG = 'H'.             "negative value
      MYBSEG-WRBTR = ( -1 ) * MYBSEG-WRBTR.
    ENDIF.
    WRITE: / MYBSEG-BUZEI UNDER 'Plant', "item
             MYBSEG-BSCHL UNDER 'Code',
             MYBSEG-HKONT UNDER 'Account',
             MYTXT50      UNDER 'Description',
             MYBSEG-WRBTR UNDER '         balance'.
  ENDLOOP.
ENDFORM.                               " WRITE_BSEG_DATA
*&---------------------------------------------------------------------*
*&      Form  COLLECT_MBLNR
*&---------------------------------------------------------------------*
FORM COLLECT_MBLNR.
  SORT MYBSIM BY AWKEY.
  S_MBLNR-SIGN = 'I'.
  S_MBLNR-OPTION = 'EQ'.
  LOOP AT MYBSIM.
    AT NEW AWKEY.
      S_MBLNR-LOW = MYBSIM-AWKEY(10).
      APPEND S_MBLNR.
    ENDAT.
  ENDLOOP.
  READ TABLE S_MBLNR INDEX 1.
ENDFORM.                    " COLLECT_MBLNR
*&---------------------------------------------------------------------*
*&      Form  COLLECT_BELNR
*&---------------------------------------------------------------------*
FORM COLLECT_BELNR.
  S_BELNR-SIGN = 'I'.
  S_BELNR-OPTION = 'EQ'.
  SORT MYBSIM BY BELNR.
  LOOP AT MYBSIM.
    AT NEW BELNR.
      S_BELNR-LOW = MYBSIM-BELNR.
      APPEND S_BELNR.
    ENDAT.
  ENDLOOP.
  READ TABLE S_BELNR INDEX 1.
ENDFORM.                    " COLLECT_BELNR
*&---------------------------------------------------------------------*
*&      Form  WRITE_MSEG_DATA
*&---------------------------------------------------------------------*
FORM WRITE_MSEG_DATA USING P_MBLNR LIKE MSEG-MBLNR.
  DATA: MYBTEXT LIKE T156T-BTEXT,
        MYMAKTX LIKE MAKT-MAKTX.
  PERFORM WRITE_MKPF_HEADER USING P_MBLNR.
  LOOP AT MYMSEG WHERE MBLNR = P_MBLNR.
    SELECT SINGLE BTEXT INTO MYBTEXT FROM T156T
             WHERE SPRAS = '1' AND
                   BWART = MYMSEG-BWART AND
                   SOBKZ = MYMSEG-SOBKZ AND
                   KZBEW = MYMSEG-KZBEW AND
                   KZZUG = MYMSEG-KZZUG AND
                  KZVBR = MYMSEG-KZVBR.
    SELECT SINGLE MAKTX INTO MYMAKTX FROM MAKT
           WHERE SPRAS = '1' AND MATNR = MYMSEG-MATNR.
    IF MYMSEG-SHKZG = 'H'.
      MYMSEG-DMBTR = ( -1 ) * MYMSEG-DMBTR.
    ENDIF.
    PERFORM WRITE_MKPF_DATA USING MYMSEG MYMAKTX MYBTEXT.
  ENDLOOP.
ENDFORM.                    " WRITE_MSEG_DATA


* end of ZFIMMDOC program *

* begin of ZFIMMTOP include program *
*----------------------------------------------------------------------*
*   INCLUDE ZFIMMTOP                                                   *
*----------------------------------------------------------------------*
  TYPES: BEGIN OF MYMSEG_TYPE,
          MBLNR LIKE MSEG-MBLNR,
          ZEILE LIKE MSEG-ZEILE,
          BWART LIKE MSEG-BWART,
          MATNR LIKE MSEG-MATNR,
          WERKS LIKE MSEG-WERKS,
          LGORT LIKE MSEG-LGORT,
          MENGE LIKE MSEG-MENGE,
          MEINS LIKE MSEG-MEINS,
          WAERS LIKE MSEG-WAERS,
          SHKZG LIKE MSEG-SHKZG,
          DMBTR LIKE MSEG-DMBTR,
          KOSTL LIKE MSEG-KOSTL,
          SOBKZ LIKE MSEG-SOBKZ,       " for goods movement text
          KZBEW LIKE MSEG-KZBEW,       " for goods movement text
          KZZUG LIKE MSEG-KZZUG,       " for goods movement text
          KZVBR LIKE MSEG-KZVBR,       " for goods movement text
        END OF MYMSEG_TYPE.
TYPES: BEGIN OF MYBSIM_TYPE,
        BLART LIKE BKPF-BLART,         "doc type
        BELNR LIKE BKPF-BELNR,         "doc no
        WAERS LIKE BKPF-WAERS,
        AWKEY LIKE BKPF-AWKEY,
        BUZEI LIKE BSIM-BUZEI,         "doc item
        MATNR LIKE BSIM-MATNR,
        BUDAT LIKE BSIM-BUDAT,
        MENGE LIKE BSIM-MENGE,         "quantity
        MEINS LIKE BSIM-MEINS,         "unit of measure
        SHKZG LIKE BSIM-SHKZG,         "debit/credit
        DMBTR LIKE BSIM-DMBTR,         "balance amount
      END OF MYBSIM_TYPE.
* end of ZFIMMDOC include *
 来源:http://www.geocities.com/SiliconValley/Grid/4858/sap/ABAPCode/FIMMdocs.htm
分享到:
评论

相关推荐

    Automatically exported from code.google.compprotobuf-matlab.zip

    标题和描述中提到的"Automatically exported from code.google.compprotobuf-matlab.zip"表明这是一个从code.google.com导出的项目,与Protocol Buffers(protobuf)和MATLAB有关。protobuf是一种序列化数据的开源...

    手机管理器

    /* Automatically generated from i_pp_data_def.h : "Nov 5 2008" */ /* * "rm217" Product Profile File * * Copyright (c) Nokia Mobile Phones. All rights reserved. * * File creation date : "Nov 5 ...

    Ant To Download the code from SVN automatically

    标题“Ant To Download the code from SVN automatically”涉及的是使用Apache Ant工具自动化从Subversion (SVN) 下载代码的过程。Apache Ant是一个Java库和命令行工具,它的设计目的是驱动构建过程,尤其在Java项目...

    Dropbox 3.14.7 Offline Installer / DROPBOX 离线安装文件

    Take your docs anywhereSave files on your computer, then access them on your phone from the road. Everything you keep in Dropbox is synced automatically to all your devices. Send videos quickly Send...

    c++网络嗅探器源码两个

    You can download source code packages and Windows installers which are automatically created each time code is checked into the source code repository". These packages are available in the automated ...

    This is an automatically generated MAKEFILE tool.

    This is an automatically generated MAKEFILE tool. A very useful libraries. LINUX projects in Lane is a good helper.

    DIContainers v5.7.0 D7-XE10.1 容器

    DIContainers is a collection of more than 100 individual container classes for Delphi (Embarcadero,... The graphic was automatically created from the DIContainers library by one of the demo applications.

    DIContainers 5.5.0 Source Code

    DIContainers is a collection of more than 100 different container classes for Borland / CodeGear ... The graphic was automatically created from the DIContainers library by one of the demo applications.

    SAP MM customizing

    ### SAP MM 定制化知识点概述 #### 一、组织结构定义 1. **定义公司与地区** - **路径**:一般设置 — 设置国家 — 插入地区。 - **事务代码**:OVK2。 - **描述**:在 SAP MM 的定制化过程中,首先需要定义...

    Natural_Language_Processing_of_Semitic_Language

    自然语言处理(NLP)是计算机科学、人工智能和语言学领域的一个分支,它涉及到如何让计算机理解和处理人类语言的问题。它包括将自然语言转化为计算机可以处理的形式,然后对这些数据进行分析和解释,最终让计算机...

    高级java笔试题-srgb:学习收藏代码库_Automaticallyexportedfromcode.google.com/p/srgb

    高级java笔试题 香橙派挂载玩客云移动硬盘适合PT root@orangepizero:/var$ smbclient -L 192.168.1.90 -N Sharename Type Comment --------- ---- ------- 8cb3 Disk Reconnecting with SMB1 for ...

    github-action-version-pr:一个GitHub Action创建一个请求版本控制的请求

    # The GitHub automatically created secret to use in your workflow for authentications. # see: https://docs.github.com/en/actions/reference/authentication-in-a-workflow # Can be obtained from ${{ ...

    2.Liu_RankIQA_Learning_From_ICCV_2017_paper.pdf

    These ranked image sets can be automatically generated without laborious human labeling. We then use fine-tuning to transfer the knowledge represented in the trained Siamese Network to a traditional ...

    经典的爬虫 的项目文件mySpider

    # Automatically created by: scrapy startproject # https://scrapyd.readthedocs.io/en/latest/deploy.html [settings] default = mySpider.settings [deploy] #url = http://localhost:6800/ project = mySpider

    详解IOS的Automatically Sign在设备上打包

    iOS的Automatically Sign功能是Xcode 8及更高版本引入的一项便利特性,旨在简化iOS应用的签名过程,以便开发者能够更轻松地将应用程序部署到实际设备进行测试。这个功能消除了手动创建和管理证书及配置文件的需求,...

    Predicting Human Decision-Making: From Prediction to Action

    In this book, we explore the task of automatically predicting human decision-making and its use in designing intelligent human-aware automated computer systems of varying natures-from purely ...

    藏经阁-AVPASS_Automatically Bypassing.pdf

    "藏经阁-AVPASS_Automatically Bypassing.pdf" 文件揭示了针对Android恶意软件检测系统的一种自动化规避策略,即AVPASS(Automatically Bypassing Android Malware Detection System)。该研究由乔治亚理工学院的...

    crypto-js:提供多种加密算法,MD5 哈希的 JS版本 -- Automatically exported from code.google.compcrypto-js

    CryptoJS是使用最佳实践和模式在JavaScript中实现的标准安全加密算法的不断增长的集合。 它们速度很快,并且具有一致且简单的界面。 如果您对CryptoJS有问题,或者想讨论新功能,或者想为项目做贡献,可以访问...

Global site tag (gtag.js) - Google Analytics