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

ABAP--如何快速从BSEG读取数据

UP 
阅读更多

由于bseg表很大,而且表的索引字段是:

BUKRS - Company Code
BELNR - Accounting Document Number
GJAHR - Fiscal Year
BUZEI - Line Item Number

 访问此表最佳的是包含所有的索引字段,但在实际应用是很少能达到的。但要有好的性能根据经验必须要有公司和凭证号作为查询条件。为了达到这一点,我可以根据条件不同而使用不同sap的其他表,先查出公司和凭证号,再去读取BSEG表

代码如下:

注意:该程序包含了各种条件的查询,程序员可以根据自己应用需求选择对应一个的子程序来读取公司和凭证号。

REPORT ztest_select.

* Tables ***************************************************************
TABLES: bkpf, bseg,
        covp, csks,
        glpca,
        bsis, bsas, bsid, bsad, bsik, bsak,
        ekbe, aufk,
        vbfa, vbak,
        vapma,
        fmifiit,
        payr.

* Global Data **********************************************************

TYPES: BEGIN OF doc,
        bukrs TYPE bseg-bukrs,
        belnr TYPE bseg-belnr,
        gjahr TYPE bseg-gjahr,
        buzei TYPE bseg-buzei,
      END   OF doc.

DATA: doc_int  TYPE TABLE OF doc,
      doc_wa   TYPE          doc,
      w_repid  TYPE sy-repid VALUE sy-repid,
      no_lines TYPE sy-tabix.

* Selection Screen *****************************************************
PARAMETERS: p_gjahr TYPE covp-refgj OBLIGATORY.
SELECTION-SCREEN SKIP.
PARAMETERS: p_kokrs TYPE csks-kokrs OBLIGATORY,
            p_kostl TYPE csks-kostl,
            p_prctr TYPE glpca-rprctr,
            p_aufnr TYPE aufk-aufnr.
SELECTION-SCREEN SKIP.
PARAMETERS: p_bukrs TYPE bsis-bukrs OBLIGATORY,
            p_budat TYPE bkpf-budat,
            p_ebeln TYPE ekko-ebeln,
            p_hkont TYPE bsis-hkont,
            p_lifnr TYPE bsik-lifnr,
            p_kunnr TYPE bsid-kunnr.
SELECTION-SCREEN SKIP.
PARAMETERS: p_vbeln TYPE vbak-vbeln.
SELECTION-SCREEN SKIP.
PARAMETERS: p_matnr TYPE vapma-matnr.
SELECTION-SCREEN SKIP.
PARAMETERS: p_fikrs TYPE fmifiit-fikrs,
            p_fistl TYPE fmifiit-fistl,
            p_fonds TYPE fmifiit-fonds.
SELECTION-SCREEN ULINE.
PARAMETERS: p_hbkid TYPE payr-hbkid,
            p_hktid TYPE payr-hktid,
            p_rzawe TYPE payr-rzawe,
            p_chect TYPE payr-chect.

START-OF-SELECTION.

* Retrieve document numbers based on different requirements

* Posting Date (用日期做查询条件)
  PERFORM posting_date_actuals
    USING p_bukrs
          p_budat.

* Cost Center
  PERFORM cost_center_actuals
    USING p_kokrs
          p_kostl
          p_gjahr.

* GL Account
  PERFORM gl_actuals
    USING p_bukrs
          p_hkont
          p_gjahr.

* Vendor
  PERFORM vendor_actuals
    USING p_bukrs
          p_lifnr
          p_gjahr.

* Customer
  PERFORM customer_actuals
    USING p_bukrs
          p_kunnr
          p_gjahr.

* Purchase Order
  PERFORM po_actuals
    USING p_ebeln.

* Sales Order
  PERFORM so_actuals
    USING p_vbeln.

* Order
  PERFORM order_actuals
    USING p_aufnr
          p_gjahr.

* Fund/Fund Center
  PERFORM fm_actuals
    USING p_fikrs
          p_gjahr
          p_fistl
          p_fonds.

* Profit Center
  PERFORM profit_center_actuals
    USING p_kokrs
          p_prctr
          p_gjahr.

* Material
  PERFORM material_actuals
    USING p_matnr
          p_gjahr.

* Cheque number
  PERFORM cheque_actuals
    USING p_hbkid
          p_hktid
          p_chect.

*&---------------------------------------------------------------------*
*&      Form  posting_date_actuals
*&---------------------------------------------------------------------*
*       Use one of the secondary indices of BKPF to retrieve the
*       document number
*----------------------------------------------------------------------*
FORM posting_date_actuals
  USING    bukrs
           budat.

  DATA: disp_date(10).

  CHECK NOT budat IS INITIAL.

