Skip to Content
0
Sep 10, 2007 at 07:08 AM

Error

16 Views

Hi all,

I got run time error from this program, pls verify its urgrent.

Thanks

siva

REPORT zfi_monthly_os_re NO STANDARD PAGE HEADING.

************************************************************************

  • TABLES *

************************************************************************

TABLES: bkpf,

vbak,

vbfa,

bsid,

t009b,

bsad.

************************************************************************

  • Data Declaration *

************************************************************************

DATA: it_bkpf LIKE bkpf OCCURS 0 WITH HEADER LINE.

DATA: it_bsid1 LIKE bsid OCCURS 0 WITH HEADER LINE.

DATA: it_prps LIKE prps OCCURS 0 WITH HEADER LINE.

DATA: it_vbap LIKE vbap OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF it_vbak OCCURS 0,

ps_psp_pnr TYPE ps_psp_pnr,

kunnr TYPE kunnr,

vbeln TYPE vbak-vbeln,

END OF it_vbak.

DATA: BEGIN OF it_disp OCCURS 0,

ps_psp_pnr TYPE vbak-ps_psp_pnr,

amt1 LIKE bsad-dmbtr,

amt2 LIKE bsad-dmbtr,

amt3 LIKE bsad-dmbtr,

amt4 LIKE bsad-dmbtr,

amt5 LIKE bsad-dmbtr,

amt6 LIKE bsad-dmbtr,

coll TYPE p DECIMALS 4,

END OF it_disp.

DATA: BEGIN OF it_wa ,

ps_psp_pnr TYPE vbak-ps_psp_pnr,

amt1 LIKE bsad-dmbtr,

amt2 LIKE bsad-dmbtr,

amt3 LIKE bsad-dmbtr,

amt4 LIKE bsad-dmbtr,

amt5 LIKE bsad-dmbtr,

amt6 LIKE bsad-dmbtr,

coll TYPE p DECIMALS 4,

END OF it_wa.

DATA: BEGIN OF it_bsid OCCURS 0,

zterm TYPE bsid-zterm,

kunnr TYPE bsid-kunnr,

dmbtr TYPE bsid-dmbtr,

monat TYPE bsid-monat,

gjahr TYPE bsid-gjahr,

vbeln LIKE bsid-vbeln,

END OF it_bsid.

DATA: BEGIN OF it_bsad OCCURS 0,

zterm TYPE bsad-zterm,

kunnr TYPE bsad-kunnr,

dmbtr TYPE bsad-dmbtr,

monat TYPE bsad-monat,

gjahr TYPE bsad-gjahr,

vbeln LIKE bsad-vbeln,

END OF it_bsad.

DATA: g_first_day LIKE sy-datum,

g_past_day LIKE sy-datum,

g_year LIKE bsid-gjahr,

g_period LIKE bsid-monat.

DATA: v_date(10) TYPE c.

DATA: v_date1 LIKE sy-datum.

DATA v_days(10) TYPE n.

DATA: i_yy LIKE bkpf-gjahr.

DATA: i_mm LIKE t009b-poper.

DATA: g_first(2) TYPE c.

DATA: xt001 TYPE t001.

DATA: w_curry LIKE bkpf-gjahr ,

w_currm LIKE bkpf-monat.

***********************************************************

  • ALV Declaration

***********************************************************

TYPE-POOLS: slis.

DATA:st_layout TYPE slis_layout_alv,

it_fieldcat TYPE slis_t_fieldcat_alv,

it_listheader TYPE slis_t_listheader,

it_event TYPE slis_t_event,

keyinfo TYPE slis_keyinfo_alv.

DATA:ls_selfield TYPE slis_selfield.

DATA: v_repid LIKE sy-repid.

*****************************************************************

  • Selection Screen

*****************************************************************

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

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-000.

SELECT-OPTIONS: s_proj FOR vbak-ps_psp_pnr . "Project

SELECT-OPTIONS: s_year FOR bkpf-gjahr . "Fiscal year

SELECT-OPTIONS: s_period FOR t009b-poper. "Period

SELECTION-SCREEN: END OF BLOCK b.

SELECTION-SCREEN: END OF BLOCK a.

*****************************************************************

  • TOP OF PAGE.

****************************************************************

*TOP-OF-PAGE.

*****************************************************************

  • Initialazation

*****************************************************************

v_repid = sy-repid.

