REUSE_ALV_GRID_DISPLAY function
Hello,
with 'REUSE_ALV_GRID_DISPLAY'function, once displayed,
I need to show in a label, a field from the List, is there a way to do this. I did try and see if a user command occurs , when I select a line, but there was not one generated.
Thanks
Hi sims,
when I select a line, but there was not one generated.
Event will occur when we DOUBLE-CLICK
a line.
1. There are some parameters
in the FM which are passed,
and a new FORM has to be written.
2. Just copy paste this code in new program.
3. It will display list of company.
On double-clicking on the alv,
it will again display the clicked company code.
Important code has been marked.
4.
REPORT abc.
TYPE-POOLS : slis.
Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
Display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
CALL BACK FORM
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
READ TABLE itab INDEX whatrow-tabindex.
WRITE itab-bukrs.
ENDFORM. "ITAB_user_command
regards,
amit m.
regards,
amit m.
Similar Messages
-
ALV totals with REUSE_ALV_GRID_DISPLAY function
Hi folks, I am using the function REUSE_ALV_GRID_DISPLAY to display a report. One column called 'Perc Left' has been defined as a total using the do_sum = 'X' field in the field catalog. Not what I really want...
My issue is that when the totals are displayed I want this column to use a formula based on 2 other results from the total line. Is it possible to change the totals using something like events etc. Or is this not possible using the REUSE_ALV_GRID_DISPLAY function ?
Cheers
DaveThanks Srinivas, I didn't want the user to execute a function after the list is displayed for this. What I need is for the report to be executed and before the initial list is displayed I need some way to intercept and recalculate one of the columns on the total line. Unless I am misinterpreting the help for this it_event_exit internal table. I tried it and it does not go to the USER COMMAND section until after the basic list with the totals is displayed. At this point its too late and the wrong total has been presented to the user.
Hope this clarifies.
Dave -
The parameters of REUSE_ALV_GRID_DISPLAY function.
Hi abap experts,
I have a question. I m using REUSE_ALV_GRID_DISPLAY function. However I m using a view to fill the internal table which will be T_OUTTAB parameter of function. What will be the value of I_STRUCTURE_NAME parameter. Thanks in advance.when you use function 'reuse_alv_fieldcatalog_merge' :
you have to use following things:
Actually no need of Structure_name
Please refer Below:
DATA:I_PROGRAM_NAME LIKE SY-REPID VALUE ' ', " put your report name here
I_INTERNAL_TABNAME TYPE SLIS_TABNAME VALUE ' ' , " put your internal table name which is to be displayed
I_INCLNAME LIKE TRDIR-NAME VALUE ' '. " Put the Include name where internal table is defined, if include is not there then give report name again.
EXPORTING
I_PROGRAM_NAME = I_PROGRAM_NAME " this is program name
I_INTERNAL_TABNAME = I_INTERNAL_TABNAME " this is the internal table name which u will be using
I_INCLNAME = I_INCLNAME " this is the include name where internal table & it's data is defined
CHANGING
CT_FIELDCAT = " fieldcat to be displayed....
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = ' ' " Enter the Report Name here.
I_CALLBACK_PF_STATUS_SET = ' ' "set PF Status Here
I_CALLBACK_USER_COMMAND = ' '" Set User Command Here
IT_FIELDCAT = "write the Fieldcatalog name here
TABLES
T_OUTTAB = " write the name of the Internal Table to be Displayed.
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.
Please check it and if helpful Let me Know. -
How to create Drop-Down with Function Module REUSE_ALV_GRID_DISPLAY
Hi Experts,
I have used Reuse_alv_grid_display function module in my report for ALV output. I have a requirement to add drop down in one cell of my output. I have searched but all are suggesting through OOPS programing that I can not use.
If it is possible with the given scenerion , please help me how to write the code for it?
Thanks a bunch in advance.Hi,
You can check demo programs:
BCALV_EDIT_06
BCALV_EDIT_07
Hope it helps
Regards
Mansi -
Regarding the function module 'REUSE_ALV_GRID_DISPLAY'
wat do these things do in 'REUSE_ALV_GRID_DISPLAY' function module and how to use them??
IS_VARIANT =
IT_EVENTS =
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 = 0Hi
See the function module Documentation,
Passing an EXIT routine indicates to the ALV that the application wants to respond to certain function codes.
Generally, these are function codes that are unknown to the ALV (that is, are not standard ALV functions) and that were defined and set by a user status.
See also the documentation on parameter I_CALLBACK_PF_STATUS_SET.
The interface of the form routine specified must be defined as follows:
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Parameter R_UCOMM contains the function code triggered.
Structure RS_SELFIELD contains the following information:
tabname : Name of the internal output table
tabindex : Index of the internal output table
fieldname: Field name
endsum : Cursor is located on the totals line
sumindex : If >0, the cursor is located on a subtotals line
value : Value of the field on the list
refresh : (Exporting) List should be set up again
col_stable:(Exporting) Keep column position when list is set up again
row_stable:(Exporting) Keep row position when list is set up again
exit :(Exporting) Exit list (and ALV)
before_action: Call before standard action execution
after_action : Call after standard action execution, before list setup
ignore_multi : Internal use
sel_tab_field: Internal use
The EXIT routine is called whenever a function unknown to the ALV is triggered or if the routine call before/after the execution of a standard function code has been defined by interface parameter IT_EVENT_EXIT.
See also the documentation on parameter IT_EVENT_EXIT.
The function code and the current cursor position are then passed on to the calling program through the EXIT routine.
If the user has selected multiple rows by selecting checkboxes, the output table field designated as the checkbox contains the current state of the checkbox in the list.
Top_Of_page :
If the caller specifies an EXIT routine, this routine must have the following form:
FORM top_of_page.
Module REUSE_ALV_COMMENTARY_WRITE can then be called within the EXIT routine. This module is responsible for formatting the header information and also ensures online HTML formatting. In the print preview or in batch mode, the text passed is then output in the normal format.
If module REUSE_ALV_COMMENTARY_WRITE cannot be used, you must use two parameters instead. In I_CALLBACK_TOP_OF_PAGE you pass the form routine that is responsible for normal formatting in batch mode or in the print preview mode. The form routine that is responsible for online formatting, is passed in parameter I_CALLBACK_HTML_TOP_OF_PAGE. If one of these parameters is not filled, top-of-page is not output in the respective mode.
The important parameters are :
I. Export :
i. I_callback_program : report id
ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
iii. I_callback_user_command : routine where the function codes are handled
iv. I_structure name : name of the dictionary table
v. Is_layout : structure to set the layout of the report
vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
II. Tables :
i. t_outtab : internal table with the data to be output
<b>REward if usefull</b> -
Function REUSE_ALV_GRID_DISPLAY
Hi !
I wanted to ask few questions concern a standard sap ALV report created by the function REUSE_ALV_GRID_DISPLAY :
1. How to make columns editable, and to enable the user to change values of the columns ?
2. How to make drop down list to a column ?
3. How to add a function code to the ALV toolbar ?
4. When i use the abap commands at event handler user_command_l :
READ TABLE object_tab INDEX p_selfield-tabindex INTO l_struct.
IF sy-subrc EQ 0.
SET PARAMETER ID: 'QPN' FIELD l_struct-field1 .
CALL TRANSACTION 'QPR2' AND SKIP FIRST SCREEN.
endif.
Then abap navigate to 'QPR2' transaction however i get the error mesage "field1 is already being processed by my user". My question is how to enable using field1 before the navigation ?
Please give additional material besides the documentation of the REUSE_ALV_GRID_DISPLAY function.
Thanks
MosheHi Mohse,
1.How to make columns editable, and to enable the user to change values of the columns
use layout.
layout-EDIT = 'X'.
and pass this layout while calling FM.
2. How to make drop down list to a column ?
If the field in the internal table
is assigned to table-field name,eg. t001-bukrs,
then ,probably, it will come automatically!
( i doubt)
3. How to add a function code to the ALV toolbar ?
a) from se80, function group salv,
copy the gui status 'STANDARD'
(by right clicking)
to your program
with the name say , 'STANDARD_COPY'
B) WRITE ONE FORM.
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STANDARD_COPY'.
ENDFORM. "SET_PF_STATUS
C) WHILE CALLING fm reuse_alv_list_display
also pass this parameter :
i_callback_pf_status_set = 'SET_PF_STATUS'
MAKE SURE YOUR GUI STATUS IS ACTIVE IN UR PROGRAM.
PS
4.
Then abap navigate to 'QPR2' transaction however i get the error mesage "field1 is already being processed by my user". My question is how to enable using field1 before the navigation ?
This is becuase, in another session,
u must have opened this tcode
with the same value.
Hence, it tries to tell that,
two users cannot access/modify it simulataenouslyy.
This is not alv problem, but general
security /locking maintained by r3.
Just close all other session of this tcode.
and try agin. it will work.
regards,
amit m.
Message was edited by: Amit Mittal
Message was edited by: Amit Mittal -
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
Dear Experts,
I hv created a report using ALV.
Problem is , until I call "CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'" function module, my internal table is sorted fine. but after this function module ( i hv seen in debug mode) , the sort order is getting changed.
I hv not used any kind of sort in update catalog funcion.
w_repid = sy-repid.
PERFORM update_catalog.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = w_repid
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'
IT_FIELDCAT = i_fcat[]
I_SAVE = 'X'
TABLES
T_OUTTAB = i_faglflexa_all
* 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.
can any one suggest something.
Regards,
maverickThanks for ur reply.
itab_open.
status doc no
open 101
open 102
open 103
itab_all.
append itab_open[] to itab_all.
sort itab_all by date.
itab_clear
status doc no
clear 104
clear 105
claer 106
loop at itab_clear.
append itab_clear to itab_all.
endloop.
i hv sorted my internal table itab_all based on date only once after copying the data from itab_open. Then i appended the data from itab_clear.
now I call CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = w_repid
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'
IT_FIELDCAT = i_fcat[]
I_SAVE = 'X'
IT_SORT = ''
TABLES
T_OUTTAB = itab_all
* 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.
and i get the following output.
status doc no
open 101
open 102
clear 104
clear 105
claer 106
open 103
tha's the problem. why one open item is displayed at the end. i sorted itab_all after copying the data from itab_open and after itab_clear.
regards,
Maverick -
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: 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 -
How to use aggregate function on internal table
hi experts,
I am beginner in abap.I want to use sum function on internal table.
I have structure as follow:
types: begin of ty_ftab,
docno TYPE bkpf-belnr,
comcode TYPE bkpf-bukrs,
year TYPE bkpf-gjahr,
line_itm type bsad-buzei,
cust type bsad-kunnr,
amt type bsad-dmbtr,
end of ty_ftab.
data: it_ftab type table of ty_ftab,
wa_ftab type ty_ftab.
i fetched data successfully into it_ftab from bkpf and bsad table and displyed into alv.
now i want sum of amt using group by cust and want to display like
cust total_amt
in next screen...
displying part is not important but how can i do sum of amt according to cust value? Is there in way to query on internal table?Hi,
try this code,
data : i_sort TYPE TABLE OF slis_sortinfo_alv
w_sort like LINE OF i_sort.
sort it_ftab by cust.
w_sort-subtot = 'X'.
w_sort-fieldname = 'AMT'.
w_sort-tabname = 'it_ftab'.
APPEND w_sort to i_sort.
In fieldcatalog :
w_fcat-fieldname = 'AMT'.
w_fcat-tabname = 'it_ftab'.
w_fcat-do_sum = 'X'.
In REUSE_ALV_GRID_DISPLAY FUNCTION MODULE provide the it_sort.
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_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = i_sort
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* 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 =
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF. -
I am using REUSE_ALV_GRID_DISPLAY function module
I want to use I_CALLBACK_PF_STATUS_SET' that field & show menu bar which I create but it's not showing that menu bar?
I am using following coding :
Please guide me..............
DOWNLOAD = 'MM'.
SET PF-STATUS 'MM'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'ZVR_INEX'
I_CALLBACK_PF_STATUS_SET = DOWNLOAD
I_CALLBACK_USER_COMMAND = 'HANDLE_USER_COMMAND'(005)
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 = FIELDCAT_T
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
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 = I_VBPA
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.HI,
see this example.
REPORT ZBHALV_LIST1.
TABLES:MARA.
SELECT-OPTIONS: MATNR FOR MARA-MATNR.
DATA:BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
ERSDA LIKE MARA-ERSDA,
MTART LIKE MARA-MTART,
MBRSH LIKE MARA-MBRSH,
END OF ITAB.
SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE MATNR
IN MATNR.
TYPE-POOLS SLIS.
DATA:FCAT TYPE slis_t_fieldcat_alv.
DATA:LAYOUT TYPE slis_layout_alv.
DATA:EVE TYPE slis_t_event WITH HEADER LINE.
DATA:HEAD TYPE slis_t_listheader WITH HEADER LINE.
DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
SORT-UP = 'X'.
SORT-SPOS = 1.
SORT-FIELDNAME = 'ERSDA'.
SORT-tabname = 'MARA'.
APPEND SORT.
SORT-SPOS = 2.
SORT-FIELDNAME = 'MTART'.
SORT-tabname = 'MARA'.
APPEND SORT.
EVE-NAME = 'TOP_OF_PAGE'.
EVE-FORM = 'TOPOFPAGE'.
APPEND EVE.
EVE-NAME = 'TOP_OF_LIST'.
EVE-FORM = 'TOPOFLIST'.
APPEND EVE.
EVE-NAME = 'END_OF_LIST'.
EVE-FORM = 'ENDOFLIST'.
APPEND EVE.
LAYOUT-ZEBRA = 'X'.
LAYOUT-no_hline = 'X'.
LAYOUT-NO_VLINE = 'X'.
LAYOUT-window_titlebar = 'MATERIAL DETAILS'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = SY-REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = FCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
<b> I_CALLBACK_PF_STATUS_SET = 'STATUS'</b>
I_CALLBACK_USER_COMMAND = 'UCOMM'
I_STRUCTURE_NAME =
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = SORT[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = EVE[]
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 5
I_SCREEN_START_LINE = 5
I_SCREEN_END_COLUMN = 120
I_SCREEN_END_LINE = 25
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 TOPOFPAGE.
REFRESH HEAD.
HEAD-TYP = 'H'.
HEAD-INFO = 'MATERIALS'.
APPEND HEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEAD[]
I_LOGO =
I_END_OF_LIST_GRID =
ENDFORM.
FORM TOPOFLIST.
REFRESH HEAD.
HEAD-TYP = 'H'.
HEAD-INFO = 'MATERIALS-LISTTOP'.
APPEND HEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEAD[]
I_LOGO =
I_END_OF_LIST_GRID =
ENDFORM.
FORM ENDOFLIST.
REFRESH HEAD.
HEAD-TYP = 'H'.
HEAD-INFO = 'MATERIALS-LISTEND'.
APPEND HEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEAD[]
I_LOGO =
I_END_OF_LIST_GRID =
ENDFORM.
<b>FORM STATUS USING MYMENU.
*here MYMENU is the excluding buttons list
SET PF-STATUS 'MENU' excluding MYMENU.
ENDFORM.</b>
FORM UCOMM USING CODE STEXT.
CASE CODE.
WHEN 'ABC'.
WRITE:/ 'YOU HAVE CLICKED ON ABC'.
WHEN 'XYZ'.
WRITE:/ 'YOU HAVE CLICKED ON XYZ'.
ENDCASE.
ENDFORM.
rgds,
bharat. -
Drop down in REUSE_ALV_GRID_DISPLAY
Hi,
I am using REUSE_ALV_GRID_DISPLAY function module,
I am facing a problem with drop down list used for the fields that are displayed in ALV.
To get the search help or drop down for the field I am using the below code in field catalogue.
wa_p_i_fieldcat_alv-fieldname = 'VBTYP'.
wa_p_i_fieldcat_alv-ddictxt = 'M'.
wa_p_i_fieldcat_alv-seltext_m = 'VBTYP' .
wa_p_i_fieldcat_alv-seltext_l = wa_p_i_fieldcat_alv-seltext_s = wa_p_i_fieldcat_alv-seltext_m.
wa_p_i_fieldcat_alv-reptext_ddic = wa_p_i_fieldcat_alv-seltext_s.
wa_p_i_fieldcat_alv-ddic_outputlen = 1 .
wa_p_i_fieldcat_alv-col_pos = 4.
wa_p_i_fieldcat_alv-edit = 'X'.
wa_p_i_fieldcat_alv-ref_fieldname = 'VBTYP' .
wa_p_i_fieldcat_alv-ref_tabname = 'ZVBOOKING'.
APPEND wa_p_i_fieldcat_alv TO p_i_fieldcat_alv.
But for the field VBTYP the values are maintained in domain level value range.
So when I enter any value in the field 'VBTYP' and save the value, and try to deleted that value, FM is poping me an error message 'Enter an valid value', which should not happen, since its not a mandatory field in ZVBOOKING table.
Please any one guide me how to over come it.
Correct answer, points will be rewarded.
Regards,
Nithyacheck this sample program this will help you
*& Report Z_PRA_16 *
*& classical & alv with header line *
REPORT z_pra_16 NO STANDARD PAGE HEADING
LINE-COUNT 20 " no of records in a single page
LINE-SIZE 100."no of colons in a page.
DECLARING STRUCTURE.
TYPES:
BEGIN OF type_wa,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
price LIKE sflight-price,
currancy LIKE sflight-currency,
seatsmax LIKE sflight-seatsmax,
seatsocc LIKE sflight-seatsocc,
carrname LIKE scarr-carrname,
END OF type_wa.
FOR TYPE DECLARING INTERNAL TABLE
DATA :
wa TYPE type_wa,
itab TYPE STANDARD TABLE OF type_wa.
*For selection option
DATA: pp TYPE sflight-carrid,
pp1 TYPE sflight-connid,
pp2 TYPE sflight-price.
DECLARING SELECTION BLOCK.
SELECTION-SCREEN BEGIN OF BLOCK pra WITH FRAME TITLE text-001.
Declaring selection options IN SELECTION.
SELECT-OPTIONS :
s_carrid FOR pp, " declaring variables from table pp.
s_connid FOR pp1, " declaring variables from table pp1.
s_fldate FOR sy-datum, " declaring variables from table .
s_price FOR pp2. " declaring variables from table pp2.
SELECTION-SCREEN END OF BLOCK pra.
PARAMETERS:
alv TYPE c RADIOBUTTON GROUP g1, " option for selecting ALV REPORT
class TYPE c RADIOBUTTON GROUP g1. " option for selecting CLASSICL REPORT
**FOR CARRID MESSAGE GIVING CONDITION FOR A FIELD
AT SELECTION-SCREEN ON s_carrid.
SELECT SINGLE
carrid INTO s_carrid
FROM sflight
WHERE carrid IN s_carrid.
IF sy-subrc <> 0 .
MESSAGE i000(zp). " message for information
MESSAGE w000(zp). " message for warringing
ENDIF.
for connid MESSAGE
AT SELECTION-SCREEN ON s_connid.
SELECT SINGLE
carrid INTO s_connid
FROM sflight
WHERE connid IN s_connid.
IF sy-subrc <> 0 .
MESSAGE i001(zp).
MESSAGE w001(zp).
ENDIF.
FOR DATE MESSAGE
AT SELECTION-SCREEN ON s_fldate.
SELECT SINGLE
carrid INTO s_fldate
FROM sflight
WHERE fldate IN s_fldate.
IF sy-subrc <> 0 .
MESSAGE i002(zp).
MESSAGE w002(zp).
ENDIF.
START-OF-SELECTION.
IF class = 'X'. " FOR CLASSICAL REPORT OPTION.
PERFORM kumar. " SUBROUTINE for select statement fetching data.
Getting output.
LOOP AT itab INTO wa.
WRITE: /
wa-carrid,
10 wa-carrname,
30 wa-connid,
40 wa-fldate,
55 wa-price LEFT-JUSTIFIED,
70 wa-currancy,
75 wa-seatsmax,
90 wa-seatsocc.
ENDLOOP.
FORMAT COLOR OFF. "SCREEN COLOR
CLEAR itab.
ENDIF.
TOP-OF-PAGE. "
FORMAT COLOR 1.
WRITE: / 'Page ', syst-pagno,'REPORT NAME', sy-repid,'Date / time',
syst-datum, syst-uzeit.
SKIP.
WRITE: /
text-010, " FOR CARRID
15 text-008, " FOR CARRNAME
30 text-002, "CONNID
40 text-003, "FLDATE
55 text-004, "PRICE
70 text-005, "CURRENCY
80 text-006, "SEATSMAX
90 text-007. "SEATSCONN
FORMAT COLOR OFF.
ULINE.
FOR ALV OPTION
START-OF-SELECTION.
IF alv = 'X'. "FOR ALV REPORT OPTION.
TYPE-POOLS: slis. " declaring slis.
DATA:
gt_fieldcat TYPE slis_t_fieldcat_alv.
" declaring field catalog with internal table
PERFORM kumar. "for select statement fetching data
PERFORM praveen. " subroutine
DATA : prahead TYPE slis_t_listheader,
" DECLARING INTERNAL TABLE FOR HEADER FROM SLIS
praevent TYPE slis_t_event.
" DECLARING INTERNAL TABLE FOR EVENT FROM SLIS
CONSTANTS: praconst(30) TYPE c VALUE 'TOP_OF_PAGE'.
PERFORM pra. " DECLARING SUBROUTIN FOR HEADER
*CALLING FUNCTIONAL MODULE
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid " FOR PROGRAM NAME
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 = gt_fieldcat "FOR FIELD CATAGORI
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = praevent " FOR EVENTS
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 " declaring slfight,scarr in 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.
ENDIF.
*& Form praveen
text
--> p1 text
<-- p2 text
FORM praveen . " subroutine
DATA: pra TYPE slis_fieldcat_alv. " declaring structure from slis table.
CLEAR pra. " cleaing structure
pra-fieldname = 'CARRID'. " declaring field name for carrid
pra-tabname = 'ITAB'.
pra-seltext_m = 'CARRID'. " declaring field heading
APPEND pra TO gt_fieldcat.
CLEAR pra.
pra-fieldname = 'CONNID'.
pra-tabname = 'ITAB'.
pra-seltext_m = 'CONNID'.
APPEND pra TO gt_fieldcat.
CLEAR pra.
pra-fieldname = 'FLDATE'.
pra-tabname = 'ITAB'.
pra-seltext_m = 'FLDATE'.
APPEND pra TO gt_fieldcat.
CLEAR pra.
pra-fieldname = 'PRICE'.
pra-tabname = 'ITAB'.
pra-seltext_m = 'PRICE'.
APPEND pra TO gt_fieldcat.
CLEAR pra.
pra-fieldname = 'CURRANCY'.
pra-tabname = 'ITAB'.
pra-seltext_m = 'CURRENCY'.
APPEND pra TO gt_fieldcat.
ENDFORM. " praveen
*& Form kumar
text
--> p1 text
<-- p2 text
FOR FETCHING DATA TO RE-USE.'SUBROUTINE'
FORM kumar .
SELECT
a~carrid
a~connid
a~fldate
a~price
a~currency
a~seatsmax
a~seatsocc
b~carrname
INTO TABLE itab
FROM
sflight AS a
INNER JOIN
scarr AS b
ON
acarrid = bcarrid
WHERE
a~fldate IN s_fldate
AND
a~carrid IN s_carrid
AND
a~price IN s_price.
FORMAT COLOR 5. "adding color
ENDFORM. " kumar
*& Form pra
text
--> p1 text
<-- p2 text
FOR HEADER
FORM pra .
DATA : praeventstr TYPE slis_alv_event, "DECLARING EVENT STRCTURE
praheadstr TYPE slis_listheader. " DECLARING HEADER STRUCRTUE
praheadstr-typ = 'H'(009). " TYP ='H' THIS IS FOR HEADING SAP-DEFAULT
praheadstr-info = text-025. " INFORMATATION
APPEND praheadstr TO prahead. " STRUCTUCTURE TO INTERNAL TABLE
CALL FUNCTION 'REUSE_ALV_EVENTS_GET' " CALLING EVENTS
EXPORTING
i_list_type = 0
IMPORTING
et_events = praevent " DECLARING EVENTS
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.
" EVENTS TO STRUCTURE
READ TABLE praevent WITH KEY
name = slis_ev_top_of_page
INTO praeventstr.
MOVE praconst TO praeventstr-form. " MOVING CONSTRANT TO STRYCTUE
APPEND praeventstr TO praevent. " STRUCTURE TO EVENTS
ENDFORM. " pra
*CALLING FUNCTIONAL MODUL FOR HEADER
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = prahead.
I_LOGO =
I_END_OF_LIST_GRID =
ENDFORM. "TOP_OF_PAGE -
REUSE_ALV_GRID_DISPLAY - layout variant
Hi all
I am working with REUSE_ALV_GRID_DISPLAY function module. For layout variant I using the below code
parameters: variant LIKE disvariant-variant.
* POV for Layout
at selection-screen on value-request for variant.
g_save = 'A'.
clear g_variant.
g_variant-report = sy-repid.
gx_variant = g_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
I_SAVE = g_save
CHANGING
CS_VARIANT = gx_variant
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 0.
variant = gx_variant-variant.
ENDIF.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = g_variant
I_SAVE = g_save
IMPORTING
E_EXIT = g_exit
ES_VARIANT = gx_variant
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 2.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF g_exit = SPACE.
variant = gx_variant-variant.
ENDIF.
ENDIF.
Everything is working well right now. I have two layouts saved. But my question is when I execute my report I want to see one of the saved layout by default in my 'variant' at selection screen.
How can I do this? PLease help. Waiting......Here is some modified code. Notice here that I have added another event. AT SELECTION-SCREEN OUTPUT. If you have a default variant defined, it will now show up in the screen.
report zrich_0003.
data: g_save type c value 'X'.
data: g_variant type disvariant.
data: gx_variant type disvariant.
data: g_exit type c.
data: ispfli type table of spfli.
parameters: variant like disvariant-variant.
at selection-screen output.
check variant is initial.
gx_variant-report = sy-repid.
call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
* exporting
* i_save = g_save
changing
cs_variant = gx_variant
exceptions
not_found = 2.
if sy-subrc = 0.
variant = gx_variant-variant.
endif.
* POV for Layout
at selection-screen on value-request for variant.
g_save = 'A'.
clear g_variant.
g_variant-report = sy-repid.
* gx_variant = g_variant.
call function 'REUSE_ALV_VARIANT_F4'
exporting
is_variant = g_variant
i_save = g_save
importing
e_exit = g_exit
es_variant = gx_variant
exceptions
not_found = 2.
if sy-subrc = 2.
message id sy-msgid type 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
if g_exit = space.
variant = gx_variant-variant.
endif.
endif.
start-of-selection.
select * into table ispfli from spfli.
g_variant-report = sy-repid.
g_variant-variant = variant.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_structure_name = 'SPFLI'
i_save = g_save
is_variant = g_variant
tables
t_outtab = ispfli
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
REgards,
Rich Heilman -
REUSE_ALV_GRID_DISPLAY --- on - APO /SCM 4.10
Hi ,
Though my requirement is simple, but not getting the desired output from 'REUSE_ALV_GRID_DISPLAY' Function.
I'm using this function for data display in Grid layout. but the default menu bar is get disturbed, though i have not set any PF-STATUS it is diplaying 'question marks''?' & EDIT button & then Question marks '?'.
Has anyone faced this kind of display issue ( on SCM 4.10).
Note : its working fine in R/3.
snapshot of my code below.
LS_LAYOUT-ZEBRA = 'X'.
LS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = 'X'
I_CALLBACK_PROGRAM = 'YSNP_PDS'
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 = 'WA_PDS'
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = LS_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'X'
IS_VARIANT =
IT_EVENTS =
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_PDS
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2Hi kannan,
it is the General Problem with the Grid.
you need to do little manual work...
Go to SE41 and Give the Program name <b>SAPLKKBL</b>
Status <b>STANDARD</b>
then click on Copy Status(CTRL+F6).
then in the popup give your Program name and status .
and copy the status and save & activate it .
then go to your Program
mention the Bold one for status
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = L_LAYOUT
<b> I_CALLBACK_PF_STATUS_SET = 'STATUS'</b>
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
it_events = it_events
* I_SCREEN_START_COLUMN = 10
* I_SCREEN_START_LINE = 1
* I_SCREEN_END_COLUMN = 50
* I_SCREEN_END_LINE = 20
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.
then
FORM STATUS USING P_EXTAB TYPE SLIS_T_EXTAB.
*- Pf status which i copied from Standard Program
SET PF-STATUS <b>'STATUS'</b> EXCLUDING P_EXTAB.
ENDFORM. " STATUS
then check your Program .....
now they will come.../
Regards
vijay -
Create TOP-OF-PAGE display for REUSE_ALV_GRID_DISPLAY
Hi,
I need to create a TOP-OF-PAGE display to show the MATNR, description and EA per CSE for my report.
The report is output using "REUSE_ALV_GRID_DISPLAY."
See following code:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_TOP_OF_PAGE =
I_STRUCTURE_NAME = 'ZSTATE_PROD_INQ'
TABLES
T_OUTTAB = I_ALV_MATNR.
How do I add a TOP-OF-PAGE display to the report, while using the above alv?
Points will be rewarded and all responses will be greatly appreciated.
Thanks,
JohnSee the example Program :
Use FM -
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'FDLOGO'
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
REPORT ZMM_INV_DAYS_SUPPLY no standard page heading
message-id zwave.
======================================================================
Program Name : ZMM_INV_DAYS_SUPPLY *
Description : this report identify Obsolete and Excessive inventory*
it show show days of supply by date. Need to define *
Average daily sales for a sku. Possibly look back to *
the last 3 weeks or look at the same period a year ago*
puls a growth factor to help with seasonal items *
Author : Seshu *
Date : 03/14/2007 *
MODIFICATION HISTORY *
DATE | AUTHOR | CHANGE # | DESCRIPTION OF MODIFICATION *
--|||--
03/14/07| Seshu | DEVK922128 | Initial *
03/22/07| Seshu | DEVK922148 | Removed Duplicates *
03/26/07| Seshu | DEVK922152 | Added new selection-screen *
03/27/07| Seshu | DEVK922154 | Material status as range option now*
03/27/07| Seshu | DEVK922158 | Corrected storage type in where con*
======================================================================
type-pools
type-pools : slis.
Data Declaration
tables : mara,
marc,
lagp,
mvke,
makt.
Constants
constants : c_werks(4) type c value '1000'," Plant
c_lgort(4) type c value '1000'," Storage Location
c_periv like MARC-PERIV value 'XX',
c_perkz like MVER-PERKZ value 'T'.
Internal Tables
Internal Table for MARA and MAKT and MARD
data : begin of I_material occurs 0,
matnr like mara-matnr, " Material
lgpla like mlgt-lgpla," Storage Type
zzdept like marc-zzdept," Pick Dept
ZZPRODDEPT like marc-ZZPRODDEPT," Prod Dept
vmsta like mvke-vmsta, " Material Status
end of i_material.
Structure
data : begin of i_final occurs 0 ,
matnr like mara-matnr," Material #
maktx like makt-maktx," Description
lgpla like mlgt-lgpla, " Storage Bin
days like P0347-SCRDD, " No of Days
menge like mseg-menge, " Avg Daily Sales
kbetr like konp-kbetr, " Avg
labst like mard-labst," Inventory Stock
stprs like mbew-stprs, " Mvg avg Price
dos like mseg-menge, " DOS Units
dosm like konp-kbetr, " DOS $$
end of i_final.
data : int_ges_verb_tab like sverbtaba
occurs 0 with header line.
Internal table for A004
data : i_a004 like a004 occurs 0 with header line.
Data Variables
data : v_stprs like konp-kbetr,
v_repid like sy-repid,
v_labst like mard-labst,
v_maktx like makt-maktx.
ALV Function Module Variables
DATA: g_repid like sy-repid,
gs_layout type slis_layout_alv,
g_exit_caused_by_caller,
gs_exit_caused_by_user type slis_exit_by_user.
DATA: gt_fieldcat type slis_t_fieldcat_alv,
gs_print type slis_print_alv,
gt_events type slis_t_event,
gt_list_top_of_page type slis_t_listheader,
g_status_set type slis_formname value 'PF_STATUS_SET',
g_user_command type slis_formname value 'USER_COMMAND',
g_top_of_page type slis_formname value 'TOP_OF_PAGE',
g_top_of_list type slis_formname value 'TOP_OF_LIST',
g_end_of_list type slis_formname value 'END_OF_LIST',
g_variant LIKE disvariant,
g_save(1) TYPE c,
g_tabname_header TYPE slis_tabname,
g_tabname_item TYPE slis_tabname,
g_exit(1) TYPE c,
gx_variant LIKE disvariant.
Selection-screen
selection-screen : begin of block blk with frame title text-001.
parameters : p_werks like marc-werks obligatory default '1000'.
select-options : s_matnr for mara-matnr,
s_MATKL for mara-MATKL,
s_mtart for mara-mtart,
s_LGTYP for LAGP-LGTYP,
p_vmsta for MVKE-VMSTA,
s_dept for marc-zzdept,
s_pdept for MARC-ZZPRODDEPT.
selection-screen: end of block blk.
selection-screen begin of block periods with frame title text-002.
selection-screen begin of line.
selection-screen comment (15) text-c01.
selection-screen position 18.
Period 1
parameters: p_stdat1 like mkpf-budat obligatory.
selection-screen position 35.
selection-screen comment (10) text-c02.
parameters: p_endat1 like mkpf-budat obligatory.
selection-screen end of line.
selection-screen end of block periods.
Fill the default values
initialization.
v_repid = sy-repid.
PERFORM LAYOUT_INIT USING GS_LAYOUT.
PERFORM EVENTTAB_BUILD USING GT_EVENTS[].
Validation for Dates
at selection-screen.
if p_stdat1 > p_endat1.
message e206(zwave) with
' End date should be greater than or equal to Start Date'.
endif.
Make one of the Selection should be mandatory
if s_matnr-low is initial.
if s_matkl-low is initial and s_mtart-low is initial and
s_dept-low is initial and s_pdept-low is initial.
message e208(zwave) with
'Enter atleast one selection Criteria'.
endif.
endif.
Start-of-selection.
start-of-selection.
Get the data from MARA,MARD,MAKT Table
perform get_data_tables.
Read the data into FInal Table.
perform read_data.
END-OF-SELECTION.
end-of-selection.
if not i_final[] is initial.
ALV Function Module
perform print_alv.
endif.
*& Form get_data_tables
Get the data from Tables MARA,MARD,MAKT
FORM get_data_tables.
select a~matnr
b~lgpla
czzdept cZZPRODDEPT d~vmsta into table i_material
from mara as a inner join mlgt as b on amatnr = bmatnr
inner join marc as c on cmatnr = amatnr
inner join mvke as d on dmatnr = amatnr
where a~matnr in s_matnr
and c~werks = p_werks
and a~mtart in s_mtart
and c~ZZPRODDEPT in s_pdept
and a~MATKL in s_MATKL
and c~zzdept in s_dept
and b~lgnum = '100'
and b~LGTYP in s_lgtyp
and b~lgpla ne space
and d~vkorg = '0001'
and d~vtweg = '01'
and d~matnr in s_matnr
and d~vmsta in p_vmsta.
if sy-subrc ne 0.
message e207(zwave) with 'No data found for Given Selection Criteria'.
endif.
sort i_material by matnr .
DELETE ADJACENT DUPLICATES FROM i_material COMPARING matnr.
ENDFORM. " get_data_tables
*& Form read_data
Read the data
FORM read_data.
loop at i_material.
Storage Bin
i_final-lgpla = i_material-lgpla.
Days of Sales ( End date - Start date )
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
DATE1 = p_endat1
DATE2 = p_stdat1
OUTPUT_FORMAT = '02'
IMPORTING
DAYS = i_final-days.
Get the Average Daily Sales (Units) from MVER Table
perform get_average_sales.
Get the Average Daily Sales ($$) from VK13 Transaction
perform get_avgsales_price.
clear : v_labst.
Get the Inventory from MARD Table
select single labst from mard into v_labst
where matnr = i_material-matnr
and werks = p_werks
and lgort = c_lgort.
if sy-subrc eq 0.
Inventory Stock - MARD-LABST
i_final-labst = v_labst.
endif.
Material #
i_final-matnr = i_material-matnr.
Get the Material Description
clear v_maktx.
select single maktx from makt into v_maktx
where matnr = i_material-matnr
and spras = 'EN'.
if sy-subrc eq 0.
Description
i_final-maktx = v_maktx.
endif.
Get the Mvg Average Price
perform get_moving_avgpr.
Days of Supply Units.
if i_final-kbetr ne 0.
i_final-dos = i_final-labst / i_final-menge.
endif.
Days of Supply $$
i_final-dosm = i_final-dos * v_stprs.
append i_final.
clear : i_final,
i_material.
endloop.
refresh i_material.
ENDFORM. " read_data
*& Form get_average_sales
Get the data from MVER Table
FORM get_average_sales.
data : lv_menge like mseg-menge.
refresh int_ges_verb_tab.
clear : int_ges_verb_tab,
lv_menge.
CALL FUNCTION 'CONSUMPTION_READ_FOR_MM'
EXPORTING
KZRFB = ' '
MATNR = i_material-matnr
WERKS = c_werks
PERKZ = c_perkz
PERIV = c_periv
TABLES
GES_VERB_TAB = int_ges_verb_tab
UNG_VERB_TAB =
EXCEPTIONS
WRONG_CALL = 1
NOT_FOUND = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at int_ges_verb_tab.
if int_ges_verb_tab-ertag >= p_stdat1 and
int_ges_verb_tab-ertag <= p_endat1.
add int_ges_verb_tab-vbwrt to lv_menge.
endif.
endloop.
i_final-menge = lv_menge / i_final-days.
ENDFORM. " get_average_sales
*& Form get_avgsales_price
Avg Daily Sales Price
FORM get_avgsales_price.
Get the data from A004 table to get KNUMH
Added new field Sales Unit - Seshu 01/09/2006
refresh : i_a004.
clear : i_a004.
data : lv_kbetr like konp-kbetr," Condition value
lv_KPEIN like konp-kpein , "per
lv_KMEIN like konp-KMEIN. " Sales Unit
select * from a004 into table i_a004
where matnr = i_material-matnr
and vkorg = '0001'
and vtweg = '01'.
if sy-subrc eq 0.
sort i_a004 by DATAB descending.
Get the Latetest Date
read table i_a004 with key matnr = i_material-matnr
vkorg = '0001'
vtweg = '01'
binary search.
Get the Sales Value
select single kbetr KPEIN KMEIN from konp
into (lv_kbetr,lv_KPEIN, lv_KMEIN)
where knumh = i_a004-knumh
and kappl = i_a004-kappl
and kschl = i_a004-kschl.
if sy-subrc eq 0.
i_final-kbetr = lv_kbetr / lv_KPEIN.
i_final-kbetr = i_final-kbetr * i_final-menge.
endif.
endif.
clear : lv_kbetr,
lv_kpein,
lv_KMEIN.
ENDFORM. " get_avgsales_price
*& Form get_moving_avgpr
Get the data from MVEW Table
FORM get_moving_avgpr.
Local Variables
data : lv_stprs like mbew-stprs, " Standard Price
lv_verpr like mbew-verpr, " Moving avg Price
lv_vprsv like mbew-vprsv. " Price Indicator
clear : lv_stprs,
lv_verpr,
lv_vprsv,
v_stprs.
select single stprs verpr vprsv from mbew
into (lv_stprs,lv_verpr,lv_vprsv)
where matnr = i_material-matnr.
if sy-subrc eq 0.
if lv_vprsv = 'S'.
i_final-stprs = lv_stprs * i_final-labst.
v_stprs = lv_stprs.
elseif lv_vprsv = 'V'.
i_final-stprs = lv_verpr * i_final-labst.
v_stprs = lv_verpr.
endif.
endif.
ENDFORM. " get_moving_avgpr
*& Form print_alv
REUSE_ALV_GRID_DISPLAY Function Module
FORM print_alv.
PERFORM COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].
Populate field catalog
PERFORM fieldcat_init using gt_fieldcat[].
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = g_user_command
I_CALLBACK_TOP_OF_PAGE = g_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 = gs_layout
IT_FIELDCAT = gt_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = GT_EVENTS[]
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_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
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.
ENDFORM. " print_alv
*& Form get_fieldcatlog
Fieldcatlog
*& Form fieldcat_init
Fieldcat
FORM fieldcat_init USING e01_lt_fieldcat type slis_t_fieldcat_alv.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
Material #
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MATNR'.
LS_FIELDCAT-ref_fieldname = 'MATNR'.
LS_FIELDCAT-ref_tabname = 'MARA'.
LS_FIELDCAT-TABNAME = 'I_FINAL'.
ls_fieldcat-seltext_L = 'Material'.
ls_fieldcat-seltext_M = 'Material'.
ls_fieldcat-seltext_S = 'Material'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Material Description
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MAKTX'.
LS_FIELDCAT-OUTPUTLEN = 30.
LS_FIELDCAT-TABNAME = 'I_FINAL'.
ls_fieldcat-seltext_L = 'Description'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Storage Bin
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'LGPLA'.
LS_FIELDCAT-OUTPUTLEN = 10.
LS_FIELDCAT-TABNAME = 'I_FINAL'.
ls_fieldcat-seltext_L = 'Storage Bin'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Start Date
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'SDATE'.
LS_FIELDCAT-OUTPUTLEN = 10.
LS_FIELDCAT-TABNAME = 'I_FINAL'.
ls_fieldcat-seltext_L = 'Start Date'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
End Date.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'EDATE'.
LS_FIELDCAT-OUTPUTLEN = 10.
LS_FIELDCAT-TABNAME = 'I_FINAL'.
ls_fieldcat-seltext_L = 'End Date'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Days of Sales
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'DAYS'.
LS_FIELDCAT-OUTPUTLEN = 12.
LS_FIELDCAT-TABNAME = 'I_FINAL'.
ls_fieldcat-seltext_L = 'Days of Sales'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Average Daily Sales(Units).
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MENGE'.
LS_FIELDCAT-OUTPUTLEN = 18.
LS_FIELDCAT-TABNAME = 'I_FINAL'.
ls_fieldcat-seltext_L = 'Average Daily Sales(Units)'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Average Daily Sales($$)
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KBETR'.
LS_FIELDCAT-OUTPUTLEN = 18.
LS_FIELDCAT-TABNAME = 'I_FINAL'.
ls_fieldcat-seltext_L = 'Average Daily Sales($$)'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Inventory(Units)
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'LABST'.
LS_FIELDCAT-OUTPUTLEN = 18.
LS_FIELDCAT-TABNAME = 'I_FINAL'.
ls_fieldcat-seltext_L = 'Inventory(Units)'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Inventory($$)
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'STPRS'.
LS_FIELDCAT-OUTPUTLEN = 18.
LS_FIELDCAT-TABNAME = 'I_FINAL'.
ls_fieldcat-seltext_L = 'Inventory($$)'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
DOS($$)
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'DOSM'.
LS_FIELDCAT-OUTPUTLEN = 13.
LS_FIELDCAT-TABNAME = 'I_FINAL'.
ls_fieldcat-seltext_L = 'DOS($$)'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
DOS(Days)
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'DOS'.
LS_FIELDCAT-OUTPUTLEN = 13.
LS_FIELDCAT-TABNAME = 'I_FINAL'.
ls_fieldcat-seltext_L = 'DOS(Days)'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
ENDFORM. " get_fieldcatlog
FORM COMMENT_BUILD *
--> LT_TOP_OF_PAGE *
FORM COMMENT_BUILD USING LT_TOP_OF_PAGE TYPE
SLIS_T_LISTHEADER.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
Variables for Date
data : lv_year(4) type c,
lv_mon(2) type c,
lv_day(2) type c,
lv_date1(10) type c,
lv_date2(10) type c.
LIST HEADING LINE: TYPE H
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = sy-title.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
clear : lv_year,
lv_day,
lv_mon,
lv_date1.
lv_year = p_stdat1+0(4).
lv_mon = p_stdat1+4(2).
lv_day = p_stdat1+6(2).
concatenate lv_mon '/' lv_day '/' lv_year into lv_date1.
STATUS LINE: TYPE S
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = TEXT-c01.
LS_LINE-INFO = lv_date1.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
clear : lv_year,
lv_day,
lv_mon,
lv_date2.
lv_year = P_ENDAT1+0(4).
lv_mon = P_ENDAT1+4(2).
lv_day = P_ENDAT1+6(2).
concatenate lv_mon '/' lv_day '/' lv_year into lv_date2.
LS_LINE-KEY = text-c02.
LS_LINE-INFO = lv_date2.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
ENDFORM.
FORM TOP_OF_PAGE *
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'FDLOGO'
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
ENDFORM.
FORM EVENTTAB_BUILD *
--> RT_EVENTS *
FORM EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT.
*"Registration of events to happen during list display
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = RT_EVENTS.
READ TABLE RT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE G_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO RT_EVENTS.
ENDIF.
ENDFORM.
FORM LAYOUT_INIT *
--> RS_LAYOUT *
FORM LAYOUT_INIT USING RS_LAYOUT TYPE SLIS_LAYOUT_ALV.
**"Build layout for list display
RS_LAYOUT-DETAIL_POPUP = 'X'.
lslayout-f2code = p_f2code.
rs_layout-zebra = 'X'.
rs_layout-colwidth_optimize = 'X'.
ENDFORM.
Maybe you are looking for
-
Do the latest n grestest (17 inch) iMacs have overheating issues like the G5 PPCs did ? I'm in Houston,Tx so there is no lack of heat & humidity here and it isn't getting any cooler ... G3 i Mac OS X (10.3.9) iMac in the future
-
A2DP Bluetooth Transmitter Comparison Spreadsheet?
Is anyone aware of a spreadsheet or google doc that has all the bluetooth transmitters listed and remarks about specs, compatibility, capabilities. And specifically is there one out there thats a newer version of the Zoom 4335. I want one that is Blu
-
I think it's tween. Not sure. Anyway, I want to make something like this. The user clicks on a day of the week and the slider goes to that day. I'm not trying to do the XML part where the information is displayed, I just want to know how to get the s
-
Is the points system too restrictive?
When I first joined these forums, the points system was quite different, so that the transition from level three to four took a long time, but was possible. Since then giving and receiving points has tightened up so much that I now think that it is a
-
Hi to everyone: I haven't found a post about this issue but, Does SAP xMII runs on Windows Vista? Is there problems with the new IIS?. I'll like to know if anyone has install SAP xMII on Vista, if someone has: can i have some Tips or recomendations?