Skip to Content
0
Former Member
Oct 16, 2006 at 04:55 AM

RunTime

18 Views

I have problem in this report.i excute the report it will take more time please sort out my problem?its very urgent for me

REPORT ZRPT_MM_006.

TYPE-POOLS: slis.

tables : likp, lips, bseg, bkpf, mara, t001w, makt,ekko,ekpo.

DATA : gt_fieldcat TYPE slis_t_fieldcat_alv.

DATA : heading TYPE slis_t_listheader.

DATA : gt_events TYPE slis_t_event.

DATA : gs_keyinfo TYPE slis_keyinfo_alv.

DATA : gt_sort TYPE slis_t_sortinfo_alv.

DATA : gt_sp_group TYPE slis_t_sp_group_alv.

DATA : g_header_tab TYPE slis_tabname.

DATA : g_item_tab TYPE slis_tabname.

DATA : g_repid TYPE sy-repid.

SELECTION-SCREEN : BEGIN OF BLOCK t1 WITH FRAME TITLE text-007 .

SELECT-OPTIONS : s_vstel FOR likp-vstel OBLIGATORY,

s_matnr FOR lips-matnr,

s_lfdat FOR likp-lfdat OBLIGATORY,

s_matkl for mara-matkl,

s_werks for likp-werks.

SELECTION-SCREEN : END OF BLOCK t1.

PARAMETERS: p_vari LIKE disvariant-variant. " ALV Variant

data: begin of itab occurs 0,

lfdat like likp-lfdat,

vbeln like likp-vbeln,

vstel like likp-vstel,

werks like likp-werks,

matnr like lips-matnr,

maktx like makt-maktx,

matkl like lips-matkl,

lfimg like lips-lfimg,

vrkme like lips-vrkme,

dmbtr like bseg-dmbtr,

ebeln like ekko-ebeln,

ebelp like ekpo-ebelp,

bedat like ekko-bedat,

menge like ekpo-menge,

end of itab.

data : it_likp like likp occurs 0 with header line,

it_lips like lips occurs 0 with header line.

CONSTANTS : formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',

formaname_foreign_top_of_page TYPE slis_formname

VALUE 'FOREIGN_TOP_OF_PAGE'.

DATA : g_save(1) TYPE c,

g_exit(1) TYPE c,

gx_variant LIKE disvariant,

g_variant LIKE disvariant,

f2code LIKE sy-ucomm VALUE '&ETA',

layout TYPE slis_layout_alv.

DATA : repid LIKE sy-repid.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.

PERFORM f4_for_variant.

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

  • At Selection Screen *

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

AT SELECTION-SCREEN.

PERFORM pai_of_selection_screen.

INITIALIZATION.

repid = sy-repid.

PERFORM field_cat_fill USING gt_fieldcat[].

PERFORM initialize_variant.

START-OF-SELECTION.

PERFORM build_eventtab USING gt_events[].

PERFORM build_comment USING heading[].

PERFORM build_layout .

PERFORM get_data.

perform process_data.

PERFORM display_data.

END-OF-SELECTION.

&----


*& Form field_cat_fill

&----


  • text

----


  • -->RT_FIELDCATtext

----


FORM field_cat_fill USING

rt_fieldcat TYPE slis_t_fieldcat_alv.

DATA : ls_fieldcat TYPE slis_fieldcat_alv,

v_pos TYPE i.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'LFDAT'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'Del.Date'.

ls_fieldcat-outputlen = '10'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'VBELN'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'Del.Doc.No.'.

ls_fieldcat-outputlen = '12'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'VSTEL'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'Iss.Plant'.

ls_fieldcat-outputlen = '10'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'WERKS'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'Rec.Plant'.

ls_fieldcat-outputlen = '10'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'MATNR'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'Material code'.

ls_fieldcat-outputlen = '18'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'MAKTX'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'Material Description'.

ls_fieldcat-outputlen = '40'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'MATKL'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'Mat.Group'.

ls_fieldcat-outputlen = '10'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'LFIMG'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'Delivery Qty.'.

ls_fieldcat-outputlen = '20'.

ls_fieldcat-just = 'R'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'VRKME'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'UOM'.

ls_fieldcat-outputlen = '3'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'DMBTR'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'Value'.

ls_fieldcat-outputlen = '15'.

ls_fieldcat-just = 'R'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'EBELN'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'PO No'.

ls_fieldcat-outputlen = '10'.

ls_fieldcat-just = 'R'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'EBELP'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'PO Item'.

ls_fieldcat-outputlen = '8'.

ls_fieldcat-just = 'R'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'BEDAT'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'PO Date'.

ls_fieldcat-outputlen = '10'.

ls_fieldcat-just = 'R'.

