Skip to end of metadata
Go to start of metadata

Objective: Most of the time  every client requires AP Aging report to track the Vendor information amount.


\*&--------------------------------------------------------------------\*
\*& Report  ZFI_ARAGING                                                *
\*&                                                                    *
\*&--------------------------------------------------------------------\*
\*& Developer: Chidanand Chauhan (Sparta Consulting)                   *
\*& Date: 1/20/2009                                                    *
\*& Transport Request: DEVK913008                                      *
\*& Description:  AR Aging Report                                      *
\*&                                                                    *
\*&--------------------------------------------------------------------\*
\*           M O D I F I C A T I O N   L O G                           *
\*&--------------------------------------------------------------------\*
\*  Version     Date       Developer    Description of change          *
\*&--------------------------------------------------------------------\*
\*   1.0        1/20/2009   CChauhan     Initial Development           *
\*&--------------------------------------------------------------------\*
REPORT  zfi_araging.
TYPE-POOLS: slis.
TABLES: kna1,
        knb1,
        bsid.
DATA: BEGIN OF it_bsid OCCURS 0,
   bukrs TYPE bsid-bukrs,    " Company Code
   kunnr TYPE bsid-kunnr,    " Customer No
   gjahr TYPE bsid-gjahr,    " FINANCIAL YEAR
   belnr TYPE bsid-belnr,    " Doc No
   blart TYPE bsid-blart,    " Doc Type
   bldat TYPE bsid-bldat,    " Doc Date
   shkzg TYPE bsid-shkzg,    " Credit / Debit
   waers TYPE bsid-waers,    " Local Currency
   monat TYPE bsid-monat,     "FINANCIAL PERIOD
   dmbtr TYPE bsid-dmbtr,    " Amount in Loc Currency
   wrbtr TYPE bsid-wrbtr,    " Amount in DC
   hkont TYPE bsid-hkont,    " General Ledger Account
   zterm TYPE bsid-zterm,     " Terms of payment key
   zbd1t TYPE bsid-zbd1t,    " Days
   vbeln TYPE bsid-vbeln,    "Sales Document
END OF it_bsid.
DATA: BEGIN OF it_bkpf OCCURS 0,
        bukrs TYPE bkpf-bukrs,    "Company Code
        belnr TYPE bkpf-belnr,    "Doc No
        xblnr TYPE bkpf-xblnr,    "Reference
        budat TYPE bkpf-budat,    "Posting Date
 END OF it_bkpf.
DATA: BEGIN OF it_kna1 OCCURS 0,
  kunnr TYPE kna1-kunnr,
  name1 TYPE kna1-name1,
  land1 TYPE kna1-land1,
  regio TYPE kna1-regio,
END OF it_kna1.
DATA: BEGIN OF it_vbpa OCCURS 0,
  vbeln TYPE vbpa-vbeln,
  kunnr TYPE vbpa-kunnr,
END OF it_vbpa.
DATA : BEGIN OF it_v_vbsegd OCCURS 0,
        bukrs TYPE v_vbsegd-bukrs,   "Company Code
        kunnr TYPE v_vbsegd-kunnr,   "Customer No.
        belnr TYPE v_vbsegd-belnr,   "Doc. No.
        blart TYPE v_vbsegd-blart,   "Doc. type
        bldat TYPE v_vbsegd-bldat,   "Doc. Date
        shkzg TYPE v_vbsegd-shkzg,   "Credit / Debit
        swaer TYPE v_vbsegd-swaer,   "Currency Key
        dmbtr TYPE v_vbsegd-dmbtr,   "Amount in Local currency
        wrbtr TYPE v_vbsegd-wrbtr,   "Amount in Doc. Curr.
        zbd1t TYPE v_vbsegd-zbd1t,   "Days
        xblnr TYPE v_vbsegd-xblnr,   "Reference Doc.
        budat TYPE v_vbsegd-budat,   "Postin Date
       END OF it_v_vbsegd.