*****************************************************************

  • Start-of-selection

*****************************************************************

START-OF-SELECTION.

PERFORM get_fiscalyear.

PERFORM get_bsid.

PERFORM disp .

PERFORM fill_layout_structure.

PERFORM fill_field_catalog_table.

PERFORM get_event USING it_event.

PERFORM fill_listheader USING it_listheader.

PERFORM call_alv_function.

END-OF-SELECTION.

&----


*& Form get_fiscalyear

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_fiscalyear .

IF NOT s_year IS INITIAL AND s_period IS NOT INITIAL.

PERFORM given_date.

ELSE.

PERFORM system_date.

ENDIF.

ENDFORM. " get_fiscalyear

&----


*& Form given_date

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM given_date .

i_yy = s_year-low.

i_mm = s_period-low.

PERFORM get_date.

PERFORM get_past6month.

ENDFORM. " given_date

&----


*& Form system_date

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM system_date .

PERFORM get_current USING sy-datum.

ENDFORM. " system_date

&----


*& Form get_current

&----


  • text

----


  • -->P_G_FIRST_DAY text

----


FORM get_current USING p_g_first_day.

CALL FUNCTION 'FTI_FISCAL_YEAR_MONTH_GET'

EXPORTING

i_bukrs = '1000'

i_budat = p_g_first_day "FTIS_DATUM-INITIAL

IMPORTING

e_gjahr = w_curry

e_monat = w_currm.

CONCATENATE w_curry w_currm '01' INTO g_first_day.

PERFORM get_past6month.

ENDFORM. " get_current

&----


*& Form get_date

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_date .

SELECT SINGLE * INTO xt001 FROM t001

WHERE bukrs = '1000'. "< Your company code

CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'

EXPORTING

i_gjahr = i_yy

i_periv = xt001-periv

i_poper = i_mm

IMPORTING

e_date = g_first_day.

ENDFORM. " get_date

&----


*& Form get_past6month

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_past6month .

CALL FUNCTION 'CCM_GO_BACK_MONTHS'

EXPORTING

currdate = g_first_day

backmonths = 6

IMPORTING

newdate = g_past_day.

ENDFORM. " get_past6month

&----


*& Form get_bsid

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_bsid .

SELECT ps_psp_pnr vbeln kunnr FROM vbak INTO CORRESPONDING FIELDS OF TABLE it_vbak

WHERE ps_psp_pnr IN s_proj.

SORT it_vbak BY ps_psp_pnr .

DELETE ADJACENT DUPLICATES FROM it_vbak.

SELECT dmbtr gjahr monat kunnr vbeln zterm

FROM bsad

INTO CORRESPONDING FIELDS OF TABLE it_bsad

FOR ALL ENTRIES IN it_vbak

WHERE kunnr = it_vbak-kunnr

AND bukrs = '1000'

AND blart = 'RE'.

ENDFORM. " get_bsid

&----


*& Form disp

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM disp .

DELETE ADJACENT DUPLICATES FROM it_vbak.

LOOP AT it_vbak .

MOVE it_vbak-ps_psp_pnr TO it_wa-ps_psp_pnr.

LOOP AT it_bsad WHERE kunnr = it_vbak-kunnr .

CALL FUNCTION 'J_1A_SD_CI_DUEDATE_GET' "TO GET OVERDUE DATE

EXPORTING

iv_vbeln = it_bsad-vbeln

iv_zterm = it_bsad-zterm

IMPORTING

ev_netdate = v_date1

EXCEPTIONS

fi_document_not_found = 1.

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES' " CALCULATING THE OUTSTANDING DAYS

EXPORTING

i_datum_bis = g_past_day

i_datum_von = v_date1

IMPORTING

e_tage = v_days

EXCEPTIONS

days_method_not_defined = 1

OTHERS = 2.

IF v_days > 1 AND v_days <= 30.

MOVE it_bsad-dmbtr TO it_wa-amt1.

ELSEIF v_days > 30 AND v_days <= 60.

MOVE it_bsad-dmbtr TO it_wa-amt2.

ELSEIF v_days > 60 AND v_days <= 90.

MOVE it_bsad-dmbtr TO it_wa-amt3.

ELSEIF v_days > 60 AND v_days <= 90.

MOVE it_bsad-dmbtr TO it_wa-amt4.

ELSEIF v_days > 90 AND v_days <= 150.