* Uses index BKPF~2 (4.7)
  SELECT bukrs belnr gjahr
    INTO TABLE doc_int
    UP TO 100 ROWS
    FROM bkpf
    WHERE bukrs = bukrs  AND
* Normally, you would probably only want normal documents, that is
* documents with BSTAT = ' '. So you would change the next line.
* On the other hand, you might want documents for all values of BSTAT,
* but not want to hardcode the values. In that case, you can retrieve
* values from the domain of BSTAT and put them in a range table and
* use the range table in the next line.
          bstat IN (' ', 'A', 'B', 'D', 'M', 'S', 'V', 'W', 'Z') AND
          budat = budat.

  CHECK sy-subrc = 0.
  WRITE budat TO disp_date.

  PERFORM display_documents
    TABLES doc_int
    USING 'Posting date'
          disp_date
          space
          space.

ENDFORM.                    " posting_date_actuals

*&---------------------------------------------------------------------*
*&      Form  cost_center_actuals
*&---------------------------------------------------------------------*
*       Retrieve documents for a cost center
*----------------------------------------------------------------------*
FORM cost_center_actuals
  USING    kokrs
           kostl
           gjahr.

  DATA: covp_int TYPE TABLE OF covp,
        disp_cc(10).

  CHECK NOT kostl IS INITIAL.

* Uses primary index (4.7)
  SELECT SINGLE objnr
    FROM csks
    INTO csks-objnr
    WHERE kokrs = kokrs
      AND kostl = kostl.

  CHECK sy-subrc = 0.

* COVP is a view. This uses index COEP~1 (4.7)
  SELECT refbk refbn refgj refbz
    FROM covp
    INTO TABLE doc_int
    UP TO 100 ROWS
    WHERE lednr = '00'
      AND objnr = csks-objnr
      AND gjahr = gjahr
      AND wrttp IN ('04', '11')
      AND versn = '000'.

  CHECK sy-subrc = 0.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = kostl
    IMPORTING
      output = disp_cc.

  PERFORM display_documents
    TABLES doc_int
    USING 'Cost Center'
          disp_cc
          space
          space.

ENDFORM.                    " cost_center_actuals

*&---------------------------------------------------------------------*
*&      Form  gl_actuals
*&---------------------------------------------------------------------*
*       BKPF and BSEG have a number of secondary index tables. These are
*       tables that are indexed by GL customer or vendor number and have
*       data that is in both BKPF and BSEG. These secondary index tables
*       that have an 'i' in the third character of the name contain open
*       items. Those with an 'a' contain cleared items. In practice, you
*       may only one or the other. In this program I am retrieving both.
*
*       Here we get documents related to a GL.
*----------------------------------------------------------------------*
FORM gl_actuals
  USING    bukrs
           hkont
           gjahr.

  DATA: disp_gl(10).

  CHECK NOT hkont IS INITIAL.

* Uses primary index (4.7)
  SELECT bukrs belnr gjahr buzei
    FROM bsis
    INTO TABLE doc_int
    UP TO 100 ROWS
    WHERE bukrs = bukrs
      AND hkont = hkont
      AND gjahr = gjahr.

* Uses primary index (4.7)
  SELECT bukrs belnr gjahr buzei
    FROM bsas
    APPENDING TABLE doc_int
    UP TO 100 ROWS
    WHERE bukrs = bukrs
      AND hkont = hkont
      AND gjahr = gjahr.

  DESCRIBE TABLE doc_int LINES no_lines.
  CHECK no_lines > 0.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = hkont
    IMPORTING
      output = disp_gl.

  PERFORM display_documents
    TABLES doc_int
    USING 'GL Account'
          disp_gl
          space
          space.

ENDFORM.                    " gl_actuals

*&---------------------------------------------------------------------*
*&      Form  vendor_actuals
*&---------------------------------------------------------------------*
*       Here we get documents related to a vendor.
*----------------------------------------------------------------------*
FORM vendor_actuals
  USING    bukrs
           lifnr
           gjahr.

  DATA: disp_vendor(10).

  CHECK NOT lifnr IS INITIAL.

* Uses primary index (4.7)
  SELECT bukrs belnr gjahr buzei
    FROM bsik
    INTO TABLE doc_int
    UP TO 100 ROWS
    WHERE bukrs = bukrs
      AND lifnr = lifnr
      AND gjahr = gjahr.