DATA: BEGIN OF it_final OCCURS 0,
       kunnr TYPE bsid-kunnr,    " Customer No
       name1 TYPE kna1-name1,    " Customer Name
       landx TYPE t005t-landx,  "  COUNTRY
       bezei TYPE t005u-bezei,    " Region
       name11 type kna1-name1,    " Sales person name
       bukrs TYPE bsid-bukrs,    " Company Code
       gjahr TYPE bsid-gjahr,    " FINANCIAL YEAR
       belnr TYPE bsid-belnr,    " Doc No
       blart TYPE bsid-blart,    " Doc Type
       xblnr TYPE bkpf-xblnr,    "Reference
       bldat TYPE bsid-bldat,    " Doc Date
       budat TYPE bkpf-budat,    "Posting Date
       duedt TYPE bkpf-budat,    " Due Date
       wrbtr TYPE bsid-wrbtr,    " Amount in DC
       hkont TYPE bsid-hkont,    " General Ledger Account
       waers TYPE bsid-waers,    "Local Currency
       monat TYPE bsid-monat,    "FINANCIAL PERIOD
       vbeln TYPE bsid-vbeln,    "Sales Document
       bstnk TYPE vbak-bstnk,    " Purchase Order No
       dmbtr TYPE bsid-dmbtr,    " Amount in Loc Currency
       zterm TYPE bsid-zterm,    " Terms of payment key
       zbd1t TYPE bsid-zbd1t,    " Days
       AGING TYPE BSID-DMBTR,    "Aging
       30days TYPE bsid-dmbtr,                              " 30 Days,
       60days TYPE bsid-dmbtr,                              " 60 Days,
       90days TYPE bsid-dmbtr,                              " 90 Days,
       120days TYPE bsid-dmbtr,                             "120 Days,
       150days TYPE bsid-dmbtr,                             "150 Days,
       yrmon(10) ,                     "for year month concatination
      END OF it_final.
DATA: BEGIN OF it_vbfa OCCURS 0,
  vbelv TYPE vbfa-vbelv,    "Sales Order
  vbeln TYPE vbfa-vbeln,    "Billing Doc
END OF it_vbfa.
DATA: BEGIN OF it_vbak OCCURS 0,
    vbeln TYPE vbak-vbeln,     " Sales Order
    bstnk TYPE vbak-bstnk,     " Purchase Order
 END OF it_vbak.
DATA: BEGIN OF it_t005t OCCURS 0,
    land1 TYPE t005t-land1,
    landx TYPE t005t-landx,
END OF it_t005t.
DATA: BEGIN OF it_t005u OCCURS 0,
    land1 TYPE t005u-land1,
    bland TYPE t005u-bland,
    bezei TYPE t005u-bezei,
  END OF it_t005u.
DATA: BEGIN OF it_kna11 OCCURS 0,
    kunnr TYPE kna1-kunnr,
    name1 TYPE kna1-name1,
  END OF it_kna11.
DATA: gt_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE .
DATA: gv_repname        LIKE sy-repid.
DATA: gs_layout         TYPE slis_layout_alv.
CONSTANTS: formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',
           c_check TYPE c VALUE 'X'.
DATA: events         TYPE slis_t_event,
      l_string       TYPE slis_entry,
      wa_header      TYPE slis_listheader,
      heading        TYPE slis_t_listheader,
      dat  LIKE sy-datum.
\*&--------------------------------------------------------------------\*
\*    S E L E C T I O N     S C R E E N    D E C L A R A T I O N
\*&--------------------------------------------------------------------\*
SELECTION-SCREEN BEGIN OF BLOCK customer WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr .
SELECT-OPTIONS: s_bukrs FOR knb1-bukrs  OBLIGATORY.
SELECTION-SCREEN END OF BLOCK customer.
SELECTION-SCREEN BEGIN OF BLOCK line WITH FRAME TITLE text-002.
PARAMETERS pa_stida LIKE rfpdo-allgstid DEFAULT sy-datlo.
SELECTION-SCREEN END OF BLOCK line.
SELECTION-SCREEN BEGIN OF BLOCK further WITH FRAME TITLE text-003.
PARAMETERS: p_norm LIKE itemset-xnorm AS CHECKBOX DEFAULT 'X',
            p_park LIKE itemset-xpark AS CHECKBOX,
            p_merk LIKE itemset-xmerk AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK further.
\*&--------------------------------------------------------------------\*
\*      A T      S E L E C T I O N     S C R E E N
\*---------------------------------------------------------------------\*
AT SELECTION-SCREEN ON BLOCK further.
  IF p_norm IS INITIAL AND p_park IS INITIAL AND p_merk IS INITIAL.
    MESSAGE e020(msitem).
  ENDIF.
