Skip to Content
0
Former Member
Apr 07, 2013 at 10:19 AM

Vendor Ageing Report

50 Views

Hi,

This is a vendor ageing report which is running fine. But the issue is that in the output its not showing 1-30 (DIF1) column. Did not get where I am lacking.😕

report zrough.

TABLES : bsik, BAPIFVDEXP_VZZBEPP.

DATA : t_bsik LIKE bsik OCCURS 0 WITH HEADER LINE,

t_bsak LIKE bsak OCCURS 0 WITH HEADER LINE,

days like BAPIFVDEXP_VZZBEPP-NUM4.

DATA : BEGIN OF t_lfa1 OCCURS 0,

lifnr LIKE lfa1-lifnr,

name1 LIKE lfa1-name1,

adrnr LIKE lfa1-adrnr,

END OF t_lfa1.

DATA : BEGIN OF t_adrc OCCURS 0,

adrnr LIKE lfa1-adrnr,

street LIKE adrc-street,

city1 LIKE adrc-city1,

END OF t_adrc.

DATA : BEGIN OF t_BSEG OCCURS 0,

zfbdt LIKE BSEG-zfbdt,

KOART LIKE BSEG-KOART,

KOSTL LIKE BSEG-KOSTL,

PROJK LIKE BSEG-PROJK,

END OF t_BSEG.

DATA : BEGIN OF t_prps OCCURS 0,

POSID like prps-posid,

OBJNR like prps-objnr,

END OF t_prps.

DATA : T_KOSTL LIKE BSEG-KOSTL,

T_PROJK LIKE BSEG-PROJK,

TEXT(15).

DATA : BEGIN OF t_output OCCURS 0,

lifnr LIKE lfa1-lifnr,

name1 LIKE lfa1-name1,

street LIKE adrc-street,

city1 LIKE adrc-city1,

OBJNR LIKE prps-OBJNR,

posid LIKE prps-posid,

KOSTL LIKE BSIK-KOSTL, " COST CENTER

UMSKZ like bsik-UMSKZ,

belnr like bsik-belnr,

bukrs like bsik-bukrs,

gjahr like bsik-gjahr,

wrbtr like bsik-wrbtr,

hkont like bsik-hkont,

dif1 like bsik-wrbtr,

dif2 like bsik-wrbtr,

dif3 like bsik-wrbtr,

dif4 like bsik-wrbtr,

dif5 like bsik-wrbtr,

days like BAPIFVDEXP_VZZBEPP-NUM4,

END OF t_output.

* Alv data declaration

TYPE-POOLS : slis.

DATA :alv_fieldcat TYPE slis_t_fieldcat_alv,

alv_fieldcat_line LIKE LINE OF alv_fieldcat,

alv_sort TYPE slis_t_sortinfo_alv,

alv_sort_line LIKE LINE OF alv_sort,

alv_layout TYPE slis_layout_alv,

g_repid LIKE sy-repid VALUE sy-repid,

alv_status_set TYPE slis_formname VALUE 'ALV_STATUS_SET',

alv_user_comm TYPE slis_formname VALUE 'ALV_USER_COMM',

grid_title TYPE lvc_title,

alv_fieldcat_acty TYPE slis_t_fieldcat_alv,

g_save,

gs_variant LIKE disvariant,

g_exit_caused_by_caller TYPE c,

gs_exit_caused_by_user TYPE slis_exit_by_user.

DATA: alv_fieldcat_line_acty LIKE LINE OF alv_fieldcat_acty,

alv_layout_acty TYPE slis_layout_alv,

gt_list_top_of_page TYPE slis_t_listheader,

gt_events TYPE slis_t_event,

message TYPE string,

r_ucomm LIKE sy-ucomm,

rs_selfield TYPE slis_selfield.

CONSTANTS:

gc_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS : s_bukrs FOR bsik-bukrs,

s_gjahr FOR bsik-gjahr,

s_lifnr FOR bsik-lifnr,

s_umskz FOR bsik-umskz.

parameters : p_budat like bsik-budat OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

SELECT-OPTIONS : s_date1 FOR BAPIFVDEXP_VZZBEPP-NUM4 NO-EXTENSION

OBLIGATORY

DEFAULT 1 TO 30,

s_date2 FOR BAPIFVDEXP_VZZBEPP-NUM4 NO-EXTENSION

OBLIGATORY

DEFAULT 30 TO 60,

s_date3 FOR BAPIFVDEXP_VZZBEPP-NUM4 NO-EXTENSION

