‎2007 Aug 06 8:27 AM
‎2007 Aug 06 11:50 AM
HI
plz check this sample code
______________________________________________________
&----
*& Include Z_INITIALIZATION
&----
tables: eban,
sscrfields.
selection-screen begin of screen 100 title title.
selection-screen begin of block b1 with frame title text-t01.
parameter:rad1 radiobutton group rad user-command frad1 default 'X',
rad2 radiobutton group rad .
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-t02.
parameter: mtr as checkbox modif id g3 user-command chk1,
p_matnr type eban-matnr modif id g1,
sloc as checkbox modif id g3 user-command chk2,
str_loc type eban-lgort modif id g4.
selection-screen end of block b2.
selection-screen begin of block b3 with frame title text-t03.
select-options: matnr1 for eban-matnr modif id g2.
selection-screen end of block b3.
selection-screen pushbutton /20(10) name user-command ucom.
selection-screen end of screen 100.
name = 'FETCH'.
title = 'Test Report'.
call selection-screen '100'.
type-pools slis.
declaration of internal tables and work areas to be used
data: begin of it_pr occurs 0,
banfn type eban-banfn,
bnfpo type eban-bnfpo,
loekz type eban-loekz,
statu type eban-statu,
ekgrp type eban-ekgrp,
matnr type eban-matnr,
werks type eban-werks,
lgort type eban-lgort,
preis type eban-preis,
peinh type eban-peinh,
end of it_pr.
data: begin of it_mat occurs 0,
matnr type eban-matnr,
end of it_mat.
*DATA:BEGIN OF ITAB1 OCCURS 0,
data: l_answer.
data: it_fieldcat type slis_t_fieldcat_alv,
wa_fieldcat like line of it_fieldcat,
it_event type slis_t_event,
wa_event type slis_alv_event.
declaration of variables to be used
data: r_ucomm type sy-ucomm,
mat_no type eban-matnr,
len type i value 1,
count type i value is initial,
iflag type i value is initial,
iflag1 type i value 0.
data :pr_id type sy-repid,
rt_extab type slis_t_extab.
initialization.
pr_id = sy-repid.
&----
*& Include Z_PRE_CONDITIONS
&----
at selection-screen output.
if rad1 = 'X'.
loop at screen.
if screen-group1 = 'G1' or screen-group1 = 'G4'.
screen-active = '1'.
screen-input = 0.
elseif screen-group1 = 'G2'.
screen-active = '0'.
endif.
modify screen.
endloop.
elseif rad2 = 'X'.
loop at screen.
if screen-group1 = 'G1' or screen-group1 = 'G4' or screen-group1 = 'G3' or screen-group1 = 'G5'.
screen-active = '0'.
elseif screen-group1 = 'G2'.
screen-active = '1'.
endif.
modify screen.
endloop.
endif.
if mtr = 'X'.
loop at screen.
if screen-group1 = 'G1'.
screen-input = 1 .
endif.
modify screen.
endloop.
endif.
if sloc = 'X'.
loop at screen.
if screen-group1 = 'G4'.
screen-input = 1 .
endif.
modify screen.
endloop.
endif.
clear sy-ucomm.
iflag = 1.
endif.
at selection-screen.
PERFORM TO FETCH DATA
case sscrfields.
when 'UCOM'.
perform dataselection.
endcase.
&----
*& Form user_command
&----
text
----
-->R_UCOMM text
-->SELFIELD text
----
form user_command using r_ucomm type sy-ucomm
selfield type slis_selfield .
on the basis of the button clicked, execution of a code
case r_ucomm.
when 'SAVE'.
data: t_spopli like spopli occurs 0 with header line.
t_spopli-varoption = 'PDF'.
append t_spopli.
t_spopli-varoption = 'EXCEL'.
append t_spopli .
call function 'POPUP_TO_DECIDE_LIST'
exporting
CURSORLINE = 1
MARK_FLAG = ' '
MARK_MAX = 1
START_COL = 0
START_ROW = 0
textline1 = 'SELECT THE FORMAT OF THE OUTPUT'
TEXTLINE2 = ' '
TEXTLINE3 = ' '
titel = 'SAVE AS'
DISPLAY_ONLY = ' '
importing
answer = l_answer
tables
t_spopli = t_spopli
exceptions
not_enough_answers = 1
too_much_answers = 2
too_much_marks = 3
others = 4 .
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
perform download.
exit when back or exit button is pressed
when 'BACK'.
leave program .
when 'EXIT'.
leave program .
endcase.
endform. " user_command
end-of-selection.
&----
*& Form dataselection
&----
text
----
--> p1 text
<-- p2 text
----
form dataselection .
fetching details from database table on the basis of material number fetched.
if mtr = 'X' and sloc = 'X'.
select banfn
bnfpo
loekz
statu
ekgrp
matnr
werks
lgort
preis
peinh
from eban into table it_pr where matnr = p_matnr and lgort = str_loc .
elseif mtr = 'X'.
select banfn
bnfpo
loekz
statu
ekgrp
matnr
werks
lgort
preis
peinh
from eban into table it_pr where matnr = p_matnr.
elseif sloc = 'X'.
select banfn
bnfpo
loekz
statu
ekgrp
matnr
werks
lgort
preis
peinh
from eban into table it_pr where lgort = str_loc.
else.
message e002(zpurreq_msg).
endif.
flag to check single access of the database
if iflag = 0.
perform build_catalog.
endif.
perform build_events
perform build_events.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = 'X'
I_BUFFER_ACTIVE = ' '
i_callback_program = pr_id
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = '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 =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = it_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = it_event
IT_EVENT_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
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = it_pr
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.
perform set_pf_status using rt_extab.
endform. " dataselection
&----
*& Form set_pf_status
&----
text
----
-->P_RT_EXTAB text
-->P_TYPE text
-->P_SLIS_EXTAB text
----
form set_pf_status using p_rt_extab.
set pf-status 'Z_71945_STATUS'.
endform.
form
build_events .
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = it_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 contents of table it_event into work area
read table it_event with key name = slis_ev_top_of_page
into wa_event.
if sy-subrc eq 0.
move 'ALV_TOP_OF_PAGE' to wa_event-form.
modify it_event from wa_event index sy-tabix.
endif.
read table it_event with key name = slis_ev_end_of_list
into wa_event.
if sy-subrc eq 0.
move 'ALV_END_OF_LIST' to wa_event-form.
modify it_event from wa_event index sy-tabix.
endif.
endform. " build_events
&----
*& Form ALV_TOP_OF_PAGE
&----
text
----
form alv_top_of_page.
data:h_header type slis_t_listheader,
wa_header type slis_listheader.
building the header of the list
wa_header-typ = 'H'.
concatenate 'Purchase'
'Requisition'
into wa_header-info separated by space.
append wa_header to h_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Name:'.
wa_header-info = 'Infosys technologies limited'.
append wa_header to h_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Address:'.
wa_header-info = 'IT PARK Chandigarh'.
append wa_header to h_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'DATE:'.
concatenate sy-datum+6(2)'-'
sy-datum+4(2)'-'
sy-datum(4)
into wa_header-info.
append wa_header to h_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'TIME:'.
concatenate sy-uzeit(2)':'
sy-uzeit+2(2)':'
sy-uzeit+4(2)
into wa_header-info.
append wa_header to h_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Material Number:'.
wa_header-info = p_matnr.
append wa_header to h_header.
clear wa_header.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = h_header
i_logo = 'INFY1'.
endform. "ALV_TOP_OF_PAGE
&----
*& Form ALV_END_OF_LIST
&----
text
----
form alv_end_of_list.
building the footer
data: f_footer type slis_t_listheader,
wa_footer type slis_listheader.
wa_footer-typ = 'A'.
concatenate 'Authorized'
'Signature'
':'
into wa_footer-info separated by space.
append wa_footer to f_footer.
clear wa_footer.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = f_footer.
endform. "ALV_END_OF_LIST
&----
*& Form build_catalog
&----
text
----
--> p1 text
<-- p2 text
----
form build_catalog .
building the catalog.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'BANFN'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-seltext_l = 'PUR_REQ'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C511'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 2.
wa_fieldcat-fieldname = 'BNFPO'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '9'.
wa_fieldcat-seltext_l = 'ITEM_REQ'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C611'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 3.
wa_fieldcat-fieldname = 'LOEKZ'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '7'.
wa_fieldcat-seltext_l = 'DEL_IND'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C511'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 4.
wa_fieldcat-fieldname = 'STATU'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-seltext_l = 'PROC_STAT'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C611'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 5.
wa_fieldcat-fieldname = 'EKGRP'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-seltext_l = 'PUR_GRP'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C511'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 6.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '18'.
wa_fieldcat-seltext_l = 'MATERIAL NO'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C611'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 7.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '8'.
wa_fieldcat-seltext_l = 'PLANT'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C511'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 8.
wa_fieldcat-fieldname = 'LGORT'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-seltext_l = 'STRG_LOC'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C611'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 9.
wa_fieldcat-fieldname = 'PREIS'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-seltext_l = 'VAL_PRICE'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C511'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 10.
wa_fieldcat-fieldname = 'PEINH'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-seltext_l = 'PRICE_UNIT'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C611'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
iflag = 1.
endform. " build_catalog
&----
*& Form DOWNLOAD
&----
text
----
--> p1 text
<-- p2 text
----
form download .
if l_answer = '2'.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = 'C:\REPORT.XLS'
FILETYPE = 'ASC'
append = ' '
write_field_separator = 'X'
header = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = it_pr
FIELDNAMES =
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endif.
endform. " DOWNLOAD
regards
vijay
<b>reward points if helpful</b>
‎2007 Aug 06 11:39 AM
Hi,
For running the program in background use Tcode SM36 .
Give the program name and schedule it accordingly.
‎2007 Aug 06 11:46 AM
Hi,
It is possible. Please refer this blog:
/people/prashant.patil12/blog/2007/02/20/displaying-alv-grid-in-background-job
Reward points for helpful answers,
kiran.M
‎2007 Aug 06 11:50 AM
HI
plz check this sample code
______________________________________________________
&----
*& Include Z_INITIALIZATION
&----
tables: eban,
sscrfields.
selection-screen begin of screen 100 title title.
selection-screen begin of block b1 with frame title text-t01.
parameter:rad1 radiobutton group rad user-command frad1 default 'X',
rad2 radiobutton group rad .
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-t02.
parameter: mtr as checkbox modif id g3 user-command chk1,
p_matnr type eban-matnr modif id g1,
sloc as checkbox modif id g3 user-command chk2,
str_loc type eban-lgort modif id g4.
selection-screen end of block b2.
selection-screen begin of block b3 with frame title text-t03.
select-options: matnr1 for eban-matnr modif id g2.
selection-screen end of block b3.
selection-screen pushbutton /20(10) name user-command ucom.
selection-screen end of screen 100.
name = 'FETCH'.
title = 'Test Report'.
call selection-screen '100'.
type-pools slis.
declaration of internal tables and work areas to be used
data: begin of it_pr occurs 0,
banfn type eban-banfn,
bnfpo type eban-bnfpo,
loekz type eban-loekz,
statu type eban-statu,
ekgrp type eban-ekgrp,
matnr type eban-matnr,
werks type eban-werks,
lgort type eban-lgort,
preis type eban-preis,
peinh type eban-peinh,
end of it_pr.
data: begin of it_mat occurs 0,
matnr type eban-matnr,
end of it_mat.
*DATA:BEGIN OF ITAB1 OCCURS 0,
data: l_answer.
data: it_fieldcat type slis_t_fieldcat_alv,
wa_fieldcat like line of it_fieldcat,
it_event type slis_t_event,
wa_event type slis_alv_event.
declaration of variables to be used
data: r_ucomm type sy-ucomm,
mat_no type eban-matnr,
len type i value 1,
count type i value is initial,
iflag type i value is initial,
iflag1 type i value 0.
data :pr_id type sy-repid,
rt_extab type slis_t_extab.
initialization.
pr_id = sy-repid.
&----
*& Include Z_PRE_CONDITIONS
&----
at selection-screen output.
if rad1 = 'X'.
loop at screen.
if screen-group1 = 'G1' or screen-group1 = 'G4'.
screen-active = '1'.
screen-input = 0.
elseif screen-group1 = 'G2'.
screen-active = '0'.
endif.
modify screen.
endloop.
elseif rad2 = 'X'.
loop at screen.
if screen-group1 = 'G1' or screen-group1 = 'G4' or screen-group1 = 'G3' or screen-group1 = 'G5'.
screen-active = '0'.
elseif screen-group1 = 'G2'.
screen-active = '1'.
endif.
modify screen.
endloop.
endif.
if mtr = 'X'.
loop at screen.
if screen-group1 = 'G1'.
screen-input = 1 .
endif.
modify screen.
endloop.
endif.
if sloc = 'X'.
loop at screen.
if screen-group1 = 'G4'.
screen-input = 1 .
endif.
modify screen.
endloop.
endif.
clear sy-ucomm.
iflag = 1.
endif.
at selection-screen.
PERFORM TO FETCH DATA
case sscrfields.
when 'UCOM'.
perform dataselection.
endcase.
&----
*& Form user_command
&----
text
----
-->R_UCOMM text
-->SELFIELD text
----
form user_command using r_ucomm type sy-ucomm
selfield type slis_selfield .
on the basis of the button clicked, execution of a code
case r_ucomm.
when 'SAVE'.
data: t_spopli like spopli occurs 0 with header line.
t_spopli-varoption = 'PDF'.
append t_spopli.
t_spopli-varoption = 'EXCEL'.
append t_spopli .
call function 'POPUP_TO_DECIDE_LIST'
exporting
CURSORLINE = 1
MARK_FLAG = ' '
MARK_MAX = 1
START_COL = 0
START_ROW = 0
textline1 = 'SELECT THE FORMAT OF THE OUTPUT'
TEXTLINE2 = ' '
TEXTLINE3 = ' '
titel = 'SAVE AS'
DISPLAY_ONLY = ' '
importing
answer = l_answer
tables
t_spopli = t_spopli
exceptions
not_enough_answers = 1
too_much_answers = 2
too_much_marks = 3
others = 4 .
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
perform download.
exit when back or exit button is pressed
when 'BACK'.
leave program .
when 'EXIT'.
leave program .
endcase.
endform. " user_command
end-of-selection.
&----
*& Form dataselection
&----
text
----
--> p1 text
<-- p2 text
----
form dataselection .
fetching details from database table on the basis of material number fetched.
if mtr = 'X' and sloc = 'X'.
select banfn
bnfpo
loekz
statu
ekgrp
matnr
werks
lgort
preis
peinh
from eban into table it_pr where matnr = p_matnr and lgort = str_loc .
elseif mtr = 'X'.
select banfn
bnfpo
loekz
statu
ekgrp
matnr
werks
lgort
preis
peinh
from eban into table it_pr where matnr = p_matnr.
elseif sloc = 'X'.
select banfn
bnfpo
loekz
statu
ekgrp
matnr
werks
lgort
preis
peinh
from eban into table it_pr where lgort = str_loc.
else.
message e002(zpurreq_msg).
endif.
flag to check single access of the database
if iflag = 0.
perform build_catalog.
endif.
perform build_events
perform build_events.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = 'X'
I_BUFFER_ACTIVE = ' '
i_callback_program = pr_id
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = '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 =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = it_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = it_event
IT_EVENT_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
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = it_pr
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.
perform set_pf_status using rt_extab.
endform. " dataselection
&----
*& Form set_pf_status
&----
text
----
-->P_RT_EXTAB text
-->P_TYPE text
-->P_SLIS_EXTAB text
----
form set_pf_status using p_rt_extab.
set pf-status 'Z_71945_STATUS'.
endform.
form
build_events .
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = it_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 contents of table it_event into work area
read table it_event with key name = slis_ev_top_of_page
into wa_event.
if sy-subrc eq 0.
move 'ALV_TOP_OF_PAGE' to wa_event-form.
modify it_event from wa_event index sy-tabix.
endif.
read table it_event with key name = slis_ev_end_of_list
into wa_event.
if sy-subrc eq 0.
move 'ALV_END_OF_LIST' to wa_event-form.
modify it_event from wa_event index sy-tabix.
endif.
endform. " build_events
&----
*& Form ALV_TOP_OF_PAGE
&----
text
----
form alv_top_of_page.
data:h_header type slis_t_listheader,
wa_header type slis_listheader.
building the header of the list
wa_header-typ = 'H'.
concatenate 'Purchase'
'Requisition'
into wa_header-info separated by space.
append wa_header to h_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Name:'.
wa_header-info = 'Infosys technologies limited'.
append wa_header to h_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Address:'.
wa_header-info = 'IT PARK Chandigarh'.
append wa_header to h_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'DATE:'.
concatenate sy-datum+6(2)'-'
sy-datum+4(2)'-'
sy-datum(4)
into wa_header-info.
append wa_header to h_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'TIME:'.
concatenate sy-uzeit(2)':'
sy-uzeit+2(2)':'
sy-uzeit+4(2)
into wa_header-info.
append wa_header to h_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Material Number:'.
wa_header-info = p_matnr.
append wa_header to h_header.
clear wa_header.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = h_header
i_logo = 'INFY1'.
endform. "ALV_TOP_OF_PAGE
&----
*& Form ALV_END_OF_LIST
&----
text
----
form alv_end_of_list.
building the footer
data: f_footer type slis_t_listheader,
wa_footer type slis_listheader.
wa_footer-typ = 'A'.
concatenate 'Authorized'
'Signature'
':'
into wa_footer-info separated by space.
append wa_footer to f_footer.
clear wa_footer.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = f_footer.
endform. "ALV_END_OF_LIST
&----
*& Form build_catalog
&----
text
----
--> p1 text
<-- p2 text
----
form build_catalog .
building the catalog.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'BANFN'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-seltext_l = 'PUR_REQ'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C511'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 2.
wa_fieldcat-fieldname = 'BNFPO'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '9'.
wa_fieldcat-seltext_l = 'ITEM_REQ'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C611'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 3.
wa_fieldcat-fieldname = 'LOEKZ'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '7'.
wa_fieldcat-seltext_l = 'DEL_IND'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C511'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 4.
wa_fieldcat-fieldname = 'STATU'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-seltext_l = 'PROC_STAT'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C611'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 5.
wa_fieldcat-fieldname = 'EKGRP'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-seltext_l = 'PUR_GRP'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C511'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 6.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '18'.
wa_fieldcat-seltext_l = 'MATERIAL NO'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C611'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 7.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '8'.
wa_fieldcat-seltext_l = 'PLANT'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C511'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 8.
wa_fieldcat-fieldname = 'LGORT'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-seltext_l = 'STRG_LOC'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C611'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 9.
wa_fieldcat-fieldname = 'PREIS'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-seltext_l = 'VAL_PRICE'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C511'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-col_pos = 10.
wa_fieldcat-fieldname = 'PEINH'.
wa_fieldcat-tabname = 'eban'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-seltext_l = 'PRICE_UNIT'.
wa_fieldcat-datatype = 'C'.
wa_fieldcat-emphasize = 'C611'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
iflag = 1.
endform. " build_catalog
&----
*& Form DOWNLOAD
&----
text
----
--> p1 text
<-- p2 text
----
form download .
if l_answer = '2'.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = 'C:\REPORT.XLS'
FILETYPE = 'ASC'
append = ' '
write_field_separator = 'X'
header = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = it_pr
FIELDNAMES =
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endif.
endform. " DOWNLOAD
regards
vijay
<b>reward points if helpful</b>