* Uses primary index (4.7)
  SELECT bukrs belnr gjahr buzei
    FROM bsak
    APPENDING TABLE doc_int
    UP TO 100 ROWS
    WHERE bukrs = bukrs
      AND lifnr = lifnr
      AND gjahr = gjahr.

  DESCRIBE TABLE doc_int LINES no_lines.
  CHECK no_lines > 0.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = lifnr
    IMPORTING
      output = disp_vendor.

  PERFORM display_documents
    TABLES doc_int
    USING 'Vendor'
          disp_vendor
          space
          space.


ENDFORM.                    " vendor_actuals

*&---------------------------------------------------------------------*
*&      Form  customer_actuals
*&---------------------------------------------------------------------*
*       Here we get documents related to a customer.
*----------------------------------------------------------------------*
FORM customer_actuals
  USING  bukrs
         kunnr
         gjahr.

  DATA: disp_customer(10).

  CHECK NOT kunnr IS INITIAL.

* Uses primary index (4.7)
  SELECT bukrs belnr gjahr buzei
    FROM bsid
    INTO TABLE doc_int
    UP TO 100 ROWS
    WHERE bukrs = bukrs
      AND kunnr = kunnr
      AND gjahr = gjahr.

* Uses primary index (4.7)
  SELECT bukrs belnr gjahr buzei
    FROM bsad
    APPENDING TABLE doc_int
    UP TO 100 ROWS
    WHERE bukrs = bukrs
      AND kunnr = kunnr
      AND gjahr = gjahr.

  DESCRIBE TABLE doc_int LINES no_lines.
  CHECK no_lines > 0.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = kunnr
    IMPORTING
      output = disp_customer.

  PERFORM display_documents
    TABLES doc_int
    USING 'Customer'
          disp_customer
          space
          space.

ENDFORM.                    " customer_actuals

*&---------------------------------------------------------------------*
*&      Form  po_actuals
*&---------------------------------------------------------------------*
*       Table BKPF has a useful index on AWTYP and AWKEY. Here, we use
*       this to retrieve documents for purchase orders.
*----------------------------------------------------------------------*
FORM po_actuals
  USING    ebeln.

  TYPES: BEGIN OF ekbe_type,
           belnr TYPE ekbe-belnr,
           gjahr TYPE ekbe-gjahr,
           vgabe TYPE ekbe-vgabe,
         END   OF ekbe_type.

  DATA: ekbe_int TYPE TABLE OF ekbe_type,
        ekbe_wa  TYPE          ekbe_type.

  DATA: v_reference    TYPE bkpf-awtyp,           "Reference procedure
        v_objectkey    TYPE bkpf-awkey.           "Object key

  DATA:disp_po(10).

  CHECK NOT ebeln IS INITIAL.

* Uses primary index (4.7)
  SELECT belnr gjahr
    FROM ekbe
    INTO TABLE ekbe_int
    UP TO 100 ROWS
    WHERE ebeln = ebeln
    AND vgabe IN ('1', '2').                      "1 - GR, 2 - IR

  CHECK sy-subrc = 0.

  SORT ekbe_int.
  DELETE ADJACENT DUPLICATES FROM ekbe_int.

  LOOP AT ekbe_int INTO ekbe_wa.
    v_objectkey+00(10) = ekbe_wa-belnr.
    v_objectkey+10(10) = ekbe_wa-gjahr.           "BELNR+YEAR

    IF ekbe_wa-vgabe = '1'.
      v_reference = 'MKPF'.
    ELSE.
      v_reference = 'RMRP'.
    ENDIF.

* Uses index BKPF~4 (4.7)
    SELECT SINGLE bukrs belnr gjahr               "Accounting Doc Header
      FROM bkpf
      INTO doc_wa
      WHERE awtyp =  v_reference
        AND awkey =  v_objectkey.
    IF sy-subrc = 0.
      APPEND doc_wa TO doc_int.
    ENDIF.
  ENDLOOP.

  CHECK no_lines > 0.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = ebeln
    IMPORTING
      output = disp_po.

  PERFORM display_documents
    TABLES doc_int
    USING 'Purchase Order'
          disp_po
          space
          space.

ENDFORM.                    " po_actuals

*&---------------------------------------------------------------------*
*&      Form  so_actuals
*&---------------------------------------------------------------------*
*       Use AWTYP and AWKEY to retrieve documents related to sales
*----------------------------------------------------------------------*
FORM so_actuals  USING    vbeln.

  TYPES: BEGIN OF vbfa_type,
           vbeln TYPE vbfa-vbeln,
         END   OF vbfa_type.

  DATA: vbfa_int TYPE TABLE OF vbfa_type,
        vbfa_wa  TYPE          vbfa_type.

  DATA: v_reference    TYPE bkpf-awtyp,           "Reference procedure
        v_objectkey    TYPE bkpf-awkey.           "Object key

  DATA:disp_so(10).

  CHECK NOT vbeln IS INITIAL.