APPEND ls_fieldcat TO rt_fieldcat.

v_pos = v_pos + 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = v_pos.

ls_fieldcat-fieldname = 'MENGE'.

ls_fieldcat-tabname = 'ITAB'.

ls_fieldcat-seltext_l = 'PO qty'.

ls_fieldcat-outputlen = '15'.

ls_fieldcat-just = 'R'.

APPEND ls_fieldcat TO rt_fieldcat.

  • v_pos = v_pos + 1.

  • CLEAR ls_fieldcat.

  • ls_fieldcat-col_pos = v_pos.

  • ls_fieldcat-fieldname = 'DMBTR'.

  • ls_fieldcat-tabname = 'ITAB'.

  • ls_fieldcat-seltext_l = 'Total'.

  • ls_fieldcat-outputlen = '15'.

  • ls_fieldcat-just = 'R'.

  • APPEND ls_fieldcat TO rt_fieldcat.

ENDFORM. "field_cat_fill

&----


*& Form build_eventtab

&----


  • text

----


  • -->P_EVENTS text

----


FORM build_eventtab USING p_events TYPE slis_t_event.

DATA : ls_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = p_events.

READ TABLE p_events WITH KEY name = slis_ev_top_of_page

INTO ls_event.

IF sy-subrc = 0.

MOVE formname_top_of_page TO ls_event-form.

APPEND ls_event TO p_events.

ENDIF.

ENDFORM. "build_eventtab

&----


*& Form build_comment

&----


  • text

----


  • -->P_HEADING text

----


