I_save vaue in REuse_alv_grid_display
HI Experts,
Can anyone pl tell me wat are all the possible values of i_save in FM 'Reuse_alv_grid_display'.
PLease provide the explanation for each alphabet if possible.
Thanks
Neeraj
Hi Neeraj,
Text
Variants can be saved
Description
Controls the save mode
Prerequisite:
Parameter IS_VARIANT is filled accordingly.
See also the documentation on IMPORTING parameter IS_VARIANT.
Value range
' ' = Display variants cannot be saved
Defined display variants (such as delivered display variants) can be selected for presentation regardless of this indicator. However, changes cannot be saved.
'X' = Standard save mode
Display variants can be saved as standard display variants.
Saving display variants as user-specific is not possible.
'U' = User-specific save mode
Display variants can only be saved as user-specific.
'A' = Standard and user-specific save mode
Display variants can be saved both as user-specific and as standard
variants. Users make their choice on the dialog box for saving the
display variant.
Default
SPACE
Reward if helpful,
Pritha
Similar Messages
-
Fm REUSE_ALV_GRID_DISPLAY
I'm using this function module...
the output look like this <a href="http://img92.imageshack.us/img92/9213/pic11fc.png">[Click here]</a>
but for a reason I cannot save the customized layout. The Save option is disabled! <a href="http://img92.imageshack.us/img92/500/pic21dk.png">[ click here]</a>
anyone has the same problem?Hi
You have to set the parameter I_SAVE of fm REUSE_ALV_GRID_DISPLAY, from help:
'' = Display variants cannot be saved
Defined display variants (such as delivered display variants) can be selected for presentation regardless of this indicator. However, changes cannot be saved.
'X' = Standard save mode
Display variants can be saved as standard display variants.
Saving display variants as user-specific is not possible.
'U' = User-specific save mode
Display variants can only be saved as user-specific.
'A' = Standard and user-specific save mode
Display variants can be saved both as user-specific and as standard
variants. Users make their choice on the dialog box for saving the
display variant.
Max -
How to Restrict the users from changing the Default variant of report.
Hello everybody,
The requirement is to restrict the users to save and overwrite the default layout variant (Layout for higher managenet)set for the report, but at the same time they should be able to change and save the other layouts for which they are having access.
I have written the logic in the program which is working fine for all the scenario when we execute the report. But the logic doesnt work if the user is selecting the layout on the output screen of the report.
for e.g if the user runs the report using the layout varaint for which he is having the authorization then he gets the all 4 options so he then he can select the layout for which he is not authorized and he can overwrite.
i have debugged and check as i have found that after the report output is shown all the layout paramater is controllled by the statndard SAP objects.
Can anyone help me out in this issue.
Thankyou in advance.
*to get the default layout variant.
w_save = 'A'.
if p_vari is initial.
clear disvariant.
disvariant-report = sy-repid.
w_variant = disvariant.
call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
exporting
i_save = w_save
changing
cs_variant = w_variant
exceptions
not_found = 2.
if sy-subrc = 0.
p_vari = w_variant-variant.
endif.
endif.
*logic to check user authorization to change the layout setting.
if p_vari = c_layout.
if not sy-uname is initial.
select single * from agr_users
where agr_name = c_role
and uname = sy-uname.
if sy-subrc = 0.
w_save = 'A'.
else.
w_save = ' '.
endif.
endif.
endif.
Regards,
Satish.Hi Maine,
Thanks for your reply.
As you mentioned for your own program, you can control the parameter "I_SAVE", when calling "REUSE_ALV_GRID_DISPLAY".
so already i have use the same logic and control the parameter through I_SAVE and here i am calling method ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY instead of "REUSE_ALV_GRID_DISPLAY".
and it works fine when we execute the report but the logic doesnt work when the user tries to change and save the layout variant on the output screen of the report.
Regards,
Satish -
Hi,
I have one query that how to enhance the standard default variant (SAP&COOIS) for standard transaction COOIS.
If any one know solution pls share.
Thanks & Regards,
J.GoudHi Maine,
Thanks for your reply.
As you mentioned for your own program, you can control the parameter "I_SAVE", when calling "REUSE_ALV_GRID_DISPLAY".
so already i have use the same logic and control the parameter through I_SAVE and here i am calling method ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY instead of "REUSE_ALV_GRID_DISPLAY".
and it works fine when we execute the report but the logic doesnt work when the user tries to change and save the layout variant on the output screen of the report.
Regards,
Satish -
ALV Grid Excel in Place using REUSE_ALV_GRID_DISPLAY
I have a ALV grid displayed in a report and i have a bunch of layouts created by various users and the layouts works fine when selected. But when I use 'Excel' (excel-in-place) button to export the grid into an excel sheet, the order of the columns are all jumbled up and not in sync with the ALV grid layout on the screen. However, when I use export to local file>excel option, the order of columns are in sync with the layout. Can any one explain why this is happening and how I can fix it ? Is there any OSS note or something that I need to apply ?
PS : I am using REUSE_ALV_GRID_DISPLAY to display the report and I am building the fieldcatalog manually
Eg :
CLEAR r_fieldcatalog.
MOVE 'TB_OUTPUT' TO r_fieldcatalog-tabname.
MOVE 'BUKRS' TO r_fieldcatalog-fieldname.
MOVE 'VBAK' TO r_fieldcatalog-ref_tabname.
MOVE 'BUKRS_VF' TO r_fieldcatalog-ref_fieldname.
MOVE text-f01 TO r_fieldcatalog-seltext_s.
MOVE text-f01 TO r_fieldcatalog-seltext_m.
MOVE text-f01 TO r_fieldcatalog-seltext_l.
add '1' to lv_col_pos .
move lv_col_pos to r_fieldcatalog-col_pos .
APPEND r_fieldcatalog TO tc_fieldcatalog.
CLEAR r_fieldcatalog.
MOVE 'TB_OUTPUT' TO r_fieldcatalog-tabname.
MOVE 'VKORG' TO r_fieldcatalog-fieldname.
MOVE 'VBAK' TO r_fieldcatalog-ref_tabname.
MOVE 'VKORG' TO r_fieldcatalog-ref_fieldname.
MOVE text-f02 TO r_fieldcatalog-seltext_s.
MOVE text-f02 TO r_fieldcatalog-seltext_m.
MOVE text-f02 TO r_fieldcatalog-seltext_l.
add '1' to lv_col_pos .
move lv_col_pos to r_fieldcatalog-col_pos .
APPEND r_fieldcatalog TO tc_fieldcatalog.
Thanks in advance,
ShareenCALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_pf_status_set = 'ALV_PF_STATUS'
i_callback_program = sy-repid
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
i_default = ' '
i_save = g_save
TABLES
t_outtab = it_tab
EXCEPTIONS
program_error = 1
OTHERS = 2.
and beneath this just put a form.as its shown.
FORM alv_pf_status USING l_alv_excl TYPE STANDARD TABLE.
SET PF-STATUS 'STANDARD_FULLSCREEN' "excluding lt_extab
OF PROGRAM 'SAPLSETB'.
ENDFORM. "alv_pf_status -
Total in REUSE_ALV_GRID_DISPLAY
Hi,
If we CHECK total option in REUSE_ALV_GRID_DISPLAY we get a total of numeric value with yellow color at the bottom.
Requirement:
Let say I have 3 line item records in the display, with 20 fields and one amount field. So I get the total of the amount field. Apart from that I want the Total number of LINE ITEMS to get displayed on that line. Is that possible . How?
Thanks in Advance.Just call Reuse_alv_list_display instead of gris. Rest of functionality is same.
*& 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.
*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.
* 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' "Display column total
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_XEVENTS
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 -
Button in ALV toolbar with REUSE_ALV_GRID_DISPLAY
Hello friends,
I am Displaying ALV using REUSE_ALV_GRID_IDSPLAY. i need to add a button in grid toolbar.
i am doing it by adding a new ZSTATUS in SET PF_STATUS. but the problem is that it is removing the standard buttons.
i want to add button without removing the standard butttons.
Please help.
thanx in advance.
Krishan Kumarhai friends.......
i had tried to add custom button to the reuse_alv_grid_display.please send the coding...
REPORT ZHAJI_SAMPLE.
tables:lfa1.
TYPE-POOLS : slis.
SELECT-OPTIONS: lifnr FOR lfa1-lifnr.
types:begin of fs,
flag type c,
lifnr type lfa1-lifnr,
land1 type lfa1-land1,
name1 type lfa1-name1,
end of fs.
data: itab type table of fs,
wa type fs.
data: fcat type slis_t_fieldcat_alv,
fcat1 type slis_fieldcat_alv.
data: rt_extab type slis_t_extab.
*CONSTANTS : c_check(1) VALUE 'X'.
select lifnr land1 name1 from lfa1 into corresponding FIELDS OF table
itab where lifnr IN
lifnr.
perform sub.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'sy-repid'
I_CALLBACK_PF_STATUS_SET = 'PF'
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 = 'vendor details'
I_GRID_SETTINGS =
IS_LAYOUT = LAYOUT
IT_FIELDCAT = fcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = I_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
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.
form sub.
fcat1-fieldname = 'FLAG'.
fcat1-tabname = 'TAB'.
*fcat1-COL_POS = 1.
fcat1-checkbox = 'X'.
fcat1-edit = 'X'.
append fcat1 to fcat.
CLEAR FCAT1.
fcat1-fieldname = 'LIFNR'.
fcat1-ref_tabname = 'LFA1'.
fcat1-ref_fieldname = 'LIFNR'.
FCAT1-outputlen = 10.
append fcat1 to fcat.
CLEAR FCAT1.
fcat1-fieldname = 'NAME1'.
fcat1-ref_tabname = 'LFA1'.
fcat1-ref_fieldname = 'NAME1'.
append fcat1 to fcat.
CLEAR FCAT1.
fcat1-fieldname = 'LAND1'.
fcat1-ref_tabname = 'LFA1'.
fcat1-ref_fieldname = 'LAND1'.
append fcat1 to fcat.
CLEAR FCAT1.
endform.
form PF USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZHAJI_P1' .
ENDFORM.
just give the fine coding -
Button in alv grid cell using REUSE_ALV_GRID_DISPLAY
Hi all,
I want to make the contents of 2 columns of my alv grid as push button with values as text on it. I am not using classes or methods but alv grid fm. On clicking the button one dialog box has to pop up which gives edit option for the values in that coloumn, my question is how to introduce button in alv grid cell? if i can use t_fieldcatalog-icon, then please give me the complete steps for that.
Thanks.this may helps u
u need to copy stadard screen elemetn to MARATAB1(at PF -STATUS)
You should copy the 'STANDARD' GUI status from program <b>SAPLSLVC_FULLSCREEN</b>
type this one in SE41 program name is:<b>SAPLSLVC_FULLSCREEN</b>
status : <b>STANDARD_FULLSCREEN</b>
and copy it ...
Type-pool
type-pools slis.
Tables
tables: mara,sscrfields.
Selection screen
select-options: s_matnr for mara-matnr.
PARAMETERS: p_email TYPE somlreci1-receiver.
TYPES: BEGIN OF t_charmara,
matnr(18) TYPE c, " Material Number
ernam(12) TYPE c, " Person Credited
aenam(12) TYPE c, " Person Changed Object
pstat(15) TYPE c, " Maintenance Status
END OF t_charmara.
Data Declarations
data: rt_extab type slis_t_extab, " Table of inactive function
codes
wa_charmara TYPE t_charmara, " work area of mara Table
fs_fieldcat type slis_t_fieldcat_alv,
" Field catalog with field
descriptions
t_fieldcat like line of fs_fieldcat,
" Table of Field catalog
r_ucomm like sy-ucomm, " User Command
rs_selfield TYPE slis_selfield. " cursor position ALV
data: filedlayout type slis_layout_alv,
heading type slis_t_listheader with header line,
t_event type slis_t_event.
data: fs_event like line of t_event.
data: fs_sort type slis_sortinfo_alv,
t_sort type slis_t_sortinfo_alv.
data: w_char(200) type c,
w_matnr type mara-matnr.
fs_sort-fieldname = 'MATNR'.
fs_sort-up = 'X'.
fs_sort-group = '*'.
append fs_sort to t_sort.
clear fS_sort.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
Internal Tables
data: begin of it_mara occurs 0,
matnr like mara-matnr, " Material Number
ernam like mara-ernam, " Person Credited
aenam like mara-aenam, " Person Changed Object
pstat like mara-pstat, " Maintenance Status
end of it_mara.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
*at selection-screen on field event
AT SELECTION-SCREEN on s_matnr.
PERFORM f0100_VALIDATE_MATERIAL_NUMBER.
start-of-selection.
retrive Data from the data base table Mara
perform retrive_data_from_mara.
end-of-selection.
*Field catalog with field descriptions
perform fieldcat.
*perform top_of_page.
PERFORM EVENT_LIST.
*ALV Grid Display
perform alv_display.
Creating one Push button ENTER
perform maratab1 USING RT_EXTAB.
*& Form f0100_VALIDATE_MATERIAL_NUMBER
text
There are no interface parameters to be passed to this subroutine
FORM F0100_VALIDATE_MATERIAL_NUMBER .
select matnr " Material Number
from mara
up to 1 rows
into mara-matnr
where matnr in s_matnr.
endselect.
IF sy-subrc NE 0.
clear sscrfields-ucomm.
MESSAGE e000 WITH 'Enter valid Material number'(003).
ENDIF. " IF sy-subrc NE 0
ENDFORM. " f0100_VALIDATE_MATERIAL_NUMBER
*& Form retrive_data_from_mara
text
*There are no interface parameters to be passed to this subroutine
FORM retrive_data_from_mara .
select matnr " Material Number
ernam " Person Credited
aenam " Person Changed Object
pstat " Maintenance Status
from mara
into table It_mara
where matnr in s_matnr.
IF sy-subrc NE 0.
MESSAGE i001 WITH 'Records are not found'.
exit.
stop.
ENDIF. " IF sy-subrc NE 0
ENDFORM. " retrive_data_from_mara
*& Form fieldcat
text
*There are no interface parameters to be passed to this subroutine
FORM fieldcat .
*field catalog for MATNR
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'MATNR'.
t_fieldcat-col_pos = 1.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
*field catalog for ERNAM
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'ERNAM'.
t_fieldcat-col_pos = 2.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
*field catalog for AENAM
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'AENAM'.
t_fieldcat-col_pos = 3.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
*field catalog for PSTAT
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'PSTAT'.
t_fieldcat-col_pos = 4.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
ENDFORM. " fieldcat
*& Form EVENT_LIST
text
*There are no interface parameters to be passed to this subroutine
FORM EVENT_LIST .
fs_event-name ='TOP_OF_PAGE'.
fs_event-form = 'TOP_PAGE'.
append fs_event TO t_EVENT.
CLEAR FS_EVENT.
fs_event-name ='END_OF_PAGE'.
fs_event-form = 'END_PAGE'.
append fs_event TO t_EVENT.
CLEAR FS_EVENT.
fs_event-name ='END_OF_LIST'.
fs_event-form = 'LIST_END'.
append fs_event TO t_EVENT.
CLEAR FS_EVENT.
ENDFORM. " EVENT_LIST
*& Form alv_display
text
*There are no interface parameters to be passed to this subroutine
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'MARATAB1'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_STRUCTURE_NAME =
IS_LAYOUT =
IT_FIELDCAT = FS_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = T_SORT
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = T_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
IR_SALV_LIST_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_MARA[]
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. " alv_display
form TOP_PAGE.
data:tbl_listheader type slis_t_listheader,
wa_listheader type slis_listheader .
wa_listheader-typ = 'S'.
wa_listheader-info = 'Created by : Vijay Pawar'.
append wa_listheader to tbl_listheader.
wa_listheader-typ = 'S'.
concatenate ' Date ' sy-datum into
wa_listheader-info separated by space.
append wa_listheader to tbl_listheader.
wa_listheader-typ = 'S'.
concatenate ' From ' s_matnr-low ' To ' s_matnr-high into
wa_listheader-info separated by space.
append wa_listheader to tbl_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = tbl_listheader
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
endform. " form TOP_PAGE.
form END_PAGE.
STATICS W_PAGE TYPE I .
data:tbl_listheader type slis_t_listheader,
wa_listheader type slis_listheader .
wa_listheader-typ = 'S'.
wa_listheader-info = W_PAGE.
append wa_listheader to tbl_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = tbl_listheader
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
add 1 to w_page.
endform. " form END_PAGE.
form list_end.
data:tbl_listheader type slis_t_listheader,
wa_listheader type slis_listheader .
wa_listheader-typ = 'S'.
wa_listheader-info = '......................................Last Page'
append wa_listheader to tbl_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = tbl_listheader
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
endform. " form list_end.
*& Form maratab1
text
-->P_RT_EXTAB text
FORM maratab1 USING P_RT_EXTAB.
SET PF-STATUS 'MARATAB1' EXCLUDING rt_extab.
ENDFORM. " maratab1
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
case r_ucomm.
when 'ENTER'.
perform bulid_xls_data_table.
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email "'[email protected]'
'Example .xls documnet attachment'
'XLS'
'filename'
changing gd_error
gd_reciever.
perform populate_email_message_body.
PERFORM initiate_mail_execute_program.
endcase. " case r_ucomm.
endform. " FORM user_command
perform populate_email_message_body.
PERFORM initiate_mail_execute_program.
CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
EXPORTING
DATA_FILENAME = 'MARA.XLS'
DATA_PATH_FLAG = 'W'
DATA_ENVIRONMENT =
DATA_TABLE = ITAB[]
MACRO_FILENAME =
MACRO_PATH_FLAG = 'E'
MACRO_ENVIRONMENT =
WAIT = 'X'
DELETE_FILE = 'X'
EXCEPTIONS
NO_BATCH = 1
EXCEL_NOT_INSTALLED = 2
INTERNAL_ERROR = 3
CANCELLED = 4
DOWNLOAD_ERROR = 5
NO_AUTHORITY = 6
FILE_NOT_DELETED = 7
OTHERS = 8
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
leave to list-processing.
endcase.
*& Form bulid_xls_data_table
text
*There are no interface parameters to be passed to this subroutine
FORM bulid_xls_data_table .
CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'matnr' 'ernam' 'aenam' 'pstat'
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
LOOP AT It_mara INTO wa_charmara.
CONCATENATE wa_charmara-matnr wa_charmara-ernam
wa_charmara-aenam wa_charmara-pstat
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
ENDLOOP. " LOOP AT it_mara INTO...
ENDFORM. " bulid_xls_data_table
*& Form send_file_as_email_attachment
Send email
-->P_IT_MESSAGE text
-->P_IT_ATTACH text
-->P_P_EMAIL text
-->P_0387 text
-->P_0388 text
-->P_0389 text
-->P_0390 text
-->P_0391 text
-->P_0392 text
<--P_GD_ERROR text
<--P_GD_RECIEVER text
FORM send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
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.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM. " send_file_as_email_attachment
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test mara records'.
APPEND it_message.
endform. "form populate_email_message_bod
rewards if it helps u -
Set pf_status in REUSE_ALV_GRID_DISPLAY
Hi All,
I am using the 'i_callback_pf_status_set' from the FUNCTION 'REUSE_ALV_GRID_DISPLAY' and I see the output but the pf_status is not working. I donot see the buttin I created not even basic BACK and SAvE are working. When I activate the program I am getting the warning like '
when you pass SY-REPID DIRECTLY, "I_CALLBACK_PROGRAM" is set to the name ot the function group "REUSE_ALV_GRID_DISPLAY"'.
Please help me how to set the pf_status in the ALV.
Thanks,
Neelu.
REPORT zppprice1 .
TABLES: zppprice, kna1.
* ALV Type-Pools *
TYPE-POOLS: slis. "Global types
* ALV Structures *
* ALV layout catalog
DATA: s_alv_layout_cat TYPE slis_layout_alv.
* ALV Tables *
* ALV field catalog
DATA: it_alv_field_cat TYPE slis_t_fieldcat_alv,
*occurs 0 with header line,
i_fieldcat TYPE slis_fieldcat_alv OCCURS 0 WITH HEADER LINE,
w_fieldcat LIKE LINE OF i_fieldcat. "ALV FieldCat WorkArea
* ALV sort catalog
DATA: it_alv_sort_cat TYPE slis_sortinfo_alv OCCURS 0 WITH HEADER LINE.
* ALV event catalog
*data: it_alv_event_cat type slis_alv_event occurs 0 with header line.
DATA: it_alv_event_cat TYPE slis_t_event,
ls_alv_event TYPE slis_alv_event.
DATA: t_list_top_of_page TYPE slis_t_listheader.
TYPES: BEGIN OF slis_layout_alv.
INCLUDE TYPE slis_layout_main.
INCLUDE TYPE slis_layout_alv_spec.
TYPES: END OF slis_layout_alv.
DATA: gt_zprice TYPE TABLE OF zprice_struct,
gs_zprice TYPE zprice_struct.
DATA: chbox(1) TYPE c VALUE ' '.
*SET PF-STATUS 'LIST'.
*NEW-PAGE LINE-SIZE 158.
SELECT kunnr matnr crdate efdate sprice
eprice eohqty aohqty crmemo
FROM zppprice
INTO TABLE gt_zprice.
PERFORM field_catalog.
* Populate the layout catalog for alv
PERFORM alv_layout.
* Populate the event catalog for alv
PERFORM alv_events.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'PF_STATUS'
i_callback_user_command = 'HANDLE_USER_COMMAND'
is_layout = s_alv_layout_cat
it_fieldcat = it_alv_field_cat
i_default = 'X'
i_save = 'A'
it_events = it_alv_event_cat
TABLES
t_outtab = gt_zprice
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
FORM field_catalog.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
ls_fieldcat-fieldname = 'CHBOX'.
ls_fieldcat-checkbox = 'X'.
ls_fieldcat-input = 'X'.
ls_fieldcat-edit = 'X'.
ls_fieldcat-seltext_s = 'BOX'.
ls_fieldcat-seltext_l = 'BOX'.
APPEND ls_fieldcat TO it_alv_field_cat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'KUNNR'.
ls_fieldcat-seltext_s = 'Customer'.
ls_fieldcat-seltext_l = 'Customer'.
APPEND ls_fieldcat TO it_alv_field_cat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-seltext_s = 'Material'.
ls_fieldcat-seltext_l = 'Material'.
APPEND ls_fieldcat TO it_alv_field_cat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'CRDATE'.
ls_fieldcat-seltext_s = 'Creation date'.
ls_fieldcat-seltext_l = 'Creation date'.
APPEND ls_fieldcat TO it_alv_field_cat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'EFDATE'.
ls_fieldcat-seltext_s = 'Effective date'.
ls_fieldcat-seltext_l = 'Effective date'.
APPEND ls_fieldcat TO it_alv_field_cat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SPRICE'.
ls_fieldcat-seltext_s = 'Old Price'.
ls_fieldcat-seltext_l = 'Old Price'.
APPEND ls_fieldcat TO it_alv_field_cat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'EPRICE'.
ls_fieldcat-seltext_s = 'New Price'.
ls_fieldcat-seltext_l = 'New Price'.
APPEND ls_fieldcat TO it_alv_field_cat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'EOHQTY'.
ls_fieldcat-seltext_s = 'Est. Qty'.
ls_fieldcat-seltext_l = 'Est. Qty'.
APPEND ls_fieldcat TO it_alv_field_cat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'AOHQTY'.
ls_fieldcat-seltext_s = 'Act. Qty'.
ls_fieldcat-seltext_l = 'Act. Qty'.
APPEND ls_fieldcat TO it_alv_field_cat.
CLEAR ls_fieldcat.
ENDFORM. " field_catalog
*& Form alv_layout
* text
* --> p1 text
* <-- p2 text
FORM alv_layout.
* Enable striped output display if user wants
s_alv_layout_cat-zebra = 'X'.
* Optimize column width if user wants
s_alv_layout_cat-colwidth_optimize = 'X'.
s_alv_layout_cat-box_fieldname = space.
s_alv_layout_cat-no_input = 'X'.
ENDFORM. " alv_layout
* FORM SET_PFSTATUS *
* --> EXTAB *
FORM pf_status USING extab TYPE slis_t_extab.
SET PF-STATUS 'LIST'.
ENDFORM.
* FORM HANDLE_USER_COMMAND *
* --> I_UCOM *
* --> IS_SELFIELD *
FORM handle_user_command USING i_ucom TYPE sy-ucomm
is_selfield TYPE slis_selfield.
CASE i_ucom.
WHEN 'CMEMO'.
LOOP AT gt_zprice INTO gs_zprice WHERE chbox = 'X'.
ENDLOOP.
ENDCASE.
ENDFORM.
*& Form alv_events
* text
* --> p1 text
* <-- p2 text
FORM alv_events.
* Declare event catalog for page headers
REFRESH: it_alv_event_cat.
CLEAR ls_alv_event.
ls_alv_event-name = 'PF_STATUS_SET'.
ls_alv_event-form = 'PF_STATUS'.
APPEND ls_alv_event TO it_alv_event_cat.
* Declare event catalog for report footers
CLEAR ls_alv_event.
ls_alv_event-name = 'USER_COMMAND'.
ls_alv_event-form = 'HANDLE_USER_COMMAND'.
APPEND ls_alv_event TO it_alv_event_cat.
ENDFORM. " alv_eventsYes, do not pass SY-REPID directly, first move to a variable.
data: repid type sy-repid.
repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
i_callback_pf_status_set = 'PF_STATUS'
i_callback_user_command = 'HANDLE_USER_COMMAND'
is_layout = s_alv_layout_cat
it_fieldcat = it_alv_field_cat
i_default = 'X'
i_save = 'A'
it_events = it_alv_event_cat
TABLES
t_outtab = gt_zprice
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
Regards,
Rich Heilman -
FM REUSE_ALV_GRID_DISPLAY - runtime error
I get the following error when I use FM REUSE_ALV_GRID_DISPLAY:
"Field catalog not found".
I realize that it is looking for the parameter it_fieldcat but I don't remember ever passing that parameter before; it also says that it is optional. Below is my call to the FM. Does the addition of it_sort mean that I must pass it_fieldcat?
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* 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 =
* I_GRID_SETTINGS =
* IS_LAYOUT =
* it_fieldcat = it_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
it_sort = it_sort
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* is_print = 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_out
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
DavisDavis,
I dont know how much it will be of help to you. But this is how I used in one of my programs.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_BACKGROUND_ID = 'ALV_BACKGROUND'
I_CALLBACK_PROGRAM = G_REPID
* I_STRUCTURE_NAME = 'SFLIGHT'
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = f_cat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS = GT_SP_GROUP[]
* IT_SORT = GT_SORT[]
* IT_FILTER =
* IS_SEL_HIDE =
* i_default = g_default
I_SAVE = G_SAVE
IS_VARIANT = G_VARIANT
IT_EVENTS = GT_xEVENTS
* IT_EVENT_EXIT =
* IS_PRINT = GS_PRINT
* 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 =
TABLES
T_OUTTAB = bestand.
Regards
Aneesh. -
HOW TO USE OOBJECT ORIENTD ALV INSTED OF REUSE_ALV_GRID_DISPLAY
Pls help me to implement the object oriented ALV Insted of REUSE_ALV_GRID_DISPLAY.
Pls find the report below its working fine but we want the OBJECT ORIENTD ALV.
THNAKS
TYPE-POOLS: slis. " ALV Global types
tables:pa0001,
pa0315,
pa0007,
disvariant.
Selection-Screen
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
*SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: s_pernr FOR pa0001-pernr OBLIGATORY
. " Personnel No
SELECT-OPTIONS: s_orgeh FOR pa0001-orgeh . " Organization unit
SELECT-OPTIONS: s_werks FOR pa0001-werks. " Personnel Area
SELECT-OPTIONS: s_plans FOR pa0001-plans. " Position
SELECT-OPTIONS: s_ebeln FOR pa0315-ebeln. " Purchase order
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK b2k2 WITH FRAME TITLE text-002.
*SELECT-OPTIONS: s_var FOR disvariant-variant.
PARAMETERS: p_disva1 LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK b2k2.
Type Definition *
TYPES :
BEGIN OF ty_pa0001_pa0002,
pernr TYPE pa0001-pernr , " Personnel no.
endda TYPE pa0001-endda , " end date
begda TYPE pa0001-begda , " start date
bukrs TYPE pa0001-bukrs , " company code
werks TYPE pa0001-werks , " Personnnel area
persg TYPE pa0001-persg , " Employee group
persk TYPE pa0001-persk , " Employee subgroup
btrtl TYPE pa0001-btrtl , " Personnnel subarea
abkrs TYPE pa0001-abkrs , " Payroll area
kostl TYPE pa0001-kostl , " cost center
orgeh TYPE pa0001-orgeh , " Organizational Unit
plans TYPE pa0001-plans , " Position
nachn TYPE pa0002-nachn , " Last name
vorna TYPE pa0002-vorna , " First name
midnm TYPE pa0002-midnm , " Middle name
END OF ty_pa0001_pa0002 ,
BEGIN OF ty_pa0315,
pernr TYPE pa0315-pernr , " Personnel no.
kostl TYPE pa0315-kostl , " Sending cost center
lstar TYPE pa0315-lstar , " Activity type
werks TYPE pa0315-werks , " Plant
lifnr TYPE pa0315-lifnr , " Vendor number
ebeln TYPE pa0315-ebeln , " Sending pruchase ord
ebelp TYPE pa0315-ebelp , " Sending PO item
lstnr TYPE pa0315-lstnr , " Activity number
END OF ty_pa0315,
BEGIN OF ty_pa0007,
pernr TYPE pa0007-pernr,
schkz TYPE pa0007-schkz,
END OF ty_pa0007,
BEGIN OF ty_t527x,
orgeh TYPE t527x-orgeh,
orgtx TYPE t527x-orgtx,
END OF ty_t527x,
BEGIN OF ty_t528t,
plans TYPE t528t-plans,
plstx TYPE t528t-plstx,
END OF ty_t528t,
BEGIN OF ty_final,
pernr TYPE pa0001-pernr , " Personnel no.
nachn TYPE pa0002-nachn , " Last name
vorna TYPE pa0002-vorna , " First name
midnm TYPE pa0002-midnm , " Middle name
bukrs TYPE pa0001-bukrs , " company code
werks TYPE pa0001-werks , " Personnnel area
persg TYPE pa0001-persg , " Employee group
persk TYPE pa0001-persk , " Employee subgroup
btrtl TYPE pa0001-btrtl , " Personnnel subarea
abkrs TYPE pa0001-abkrs , " Payroll area
kostl TYPE pa0001-kostl , " cost center
orgeh TYPE pa0001-orgeh , " Organizational Unit
orgtx TYPE t527x-orgtx , " Organizational text
plans TYPE pa0001-plans , " Position
plstx TYPE t528t-plstx , " Position text
schkz TYPE pa0007-schkz , " Work schedule rule
kostl TYPE pa0315-kostl , " Sending cost center
lstar TYPE pa0315-lstar , " Activity type
werks_p TYPE pa0315-werks , " Plant
lifnr TYPE pa0315-lifnr , " Vendor number
ebeln TYPE pa0315-ebeln , " Sending pruchase ord
ebelp TYPE pa0315-ebelp , " Sending PO item
lstnr TYPE pa0315-lstnr , " Activity number
begda TYPE pa0001-begda , " start date
endda TYPE pa0001-endda , " end date
END OF ty_final.
Data Declaration *
DATA :
t_pa0001_pa0002 TYPE STANDARD TABLE OF ty_pa0001_pa0002 ,
w_pa0001_pa0002 TYPE ty_pa0001_pa0002 ,
t_pa0315 TYPE STANDARD TABLE OF ty_pa0315 ,
w_pa0315 TYPE ty_pa0315 ,
t_pa0007 TYPE STANDARD TABLE OF ty_pa0007 ,
w_pa0007 TYPE ty_pa0007 ,
t_t527x TYPE STANDARD TABLE OF ty_t527x ,
w_t527x TYPE ty_t527x ,
t_t528t TYPE STANDARD TABLE OF ty_t528t ,
w_t528t TYPE ty_t528t ,
t_final TYPE STANDARD TABLE OF ty_final ,
w_final TYPE ty_final .
START-OF-SELECTION .
SELECT a~pernr
a~endda
a~begda
a~bukrs
a~werks
a~persg
a~persk
a~btrtl
a~abkrs
a~kostl
a~orgeh
a~plans
b~nachn
b~vorna
b~midnm
INTO TABLE t_pa0001_pa0002
FROM pa0001 AS a INNER JOIN pa0002 AS b
ON apernr = bpernr
WHERE a~pernr IN s_pernr
AND a~werks IN s_werks
AND a~orgeh IN s_orgeh
AND a~plans IN s_plans.
SORT t_pa0001_pa0002 BY pernr .
IF NOT t_pa0001_pa0002[] IS INITIAL .
SELECT pernr
kostl
lstar
werks
lifnr
ebeln
ebelp
lstnr
FROM pa0315
INTO TABLE t_pa0315
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE pernr = t_pa0001_pa0002-pernr
AND kostl = t_pa0001_pa0002-kostl
AND ebeln IN s_ebeln.
SELECT pernr
schkz
FROM pa0007
INTO TABLE t_pa0007
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE pernr = t_pa0001_pa0002-pernr.
SELECT orgeh
orgtx
FROM t527x
INTO TABLE t_t527x
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE orgeh = t_pa0001_pa0002-orgeh.
SELECT plans
plstx
FROM t528t
INTO TABLE t_t528t
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE plans = t_pa0001_pa0002-plans.
ENDIF.
Merging data of t_pa0001_pa0002,t_pa0315 & t_pa0007 into t_final.
LOOP AT t_pa0001_pa0002 INTO w_pa0001_pa0002 .
MOVE-CORRESPONDING w_pa0001_pa0002 TO w_final.
READ TABLE t_pa0315 INTO w_pa0315 WITH KEY pernr =
w_pa0001_pa0002-pernr
kostl = w_pa0001_pa0002-kostl.
IF sy-subrc = 0.
w_final-kostl = w_pa0315-kostl.
w_final-lstar = w_pa0315-lstar.
w_final-werks_p = w_pa0315-werks.
w_final-lifnr = w_pa0315-lifnr.
w_final-ebeln = w_pa0315-ebeln.
w_final-ebelp = w_pa0315-ebelp.
w_final-lstnr = w_pa0315-lstnr.
ENDIF.
READ TABLE t_pa0007 INTO w_pa0007 WITH KEY pernr =
w_pa0001_pa0002-pernr.
IF sy-subrc = 0.
w_final-schkz = w_pa0007-schkz.
ENDIF.
READ TABLE t_t527x INTO w_t527x WITH KEY orgeh = w_pa0001_pa0002-orgeh
IF sy-subrc = 0.
w_final-orgtx = w_t527x-orgtx.
ENDIF.
READ TABLE t_t528t INTO w_t528t WITH KEY plans =
w_pa0001_pa0002-plans.
IF sy-subrc = 0.
w_final-plstx = w_t528t-plstx.
ENDIF.
APPEND w_final to t_final.
ENDLOOP.
PERFORM f_display_data.
FORM f_display_data.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
Build the field catalog
m_fieldcat 'PERNR' 'PA0001'.
m_fieldcat 'NACHN' 'PA0002'.
m_fieldcat 'VORNA' 'PA0002'.
m_fieldcat 'MIDNM' 'PA0002'.
m_fieldcat 'BUKRS' 'PA0001'.
m_fieldcat 'WERKS' 'PA0001'.
m_fieldcat 'PERSG' 'PA0001'.
m_fieldcat 'PERSK' 'PA0001'.
m_fieldcat 'BTRTL' 'PA0001'.
m_fieldcat 'ABKRS' 'PA0001'.
m_fieldcat 'ORGEH' 'PA0001'.
m_fieldcat 'ORGTX' 'T527X'.
m_fieldcat 'PLANS' 'PA0001'.
m_fieldcat 'PLSTX' 'T528T'.
m_fieldcat 'SCHKZ' 'PA0007'.
m_fieldcat 'KOSTL' 'PA0315'.
m_fieldcat 'LSTAR' 'PA0315'.
m_fieldcat 'WERKS' 'PA0315'.
m_fieldcat 'LIFNR' 'PA0315'.
m_fieldcat 'EBELN' 'PA0315'.
m_fieldcat 'EBELP' 'PA0315'.
m_fieldcat 'LSTNR' 'PA0315'.
m_fieldcat 'BEGDA' 'PA0001'.
m_fieldcat 'ENDDA' 'PA0001'.
ls_fieldcat-col_pos = '1'.
ls_fieldcat-fieldname = 'PERNR'.
ls_fieldcat-tabname = 't_FINAL'.
*ls_fieldcat-rollname = 'PERNR'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '2'.
ls_fieldcat-fieldname = 'NACHN'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0002'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '3'.
ls_fieldcat-fieldname = 'VORNA'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0002'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '4'.
ls_fieldcat-fieldname = 'MIDNM'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0002'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '5'.
ls_fieldcat-fieldname = 'BUKRS'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '6'.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '7'.
ls_fieldcat-fieldname = 'PERSG'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '8'.
ls_fieldcat-fieldname = 'PERSK'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '9'.
ls_fieldcat-fieldname = 'BTRTL'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '10'.
ls_fieldcat-fieldname = 'ABKRS'.
ls_fieldcat-tabname = 'T_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '11'.
ls_fieldcat-fieldname = 'ORGEH'.
ls_fieldcat-tabname = 'T_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '12'.
ls_fieldcat-fieldname = 'ORGTX'.
ls_fieldcat-tabname = 'T_FINAL'.
ls_fieldcat-ref_tabname = 'T527X'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '13'.
ls_fieldcat-fieldname = 'PLANS'.
ls_fieldcat-tabname = 'T_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '14'.
ls_fieldcat-fieldname = 'PLSTX'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'T528T'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '15'.
ls_fieldcat-fieldname = 'SCHKZ'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0007'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '16'.
ls_fieldcat-fieldname = 'KOSTL'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '17'.
ls_fieldcat-fieldname = 'LSTAR'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '18'.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '19'.
ls_fieldcat-fieldname = 'LIFNR'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '20'.
ls_fieldcat-fieldname = 'EBELN'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '21'.
ls_fieldcat-fieldname = 'EBELP'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '22'.
ls_fieldcat-fieldname = 'LSTNR'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '23'.
ls_fieldcat-fieldname = 'BEGDA'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '24'.
ls_fieldcat-fieldname = 'ENDDA'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
*DATA: v_repid TYPE sy-repid.
v_repid = sy-repid.
*Display the list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_program = v_repid
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = lt_fieldcat
TABLES
t_outtab = t_final.
ENDFORM. " F_DISPLAY_DATAHi,
<b>Sample programs on ALV Grid</b>
report zbnstest.
* TABLES AND DATA DECLARATION.
*TABLES: mara,makt.",marc.
data syrepid like sy-repid.
data sydatum(10). " LIKE sy-datum.
data sypagno(3) type n.
* WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
* GROUP (TYPE-POOLS--------->SLIS)
type-pools : slis.
* INTERNAL TABLE DECLARATION.
* INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
data: begin of t_mara occurs 0,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
matkl like mara-matkl,
end of t_mara.
* INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
data : begin of t_marc occurs 0,
matnr like mara-matnr,
werks like marc-werks,
minbe like marc-minbe.
data: end of t_marc.
* INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
data : begin of t_makt occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
spras like makt-spras,
end of t_makt.
* INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
data: begin of itab1 occurs 0,
matnr like mara-matnr,
meins like mara-meins,
maktx like makt-maktx,
spras like makt-spras,
werks like marc-werks,
minbe like marc-minbe,
end of itab1.
* THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
* AND THE LAYOUT FOR THE ALV.
* HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
* WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
* OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
* THIS IS DONE TO MAKE THE CODE SIMPLER.
* OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
* PROGRAMS.
* IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
* MORE TABLES AND CREATE A STRUCTURE
* IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
* LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
fieldlayout type slis_layout_alv.
* DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
* TOP-OF-PAGE ETC.
data : eventstab type slis_t_event with header line.
* DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
data : heading type slis_t_listheader with header line.
data : heading1 type slis_t_listheader with header line.
data : heading2 type slis_t_listheader with header line.
data : heading3 type slis_t_listheader with header line.
data : heading4 type slis_t_listheader with header line.
data : heading5 type slis_t_listheader with header line.
data : heading6 type slis_t_listheader with header line.
data : heading7 type slis_t_listheader with header line.
data : heading8 type slis_t_listheader with header line.
* STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
data : colorstruct type slis_coltypes.
* INITIALIZATION. *
initialization.
syrepid = sy-repid.
sypagno = sy-pagno.
clear fieldcatalog.
* START-OF-SELECTION. *
start-of-selection.
* SUBROUTINE TO POPULATE THE COLORSTRUCT
perform fill_colorstruct using colorstruct.
* SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
perform populate_fieldcatalog.
* SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
* INTERNAL TABLE.
perform selectdata_and_sort.
* SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
perform populate_layout using fieldlayout.
* SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
perform merge_fieldcatalog.
* SUBROUTINE TO POPULATE THE EVENTSTAB.
perform fill_eventstab tables eventstab.
* SUBROUTINE TO POPULATE THE HEADING TABLES.
perform fill_headingtable tables heading using 'HEADING'.
perform fill_headingtable tables heading1 using 'HEADING1'.
perform fill_headingtable tables heading2 using 'HEADING2'.
perform fill_headingtable tables heading3 using 'HEADING3'.
perform fill_headingtable tables heading4 using 'HEADING4'.
perform fill_headingtable tables heading5 using 'HEADING5'.
perform fill_headingtable tables heading6 using 'HEADING6'.
perform fill_headingtable tables heading7 using 'HEADING7'.
perform fill_headingtable tables heading8 using 'HEADING8'.
* SUBROUTINE TO DISPLAY THE LIST.
perform display_alv_list.
* FORMS
* IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
* OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
* COLUMN JUSTIFICATION.
form populate_fieldcatalog.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATNR' 'X' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MEINS' ' '.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MAKTX' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MTART' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATKL' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'SPRAS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'WERKS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MINBE' ' ' .
endform. " POPULATE_FIELDCATALOG
* FORM FILL_FIELDS_OF_FIELDCATALOG *
* --> FIELDCATALOG *
* --> P_TABNAME *
* --> P_FIELDNAME *
* --> P_KEY *
* --> P_KEY *
form fill_fields_of_fieldcatalog tables fieldcatalog
structure fieldcatalog
using p_tabname
p_fieldname
p_key.
* p_no_out.
fieldcatalog-tabname = p_tabname.
fieldcatalog-fieldname = p_fieldname.
fieldcatalog-key = p_key.
fieldcatalog-emphasize = '1234'.
*fieldcatalog-no_out = p_no_out.
append fieldcatalog.
endform. " FILL_FIELDSOFFIELDCATALOG
* FORM POPULATE_LAYOUT *
* --> FIELDLAYOUT *
form populate_layout using fieldlayout type slis_layout_alv.
fieldlayout-f2code = '&ETA' .
fieldlayout-zebra = 'X'.
* FOR THE WINDOW TITLE.
fieldlayout-window_titlebar = 'ALV with Events'.
fieldlayout-colwidth_optimize = 'X'.
fieldlayout-no_vline = ' '.
*fieldlayout-no_input = 'X'.
fieldlayout-confirmation_prompt = ''.
fieldlayout-key_hotspot = 'X'.
* This removes the column headings if the flag is set to 'X'
fieldlayout-no_colhead = ' '.
*fieldlayout-hotspot_fieldname = 'MAKTX'.
fieldlayout-detail_popup = 'X'.
* fieldlayout-coltab_fieldname = 'X'.
endform. " POPULATE_LAYOUT
* FORM SELECTDATA_AND_SORT *
form selectdata_and_sort.
select matnr meins mtart matkl from mara
into corresponding fields of t_mara
up to 500 rows .
select matnr maktx spras from makt
into corresponding fields of t_makt
where matnr = t_mara-matnr and
spras = sy-langu.
select matnr werks minbe from marc
into corresponding fields of t_marc
where matnr = t_mara-matnr.
append t_marc.
endselect.
append t_makt.
endselect.
append t_mara.
endselect.
perform populate_itab1.
sort itab1 by matnr.
endform. " SELECTDATA_AND_SORT
* FORM MERGE_FIELDCATALOG *
form merge_fieldcatalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = syrepid
i_internal_tabname = 'ITAB1'
* i_structure_name = 'COLORSTRUCT'
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = syrepid
changing
ct_fieldcat = fieldcatalog[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
endform. " MERGE_FIELDCATALOG
* IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
* FOLLOWS:-
* i_callback_program --> CALLING PROGRAM NAME
* i_structure_name --> STRUCTURE NAME.
* is_layout --> LAYOUT NAME.
* it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
form display_alv_list.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
* I_INTERFACE_CHECK = ' '
i_callback_program = syrepid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
i_structure_name = 'ITAB1'
is_layout = fieldlayout
it_fieldcat = fieldcatalog[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
* TOOL BAR
i_save = 'A'
* IS_VARIANT = ' '
it_events = eventstab[]
* IT_EVENT_EXIT =
* IS_PRINT =
* 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 = itab1
exceptions
program_error = 1
others = 2.
endform. " DISPLAY_ALV_LIST
*& Form POPULATE_ITAB1
* text
* --> p1 text
* <-- p2 text
form populate_itab1.
loop at t_mara.
loop at t_makt where matnr = t_mara-matnr.
loop at t_marc where matnr = t_mara-matnr.
move-corresponding t_mara to itab1.
move-corresponding t_makt to itab1.
move-corresponding t_marc to itab1.
append itab1.
endloop.
endloop.
endloop.
endform. " POPULATE_ITAB1
*& Form FILL_EVENTSTAB
* text
* -->P_EVENTSTAB text *
form fill_eventstab tables p_eventstab structure eventstab.
* WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
* INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
* AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
* EVENTS NAME.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_eventstab[]
exceptions
list_type_wrong = 1
others = 2.
* BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
* THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
* WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
* FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
* IS DYNAMICALY CALLED.
read table p_eventstab with key name = slis_ev_top_of_page.
if sy-subrc = 0 .
move 'TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_coverpage.
if sy-subrc = 0 .
move 'TOP_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_coverpage .
if sy-subrc = 0 .
move 'END_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_top_of_page.
if sy-subrc = 0 .
move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_end_of_page.
if sy-subrc = 0 .
move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_list_modify.
if sy-subrc = 0 .
move 'LIST_MODIFY' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_list.
if sy-subrc = 0 .
move 'TOP_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_page.
if sy-subrc = 0 .
move 'END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_list .
if sy-subrc = 0 .
move 'END_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
endform. " FILL_EVENTSTAB
*& Form FILL_HEADINGTABLE
* text
* -->P_HEADING text *
form fill_headingtable tables p_heading structure heading
using tablename.
case tablename.
when 'HEADING'.
p_heading-typ = 'H'.
concatenate
' REPORT NAME:-' syrepid
' ABB Industry Pte Ltd' into p_heading-info.
append p_heading.
write sy-datum using edit mask '__/__/____' to sydatum.
concatenate
' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
into p_heading-info.
append p_heading.
when 'HEADING1'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-COVER-PAGE'.
append p_heading.
when 'HEADING2'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-COVER-PAGE'.
append p_heading.
when 'HEADING3'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
append p_heading.
when 'HEADING4'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-END-OF-PAGE'.
append p_heading.
* WHEN 'HEADING5'.
* P_HEADING-TYP = 'H'.
* P_HEADING-INFO = 'LIST-MODIFY'.
* APPEND P_HEADING.
when 'HEADING6'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-PAGE'.
append p_heading.
when 'HEADING7'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-LIST'.
append p_heading.
when 'HEADING8'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-LIST'.
append p_heading.
endcase.
endform. " FILL_HEADINGTABLE
* FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading[]
exceptions
others = 1.
endform.
*& Form FILL_COLORSTRUCT
* text
* -->P_COLORSTRUCT text *
form fill_colorstruct using p_colorstruct type slis_coltypes .
p_colorstruct-heacolfir-col = 6.
p_colorstruct-heacolfir-int = 1.
p_colorstruct-heacolfir-inv = 1.
endform. " FILL_COLORSTRUCT
* FORM TOP_OF_COVERPAGE *
form top_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading1[]
exceptions
others = 1.
endform.
* FORM END_OF_COVERPAGE *
form end_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading2[]
exceptions
others = 1.
endform.
* FORM FOREIGN_TOP_OF_PAGE *
form foreign_top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading3[]
exceptions
others = 1.
endform.
* FORM FOREIGN_END_OF_PAGE *
form foreign_end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading4[]
exceptions
others = 1.
endform.
* FORM LIST_MODIFY *
*FORM LIST_MODIFY.
* CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
* EXPORTING
* IT_LIST_COMMENTARY = HEADING5[]
* EXCEPTIONS
* OTHERS = 1.
*ENDFORM.
* FORM END_OF_PAGE *
form end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading6[]
exceptions
others = 1.
endform.
* FORM END_OF_LIST *
form end_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading7[]
exceptions
others = 1.
endform.
* FORM TOP_OF_LIST *
form top_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading8[]
exceptions
others = 1.
endform.
*--- End of Program
Regards
Sudheer -
'Reuse_alv_grid_display' - how to enable save layout button
Hi,
am not getting the option 'save layout' button in my ALV. I have tried the following code.
s_layout-colwidth_optimize = c_on.
s_layout-zebra = c_on.
s_variant-report = sy-repid.
s_variant-username = sy-uname.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = s_layout
it_fieldcat = t_fieldcat
is_variant = s_variant
is_save = 'A'
TABLES
t_outtab = rt_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
Please help.Dear Arvind,
If you are using "REUSE_ALV_GRID_DISPLAY" and not passing "I_CALLBACK_PROGRAM = SY-REPID", You will not be able to save layout.
So I request all to pass following parameters to save layout.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
I_SAVE = 'X'
IS_VARIANT = 'X'
TABLES
T_OUTTAB = IT_DATA
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
With Regards,
Tushar Trivedi. -
REUSE_ALV_GRID_DISPLAY == How to add a new line?
Hello SDN community,
I'm using the "REUSE_ALV_GRID_DISPLAY" function with "i_save = 'X'". How can I solve the following problem: I want to insert a new line into the ALV and after a click on the SAVE Button, the internal table should have this new line too?
Best regards,
Marius Klaus
[click for an example picture|http://pic-hoster.net/upload/0a8b8c5c7a38434f4e0010ceb7f6fbe7.jpg]
Edited by: Marius Klaus on Nov 30, 2009 4:00 PMon the click of add button(for adding an line in grid_display) write the following code.
t_user_input is the table to be displayed in ALV_GRID.
DATA : ob_ref_grid TYPE REF TO cl_gui_alv_grid.
READ TABLE t_user_input INTO e_user_input INDEX 1 .
MODIFY e_user_input(as per user's requirement)
APPEND e_user_input TO t_user_input.
CALL METHOD ob_ref_grid->check_changed_data .
CALL METHOD ob_ref_grid->refresh_table_display.
Regards,
Shekhar -
Reg: ALV (REUSE_ALV_GRID_DISPLAY)
Hi Experts,
I need to know how to give drop down list in one of the field in my ALV.
I found some posting in sdn, but that are related to OOPS concepts.
But i am using REUSE function module.
Can you please provide me the solution how to achecive drop down list in ALV using REUSE_ALV_GRID_DISPLAY.
Thanks
Vijay.RHi Vijayendran,
There is only oops method available to create drop down list in ALV.
Go through the program below and modify your program accordingly.
Only thing that you have to do is to create container for your alv and use this container for displaying drop down list.
This program displays a dropdown list in one of the fields of the ALV.
*& Report Z_LISTBOX_ALV
*& Program to display a dropdown list in ALV.
REPORT z_listbox_alv.
TYPE-POOLS: slis.
TYPES: BEGIN OF ty_rating,
task(20) TYPE c,
rating TYPE i,
weightage(2) TYPE c,
comments(40) TYPE c,
END OF ty_rating.
DATA: g_alvgrid TYPE REF TO cl_gui_alv_grid,
g_alv_container TYPE REF TO cl_gui_custom_container,
int_fieldcat TYPE lvc_t_fcat,
ok_code TYPE sy-ucomm.
DATA: int_outputdata TYPE TABLE OF ty_rating.
INITIALIZATION.
START-OF-SELECTION.
* call new screen for displaying the oop alv
CALL SCREEN 1100.
* Double click on the screen, it takes you the screen painter (SE51). Create
* Custom Container on the screen and name is as u2018CONTAINERu2019. Set the Ok-Code
* the screen as u2018OK_CODEu2019. Also create a GUI status named 'STANDARD' and
* in set Ok-code '&F03' for the back button.
* The screen 1100 thus gets created to hold the grid ALV.
* In the PBO of the screen, call the modules to set pf-status, title and
* to display the ALV list.
* In case we have an interactive ALV or for additional functionalities we can
* create OK-CODES and based on the user command we do the coding in the PAI.
*& Module STATUS_0600 OUTPUT
* set the PF status of the screen. Called in PBO of screen.
MODULE status_0600 OUTPUT.
SET PF-STATUS 'STANDARD'.
ENDMODULE. " STATUS_0600 OUTPUT
*& Module DISPLAY_ALV OUTPUT
* Displays the alv list. Called in PBO of screen.
MODULE display_alv OUTPUT.
* get the data.
PERFORM retrieve_data.
* prepare fieldcatalog for displaying the alv
PERFORM prepare_fieldcatalog.
* create a container to display the list
CREATE OBJECT g_alv_container
EXPORTING
container_name = 'CONTAINER'.
* create a reference for the alv
CREATE OBJECT g_alvgrid
EXPORTING
i_parent = g_alv_container.
* prepare a listbox for the rating column
PERFORM fill_dropdown.
* call the method to display the list
CALL METHOD g_alvgrid->set_table_for_first_display
EXPORTING
i_bypassing_buffer = 'X'
i_save = 'X'
CHANGING
it_outtab = int_outputdata
it_fieldcatalog = int_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 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.
ENDMODULE. "DISPLAY_ALV OUTPUT
*& Form PREPARE_FIELDCATALOG
* prepares fieldcatalog
FORM prepare_fieldcatalog .
DATA: lws_fieldcat TYPE lvc_s_fcat.
CLEAR int_fieldcat.
CLEAR lws_fieldcat.
lws_fieldcat-col_pos = 1.
lws_fieldcat-fieldname = 'TASK'.
lws_fieldcat-scrtext_m = 'TASK'.
APPEND lws_fieldcat TO int_fieldcat.
CLEAR lws_fieldcat.
lws_fieldcat-col_pos = 2.
lws_fieldcat-fieldname = 'RATING'.
lws_fieldcat-edit = 'X'.
lws_fieldcat-scrtext_m = 'RATING'.
lws_fieldcat-just = 'L'.
lws_fieldcat-outputlen = '6'.
lws_fieldcat-drdn_hndl = '1'. "handle for listbox
APPEND lws_fieldcat TO int_fieldcat.
CLEAR lws_fieldcat.
lws_fieldcat-col_pos = 3.
lws_fieldcat-fieldname = 'WEIGHTAGE'.
lws_fieldcat-scrtext_m = 'WEIGHTAGE'.
lws_fieldcat-outputlen = '9'.
APPEND lws_fieldcat TO int_fieldcat.
CLEAR lws_fieldcat.
lws_fieldcat-col_pos = 4.
lws_fieldcat-fieldname = 'COMMENTS'.
lws_fieldcat-scrtext_m = 'COMMENTS'.
lws_fieldcat-edit = 'X'.
APPEND lws_fieldcat TO int_fieldcat.
ENDFORM. " PREPARE_FIELDCATALOG
*& Form RETRIEVE_DATA
* retreives the data to be displayed
FORM retrieve_data .
DATA: lws_outputdata TYPE ty_rating.
CLEAR int_outputdata.
CLEAR lws_outputdata.
lws_outputdata-task = 'proj. related'.
lws_outputdata-weightage = '20'.
APPEND lws_outputdata TO int_outputdata.
CLEAR lws_outputdata.
lws_outputdata-task = 'process. related'.
lws_outputdata-weightage = '10'.
APPEND lws_outputdata TO int_outputdata.
CLEAR lws_outputdata.
lws_outputdata-task = 'knowledge mgnt.'.
lws_outputdata-weightage = '30'.
APPEND lws_outputdata TO int_outputdata.
ENDFORM. " RETRIEVE_DATA
*& Form FILL_DROPDOWN
* prepares the listbox to be displayed and assigns it to the alv
FORM fill_dropdown .
DATA: lint_dropdown TYPE lvc_t_drop,
lws_dropdown TYPE lvc_s_drop.
CLEAR lint_dropdown.
CLEAR lws_dropdown.
lws_dropdown-handle = '1'.
lws_dropdown-value = '5'.
APPEND lws_dropdown TO lint_dropdown.
CLEAR lws_dropdown.
lws_dropdown-handle = '1'.
lws_dropdown-value = '4'.
APPEND lws_dropdown TO lint_dropdown.
CLEAR lws_dropdown.
lws_dropdown-handle = '1'.
lws_dropdown-value = '3'.
APPEND lws_dropdown TO lint_dropdown.
CLEAR lws_dropdown.
lws_dropdown-handle = '1'.
lws_dropdown-value = '2'.
APPEND lws_dropdown TO lint_dropdown.
CLEAR lws_dropdown.
lws_dropdown-handle = '1'.
lws_dropdown-value = '1'.
APPEND lws_dropdown TO lint_dropdown.
CALL METHOD g_alvgrid->set_drop_down_table
EXPORTING
it_drop_down = lint_dropdown.
ENDFORM. " FILL_DROPDOWN
*& Module HANDLE_GOBACK INPUT
* handles 'back' button. Called in PAI of the screen.
MODULE handle_goback INPUT.
IF ok_code EQ '&F03'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE.
Get back to me for any clarification.
Regards,
Bhavesh -
Reg: REUSE_ALV_GRID_DISPLAY
Hi Friends,
I am using REUSE_ALV_GRID_DISPLAY Function Module to display the report.I need SAVE button Should be enabled.
I have done coding as below.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'DELETE_ENTRIES'
i_callback_pf_status_set = 'SET_PF_STATUS'
is_layout = ls_layout
it_fieldcat = i_fieldcat[]
i_save = 'A'
TABLES
t_outtab = i_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.
Pls. give me suugestion how can i achieve the save button should enable.CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'DELETE_ENTRIES'
i_callback_pf_status_set = 'SET_PF_STATUS'
is_layout = ls_layout
it_fieldcat = i_fieldcat[]
i_save = 'A'
TABLES
t_outtab = i_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.
add a subroutine with name 'SET_PF_STATUS'
form SET_PF_STATUS.
set pf-status 'MYSTATUS'.
endform.
Create a status MYSTATUS by copying the STANDARD status of the program and standard alv example and then add save button on the application toolbar for the MYSTATUS pf-status.
Regards,
Ravi
Maybe you are looking for
-
I had a iPhone 3G and I change it in to a iPhone 4G 32GB! I have 3 apple ID account. The one I used is <edited by host> and I know my password but it ask me for my security question and I forgot it! It send a veify email the answer the an email to <e
-
How to create a BI report overview page like ESS overview page.
Hi Experts, I am implimenting FPN environment with BI portal.I have lot of BI reports in my system.now i would like to create a overview page to combine all BI reports in to one page Like our ESS overview page.can any body pleae suggest me? Thanks ,
-
My iPhone screen is locked and is saying it is not backed up, it says that it needs to be plugged in, locked and connected to a wi-fi network but I have done this and nothing is working!
-
Use combination context param, EL of databinding in a EL.
Hi. I have a image tag(ADF Faces.General Controls). I add into source attribute at common of property palette a EL #{resource['images:bakery.jpg']} with bakery.jpg is a image locate directy in images directory. Now, I want to change images directory
-
Is possible to filter data in a LOV after it has been chosen?
Let's say I got a tabular with 5 records, and a LIST OF VALUES in that item (LOV). ok, if in first record I choose the value in the list and I go to second record, I dont want it to be again (I dont want the value I already chose). I've tried several