MOVE it_bsad-dmbtr TO it_wa-amt5.

ELSEIF v_days > 150 AND v_days <= 180.

MOVE it_bsad-dmbtr TO it_wa-amt6.

ENDIF.

it_wa-coll = it_wa-amt1 + it_wa-amt2 + it_wa-amt3 + it_wa-amt4 + it_wa-amt5 + it_wa-amt6.

IF NOT it_wa IS INITIAL.

COLLECT it_wa INTO it_disp.

CLEAR it_wa.

CLEAR it_disp.

ENDIF.

ENDLOOP.

ENDLOOP.

ENDFORM. " disp

*****************************************************************

  • END OF PAGE.

*****************************************************************

END-OF-PAGE.

WRITE: / 'PAGENO: ', sy-pagno.

********************************************************************

*FORM FOR ALV LAYOUT STRUCTURE

********************************************************************

FORM fill_layout_structure .

st_layout-zebra = 'X'.

st_layout-colwidth_optimize = 'X'.

ENDFORM. "fill_layout_structure

********************************************************************

*FORM FOR ALV FIELD CATALOG TABLE

********************************************************************

FORM fill_field_catalog_table .

PERFORM fill_field_catalog USING :

'PS_PSP_PNR' 'PROJECT ' 'IT_DISP' ' ' space,

'AMT1' 'O/S PERIOD1 (AMT) ' 'IT_DISP' space space,

'AMT2' 'O/S PERIOD2 (AMT) ' 'IT_DISP' space space,

'AMT3' 'O/S PERIOD3 (AMT) ' 'IT_DISP' space space,

'AMT4' 'O/S PERIOD4 (AMT) ' 'IT_DISP' space space,

'AMT5' 'O/S PERIOD5 (AMT) ' 'IT_DISP' space space,

'AMT6' 'O/S PERIOD6 (AMT) ' 'IT_DISP' space space,

'COLL' 'COLLECTION FOR THE MONTH KEY IN PERIOD ' 'IT_DISP' space space.

ENDFORM. "fill_field_catalog_table

********************************************************************

*FORM FOR FILLING FIELD CATALOG

********************************************************************

FORM fill_field_catalog USING f d t p s.

DATA: wa_fieldcat TYPE slis_fieldcat_alv.

STATICS v_pos TYPE i VALUE 1.

wa_fieldcat-row_pos = 1.

wa_fieldcat-col_pos = v_pos.

wa_fieldcat-fieldname = f.

wa_fieldcat-seltext_m = d.

wa_fieldcat-tabname = t.

wa_fieldcat-fix_column = p.

wa_fieldcat-do_sum = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

v_pos = v_pos + 1.

ENDFORM. "fill_field_catalog

********************************************************************

*FORM FOR FILLING LISTHEADER

********************************************************************

FORM fill_listheader USING it_listheader TYPE slis_t_listheader.

DATA : wa_listheader TYPE slis_listheader.

CLEAR wa_listheader.

wa_listheader-typ = 'H'.

wa_listheader-info = 'Noel Gifts International Limited '.

APPEND wa_listheader TO it_listheader.

WRITE : sy-datum TO v_date DD/MM/YYYY NO-GAP.

wa_listheader-typ = 'S'.

wa_listheader-key = ' Overall Outstanding as at ' .

wa_listheader-info = v_date.

APPEND wa_listheader TO it_listheader.

ENDFORM. "fill_listheader

********************************************************************

*FORM FOR GET_EVENT

********************************************************************

FORM get_event USING it_event TYPE slis_t_event.

DATA : wa_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = it_event.

READ TABLE it_event WITH KEY name = slis_ev_top_of_page INTO wa_event.

IF sy-subrc = 0.

MOVE 'TOP_OF_PAGE' TO wa_event-form.

APPEND wa_event TO it_event.

ENDIF.

ENDFORM. "get_event

********************************************************************

*FORM FOR TOP_OF_PAGE(to assign form for the top-of-page event)

********************************************************************

FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheader.

ENDFORM. "top_of_page

********************************************************************

*FORM FOR ALV FUNCTIONS

********************************************************************

FORM call_alv_function.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

i_callback_user_command = 'CALL_TCODE '

is_layout = st_layout

it_fieldcat = it_fieldcat[]

i_save = 'A'

it_events = it_event[]

TABLES

t_outtab = it_disp[].

ENDFORM. "call_alv_function