\*&--------------------------------------------------------------------\*
\*      S T A R T     O F    S E L E C T I O N
\*&--------------------------------------------------------------------\*
START-OF-SELECTION.
  PERFORM get_data.
  PERFORM get_final_data.
  PERFORM display_output.
\*&--------------------------------------------------------------------\*
\*&      Form  get_data
\*&--------------------------------------------------------------------\*
\*  Populate internal table with appropriate data.
\*---------------------------------------------------------------------\*
FORM get_data .
\*&--If normal item is selected.
  IF p_norm = c_check.
\*&--Get Comapny ocde and Customer specific data from BSID
    SELECT
           bukrs
           kunnr
           gjahr
           belnr
           blart
           bldat
           shkzg
           waers
           monat
           dmbtr
           wrbtr
           hkont
           zterm
           zbd1t
           vbeln
       INTO TABLE it_bsid
       FROM bsid
       WHERE bukrs IN s_bukrs
         AND kunnr IN s_kunnr
         AND bstat = '' AND umskz = ''.
  ENDIF.
\*&--If noted item is selected.
  IF p_merk = c_check.
\*&--Get Comapny ocde and Customer specific data from BSID
\*&--Use of APPENDING instead of INTO to add records if table
\*&--contains records as NORMAL ITEMS.
    SELECT
           bukrs
           kunnr
           gjahr
           belnr
           blart
           bldat
           shkzg
           waers
           monat
           dmbtr
           wrbtr
           hkont
           zterm
           zbd1t
           vbeln
       APPENDING TABLE it_bsid
       FROM bsid
       WHERE bukrs IN s_bukrs
         AND kunnr IN s_kunnr
         AND bstat = 'S'.
  ENDIF.
\*&--Get Reference No and posting Date
  SORT it_bsid   BY  bukrs belnr.
  IF NOT it_bsid\[\] IS INITIAL.
    SELECT bukrs
           belnr
           xblnr
           budat
       INTO TABLE it_bkpf
       FROM bkpf
       FOR ALL ENTRIES IN it_bsid
       WHERE bukrs = it_bsid-bukrs
       AND   belnr = it_bsid-belnr.
\*&-\- Get the Sales Order information
    SELECT vbelv  " Billing Doc no
           vbeln  " Sales Order
      INTO TABLE it_vbfa
      FROM vbfa
      FOR ALL ENTRIES IN it_bsid
      WHERE vbeln = it_bsid-vbeln.
    IF NOT it_vbfa\[\] IS INITIAL.
\*&Get the Sales Order and Related Purchase Order
      SELECT vbeln      " Sales Order
             bstnk      " Purchase Order
        INTO TABLE it_vbak
        FROM vbak
        FOR ALL ENTRIES IN it_vbfa
        WHERE vbeln = it_vbfa-vbelv.
    ENDIF.
\*& Get Sales Person number
    IF NOT it_vbak\[\] IS INITIAL.
      SELECT vbeln
             kunnr
       INTO TABLE it_vbpa
       FROM vbpa
       FOR ALL ENTRIES IN it_vbak
       WHERE vbeln = it_vbak-vbeln
         AND parvw = 'SA'.
    ENDIF.
    IF NOT it_vbpa\[\] IS INITIAL.
\*& Get Sales person name
      SELECT kunnr
             name1
       INTO TABLE it_kna11
       FROM kna1
       FOR ALL ENTRIES IN it_vbpa
       WHERE kunnr = it_vbpa-kunnr.
    ENDIF.
  ENDIF.
\*&--If parked item is selected.
  IF p_park = c_check.
\*&--Get Customer specific,Company Code and reference doc for Parked Items from V_VBSEGD
    SELECT bukrs
           kunnr
           belnr
           blart
           bldat
           shkzg
           swaer
           dmbtr
           wrbtr
           zbd1t
           xblnr
           budat
        INTO TABLE it_v_vbsegd
        FROM v_vbsegd
        WHERE bukrs IN s_bukrs
          AND kunnr IN s_kunnr.