OBLIGATORY

DEFAULT 60 TO 90,

s_date4 FOR BAPIFVDEXP_VZZBEPP-NUM4 NO-EXTENSION

OBLIGATORY

DEFAULT 90 TO 120,

s_date5 FOR BAPIFVDEXP_VZZBEPP-NUM4 NO-EXTENSION

OBLIGATORY

DEFAULT 120 TO 150.

SELECTION-SCREEN END OF BLOCK b2.

INITIALIZATION.

START-OF-SELECTION.

*break-point.

PERFORM fetch_data.

PERFORM display.

*&---------------------------------------------------------------------*

*& Form fetch_data

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM fetch_data .

SELECT *

INTO TABLE t_bsik

FROM bsik

WHERE bukrs IN s_bukrs

AND gjahr IN s_gjahr

AND lifnr IN s_lifnr

AND umskz IN s_umskz

AND umskz NOT IN ('F','P','L','G').

* AND zfbdt <= P_augdt.

if sy-subrc = 0.

SELECT *

INTO TABLE t_bsak

FROM bsak

WHERE bukrs IN s_bukrs

AND gjahr IN s_gjahr

AND lifnr IN s_lifnr

AND umskz IN s_umskz

AND umskz NOT IN ('F','P','L','G')

AND budat > P_budat.

loop at t_bsak.

move-corresponding t_bsak to t_bsik.

append t_bsik.

endloop.

loop at t_bsik.

if t_bsik-zfbdt is initial.

t_bsik-zfbdt = t_bsik-bldat.

modify t_bsik transporting zfbdt.

endif.

if t_bsik-zfbdt > P_budat.

delete t_bsik.

endif.

* if t_bsik-umskz > P_.

endloop.

select lifnr

name1

adrnr

into table t_lfa1

from lfa1

for all entries in t_bsik

where lifnr = t_bsik-lifnr.

if sy-subrc = 0.

select ADDRNUMBER as adrnr

street

city1

into table t_adrc

from adrc

for all entries in t_lfa1

where ADDRNUMBER = t_lfa1-adrnr.

endif.

endif.

LOOP AT t_bsik.

if t_bsik-shkzg = 'S'.

t_bsik-WRBTR = t_bsik-WRBTR * -1.

endif.

REFRESH T_BSEG.

CLEAR : T_KOSTL, T_PROJK, t_output.

IF t_bsik-rebzg IS NOT INITIAL.

SELECT zfbdt

KOART

KOSTL

PROJK

INTO TABLE T_BSEG "t_bsik-ZFBDT

FROM bseg

WHERE bukrs = t_bsik-bukrs

AND belnr = t_bsik-rebzg

AND gjahr = t_bsik-rebzj

and KOART IN ('K','S').

LOOP AT T_BSEG.

IF T_BSEG-KOART = 'K' AND T_BSEG-zfbdt IS NOT INITIAL.

t_bsik-ZFBDT = T_BSEG-ZFBDT.

MODIFY t_bsik TRANSPORTING ZFBDT.

ELSEIF T_BSEG-KOART = 'S'.

T_KOSTL = T_BSEG-KOSTL.

T_PROJK = T_BSEG-PROJK.

ENDIF.

ENDLOOP.

ELSE.

SELECT SINGLE KOSTL PROJK

INTO (T_KOSTL, T_PROJK)

FROM bseg

WHERE bukrs = t_bsik-bukrs

AND belnr = t_bsik-BELNR

AND gjahr = t_bsik-GJAHR

and KOART = 'S'.

ENDIF.

MOVE-CORRESPONDING t_bsik TO t_output.

t_output-KOSTL = T_KOSTL.

CONCATENATE 'PR' T_PROJK INTO T_OUTPUT-OBJNR.

days = P_budat - t_bsik-ZFBDT.

READ TABLE t_lfa1 WITH KEY lifnr = t_output-LIFNR.

IF SY-SUBRC = 0.

t_output-NAME1 = t_lfa1-NAME1.

READ TABLE t_adrc WITH KEY ADRNR = t_lfa1-ADRNR.

IF SY-SUBRC = 0.

t_output-street = t_adrc-STREET.

t_output-city1 = t_adrc-CITY1.

ENDIF.

ENDIF.

t_output-days = days.

if days >= s_date1-low and days < s_date1-high.

t_output-dif1 = t_bsik-wrbtr. " days.

elseif days >= s_date2-low and days < s_date2-high.