* Uses primary index (4.7)
  SELECT vbeln
    FROM vbfa
    INTO TABLE vbfa_int
    UP TO 100 ROWS
    WHERE vbelv   = vbeln
      AND vbtyp_n = 'P'.                          "Debit memo

  CHECK sy-subrc = 0.

  SORT vbfa_int.
  DELETE ADJACENT DUPLICATES FROM vbfa_int.

  LOOP AT vbfa_int INTO vbfa_wa.
    v_objectkey+00(10) = vbfa_wa-vbeln.           "BELNR
    v_reference        = 'VBRK'.

* Uses index BKPF~4 (4.7)
    SELECT SINGLE bukrs belnr gjahr               "Accounting Doc Header
      FROM bkpf
      INTO doc_wa
      WHERE awtyp =  v_reference
        AND awkey =  v_objectkey.
    IF sy-subrc = 0.
      APPEND doc_wa TO doc_int.
    ENDIF.
  ENDLOOP.

  DESCRIBE TABLE doc_int LINES no_lines.
  CHECK no_lines > 0.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = vbeln
    IMPORTING
      output = disp_so.

  PERFORM display_documents
    TABLES doc_int
    USING 'Sales Document'
          disp_so
          space
          space.

ENDFORM.                    " so_actuals

*&---------------------------------------------------------------------*
*&      Form  order_actuals
*&---------------------------------------------------------------------*
*       Retrieve documents related to an order
*----------------------------------------------------------------------*
FORM order_actuals
  USING    aufnr
           gjahr.

  DATA: disp_order(10).

  CHECK NOT aufnr IS INITIAL.

* Uses primary index (4.7)
  SELECT SINGLE objnr
    FROM aufk
    INTO aufk-objnr
    WHERE aufnr = aufnr.

  CHECK sy-subrc = 0.

* COVP is a view. This uses index COEP~1 (4.7)
  SELECT refbk refbn refgj refbz
    FROM covp
    INTO TABLE doc_int
    UP TO 100 ROWS
    WHERE lednr = '00'
      AND objnr = aufk-objnr
      AND gjahr = gjahr
      AND wrttp IN ('04', '11')
      AND versn = '000'.

  CHECK sy-subrc = 0.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = aufnr
    IMPORTING
      output = disp_order.

  PERFORM display_documents
    TABLES doc_int
    USING 'Order'
          disp_order
          space
          space.

ENDFORM.                    " order_actuals

*&---------------------------------------------------------------------*
*&      Form  FM_actuals
*&---------------------------------------------------------------------*
*       Not many institutions use Funds Management, but if you do, this
*       is how to relate funds management documents to FI documents.
*----------------------------------------------------------------------*
FORM fm_actuals
  USING    fikrs
           gjahr
           fistl
           fonds.

  DATA: disp_cfc(10),
        disp_fund(10).

  CHECK NOT fikrs IS INITIAL AND
        NOT fistl IS INITIAL.

* Uses index FMIFIIT~3 (4.7)
  SELECT bukrs knbelnr kngjahr knbuzei
    FROM  fmifiit
    INTO TABLE doc_int
    UP TO 100 ROWS
         WHERE  fistl  = fistl
         AND    fonds  = fonds.

  CHECK sy-subrc = 0.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = fistl
    IMPORTING
      output = disp_cfc.

  IF NOT fonds IS INITIAL.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
        input  = fonds
      IMPORTING
        output = disp_fund.
  ENDIF.

  PERFORM display_documents
    TABLES doc_int
    USING 'Fund Center'
          disp_cfc
          'Fund'
          disp_fund.

ENDFORM.                    " FM_actuals

*&---------------------------------------------------------------------*
*&      Form  profit_center_actuals
*&---------------------------------------------------------------------*
*       Retrieve documents related to a profit center
*----------------------------------------------------------------------*
FORM profit_center_actuals
  USING    kokrs
           prctr
           gjahr.

  DATA: disp_pc(10).

  CHECK NOT prctr IS INITIAL.