\*&--Populate it_bsid and it_bkpf for Parked items.
    LOOP AT it_v_vbsegd.
      it_bsid-bukrs = it_v_vbsegd-bukrs.
      it_bsid-kunnr = it_v_vbsegd-kunnr.
      it_bsid-belnr = it_v_vbsegd-belnr.
      it_bsid-blart = it_v_vbsegd-blart.
      it_bsid-bldat = it_v_vbsegd-bldat.
      it_bsid-shkzg = it_v_vbsegd-shkzg.
      it_bsid-waers = it_v_vbsegd-swaer.
      it_bsid-dmbtr = it_v_vbsegd-dmbtr.
      it_bsid-wrbtr = it_v_vbsegd-wrbtr.
      it_bsid-zbd1t = it_v_vbsegd-zbd1t.
      it_bkpf-bukrs = it_v_vbsegd-bukrs.
      it_bkpf-belnr = it_v_vbsegd-belnr.
      it_bkpf-xblnr = it_v_vbsegd-xblnr.
      it_bkpf-budat = it_v_vbsegd-budat.
      APPEND: it_bsid,it_bkpf.
      CLEAR: it_bsid,it_bkpf.
    ENDLOOP.
  ENDIF.
\*&--Get Customer Name
  SELECT kunnr
         name1
         land1
         regio
     INTO TABLE it_kna1
     FROM kna1
     WHERE kunnr IN s_kunnr.
  IF NOT  it_kna1\[\] IS INITIAL.
    SELECT land1
           landx
      INTO TABLE it_t005t
      FROM t005t
      FOR ALL ENTRIES IN it_kna1
      WHERE spras = sy-langu
      AND   land1 = it_kna1-land1.
    SELECT land1
           bland
           bezei
       INTO TABLE it_t005u
       FROM t005u
       FOR ALL ENTRIES IN it_kna1
       WHERE spras = sy-langu
         AND land1 = it_kna1-land1
         AND bland = it_kna1-regio.
  ENDIF.
ENDFORM.                    " get_data
\*&--------------------------------------------------------------------\*
\*&      Form  get_final_data
\*&--------------------------------------------------------------------\*
\*   Insert all relevant data in final table tobe displayed
\*---------------------------------------------------------------------\*
FORM get_final_data .
  LOOP AT it_bsid.
    it_final-kunnr  = it_bsid-kunnr.
    it_final-belnr  = it_bsid-belnr.
    it_final-blart  = it_bsid-blart.
    it_final-bldat  = it_bsid-bldat.
    it_final-waers  = it_bsid-waers.
    it_final-dmbtr  = it_bsid-dmbtr.
    it_final-wrbtr  = it_bsid-wrbtr.
    it_final-zbd1t  = it_bsid-zbd1t.    " Days
    it_final-bukrs  = it_bsid-bukrs.
    it_final-gjahr  = it_bsid-gjahr.
    it_final-monat  = it_bsid-monat.
    it_final-vbeln  = it_bsid-vbeln.
    it_final-hkont  = it_bsid-hkont.
    it_final-zterm  = it_bsid-zterm.
    READ TABLE it_vbfa WITH KEY vbeln = it_bsid-vbeln.
    IF sy-subrc = 0.
      READ TABLE it_vbak WITH KEY vbeln = it_vbfa-vbelv.
      IF sy-subrc = 0.
        it_final-vbeln = it_vbak-vbeln.   "Sales Order
        it_final-bstnk = it_vbak-bstnk.   "Purchase Order
        READ TABLE it_vbpa WITH KEY vbeln = it_vbak-vbeln.
        IF sy-subrc = 0.
          READ TABLE it_kna11 WITH KEY kunnr = it_vbpa-kunnr.
          IF sy-subrc = 0.
            it_final-name11 = it_kna11-name1.    "Sales person name
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
    READ TABLE it_kna1 WITH KEY kunnr = it_bsid-kunnr.
    IF sy-subrc = 0.
      it_final-name1  = it_kna1-name1.
      READ TABLE it_t005t WITH KEY land1 = it_kna1-land1.
      IF sy-subrc = 0.
        it_final-landx = it_t005t-landx.
      ENDIF.
      READ TABLE it_t005u WITH KEY land1 = it_kna1-land1
                                   bland = it_kna1-regio.
      IF sy-subrc = 0.
        it_final-bezei = it_t005u-bezei.
      ENDIF.
    ENDIF.
    READ TABLE it_bkpf WITH KEY bukrs = it_bsid-bukrs
                                belnr = it_bsid-belnr.
    IF sy-subrc = 0.
      it_final-xblnr = it_bkpf-xblnr.
      it_final-budat = it_bkpf-budat.
    ENDIF.