t_output-dif2 = t_bsik-wrbtr. "days.

elseif days >= s_date3-low and days < s_date3-high.

t_output-dif3 = t_bsik-wrbtr. "days.

elseif days >= s_date4-low and days < s_date4-high.

t_output-dif4 = t_bsik-wrbtr. "days.

elseif days >= s_date5-low and days < s_date5-high.

t_output-dif5 = t_bsik-wrbtr. "days.

endif.

append t_output.

ENDLOOP.

if T_OUTPUT[] is not initial.

SELECT POSID

OBJNR

INTO TABLE T_PRPS

FROM PRPS

FOR ALL ENTRIES IN T_OUTPUT

WHERE OBJNR = T_OUTPUT-OBJNR.

endif.

LOOP AT T_OUTPUT.

read table T_PRPS with key objnr = T_OUTPUT-objnr.

if sy-subrc = 0.

T_OUTPUT-POSID = T_PRPS-POSID.

MODIFY t_output TRANSPORTING POSID.

endif.

ENDLOOP.

ENDFORM. " fetch_data

*&---------------------------------------------------------------------*

*& Form display

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM display .

PERFORM build_alv_layout.

PERFORM s_sort_build USING alv_sort[].

PERFORM build_field_catalogs.

PERFORM eventtab_build CHANGING gt_events.

* SORT t_output BY .

g_save = 'A'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_repid

i_callback_pf_status_set = alv_status_set

i_callback_user_command = alv_user_comm

i_grid_title = grid_title

i_save = g_save

is_variant = gs_variant

is_layout = alv_layout

it_fieldcat = alv_fieldcat[]

it_events = gt_events[]

it_sort = alv_sort[]

IMPORTING

e_exit_caused_by_caller = g_exit_caused_by_caller

es_exit_caused_by_user = gs_exit_caused_by_user

TABLES

t_outtab = t_output.

PERFORM alv_user_comm USING r_ucomm

rs_selfield.

IF sy-subrc = 0.

IF g_exit_caused_by_caller = 'X'.

ELSE.

IF gs_exit_caused_by_user-back = 'X'. " F3

ELSE.

IF gs_exit_caused_by_user-exit = 'X'. " F15

ELSE.

IF gs_exit_caused_by_user-cancel = 'X'. " F12

ELSE.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ELSE.

*" Fatal error calling ALV

ENDIF.

ENDFORM. " display

*&---------------------------------------------------------------------*

*& Form build_alv_layout

*&---------------------------------------------------------------------*

FORM build_alv_layout.

CLEAR alv_layout.

alv_layout-colwidth_optimize = 'X'. "always display full columns

* alv_layout-box_fieldname = 'CHK'.

* alv_layout-box_tabname = 'T_OUTPUT'.

alv_layout-info_fieldname = 'COLOR'. "color a line

alv_layout-detail_popup = 'X'.

alv_layout-zebra = 'X'. "Zebra output

ENDFORM. " build_alv_layout

*---------------------------------------------------------------------*

* FORM s_sort_build *

*---------------------------------------------------------------------*

* ........ *

*---------------------------------------------------------------------*

* --> LT_SORT *

*---------------------------------------------------------------------*

FORM s_sort_build USING lt_sort TYPE slis_t_sortinfo_alv.

DATA: ls_sort TYPE slis_sortinfo_alv.

CLEAR ls_sort.

ls_sort-spos = 1.

ls_sort-fieldname = 'LIFNR'.

ls_sort-up = 'X'.

ls_sort-group = 'UL'.

ls_sort-subtot = 'X'.

APPEND ls_sort TO lt_sort.

CLEAR ls_sort.

ls_sort-spos = 2.

ls_sort-fieldname = 'BELNR'.

ls_sort-up = 'X'.

ls_sort-subtot = 'X'.

ls_sort-group = 'UL'.

APPEND ls_sort TO lt_sort.

CLEAR ls_sort.

ENDFORM. "s_sort_build

*&---------------------------------------------------------------------*

*& Form eventtab_build

*&---------------------------------------------------------------------*

FORM eventtab_build CHANGING lt_events TYPE slis_t_event.

FIELD-SYMBOLS: <lt_events> LIKE LINE OF lt_events.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = lt_events

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

* Define TOP_OF_PAGE event

READ TABLE lt_events WITH KEY name = slis_ev_top_of_page

ASSIGNING <lt_events>.

IF sy-subrc EQ 0.

MOVE gc_formname_top_of_page TO <lt_events>-form.