* This uses index GLPCA~1 (4.7)
  SELECT rbukrs refdocnr refryear refdocln
    FROM glpca
    INTO TABLE doc_int
    UP TO 100 ROWS
    WHERE kokrs  = kokrs
      AND ryear  = gjahr
      AND rprctr = prctr
      AND awtyp  = 'BKPF'.

  CHECK sy-subrc = 0.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = prctr
    IMPORTING
      output = disp_pc.

  PERFORM display_documents
    TABLES doc_int
    USING 'Profit Center'
          disp_pc
          space
          space.

ENDFORM.                    " profit_center_actuals

*&---------------------------------------------------------------------*
*&      Form  material_actuals
*&---------------------------------------------------------------------*
*       Get FI documents for a material.
*       For purchase orders get:
*         goods receipts
*         invoice receipts
*       For sales orders get:
*         debit memos
*----------------------------------------------------------------------*
FORM material_actuals
  USING    matnr
           gjahr.

  TYPES: BEGIN OF ekpo_type,
           ebeln TYPE ekpo-ebeln,
           ebelp TYPE ekpo-ebelp,
         END   OF ekpo_type.

  TYPES: BEGIN OF ekbe_type,
           belnr TYPE ekbe-belnr,
           gjahr TYPE ekbe-gjahr,
           vgabe TYPE ekbe-vgabe,
         END   OF ekbe_type.

  TYPES: BEGIN OF vapma_type,
           vbeln TYPE vapma-vbeln,
           posnr TYPE vapma-posnr,
         END   OF vapma_type.

  TYPES: BEGIN OF vbfa_type,
           vbeln TYPE vbfa-vbeln,
           posnv TYPE vbfa-posnv,
         END   OF vbfa_type.

  DATA: ekpo_int TYPE TABLE OF ekpo_type,
        ekpo_wa  TYPE          ekpo_type.

  DATA: ekbe_int TYPE TABLE OF ekbe_type,
        ekbe_wa  TYPE          ekbe_type.

  DATA: vapma_int TYPE TABLE OF vapma_type,
        vapma_wa  TYPE          vapma_type.

  DATA: v_reference    TYPE bkpf-awtyp,           "Reference procedure
        v_objectkey    TYPE bkpf-awkey.           "Object key

  DATA: vbfa_int TYPE TABLE OF vbfa_type,
        vbfa_wa  TYPE          vbfa_type.

  DATA: disp_mat(10).

  CHECK NOT matnr IS INITIAL.

* First, find purchase orders for the material
* This uses index EKPO~1 (4.7)
  SELECT ebeln ebelp
    FROM ekpo
    INTO TABLE ekpo_int
    UP TO 100 ROWS
    WHERE matnr = matnr.

* Now get the FI document numbers as above
* Uses primary index (4.7)
  SELECT belnr gjahr vgabe
    FROM ekbe
    INTO TABLE ekbe_int
    UP TO 100 ROWS
    FOR ALL ENTRIES IN ekpo_int
    WHERE ebeln = ekpo_int-ebeln
      AND ebelp = ekpo_int-ebelp
      AND vgabe IN ('1', '2').                      "1 - GR, 2 - IR

  CHECK sy-subrc = 0.

  SORT ekbe_int.
  DELETE ADJACENT DUPLICATES FROM ekbe_int.

  LOOP AT ekbe_int INTO ekbe_wa.
    v_objectkey+00(10) = ekbe_wa-belnr.
    v_objectkey+10(10) = ekbe_wa-gjahr.           "BELNR+YEAR

    IF ekbe_wa-vgabe = '1'.
      v_reference = 'MKPF'.
    ELSE.
      v_reference = 'RMRP'.
    ENDIF.

* Uses index BKPF~4 (4.7)
    SELECT SINGLE bukrs belnr gjahr               "Accounting Doc Header
      FROM bkpf
      INTO doc_wa
      WHERE awtyp =  v_reference
        AND awkey =  v_objectkey.
    IF sy-subrc = 0.
      APPEND doc_wa TO doc_int.
    ENDIF.
  ENDLOOP.

* Next get the sales orders for the material

* Note - I am using an artificial date range here because of archiving
* in our system. Feel free to remove it.
  SELECT vbeln posnr
    FROM vapma
    INTO TABLE vapma_int
    UP TO 100 ROWS
    WHERE matnr = matnr
      AND audat BETWEEN '20070101' AND '20071231'.