\*&--logic to calculate the days.
    DATA: lv_diff TYPE i.
    DATA: lv_date TYPE sy-datum.
    lv_date = it_final-budat + it_final-zbd1t.
    it_final-duedt = lv_date.
    lv_diff = pa_stida - lv_date.
    IF it_bsid-shkzg = 'H'.
      it_final-dmbtr = it_final-dmbtr * ( \-1 ).
      it_final-wrbtr = it_final-wrbtr * ( \-1 ).
    ENDIF.
    IF lv_diff > 120.
      it_final-150days = it_final-dmbtr.
      it_final-aging = it_final-dmbtr.
    ELSEIF lv_diff > 90.
      it_final-120days = it_final-dmbtr.
      it_final-aging = it_final-dmbtr.
    ELSEIF lv_diff > 60.
      it_final-90days = it_final-dmbtr.
      it_final-aging = it_final-dmbtr.
    ELSEIF lv_diff > 30.
      it_final-60days = it_final-dmbtr.
    ELSE.
      it_final-30days = it_final-dmbtr.
    ENDIF.
\*&-->concatenate
    CONCATENATE it_final-gjahr
                it_final-monat INTO it_final-yrmon SEPARATED BY '/'.
    APPEND it_final.
    CLEAR  it_final.
  ENDLOOP.
ENDFORM.                    " get_final_data
\*&--------------------------------------------------------------------\*
\*&      Form  display_output
\*&--------------------------------------------------------------------\*
\*   Display the final output in ALV
\*---------------------------------------------------------------------\*
FORM display_output .
  gv_repname = sy-repid.
\* CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
\*  EXPORTING
\*    I_PROGRAM_NAME               = gv_repname
\*    I_INTERNAL_TABNAME           = 'IT_FINAL'
\*    I_INCLNAME                   = gv_repname
\*   CHANGING
\*     ct_fieldcat                  = g_fcat
\*  EXCEPTIONS
\*    INCONSISTENT_INTERFACE       = 1
\*    PROGRAM_ERROR                = 2
\*    OTHERS                       = 3
\*           .
\* IF sy-subrc <> 0.
\*\* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
\**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
\* ENDIF.
&nbsp; PERFORM build_fieldcat.
&nbsp; PERFORM display_alv.
&nbsp;
ENDFORM.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " display_output
\*&---------------------------------------------------------------------\*
\*&&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Form&nbsp; build_fieldcat
\*&---------------------------------------------------------------------\*
\*&nbsp;&nbsp; Build Fieldcatalog for output in ALV
\*----------------------------------------------------------------------\*
FORM build_fieldcat .
&nbsp; DATA: lv_count TYPE i VALUE 0.
&nbsp; gt_fcat-fieldname = 'BUKRS'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Comp Co'.
&nbsp; gt_fcat-seltext_m = 'Comp Code'.
&nbsp; gt_fcat-seltext_l = 'Company Code'.
&nbsp; gt_fcat-no_zero = ''.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
\*&nbsp; gt_fcat-fieldname = 'HKONT'.
\*&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
\*&nbsp; gt_fcat-seltext_s = 'G/L'.
\*&nbsp; gt_fcat-seltext_m = 'G/L'.
\*&nbsp; gt_fcat-seltext_l = 'General Ledger Account'.
\*&nbsp; gt_fcat-outputlen = '30'.
\*&nbsp; gt_fcat-col_pos = lv_count.
\*&nbsp; lv_count = lv_count + 1.
\*&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'KUNNR'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Customer No'.
&nbsp; gt_fcat-seltext_m = 'Customer No'.
&nbsp; gt_fcat-seltext_l = 'Customer No'.
&nbsp; gt_fcat-no_zero = 'X'.
&nbsp; gt_fcat-outputlen = '30'.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'NAME1'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Customer Name'.
&nbsp; gt_fcat-seltext_m = 'Customer Name'.
&nbsp; gt_fcat-seltext_l = 'Customer Name'.
gt_fcat-outputlen = '30'.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'LANDX'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Country'.
&nbsp; gt_fcat-seltext_m = 'Country'.
&nbsp; gt_fcat-seltext_l = 'Country'.
gt_fcat-outputlen = '30'.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'BEZEI'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Region'.
&nbsp; gt_fcat-seltext_m = 'Region'.
&nbsp; gt_fcat-seltext_l = 'Region'.
gt_fcat-outputlen = '30'.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'NAME11'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Sales Person Name'.
&nbsp; gt_fcat-seltext_m = 'Sales Person Name'.
&nbsp; gt_fcat-seltext_l = 'Sales Person Name'.
&nbsp; gt_fcat-outputlen = '30'.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'BELNR'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Doc No'.
&nbsp; gt_fcat-seltext_m = 'Document No'.
&nbsp; gt_fcat-seltext_l = 'Document Number'.
gt_fcat-outputlen = '30'.
&nbsp; gt_fcat-no_zero = 'X'.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'XBLNR'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Reference'.
&nbsp; gt_fcat-seltext_m = 'Reference'.
&nbsp; gt_fcat-seltext_l = 'Reference'.
&nbsp; gt_fcat-no_zero = 'X'.
gt_fcat-outputlen = '30'.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'BLART'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Doc Type'.
&nbsp; gt_fcat-seltext_m = 'Document Type'.
&nbsp; gt_fcat-seltext_l = 'Document Type'.
gt_fcat-outputlen = '30'.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'YRMON'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'year/mon'.
&nbsp; gt_fcat-seltext_m = 'Year / Mon'.
&nbsp; gt_fcat-seltext_l = 'Year/Month'.
&nbsp; gt_fcat-outputlen = 15.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-col_pos = 6.
&nbsp; gt_fcat-fieldname = 'BLDAT'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Doc Date'.
&nbsp; gt_fcat-seltext_m = 'Document Date'.
&nbsp; gt_fcat-seltext_l = 'Document Date'.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'BUDAT'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Posting Date'.
&nbsp; gt_fcat-seltext_m = 'Posting Date'.
&nbsp; gt_fcat-seltext_l = 'Posting Date'.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'DUEDT'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Due Date'.
&nbsp; gt_fcat-seltext_m = 'Due Date'.
&nbsp; gt_fcat-seltext_l = 'Due Date'.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'VBELN'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Sal Odr'.
&nbsp; gt_fcat-seltext_m = 'Sal Order'.
&nbsp; gt_fcat-seltext_l = 'Sales Order'.
&nbsp; gt_fcat-outputlen = 15.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'BSTNK'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Purc Odr'.
&nbsp; gt_fcat-seltext_m = 'Purc Order'.
&nbsp; gt_fcat-seltext_l = 'Purchase Order'.
&nbsp; gt_fcat-outputlen = 15.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp;
&nbsp; gt_fcat-fieldname = 'WRBTR'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-do_sum&nbsp; = 'X'.
&nbsp; gt_fcat-no_sign = ' '.
&nbsp; gt_fcat-seltext_s = 'Amount in DC'.
&nbsp; gt_fcat-seltext_m = 'Amount in DC'.
&nbsp; gt_fcat-seltext_l = 'Amount in Document Currency'.
&nbsp; gt_fcat-outputlen = 15.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'WAERS'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-do_sum&nbsp; = 'X'.
&nbsp; gt_fcat-no_sign = ' '.
&nbsp; gt_fcat-seltext_s = 'Local Curr'.
&nbsp; gt_fcat-seltext_m = 'Local Currency'.
&nbsp; gt_fcat-seltext_l = 'Local Currency'.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-col_pos = 11.
&nbsp; gt_fcat-fieldname = 'DMBTR'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Amt in LC'.
&nbsp; gt_fcat-seltext_m = 'Amt in Loc Curr'.
&nbsp; gt_fcat-seltext_l = 'Amount in Local Currency'.
&nbsp; gt_fcat-outputlen = 15.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'ZTERM'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Pay Trm'.
&nbsp; gt_fcat-seltext_m = 'Pay Term'.
&nbsp; gt_fcat-seltext_l = 'Payment Term'.
&nbsp; gt_fcat-outputlen = 15.
&nbsp; gt_fcat-no_zero = ' '.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = 'AGING'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = 'Aging'.
&nbsp; gt_fcat-seltext_m = 'Aging'.
&nbsp; gt_fcat-seltext_l = 'Aging'.
&nbsp; gt_fcat-outputlen = 20.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = '30DAYS'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = '0 - 30 Days'.
&nbsp; gt_fcat-seltext_m = '0 - 30 Days'.
&nbsp; gt_fcat-seltext_l = '0 - 30 Days'.
&nbsp; gt_fcat-outputlen = 30.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = '60DAYS'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = '31 - 60 Days'.
&nbsp; gt_fcat-seltext_m = '31 Days - 60 Days'.
&nbsp; gt_fcat-seltext_l = '31 Days - 60 Days'.
&nbsp; gt_fcat-outputlen = 30.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = '90DAYS'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = '61 Days - 90 Days'.
&nbsp; gt_fcat-seltext_m = '61 Days - 90 Days'.
&nbsp; gt_fcat-seltext_l = '61 Days - 90 Days'.
&nbsp; gt_fcat-outputlen = 30.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = '120DAYS'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = '91 Days - 120 Days'.
&nbsp; gt_fcat-seltext_m = '91 Days - 120 Days'.
&nbsp; gt_fcat-seltext_l = '91 Days - 120 Days'.
&nbsp; gt_fcat-outputlen = 30.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
&nbsp; gt_fcat-fieldname = '150DAYS'.
&nbsp; gt_fcat-tabname&nbsp;&nbsp; = 'IT_FINAL'.
&nbsp; gt_fcat-seltext_s = '>120Days'.
&nbsp; gt_fcat-seltext_m = '>120 Days'.
&nbsp; gt_fcat-seltext_l = '>120 Days'.
&nbsp; gt_fcat-outputlen = 30.
&nbsp; gt_fcat-col_pos = lv_count.
&nbsp; lv_count = lv_count + 1.
&nbsp; APPEND gt_fcat.
ENDFORM.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " build_fieldcat
\*&---------------------------------------------------------------------\*
\*&&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Form&nbsp; display_alv
\*&---------------------------------------------------------------------\*
\*&nbsp;&nbsp;&nbsp; Display out in ALV
\*----------------------------------------------------------------------\*
FORM display_alv .
&nbsp; gs_layout-zebra = 'X'.
&nbsp; PERFORM create_event USING events\[\].
&nbsp; CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
&nbsp;&nbsp;&nbsp; EXPORTING
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_callback_program = gv_repname
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_structure_name&nbsp;&nbsp; = 'IT_FINAL'
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is_layout&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = gs_layout
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_fieldcat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = gt_fcat\[\]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_events&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = events\[\]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_default&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 'X'
&nbsp;&nbsp;&nbsp; TABLES
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t_outtab&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = it_final
&nbsp;&nbsp;&nbsp; EXCEPTIONS
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; program_error&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OTHERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 2.
&nbsp; IF sy-subrc <> 0.
&nbsp;&nbsp;&nbsp; MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
&nbsp; ENDIF.
ENDFORM.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " display_alv
\*&---------------------------------------------------------------------\*
\*&&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Form&nbsp; create_event
\*&---------------------------------------------------------------------\*
FORM create_event USING p_events TYPE slis_t_event.
&nbsp; DATA: ls_event TYPE slis_alv_event.
&nbsp; CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
&nbsp;&nbsp;&nbsp; EXPORTING
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_list_type = 0
&nbsp;&nbsp;&nbsp; IMPORTING
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; et_events&nbsp;&nbsp; = p_events.
&nbsp; READ TABLE p_events WITH KEY name = slis_ev_top_of_page
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INTO ls_event.
&nbsp; IF sy-subrc = 0.
&nbsp;&nbsp;&nbsp; MOVE formname_top_of_page TO ls_event-form.
&nbsp;&nbsp;&nbsp; APPEND ls_event TO p_events.
&nbsp; ENDIF.
ENDFORM.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "create_event
\*&*********************************************************************\*
\*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; To display TOP_OF_PAGE.
\***********************************************************************\*
FORM top_of_page.
&nbsp; DATA : text(70),txtdt(80),txtinfo(40).
&nbsp; CLEAR l_string.
&nbsp; l_string = 'Account Receivable Aging Report'(hd2).
&nbsp; wa_header-typ&nbsp; = 'H'.
&nbsp; wa_header-info = l_string.
&nbsp; APPEND wa_header TO heading.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " index 1.
&nbsp; CLEAR l_string.
&nbsp; wa_header-typ&nbsp; = 'S'.
&nbsp; WRITE : 'Date&nbsp; :' TO txtdt,sy-datum TO txtdt+20 DD/MM/YY.
&nbsp; WRITE sy-datum TO dat DD/MM/YYYY.
&nbsp; wa_header-info = txtdt.
&nbsp; APPEND wa_header TO heading.
&nbsp; IF ( s_kunnr-low = ' ' AND s_kunnr-high = ' '&nbsp; ) .
&nbsp;&nbsp;&nbsp; CLEAR txtdt.
&nbsp;&nbsp;&nbsp; wa_header-typ = 'S'.
&nbsp;&nbsp;&nbsp; txtinfo = 'All Customers '.
&nbsp;&nbsp;&nbsp; WRITE : text-004 TO txtdt,txtinfo TO txtdt+20.
&nbsp;&nbsp;&nbsp; wa_header-info = txtdt.
&nbsp;&nbsp;&nbsp; APPEND wa_header TO heading.
&nbsp; ELSEIF ( s_kunnr-high = ' ' AND s_kunnr-low <> ' ' ).
&nbsp;&nbsp;&nbsp; CLEAR txtdt.
&nbsp;&nbsp;&nbsp; wa_header-typ = 'S'.
&nbsp;&nbsp;&nbsp; txtinfo = s_kunnr-low.
&nbsp;&nbsp;&nbsp; WRITE : text-004 TO txtdt,txtinfo TO txtdt+20.
&nbsp;&nbsp;&nbsp; wa_header-info = txtdt.
&nbsp;&nbsp;&nbsp; APPEND wa_header TO heading.
&nbsp; ELSEIF ( s_kunnr-high <> ' ' AND s_kunnr-low <> ' ' ).
&nbsp;&nbsp;&nbsp; CLEAR txtdt.
&nbsp;&nbsp;&nbsp; wa_header-typ = 'S'.
&nbsp;&nbsp;&nbsp; CONCATENATE s_kunnr-low '-' s_kunnr-high INTO txtinfo SEPARATED BY space.
&nbsp;&nbsp;&nbsp; WRITE : text-004 TO txtdt,txtinfo TO txtdt+20.
&nbsp;&nbsp;&nbsp; wa_header-info = txtdt.
&nbsp;&nbsp;&nbsp; APPEND wa_header TO heading.
&nbsp; ENDIF.
&nbsp; IF ( s_bukrs-low = ' ' AND s_bukrs-high = ' ' ) .
&nbsp;&nbsp;&nbsp; CLEAR txtdt.
&nbsp;&nbsp;&nbsp; wa_header-typ = 'S'.
&nbsp;&nbsp;&nbsp; txtinfo = 'All Company Code'.
&nbsp;&nbsp;&nbsp; WRITE : text-005 TO txtdt,txtinfo TO txtdt+20.
&nbsp;&nbsp;&nbsp; wa_header-info = txtdt.
&nbsp;&nbsp;&nbsp; APPEND wa_header TO heading.
&nbsp; ELSEIF ( s_bukrs-low <> ' ' AND s_bukrs-high = ' ' ).
&nbsp;&nbsp;&nbsp; CLEAR txtdt.
&nbsp;&nbsp;&nbsp; wa_header-typ = 'S'.
&nbsp;&nbsp;&nbsp; txtinfo = s_bukrs-low .
&nbsp;&nbsp;&nbsp; WRITE : text-005 TO txtdt,txtinfo TO txtdt+20.
&nbsp;&nbsp;&nbsp; wa_header-info = txtdt.
&nbsp;&nbsp;&nbsp; APPEND wa_header TO heading.
&nbsp; ELSEIF ( s_bukrs-low <> ' ' AND s_bukrs-high <> ' ' ) .
&nbsp;&nbsp;&nbsp; CLEAR txtdt.
&nbsp;&nbsp;&nbsp; wa_header-typ = 'S'.
&nbsp;&nbsp;&nbsp; CONCATENATE s_bukrs-low '-' s_bukrs-high INTO txtinfo SEPARATED BY space.
&nbsp;&nbsp;&nbsp; WRITE : text-005 TO txtdt,txtinfo TO txtdt+20.
&nbsp;&nbsp;&nbsp; wa_header-info = txtdt.
&nbsp;&nbsp;&nbsp; APPEND wa_header TO heading.
&nbsp; ENDIF.
&nbsp; CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
&nbsp;&nbsp;&nbsp; EXPORTING
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_logo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 'ENJOYSAP_LOGO'
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_list_commentary = heading.
&nbsp; CLEAR heading.
ENDFORM.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "top_of_page
  • No labels