End of page in ALV Grid Report
Dear ABAPres,
I have developed ALV report using the Function module 'REUSE_ALV_GRID_DISPLAY'.
I want to display the End of Page.How can i achiev this.Please help me in this.
Thanks & Regards,
ashok.
Hi ,
See below code....
REPORT zcssd_sales_hours_pend2.
TYPE-POOLS : slis.
*****Tables Used in the Report************************
TABLES : vbak,
tvak,
tvlk,
likp,
vbep,
t001w,
kna1.
*****Global Data Declarations*************************
DATA: i_fieldcat TYPE slis_t_fieldcat_alv ,
wa_fieldcat TYPE slis_fieldcat_alv.
DATA: tbl_fieldcat1 TYPE slis_t_fieldcat_alv ,
st_fieldcat1 TYPE slis_fieldcat_alv.
DATA: w_layout TYPE slis_layout_alv.
DATA: st_layout1 TYPE slis_layout_alv,
v_header TYPE slis_t_listheader,
v_header1 TYPE slis_t_listheader,
v_header2 TYPE slis_t_listheader,
v_events TYPE slis_t_event.
DATA: gt_sort TYPE slis_t_sortinfo_alv.
DATA: i_events TYPE slis_t_event,
i_event_exit TYPE slis_t_event_exit.
DATA: w_events LIKE LINE OF i_events,
w_event_exit LIKE LINE OF i_event_exit.
DATA: i_list_comments TYPE slis_t_listheader.
DATA: w_list_comments LIKE LINE OF i_list_comments.
DATA: w_print TYPE slis_print_alv.
DATA: gs_sort TYPE slis_sortinfo_alv.
*DATA : BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*****Declaration of Internal Tables****************
TYPES : BEGIN OF ty_vbap_vbak,
vbeln TYPE vbap-vbeln,
posnr TYPE vbap-posnr,
matnr TYPE vbap-matnr,
matkl TYPE vbap-matkl,
zmeng TYPE vbap-zmeng,
meins TYPE vbap-meins,
spart TYPE vbap-spart,
netwr TYPE vbap-netwr,
kwmeng TYPE vbap-kwmeng,
werks TYPE vbap-werks,
route TYPE vbap-route,
netpr TYPE vbap-netpr,
kpein TYPE vbap-kpein,
kmein TYPE vbap-kmein,
auart TYPE vbak-auart,
lifsk TYPE vbak-lifsk,
netwr1 TYPE vbak-netwr,
vkorg TYPE vbak-vkorg,
vtweg TYPE vbak-vtweg,
spart1 TYPE vbak-spart,
vdatu TYPE vbak-vdatu,
kunnr TYPE vbak-kunnr,
END OF ty_vbap_vbak.
DATA : i_vbap_vbak1 TYPE STANDARD TABLE OF ty_vbap_vbak.
DATA : w_vbap_vbak1 LIKE LINE OF i_vbap_vbak1.
DATA : i_vbap_vbak2 TYPE STANDARD TABLE OF ty_vbap_vbak.
DATA : w_vbap_vbak2 LIKE LINE OF i_vbap_vbak2.
TYPES : BEGIN OF ty_knvv,
kunnr TYPE knvv-kunnr,
vkorg TYPE knvv-vkorg,
vtweg TYPE knvv-vtweg,
spart TYPE knvv-spart,
bzirk TYPE knvv-bzirk,
name1 TYPE kna1-name1,
END OF ty_knvv.
DATA : i_knvv1 TYPE STANDARD TABLE OF ty_knvv.
DATA : w_knvv1 LIKE LINE OF i_knvv1.
DATA : i_knvv2 TYPE STANDARD TABLE OF ty_knvv.
DATA : w_knvv2 LIKE LINE OF i_knvv2.
TYPES : BEGIN OF ty_likp,
vbeln TYPE likp-vbeln,
lfart TYPE likp-lfart,
lddat TYPE likp-lddat,
vbtyp TYPE likp-vbtyp,
kunnr TYPE likp-kunnr,
anzpk TYPE likp-anzpk,
netwr TYPE likp-netwr,
werks TYPE likp-werks.
TYPES : END OF ty_likp.
DATA : i_likp TYPE STANDARD TABLE OF ty_likp.
DATA : w_likp LIKE LINE OF i_likp.
DATA : i_t171t TYPE STANDARD TABLE OF t171t.
DATA : w_t171t LIKE LINE OF i_t171t.
TYPES : BEGIN OF ty_lips,
vbeln TYPE lips-vbeln,
posnr TYPE lips-posnr,
matnr TYPE lips-matnr,
matkl TYPE lips-matkl,
werks TYPE lips-werks,
lfimg TYPE lips-lfimg,
netwr TYPE lips-netwr.
TYPES : END OF ty_lips.
DATA : i_lips TYPE STANDARD TABLE OF ty_lips.
DATA : w_lips LIKE LINE OF i_lips.
TYPES : BEGIN OF ty_likp_lips,
vbeln TYPE likp-vbeln,
vkorg TYPE likp-vkorg,
lfart TYPE likp-lfart,
lddat TYPE likp-lddat,
vbtyp TYPE likp-vbtyp,
kunnr TYPE likp-kunnr,
anzpk TYPE likp-anzpk,
netwr TYPE likp-netwr,
werks TYPE likp-werks,
posnr TYPE lips-posnr,
matnr TYPE lips-matnr,
matkl TYPE lips-matkl,
lipswerks TYPE lips-werks,
lfimg TYPE lips-lfimg,
vrkme TYPE lips-vrkme,
vgbel TYPE lips-vgbel,
vtweg TYPE lips-vtweg,
spart TYPE lips-spart,
lipsnetwr TYPE lips-netwr.
TYPES : END OF ty_likp_lips.
DATA : i_likp_lips TYPE STANDARD TABLE OF ty_likp_lips.
DATA : w_likp_lips LIKE LINE OF i_likp_lips.
DATA : i_likp_lips1 TYPE STANDARD TABLE OF ty_likp_lips.
DATA : w_likp_lips1 LIKE LINE OF i_likp_lips1.
TYPES : BEGIN OF ty_vbup,
vbeln TYPE vbup-vbeln,
posnr TYPE vbup-posnr,
lfsta TYPE vbup-lfsta,
wbsta TYPE vbup-wbsta,
END OF ty_vbup.
TYPES : BEGIN OF ty_vbup1,
vbeln TYPE vbup-vbeln,
posnr TYPE vbup-posnr,
lfgsa TYPE vbup-lfgsa,
wbsta TYPE vbup-wbsta,
END OF ty_vbup1.
DATA : i_vbup TYPE STANDARD TABLE OF ty_vbup.
DATA : w_vbup LIKE LINE OF i_vbup.
DATA : i_vbup1 TYPE STANDARD TABLE OF ty_vbup1.
DATA : w_vbup1 LIKE LINE OF i_vbup1.
TYPES : BEGIN OF ty_output,
vbeln TYPE likp-vbeln,
vkorg TYPE likp-vkorg,
lfart TYPE likp-lfart,
lddat TYPE likp-lddat,
vbtyp TYPE likp-vbtyp,
kunnr TYPE likp-kunnr,
anzpk TYPE likp-anzpk,
netwr TYPE likp-netwr,
werks TYPE likp-werks,
posnr TYPE lips-posnr,
matnr TYPE lips-matnr,
matkl TYPE lips-matkl,
lipswerks TYPE lips-werks,
lfimg TYPE lips-lfimg,
vrkme TYPE lips-vrkme,
vgbel TYPE lips-vgbel,
vtweg TYPE lips-vtweg,
spart TYPE lips-spart,
lipsnetwr TYPE lips-netwr,
lfsta TYPE vbup-lfsta,
wbsta TYPE vbup-wbsta,
END OF ty_output.
DATA : i_output TYPE STANDARD TABLE OF ty_output.
DATA : w_output LIKE LINE OF i_output.
DATA : i_output1 TYPE STANDARD TABLE OF ty_output.
DATA : w_output1 LIKE LINE OF i_output1.
TYPES : BEGIN OF ty_vbfa,
vbelv TYPE vbfa-vbelv,
posnv TYPE vbfa-posnv,
vbeln TYPE vbfa-vbeln,
posnn TYPE vbfa-posnn,
vbtyp_n TYPE vbfa-vbtyp_n,
rfmng TYPE vbfa-rfmng,
RFWRT TYPE VBFA-RFWRT,
vbtyp_v TYPE vbfa-vbtyp_v,
END OF ty_vbfa.
DATA : i_vbfa TYPE STANDARD TABLE OF ty_vbfa.
DATA : w_vbfa LIKE LINE OF i_vbfa.
TYPES : BEGIN OF ty_vbfa1,
vbelv TYPE vbfa-vbelv,
posnv TYPE vbfa-posnv,
vbeln TYPE vbfa-vbeln,
posnn TYPE vbfa-posnn,
rfmng TYPE vbfa-rfmng,
rfwrt TYPE vbfa-rfwrt,
END OF ty_vbfa1.
DATA : i_vbfa1 TYPE STANDARD TABLE OF ty_vbfa1.
DATA : w_vbfa1 LIKE LINE OF i_vbfa1.
TYPES: BEGIN OF ty_vbrk_vbrp,
vbeln TYPE vbrk-vbeln,
fkart TYPE vbrk-fkart,
fktyp TYPE vbrk-fktyp,
vbtyp TYPE vbrk-vbtyp,
waerk TYPE vbrk-waerk,
netwr TYPE vbrk-netwr,
posnr TYPE vbrp-posnr,
fkimg TYPE vbrp-fkimg,
vrkme TYPE vbrp-vrkme,
umvkz TYPE vbrp-umvkz,
umvkn TYPE vbrp-umvkn,
netwr1 TYPE vbrp-netwr,
END OF ty_vbrk_vbrp.
DATA : i_vbrk_vbrp TYPE STANDARD TABLE OF ty_vbrk_vbrp.
DATA : w_vbrk_vbrp LIKE LINE OF i_vbrk_vbrp.
TYPES : BEGIN OF ty_vbep,
vbeln TYPE vbep-vbeln,
posnr TYPE vbep-posnr,
wmeng TYPE vbep-wmeng,
lddat TYPE vbep-lddat,
END OF ty_vbep.
DATA : i_vbep TYPE STANDARD TABLE OF ty_vbep.
DATA : w_vbep LIKE LINE OF i_vbep.
TYPES : BEGIN OF ty_vbep_vbup,
vbeln TYPE vbep-vbeln,
posnr TYPE vbep-posnr,
wmeng TYPE vbep-wmeng,
lddat TYPE vbep-lddat,
lfgsa TYPE vbup-lfgsa,
wbsta TYPE vbup-wbsta,
END OF ty_vbep_vbup.
DATA : i_vbep_vbup TYPE STANDARD TABLE OF ty_vbep_vbup.
DATA : w_vbep_vbup LIKE LINE OF i_vbep_vbup.
TYPES : BEGIN OF ty_makt,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
END OF ty_makt.
DATA : i_makt TYPE STANDARD TABLE OF ty_makt.
DATA : w_makt LIKE LINE OF i_makt.
TYPES : BEGIN OF ty_final,
lddat TYPE likp-lddat,
werks TYPE vbap-werks,
bzirk TYPE knvv-bzirk,
bztxt TYPE t171t-bztxt,
kunnr TYPE vbak-kunnr,
name1 TYPE kna1-name1,
vbeln TYPE likp-vbeln,
wbsta TYPE vbup-wbsta,
text(25) TYPE c,
lfgsa TYPE vbup-lfgsa,
kwmeng TYPE vbap-kwmeng,
netwr TYPE likp-netwr,
order TYPE vbak-vbeln,
posnr TYPE vbap-posnr,
matnr TYPE mara-matnr,
netwr1 TYPE vbak-netwr,
kwmeng1 TYPE vbap-kwmeng,
kwmeng2 TYPE vbap-kwmeng,
route TYPE vbap-route,
lifsk TYPE vbak-lifsk,
vdatu TYPE vbak-vdatu,
END OF ty_final.
DATA : i_final TYPE STANDARD TABLE OF ty_final.
DATA : w_final LIKE LINE OF i_final.
DATA : i_final1 TYPE STANDARD TABLE OF ty_final.
DATA : w_final1 LIKE LINE OF i_final1.
TYPES : BEGIN OF ty_final2,
lddat TYPE likp-lddat,
werks TYPE vbap-werks,
bzirk TYPE knvv-bzirk,
bztxt TYPE t171t-bztxt,
kunnr TYPE vbak-kunnr,
name1 TYPE kna1-name1,
vbeln TYPE likp-vbeln,
wbsta TYPE vbup-wbsta,
text(25) TYPE c,
lfgsa TYPE vbup-lfgsa,
kwmeng TYPE vbap-kwmeng,
netwr TYPE likp-netwr,
order TYPE vbak-vbeln,
posnr TYPE vbap-posnr,
matnr TYPE mara-matnr,
netwr1 TYPE vbak-netwr,
kwmeng1 TYPE vbap-kwmeng,
kwmeng2 TYPE vbap-kwmeng,
vdatu TYPE vbak-vdatu,
maktx TYPE makt-maktx,
END OF ty_final2.
DATA : i_final2 TYPE STANDARD TABLE OF ty_final2.
DATA : w_final2 LIKE LINE OF i_final2.
DATA : i_conwa TYPE STANDARD TABLE OF vbco6 WITH HEADER LINE.
DATA : i_vbfa_tab TYPE STANDARD TABLE OF vbfa WITH HEADER LINE.
DATA : opt TYPE ctu_params.
DATA : v_vbeln TYPE vbak-vbeln.
DATA : w_vbeln TYPE vbak-vbeln.
DATA : v_repid TYPE sy-repid.
DATA : v_netwr TYPE vbak-netwr.
DATA : v_kwmeng TYPE vbap-kwmeng.
DATA : v_netwr1 TYPE vbak-netwr.
DATA : v_kwmeng1 TYPE vbap-kwmeng.
DATA : v_time(60) TYPE c.
DATA : v_plant(60) TYPE c.
DATA : v_date(60) TYPE c.
DATA : v_lfart(60) TYPE c.
DATA : v_auart(60) TYPE c.
DATA : v_mod(2) TYPE c.
DATA : name(10).
DATA : v_indexes TYPE sy-index.
DATA : v_text(40) TYPE c.
DATA : v_total TYPE p DECIMALS 2.
DATA : v_total1(60) TYPE c.
DATA : v_totqt TYPE p DECIMALS 2.
****Constants Declaration********************************
CONSTANTS : c_wbstaa TYPE vbup-wbsta VALUE 'A',
c_wbstab TYPE vbup-wbsta VALUE 'B',
c_wbstac TYPE vbup-wbsta VALUE 'C',
c_lfartlf TYPE likp-lfart VALUE 'LF',
c_lfartlr TYPE likp-lfart VALUE 'LR',
c_lfartlo TYPE likp-lfart VALUE 'LO',
c_lfartzlo TYPE likp-lfart VALUE 'ZLO',
c_lfgsaa TYPE vbup-lfgsa VALUE 'A',
c_lfgsab TYPE vbup-lfgsa VALUE 'B',
c_vbtyp_nj TYPE vbfa-vbtyp_n VALUE 'J',
c_vbtyp_nt TYPE vbfa-vbtyp_n VALUE 'T',
c_vbtyp_nm TYPE vbfa-vbtyp_n VALUE 'M',
c_vbtyp_vh TYPE vbfa-vbtyp_v VALUE 'H',
c_1100 TYPE t001w-werks VALUE '1100',
c_1101 TYPE t001w-werks VALUE '1101'.
****Selection Screen Declaration*************************
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE title.
SELECT-OPTIONS : s_werks FOR t001w-werks OBLIGATORY.
SELECT-OPTIONS : s_lddat FOR likp-lddat.
SELECT-OPTIONS : s_auat FOR vbak-auart DEFAULT 'OR'.
SELECT-OPTIONS : s_lfat FOR likp-lfart DEFAULT 'LF'.
SELECT-OPTIONS : s_vbeln FOR vbep-vbeln NO-DISPLAY.
SELECT-OPTIONS : s_posnr FOR vbep-posnr NO-DISPLAY.
SELECTION-SCREEN : END OF BLOCK b1.
****Initialization***************************************
INITIALIZATION.
v_repid = sy-repid.
title = 'Selection Screen Options'.
s_werks-sign = 'I'.
s_werks-option = 'EQ'.
s_werks-low = c_1100.
s_werks-high = c_1101.
APPEND s_werks.
CALL FUNCTION 'OIUREP_MONTH_FIRST_LAST'
EXPORTING
i_date = sy-datum
IMPORTING
e_first_day = s_lddat-low
e_last_day = s_lddat-high.
s_lddat-sign = 'I'.
s_lddat-option = 'EQ'.
APPEND s_lddat TO s_lddat.
****At selection screen on field*************************
AT SELECTION-SCREEN ON s_werks.
SELECT SINGLE * FROM t001w WHERE werks IN s_werks.
IF sy-subrc <> 0.
MESSAGE 'Please enter correct Plant' TYPE 'E'.
ENDIF.
AT SELECTION-SCREEN ON s_lddat.
AT SELECTION-SCREEN ON s_auat.
SELECT SINGLE * FROM tvak WHERE auart IN s_auat.
IF sy-subrc <> 0.
MESSAGE 'Please enter correct Sales Doc Type' TYPE 'E'.
ENDIF.
AT SELECTION-SCREEN ON s_lfat.
SELECT SINGLE * FROM tvlk WHERE lfart IN s_lfat.
IF sy-subrc <> 0.
MESSAGE 'Please enter correct Delv Doc Type' TYPE 'E'.
ENDIF.
****Start selection of data from tables based on cond****
PERFORM SALESORDER_HEADER_ITEM.
PERFORM CUSTOMER_SALESDATA.
START-OF-SELECTION.
PERFORM delivery_header_item.
PERFORM salesdocument_itemstatus.
PERFORM salesdocument_schedulelinedata.
PERFORM salesdocument_itemstatus_lfgsa.
PERFORM sales_district.
PERFORM delivery_salesdocument_wbsta.
PERFORM salesdocumentflow.
PERFORM billingdoc_header_item.
PERFORM salesorder_header_item2.
PERFORM customer_salesdata1.
PERFORM delivery_output.
PERFORM salesdoc_shdlnitem_itemstatus.
PERFORM salesorder_header_item1.
PERFORM customer_salesdata2.
PERFORM salesorder_output.
PERFORM material_descriptions.
PERFORM final_output.
END-OF-SELECTION.
****Fieldcatalog Routine for ALVGRID******************
PERFORM fieldcatalog.
****Event Routine for ALVGRID*************************
PERFORM build_header CHANGING v_header v_header1.
PERFORM build_events CHANGING v_events.
PERFORM print_build.
****Layout Routine for ALVGRID************************
PERFORM layout_build.
****Grid_display Routine for ALVGRID******************
PERFORM grid_display.
*& Form fieldcatalog
text
--> p1 text
<-- p2 text
FORM fieldcatalog .
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'LDDAT'.
wa_fieldcat-seltext_m = 'Loading Dt'.
wa_fieldcat-key = ' '. "SUBTOTAL KEY
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-seltext_m = 'Plant'.
wa_fieldcat-key = ' '. "SUBTOTAL KEY
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'BZIRK'.
wa_fieldcat-seltext_m = 'Sales Dist'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'BZTXT'.
wa_fieldcat-seltext_m = 'Name of Dist'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'KUNNR'.
wa_fieldcat-seltext_m = 'Customer No.'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-seltext_m = 'Customer Name'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'VBELN'.
wa_fieldcat-seltext_m = 'Delivery No.'.
wa_fieldcat-key = ' '. "SUBTOTAL KEY
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'WBSTA'.
wa_fieldcat-seltext_m = 'Delv Status'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'TEXT'.
wa_fieldcat-seltext_m = 'Status Desc'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'KWMENG'.
wa_fieldcat-seltext_m = 'Delivery Qty'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'NETWR'.
wa_fieldcat-seltext_m = 'Delv Net Value'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'ORDER'.
wa_fieldcat-seltext_m = 'Sales Order'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'KWMENG1'.
wa_fieldcat-seltext_m = 'Order Qty'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'NETWR1'.
wa_fieldcat-seltext_m = 'Sales Net Value'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'LIFSK'.
wa_fieldcat-seltext_m = 'Delv Block'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'ROUTE'.
wa_fieldcat-seltext_m = 'Route'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = 'I_FINAL1'.
wa_fieldcat-fieldname = 'VDATU'.
wa_fieldcat-seltext_m = 'Req Delivery Dt'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
CLEAR gs_sort.
gs_sort-fieldname = 'LDDAT'.
gs_sort-spos = 1.
gs_sort-up = 'X'.
gs_sort-subtot = 'X'.
APPEND gs_sort TO gt_sort.
ENDFORM. " fieldcatalog
*& Form print_build
text
--> p1 text
<-- p2 text
FORM print_build .
w_print-no_print_listinfos = 'X'.
ENDFORM. " print_build
*& Form layout_build
text
--> p1 text
<-- p2 text
FORM layout_build .
w_layout-zebra = 'X'.
w_layout-no_vline = ''.
w_layout-colwidth_optimize = 'X'.
w_layout-detail_popup = 'X'.
w_layout-detail_initial_lines = 'X'.
w_layout-detail_titlebar = 'Detail Title Bar'.
ENDFORM. " layout_build
*& Form GRID_DISPLAY
text
FORM grid_display.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'PROCESS_USER_COMMANDS'
is_layout = w_layout
it_fieldcat = i_fieldcat[]
it_sort = gt_sort[]
i_default = 'X'
i_save = 'A'
it_events = v_events
is_print = w_print
TABLES
t_outtab = i_final1
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. "GRID_DISPLAY
*& Form END_OF_LIST
FORM top_of_list.
ENDFORM. "TOP_OF_LIST
*& Form PROCESS_USER_COMMANDS
text
-->SYST-UCOMM text
-->SELFIELD text
FORM process_user_commands USING syst-ucomm LIKE syst-ucomm
selfield TYPE slis_selfield.
CASE syst-ucomm.
WHEN '&IC1'.
IF selfield-sel_tab_field = 'I_FINAL1-VBELN'.
w_vbeln = selfield-value.
SET PARAMETER ID: 'VL' FIELD w_vbeln.
CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
ELSEIF selfield-sel_tab_field = 'I_FINAL1-ORDER'.
v_vbeln = selfield-value.
SET PARAMETER ID: 'AUN' FIELD v_vbeln.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ELSE.
READ TABLE i_final1 INTO w_final1 INDEX selfield-tabindex.
IF w_final1-vbeln <> ' '.
LOOP AT i_final INTO w_final WHERE vbeln = w_final1-vbeln.
READ TABLE i_makt INTO w_makt WITH KEY matnr = w_final-matnr .
IF sy-subrc = 0.
MOVE : w_final TO w_final2.
MOVE : w_makt-maktx TO w_final2-maktx.
APPEND w_final2 TO i_final2.
ELSE.
MOVE : w_final TO w_final2.
MOVE : ' ' TO w_final2-maktx.
APPEND w_final2 TO i_final2.
ENDIF.
ENDLOOP.
CLEAR w_makt.
ELSE.
LOOP AT i_final INTO w_final WHERE order = w_final1-order.
READ TABLE i_makt INTO w_makt WITH KEY matnr = w_final-matnr .
IF sy-subrc = 0.
MOVE : w_final TO w_final2.
MOVE : w_makt-maktx TO w_final2-maktx.
APPEND w_final2 TO i_final2.
ELSE.
MOVE : w_final TO w_final2.
MOVE : ' ' TO w_final2-maktx.
APPEND w_final2 TO i_final2.
ENDIF.
ENDLOOP.
CLEAR w_makt.
ENDIF.
PERFORM fieldcatalog1 USING selfield .
PERFORM event_build.
PERFORM layout_build1.
PERFORM grid_display1.
ENDIF.
ENDCASE.
ENDFORM. " PROCESS_USER_COMMANDS
*& Form fieldcatalog1
text
--> p1 text
<-- p2 text
FORM fieldcatalog1 USING r_selfield TYPE slis_selfield.
REFRESH tbl_fieldcat1.
READ TABLE i_final1 INTO w_final1 INDEX r_selfield-tabindex.
IF w_final1-vbeln <> ' '.
PERFORM write_fieldcat1 USING 'POSNR' 'I_FINAL2' 'Item Number' ' ' 2 ' ' ' '
PERFORM write_fieldcat1 USING 'MATNR' 'I_FINAL2' 'Material Number' ' ' 3 ' ' ' '
PERFORM write_fieldcat1 USING 'MAKTX' 'I_FINAL2' 'Material Description' ' ' 4 ' ' ' '
PERFORM write_fieldcat1 USING 'KWMENG' 'I_FINAL2' 'Delivery Qty' ' ' 7 ' ' ' '
PERFORM write_fieldcat1 USING 'NETWR' 'I_FINAL2' 'Delv Net Value' ' ' 8 ' ' ' '
ELSE.
PERFORM write_fieldcat1 USING 'POSNR' 'I_FINAL2' 'Item Number' ' ' 2 ' ' ' '
PERFORM write_fieldcat1 USING 'MATNR' 'I_FINAL2' 'Material Number' ' ' 3 ' ' ' '
PERFORM write_fieldcat1 USING 'MAKTX' 'I_FINAL2' 'Material Description' ' ' 4 ' ' ' '
PERFORM write_fieldcat1 USING 'KWMENG2' 'I_FINAL2' 'Sales Order Qty' ' ' 9 ' ' ' '
PERFORM write_fieldcat1 USING 'NETWR1' 'I_FINAL2' 'Net Value' ' ' 10 ' ' ' '
ENDIF.
ENDFORM. " fieldcatalog1
*& Form write_fieldcat1
text
-->NAME text
-->TAB text
-->ST text
-->KEY text
-->POS text
-->LENGTH text
-->ICON text
-->HOT text
FORM write_fieldcat1 USING name tab st key pos length icon hot.
st_fieldcat1-fieldname = name.
st_fieldcat1-tabname = tab.
st_fieldcat1-seltext_m = st.
st_fieldcat1-key = key.
st_fieldcat1-col_pos = pos.
st_fieldcat1-outputlen = length.
st_fieldcat1-icon = icon.
st_fieldcat1-do_sum = hot.
APPEND st_fieldcat1 TO tbl_fieldcat1.
CLEAR st_fieldcat1.
ENDFORM. " WRITE_FIELDCAT
*& Form GRID_DISPLAY1
text
--> p1 text
<-- p2 text
FORM grid_display1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
it_fieldcat = tbl_fieldcat1
is_layout = st_layout1
it_events = i_events[]
TABLES
t_outtab = i_final2
EXCEPTIONS
program_error = 1
OTHERS = 2.
REFRESH i_final2.
ENDFORM. " GRID_DISPLAY1
*& Form LAYOUT_BUILD1
text
FORM layout_build1 .
st_layout1-zebra = 'X'.
st_layout1-no_vline = ''.
st_layout1-colwidth_optimize = 'X'.
st_layout1-detail_popup = 'X'.
st_layout1-detail_initial_lines = 'X'.
st_layout1-detail_titlebar = 'Detail Title Bar'.
ENDFORM. " layout_build
*& Form salesdocument_itemstatus
text
--> p1 text
<-- p2 text
FORM salesdocument_itemstatus .
CLEAR i_vbup.
REFRESH i_vbup.
v_indexes = 10.
v_text = 'Processing... Sales Doc Item'.
PERFORM progress_ind.
IF NOT i_likp_lips[] IS INITIAL.
SELECT vbeln
posnr
lfsta
wbsta
FROM vbup INTO TABLE i_vbup
FOR ALL ENTRIES IN i_likp_lips
WHERE vbeln = i_likp_lips-vbeln
AND posnr = i_likp_lips-posnr
AND wbsta IN (c_wbstaa, c_wbstab, c_wbstac).
ENDIF.
SORT i_vbup BY vbeln posnr.
ENDFORM. " salesdocument_itemstatus
*& Form delivery_header_item
text
--> p1 text
<-- p2 text
FORM delivery_header_item .
CLEAR i_likp_lips.
REFRESH i_likp_lips.
v_indexes = 1.
v_text = 'Processing.. Delivery'.
PERFORM progress_ind.
selected data from delivery header and delivery iten based on loading date and plant
based on document types LF LR LO ZLO.
SELECT a~vbeln
a~vkorg
a~lfart
a~lddat
a~vbtyp
a~kunnr
a~anzpk
a~netwr
a~werks
b~posnr
b~matnr
b~matkl
b~werks
b~lfimg
b~vrkme
b~vgbel
b~vtweg
b~spart
b~netwr
INTO TABLE i_likp_lips
FROM likp AS a INNER JOIN lips AS b
ON avbeln = bvbeln
WHERE a~lfart IN s_lfat
AND a~lddat IN s_lddat
AND b~werks IN s_werks.
%_HINTS ORACLE 'index("Z05" "Z05LFART" "Z05LDDAT")'.
DELETE i_likp_lips WHERE lfart NOT IN s_lfat
OR lddat NOT IN s_lddat
OR lipswerks NOT IN s_werks.
SORT i_likp_lips BY vbeln posnr.
ENDFORM. " delivery_header_item
*& Form SalesDocument_ScheduleLineData
text
--> p1 text
<-- p2 text
FORM salesdocument_schedulelinedata .
CLEAR i_vbep.
REFRESH i_vbep.
v_indexes = 15.
v_text = 'Processing.. Sales Doc Sch Line Data'.
PERFORM progress_ind.
*SELECTED from table vbep based on loading date, this selection will fetch all
*the open sales orders.
SELECT vbeln
posnr
wmeng
lddat
FROM vbep
INTO TABLE i_vbep
WHERE vbeln in s_vbeln
and posnr in s_posnr
and lddat IN s_lddat.
DELETE I_VBEP WHERE LDDAT NOT IN S_LDDAT.
SORT i_vbep BY vbeln posnr.
ENDFORM. " SalesDocument_ScheduleLineData
*& Form salesdocument_itemstatus_lfgsa
text
--> p1 text
<-- p2 text
FORM salesdocument_itemstatus_lfgsa .
CLEAR i_vbup1.
REFRESH i_vbup1.
v_indexes = 20.
v_text = 'Processing... Sales Doc Item'.
PERFORM progress_ind.
selected from vbup for all entries of vbep based on respective salesorder and item number
and lfgsa status equals to A AND B.
IF NOT i_vbep[] IS INITIAL.
SELECT vbeln posnr lfgsa wbsta FROM vbup INTO TABLE i_vbup1 FOR ALL ENTRIES IN i_vbep
WHERE vbeln = i_vbep-vbeln
AND posnr = i_vbep-posnr
AND LFGSA IN (C_LFGSAA, C_LFGSAB).
%_HINTS ORACLE 'index("ZS1" "ZS1~LFGSA")'.
ENDIF.
DELETE i_vbup1 WHERE lfgsa <> c_lfgsaa AND lfgsa <> c_lfgsab.
SORT i_vbup1 BY vbeln posnr.
ENDFORM. " salesdocument_itemstatus_lfgsa
*& Form billingdoc_header_item
text
--> p1 text
<-- p2 text
FORM billingdoc_header_item .
CLEAR i_vbrk_vbrp.
REFRESH i_vbrk_vbrp.
v_indexes = 40.
v_text = 'Processing... Billing'.
PERFORM progress_ind.
*SELECTED INVOICE DETAILS FROM VBRK AND VBRP .
IF NOT I_VBFA1[] IS INITIAL.
SELECT AVBELN AFKART AFKTYP AVBTYP AWAERK ANETWR
BPOSNR BFKIMG BVRKME BUMVKZ BUMVKN BNETWR
INTO TABLE I_VBRK_VBRP FROM VBRK AS A INNER
JOIN VBRP AS B ON AVBELN = BVBELN FOR ALL ENTRIES IN I_VBFA1
WHERE A~VBELN = I_VBFA1-VBELN AND
B~POSNR = I_VBFA1-POSNN.
ENDIF.
SORT I_VBRK_VBRP BY VBELN POSNR VRKME.
ENDFORM. " billingdoc_header_item
*& Form sales_district
text
--> p1 text
<-- p2 text
FORM sales_district .
CLEAR i_t171t.
REFRESH i_t171t.
v_indexes = 22.
v_text = 'Processing... Sales District'.
PERFORM progress_ind.
*TO SELECT THE SALES DISTRICT FROM I171T.
SELECT * FROM t171t INTO TABLE i_t171t WHERE spras = 'EN'.
ENDFORM. " sales_district
*& Form Material_Descriptions
text
--> p1 text
<-- p2 text
FORM material_descriptions .
DATA : i_fin TYPE STANDARD TABLE OF ty_final WITH HEADER LINE.
CLEAR i_makt.
REFRESH i_makt.
PERFORM progress_ind.
i_fin[] = i_final[].
SORT i_fin BY matnr.
DELETE ADJACENT DUPLICATES FROM i_fin COMPARING matnr.
THIS STATEMENT IS USED TO SELECT MATERIAL DESCRIPTIONS BASED ON THE MATERIAL NUMBERS
PRESENT IN THE FINAL INTERNAL TABLE.
IF NOT i_fin[] IS INITIAL.
SELECT matnr maktx FROM makt INTO TABLE i_makt FOR ALL ENTRIES IN i_fin WHERE spras = 'EN'
AND matnr = i_fin-matnr.
ENDIF.
SORT i_makt BY matnr.
ENDFORM. " Material_Descriptions
*& Form delivery_salesdocument_wbsta
text
--> p1 text
<-- p2 text
This routine will helps us to combine delivery data and sales document item status
FORM delivery_salesdocument_wbsta .
CLEAR i_output.
REFRESH i_output.
v_indexes = 30.
v_text = 'Processing... Open Delivery'.
PERFORM progress_ind.
LOOP AT i_likp_lips INTO w_likp_lips.
READ TABLE i_vbup INTO w_vbup WITH KEY vbeln = w_likp_lips-vbeln
posnr = w_likp_lips-posnr BINARY SEARCH.
IF sy-subrc = 0.
MOVE-CORRESPONDING w_likp_lips TO w_output.
MOVE : w_vbup-lfsta TO w_output-lfsta.
MOVE : w_vbup-wbsta TO w_output-wbsta.
APPEND w_output TO i_output.
ENDIF.
ENDLOOP.
SORT i_output BY vbeln posnr.
ENDFORM. " delivery_salesdocument_wbsta
*& Form salesdocumentflow
text
--> p1 text
<-- p2 text
FORM salesdocumentflow .
CLEAR i_vbfa.
REFRESH i_vbfa.
CLEAR i_vbfa1.
REFRESH i_vbfa1.
v_indexes = 35.
v_text = 'Processing... Sales Doc Flow'.
PERFORM progress_ind.
THIS STATEMENT IS USED TO SELECT THE ORDER NUMBERS BASED ON DELIVERY NUMBERS
FROM SALES DOCUMENT FLOW TABLE.
IF NOT I_OUTPUT[] IS INITIAL.
SELECT VBELV POSNV VBELN POSNN VBTYP_N RFMNG VBTYP_V INTO TABLE I_VBFA FROM VBFA
FOR ALL ENTRIES IN I_OUTPUT WHERE VBELN = I_OUTPUT-VBELN
AND POSNN = I_OUTPUT-POSNR
AND VBTYP_N IN (C_VBTYP_NJ, C_VBTYP_NT).
SELECT VBELV POSNV VBELN POSNN RFMNG RFWRT FROM VBFA INTO TABLE I_VBFA1 FOR ALL ENTRIES IN
I_OUTPUT WHERE VBELV = I_OUTPUT-VBELN
AND POSNV = I_OUTPUT-POSNR
AND VBTYP_N = C_VBTYP_NM.
ENDIF.
SORT I_VBFA BY VBELN POSNN.
SORT I_VBFA1 BY VBELN POSNN.
ENDFORM. " salesdocumentflow
*& Form salesdoc_shdlnitem_itemstatus
text
--> p1 text
<-- p2 text
FORM salesdoc_shdlnitem_itemstatus .
CLEAR i_vbep_vbup.
REFRESH i_vbep_vbup.
v_indexes = 70.
v_text = 'Processing... Order'.
PERFORM progress_ind.
*TO COMBINE THE VBUP DATA WITH STATUS OF LFGSA EQ TO A AND B WITH
*DATA OF VBEP , WHERE WE GET DATA OF VBEP BASED ON LOADING DATE
IF NOT i_vbup1 IS INITIAL.
LOOP AT i_vbup1 INTO w_vbup1.
READ TABLE i_vbep INTO w_vbep WITH KEY vbeln = w_vbup1-vbeln
posnr = w_vbup1-posnr BINARY SEARCH.
IF sy-subrc = 0.
MOVE : w_vbep-vbeln TO w_vbep_vbup-vbeln,
w_vbep-posnr TO w_vbep_vbup-posnr,
w_vbep-wmeng TO w_vbep_vbup-wmeng,
w_vbep-lddat TO w_vbep_vbup-lddat,
w_vbup1-lfgsa TO w_vbep_vbup-lfgsa,
w_vbup1-wbsta TO w_vbep_vbup-wbsta.
APPEND w_vbep_vbup TO i_vbep_vbup.
ENDIF.
ENDLOOP.
ENDIF.
SORT i_vbep_vbup BY vbeln posnr.
DELETE ADJACENT DUPLICATES FROM i_vbep_vbup COMPARING vbeln posnr.
ENDFORM. " salesdoc_shdlnitem_itemstatus
*& Form delivery_output
text
--> p1 text
<-- p2 text
*This routine will give us all the deliveries which are open or closed with
*there respective delivered quantity and amount etc.
FORM delivery_output .
CLEAR i_final.
REFRESH i_final.
v_indexes = 65.
v_text = 'Processing... Deliver'.
PERFORM progress_ind.
IF NOT i_output[] IS INITIAL.
LOOP AT i_output INTO w_output.
REFRESH i_vbfa_tab.
IF W_OUTPUT-LFART = C_LFARTLF OR W_OUTPUT-LFART = C_LFARTLO OR W_OUTPUT-LFART = C_LFARTZLO.
READ TABLE I_VBFA INTO W_VBFA WITH KEY VBELN = W_OUTPUT-VBELN
POSNN = W_OUTPUT-POSNR BINARY SEARCH .
ELSEIF W_OUTPUT-LFART = C_LFARTLR.
IF W_OUTPUT-VBTYP = 'J'.
READ TABLE I_VBFA INTO W_VBFA WITH KEY VBELN = W_OUTPUT-VBELN
POSNN = W_OUTPUT-POSNR BINARY SEARCH.
ELSE.
READ TABLE I_VBFA INTO W_VBFA WITH KEY VBELN = W_OUTPUT-VBELN
POSNN = W_OUTPUT-POSNR
Similar Messages
-
How doi print Any variable at the end of page in ALV report?
Hi,
Anyone can tell me that How do i print Any variable at the end of page in ALV report?
Exmale: at the ende of alv report i want to print total no of employee who has taken house loan or education loan.Hi,
Go through these links
Thread in sdn regarding FOOTER IN ALV
[ALV FOOTER;
Wiki in sdn regarding HEADER AND FOOTER IN ALV
[https://wiki.sdn.sap.com/wiki/display/Snippets/ABAP%20Objects%20-%20ALV%20Model%20-%20Using%20Header%20and%20Footer]
Header and Footer in ALV
[http://www.sap-img.com/abap/test-alv-display-with-header-footer.htm]
Hope this helps.
Thank you,
Pavan. -
Page Format for landscape/legal paper for ALV Grid report
Hi!
I have a request to set up a particular ALV Grid report as a background job with the report output printing on legal-size paper with landscape orientation. We currently don't have any reports set up to print on legal size paper. What do I need to do to set this up? We currently use X_58_170 or X_65_255 which print on letter-size paper. I cannot seem to find a page format for landscape legal other than LEGAL which seems to be available only for SAPscript or Smart Forms. Any help will be greatly appreciated.
Best Regards,
Nik von Ruden
Edited by: Nik Von Ruden on Oct 8, 2010 1:11 AMHi,
Thanks for you reply.
I cannot control left and right margin in PDF. Also, it is a PDF file so eventhough somehow you are able to change left and right margin, the content does not adjust itself to fit the legal page (as it does in word or excel).
Let me know if there is any other option.
Thanks,
RS -
How to enable excel downloading in ALV grid report.
Hi all,
How to enable excal downing in ALV grid report?
Thanks in Advance.
Siva Sankar.hi
check the following code
Example of a Simple ALV Grid Report
REPORT ZTUFI091 .
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic requirement for this demo is to display a number of *
*& fields from the EKKO table. *
*REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
form build_fieldcatalog.
There are a number of ways to create a fieldcat.
For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.
Beware though, you need to ensure that all fields required are
populated. When using some of functionality available via ALV, such as
total. You may need to provide more information than if you were
simply displaying the result
I.e. Field type may be required in-order for
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
is_variant = z_template
tables
t_outtab = it_ekko
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. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
endform. " DATA_RETRIEVAL
Form TOP-OF-PAGE *
ALV Report Header *
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
i_logo = 'Z_LOGO'.
endform.
FORM USER_COMMAND *
--> R_UCOMM *
--> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Check function code
CASE r_ucomm.
WHEN '&IC1'.
Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
*& Form BUILD_EVENTS
Build events table
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*& Form BUILD_PRINT_PARAMS
Setup print parameters
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*& Form END_OF_PAGE
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
*& Form END_OF_LIST
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform.
hope it will help you
regards
sreelatha gullapalli -
Displaying traffic lights in alv grid report?
Hi everyone,
I have an alv grid report.I m using the FM reuse_alv_grod_display to display my alv report.I am passing the fieldcatalogue automatically.I m getting the output perfectly.Now i have to add traffic lights to that alv report.
Since i m passing the fieldcatalogue automatically i m confused to display the traffic lights?
any suggestions please?
Thank you.hi dp,
look at the program i made... se the bold part you will be able to impelment lights easily,
DECLARING TYPES POOL *
All the definitions of internal tables, structures and constants
are declared in a type-pool called SLIS.
type-pools: slis.
TABLES *
tables: vbak,vbap,kna1.
TYPES *
*&--defining types for TABLE VBAK
types: begin of t_vbak,
vbeln type vbeln_va, "sales document
kunnr type kunag,
erdat type erdat,
auart type auart,
netwr type netwr_ak,
waerk type waerk,
vkorg type vkorg,
vtweg type vtweg,
spart type spart,
name1 type name1_gp,
stras type stras_gp,
ort01 type ort01_gp,
pstlz type pstlz,
regio type regio,
land1 type land1_gp,
telf1 type telf1,
end of t_vbak.
*&--Defining types for TABLE VBAP
types: begin of t_vbap,
vbeln type vbeln_va,
posnr type posnr_va,
matnr type matnr,
maktx type maktx,
end of t_vbap.
*&--MERGED FINAL SALES TABLE
types: begin of t_sales_final,
vbeln type vbeln_va,
kunnr type kunag,
posnr type posnr_va,
erdat type erdat, "date of creation
auart type auart,
netwr type netwr_ak,
waerk type waerk,
vkorg type vkorg,
vtweg type vtweg,
spart type spart,
name1 type name1_gp,
v_lights type c,
stras type stras_gp,
ort01 type ort01_gp,
pstlz type pstlz,
regio type regio,
land1 type land1_gp,
telf1 type telf1,
matnr type matnr,
maktx type maktx,
end of t_sales_final.
defining wrokarea and IT.
WORK AREA DECLARATION *
*&---work area for Internal Tables
data: wa_vbak type t_vbak.
data: wa_vbap type t_vbap.
data: wa_sales_final type t_sales_final.
*&--work area for layout
data: wa_layout type slis_layout_alv.
INTERNAL TABLES DECLARATION *
*&---Internal tables without Header Line.
data : i_vbak type standard table of t_vbak,
i_vbap type standard table of t_vbap,
i_sales_final type standard table of t_sales_final.
*&---Internal table for field catalog
data : i_fieldcat type slis_t_fieldcat_alv,
*&---Internal table for the sorting sequence.
i_sortinfo type slis_t_sortinfo_alv,
*&---Internal table for the event catalog.
i_eventcat type slis_t_event,
*&---Internal table for the top of page event
i_listheader type slis_t_listheader.
VARIABLE DECLARATION *
data : v_progname like sy-repid, "Program name(system defined)
v_gridtitle type lvc_title. "Grid Title
INITIALIZATION EVENT *
initialization.
v_progname = sy-repid.
refresh:i_vbak,
i_vbap,
i_sales_final,
i_fieldcat,
i_sortinfo,
i_eventcat,
i_listheader.
clear: wa_vbak,
wa_vbap,
wa_sales_final,
wa_layout.
SELECTION SCREEN *
SCREEN FOR ENTERING INFORMATION
selection-screen begin of block b1 with frame title text-001.
select-options: r_vbeln for wa_vbak-vbeln obligatory.
select-options: r_erdat for wa_vbak-erdat obligatory.
selection-screen end of block b1 .
AT SELECTION SCREEN *
at selection-screen.
perform zf_validate_sales_doc_no.
perform zf_validate_date.
START OF SELECTION EVENT
start-of-selection.
perform zf_populate_header.
perform zf_populate_detail.
perform zf_append_sales_final.
END OF SELECTION EVENT
end-of-selection.
*If Internal Table Is Populated Then Only Display Alv Report.
if i_sales_final is not initial.
Prepare fieldcatalog .
perform zf_build_fieldcat using i_fieldcat.
MODIFY the records IN the internal TABLE for the traffic lights.
perform zf_modify_final.
build event catalogue
perform zf_eventcat using i_eventcat.
build sorting
perform zf_sorting using i_sortinfo.
&---Build Listheader for TOP OF PAGE EVENT.
perform zf_build_listheader using i_listheader.
&---Build layout.
perform zf_layout.
&---Initializating Grid Title
perform zf_build_grid_title.
&---Display alv grid.
perform zf_display_alv_grid.
else.
*If Table is not Populated ie Records Does not exist
message 'Record Does Not Exist' type 'S'.
endif.
*& Form zf_validate_sales_doc_no
text
--> p1 text
<-- p2 text
form zf_validate_sales_doc_no .
select single vbeln into wa_vbak-vbeln from vbak where vbeln in r_vbeln .
if sy-subrc <> 0.
message i101.
endif.
endform. " zf_validate_sales_doc_no
*& Form zf_validate_date
text
--> p1 text
<-- p2 text
form zf_validate_date .
if date is future
if r_erdat-low >= sy-datum.
message e102.
elseif r_erdat-high >= sy-datum.
message e103.
endif.
endform. " zf_validate_date
*& Form zf_populate_header
text
--> p1 text
<-- p2 text
form zf_populate_header .
select vbeln
kunnr
erdat
auart
netwr
waerk
vkorg
vtweg
spart
into table i_vbak from vbak where vbeln in r_vbeln.
if sy-subrc <> 0.
message 'RECORD DOES NOT EXIST' type 'E'.
endif.
sort i_vbak by vbeln.
*&--LOGIC TO GET FIELDS FROM TABLE KNA1 INTO INTERNAL TABLE I_VBAK
loop at i_vbak into wa_vbak.
select single name1 stras ort01 pstlz regio land1 telf1 into (wa_vbak-name1,
wa_vbak-stras,
wa_vbak-ort01,
wa_vbak-pstlz,
wa_vbak-regio,
wa_vbak-land1,
wa_vbak-telf1)
from kna1
where kunnr = wa_vbak-kunnr.
modifying it_header.
modify i_vbak from wa_vbak.
clear wa_vbak.
endloop.
endform. " zf_populate_header
*& Form zf_populate_detail
text
--> p1 text
<-- p2 text
form zf_populate_detail .
if i_vbak[] is not initial.
select vbeln
posnr
matnr
into table i_vbap from vbap
for all entries in i_vbak where vbeln = i_vbak-vbeln.
endif.
sort i_vbap by vbeln.
sort i_vbap by posnr.
*&--LOGIC TO GET FIELDS FROM TABLE MAKT INTO INTERNAL TABLE I_VBAP
loop at i_vbap into wa_vbap.
select single maktx into (wa_vbap-maktx)
from makt where matnr = wa_vbap-matnr and spras = sy-langu.
modifying it_header.
modify i_vbap from wa_vbap.
clear wa_vbap.
endloop.
endform. " zf_populate_detail
*& Form zf_append_sales_final
text
--> p1 text
<-- p2 text
form zf_append_sales_final .
sort i_vbak by vbeln.
sort i_vbap by vbeln posnr.
loop at i_vbak into wa_vbak.
move-corresponding wa_vbak to wa_sales_final.
read table i_vbap with key vbeln = wa_vbak-vbeln
binary search transporting no fields.
loop at i_vbap into wa_vbap from sy-tabix.
if wa_vbap-vbeln <> wa_vbak-vbeln.
exit.
endif.
move-corresponding wa_vbap to wa_sales_final.
append wa_sales_final to i_sales_final.
endloop.
endloop.
endform. " zf_append_sales_final
*& Form zf_build_fieldcat
text
-->P_I_FIELDCAT text
form zf_build_fieldcat using p_i_fieldcat type slis_t_fieldcat_alv.
data: l_fieldcat type slis_fieldcat_alv. "local Workarea used
clear l_fieldcat.
FOR LIGHT IN COLUMN
clear l_fieldcat.
l_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'V_LIGHTS'.
" FIELD FOR WHICH CATALOG ID FILLED.
*We are passing final internal table 'I_FINAL' to l_fieldcat(local
*variable
l_fieldcat-tabname = 'I_SALES_FINAL'.
" INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
l_fieldcat-outputlen = 20.
" TO DEFINE OUTPUT LENGTH OF THE COLUMN.
append l_fieldcat to p_i_fieldcat.
FIRST COLUMN ********************************
l_fieldcat-col_pos = '2'. " POSITION OF THE COLUMN
l_fieldcat-fieldname = 'VBELN'. " FIELD FOR WHICH CATALOG ID FILLED
l_fieldcat-tabname = 'I_SALES_FINAL'. " INTERNAL TABLE BELONGS TO
l_fieldcat-key = 'X'. " SO THAT this field is not scrollable hiddable.
l_fieldcat-just = 'L'. " FOR JUSTIFICATION
*l_fieldcat-hotspot = 'X'. " MARK THIS field as hotsopt
l_fieldcat-lzero = 'X'. " OUTPUT WITH leading zeros.
l_fieldcat-seltext_l = 'Sales Document'. " long text for header.
l_fieldcat-seltext_m = 'Sales Doc'. " medium text for header.
l_fieldcat-seltext_s = 'Sales Doc'. " sort text for header.
l_fieldcat-outputlen = 20. " SET THE output length.
l_fieldcat-ref_tabname = 'VBAK'. " FOR F1 & F4 help as
append l_fieldcat to p_i_fieldcat.
clear l_fieldcat.
**************************SECOND COLUMN ********************************
*l_fieldcat-col_pos = '3'. " POSITION OF THE COLUMN
l_fieldcat-row_pos = '2'. " POSITION OF THE COLUMN
l_fieldcat-fieldname = 'POSNR'. " FIELD FOR WHICH CATALOG ID FILLED
l_fieldcat-tabname = 'I_SALES_FINAL'. " INTERNAL TABLE BELONGS TO
l_fieldcat-key = 'X'. " SO THAT this field is not scrollable hiddable.
l_fieldcat-just = 'L'. " FOR JUSTIFICATION
l_fieldcat-hotspot = 'X'. " MARK THIS field as hotsopt
l_fieldcat-lzero = 'x'. " OUTPUT WITH leading zeros.
l_fieldcat-seltext_l = 'Sales Document Item'. " long text for header.
l_fieldcat-seltext_m = 'Sales Document Item'. " medium text for header.
l_fieldcat-seltext_s = 'Sales Document Item'. " sort text for header.
l_fieldcat-outputlen = 20. " SET THE output length.
l_fieldcat-ref_tabname = 'VBAP'. " FOR F1 & F4 help as
append l_fieldcat to p_i_fieldcat.
clear l_fieldcat.
endform. " zf_build_fieldcat
*& Form zf_eventcat
text
-->P_I_EVENTCAT text
form zf_eventcat using p_i_eventcat type slis_t_event.
data: l_eventcat type slis_alv_event.
clear l_eventcat.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_i_eventcat
exceptions
list_type_wrong = 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.
TOP OF PAGE FORM
clear l_eventcat.
read table p_i_eventcat into l_eventcat with key
name = slis_ev_top_of_page.
"(COMPONENT "NAME"of structure)
if sy-subrc = 0. "if success
move 'ZF_TOP_OF_PAGE' to l_eventcat-form.
"matches name and moves form to workarea and modifies table
modify p_i_eventcat from l_eventcat index sy-tabix
transporting form.
endif.
PF_STATUS_SET FORM
clear l_eventcat.
read table p_i_eventcat into l_eventcat with key
name = slis_ev_pf_status_set.
if sy-subrc = 0.
move 'ZF_PF_STATUS_SET' to l_eventcat-form.
modify p_i_eventcat from l_eventcat index sy-tabix
transporting form.
endif.
USER_COMMAND FORM
clear l_eventcat.
read table p_i_eventcat into l_eventcat with key
name = slis_ev_user_command.
if sy-subrc = 0.
move 'ZF_USER_COMMAND' to l_eventcat-form.
modify p_i_eventcat from l_eventcat index sy-tabix
transporting form.
endif.
endform. " zf_eventcat
*& Form zf_sorting
text
-->P_I_SORTINFO text
form zf_sorting using p_i_sortinfo.
endform. " zf_sorting
*& Form zf_build_listheader
text
-->P_I_LISTHEADER text
form zf_build_listheader using p_i_listheader type slis_t_listheader.
data: l_listheader type slis_listheader.
refresh p_i_listheader.
clear l_listheader.
HEADER
l_listheader-typ = 'H'.
l_listheader-info = 'FUJITSU CONSULTING INDIA LTD.'.
append l_listheader to p_i_listheader.
SELECTION
l_listheader-typ = 'S'.
l_listheader-key = 'Date:'.
l_listheader-info = sy-datum.
append l_listheader to p_i_listheader.
ACTION
l_listheader-typ = 'A'.
*l_listheader-key =
l_listheader-info = 'SALES ORDER ALV REPORT By Rohan Malik'.
append l_listheader to p_i_listheader.
endform. " zf_build_listheader
*& Form zf_build_grid_title
text
--> p1 text
<-- p2 text
form zf_build_grid_title .
v_gridtitle = 'List of Purchase Order'.
endform. " zf_build_grid_title
*& Form zf_display_alv_grid
text
--> p1 text
<-- p2 text
form zf_display_alv_grid .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = v_progname
i_grid_title = v_gridtitle
is_layout = wa_layout
it_fieldcat = i_fieldcat
it_sort = i_sortinfo
it_events = i_eventcat
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = i_sales_final
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. " zf_display_alv_grid
*& Form zf_top_of_page
text
--> p1 text
<-- p2 text
form zf_top_of_page .
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = i_listheader
i_logo = 'ENJOYSAP_LOGO'
I_END_OF_LIST_GRID =
endform. " zf_top_of_page
*& Form zf_user_command
text
--> p1 text
<-- p2 text
form zf_user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield .
case r_ucomm. "FCODE
when 'VA03'.
read table i_sales_final into wa_sales_final index rs_selfield-tabindex.
set parameter id 'AUN' field rs_selfield-value.
call transaction 'VA03' and skip first screen .
message i102 with rs_selfield-value .
when '&IC1'. "for hotspot with VBELN, POSNR, MATNR, KUNNR.
if rs_selfield-fieldname = 'MATNR'.
set parameter id 'MAT' field rs_selfield-value.
call transaction 'MM03' and skip first screen.
return.
message i103 with rs_selfield-value .
endif.
if rs_selfield-fieldname = 'VBELN'.
set parameter id 'AUN' field rs_selfield-value.
call transaction 'VA03' and skip first screen.
return.
message i104 with rs_selfield-value .
endif.
endcase.
endform. " zf_user_command
*& Form ZF_PF_STATUS_SET
text
--> p1 text
<-- p2 text
form zf_pf_status_set using rt_extab type slis_t_extab.
set pf-status 'Z11_RM_ALV_SO'.
endform. " ZF_PF_STATUS_SET
*& Form zf_layout
text
--> p1 text
<-- p2 text
form zf_layout .
wa_layout-zebra = 'X'.
wa_layout-lights_fieldname = 'V_LIGHTS'.
wa_layout-lights_tabname = 'I_SALES_FINAL'.
" 1, 2 or 3 for red, yellow and green respectively.
endform. " zf_layout
*& Form zf_modify_final
text
--> p1 text
<-- p2 text
form zf_modify_final .
CODE TO EXECUTE LIGHTS
*start of loop
loop at i_sales_final into wa_sales_final.
*giving conditions and modifying as we want to change many rows
if wa_sales_final-netwr <= 10000.
wa_sales_final-v_lights = '1'.
modify i_sales_final from wa_sales_final transporting v_lights.
elseif wa_sales_final-netwr > 10000 and wa_sales_final-netwr <= 100000.
wa_sales_final-v_lights = '2'. " Exception.
modify i_sales_final from wa_sales_final transporting v_lights.
else.
wa_sales_final-v_lights = '3'. " Exception.
modify i_sales_final from wa_sales_final transporting v_lights.
endif.
endloop.
reward point s if helpful
rohan malik -
How to devide the top of page in alv grid display
hi all
in the alv grid display am getting the page number and total number of pages in the left hand side
but what i need is i need in the right hand side
how to get thatHi,
PLease refer to the code below:
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic requirement for this demo is to display a number of *
*& fields from the EKKO table. *
REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
* fieldcatalog-do_sum = 'X'.
* fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
* is_variant = z_template
tables
t_outtab = it_ekko
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. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
endform. " DATA_RETRIEVAL
* Form TOP-OF-PAGE *
* ALV Report Header *
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
* Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
* i_logo = 'Z_LOGO'.
endform.
* FORM USER_COMMAND *
* --> R_UCOMM *
* --> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
* Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
*& Form BUILD_EVENTS
* Build events table
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*& Form BUILD_PRINT_PARAMS
* Setup print parameters
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*& Form END_OF_PAGE
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
*& Form END_OF_LIST
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform.
Thanks,
Sriram Ponna. -
How to trigger top-of-page in ALV Grid
How to trigger Top-Of-Page in ALV Grid...
can any one plese send the sample code...
thanks.here is sample code. try this. u need to build an internal table and then call function commentary write and pass that internal table.
*& Form TOP_OF_PAGE
Top_of_page
FORM top-of-page. "#EC CALLED
*ALV Header declarations
DATA: lit_header TYPE slis_t_listheader,
lwa_header TYPE slis_listheader.
Title
lwa_header-typ = 'H'.
lwa_header-info = text-013.
APPEND lwa_header TO lit_header.
CLEAR lwa_header.
BOM Number
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = p_matnr
IMPORTING
output = gv_matnr.
Pass BOM number
lwa_header-typ = 'S'.
lwa_header-key = text-014.
lwa_header-info = gv_matnr .
APPEND lwa_header TO lit_header.
CLEAR: lwa_header ,
gv_matnr .
BOM description
lwa_header-typ = 'S'.
lwa_header-key = text-015 .
lwa_header-info = gv_maktx .
APPEND lwa_header TO lit_header.
CLEAR: lwa_header.
start/end date format MM/DD/YY
lwa_header-typ = 'S'.
lwa_header-key = text-016 .
CONCATENATE s_erdat-low+4(2) '/'
s_erdat-low+6(2) '/'
s_erdat-low(4) ' - '
s_erdat-high+4(2) '/'
s_erdat-high+6(2) '/'
s_erdat-high(4)
INTO lwa_header-info.
APPEND lwa_header TO lit_header.
CLEAR: lwa_header.
Run Date of Report format MM/DD/YY
lwa_header-typ = 'S'.
lwa_header-key = text-017 .
CONCATENATE sy-datum+4(2) '/'
sy-datum+6(2) '/'
sy-datum(4) INTO lwa_header-info .
APPEND lwa_header TO lit_header.
CLEAR: lwa_header.
call function REUSE_ALV_COMMENTARY_WRITE to use TOP_OF_PAGE event.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = lit_header.
ENDFORM . " FORM top-of-page. -
Top of page in ALV GRID display
Hi All,
Is it possible to have a top of page in ALV grid display?
If yes, then how?
Thanks and Regards,
Sirishahi
check out the following code:
report z_alv2 line-count 20.
type-pools : slis.
type-pools : icon.
tables:
lfa1, lfb1, lfm1.
selection-screen begin of block b1 with frame title text-001.
select-options:
s_lifnr for lfa1-lifnr, "VENDOR
s_bukrs for lfb1-bukrs, "COMPANY CODE
s_ekorg for lfm1-ekorg, "PURCHASING ORGANIZATION
s_ktokk for lfa1-ktokk. "ACCOUNT GROUP
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-002.
parameters: r1 radiobutton group g1,
r2 radiobutton group g1.
selection-screen end of block b2.
data:
v_repid like sy-repid,
begin of itab occurs 0,
lifnr like lfa1-lifnr,
bukrs like lfb1-bukrs,
ekorg like lfm1-ekorg,
ktokk like lfa1-ktokk,
name1 like lfa1-name1,
stras like lfa1-stras,
ort01 like lfa1-ort01,
regio like lfa1-regio,
pfort like lfa1-pfort,
pstlz like lfa1-pstlz,
pstl2 like lfa1-pstl2,
telf1 like lfa1-telf1,
end of itab.
data : itab_event type slis_t_event,
wa_event type slis_alv_event.
data : itab_fld_cat type slis_t_fieldcat_alv,
wa_fldcat type slis_fieldcat_alv.
data : wa_layout type slis_layout_alv.
start-of-selection.
*PERFORM GET_VARIANT.
PERFORM data_validation.
perform select_data.
perform get_events using itab_event .
perform fieldcatmerge.
if r1 = 'X'.
perform alvlistdisplay.
elseif r2 = 'X' .
perform alvgriddisplay.
endif.
*& Form DATA_VALIDATION
text
--> p1 text
<-- p2 text
form data_validation .
data: v_count type i.
if s_lifnr is initial and
s_bukrs is initial and
s_ekorg is initial and
s_ktokk is initial.
message e000(z13325).
Enter any value in the Selection Screen
endif.
select count(*) from lfa1 where lifnr in s_lifnr.
if sy-subrc <> 0.
message e000(z13325).
Enter any value in the Selection Screen
endif.
select count(*) from lfb1 where lifnr in s_bukrs.
if sy-subrc <> 0.
message e000(z13325).
Enter any value in the Selection Screen
endif.
select count(*) from lfm1 where lifnr in s_ekorg.
if sy-subrc <> 0.
message e000(z13325).
Enter any value in the Selection Screen
endif.
select count(*) from lfa1 where lifnr in s_ktokk.
if sy-subrc <> 0.
message e000(z13325).
Enter any value in the Selection Screen
endif.
endform. " DATA_VALIDATION
*& Form SELECT_DATA
text
--> p1 text
<-- p2 text
form select_data .
select a~lifnr
b~bukrs
c~ekorg
a~ktokk
a~name1
a~stras
a~ort01
a~regio
a~pfort
a~pstlz
a~pstl2
a~telf1
into corresponding fields of table itab
from lfa1 as a inner join lfb1 as b
on alifnr = blifnr
inner join lfm1 as c
on alifnr = clifnr
where a~lifnr in s_lifnr
and b~bukrs in s_bukrs
and c~ekorg in s_ekorg
and a~ktokk in s_ktokk.
sort itab by lifnr bukrs ekorg.
endform. " SELECT_DATA
*& Form FIELDCATMERGE
text
--> p1 text
<-- p2 text
form fieldcatmerge .
v_repid = sy-repid.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = v_repid
i_internal_tabname = 'ITAB'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = v_repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = itab_fld_cat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
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. " FIELDCATMERGE
*& Form ALVLISTDISPLAY
text
--> p1 text
<-- p2 text
form alvlistdisplay .
v_repid = sy-repid.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME =
is_layout = wa_layout
it_fieldcat = itab_fld_cat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'X'
I_SAVE = 'A'
IS_VARIANT =
it_events = itab_event
IT_EVENT_EXIT = itab_exit
IS_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. " ALVLISTDISPLAY
*& Form ALVGRIDDISPLAY
text
--> p1 text
<-- p2 text
form alvgriddisplay .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'GRID DISPLAY'
I_GRID_SETTINGS =
IS_LAYOUT = WS_LAYOUT1
it_fieldcat = itab_fld_cat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = itab_event
IT_EVENT_EXIT = itab_exit
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
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. " ALVGRIDDISPLAY
*& Form GET_EVENTS
text
--> p1 text
<-- p2 text
form get_events using itab_event type slis_t_event.
call function 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
importing
et_events = itab_event
exceptions
list_type_wrong = 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.
read table itab_event with key name = slis_ev_top_of_page into wa_event
if sy-subrc = 0.
wa_event-form = 'FRM_TOP_OF_PAGE'.
modify itab_event from wa_event index sy-tabix.
endif.
endform. " GET_EVENTS
*& Form FRM_TOP_OF_PAGE
text
form frm_top_of_page.
write : 130 'Time:' ,sy-uzeit .
write :/2 'User: ', sy-uname.
write: 59 sy-title, 130 'Page:' , sy-pagno.
write:/ 'this is swathi and this is top of page '.
endform. "FRM_TOP_OF_PAGE
Reward points if helpful.
Regards
Swathi -
Regarding END of PAGE in ALV's
hi guys,
Can you tell me which function module do i use to insert end of page in ALV's.
thanks
pavanHi Pavan,
check the format of End of page in this program.The page no will not be shown in the display,when you will take the printout you will see the content(pageno) that is written in the end of page event.
report ztest
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
form build_fieldcatalog.
There are a number of ways to create a fieldcat.
For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.
Beware though, you need to ensure that all fields required are
populated. When using some of functionality available via ALV, such as
total. You may need to provide more information than if you were
simply displaying the result
I.e. Field type may be required in-order for
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
is_variant = z_template
tables
t_outtab = it_ekko
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. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
endform. " DATA_RETRIEVAL
Form TOP-OF-PAGE *
ALV Report Header *
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
i_logo = 'Z_LOGO'.
endform.
FORM USER_COMMAND *
--> R_UCOMM *
--> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Check function code
CASE r_ucomm.
WHEN '&IC1'.
Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
*& Form BUILD_EVENTS
Build events table
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*& Form BUILD_PRINT_PARAMS
Setup print parameters
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*& Form END_OF_PAGE
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
*& Form END_OF_LIST
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform. -
How to send ALV Grid report to Email?
hai all,
How to send ALV Grid report to Email.
please its very urgent.....Hi,
when u run the Alv, u will button 'Mail Recepiant' in tool bar.When u click it and enter to new screen, go to the Recipient Tab(down) enter ur maild id and click 'Send' button on tool bar.
or.
if u want to send the Alv content to mail id thru prg, go thru the following code.
TABLES
TABLES: BSID. " Accounting: Secondary Index for Customers.
TYPE-POOLS
TYPE-POOLS: SLIS.
INTERNAL TABLES
Internal table to hold Customer data.
DATA: BEGIN OF TB_BSID OCCURS 0,
BUKRS LIKE BSID-BUKRS, " Company code
KUNNR LIKE BSID-KUNNR, " Customer number
AUGDT LIKE BSID-AUGDT, " Clearing Date
BLDAT LIKE BSID-BLDAT, " Doc date in document
SHKZG LIKE BSID-SHKZG, " Debit/credit indicator
DMBTR LIKE BSID-DMBTR, " Amount in local currency
ZFBDT LIKE BSID-ZFBDT, " Baseline date for due date calc
ZBD1T LIKE BSID-ZBD1T, " Cash discount days 1
ZBD2T LIKE BSID-ZBD2T, " Cash discount days 2
ZBD3T LIKE BSID-ZBD3T, " Net Payment Terms Period
REBZG LIKE BSID-REBZG, " No Of the Inv the Tran Belongs to
REBZT LIKE BSID-REBZT, " Follow-On Document Type
END OF TB_BSID.
Internal table to hold Open Items.
DATA: TB_BSID_OPEN LIKE TABLE OF TB_BSID WITH HEADER LINE.
Internal table to hold Cleared Items.
DATA: TB_BSAD_CLEAR LIKE TABLE OF TB_BSID WITH HEADER LINE.
Internal table to hold General Data in Customer Master
DATA: BEGIN OF TB_KNA1 OCCURS 0,
KUNNR LIKE KNA1-KUNNR, " Customer Number
NAME1 LIKE KNA1-NAME1, " Name Line 1
TELF1 LIKE KNA1-TELF1, " Telephone Number
ADRNR LIKE KNA1-ADRNR, " Address
END OF TB_KNA1.
Internal table to hold Customer Master (Company Code)
DATA: BEGIN OF TB_KNB1 OCCURS 0,
KUNNR LIKE KNB1-KUNNR, " Customer Number
BUKRS LIKE KNB1-BUKRS, " Company code
ERDAT LIKE KNB1-ERDAT, " Rec Created Date
ZAMIB LIKE KNB1-ZAMIB, " DMS Managed Indicator
END OF TB_KNB1.
Internal table to hold Final Output Data
DATA: BEGIN OF TB_FINAL OCCURS 0,
KUNNR LIKE KNA1-KUNNR, " Customer Number
NAME1 LIKE KNA1-NAME1, " Name Line 1
ADDRESS1(25) TYPE C, " Address line 1
ADDRESS2(25) TYPE C, " Address line 2
ADDRESS3(25) TYPE C, " Address line 3
ADDRESS4(25) TYPE C, " Address line 4
PHONE LIKE KNA1-TELF1, " Telephone Number
DAYS_SLOW(3) TYPE C, " Days Slow
LAST_DATE(8) TYPE C, " Date of Last Invoice
AVG(4) TYPE C, " Average Days to Pay
CURRENT(10) TYPE N, " Current
AVG_1_30(10) TYPE N, " 1-30 past due
AVG_31_60(10) TYPE N, " 31-60 past due
AVG_61_90(10) TYPE N, " 61-90 past due
AVG_90G(10) TYPE N, " 90+ past due
END OF TB_FINAL.
ALV Internal tables
DATA : TB_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, " Field Catalog
TB_EVENTS TYPE SLIS_T_EVENT, " ALV Events
TB_COMMENTS TYPE SLIS_T_LISTHEADER. " Comment
Internal tables for the sending mail data
DATA: TB_OBJPACK TYPE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,
TB_OBJHEAD TYPE SOLISTI1 OCCURS 1 WITH HEADER LINE,
TB_OBJTXT TYPE SOLISTI1 OCCURS 10 WITH HEADER LINE,
TB_RECLIST TYPE SOMLRECI1 OCCURS 5 WITH HEADER LINE,
TB_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
TB_DOC_CHNG TYPE SODOCCHGI1.
Internal table to get mail Receivers Address
DATA: TB_ZRECEIVE LIKE YSMTP_ADDRESS OCCURS 0 WITH HEADER LINE.
STRUCTURES
DATA: X_SADR TYPE SADR, " For Address
X_FIELDCAT TYPE SLIS_FIELDCAT_ALV, " For Field Catalog
X_LAYOUT TYPE SLIS_LAYOUT_ALV, " For Layout
X_EVENTS TYPE SLIS_ALV_EVENT, " For Events
X_COMMENTS TYPE SLIS_LISTHEADER, " For Comments
X_ADDR1_SEL LIKE ADDR1_SEL, " For Address
WA_FAEDE TYPE FAEDE. " For FAEDE struct
VARIABLES
DATA: G_REPID LIKE SY-REPID, " Prog ID
G_DAYS_SLOW(3) TYPE N, " Days Slow
G_OPEN TYPE I, " Counter
G_AVG(4) TYPE C, " Avg Days
G_COUNT TYPE I, " Counter
G_TITLE TYPE SOLISTI1-LINE, " Description
G_TAB_LINES TYPE SY-TABIX, " Internal data count
G_REC_COUNT TYPE I, " Total records
G_CURR_BAL TYPE N, " Account balance
G_FILE_NAME LIKE EDI_PATH-PTHNAM. " Output File Name
CONSTANTS
CONSTANTS: C_D TYPE C VALUE 'D', " Account type
C_X TYPE C VALUE 'X', " Check Value
C_0(4) TYPE N VALUE '0.00', " Constant for char
C_1(2) TYPE C VALUE '01', " Posting key const
C_H TYPE C VALUE 'H', " For Commenet-Type
C_TXT(3) TYPE N VALUE 'TXT', " File type
C_RAW(3) TYPE C VALUE 'RAW', " File type
C_DELIMITER TYPE X VALUE '09', " ASCII CODE LINE
C_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
C_INTERFACE TYPE YWFSALOFFICNOTIF-INTERFACE_ID VALUE 'AP',
C_FILENAME(20) TYPE N VALUE 'TEXT.TXT'," File name
C_TITLE(30) TYPE N VALUE 'Z21614_DB_CREDIT_AGENCY',
C_Z001 TYPE RF035-RASID VALUE 'Z001'." Net 30/60/90/120/150
SELECTION SCREEN.
Selection Screen for Selection Criteria.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
SELECT-OPTIONS: S_BUKRS FOR BSID-BUKRS OBLIGATORY, " Company Code
S_BLDAT FOR BSID-BLDAT," OBLIGATORY, " Doc Date
S_KUNNR FOR BSID-KUNNR, " Cust No
S_ZUONR FOR BSID-ZUONR. " Assignment
PARAMETERS: P_GRACE(2) TYPE N OBLIGATORY, " Grace Days
P_ZAMIB LIKE KNB1-ZAMIB AS CHECKBOX. " DMS Indicator
SELECTION-SCREEN END OF BLOCK B1.
Selection Screen for Output Options.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-T02.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 01.
PARAMETERS: P_REPORT RADIOBUTTON GROUP R1. " Report Only
SELECTION-SCREEN COMMENT 5(25) TEXT-016.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 01.
PARAMETERS: P_DOWN RADIOBUTTON GROUP R1. " Dwnld to Unix
SELECTION-SCREEN COMMENT 5(25) TEXT-017.
SELECTION-SCREEN POSITION 30.
PARAMETERS: P_FILE LIKE FILENAME-FILEINTERN DEFAULT
'Z21614_DB_CREDIT_AGENCY'. " File Name
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
Selection Screen for E-mail.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-T03.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 01.
PARAMETERS: P_EMAIL AS CHECKBOX. " E-mail
SELECTION-SCREEN COMMENT 5(25) TEXT-018.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B3.
INITIALIZATION
INITIALIZATION.
G_REPID = SY-REPID.
AT SELECTION SCREEN. *
AT SELECTION-SCREEN.
Validation of selection screen entries
perform validate_data.
START-OF-SELECTION
START-OF-SELECTION.
Select Data from Customer Master (Company Code)
PERFORM SELECT_KNB1.
Select Custmer Open Items.
PERFORM SELECT_CUSTOMER_OPEN_ITEMS.
Select Custmer Cleared Items.
PERFORM SELECT_CUSTOMER_CLEARED_ITEMS.
Select General Data in Customer Master
PERFORM SELECT_KNA1.
Populate Final Output Data.
PERFORM POPULATE_TB_FINAL.
End of selection *
END-OF-SELECTION.
If both display report and send email is checked
IF P_REPORT = C_X AND P_EMAIL = C_X.
MESSAGE E999 WITH
'Select One Among Report Only & Send E-mail'(023).
When Radiobutton for Email or if the program is run background
ELSEIF ( P_EMAIL = C_X OR SY-BATCH = C_X ).
To send the mail
PERFORM SEND_EMAIL.
ELSEIF P_REPORT = C_X .
To display the Final Output data using ALV's
PERFORM DISPLAY_ALV_REPORT.
ENDIF.
Transfering data to file when downloading to Unix
IF P_DOWN = C_X.
IF G_REC_COUNT IS INITIAL.
MESSAGE I999 WITH
'No Records Found For Selection Criteria'(024).
EXIT.
ELSE.
IF NOT G_FILE_NAME IS INITIAL.
Trasefering data to file
PERFORM TRANSFER_DATA_FILE.
Interface Audit report
PERFORM WRITE_REPORT.
ENDIF.
ENDIF.
ENDIF.
F O R M S
*& Form VALIDATE_DATA
Validating selection-screen entries
FORM VALIDATE_DATA.
Local variables
DATA : L_BUKRS LIKE BSEG-BUKRS, " For Company Code
L_KUNNR LIKE BSEG-KUNNR. " For Customer Number
Validate the Company code.
SELECT SINGLE BUKRS
INTO L_BUKRS
FROM T001
WHERE BUKRS IN S_BUKRS.
IF SY-SUBRC <> 0.
MESSAGE E999 WITH 'Enter valid Company Code'(025).
ENDIF.
Validate the Customer number
IF NOT S_KUNNR[] IS INITIAL.
SELECT SINGLE KUNNR
INTO L_KUNNR
FROM KNA1
WHERE KUNNR IN S_KUNNR.
IF SY-SUBRC <> 0.
MESSAGE E999 WITH 'Enter valid Customer Number'(026).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_DATA
*& Form SELECT_KNB1
Select Data from Customer Master (Company Code)
FORM SELECT_KNB1 .
CLEAR: TB_KNB1,
TB_KNB1[].
SELECT KUNNR
BUKRS
ERDAT
ZAMIB
FROM KNB1
INTO TABLE TB_KNB1
WHERE BUKRS IN S_BUKRS
AND KUNNR IN S_KUNNR.
IF SY-SUBRC = 0.
Sort TB_KNB1 by Customer no & Rec Created Date
SORT TB_KNB1 BY KUNNR ERDAT DESCENDING.
ENDIF.
ENDFORM. " SELECT_KNB1
*& Form SELECT_CUSTOMER_OPEN_ITEMS
Select Custmer Open Items.
FORM SELECT_CUSTOMER_OPEN_ITEMS .
CLEAR: TB_BSID,
TB_BSID[].
SELECT A~BUKRS
B~KUNNR
B~AUGDT
B~BLDAT
B~SHKZG
B~DMBTR
B~ZFBDT
B~ZBD1T
B~ZBD2T
B~ZBD3T
B~REBZG
B~REBZT
INTO TABLE TB_BSID
FROM BKPF AS A JOIN BSID AS B
ON ABUKRS = BBUKRS
AND ABELNR = BBELNR
AND AGJAHR = BGJAHR
WHERE A~BUKRS IN S_BUKRS
AND A~BLDAT IN S_BLDAT
AND B~KUNNR IN S_KUNNR
AND B~ZUONR IN S_ZUONR
AND B~BSCHL = C_1.
IF SY-SUBRC = 0.
DMS Managed Indicator = X.
IF P_ZAMIB = C_X.
LOOP AT TB_KNB1 WHERE ZAMIB = SPACE.
DELETE TB_BSID WHERE BUKRS = TB_KNB1-BUKRS
AND KUNNR = TB_KNB1-KUNNR.
ENDLOOP.
ENDIF.
Transfering Open Items from TB_BSID to TB_BSID_OPEN
TB_BSID_OPEN[] = TB_BSID[].
ENDIF.
ENDFORM. " SELECT_CUSTOMER_OPEN_ITEMS
*& Form SELECT_CUSTOMER_CLEARED_ITEMS
Select Custmer Cleared Items.
FORM SELECT_CUSTOMER_CLEARED_ITEMS .
CLEAR: TB_BSAD_CLEAR,
TB_BSAD_CLEAR[].
SELECT A~BUKRS
B~KUNNR
B~AUGDT
B~BLDAT
B~SHKZG
B~DMBTR
B~ZFBDT
B~ZBD1T
B~ZBD2T
B~ZBD3T
B~REBZG
B~REBZT
INTO TABLE TB_BSAD_CLEAR
FROM BKPF AS A JOIN BSAD AS B
ON ABUKRS = BBUKRS
AND ABELNR = BBELNR
AND AGJAHR = BGJAHR
WHERE A~BUKRS IN S_BUKRS
AND A~BLDAT IN S_BLDAT
AND B~KUNNR IN S_KUNNR
AND B~ZUONR IN S_ZUONR
AND B~BSCHL = C_1.
IF SY-SUBRC = 0.
DMS Managed Indicator = X.
IF P_ZAMIB = C_X.
LOOP AT TB_KNB1 WHERE ZAMIB = SPACE.
DELETE TB_BSID WHERE BUKRS = TB_KNB1-BUKRS
AND KUNNR = TB_KNB1-KUNNR.
ENDLOOP.
ENDIF.
Sort TB_BSID_CLEAR by Customer number
SORT TB_BSAD_CLEAR BY KUNNR.
ENDIF.
Append lines of TB_BSID_CLEAR to table TB_BSID
APPEND LINES OF TB_BSAD_CLEAR TO TB_BSID.
Sort TB_BSID by Cust num AND Doc date in document
SORT TB_BSID BY KUNNR BLDAT.
ENDFORM. " SELECT_CUSTOMER_CLEARED_ITEMS
*& Form SELECT_KNA1
Select General Data in Customer Master
FORM SELECT_KNA1.
CLEAR: TB_KNA1,
TB_KNA1[].
SELECT KUNNR
NAME1
TELF1
ADRNR
INTO TABLE TB_KNA1
FROM KNA1
WHERE KUNNR IN S_KUNNR.
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM. " SELECT_KNA1
*& Form POPULATE_TB_FINAL
Populate Final Output Data.
FORM POPULATE_TB_FINAL.
Local variable
DATA: L_DAYS_SLOW(3) TYPE N. " Days Slow
CLEAR: TB_FINAL,
TB_FINAL[].
LOOP AT TB_KNA1.
Move-corresponding TB_KNA1 to TB_FINAL.
TB_FINAL-KUNNR = TB_KNA1-KUNNR. " Customer Number
TB_FINAL-NAME1 = TB_KNA1-NAME1. " Name Line 1
TB_FINAL-PHONE = TB_KNA1-TELF1. " Telephone Number
To get Customer Address.
PERFORM GET_CUSTOMER_ADDRESS.
To get Date of Last Invoice.
READ TABLE TB_BSID WITH KEY KUNNR = TB_KNA1-KUNNR.
IF SY-SUBRC = 0.
TB_FINAL-LAST_DATE = TB_BSID-BLDAT.
ENDIF.
To get past due and current details.
PERFORM GET_PAST_DUE_CURRENT.
To get Days Slow.
CLEAR WA_FAEDE .
LOOP AT TB_BSID_OPEN WHERE KUNNR = TB_KNA1-KUNNR.
WA_FAEDE-SHKZG = TB_BSID-SHKZG.
WA_FAEDE-ZFBDT = TB_BSID-ZFBDT.
WA_FAEDE-ZBD1T = TB_BSID-ZBD1T.
WA_FAEDE-ZBD2T = TB_BSID-ZBD2T.
WA_FAEDE-ZBD3T = TB_BSID-ZBD3T.
WA_FAEDE-REBZG = TB_BSID-REBZG.
WA_FAEDE-REBZT = TB_BSID-REBZT.
WA_FAEDE-KOART = C_D.
To Determine Due Date.
CALL FUNCTION 'DETERMINE_DUE_DATE'
EXPORTING
I_FAEDE = WA_FAEDE
IMPORTING
E_FAEDE = WA_FAEDE
EXCEPTIONS
ACCOUNT_TYPE_NOT_SUPPORTED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
CLEAR WA_FAEDE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR: L_DAYS_SLOW.
L_DAYS_SLOW = SY-DATUM - WA_FAEDE-NETDT - P_GRACE.
G_DAYS_SLOW = G_DAYS_SLOW + ABS( L_DAYS_SLOW ).
G_OPEN = G_OPEN + 1.
ENDLOOP.
IF G_OPEN IS INITIAL.
TB_FINAL-DAYS_SLOW = G_DAYS_SLOW / G_OPEN. " Days Slow
ENDIF.
To get Average days to Pay.
PERFORM GET_AVG_DAYS_PAY.
Calculating total records .
G_REC_COUNT = G_REC_COUNT + 1.
APPEND TB_FINAL.
CLEAR TB_FINAL.
ENDLOOP.
Current account balance.
G_CURR_BAL = TB_FINAL-CURRENT + TB_FINAL-AVG_1_30 +
TB_FINAL-AVG_31_60 +
TB_FINAL-AVG_61_90 +
TB_FINAL-AVG_90G .
ENDFORM. " POPULATE_TB_FINAL
*& Form GET_PAST_DUE_CURRENT
To get past due and current details.
FORM GET_PAST_DUE_CURRENT.
Local Varaibles.
DATA: L_RF035_SFAE1 TYPE RF035-SFAE1,
L_RF035_SFAE2 TYPE RF035-SFAE2,
L_RF035_SFAE3 TYPE RF035-SFAE3,
L_RF035_SFAE4 TYPE RF035-SFAE4,
L_RF035_SFAE5 TYPE RF035-SFAE5,
L_RF035_SFAE6 TYPE RF035-SFAE6,
L_RF035_SFAEL TYPE RF035-SFAEL,
L_RF035_SNFA1 TYPE RF035-SNFA1,
L_RF035_SNFA2 TYPE RF035-SNFA2,
L_RF035_SNFA3 TYPE RF035-SNFA3,
L_RF035_SNFA4 TYPE RF035-SNFA4,
L_RF035_SNFA5 TYPE RF035-SNFA5,
L_RF035_SNFA6 TYPE RF035-SNFA6,
L_RF035_SNFAE TYPE RF035-SNFAE.
LOOP AT TB_KNB1 WHERE KUNNR = TB_KNA1-KUNNR.
CALL FUNCTION 'CUSTOMER_DUE_DATE_ANALYSIS'
EXPORTING
BUKRS = TB_KNB1-BUKRS
KKBER = ' '
KUNNR = TB_KNB1-KUNNR
RASID = C_Z001
IMPORTING
SFAE1 = L_RF035_SFAE1
SFAE2 = L_RF035_SFAE2
SFAE3 = L_RF035_SFAE3
SFAE4 = L_RF035_SFAE4
SFAE5 = L_RF035_SFAE5
SFAE6 = L_RF035_SFAE6
SFAEL = L_RF035_SFAEL
SNFA1 = L_RF035_SNFA1
SNFA2 = L_RF035_SNFA2
SNFA3 = L_RF035_SNFA3
SNFA4 = L_RF035_SNFA4
SNFA5 = L_RF035_SNFA5
SNFA6 = L_RF035_SNFA6
SNFAE = L_RF035_SNFAE
EXCEPTIONS
INVALID_RASTER = 1
NO_OPEN_ITEMS = 2
OTHERS = 3
IF SY-SUBRC = 0.
TB_FINAL-AVG_1_30 = TB_FINAL-AVG_1_30 + L_RF035_SFAE1.
TB_FINAL-AVG_31_60 = TB_FINAL-AVG_31_60 + L_RF035_SFAE2.
TB_FINAL-AVG_61_90 = TB_FINAL-AVG_61_90 + L_RF035_SFAE3.
TB_FINAL-AVG_90G = TB_FINAL-AVG_90G + L_RF035_SFAE4
+ L_RF035_SFAE5
+ L_RF035_SFAE6.
TB_FINAL-CURRENT = TB_FINAL-CURRENT + L_RF035_SNFAE.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
ENDFORM. " GET_PAST_DUE_CURRENT
*& Form GET_CUSTOMER_ADDRESS
To get Customer Address.
FORM GET_CUSTOMER_ADDRESS.
X_ADDR1_SEL-ADDRNUMBER = TB_KNA1-ADRNR.
CALL FUNCTION 'ADDR_GET'
EXPORTING
ADDRESS_SELECTION = X_ADDR1_SEL
IMPORTING
SADR = X_SADR
EXCEPTIONS
PARAMETER_ERROR = 1
ADDRESS_NOT_EXIST = 2
VERSION_NOT_EXIST = 3
INTERNAL_ERROR = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ADDRESS LINE 1.
TB_FINAL-ADDRESS1 = X_SADR-STRAS.
ADDRESS LINE 2.
CONCATENATE X_SADR-PFACH 'CODE' X_SADR-PSTL2 INTO TB_FINAL-ADDRESS2
SEPARATED BY SPACE.
ADDRESS LINE 3.
CONCATENATE X_SADR-ORT01 X_SADR-ORT02 ',' X_SADR-REGIO X_SADR-PSTLZ
INTO TB_FINAL-ADDRESS3 SEPARATED BY SPACE.
ADDRESS LINE 4.
TB_FINAL-ADDRESS4 = X_SADR-LAND1.
ENDFORM. " GET_CUSTOMER_ADDRESS
*& Form GET_AVG_DAYS_PAY
To get Average days to Pay.
FORM GET_AVG_DAYS_PAY.
*Local variable
DATA: L_DAYS TYPE N . " Number of Days
LOOP AT TB_BSAD_CLEAR WHERE KUNNR = TB_KNA1-KUNNR.
L_DAYS = TB_BSAD_CLEAR-AUGDT - TB_BSAD_CLEAR-BLDAT.
G_AVG = G_AVG + L_DAYS.
G_COUNT = G_COUNT + 1.
ENDLOOP.
IF NOT G_COUNT IS INITIAL.
TB_FINAL-AVG = G_AVG / G_COUNT. " Average days to Pay.
ENDIF.
ENDFORM. " GET_AVG_DAYS_PAY
*& Form DISPLAY_ALV_REPORT
text
FORM DISPLAY_ALV_REPORT.
For Populating Field Catalog.
PERFORM RPT_BUILD_FIELDCATLOG.
For Modifying Field Catalog.
PERFORM RPT_MODIFY_FIELDCATLOG.
For TOP_OF_PAGE Event.
PERFORM RPT_GET_EVENTS.
For Displaying Output in Grid Format.
PERFORM RPT_GRID_DISPLAY.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form RPT_BUILD_FIELDCATLOG
text
FORM RPT_BUILD_FIELDCATLOG.
To build the Field Catlog.
DATA : L_TABNAME TYPE SLIS_TABNAME. " Table Name
L_TABNAME = 'TB_FINAL'.
REFRESH : TB_FIELDCAT.
CLEAR : TB_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = G_REPID
I_INTERNAL_TABNAME = L_TABNAME
I_INCLNAME = G_REPID
CHANGING
CT_FIELDCAT = TB_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
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. " RPT_BUILD_FIELDCATLOG
*& Form RPT_MODIFY_FIELDCATLOG
text
FORM RPT_MODIFY_FIELDCATLOG.
Getting the Header Text for the Coloumns
DATA : L_TABIX LIKE SY-TABIX, " Index
L_DDICTXT TYPE C VALUE 'L'. " Flag
Getting the Header Text for the Coloumns
LOOP AT TB_FIELDCAT INTO X_FIELDCAT.
CLEAR L_TABIX.
L_TABIX = SY-TABIX.
CASE X_FIELDCAT-FIELDNAME.
WHEN 'KUNNR'. " Customer Number
X_FIELDCAT-SELTEXT_L = 'Customer Number'(001).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'NAME1'. " Name Line 1
X_FIELDCAT-SELTEXT_L = 'Name'(002).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'ADDRESS1'. " Address line 1
X_FIELDCAT-SELTEXT_L = 'Address 1'(003).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'ADDRESS2'. " Address line 2
X_FIELDCAT-SELTEXT_L = 'Address 2'(004).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'ADDRESS3'. " Address line 3
X_FIELDCAT-SELTEXT_L = 'Address 3'(005).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'ADDRESS4'. " Address line 4
X_FIELDCAT-SELTEXT_L = 'Address 4'(006).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'PHONE'. " Telephone Number
X_FIELDCAT-SELTEXT_L = 'Telephone Number'(007).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'DAYS_SLOW'. " Days Slow
X_FIELDCAT-SELTEXT_L = 'Days Slow'(008).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'LAST_DATE'. " Date of Last Invoice
X_FIELDCAT-SELTEXT_L = 'Date of Last Invoice'(009).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AVG'. " Average Days to Pay
X_FIELDCAT-SELTEXT_L = 'Average Days to Pay'(010).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'CURRENT'. " Current
X_FIELDCAT-SELTEXT_L = 'Aging Category 1'(011).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AVG_1_30'. " 1-30 past due
X_FIELDCAT-SELTEXT_L = 'Aging Category 2'(012).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AVG_31_60'. " 31-60 past due
X_FIELDCAT-SELTEXT_L = 'Aging Category 3'(013).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AVG_61_90'. " 61-90 past due
X_FIELDCAT-SELTEXT_L = 'Aging Category 4'(014).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AVG_90G'. " 90+ past due
X_FIELDCAT-SELTEXT_L = 'Aging Category 5'(015).
X_FIELDCAT-DDICTXT = L_DDICTXT.
ENDCASE.
MODIFY TB_FIELDCAT FROM X_FIELDCAT INDEX L_TABIX.
ENDLOOP.
ENDFORM. " RPT_MODIFY_FIELDCATLOG
*& Form RPT_GET_EVENTS
text
FORM RPT_GET_EVENTS.
DATA : L_TABIX TYPE SY-TABIX. " Index
CLEAR : TB_EVENTS,
TB_EVENTS[].
To get the events from this function module
for ALV display
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = TB_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE I999 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Modifing Top of Page event
READ TABLE TB_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO X_EVENTS.
IF SY-SUBRC = 0.
CLEAR L_TABIX.
L_TABIX = SY-TABIX.
X_EVENTS-FORM = C_TOP_OF_PAGE.
MODIFY TB_EVENTS FROM X_EVENTS INDEX L_TABIX.
CLEAR X_EVENTS.
ENDIF.
ENDFORM. " RPT_GET_EVENTS
*& Form TOP_OF_PAGE
Top Of Page for the ALV format
FORM TOP_OF_PAGE.
REFRESH TB_COMMENTS.
For heading
CLEAR X_COMMENTS.
X_COMMENTS-TYP = C_H.
X_COMMENTS-INFO = 'D&B Credit Agency Interface'(019).
APPEND X_COMMENTS TO TB_COMMENTS.
This module outputs formatted simple header information at TOP-OF-PAGE
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = TB_COMMENTS.
ENDFORM. " TOP_OF_PAGE
*& Form RPT_GRID_DISPLAY
text
FORM RPT_GRID_DISPLAY.
Layout Settings
CLEAR X_LAYOUT.
X_LAYOUT-ZEBRA = 'X'.
X_LAYOUT-COLWIDTH_OPTIMIZE = C_X.
X_LAYOUT-NO_COLHEAD = SPACE.
To Display the Output in ALV Format
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
IS_LAYOUT = X_LAYOUT
IT_FIELDCAT = TB_FIELDCAT
IT_EVENTS = TB_EVENTS
TABLES
T_OUTTAB = TB_FINAL
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. " RPT_GRID_DISPLAY
*& Form SEND_EMAIL
text
--> p1 text
<-- p2 text
FORM SEND_EMAIL.
Prepare the mail
PERFORM SEND_MAIL USING C_INTERFACE.
Sending the mail to Receivers
PERFORM SENDING_MAIL.
ENDFORM. " SEND_EMAIL
*& Form SEND_MAIL
Sending the Mail
FORM SEND_MAIL USING P_C_INTERFACE TYPE YWFSALOFFICNOTIF-INTERFACE_ID.
Populating Report name
G_TITLE = C_TITLE.
PERFORM POPULATE_EMAIL_REF_DATA USING G_TITLE.
IF NOT G_REC_COUNT IS INITIAL.
To populate the data to table tb_objbin
PERFORM POPULATE_DATA_OBJBIN.
To get the attached file for the mail
CLEAR G_TAB_LINES.
DESCRIBE TABLE TB_OBJBIN LINES G_TAB_LINES.
TB_OBJHEAD = C_FILENAME.
APPEND TB_OBJHEAD.
CLEAR TB_OBJHEAD.
Creation of the entry for the mail
TB_OBJPACK-TRANSF_BIN = C_X.
TB_OBJPACK-HEAD_START = C_1.
TB_OBJPACK-HEAD_NUM = C_1.
TB_OBJPACK-BODY_START = C_1.
TB_OBJPACK-BODY_NUM = G_TAB_LINES.
TB_OBJPACK-DOC_TYPE = C_TXT.
TB_OBJPACK-OBJ_NAME = G_REPID.
TB_OBJPACK-OBJ_DESCR = 'Interface Audit Report'(020).
TB_OBJPACK-DOC_SIZE = G_TAB_LINES * 255.
APPEND TB_OBJPACK.
ENDIF.
ENDFORM. " SEND_MAIL
*& Form SENDING_MAIL
FORM SENDING_MAIL.
Function Module to send mail along with attached file
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = TB_DOC_CHNG
TABLES
PACKING_LIST = TB_OBJPACK
OBJECT_HEADER = TB_OBJHEAD
CONTENTS_BIN = TB_OBJBIN
CONTENTS_TXT = TB_OBJTXT
RECEIVERS = TB_RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
CASE SY-SUBRC.
WHEN 0.
MESSAGE S999 WITH 'Mail has been sucessfully sent'(029).
WHEN 1.
MESSAGE S999 WITH 'Too Many Parameters'(030).
WHEN 2.
MESSAGE S999 WITH 'Doc Could Not Be Sent'(031).
WHEN 4.
MESSAGE S999 WITH 'No Authority To Send'(032).
WHEN 99.
MESSAGE S999 WITH 'Error While Sending'(033).
ENDCASE.
ENDFORM. " SENDING_MAIL
*& Form POPULATE_EMAIL_REF_DATA
Poplulating the body of the mail
FORM POPULATE_EMAIL_REF_DATA USING TEXT TYPE SOLISTI1-LINE.
Setting up Mail Subject
TB_DOC_CHNG-OBJ_DESCR = 'Interface Audit Report'(020).
Populating body of the mail
TB_OBJTXT-LINE = 'Interface Audit Report'(020).
APPEND TB_OBJTXT.
CLEAR: TB_OBJTXT.
DESCRIBE TABLE TB_OBJTXT LINES G_TAB_LINES.
READ TABLE TB_OBJTXT INDEX G_TAB_LINES.
*To determine the document size
TB_DOC_CHNG-DOC_SIZE = ( G_TAB_LINES - 1 ) * 255 + STRLEN( TB_OBJTXT ).
Creation of the entry for the Mail Contents
CLEAR TB_OBJPACK-TRANSF_BIN.
TB_OBJPACK-HEAD_START = C_1.
TB_OBJPACK-HEAD_NUM = C_0.
TB_OBJPACK-BODY_START = C_1.
TB_OBJPACK-BODY_NUM = G_TAB_LINES.
TB_OBJPACK-DOC_TYPE = C_RAW.
APPEND TB_OBJPACK.
ENDFORM. " POPULATE_EMAIL_REF_DATA
*& Form POPULATE_DATA_OBJBIN
Populating table for file attachment -
Hi All,
I am generating the report output in ALV list and downloading in the PDF format. It is working fine.
But I am not able to print last line(AS SOME TEXT) on each page of the report. I think the output of report in ALV LIST does not show the END OF PAGE, But It should show once we take print out.
Please let me know.
Waiting for reply.
Thanks,
Rakesh SinghRakesh,
END OF PAGE can be found in ALV Printout, you can't see it in Display. So if you download as PDF without printing, it is normal not to display END-OF-PAGE.
You can print your report and you can see the END-OF-PAGE in spool and maybe you can convert this spool as PDF. Otherwise you won't use END-OF-PAGE.
Look at these links, same topic:
End of page in ALV reports
ALV - END_OF_PAGE event
http://help.sap.com/saphelp_webas630/helpdata/en/ee/c8e071d52611d2b468006094192fe3/content.htm
End of Page event not triggering in ALV report -
End of page in alv list output.
Hi All,
Can any body help me out for how to show end of page in alv list output.
Thanks,
Rakesh SinghRefer this link:
http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
Regards,
Ravi -
How Alternate rows to be colored in an ALV Grid report?
How Alternate rows to be colored in an ALV Grid report?
hi,
try this
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) TYPE c, "Used to store row color attributes
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-info_fieldname = 'LINE_COLOR'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
TABLES
t_outtab = it_ekko
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. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
DATA: ld_color(1) TYPE c.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekko.
*Populate field with color attributes
LOOP AT it_ekko INTO wa_ekko.
Populate color variable with colour properties
Char 1 = C (This is a color property)
Char 2 = 3 (Color codes: 1 - 7)
Char 3 = Intensified on/off ( 1 or 0 )
Char 4 = Inverse display on/off ( 1 or 0 )
i.e. wa_ekko-line_color = 'C410'
ld_color = ld_color + 1.
Only 7 colours so need to reset color value
IF ld_color = 8.
ld_color = 1.
ENDIF.
CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
wa_ekko-line_color = 'C410'.
MODIFY it_ekko FROM wa_ekko.
ENDLOOP.
ENDFORM. " DATA_RETRIEVAL -
VF05 Report(ALV GRID REPORT) to be exported into excel without Header
Hi
I need to export the VF05 Billing due list report(ALV Grid Report) into excel with out having the Top of the page. I need to export only the bottom grid into excel sheet.
Plz help me on this. URGENTDear Chandra sekhar
Once VF05 is executed, select "List" on top left followed by "Save - File" and "Spreadsheet".
By default, the data will be downloaded into a text file. Open the file and select "Save as" and choose "Excel" and save. Now you can make changes whatever you want.
Thanks
G. Lakshmipathi -
Functionality of Checkbox in ALV Grid Report
Hi Experts,
I created a ALV grid report with the checkbox as my first coloum and other fields as shown below. Initially, my ALV report displays as below. It is working fine till here.
checkbox customer material quantity UOM Sales Order Delivery
C1 M1 1 KG
C1 M2 2 KG
C2 M1 1 KG
C2 M2 2 KG
C3 M1 1 KG
C3 M2 2 KG
C3 M3 3 KG
C4 M1 1 KG
C5 M5 1 KG
I have created a push button on application toolbar for creating sales order and delivery using bapi's. When I click on my pushbutton, as of now it creates the SO and delivery for the first customer C1 and updates my Internal table with the sales order number and delivery number. If I need to create sales order for the second customer I need to run my ALV report again and so on for 3rd, 4th and 5th customers. It is also working fine till here.
checkbox customer material quantity UOM Sales Order Delivery
C1 M1 1 KG SO1 DEL1
C1 M2 2 KG SO1 DEL1
C2 M1 1 KG
C2 M2 2 KG
C3 M1 1 KG
C3 M2 2 KG
C3 M3 3 KG
C4 M1 1 KG
C5 M5 1 KG
Need help on this:
When I select the check boxes as shown below and when I click the push button to create SO and Delivery then my program should create sales order and delivery for all the checked ones as shown below. What is the condition do I need to put here for selecting the checkbox.
checkbox customer material quantity UOM Sales Order Delivery
X C1 M1 1 KG SO1 DEL1
X C1 M2 2 KG SO1 DEL1
C2 M1 1 KG
C2 M2 2 KG
X C3 M1 1 KG SO3 DEL3
X C3 M2 2 KG SO3 DEL3
X C3 M3 3 KG SO3 DEL3
C4 M1 1 KG
X C5 M5 1 KG SO5 DEL5
I would really appreciate if somebody could help me / guide me on this. I will also post my code if someone needs to understand what I am doing exactly.
Thanks.You need to use OO ABAP
Use Class the class 1) CL_GUI_ALV_GRID, 2) CL_GUI_CUSTOM_CONTAINER
Create Sceen and container on same screen.
Check following COde it used for printing purpose.
Using AFTER_USER_COMMAND Event you will find Check box selected entries.
Capture those in another internal Table and use it for SO Creation
DATA: O_GRID TYPE REF TO CL_GUI_ALV_GRID,
O_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
T_FCAT TYPE LVC_T_FCAT,
CONTAINER(15) TYPE C VALUE 'ET_CONTAINER'.
CLASS EVENT_CLASS DEFINITION
CLASS EVENT_CLASS DEFINITION.
PUBLIC SECTION.
METHODS: BEFORE_COMMAND FOR EVENT AFTER_USER_COMMAND OF CL_GUI_ALV_GRID IMPORTING E_UCOMM,
DOUBLE_CLICK_N FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW E_COLUMN,
TOOLBAR FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID IMPORTING E_OBJECT.
ENDCLASS. "EVENT_CLASS DEFINITION
CLASS EVENT_CLASS IMPLEMENTATION
CLASS EVENT_CLASS IMPLEMENTATION.
METHOD BEFORE_COMMAND.
IF E_UCOMM = 'PRINT'.
CLEAR : W_FLAG.
T_FINAL2 = T_FINAL.
SORT T_FINAL2 BY COL_CHK .
DELETE T_FINAL2 WHERE COL_CHK = ' '.
IF NOT T_FINAL2 IS INITIAL.
LOOP AT T_FINAL2 INTO WA_FINAL.
IF W_FLAG IS INITIAL.
Does some of modification/s in control parameters
W_CONTROL_PARAM-NO_OPEN = 'X'.
W_CONTROL_PARAM-NO_CLOSE = 'X'.
W_CONTROL_PARAM-PREVIEW = 'X'.
W_CONTROL_PARAM-NO_DIALOG = SPACE.
W_OUTPUT_OPTIONS-TDNEWID = 'X'.
W_OUTPUT_OPTIONS-TDIMMED = SPACE.
Opens the smartform print-job
CALL FUNCTION 'SSF_OPEN'
EXPORTING
OUTPUT_OPTIONS = W_OUTPUT_OPTIONS
CONTROL_PARAMETERS = W_CONTROL_PARAM
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC EQ 0.
W_FLAG = 'X'.
ELSE.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
IF W_FLAG = 'X'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZFORM_BIW_PRINT'
IMPORTING
FM_NAME = LF_FM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF.
IF SY-SUBRC = 0.
CALL FUNCTION LF_FM_NAME
EXPORTING
CONTROL_PARAMETERS = W_CONTROL_PARAM
V_VBELN = WA_FINAL-VBELN
WA_FINAL = WA_FINAL.
TABLES
T_FINAL = T_FINAL.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDLOOP.
* Close the smartform print job
IF W_FLAG EQ 'X'.
CALL FUNCTION 'SSF_CLOSE'
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
OTHERS = 4.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD. "BEFORE_COMMAND
Maybe you are looking for
-
MacbookPro + External Monitor wake up from sleep
Hey, If I connect my mbp to external monitor and press sleep and then close the lid, 30% of the cases I cannot wake it up. I have all updates in Mountain Lion. Any thoughts about it? Software bug?
-
hello! i am currently working with the follow: Mac Pro 3.5GHz 6-Core intel Xeon E5 64GB RAM 1867 MHz DDR3 500GB flash storage external G RAID 8TB thunderbolt my question is regarding my photoshop performance, recently i have been working on some mass
-
When I tried to open a file, I occurred "Labview load code 9: VI version (10.0) is newer than labview version (8.5.1). In this circumstance, how can I open the file?
-
Mac mini 2.3 Ghz' all the bleu become purple
al the system things like icons and sliders become from blue to purple and the other colors didn't changed. i con see blue clearly in the display but not system things anyone know what the problem? thank's and goodnight
-
Ipod nano 7th Generation not connecting to itunes
I bought my Ipod nano in January of this year, and have been using the same computer and operating system to access Itunes since I brought it home. As of this month, whenever I try to connect my Ipod to Itunes to sync my music, it states a message co