Zfi - Cust - Ageing Report
Zfi - Cust - Ageing Report
Zfi - Cust - Ageing Report
-----------------------------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Report ZFI_CUST_AGEING
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zfi_cust_ageing.
TYPE-POOLS: slis.
************************************************************************
*Types
************************************************************************
*Types
TYPES: BEGIN OF ty_adrc,
adrnr LIKE kna1-adrnr,
street LIKE adrc-street,
city1 LIKE adrc-city1,
region LIKE adrc-region,
END OF ty_adrc,
BEGIN OF ty_t005u,
spras LIKE t005u-spras,
land1 LIKE t005u-land1,
bland LIKE t005u-bland,
bezei LIKE t005u-bezei,
END OF ty_t005u,
BEGIN OF ty_j1iexcdtl,
exnum TYPE j_1iexcnum,
rdoc2 TYPE j_1irdoc2,
END OF ty_j1iexcdtl,
BEGIN OF ty_knav,
kunnr TYPE kunnr,
name1 TYPE name1_gp,
ort01 TYPE ort01_gp,
adrnr TYPE adrnr,
* bzirk TYPE bzirk,
END OF ty_knav,
BEGIN OF ty_bsidad,
bukrs TYPE bukrs,
kunnr TYPE kunnr,
augdt TYPE augdt,
augbl TYPE augbl,
gjahr TYPE gjahr,
belnr TYPE belnr_d,
budat TYPE budat,
bldat TYPE bldat,
blart TYPE blart,
shkzg TYPE shkzg,
dmbtr TYPE dmbtr,
zfbdt TYPE dzfbdt,
zterm TYPE dzterm,
zbd1t TYPE dzbd1t,
vbeln TYPE vbeln_vf,
END OF ty_bsidad,
BEGIN OF ty_vbrk,
vbeln TYPE vbeln,
fkdat TYPE fkdat,
END OF ty_vbrk,
BEGIN OF ty_output,
bukrs TYPE bukrs,
kunnr TYPE kunnr,
name1 TYPE name1,
gjahr TYPE gjahr,
zterm TYPE dzterm,
city TYPE ad_city1,
state TYPE bezei20,
budat TYPE budat,
vbeln TYPE vbeln,
bldat TYPE bldat,
duedate TYPE dzfbdt,
belnr TYPE belnr_d,
bzirk TYPE bzirk,
exnum TYPE j_1iexcnum,
day1 TYPE tfmatage,
dd TYPE i,
nd TYPE dmbtr, "Not Due
a_4 TYPE dmbtr,
a_7 TYPE dmbtr,
a_10 TYPE dmbtr,
a_15 TYPE dmbtr,
a_20 TYPE dmbtr,
a_30 TYPE dmbtr,
a_60 TYPE dmbtr,
a_90 TYPE dmbtr,
a_120 TYPE dmbtr,
a_150 TYPE dmbtr,
a_180 TYPE dmbtr,
a_210 TYPE dmbtr,
a_240 TYPE dmbtr,
a_275 TYPE dmbtr,
a_300 TYPE dmbtr,
a_330 TYPE dmbtr,
a_365 TYPE dmbtr,
a_366 TYPE dmbtr,
total TYPE dmbtr,
END OF ty_output.
*Workareas
DATA: gs_adrc TYPE ty_adrc,
gs_t005u TYPE ty_t005u,
gs_knav TYPE ty_knav,
gs_vbrk TYPE ty_vbrk,
gs_bskna1 TYPE ty_bsidad,
gs_bsexinv TYPE ty_bsidad,
gs_bsidad TYPE ty_bsidad,
gs_bsidtmp TYPE ty_bsidad,
gs_output TYPE ty_output,
gs_j1iexcdtl TYPE ty_j1iexcdtl.
*Internal tables
DATA: gt_adrc TYPE STANDARD TABLE OF ty_adrc,
gt_t005u TYPE STANDARD TABLE OF ty_t005u,
gt_knav TYPE STANDARD TABLE OF ty_knav,
gt_vbrk TYPE STANDARD TABLE OF ty_vbrk,
gt_bskna1 TYPE STANDARD TABLE OF ty_bsidad,
gt_bsexinv TYPE STANDARD TABLE OF ty_bsidad,
gt_bsidad TYPE STANDARD TABLE OF ty_bsidad,
gt_bsidtmp TYPE STANDARD TABLE OF ty_bsidad,
gt_output TYPE STANDARD TABLE OF ty_output,
gt_j1iexcdtl TYPE STANDARD TABLE OF ty_j1iexcdtl.
*Variables
DATA: gv_days TYPE tfmatage,
gv_1st_age(17) TYPE c,
gv_2nd_age(17) TYPE c,
gv_3rd_age(17) TYPE c,
gv_4th_age(17) TYPE c,
gv_5th_age(17) TYPE c,
gv_6th_age(18) TYPE c,
gv_7th_age(18) TYPE c,
gv_8th_age(18) TYPE c,
gv_9th_age(18) TYPE c,
gv_10th_age(18) TYPE c,
gv_11th_age(18) TYPE c,
gv_12th_age(18) TYPE c,
gv_13th_age(18) TYPE c,
gv_14th_age(18) TYPE c,
gv_15th_age(18) TYPE c,
gv_16th_age(18) TYPE c,
gv_17th_age(18) TYPE c,
gv_18th_age(18) TYPE c.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
*Start Of Selection
START-OF-SELECTION.
SELECT bukrs kunnr augdt augbl gjahr belnr budat bldat blart shkzg dmbtr
zfbdt zterm zbd1t vbeln
FROM bsad
APPENDING TABLE gt_bsidad
WHERE kunnr IN s_kunnr AND
augdt GT s_bldat-low AND
budat LE s_bldat-low AND
bldat LE s_bldat-low.
IF sy-subrc EQ 0.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
IF sy-subrc = 0.
ENDIF.
ENDIF.
gs_output-budat = gs_vbrk-fkdat.
ENDIF.
ENDIF.
gs_output-name1 = gs_knav-name1.
* gs_output-bzirk = gs_knav-bzirk.
*Retrieve City
gs_output-city = gs_adrc-city1.
*Retrieve State
gs_output-state = gs_t005u-bezei.
ENDIF.
ENDIF.
ENDIF.
* READ TABLE gt_j1iexcdtl INTO gs_j1iexcdtl WITH KEY rdoc2 = gs_output-
vbeln.
* IF sy-subrc EQ 0.
*
**Retrieve Excise Number
* gs_output-exnum = gs_j1iexcdtl-exnum.
*
* ENDIF.
IF p_docdat = 'X'.
ENDIF.
* ENDIF.
ENDIF.
IF gs_bsidad-shkzg = 'H'.
ENDIF.
IF gv_days GT p_aged17.
ENDLOOP.
*&------------Form BUILD
FORM build.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'KUNNR'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = 'Customer Code'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-no_zero = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'NAME1'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = 'Customer Name'.
fieldcat_ln-no_zero = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'VBELN'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = 'Invoice No'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-no_zero = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'BUDAT'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = 'Invoice date'.
fieldcat_ln-no_zero = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'BELNR'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = 'Doc No'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-no_zero = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'BLDAT'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = 'Doc. Date'.
fieldcat_ln-no_zero = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
* CLEAR fieldcat_ln.
* fieldcat_ln-fieldname = 'EXNUM'.
* fieldcat_ln-tabname = 'gt_output'.
* fieldcat_ln-seltext_l = 'Ex. Invoice no'.
* fieldcat_ln-no_zero = 'X'.
* APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'DUEDATE'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = 'Due Date'.
fieldcat_ln-no_zero = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'ZTERM'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = 'Payment Terms'.
fieldcat_ln-no_zero = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'CITY'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = 'CITY'.
fieldcat_ln-no_zero = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'STATE'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = 'STATE'.
fieldcat_ln-no_zero = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
* CLEAR fieldcat_ln.
* fieldcat_ln-fieldname = 'BZIRK'.
* fieldcat_ln-tabname = 'gt_output'.
* fieldcat_ln-seltext_l = 'ZONE'.
* fieldcat_ln-no_zero = 'X'.
* APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'ND'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = 'Not Due'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_4'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '0 - 4'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_7'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '4 - 7'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_10'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '7 - 10'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_15'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '10 - 15'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_20'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '15 - 20'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_30'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '20 - 30'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_60'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '30 - 60'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_90'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '60 - 90'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_120'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '90 - 120'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_150'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '120 - 150'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_180'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '150 - 180'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_210'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '180 - 210'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_240'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '210 - 240'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_275'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '240 - 275'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_300'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '275 - 300'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_330'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '300 - 330'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_365'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '330 - 365'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'A_366'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = '> 365'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'TOTAL'.
fieldcat_ln-tabname = 'gt_output'.
fieldcat_ln-seltext_l = 'OUTSTANDING AMT'.
fieldcat_ln-no_zero = 'X'.
fieldcat_ln-do_sum = 'X'.
APPEND fieldcat_ln TO gt_fieldcat.
g_repid = sy-repid.
gs_variant-report = g_repid.
g_save = 'A'.
ENDFORM. "BUILD
*&---------------Form CALL_ALV
DATA t_layout TYPE slis_layout_alv.
*&---------------------------------------------------------------------*
*& Form CALL_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM call_alv.
ENDFORM. "CALL_ALV
*& Form GET_EVENTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_events .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
*&---------------------------------------------------------------------*
*& Form sub_comment_build
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LIST_TOP_OF_PAGE text
*----------------------------------------------------------------------*
FORM sub_comment_build USING i_top_of_page TYPE slis_t_listheader.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = 'MK Agrotech Limited'.
APPEND ls_line TO i_top_of_page.
ls_line-typ = 'H'.
ls_line-info = 'Customer Ageing'.
APPEND ls_line TO i_top_of_page.
ls_line-typ = 'S'.
ls_line-info = l_list.
APPEND ls_line TO i_top_of_page.
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM top_of_page.
ENDFORM. "TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form ALV_USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_user_command USING in_ucomm LIKE sy-ucomm
in_selfield TYPE slis_selfield.
IF in_ucomm = '&IC1'.
READ TABLE gt_output INTO gs_output INDEX in_selfield-tabindex.
CASE in_selfield-fieldname.
WHEN 'KUNNR'.
ENDIF.
WHEN 'VBELN'.
ENDIF.
WHEN 'BELNR'.
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDIF.
ENDFORM.