report for purchase requsition to vendor payment

I  have developed a report for purchase requisition to vendor payment but I cant able to show vendors open amount and clear amount respect to purchase order and vendor the report code is as follows please suggest me me next solution

 

 

report zpo_purchase_history no standard page heading message-id 00.
TABLES : bsik, bsak, lfa1, lfb1, skb1, t001, bapifvdexp_vzzbepp.
type-pools:slis,ICON.
types :begin of ty_po,
        banfn type eban-banfn,
        "Purchase Requisition Number
        bnfpo type eban-bnfpo,
        "Item Number of Purchase Requisition
        ekgrp type eban-ekgrp,                 "Purchasing Group
        badat type eban-badat,
        "Requisition (Request) Date
        menge type eban-menge,
        KNTTP TYPE EBAN-KNTTP,
         PSTYP type eban-PSTYP,
        "Purchase Requisition Quantity
        meins type eban-meins,
        "Purchase Requisition Unit of Measure
        lifnr type ekko-lifnr,                 "Vendor Account Number
        bedat type ekko-bedat,                 "Purchasing Document Date
        ebeln type ekpo-ebeln,
        "Purchasing Document Number
        ebelp type ekpo-ebelp,
        "Item Number of Purchasing Document
        matkl type ekpo-matkl,                 "Material Group
        mtart type ekpo-mtart,                 "Material Type
        matnr type ekpo-matnr,                 "Material Number
        txz01 type ekpo-txz01,                 "Short Text
        menge1 type ekpo-menge,                "Purchase Order Quantity
        meins1 type ekpo-meins,
        "Purchase Order Unit of Measure
        balqty type ekpo-menge,                "Balance Quantity
        netpr type ekpo-netpr,
        "Net Price in Purchasing Document
        peinh type ekpo-peinh,                 "Price Unit
        mblnr type mseg-mblnr,
        "Number of Material Document
        zeile type mseg-zeile,                 "Item in Material Document
        menge2 type mseg-menge,                "GR Quantity
        meins2 type mseg-meins,                "GR Unit of Measure
        werks type mseg-werks,                 "Plant
        charg type mseg-charg,                 "Batch
        belnr type rbkp-belnr,
        "Document Number of an Invoice Document
        bldat type ekbe-bldat,                 "Document Date in Document
        belnr_b type rbkp-belnr,
        SHKZG type ekbe-SHKZG ,                "Debit/Credit Indicator
        DMBTR_i type   bsik-dmbtr,                "Amount in Local Currency
        DMBTR_a type   bsAk-dmbtr,                "Amount in Local Currency
        thick(10type c,                      "Thickness
        width(10type c,                      "Width
        length(10type c,                     "Length
        grade(10type c,                        "Grade
        BELNR_D type bseg-BELNR,
        xblnr type bkpf-xblnr,
        awkey  type bkpf-awkey,
        RMWWR type rbkp-RMWWR,
        WMWST1 type rbkp-WMWST1,

        end of ty_po.
types :begin of ty_ekko,
        ebeln type ekko-ebeln,
        lifnr type ekko-lifnr,
        bedat type ekko-bedat,
        end of ty_ekko.

types:begin of ty_ekpo,
        ebeln type ekpo-ebeln,
        ebelp type ekpo-ebelp,
        matnr type ekpo-matnr,
        txz01 type ekpo-txz01,
        menge type ekpo-menge,
        meins type ekpo-meins,
        netpr type ekpo-netpr,
        peinh type ekpo-peinh,
        banfn type ekpo-banfn,
        bnfpo type ekpo-bnfpo,
        mtart type ekpo-mtart,
        end of ty_ekpo.

types :begin of ty_eban,
        banfn type eban-banfn,
        bnfpo type eban-bnfpo,
        matnr type eban-matnr,
        menge type eban-menge,
        meins type eban-meins,
        end of ty_eban.

types : begin of ty_ekbe,
         ebeln type ekbe-ebeln,
         ebelp type ekbe-ebelp,
         belnr type ekbe-belnr,
         bldat type ekbe-bldat,
         gjahr type ekbe-gjahr,
         buzei type ekbe-buzei,
         matnr type ekbe-matnr,
         DMBTR type ekbe-dmbtr,
         shkzg type ekbe-shkzg,
         end of ty_ekbe.

types : begin of ty_mseg,
         mblnr type mseg-mblnr,
         mjahr type mseg-mjahr,
         zeile type mseg-zeile,
         menge type mseg-menge,
         meins type mseg-meins,
         ebeln type mseg-ebeln,
         ebelp type mseg-ebelp,
         matnr type mseg-matnr,
         werks type mseg-werks,
         charg type mseg-charg,
         end of ty_mseg.

types : begin of ty_rbkp,
         belnr type rbkp-belnr,
         gjahr type rbkp-gjahr,
         bldat type rbkp-bldat,
         lifnr type rbkp-lifnr,
         ZUONR type rbkp-ZUONR,
         RMWWR type rbkp-RMWWR,
         WMWST1 type rbkp-WMWST1,
         end of ty_rbkp.

types : begin of ty_bseg,
         bukrs type bseg-bukrs,
         belnr type bseg-belnr,
         gjahr type bseg-gjahr,
         buzei type bseg-buzei,
         valut type bseg-valut,
         wrbtr type bseg-wrbtr ,
         augbl type bseg-augbl,
         matnr type bseg-matnr,
         lifnr type bseg-lifnr,
         ebeln type bseg-ebeln,
         augdt type bseg-augdt,
         BUSTW type bseg-BUSTW,

         end of ty_bseg.

types : begin of ty_rseg,
         belnr type rseg-belnr,
         gjahr type rseg-gjahr,
         ebeln type rseg-ebeln,
         ebelp type rseg-ebelp,
         matnr type rseg-matnr,
         bukrs type rseg-bukrs,
         end of ty_rseg.

types : begin of ty_bsik,

         belnr type bsik-belnr,

         DMBTR_i type bsik-DMBTR,

*        shkzg type bsik-shkzg,
         ebeln type bsik-ebeln,
*        lifnr type bsik-lifnr,

         end of ty_bsik.

types : begin of ty_bsak,
         belnr type bsak-belnr,
*  lifnr type bsak-lifnr,

         DMBTR_a type bsak-DMBTR,
            ebeln type bsak-ebeln,
*ZUONR type bsak-ZUONR,
         end of ty_bsak.
typesbegin of ty_bkpf,
         BELNR type bkpf-belnr,
         xblnr type bkpf-xblnr,
         awkey  type bkpf-awkey,
         gjahr type bkpf-gjahr,
         bukrs type bkpf-bukrs,
       end of ty_bkpf.
data: it_po type standard table of ty_po,
       it_ekko type standard table of ty_ekko,
       it_ekpo type standard table of ty_ekpo,
       it_eban type standard table of ty_eban,
       it_ekbe type standard table of ty_ekbe,
       it_mseg type standard table of ty_mseg,
       it_rbkp type standard table of ty_rbkp,
       it_rseg type standard table of ty_rseg,
       it_bseg type standard table of ty_bseg WITH HEADER LINE,
       it_bsik type STANDARD TABLE OF ty_bsik WITH HEADER LINE,
       it_bsak type STANDARD TABLE OF ty_bsak,
       it_bkpf type standard table of ty_bkpf,
       wa_po type ty_po,
       wa1_po type ty_po,
       wa_ekko type ty_ekko,
       wa_ekpo type ty_ekpo,
       wa_eban type ty_eban,
       wa_mseg type ty_mseg,
       wa_rbkp type ty_rbkp,
       wa_rseg type ty_rseg,
       wa_bseg type ty_bseg,
       wa_ekbe type ty_ekbe,
       wa_bsik type ty_bsik,
       wa_bsak type ty_bsak,
       wa_bkpf type ty_bkpf.

data: it_fcat type slis_t_fieldcat_alv,
       it_lshead type slis_t_listheader,
       it_sort type slis_t_sortinfo_alv,
       wa_fcat type slis_fieldcat_alv,
       wa_lshead type slis_listheader,
       wa_layout type slis_layout_alv,
       wa_sort type slis_sortinfo_alv.

data :it_cl_data like table of clobjdat,
       wa_cl_data like clobjdat.
data: values(10type n.
data: value1(4type N.
DATA : E_EBELN TYPE EBELN.
data: c_matkl type ekpo-matkl,
       c_matnr type ekpo-matnr,
       c_ekgrp type eban-ekgrp,
       c_badat type eban-badat,
       c_index type sy-tabix,
       c_grmenge type mseg-erfmg,
       c_low(10type c,
       c_high(10type c,
       c_date type string,
       c_bukrs type ekko-bukrs,
       c_WERKS type eban-WERKS.
data: gd_date(10).
DATA: V_EVENTS TYPE SLIS_T_EVENT,
       WA_EVENT TYPE SLIS_ALV_EVENT.
*********Selection screen variables*********
selection-screen:begin of block b1 with frame title text-001.
select-options: s_bukrs for c_bukrs DEFAULT  'bmp1',
                 s_WERKS for c_WERKS,
                 s_matnr for c_matnr DEFAULT 'rm-01',
                 s_matkl for c_matkl ,
                 s_badat for c_badat ,"obligatory,
                 s_ekgrp for c_ekgrp.
parameters: ch_bal as checkbox.
selection-screen:end of block b1.
*initialization.
* PERFORM EVENT_CALL.
*  PERFORM POPULATE_EVENT.
start-of-selection.
     PERFORM EVENT_CALL.
   PERFORM POPULATE_EVENT.
   perform getdata.
   perform setdata.
   perform fieldcat.
   perform display.

*&---------------------------------------------------------------------*
*&      Form  GETDATA
*&---------------------------------------------------------------------*
form getdata .

   select a~BANFN
          a~bnfpo
          a~ekgrp
          a~badat
          a~KNTTP
          a~PSTYP
          b~ebeln
          b~ebelp
          b~matkl
          b~matnr
          b~bukrs
          into corresponding fields of table it_po
          from eban as a inner join ekpo as b
          on a~banfn = b~banfn and
             a~bnfpo = b~bnfpo AND
             A~KNTTP = B~KNTTP and
             a~PSTYP = b~PSTYP
          where  a~badat in s_badat and
                 a~ekgrp in s_ekgrp and
                 a~WERKS in s_WERKS and
                 b~matnr in s_matnr and
                 b~matkl in s_matkl and
                 b~bukrs in s_bukrs and
                 b~loekz <> 'L' and
                 a~loekz <> 'X'.

   if it_po[] is not initial.
     select ebeln
            ebelp
            matnr
            txz01
            menge
            meins
            netpr
            peinh
            banfn
            bnfpo
            mtart
            from ekpo into table it_ekpo
            for all entries in it_po
            where ebeln = it_po-ebeln and
                  ebelp = it_po-ebelp and
                  loekz <> 'L'.

     select banfn
            bnfpo
            matnr
            menge
            meins
            from eban into table it_eban
            for all entries in it_po
            where banfn = it_po-banfn and
                  bnfpo = it_po-bnfpo and
                  loekz <> 'X'.

     if it_ekpo[] is not initial.
       select ebeln
              lifnr
              bedat
              from ekko into table it_ekko
              for all entries in it_ekpo
              where ebeln = it_ekpo-ebeln.

       select ebeln
              ebelp
              belnr
              bldat
              gjahr
              buzei
              matnr
              DMBTR
              shkzg
              from ekbe into table it_ekbe
              for all entries in it_ekpo
              where ebeln = it_ekpo-ebeln and
                    ebelp = it_ekpo-ebelp .
*if it_ekbe-shkzg = 'H'.
**ekbe-dmbtr = ekbe-dmbtr * -1.
**ekbe-menge = ekbe-menge * -1.
*endif.

* select belnr
*             gjahr
*             ebeln
*             ebelp
*     from bseg into table it_bseg
*             for all entries in it_ekpo
*             where ebeln = it_ekpo-ebeln and
*                   ebelp = it_ekpo-ebelp.

       select belnr
              gjahr
              ebeln
              ebelp
              matnr
              bukrs
              from rseg into table it_rseg
              for all entries in it_ekpo
              where ebeln = it_ekpo-ebeln and
                    ebelp = it_ekpo-ebelp.
     endif.

     if it_ekbe[] is not initial.
       select mblnr
              mjahr
              zeile
              menge
              meins
              ebeln
              ebelp
              matnr
              werks
              charg
              from mseg into table it_mseg
              for all entries in it_ekbe
              where mblnr = it_ekbe-belnr and
                    mjahr = it_ekbe-gjahr and
                    zeile = it_ekbe-buzei and
                    bwart = '101'.
     endif.

     if it_rseg[] is not initial.
       select belnr
              gjahr
              bldat
              lifnr
              ZUONR
              RMWWR
              WMWST1
              from rbkp into table it_rbkp
              for all entries in it_rseg
              where belnr = it_rseg-belnr.
     endif.

if it_rseg[] is not initial.
       SELECT bukrs
               belnr
               gjahr
               buzei
               valut
               wrbtr
               augbl
               matnr
               lifnr
               ebeln
               augdt
               BUSTW

         INTO TABLE it_bseg
           FROM bseg
           FOR ALL ENTRIES IN it_rseg
           WHERE bukrs = it_rseg-bukrs and ebeln = it_rseg-ebeln and BUSTW = 'RE01' .

endif.
*
*loop at it_rbkp into wa_rbkp.
*  values = wa_rbkp-belnr.
*  value1 = s_bukrs.
*  data: aekey_1 type string .
*CONCATENATE values value1 into aekey_1.
*
*
**  if it_BSEG[] is not initial.
*
*
**MESSAGE aekey_1 type 'I'.
*      SELECT single belnr xblnr awkey into wa_bkpf
*        from bkpf
*        where awkey = aekey_1.

    values = wa_bseg-belnr.
    E_EBELN = WA_BSEG-EBELN.
SELECT single belnr dmbtr  FROM bsik
INTO  wa_bsik
WHERE
    bukrs in s_bukrs and
blart = 'RE' and
belnr = values .
if sy-subrc = 0 .
   WA_BSIK-EBELN = E_EBELN.
  insert wa_bsik into table it_BSIK.
else.

   select  single belnr dmbtr from bsak
     into wa_bsak
     WHERE
    bukrs in s_bukrs and
     blart = 'RE' and

belnr = values.
if sy-subrc = 0 .
WA_BSAK-EBELN = E_EBELN.
     insert wa_bsak into table it_bsak .
     endif.
     ENDIF.


*SELECT SINGLE BELNR EBELN FROM BSEG INTO WA_BSEG WHERE BUKRS = S_BUKRS AND BELNR = WA_BKPF-BELNR.
*  WA_BSIK-EBELN = WA_BSEG-EBELN.
*  insert wa_bsik into table it_bsik.
*CLEAR wa_bsik.
*CLEAR it_bsik.
**endloop.
* and ebeln = it_bseg-ebeln .
*    select BELNR
**           SHKZG
**           DMBTR
*           from bkpf into table it_bkpf
*            for ALL ENTRIES IN it_rbkp
*            where belnr = it_rbkp-belnr.
*        ENDif.
*IF IT_bseg[] IS NOT INITIAL.
*      select belnr
*        LIFNR
*        ebeln
*             DMBTR
*         ZUONR
*             from bsik into table it_bsik
*             for all entries in it_bseg
*             where belnr = it_bseg-belnr.
*
*      select belnr
*        LIFNR
*        ebeln
*             DMBTR
*         ZUONR
*             from bsak into table it_bsak
*             for all entries in it_bseg
*             where belnr = it_bseg-belnr.
*ENDIF.
   else.
     message s002.
     leave list-processing.
   endif.
endform.                    " GETDATA
*&---------------------------------------------------------------------*
*&      Form  SETDATA
*&---------------------------------------------------------------------*
form setdata .


   clear wa_po.
   loop at it_po into wa_po.
     c_index = sy-tabix.

********Calculate PR Quantity**********
     clear wa_eban.
     read table it_eban into wa_eban
                with key banfn = wa_po-banfn
                         bnfpo = wa_po-bnfpo.

     if sy-subrc eq 0.
       move:wa_eban-menge to wa_po-menge,
            wa_eban-meins to wa_po-meins.
     endif.

********Calculate PO Quantity**********
     clear wa_ekpo.
     read table it_ekpo into wa_ekpo
                with key banfn = wa_po-banfn
                         bnfpo = wa_po-bnfpo .

     if sy-subrc eq 0.
       move:wa_ekpo-txz01 to wa_po-txz01,
            wa_ekpo-netpr to wa_po-netpr,
            wa_ekpo-peinh to wa_po-peinh,
            wa_ekpo-mtart to wa_po-mtart,
            wa_ekpo-menge to wa_po-menge1,
            wa_ekpo-meins to wa_po-meins1.
     endif.

********Calculate Balance Quantity******
     clear wa_mseg.
     loop at it_mseg into wa_mseg
            where ebeln = wa_po-ebeln and
                  ebelp = wa_po-ebelp.
       c_grmenge = c_grmenge + wa_mseg-menge.
     endloop.

     move:wa_mseg-mblnr to wa_po-mblnr,
          c_grmenge to wa_po-menge2,
          wa_mseg-meins to wa_po-meins2,
          wa_mseg-werks to wa_po-werks,
          wa_mseg-charg to wa_po-charg.
     wa_po-balqty = wa_eban-menge - c_grmenge.

     clear : wa_rseg,wa_rbkp.
     read table it_rseg into wa_rseg with key
                    ebeln = wa_mseg-ebeln
                    ebelp = wa_mseg-ebelp.

     read table it_rbkp into wa_rbkp
                with key belnr = wa_rseg-belnr
                         gjahr = wa_rseg-gjahr.
     if sy-subrc eq 0.
       move : wa_rbkp-belnr to wa_po-belnr,
              wa_rbkp-bldat to wa_po-bldat,
              wa_rbkp-RMWWR to wa_po-RMWWR,
              WA_RBKP-WMWST1 TO WA_PO-WMWST1.
     endif.

       read table it_bseg into wa_bseg with key
                     ebeln = wa_rseg-ebeln
                     bukrs = wa_rseg-bukrs.
       if sy-subrc eq 0.
         move wa_bseg-belnr to wa_po-belnr_d.
       endif.
*    read table it_bkpf into wa_bkpf
*    with key belnr = wa_ekbe-belnr.

*    read table it_bseg into wa_bseg
*    with key belnr = wa_bkpf-belnr.
CLEAR wa_bsik.
clear it_bsik.
     read table it_bsik into wa_bsik
     with key belnr = wa_bkpf-belnr.
*    if wa_bsik-shkzg = 'H'.
*     wa_bsik-DMBTR = wa_bsik-DMBTR * 1.
*     endif.
       if sy-subrc eq 0.
         move : wa_bsik-belnr to wa_po-belnr,
                 wa_bsik-dmbtr_i to wa_po-dmbtr_i.
        endif.
*    clear wa_bsik.
*    read table it_bsik into wa_bsik
*               with key  belnr = wa_bseg-belnr.
*
*    if sy-subrc eq 0.
*        move : wa_bsik-DMBTR to wa_po-DMBTR.
*    endif.
*clear wa_bsak.
*    read table it_bsak into wa_bsak
*               with key  belnr = wa_bseg-belnr.
*
*    if sy-subrc eq 0.
*        move : wa_bsak-DMBTR_C to wa_po-DMBTR_C.
*    endif.
*clear : wa_rbkp.
*loop at it_bsik into wa_bsik.
*read table it_bsik into wa_bsik with key belnr = wa_rbkp-belnr.
*if sy-subrc eq 0.
*  move : wa_bsik-DMBTR to wa_po-DMBTR.
*    endif.
*endloop.
*********Assign Vendor,PO Date*********
     clear wa_ekko.
     read table it_ekko into wa_ekko
                with key ebeln = wa_po-ebeln.

     if sy-subrc eq 0.
       move:wa_ekko-lifnr to wa_po-lifnr,
            wa_ekko-bedat to wa_po-bedat.
     endif.
*clear wa_ekko.
*read table it_ekko into wa_ekko
*with key lifnr = wa_po-lifnr.
*if sy-subrc eq 0.
*  move: wa_bsik-DMBTR to wa_po-DMBTR.
*  endif.
*    call function 'ZSD_BATCH_CLASSIFICATION_DATA'
*      exporting
**        ch_charg                   = wa_po-charg
*        ch_matnr                   = wa_po-matnr
*        ch_werks                   = wa_po-werks
*      tables
*        cl_data                    = it_cl_data
**       I_SEL_CHARACTERISTIC       =
*              .
     loop at it_cl_data into wa_cl_data.
       if wa_cl_data-ausp1 ne '?'.
         if wa_cl_data-atnam eq 'THICKNESS'.
           move wa_cl_data-ausp1 to wa_po-thick.

         elseif wa_cl_data-atnam eq 'LENGTH'.
           move wa_cl_data-ausp1 to wa_po-length.

         elseif wa_cl_data-atnam eq 'WIDTH'.
           move wa_cl_data-ausp1 to wa_po-width.

         elseif wa_cl_data-atnam eq 'GRADE'.
           move wa_cl_data-ausp1 to wa_po-grade.
         endif.
       endif.
     endloop.
     modify it_po from wa_po index c_index.
     clear :c_grmenge,wa_po,wa_ekpo,wa_mseg,c_index.
     ENDLOOP.
endform.                    " SETDATA
*&---------------------------------------------------------------------*
*&      Form  FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form fieldcat .
   perform buildfields using '1' 'BANFN'  'IT_PO' 'PR Number' '' ''.
*  perform buildfields using '2' 'BNFPO'  'IT_PO' 'PR Item Number' '' ''.
   perform  buildfields using '2' 'KNTTP' 'IT_PO' 'A/c Assignment Cat' '' ''.
   perform  buildfields using '3' 'PSTYP' 'IT_PO' 'Item Cat' '' ''.
   perform buildfields using '4' 'EKGRP'  'IT_PO' 'Purchase Group' '' ''.
   perform buildfields using '5' 'BADAT'  'IT_PO' 'Request Date' '' ''.
   perform buildfields using '6' 'MENGE'  'IT_PO' 'PR Quantity'  'X' ''.
   perform buildfields using '7' 'MEINS'  'IT_PO' 'PR Unit' '' ''.
   perform buildfields using '8' 'LIFNR'  'IT_PO' 'Vendor Number' '' ''.
   perform buildfields using '9' 'EBELN'  'IT_PO' 'Purchasing Doc No' '' ''  .
   perform buildfields using '10' 'BEDAT'  'IT_PO' 'PO Date' '' ''.
   perform buildfields using '11' 'MTART' 'IT_PO' 'Material Type' '' ''.
   perform buildfields using '12' 'MATKL' 'IT_PO' 'Material Group' '' ''.
   perform buildfields using '13' 'MATNR' 'IT_PO' 'Material Number' '' ''.
   perform buildfields using '14' 'TXZ01' 'IT_PO' 'Material Desc' '' ''.
   perform buildfields using '15' 'MENGE1' 'IT_PO' 'PO Quantity' 'X' ''.
   perform buildfields using '16' 'MEINS' 'IT_PO' 'PO Unit' '' ''.
   perform buildfields using '17' 'NETPR' 'IT_PO' 'Net Price' '' ''.
   perform buildfields using '18' 'PEINH' 'IT_PO' 'Price Unit' '' ''.

   perform buildfields using '20' 'MBLNR' 'IT_PO' 'GR Number' '' ''.

   perform buildfields using '21' 'MENGE2' 'IT_PO' 'GR Quantity' 'X' ''.
   perform buildfields using '22' 'MEINS2' 'IT_PO' 'GR Unit' '' ''.
   perform buildfields using '23' 'BELNR' 'IT_PO' 'Invoice doc. number' '' ''.

   perform buildfields using '24' 'BLDAT' 'IT_PO' 'Invoice Date' '' ''.
    perform buildfields using '19' 'BELNR_D' 'IT_PO' 'IR A/C Doc. No.' '' ''.

*  perform buildfields using '26' 'AUGBL' 'IT_PO' 'Clearing Doc No.' '' ''.
*  perform buildfields using '25' 'DMBTR_a' 'IT_PO' 'OPEN AMOUNT' '' ''.
* perform buildfields using '26' 'DMBTR_i' 'IT_PO' 'clear AMOUNT' '' ''.
*  perform buildfields using '26' 'DMBTR_C' 'IT_PO' 'Clear balance' '' ''.
   if ch_bal = 'X'.
     perform buildfields using '27' 'BALQTY' 'IT_PO' 'Balance Quantity'
     'X' ''.
   endif.
   perform buildfields using '28' 'WMWST1' 'IT_PO' 'TOTAL TAX ADDED' 'X' ''.
   perform buildfields using '29' 'RMWWR' 'IT_PO' 'TOTAL AMOUNT IN INVOICE' 'X' ''.
endform.                    " FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  BUILDFIELDS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0449   text
*      -->P_0450   text
*      -->P_0451   text
*      -->P_0452   text
*----------------------------------------------------------------------*
form buildfields  using    value(p_col_pos) like sy-cucol
                            value(p_fldname) type slis_fieldname
                            value(p_tabname) type slis_tabname
                            value(p_reptext) like dd03p-reptext
                            value(p_do_sum) type char1
                            value(hotspottype char1.


   wa_fcat-col_pos = p_col_pos.
   wa_fcat-fieldname = p_fldname.
   wa_fcat-tabname = p_tabname.
   wa_fcat-reptext_ddic = p_reptext.
   wa_fcat-do_sum = p_do_sum.
   wa_fcat-hotspot = hotspot.
   append wa_fcat to it_fcat.
   clear wa_fcat.

endform.                    " BUILDFIELDS
*&---------------------------------------------------------------------*
*&      Form  DISPLAY
*&---------------------------------------------------------------------*
form display .
   clear wa_layout.
   wa_layout-zebra = 'X'.
   wa_layout-colwidth_optimize = 'X'.
* wa_layout-box_fieldname     = 'SEL'.
* wa_layout-edit = 'X'.
   perform build_sort using 'BANFN' '1' 'X'.

   call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
      i_callback_program               = sy-cprog
*   I_CALLBACK_PF_STATUS_SET          = ' '
    I_CALLBACK_USER_COMMAND           = 'USER_COMMAND '
      i_callback_top_of_page           = 'TOP_OF_PAGE'
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
    i_background_id                   = 'ALV_BACKGROUND'
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
      is_layout                        = wa_layout
      it_fieldcat                      = it_fcat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
     it_sort                           = it_sort
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
    I_SAVE                            = 'A'
*   IS_VARIANT                        =
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
     tables
       t_outtab                          = it_po[]
  exceptions
    program_error                     = 1
    others                            = 2
             .
   if sy-subrc <> 0.
     message id sy-msgid type sy-msgty number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
   endif.

endform.                    " DISPLAY

*&---------------------------------------------------------------------*
*&      Form  top_of_page
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form top_of_page.                                           "#EC *
**********Create report header*********
   refresh it_lshead.
   clear wa_lshead.
**********To display date in header*********
*  write: s_badat-low to c_low dd/mm/yyyy,s_badat-high to c_high
*  dd/mm/yyyy.
*  if s_badat-high is initial.
*    concatenate 'Dated on' c_low into c_date separated by space.
*  else.
*    concatenate 'Dated between' c_low 'and' c_high into c_date separated
*    by space.
*  endif.

   wa_lshead-typ = 'H'.
   wa_lshead-info = 'PR To Payment History'.
*  'Pending Indents History - Material Type HR,ZINC and Others'.
   append wa_lshead to it_lshead.

   wa_lshead-typ = 'S'.
   wa_lshead-info = c_date .
   append wa_lshead to it_lshead.

   call function 'REUSE_ALV_COMMENTARY_WRITE'
     exporting
       it_list_commentary       = it_lshead
*      i_logo                   = 'SGL LOGO'
*     I_END_OF_LIST_GRID       =
*     I_ALV_FORM               =
             .
endform.                    "top_of_page
*&---------------------------------------------------------------------*
*&      Form  BUILD_SORT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_1072   text
*      -->P_1073   text
*      -->P_1074   text
*----------------------------------------------------------------------*
form build_sort  using    value(p_fldname) type slis_fieldname
                           value(p_spos) like alvdynp-sortpos
                           value(p_up) like alvdynp-sortup.
   wa_sort-fieldname = p_fldname.
   wa_sort-spos = p_spos.
   wa_sort-up = p_up.
   append wa_sort to it_sort.
   clear wa_sort.
endform.                    " BUILD_SORT
*&---------------------------------------------------------------------*
*&      Form  EVENT_CALL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM EVENT_CALL .
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      I_LIST_TYPE           = 0
    IMPORTING
      ET_EVENTS             = V_EVENTS
*  EXCEPTIONS
*    LIST_TYPE_WRONG       = 1
*    OTHERS                = 2
             .
   IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   ENDIF.
ENDFORM.                    " EVENT_CALL
*&---------------------------------------------------------------------*
*&      Form  POPULATE_EVENT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM POPULATE_EVENT .
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
   IF SY-SUBRC EQ 0.
     WA_EVENT-FORM = 'TOP_OF_PAGE'.
     MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
   ENDIF.

   READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
   IF SY-SUBRC EQ 0.
     WA_EVENT-FORM = 'USER_COMMAND'.
     MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
   ENDIF.
ENDFORM.                    " POPULATE_EVENT


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
       RS_SELFIELD TYPE SLIS_SELFIELD.
    CASE R_UCOMM.
     WHEN '&IC1'.
        READ TABLE IT_po INTO WA_po INDEX RS_SELFIELD-TABINDEX.
        perform abc.

ENDCASE.
   ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  abc
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM abc .
* CALL TRANSACTION 'ZVENDOR_PAY_HISTORY'.


  CALL TRANSACTION 'ZFI_VENDOR_AGEING_RE'.

ENDFORM.                    " abc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SAP剑客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值