* Uses primary index (4.7)
  SELECT vbeln posnv
    FROM vbfa
    INTO TABLE vbfa_int
    FOR ALL ENTRIES IN vapma_int
    WHERE vbelv   = vapma_int-vbeln
      AND posnv   = vapma_int-posnr
      AND vbtyp_n = 'P'.                          "Debit memo

  CHECK sy-subrc = 0.

  SORT vbfa_int.
  DELETE ADJACENT DUPLICATES FROM vbfa_int.

  LOOP AT vbfa_int INTO vbfa_wa.
    CLEAR: v_objectkey,
           v_reference.
    v_objectkey+00(10) = vbfa_wa-vbeln.           "BELNR
    v_reference        = 'VBRK'.

* Uses index BKPF~4 (4.7)
    SELECT SINGLE bukrs belnr gjahr               "Accounting Doc Header
      FROM bkpf
      INTO doc_wa
      WHERE awtyp =  v_reference
        AND awkey =  v_objectkey.
    IF sy-subrc = 0.
      APPEND doc_wa TO doc_int.
    ENDIF.
  ENDLOOP.

  DESCRIBE TABLE doc_int LINES no_lines.
  CHECK no_lines > 0.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = matnr
    IMPORTING
      output = disp_mat.

  PERFORM display_documents
    TABLES doc_int
    USING 'Material'
          disp_mat
          space
          space.

ENDFORM.                    " material_actuals

*&---------------------------------------------------------------------*
*&      Form  cheque_actuals
*&---------------------------------------------------------------------*
*       Retrieve FI documents for a cheque. We are assuming Accounts
*       Payable related.
*----------------------------------------------------------------------*
FORM cheque_actuals
  USING    hbkid
           hktid
           chect.
  DATA: belnr TYPE payr-vblnr,
        gjahr TYPE payr-gjahr,
        lifnr TYPE payr-lifnr,
        laufd TYPE payr-laufd,
        disp_cheque(13).

  CHECK NOT p_chect IS INITIAL.

* Retrieve the cheque data using the primary key (4.7)
* We are assuming a vendor payment here
  SELECT SINGLE vblnr gjahr lifnr laufd
    FROM  payr
    INTO (belnr, gjahr, lifnr, laufd )
    WHERE  zbukr  = p_bukrs
      AND  hbkid  = p_hbkid
      AND  hktid  = p_hktid
      AND  rzawe  = p_rzawe
      AND  chect  = p_chect.

* Now get the accounting documents
  SELECT bukrs belnr gjahr
    FROM  bsak
    INTO TABLE doc_int
         WHERE  bukrs  = p_bukrs
         AND    lifnr  = lifnr
         AND    umsks  = ' '
         AND    umskz  = ' '
         AND    augdt  = laufd
         AND    augbl  = belnr
         AND    gjahr  = gjahr.

  DESCRIBE TABLE doc_int LINES no_lines.
  CHECK no_lines > 0.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = chect
    IMPORTING
      output = disp_cheque.

  PERFORM display_documents
    TABLES doc_int
    USING 'Cheque number'
          disp_cheque
          space
          space.

ENDFORM.                    " cheque_actuals

*&---------------------------------------------------------------------*
*&      Form  display_documents
*&---------------------------------------------------------------------*
*       At this point, you have the company code, document number and
*       fiscal year in table DOC_INT. Here, I just use a standard SAP
*       function module and transaction to display documents and
*       details, but you could use the same information to retrieve
*       document data from BKPF and/or BSEG.
*----------------------------------------------------------------------*
FORM display_documents
  TABLES   doc_int STRUCTURE doc_wa
  USING    doc_source_1
           source_value_1
           doc_source_2
           source_value_2.

  TYPE-POOLS: slis.

  DATA: sel     TYPE  slis_selfield.
  DATA: title   TYPE string.

  CONCATENATE 'FI line items for' doc_source_1 source_value_1
               INTO title SEPARATED BY space.

  IF NOT source_value_2 IS INITIAL.
    CONCATENATE title doc_source_2 source_value_2
                INTO title SEPARATED BY space.
  ENDIF.

  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
    EXPORTING
      i_title                 = title
      i_selection             = 'X'
      i_tabname               = 'BSEG'
      i_structure_name        = 'BSEG'
      i_callback_user_command = 'USER_COMMAND'
      i_callback_program      = w_repid
    IMPORTING
      es_selfield             = sel
    TABLES
      t_outtab                = doc_int.

  IF NOT sel IS INITIAL.
    READ TABLE doc_int INDEX sel-tabindex.
    SET PARAMETER ID 'BUK' FIELD doc_int-bukrs.
    SET PARAMETER ID 'BLN' FIELD doc_int-belnr.
    SET PARAMETER ID 'GJR' FIELD doc_int-gjahr.
    CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
  ENDIF.

ENDFORM.                    " display_documents

 

 

分享到:
评论

