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

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

 

 

分享到:
评论

相关推荐

    ABAP751 ABAP - Keyword Documentation

    ABAP - Keyword Documentation This documentation describes the syntax and meaning of the keywords of the ABAP language and its object-oriented part ABAP Objects. Alongside this, language frameworks ...

    SAP中文教材全系列之ABAP-BC400_ZH

    本文档是《SAP中文教材全系列之ABAP-BC400_ZH》,为SAP ABAP编程语言的学习提供参考。文档包含了详细的ABAP课程内容,旨在帮助学员理解并掌握ABAP编程的基础知识和高级技能。以下将详细阐释文档所涵盖的知识点。 ...

    ABAP-培训教材目录

    ABAP-培训教材附录 ABAP-培训教材ABAP-培训教材ABAP-培训教材ABAP-培训教材

    CD260-ABAP-in-Eclipse-开发-CN

    CD260-ABAP-in-Eclipse-开发-CN CD260-ABAP-in-Eclipse-开发-CNCD260-ABAP-in-Eclipse-开发-CNCD260-ABAP-in-Eclipse-开发-CN

    eclipse-abap-keywordcolors-master.rar

    eclipse-abap-keywordcolors eclipse-abap-关键字颜色

    ABAP-数据类型学习笔记

    ABAP-数据类型学习笔记

    ABAP-操作Excel导出数据

    为了更好地理解这一过程,你可以参考提供的文档:《用OLE DOI 实现ABAP导出EXCEL表格.docx》和《ABAP-透過OLE操作OFFICE.docx》。同时,《OLE.pdf》可能包含更深入的OLE和DOI技术细节,这对于优化和调试代码会非常有...

    三月精通ABAP--快速入门

    《三月精通ABAP——快速入门》是一本旨在帮助初学者快速掌握ABAP编程语言的教程。ABAP,全称Advanced Business Application Programming,是SAP系统中的主要编程语言,用于开发企业级应用,特别是在供应链管理(SCM...

    ABAP-学习笔记-通用

    ABAP-学习笔记-通用

    SAP-ABAP-Certification-Review.pdf

    SAP-ABAP-Certification-Review.pdf

    ABAP-ALV进阶

    "ABAP-ALV进阶知识点详解" ABAP-ALV进阶是指在SAP系统中使用ABAP语言开发的高级列表查看器(ALV)。ALV是SAP系统中心的列表标准,可以在ABAP程序中进行报表输出。下面是ABAP-ALV进阶的知识点详解: 一、ALV概要 ...

    ABAP-OLE[借鉴].pdf

    在SAP编程中,ABAP-OLE(Object Linking and Embedding)是一种技术,它允许SAP应用程序与外部非SAP系统进行交互,例如创建、读取、更新和删除Excel电子表格。在上述代码中,我们看到了一个名为`ZWM_015`的报告,它...

    ABAP-WebDynpro实例.pdf

    ABAP-WebDynpro 实例 ABAP-WebDynpro 实例是 SAP 中的一种开发技术,允许开发者创建基于 Web 的应用程序。该技术将 SAP 中开发的程序在 Web 中运行,从而不需要在客户机上安装 SAPGUI。 在本实例中,我们将创建一...

    web-dynpro-abap-ui-element-tree_Ch01_CV_Introduction_

    总结来说,“web-dynpro-abap-ui-element-tree”涵盖了Web Dynpro ABAP中创建和管理树形UI元素的核心概念和技术,包括UI元素定义、数据绑定、用户交互处理和测试。通过深入学习这一章节,开发者将能够构建出更加灵活...

    ABAP-OLE开发[汇编].pdf

    ABAP-OLE开发是SAP系统中的一种技术,它允许ABAP编程语言与外部对象链接和嵌入(OLE)应用程序进行交互。OLE自动化是Windows环境中的一种技术,它使得不同的应用程序可以共享数据和服务,通常用于控制一个应用程序...

    ABAP-选择屏幕

    ABAP-选择屏幕 Dynpros 基础 Dynpros 是ABAP编程语言中的一种基础组件,用于构建交互式用户界面。通过本文,我们将了解 Dynpros 的基本结构、屏幕元素的构成、屏幕事件等知识点。 屏幕元素 在 Dynpros 中,屏幕...

    ABAP--ALV

    SearchHelp是在ABAP程序中用于提供快速搜索帮助的功能,通常用于输入屏幕或选择屏幕中。用户可以通过按F4键来弹出一个辅助窗口,从中选择合适的值填充到当前输入字段中。 #### 四、层级显示 (Hierarchical Display)...

    abap-ALV.rar_ABAP系统ALV_abap_abap开发alv

    标题“abap-ALV.rar_ABAP系统ALV_abap_abap开发alv”暗示我们将深入探讨ABAP ALV的使用,特别是在ABAP系统中的应用以及如何进行开发。 描述中提到“ABAP ALV总结,ALV格式,REUSE_ALV_GRID_DISPLAY_LVC函数使用”,...

    SAP ABAP-采购申请释放后到更新发布标识.zip

    在SAP系统中,ABAP(Advanced Business Application Programming)是一种编程语言,用于开发和定制企业资源规划(ERP)软件,而MM(Materials Management)模块则是SAP中的一个重要部分,主要处理采购、库存管理和...

    ABAP-透明表学习笔记.py

    ABAP-透明表学习笔记.py

Global site tag (gtag.js) - Google Analytics