FORM build_comment USING p_heading LIKE heading.

  • DATA: hline TYPE slis_listheader,

  • text(60) TYPE c,

  • text1(60) type c,

  • sep(20) TYPE c,

  • option(10).

  • *

    • CLEAR: hline, text.

    • hline-typ = 'H'.

    • WRITE: 'RunDate:' TO text,

    • sy-datum TO text+9,

    • 'User' TO text+23,

    • sy-uname TO text+29,

    • 'TCode' TO text+45,

    • sy-tcode TO text+52.

    *

    • hline-info = text.

    • APPEND hline TO p_heading.

    • CLEAR text.

    • INCLUDE zselectionsalv.

    ENDFORM. "build_comment

    &----


    *& Form top_of_page

    &----


    • text

    ----


    FORM top_of_page.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = heading.

    if not s_vstel-low is initial.

    clear t001w.

    select single * from t001w where werks = s_vstel-low.

    write: / 'Issuing Plant :', s_vstel-low, ' - ', t001w-name1.

    endif.

    if not s_vstel-high is initial.

    clear t001w.

    select single * from t001w where werks = s_vstel-high.

    write: / ' to ', s_vstel-high, ' - ', t001w-name1.

    endif.

    if not s_matnr-low is initial.

    write: / 'Material Code :', s_matnr-low.

    endif.

    if not s_matnr-high is initial.

    write: ' to ', s_matnr-high.

    endif.

    if not s_lfdat-low is initial.

    write: / 'Duration :', s_lfdat-low.

    endif.

    if not s_lfdat-high is initial.

    write: ' to ', s_lfdat-high.

    endif.

    if not s_matkl-low is initial.

    write: / 'Material Grp :', s_matkl-low.

    endif.

    if not s_matkl-high is initial.

    write: ' to ', s_matkl-high.

    endif.

    if not s_werks-low is initial.

    clear t001w.

    select single * from t001w where werks = s_werks-low.

    write: / 'Receiving Plant :', s_werks-low, ' - ', t001w-name1.

    endif.

    if not s_werks-high is initial.

    clear t001w.

    select single * from t001w where werks = s_werks-high.

    write: ' to ', s_werks-high, ' - ', t001w-name1.

    endif.

    ENDFORM. "top_of_page

    &----


    *& Form display_data

    &----


    • text

    ----


    FORM display_data.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE = ' '

    i_callback_program = repid

    • I_CALLBACK_PF_STATUS_SET = ' '

    i_callback_user_command = 'USER_COMMAND'

    • I_STRUCTURE_NAME =

    is_layout = layout

    it_fieldcat = gt_fieldcat[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    i_default = 'A'

    i_save = g_save

    is_variant = g_variant

    it_events = gt_events[]

    • IT_EVENT_EXIT =

    • IS_PRINT = gt_print

    • IS_REPREP_ID =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    t_outtab = itab

    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. " WRITE_ALV

    &----


    *& Form get_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM get_data .

    select * from likp into corresponding fields of table it_likp

    where vstel IN s_vstel

    and lfdat IN s_lfdat

    and werks IN s_werks.

    CHECK NOT it_likp[] IS INITIAL.

    • if p_grn is initial.

    select * from lips into corresponding fields of table it_lips

    for all entries in it_likp

    where vbeln = it_likp-vbeln

    and matnr IN s_matnr

    and matkl IN s_matkl

    and bwart IN ('641')

    and LFIMG ne 0.

    • else.

    *

    • select * from lips into corresponding fields of table it_lips

    • for all entries in it_likp

    • where vbeln = it_likp-vbeln

    • and matnr IN s_matnr

    • and matkl IN s_matkl

    • and bwart IN ('642').

    *

    • endif.

    sort : it_likp, it_lips.

    ENDFORM. " get_data

    &----


    *& Form process_data

    &----


    • text

    ----


    form process_data.

    loop at it_likp.

    loop at it_lips where vbeln = it_likp-vbeln.

    move it_likp-lfdat to itab-lfdat.

    move it_likp-vbeln to itab-vbeln.

    move it_likp-vstel to itab-vstel.

    move it_likp-werks to itab-werks.

    move it_lips-matnr to itab-matnr.

    clear makt.

    select single * from makt where matnr = it_lips-matnr.

    if sy-subrc = 0.

    move makt-maktx to itab-maktx.

    endif.

    move it_lips-matkl to itab-matkl.

    move it_lips-lfimg to itab-lfimg.

    move it_lips-vrkme to itab-vrkme.

    clear bkpf.

    • if p_grn is initial.

    select single * from bkpf where xblnr = it_likp-vbeln

    and tcode = 'VL02N'.

    • else.

    • select single * from bkpf where xblnr = it_likp-vbeln

    • and tcode = 'VL09'.

    • endif.

    if sy-subrc = 0.

    clear bseg.

    select single * from bseg where belnr = bkpf-belnr

    and bschl = '89'

    and shkzg = 'S'

    and ebeln = it_lips-VGBEL

    and ebelp = it_lips-vgpos.

    if sy-subrc = 0.

    move bseg-dmbtr to itab-dmbtr.

    else.

    itab-dmbtr = 0.

    endif.

    endif.

    perform get_poinfo.

    append itab.

    clear itab.

    clear it_lips.

    endloop.

    clear it_likp.

    endloop.

    endform. "proccess_data

    &----


    *& Form get_poinfo

    &----


    • text

    ----


    form get_poinfo.

    clear : ekko,ekpo.

    select single * from ekko

    where ebeln = it_lips-VGBEL.

    select single * from ekpo

    where ebeln = it_lips-VGBEL

    and ebelp = it_lips-vgpos.

    move : ekko-ebeln to itab-ebeln,

    ekko-bedat to itab-bedat,

    ekpo-ebelp to itab-ebelp,

    ekpo-menge to itab-menge.

    endform. "get_poinfo

    &----


    *& Form f4_for_variant

    &----


    • text

    ----


    FORM f4_for_variant.

    g_save = 'A'.

    g_variant-report = sy-repid.

    CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

    EXPORTING

    is_variant = g_variant

    i_save = g_save

    IMPORTING

    e_exit = g_exit

    es_variant = gx_variant

    EXCEPTIONS

    not_found = 2.

    IF sy-subrc = 2.

    MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ELSE.

    IF g_exit = space.

    p_vari = gx_variant-variant.

    ENDIF.

    ENDIF.

    ENDFORM. " F4_FOR_VARIANT

    &----


    *& Form pai_of_selection_screen

    &----


    • text

    ----


    FORM pai_of_selection_screen.

    IF NOT p_vari IS INITIAL.

    MOVE g_variant TO gx_variant.

    MOVE p_vari TO gx_variant-variant.

    gx_variant-report = sy-repid.

    CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

    EXPORTING

    i_save = g_save

    CHANGING

    cs_variant = gx_variant.

    g_variant = gx_variant.

    ELSE.

    • PERFORM initialize_variant.

    ENDIF.

    ENDFORM. " PAI_OF_SELECTION_SCREEN

    &----


    *& Form initialize_variant

    &----


    • text

    ----


    FORM initialize_variant.

    g_save = 'A'.

    CLEAR g_variant.

    g_variant-report = repid.

    gx_variant = g_variant.

    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

    EXPORTING

    i_save = g_save

    CHANGING

    cs_variant = gx_variant

    EXCEPTIONS

    not_found = 2.

    IF sy-subrc = 0.

    p_vari = gx_variant-variant.

    ENDIF.

    ENDFORM. " INITIALIZE_VARIANT

    &----


    *& Form build_layout

    &----


    • text

    ----


    FORM build_layout.

    layout-f2code = f2code.

    layout-zebra = 'X'.

    layout-detail_popup = 'X'.

    • layout-no_vline = ' '.

    ENDFORM. "build_layout