相关推荐

    提高ABAP 性能注意事项

    索引使得数据库能够快速定位到所需数据,避免全表扫描。 2. **采用存在的索引表**:利用SAP预定义的索引表,如BSEG的六个索引表,可以更有效地访问数据,减少查询时间。 3. **使用合适的数据视图**:视图通过预...

    ABAP面试大全

    - **完全缓冲**: 所有数据都缓存,适用于经常读取但很少修改的数据。 - **不完全缓冲**: 只缓存部分数据,适用于混合访问模式。 - **无缓冲**: 不缓存任何数据,适用于频繁更新的数据。 **2.2 ABAP和数据库** -...

    Abap效率.docx

    使用`SELECT SINGLE`来确保只获取一条数据,减少不必要的数据读取。对于统计操作,直接利用SQL聚合函数(如SUM, COUNT等),避免将数据读入程序后再计算。在JOIN操作中,优先使用INNER JOIN,只有在必要时才使用LEFT...

    ZGR_FI_R_ZFI02.txt

    程序中定义的这些数据类型将被用于读取、处理和显示相关财务信息。 最后,该文件还包含了元数据部分,显示了创建和最后修改的日期,以及一些其他格式化指令和注释,这些都是ABAP源代码的标准组成部分。 请注意,...

    63.基于51单片机的酒精气体检测器设计(实物).pdf

    63.基于51单片机的酒精气体检测器设计(实物).pdf

    13.基于51单片机的简易计算器设计(仿真).pdf

    13.基于51单片机的简易计算器设计(仿真)

    12.基于单片机的可语音播报的脉搏检测仪设计(实物).pdf

    12.基于单片机的可语音播报的脉搏检测仪设计(实物)

    模块六:云原生训练营-Kubernetes 控制平面组件API Server

    内容概要:本文档详细介绍了Kubernetes控制平面中最为核心的API Server组件。内容涵盖认证、鉴权、准入控制(Mutating、Validating Admission)、限流机制和API服务器的高可用实现等重要方面。通过认证插件如X509证书、OAuth2、Webhook等方式保障API服务器的安全性,通过各种准入控制器如ResourceQuota、LimitRanger等确保资源的有效管理和安全性,以及如何通过对并发请求的数量、速率进行精确控制,提升系统的稳定性。API服务器的设计思路不仅考虑到了大规模部署的需求,同时也强调了安全性、可靠性和扩展性的平衡。文档同时提供了构建高可用多副本API服务器的具体指导,并探讨了与企业现有认证系统的集成方式。 适合人群:云计算领域的架构师、运维工程师、安全专家、开发人员和技术管理人员等。这些人需要深刻理解Kubernetes的工作机制,特别是在安全管理和性能优化方面的挑战。 使用场景及目标:①掌握API Server的各种访问控制手段(认证和鉴权);②学习如何使用API Server实现细粒度的资源访问控制;③熟悉不同限流策略,解决

    实验一 Simulink仿真环境及模型的建立.docx

    实验一 Simulink仿真环境及模型的建立.docx

    GLPI开源资产管理系统Docker部署方式,2025最新教程

    GLPI开源资产管理系统Docker部署方式,2025最新教程

    275.基于51单片机的电子钟【秒表,闹钟,倒计时,整点报时,数码管,矩阵键盘】(仿真).pdf

    275.基于51单片机的电子钟【秒表,闹钟,倒计时,整点报时,数码管,矩阵键盘】(仿真).pdf

    基于多车协同感知与烟花算法的局部路径规划技术及其在自动驾驶中的应用(可复现,有问题请联系博主)

    内容概要:该论文提出了一种基于多车协同感知与烟花算法的局部路径规划方法。首先通过烟花算法实现基于网格地图相似性的多车地图合并,然后结合人工势场方法进行实时路径规划,解决了复杂环境中自动驾驶汽车存在的视野盲区和路径规划不畅的问题。文中详细介绍了网格地图合并的原理和技术步骤、动态排斥势场的构建以及路径规划的实验验证。通过对不同算法进行比较实验,并验证了该方法在安全性和效率上的优越性,尤其是在处理动态障碍物时的优势。最终通过仿真分析展示了基于多车协同感知的地图融合方法能够显著提升路径规划的安全性和舒适性,为未来的自动化驾驶提供了坚实的技术支持。 适用人群:研究自动驾驶技术和智能交通系统的学术研究人员,及相关领域的工程师和技术人员。 使用场景及目标:该研究的应用场景主要是复杂的城市道路环境和其他具有多变环境的场景,旨在解决车辆因遮挡而形成的感知盲区,提供更加精确的局部路径规划方法。通过多车协同和动态排斥势场的方法,提升自动驾驶系统的实时性能、避障能力和安全性。 其他说明:尽管研究集中在城市结构化道路环境中验证,但是提出了未来工作的几个方向,包括如何扩展至更复杂的农村公路或环形交叉路口。同时也探

    <数据集>轨道异物识别数据集<目标检测>

    YOLO与VOC格式的轨道异物识别数据集,适用于YOLO系列、Faster Rcnn、SSD等模型训练,类别:person、obsticle_oc、Animal、vehicle、motor_bicycle、Train,图片数量1659。文件中包含图片、txt标签、指定类别信息的yaml文件、xml标签,已将图片和txt标签划分为训练集、验证集和测试集,可直接用于YOLOv5、YOLOv6、YOLOv7、YOLOv8、YOLOv9、YOLOv10、YOLOv11、YOLOv12等YOLO系列算法的训练。

    基于java的ssm课程在线教育资源管理系统(含LW+PPT+源码+系统演示视频+安装说明).7z

    在线教育资源管理系统,主要的模块包括管理员;个人中心、学生管理、教师管理、公告信息管理、课程信息管理、试题管理、留言板管理、管理员管理、试卷管理、系统管理、考试管理,学生;个人中心、留言板管理、考试管理,教师;个人中心、课程信息管理、试题管理、留言板管理、试卷管理、考试管理,前台首页;首页、公告信息、课程信息、试卷列表、留言反馈、我的、跳转到后台等功能。系统中管理员主要是为了安全有效地存储和管理各类信息,还可以对系统进行管理与更新维护等操作,并且对后台有相应的操作权限。 要想实现在线教育资源管理系统的各项功能,需要后台数据库的大力支持。管理员验证注册信息,收集的用户信息,并由此分析得出的关联信息等大量的数据都由数据库管理。本文中数据库服务器端采用了Mysql作为后台数据库,使Web与数据库紧密联系起来。在设计过程中,充分保证了系统代码的良好可读性、实用性、易扩展性、通用性、便于后期维护、操作方便以及页面简洁等特点。 本系统的开发使获取在线教育资源管理系统信息能够更加方便快捷,同时也使在线教育资源管理系统信息变的更加系统化、有序化。系统界面较友好,易于操作。 关键词:在线教育资源管理系统 ;jsp技术 ;Mysql数据库

    基于Python卷积神经网络进行猫狗识别源码+报告(99分大作业)

    基于Python卷积神经网络进行猫狗识别源码+报告(99分大作业),个人大三期末大作业项目、经导师指导并认可通过的高分设计项目,评审分99分,代码完整确保可以运行,小白也可以亲自搞定,主要针对计算机相关专业的正在做大作业的学生和需要项目实战练习的学习者,可作为课程设计、期末大作业。 基于Python卷积神经网络进行猫狗识别源码+报告(99分大作业)基于Python卷积神经网络进行猫狗识别源码+报告(99分大作业)基于Python卷积神经网络进行猫狗识别源码+报告(99分大作业)基于Python卷积神经网络进行猫狗识别源码+报告(99分大作业)基于Python卷积神经网络进行猫狗识别源码+报告(99分大作业)基于Python卷积神经网络进行猫狗识别源码+报告(99分大作业)基于Python卷积神经网络进行猫狗识别源码+报告(99分大作业)基于Python卷积神经网络进行猫狗识别源码+报告(99分大作业)基于Python卷积神经网络进行猫狗识别源码+报告(99分大作业)基于Python卷积神经网络进行猫狗识别源码+报告(99分大作业)基于Python卷积神经网络进行猫狗识别源码+报告(9

    cef109.1.11+chromium 109.0.5414.120

    最后一个win7稳定运行版本,支持视频和pdf查看,因为之前下载的别人打包好的文件,可以播放视频,但是打开pdf会闪退,所以自己编译了一个,有需要的可以试试

    前端分析-2023071100789s3

    前端分析-2023071100789s3

    基于 OpenCV 和 Flask 的 Python 3 人脸检测

    人脸检测演示 (Flask 应用程序) 这是一个非常简单的 Flask 应用程序,它允许用户上传图像并检测图片中有多少张(如果有)面孔

    山东大学软件学院2022级操作系统实验

    山东大学软件学院2022级操作系统实验

    20.基于51单片机的简易电梯系统的设计(实物).pdf

    20.基于51单片机的简易电梯系统的设计(实物)

Global site tag (gtag.js) - Google Analytics