ENDIF.

ENDFORM. " eventtab_build

*&---------------------------------------------------------------------*

*& Form TOP_OF_PAGE

*&---------------------------------------------------------------------*

FORM top_of_page.

REFRESH gt_list_top_of_page.

CLEAR gt_list_top_of_page.

PERFORM comment_build USING gt_list_top_of_page.

* Output GSPC logo on report header

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_list_top_of_page

i_logo = 'GSPC_LOGO'.

ENDFORM. "top_of_page

*&---------------------------------------------------------------------*

*& Form COMMENT_BUILD

*&---------------------------------------------------------------------*

* Build comments at top of page

*----------------------------------------------------------------------*

FORM comment_build CHANGING gt_top_of_page TYPE slis_t_listheader.

DATA: gs_line TYPE slis_listheader.

CLEAR gs_line.

gs_line-typ = 'H'.

gs_line-info = 'Vendor Ageing'.

APPEND gs_line TO gt_top_of_page.

CLEAR gs_line.

gs_line-typ = 'S'.

gs_line-key = 'Report ID:'.

gs_line-info = sy-repid.

APPEND gs_line TO gt_top_of_page.

CLEAR gs_line.

gs_line-typ = 'S'.

gs_line-key = 'User:'.

gs_line-info = sy-uname.

APPEND gs_line TO gt_top_of_page.

CLEAR gs_line.

gs_line-typ = 'S'.

gs_line-key = 'Date:'.

WRITE sy-datum TO gs_line-info MM/DD/YYYY.

APPEND gs_line TO gt_top_of_page.

CLEAR gs_line.

gs_line-typ = 'S'.

gs_line-key = 'Time:'.

WRITE sy-uzeit TO gs_line-info USING EDIT MASK '__:__:__'.

APPEND gs_line TO gt_top_of_page.

CLEAR gs_line.

gs_line-typ = 'S'.

gs_line-key = ''.

WRITE ' '.

APPEND gs_line TO gt_top_of_page.

* Output data from selection screen

ENDFORM. "comment_build

*----------------------------------------------------------------------*

*Build ALV Summary field catalog

*----------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*& Form build_field_catalogs

*&---------------------------------------------------------------------*

FORM build_field_catalogs.

CLEAR: alv_fieldcat.

REFRESH: alv_fieldcat.

* Vendor Number

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = 'Vendor Number'.

* alv_fieldcat_line-hotspot = 'X'.

alv_fieldcat_line-fieldname = 'LIFNR'.

APPEND alv_fieldcat_line TO alv_fieldcat.

CLEAR alv_fieldcat_line.

* Vendor Name

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = 'Vendor Name'.

alv_fieldcat_line-fieldname = 'NAME1'.

APPEND alv_fieldcat_line TO alv_fieldcat.

CLEAR alv_fieldcat_line.

* Vendor Address

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = 'Vendor Address'.

alv_fieldcat_line-fieldname = 'STREET'.

APPEND alv_fieldcat_line TO alv_fieldcat.

CLEAR alv_fieldcat_line.

* City

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = 'City'.

alv_fieldcat_line-fieldname = 'CITY1'.

APPEND alv_fieldcat_line TO alv_fieldcat.

CLEAR alv_fieldcat_line.

* Object number #

* alv_fieldcat_line-tabname = 'T_OUTPUT'.

* alv_fieldcat_line-seltext_l = 'object #'.

* alv_fieldcat_line-fieldname = 'OBJNR'.

* alv_fieldcat_line-no_out = 'X'.

* APPEND alv_fieldcat_line TO alv_fieldcat.

* CLEAR alv_fieldcat_line.

* WBS Element

* alv_fieldcat_line-tabname = 'T_OUTPUT'.

* alv_fieldcat_line-seltext_l = 'WBS Element'.

* alv_fieldcat_line-fieldname = 'POSID'.

* APPEND alv_fieldcat_line TO alv_fieldcat.

* Cost Center

* alv_fieldcat_line-tabname = 'T_OUTPUT'.

* alv_fieldcat_line-seltext_l = 'Cost Center'.

* alv_fieldcat_line-fieldname = 'KOSTL'.

* APPEND alv_fieldcat_line TO alv_fieldcat.

* GL Indicator

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = 'GL Indicator'.

alv_fieldcat_line-fieldname = 'UMSKZ'.

APPEND alv_fieldcat_line TO alv_fieldcat.

CLEAR alv_fieldcat_line.

* General Ledger Account

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = 'General Ledger Account'.

alv_fieldcat_line-fieldname = 'HKONT'.

APPEND alv_fieldcat_line TO alv_fieldcat.

* Document No.

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-hotspot = 'X'.

alv_fieldcat_line-seltext_l = 'Document No.'.

alv_fieldcat_line-fieldname = 'BELNR'.

APPEND alv_fieldcat_line TO alv_fieldcat.

CLEAR alv_fieldcat_line.

* Amount

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = 'Amount'.

alv_fieldcat_line-fieldname = 'WRBTR'.

alv_fieldcat_line-no_out = 'X'.

APPEND alv_fieldcat_line TO alv_fieldcat.

* dif1

CLEAR TEXT.

READ TABLE s_date1 INDEX 1.

CONCATENATE 'DAYS ' s_date1-LOW '-' s_date1-HIGH INTO TEXT.

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = TEXT.

alv_fieldcat_line-fieldname = 'DIF1'.

alv_fieldcat_line-do_sum = 'X'.

APPEND alv_fieldcat_line TO alv_fieldcat.

CLEAR alv_fieldcat_line.

* dif2

CLEAR TEXT.

READ TABLE s_date2 INDEX 1.

CONCATENATE 'DAYS ' s_date2-LOW '-' s_date2-HIGH INTO TEXT.

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = TEXT.

* alv_fieldcat_line-no_out = 'X'.

alv_fieldcat_line-fieldname = 'DIF2'.

APPEND alv_fieldcat_line TO alv_fieldcat.

CLEAR alv_fieldcat_line.

* dif3

CLEAR TEXT.

READ TABLE s_date3 INDEX 1.

CONCATENATE 'DAYS ' s_date3-LOW '-' s_date3-HIGH INTO TEXT.

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = TEXT.

alv_fieldcat_line-fieldname = 'DIF3'.

APPEND alv_fieldcat_line TO alv_fieldcat.

CLEAR alv_fieldcat_line.

* dif4

CLEAR TEXT.

READ TABLE s_date4 INDEX 1.

CONCATENATE 'DAYS ' s_date4-LOW '-' s_date4-HIGH INTO TEXT.

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = TEXT.

alv_fieldcat_line-fieldname = 'DIF4'.

APPEND alv_fieldcat_line TO alv_fieldcat.

* dif5

CLEAR TEXT.

READ TABLE s_date5 INDEX 1.

CONCATENATE 'DAYS ' s_date5-LOW '-' s_date5-HIGH INTO TEXT.

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = TEXT.

alv_fieldcat_line-fieldname = 'DIF5'.

APPEND alv_fieldcat_line TO alv_fieldcat.

* Days

alv_fieldcat_line-tabname = 'T_OUTPUT'.

alv_fieldcat_line-seltext_l = 'Days'.

alv_fieldcat_line-fieldname = 'DAYS'.

* alv_fieldcat_line-no_out = 'X'.

APPEND alv_fieldcat_line TO alv_fieldcat.

ENDFORM. " build_field_catalogs

*&---------------------------------------------------------------------*

*& Form ALV_USER_COMM

*&---------------------------------------------------------------------*

* Process User Status

*----------------------------------------------------------------------*

FORM alv_user_comm USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

*Determine the main component beign viewed

READ TABLE T_OUTPUT INDEX rs_selfield-tabindex.

CASE r_ucomm.

WHEN '&IC1'. " single / double click

CASE rs_selfield-fieldname.

* Display FI document

WHEN 'BELNR'.

SET PARAMETER ID 'BLN' FIELD T_OUTPUT-BELNR.

SET PARAMETER ID 'BUK' FIELD T_OUTPUT-BUKRS.

SET PARAMETER ID 'GJR' FIELD T_OUTPUT-GJAHR.

CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.

ENDCASE.

* WHEN 'FMB58'.

* SET PARAMETER ID 'MAT' FIELD prtab-matnr.

* CALL TRANSACTION 'MB58' AND SKIP FIRST SCREEN.

* WHEN 'CHK'.

* MOVE 'X' TO prtab-chk.

* MODIFY prtab INDEX rs_selfield-tabindex.

ENDCASE.

ENDFORM.

*&---------------------------------------------------------------------*

*& Form ALV_STATUS_SET

*&---------------------------------------------------------------------*

* Set the status for the ALV screen

*----------------------------------------------------------------------*

FORM alv_status_set USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.

ENDFORM.

Regards

Purnand