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,
maverick
Thanks 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
Similar Messages
-
Displaying table using call function 'REUSE_ALV_GRID_DISPLAY'
I have created a table which has product code, product description, and product level. I am trying to display it using REUSE_ALV_GRID_DISPLAY. When I Check it, I get the following error message: "PVS2" is not an internal table - the "Occurs n" specification is missing.
Is it possible to copy PVS2 into another table, and then display that table using REUSE_ALV_GRID_DISPLAY?
I have patched together code from sdn, a client program, and my own code and I am starting to get confused. So, please help me.
Regards,
Al Lal
REPORT YABHINAV16.
* program to display products at chosen level *
Tables: T179, T179t.
types: begin of hierarchy,
prodh type t179-prodh,
vtext type t179t-vtext,
stufe type t179-stufe,
end of hierarchy.
types: begin of text,
prodh type t179t-prodh,
vtext type t179t-vtext,
end of text.
data: pvs type standard table of hierarchy initial size 0.
data: pvs2 type hierarchy.
data: it_text type standard table of text,
wa_text type text.
TYPE-POOLS:SLIS.
*For ALV
DATA: GT_FLD TYPE SLIS_T_FIELDCAT_ALV,
GT_EV TYPE SLIS_T_EVENT,
GT_HDR TYPE SLIS_T_LISTHEADER,
GT_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA: WA_FLD TYPE SLIS_FIELDCAT_ALV,
WA_EV TYPE SLIS_ALV_EVENT,
WA_HDR TYPE SLIS_LISTHEADER,
WA_SORT TYPE SLIS_SORTINFO_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
DEFINE FLD.
WA_FLD-FIELDNAME = &1.
WA_FLD-TABNAME = &2.
WA_FLD-OUTPUTLEN = &3.
WA_FLD-SELTEXT_L = &4.
WA_FLD-SELTEXT_M = &5.
WA_FLD-SELTEXT_S = &6.
WA_FLD-COL_POS = &7.
WA_FLD-FIX_COLUMN = &8.
WA_FLD-DO_SUM = &9.
APPEND WA_FLD TO GT_FLD.
CLEAR WA_FLD.
END-OF-DEFINITION.
CONSTANTS: C_TOP TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
C_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
DATA: MTRL LIKE SY-REPID,
TITLE LIKE SY-TITLE.
select-options level for t179-stufe no intervals.
start-of-selection.
Select prodh stufe from T179 into corresponding fields of table pvs where stufe in level.
select prodh vtext from t179t into corresponding fields of table it_text for all entries in pvs where prodh = pvs-prodh.
end-of-selection.
sort pvs by prodh.
sort it_text by prodh.
loop at pvs into pvs2.
read table it_text into wa_text with key prodh = pvs2-prodh.
if sy-subrc eq 0.
pvs2-vtext = wa_text-vtext.
write: / pvs2-prodh, pvs2-vtext, pvs2-stufe.
endif.
* modify pvs2.
endloop.
perform BUILD_FIELDCAT.
perform GRID_DISPLAY.
form BUILD_FIELDCAT .
FLD 'PRODH' 'PVS2' '20' 'Product Hierarchy' ' ' ' ' '1' '' '' .
FLD 'VTEXT' 'PVS2' '40' 'Description ' ' ' ' ' '3' '' '' .
FLD 'STUFE' 'PVS2' '5' 'Level' ' ' ' ' '2' '' '' .
endform. " BUILD_FIELDCAT
form GRID_DISPLAY .
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = MTRL
I_CALLBACK_USER_COMMAND = 'C_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = C_TOP
I_STRUCTURE_NAME = 'PVS2'
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = GT_FLD
IT_SORT = GT_SORT
I_DEFAULT = 'X'
I_SAVE = 'U'
IT_EVENTS = GT_EV
TABLES
T_OUTTAB = PVS2[]
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. " GRID_DISPLAYTYPE-POOLS : SLIS.
DATA : BEGIN OF WA_T001,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
END OF WA_T001,
IT_T001 LIKE TABLE OF WA_T001.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
DATA : V_NAME LIKE SY-REPID.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE IT_T001 UP TO 15 ROWS. V_NAME = SY-REPID.
CALL FUCTION MODULE 'REUSE_ALV_FIELDCATLOG_MERGE. EXPORTING I_CALBACK_PROGRAM =
V_NAME I_INTERAL_TABNAME = 'WA_T001' I_INCLNAME = V_NAME CHANGING CT_FIELDCAT =
IT_FCAT.
CALL FUNCTION MODULE "REUSE_ALV_GRID_DISPLAY"
EXPORTING
I_CALLBACK_PROGRAM = V_NAME
IT_FCAT = IT_FCAT.
TABLES
T_OUTTAB = IT_T001
SY-REPID IS THE SYSTEM VARIABLE WHICH IS HAVING THE ABAP PROGRAM
OR CURRENT MAIN PROGRAM.
----- Sample Progam -
***INCLUDE YRVR058_DEST_WISE_SUMMARY_DF01 .
*& Form DISPLAY_DATA
text *-- Rajesh Vasudeva
--> p1 text
<-- p2 text
FORM DISPLAY_DATA .
IF ITAB[] IS NOT INITIAL.
PERFORM F_APPEND_BLOCK.
ELSE.
MESSAGE 'Data not found for the selection
criteria' TYPE 'S'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " display_data
*& Form f_append_block
text
--> p1 text
<-- p2 text
FORM F_APPEND_BLOCK .
DATA : L_WA_SORT TYPE SLIS_SORTINFO_ALV, "For
sort
L_WA_EVENTS TYPE SLIS_ALV_EVENT. "For
events
Event (Top of List)
CLEAR L_WA_EVENTS.
L_WA_EVENTS-NAME = SLIS_EV_TOP_OF_LIST.
L_WA_EVENTS-FORM = C_TOPOFPAGE.
APPEND L_WA_EVENTS TO I_EVENTS_PART.
Event (Top of Page)
CLEAR L_WA_EVENTS.
L_WA_EVENTS-NAME = SLIS_EV_TOP_OF_PAGE.
L_WA_EVENTS-FORM = 'F_DISPLAY_HEADER_PARTA'(031).
"f_display_header_part
APPEND L_WA_EVENTS TO I_EVENTS_PART.
Event (End of List)
CLEAR L_WA_EVENTS.
L_WA_EVENTS-NAME = SLIS_EV_END_OF_LIST.
L_WA_EVENTS-FORM = C_END_OF_LIST.
APPEND L_WA_EVENTS TO I_EVENTS_PART.
Set Layout Zebra
STRUCT_LAYOUT-ZEBRA = 'X'.
STRUCT_LAYOUT-NUMC_SUM = 'X'.
STRUCT_LAYOUT-TOTALS_TEXT = 'TOTAL:'(032).
set field catalog
PERFORM F_FIELD_CATALOG_PART.
ASSIGN ITAB[] TO <F_OUTTAB>.
V_PART = 'A'. "initiating list is A
PERFORM F_DISPLAY_BLOCK USING STRUCT_LAYOUT
I_FIELD_CAT_PART[]
C_TAB
I_EVENTS_PART[]
I_SORT_PART[].
ENDFORM. " f_append_block
*& Form f_field_catalog_part
text
--> p1 text
<-- p2 text
FORM F_FIELD_CATALOG_PART .
REFRESH I_FIELD_CAT_PART.
CLEAR I_FIELD_CAT_PART.
PERFORM F_CREATE_CATALOG USING :
*Month
C_TAB 'MONTH' 'MONTH' SPACE 'L' 7
I_FIELD_CAT_PART[],
*OBD
*C_TAB 'VBELN' 'Delivery' SPACE 'L' 12
I_FIELD_CAT_PART[],
*DATE
C_TAB 'WADAT_IST' 'Date' SPACE 'L' 10
I_FIELD_CAT_PART[],
*Destination
C_TAB 'CITY1' 'Destination' SPACE 'L' 25
I_FIELD_CAT_PART[],
*Qty By Road
C_TAB 'NTGEW_ROAD' 'Road Quantity' SPACE 'R' 16
I_FIELD_CAT_PART[],
*Rail Qty
C_TAB 'NTGEW_RAIL' 'Rail Quantity' SPACE 'R' 16 I_FIELD_CAT_PART[],
*Total Qty C_TAB 'TOT' 'Total Quantity' SPACE 'R' 16 I_FIELD_CAT_PART[], *RR/Trk No.
C_TAB 'EXTI2' 'Truck/RR No.' SPACE 'L' 17 I_FIELD_CAT_PART[].
ENDFORM. " f_field_catalog_part
*& Form f_DISPLAY_block
text
-->P_STRUCT_LAYOUT text
-->P_I_FIELD_CAT_PART[] text
-->P_C_TAB text
-->P_I_EVENTS_PART[] text
-->P_I_SORT_PART[] text
FORM F_DISPLAY_BLOCK USING FP_LAYOUT TYPE
SLIS_LAYOUT_ALV
FP_I_FCAT TYPE
SLIS_T_FIELDCAT_ALV
VALUE(FP_TABNAME) TYPE
ANY
FP_I_EVENTS TYPE
SLIS_T_EVENT
FP_I_SORT TYPE
SLIS_T_SORTINFO_ALV.
DATA: V_REPID TYPE SYREPID,
"current Program id
C_SAVE TYPE CHAR1 VALUE 'A'.
"variant save
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
*CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
IS_LAYOUT = FP_LAYOUT
IT_FIELDCAT = FP_I_FCAT[]
IT_SORT = FP_I_SORT[]
I_SAVE = C_SAVE "variant
save
IT_EVENTS = FP_I_EVENTS[]
TABLES
T_OUTTAB = <F_OUTTAB>
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. " f_DISPLAY_block
*& Form f_create_catalog
text
-->P_C_TAB text
-->P_0085 text
-->P_0086 text
-->P_SPACE text
-->P_0088 text
-->P_5 text
-->P_I_FIELD_CAT_PART[] text
FORM F_CREATE_CATALOG USING FP_I_TABNAME TYPE
SLIS_TABNAME
FP_I_FIELDNAME TYPE SLIS_FIELDNAME
FP_I_SELTEXT TYPE
SCRTEXT_L
FP_I_DOSUM TYPE
CHAR1
FP_I_JUST TYPE C
FP_I_OUTPUTLEN TYPE
OUTPUTLEN
FP_I_FCAT TYPE
SLIS_T_FIELDCAT_ALV.
Record for field catalog
DATA: L_REC_FCAT TYPE SLIS_FIELDCAT_ALV.
L_REC_FCAT-TABNAME = FP_I_TABNAME.
L_REC_FCAT-FIELDNAME = FP_I_FIELDNAME.
L_REC_FCAT-SELTEXT_L = FP_I_SELTEXT.
L_REC_FCAT-DO_SUM = 'X'.
*l_rec_fcat-do_sum = ' '.
L_REC_FCAT-JUST = FP_I_JUST.
L_REC_FCAT-OUTPUTLEN = FP_I_OUTPUTLEN.
L_REC_FCAT-DECIMALS_OUT = '2'.
L_REC_FCAT-KEY = '1'.
APPEND L_REC_FCAT TO FP_I_FCAT.
ENDFORM. " f_create_catalog
Subroutines for Headings
*& Form f_display_header_partA
Display header for report for Part A
*& Form top_of_page
text
--> p1 text
<-- p2 text
FORM TOP_OF_PAGE .
SKIP 1.
WRITE:/25 ' Name of Company ',80 'RUN DATE' ,
SY-DATUM.
SKIP 1.
WRITE:/60 'RUN DATE' , SY-DATUM.
SKIP 1.
DATA: YR(4) TYPE N,
FIN_PRD(10) TYPE C.
IF S_DTABF-LOW+4(2) LT '04'.
YR = S_DTABF-LOW+0(4) - 1.
CONCATENATE YR '-' S_DTABF-LOW+2(2) INTO FIN_PRD.
ELSE.
YR = S_DTABF-LOW+0(4) + 1.
CONCATENATE S_DTABF-LOW0(4) '-' YR2(2) INTO
FIN_PRD.
ENDIF.
WRITE:/5 'DETAILS OF THE MONTH/DATE WISE DESPATCHES
MADE BY ROAD/RAIL DURING THE YEAR ' , FIN_PRD .
SKIP 1.
WRITE :/ 'SALES OFFICE : ' , P_SALES,' ' , RNAME.
SKIP 1.
ENDFORM. " DISPLAY_DATA
Award Points If Useful... -
Call function 'REUSE_ALV_GRID_DISPLAY' display like list alv
Hi experts,
I checked a standard tcode-IDCP.
It will be displayed like grid alv if I run it directly. However, it will be displayed like list alv if I call the tcode using BDC in a z-report even it call function 'REUSE_ALV_GRID_DISPLAY'.
Does anyone know why?
Kindly help.Hi Franklin,
I think when alv grid is running in background, it will be switched to basic list.
Here I list a part of code in FM 'REUSE_ALV_GRID_DISPLAY' (From Line 106 in ECC6EHP5):
if ( is_layout-allow_switch_to_list ne space
and boolean eq if_salv_c_bool_sap=>true )
or ( sy-binpt eq abap_true ).
perform globals_push.
call function 'REUSE_ALV_LIST_DISPLAY'
endif.
Thanks,
Sam -
How to use this function call function 'REUSE_ALV_COMMENTARY_WRITE' in alv
hi all
thanks in advance
how to use this function in alv programming
call function 'REUSE_ALV_COMMENTARY_WRITE'
why use and what purpose use this function plz tell me details
plz guide me
thanksHi
see this exmaple code where i had inserted a LOGO by useing this FM
*& Report ZTEST_ALV_LOGO
REPORT ztest_alv_logo.
TYPE-POOLS : slis.
*ALV Formatting tables /structures
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: gt_events TYPE slis_t_event.
DATA: gs_layout TYPE slis_layout_alv.
DATA: gt_page TYPE slis_t_listheader.
DATA: gs_page TYPE slis_listheader.
DATA: v_repid LIKE sy-repid.
*ALV Formatting work area
DATA: w_fieldcat TYPE slis_fieldcat_alv.
DATA: w_events TYPE slis_alv_event.
DATA: gt_bsid TYPE TABLE OF bsid WITH HEADER LINE.
INITIALIZATION.
PERFORM build_events.
PERFORM build_page_header.
START-OF-SELECTION.
*perform build_comment. "top_of_page - in initialization at present
SELECT * FROM bsid INTO TABLE gt_bsid UP TO 10 ROWS.
*perform populate_for_fm using '1' '3' 'BUKRS' '8' 'GT_BSID' 'Whee'.
*USING = Row, Column, Field name, display length, table name, heading
*OR
PERFORM build_fieldcat.
gs_layout-zebra = 'X'.
*top of page event does not work without I_callback_program
v_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_structure_name = 'BSID'
i_background_id = 'ALV_BACKGROUND'
i_grid_title = 'This is the grid title'
I_GRID_SETTINGS =
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
it_events = gt_events[]
TABLES
t_outtab = gt_bsid.
Form..............: populate_for_fm
Description.......: Populates fields for function module used in ALV
FORM populate_for_fm USING p_row
p_col
p_fieldname
p_len
p_table
p_desc.
w_fieldcat-row_pos = p_row. "Row Position
w_fieldcat-col_pos = p_col. "Column Position
w_fieldcat-fieldname = p_fieldname. "Field name
w_fieldcat-outputlen = p_len. "Column Lenth
w_fieldcat-tabname = p_table. "Table name
w_fieldcat-reptext_ddic = p_desc. "Field Description
w_fieldcat-input = '1'.
APPEND w_fieldcat TO gt_fieldcat.
CLEAR w_fieldcat.
ENDFORM. " populate_for_fm
*& Form build_events
FORM build_events.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gt_events.
READ TABLE gt_events
WITH KEY name = slis_ev_user_command
INTO ls_event.
IF sy-subrc = 0.
MOVE slis_ev_user_command TO ls_event-form.
APPEND ls_event TO gt_events.
ENDIF.
READ TABLE gt_events
WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE slis_ev_top_of_page TO ls_event-form.
APPEND ls_event TO gt_events.
ENDIF.
ENDFORM. " build_events
*& Form USER_COMMAND
When user command is called it uses 2 parameters. The itab
passed to the ALV is in whatever order it currently is on screen.
Therefore, you can read table itab index rs_selfield-tabindex to get
all data from the table. You can also check r_ucomm and code
accordingly.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
READ TABLE gt_bsid INDEX rs_selfield-tabindex.
error checking etc.
SET PARAMETER ID 'KUN' FIELD gt_bsid-kunnr.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDFORM. "user_command
*& Form top_of_page
Your own company logo can go here if it has been saved (OAOR)
If the logo is larger than the size of the headings in gt_page,
the window will not show full logo and will have a scroll bar. Thus,
it is a good idea to have a standard ALV header if you are going to
use logos in your top of page.
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = gt_page
i_logo = 'ENJOYSAP_LOGO'.
ENDFORM. "top_of_page
*& Form build_fieldcat
*Many and varied fields are available here. Have a look at documentation
*for FM REUSE_ALV_LIST_DISPLAY and REUSE_ALV_FIELDCATALOG_MERGE
FORM build_fieldcat.
w_fieldcat-fieldname = 'BUDAT'.
w_fieldcat-seltext_m = 'Dte pst'.
w_fieldcat-ddictxt(1) = 'M'.
w_fieldcat-edit = 'x'.
Can change the position of fields if you do not want them in order
of the DDIC or itab
w_fieldcat-row_pos = '1'.
w_fieldcat-col_pos = '10'.
APPEND w_fieldcat TO gt_fieldcat.
CLEAR w_fieldcat.
ENDFORM. " build_fieldcat
*& Form build_page_header
gt_page is used in top of page (ALV subroutine - NOT event)
*H = Header, S = Selection, A = Action
FORM build_page_header.
For Headers, Key is not printed and is irrelevant. Will not cause
a syntax error, but is not used.
gs_page-typ = 'H'.
gs_page-info = 'Header 1'.
APPEND gs_page TO gt_page.
gs_page-typ = 'H'.
gs_page-info = 'Header 2'.
APPEND gs_page TO gt_page.
For Selections, the Key is printed (bold). It can be anything up to 20
bytes. It gets printed in order of code here, not by key value.
gs_page-typ = 'S'.
gs_page-key = 'And the winner is:'.
gs_page-info = 'Selection 1'.
APPEND gs_page TO gt_page.
gs_page-typ = 'S'.
gs_page-key = 'Runner up:'.
gs_page-info = 'Selection 2'.
APPEND gs_page TO gt_page.
For Action, Key is also irrelevant.
gs_page-typ = 'A'.
gs_page-info = 'Action goes here'.
APPEND gs_page TO gt_page.
ENDFORM. " build_page_header -
How to adjust column length in function REUSE_ALV_GRID_DISPLAY
Hi,
I am using this function REUSE_ALV_GRID_DISPLAY to display .Please tell how to adjust the column length in this function, so that it is set to default field name size.
thanksHi anu,
The column width can be adjusted by using the following method:
-> define layout of the type.
data: it_layout type slis_layout_alv.
-> call the reuse alv... by using the is_layout field name with the above defined variable.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = <program that calls reuse>
I_CALLBACK_PF_STATUS_SET = < form to set pf-status>
I_CALLBACK_USER_COMMAND = <form to catch user command>
I_STRUCTURE_NAME = < structure to be passed>
I_GRID_TITLE = < any title to appear on top of the grid display>
IS_LAYOUT = it_layout
IT_FIELDCAT = IT_FIELDCAT[]
IT_EVENTS =
IT_EVENT_EXIT = I_EVENT_EXIT < to capture exit event>
I_SCREEN_START_COLUMN = 0 <screen settings>
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 = IT_INACT_OBJ
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
-> write a form to set the layout of the grid...
*& Form build_layout
text
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
Set layout field for row attributes(i.e. color)
gd_layout-info_fieldname = 'LINE_COLOR'.
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for double click or "click(press f2)
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
endform. " build_layout
endform.
This will optimize the output of the grid display.
Hope this helps!!!
Revert if any queries!!!
regards,
Naveenan. -
Hi All
My system is ECC6, unicode.
I had created a filed text(50), and i put 50 word into the field.
text = '123456789A123456789B123456789C123456789D123456789E'
When I used the function 'REUSE_ALV_GRID_DISPLAY' to list data
It only list 42 word on screen.
text = '123456789A123456789B123456789C123456789D12'
How to resolve it ???
Please help me.. Thanks in advance...
Regards,DDTHi
Where are you displaying text ? is that part of the column of the record or displaying on the header ?
I am able to display by setting like that .
[Check the screen shot.|http://bp1.blogger.com/_O5f8iAlgdNQ/SAD_cVWiN8I/AAAAAAAAA-U/VW2fzLZ1yIA/s1600-h/grid-744999.JPG]
and program for that .
REPORT zvenkat_alv_grid.
TABLES:t001.
"Types
TYPES:
BEGIN OF t_1001,
bukrs TYPE t001-bukrs,
butxt TYPE t001-butxt,
ort01 TYPE t001-ort01,
land1 TYPE t001-land1,
text TYPE string,
END OF t_1001.
"Work area
DATA:
w_t001 TYPE t_1001.
"Internal table
DATA:
i_t001 TYPE STANDARD TABLE OF t_1001.
" ALV Declarations
* Types Pools
TYPE-POOLS:
slis.
* Types
TYPES:
t_fieldcat TYPE slis_fieldcat_alv,
t_events TYPE slis_alv_event,
t_layout TYPE slis_layout_alv.
* Workareas
DATA:
w_fieldcat TYPE t_fieldcat,
w_events TYPE t_events,
w_layout TYPE t_layout.
* Internal Tables
DATA:
i_fieldcat TYPE STANDARD TABLE OF t_fieldcat,
i_events TYPE STANDARD TABLE OF t_events.
*& start of selection
START-OF-SELECTION.
PERFORM get_data.
*& end-of-selection.
END-OF-SELECTION.
PERFORM build_fieldcatlog.
PERFORM build_events.
PERFORM build_layout.
PERFORM list_display.
*& Form get_data
FORM get_data .
SELECT bukrs
butxt
ort01
land1
FROM t001
INTO TABLE i_t001
UP TO 30 ROWS.
w_t001-text = 'aaaaaaaaa1aaaaaaaaa2aaaaaaaaa3aaaaaaaaa4aaaaaaaaa5aaaaaaaaa6aaaaaaaaa7aaaaaaaaa8aaaaaaaaa9aaaaaaaa10'.
modify i_t001 FROM w_t001 INDEX 1.
ENDFORM. " get_data
*& Form build_fieldcatlog
FORM build_fieldcatlog .
CLEAR:w_fieldcat,i_fieldcat[].
PERFORM build_fcatalog USING:
'BUKRS' 'I_T001' 'BUKRS',
'BUTXT' 'I_T001' 'BUTXT',
'ORT01' 'I_T001' 'ORT01',
'LAND1' 'I_T001' 'LAND1',
'TEXT' 'I_T001' 'TEXT'.
ENDFORM. "BUILD_FIELDCATLOG
*& Form BUILD_FCATALOG
FORM build_fcatalog USING l_field l_tab l_text.
w_fieldcat-fieldname = l_field.
w_fieldcat-tabname = l_tab.
w_fieldcat-seltext_m = l_text.
IF l_field = 'TEXT'.
w_fieldcat-outputlen = '120'..
ENDIF.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
ENDFORM. " build_fieldcatlog
*& Form build_events
* text
FORM build_events.
CLEAR :
w_events, i_events[].
w_events-name = 'TOP_OF_PAGE'."Event Name
w_events-form = 'TOP_OF_PAGE'."Callback event subroutine
APPEND w_events TO i_events.
CLEAR w_events.
ENDFORM. "build_events
*& Form build_layout
FORM build_layout .
w_layout-colwidth_optimize = 'X'.
w_layout-zebra = 'X'.
ENDFORM. " build_layout
*& Form list_display
FORM list_display .
DATA:
l_program TYPE sy-repid.
l_program = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_program
is_layout = w_layout
it_fieldcat = i_fieldcat
it_events = i_events
TABLES
t_outtab = i_t001
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. " list_display
*& Form top_of_page
FORM top_of_page.
DATA :
li_header TYPE slis_t_listheader,
w_header LIKE LINE OF li_header.
DATA:
l_date TYPE char10.
WRITE sy-datum TO l_date.
w_header-typ = 'H'.
CONCATENATE sy-repid ':' 'From Date' l_date INTO w_header-info SEPARATED BY space.
APPEND w_header TO li_header.
CLEAR w_header.
w_header-typ = 'S'.
w_header-info = sy-title.
APPEND w_header TO li_header.
CLEAR w_header.
w_header-typ = 'A'.
w_header-info = sy-uname.
APPEND w_header TO li_header.
CLEAR w_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = li_header.
* w_fieldcat-fieldname = 'TEXT'.
* w_fieldcat-tabname = 'ITAB'.
* w_fieldcat-seltext_m = 'Text Description'. "Column heading.
* w_fieldcat-outputlen = '120'. "Max length 120
* APPEND w_fieldcat TO i_fieldcat.
* CLEAR w_fieldcat.
ENDFORM. "
Regards,
Venkat.O -
FUNCTION 'REUSE_ALV_GRID_DISPLAY': KEYBOARD ENTER
Hi ALV Experts,
in a user dialog, I call FUNCTION 'REUSE_ALV_GRID_DISPLAY' as a POPUP screen to show relevant data.
The User can leave the grid by closing the window (ALT-F4 or mouse-click on top-right-corner) or click the ENTER green hook in the menu bar below the grid.
Now they asked me why it does not react to hitting the ENTER key on the keyboard.
Actually, I know that SAP has problems with fully integrating some kind of standard, but I don't know if it is possible to make this ALV-popup sensible to detect the ENTER key.
Thank you to all readers,
also for all answers not related to the question
Regards,
ClemensThank you all,
it does not help. I do not use an own status and will not implement it.
OK, I implemented a call-back-functionality.
So, if the user doubleclicks on the information, the call-backk user_command is called and I set the parameter structure field selfield-exit = 'X'.
This way the grid is closed as well.
The thing is that the enter button of the status is set to application function &ONT. This function is not set as default. Hitting ENTER will not trigger anything at all.
Regards,
Clemens
P.S. How to award points to myself? <grin> -
FUNCTION 'REUSE_ALV_GRID_DISPLAY' with checkbox
Hello,
A short question.
I'm using the function 'REUSE_ALV_GRID_DISPLAY'. One of the columns is a character field which is displayed as a checkbox in the ALV by enabling the key "checkbox" and I also enable the "edit" key in the field catalog structure. So far so good.
But my question is the following:
When I set the key "edit" to false the ALV grid is displayed in a nice color grid. But when I enable the edit key the whole grid is showed in gray without the checkbox. Is it possible to set the checkbox to edit mode and also display the ALV grid in color?
An other question I have is the following:
Who could give me an example to use the grid in combination with special groups.
Kind regards,
Richard MeijnI'll put the most important parts of my code here:
When I anable the line "ls_fieldcat-edit = abap_true."
for the field 'ATB_SEL' the grid is showed in gray?
REPORT YMM_ATB_LIJST_GOEDGEKEURD2 no standard page heading
message-id ycdg.
TYPE-POOLS: SLIS,
sdydo,
abap, "ABAP reporting types / constants
icon. "Possible icons
DATA: fieldcatalog TYPE slis_t_fieldcat_alv ,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
Internal tables, needed for ALV formatting
DATA: ta_comment TYPE slis_t_listheader. "Top of page of the ALV
INCLUDE <icon>.
$$----
*-- Constants
$$----
CONSTANTS:
co_background_alv TYPE sdydo_key VALUE 'ALV_WALLPAPER',
co_save TYPE c VALUE 'A',
co_msgty_inf TYPE symsgty VALUE 'I'.
Constants for interactive functions of an ALV
CONSTANTS:
co_double_click TYPE syucomm VALUE '&IC1', "CHOOSE / F2
Customer interactive functions for the ALV
co_sec_list
TYPE syucomm VALUE 'SEC_LIST'.
"Secundary list
Names of the routines to be called dynamically from the ALV function
CONSTANTS:
co_rout_pf_stat TYPE char30 VALUE 'R0_SET_PF_STATUS',
co_rout_ucomm TYPE char30 VALUE 'R1_PROCESS_USER_COMMAND',
co_rout_top_of_page TYPE char30 VALUE 'R2_SET_TOP_OF_PAGE',
co_rout_html_top TYPE char30 VALUE 'R3_SET_HTML_TOP_OF_PAGE',
co_rout_html_end TYPE char30 VALUE 'R4_SET_HTML_END_OF_LIST',
co_rout_pf_stat_sec TYPE char30 VALUE 'R5_SET_PF_STATUS_SEC',
co_rout_ucomm_sec TYPE char30 VALUE 'R6_PROCESS_UCOMM_SEC',
co_rout_top_page_sec TYPE char30 VALUE 'R7_SET_TOP_OF_PAGE_SEC'.
CONSTANTS:
co_struc TYPE tabname VALUE '/CTAC/S_ALV_STRUCTURE',
co_struc_sec TYPE tabname VALUE '/CTAC/S_ALV_STRUC_SEC'.
CONSTANTS: line_feed(2) TYPE x VALUE '0D0A'.
FIELD-SYMBOLS <crlf> TYPE x.
DATA: w_crlf(2) TYPE c.
ASSIGN w_crlf TO <crlf> CASTING.
<crlf> = line_feed.
DATA:
BEGIN OF IT_EBAN occurs 0,
ATB_SEL(1) TYPE C, " Selectie optie om geselecteerde
" ATB's uit te printen.
ATB_FORM(4), " ATB icon om ingevoerd ATB-formulier
" te tonen.
banfn LIKE EBAN-banfn, " Aanvraag-tot-bestellen-nummer
bnfpo LIKE EBAN-bnfpo, " Positienummer van
" aanvraag tot bestellen
txz01 LIKE EBAN-txz01, " Korte tekst
matkl LIKE MARA-matkl, " Goederengroep
lifnr LIKE EBAN-lifnr, " Gewenste leverancier
name1 LIKE lfa1-name1, " Gewenste leverancier
lfdat LIKE EBAN-lfdat, " Leveringsdatum van de positie
opm(1) TYPE C,
bijlage(1) TYPE C,
controle(1) TYPE C, " Advies geselecteerd
onvolledig(1) TYPE C, "Om aan te geven dat er
" ongekeurde regels
" zijn
c_koptekst(1) TYPE C, " Om aan te geven dat er
" kopteksten zijn
badat LIKE EBAN-badat, " Aanvraagdatum
kritisch(1) TYPE C, " Om aan te geven dat de bestelling
" kritisch is
workflow(1) TYPE C, "Om aan te geven dat er nog een WF
" voor loopt
wf_old(1) TYPE C, "Er is een afgesloten WF of lopende WF
wi_id TYPE sww_wiid,
ernam LIKE eban-ernam, " Naam van de medewerker die
" het object heeft toegevoegd
preis LIKE EBAN-preis, " Prijs in de aanvraag tot bestellen
peinh LIKE EBAN-peinh, " Prijseenheid
menge LIKE EBAN-menge, " ATB-hoeveelheid
totaal TYPE GSWRT,
waers LIKE EBAN-waers, " Valutacode
koptekst TYPE string,
END OF it_eban.
*DATA: it_eban TYPE TABLE OF t_eban ,
DATA: wa_eban like it_eban.
*TYPES: BEGIN OF T_EBAN2,
DATA:
BEGIN OF IT_EBAN2 occurs 0,
BANFN LIKE EBAN-BANFN, " Aanvraag-tot-bestellen-nummer
BNFPO LIKE EBAN-BNFPO, " Positienummer van
" aanvraag tot bestellen
TXZ01 LIKE EBAN-TXZ01, " Korte tekst
MATKL LIKE MARA-MATKL, " Goederengroep
LIFNR LIKE EBAN-LIFNR, " Gewenste leverancier
NAME1 LIKE LFA1-NAME1, " Gewenste leverancier
END OF it_eban2.
*DATA: IT_EBAN2 TYPE TABLE OF T_EBAN2 with header line.
DATA: wa_eban2 like it_eban2.
DATA voor uitprinten rapporten
DATA: PARAMS LIKE PRI_PARAMS,
DAYS(1) TYPE N VALUE 2,
COUNT(3) TYPE N VALUE 1,
VALID TYPE C,
E_USR01 LIKE USR01.
DATA: BEGIN OF kopteksten OCCURS 1.
INCLUDE STRUCTURE tline.
DATA: END OF kopteksten.
DATA: BEGIN OF atb_kopteksten OCCURS 1,
banfn TYPE banfn.
INCLUDE STRUCTURE tline.
DATA: END OF atb_kopteksten.
DATA: line(256) TYPE c,
text_tab LIKE STANDARD TABLE OF line.
DATA: BEGIN OF atb_nummers OCCURS 1,
banfn type thead-tdname,
END OF atb_nummers.
DATA: BEGIN OF tlinetab OCCURS 10.
INCLUDE STRUCTURE tline.
DATA: END OF tlinetab.
DATA: BEGIN OF teksten OCCURS 10,
id(1),
veld(25),
waarde(40).
DATA: END OF teksten.
******************Workflow********************************************
DATA: worklist TYPE TABLE OF swr_wihdr,
wa_worklist TYPE swr_wihdr,
ibf_object TYPE sibflporb.
DATA: prev_banfn type banfn.
DATA: theader LIKE thead,
name_atb LIKE thead-tdname,
bedrijfsnr LIKE pa0001-bukrs.
DATA: ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm.
DATA: lpos TYPE I.
DATA: box(1) TYPE c.
DATA: lines TYPE I.
DATA: veld(20),
G_REPID LIKE SY-REPID,
init,
container TYPE REF TO cl_gui_custom_container,
editor TYPE REF TO cl_gui_textedit.
DATA: banfn_vorige TYPE banfn.
DATA: P_BANFN TYPE BANFN.
DATA: BUKRS LIKE PA0001-BUKRS.
DATA: Radio1, RADIO2, RADIO3.
Lijst kolomnamen
DATA: H1(6) VALUE 'ATB-nr',
H2(40) VALUE 'Omschrijving',
H3(2) VALUE 'GG',
H4(5) VALUE 'Levnr',
H5(35) VALUE 'Leverancier',
H6(10) VALUE 'Lev. Datum',
H7(6) VALUE '!BOCAT',
H8(10) VALUE 'Aanvr dat.',
H9(12) VALUE 'Invoerder',
H10(13) VALUE ' Totaal',
H11(3) VALUE 'Val'.
DATA: X TYPE I.
CALL screen 100.
INITIALIZATION.
PERFORM personeelsgegevens.
g_repid = sy-repid.
Part tor collect the data
*& Form BUILD_ALV_REPORT
text
FORM BUILD_ALV_REPORT.
perform build_field_cat CHANGING fieldcatalog[].
After building the field catalog (e.g., from a DDIC structure), we can
modify these settings in the following subroutine.
PERFORM modify_fieldcatalog CHANGING fieldcatalog[].
IF Not fieldcatalog is initial.
perform collect_data.
perform build_layout CHANGING gd_layout.
Table ta_comment is used to display header information in the
top-of-page of the ALV output.
PERFORM build_comment CHANGING ta_comment[].
Table gd_tab_group wordt gebruikt om een groepering op te bouwen.
PERFORM build_group CHANGING gd_tab_group[].
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = g_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = co_rout_ucomm
I_CALLBACK_TOP_OF_PAGE = co_rout_top_of_page
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = co_background_alv
I_GRID_TITLE = 'Lijst goedgekeurde ATBs'
I_GRID_SETTINGS =
IS_LAYOUT = gd_layout
IT_FIELDCAT = fieldcatalog
IT_EXCLUDING =
IT_SPECIAL_GROUPS = gd_tab_group[]
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
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 = it_eban
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.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
ENDFORM. " BUILD_ALV_REPORT
*& Form build_field_cat
text
--> p1 text
<-- p2 text
FORM build_field_cat CHANGING cta_fcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
DATA: ls_fieldcat type slis_t_fieldcat_alv with header line.
refresh fieldcatalog.
clear fieldcatalog.
ls_fieldcat-fieldname = 'BANFN'.
ls_fieldcat-ref_tabname = 'eban'.
ls_fieldcat-ref_fieldname = 'banfn'.
ls_fieldcat-checkbox = abap_true.
fieldcatalog-seltext_m = 'Aanvr nr'.
ls_fieldcat-col_pos = 0.
fieldcatalog-outputlen = 8.
ls_fieldcat-emphasize = abap_true.
ls_fieldcat-key = abap_true.
append ls_fieldcat to fieldcatalog.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = g_repid
I_INTERNAL_TABNAME = 'IT_EBAN'
I_STRUCTURE_NAME = 'IT_EBAN2'
I_CLIENT_NEVER_DISPLAY = abap_true
I_INCLNAME = g_repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = fieldcatalog
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " build_field_cat
*& Form modify_fieldcatalog
Modify the field catalog for the primary list, if needed!
You can set attributes for every column in the ALV output by
selecting the fieldname belonging to the column.
For an overview of the attributes available, see the
online documentation of function module REUSE_ALV_GRID_DISPLAY.
FORM modify_fieldcatalog CHANGING cta_fcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
Modify the field catalog according to the requirements.
Some examples are shown below.
LOOP AT cta_fcat INTO ls_fieldcat.
CASE ls_fieldcat-fieldname.
WHEN 'ATB_SEL'.
ls_fieldcat-seltext_m = 'ATB check'.
ls_fieldcat-outputlen = 2.
ls_fieldcat-edit = abap_true.
ls_fieldcat-input = 'X'.
ls_fieldcat-checkbox = abap_true.
WHEN 'ATB_FORM'.
ls_fieldcat-seltext_m = 'ATB formulier'.
ls_fieldcat-hotspot = abap_true.
ls_fieldcat-seltext_s = icon_protocol.
ls_fieldcat-outputlen = 2.
ls_fieldcat-icon = abap_true.
WHEN 'BANFN'.
ls_fieldcat-hotspot = abap_true.
WHEN 'NAME1'.
ls_fieldcat-ddictxt = 'S'.
ls_fieldcat-emphasize = abap_true.
ls_fieldcat-key = abap_true.
WHEN 'OPM'.
ls_fieldcat-seltext_m = 'O'.
ls_fieldcat-outputlen = 1.
WHEN 'BIJLAGE'.
ls_fieldcat-seltext_m = 'B'.
ls_fieldcat-outputlen = 1.
WHEN 'CONTROLE'.
ls_fieldcat-seltext_m = 'C'.
ls_fieldcat-outputlen = 1.
WHEN 'ONVOLLEDIG'.
ls_fieldcat-seltext_m = abap_true.
ls_fieldcat-outputlen = 1.
WHEN 'C_KOPTEKST'.
ls_fieldcat-seltext_m = 'T'.
ls_fieldcat-hotspot = abap_true.
ls_fieldcat-outputlen = 1.
WHEN 'KRITISCH'.
ls_fieldcat-seltext_m = '!'.
ls_fieldcat-outputlen = 1.
WHEN 'WORKFLOW'.
ls_fieldcat-seltext_m = 'W'.
ls_fieldcat-outputlen = 1.
WHEN 'WF_OLD'.
ls_fieldcat-seltext_m = 'A'.
ls_fieldcat-hotspot = abap_true.
ls_fieldcat-sp_group = 'A'.
ls_fieldcat-outputlen = 1.
WHEN 'KOPTEKST'.
ls_fieldcat-seltext_m = 'Koptekst'.
ls_fieldcat-hotspot = abap_false.
ls_fieldcat-outputlen = 25.
ENDCASE.
MODIFY fieldcatalog from ls_fieldcat.
clear ls_fieldcat.
endloop.
ENDFORM. " modify_fieldcatalog
*& Module USER_COMMAND_0500 INPUT
text
MODULE USER_COMMAND_0500 INPUT.
IF 500 = 500.
ENDIF.
ENDMODULE. " USER_COMMAND_0500 INPUT
*& Module USER_COMMAND_0510 INPUT
text
MODULE USER_COMMAND_0510 INPUT.
IF 510 = 510.
ENDIF.
ENDMODULE. " USER_COMMAND_0510 INPUT
*& Form r1_process_user_command
This routine deals with the "non-standard" GUI-functions.
It enables you to do the following:
- Double-click or click on a hotspotted field
- Implement your own GUI-functions
You'll find some predefined examples in this routine.
FORM r1_process_user_command "#EC CALLED
USING utp_ucomm TYPE syucomm
utp_selfield TYPE slis_selfield.
DATA: lta_list_sec TYPE TABLE OF /ctac/s_alv_struc_sec.
DATA: ltp_repid TYPE syrepid.
DATA: ltp_ebeln_num(10) TYPE n.
DATA: ltp_ebeln TYPE ebeln.
DATA: ltp_matnr TYPE matnr.
DATA: ltp_matnr_char(18) TYPE c.
Handle the specific user-commands.
CASE utp_ucomm.
Handle double click or hotspot on a specific field. *
These are some examples *
WHEN co_double_click.
read table IT_EBAN index utp_selfield-tabindex.
CASE utp_selfield-fieldname.
WHEN 'ATB_FORM'.
SUBMIT ymm_atb_formulierprint AND RETURN
WITH sel_atb = it_eban-banfn. " utp_selfield-value.
WHEN 'BANFN'.
CHECK NOT wa_eban IS INITIAL.
SET PARAMETER ID 'BAN' FIELD it_eban-banfn.
CALL FUNCTION 'ENQUEUE_EMEBANE'
EXPORTING
banfn = it_eban-banfn
bnfpo = it_eban-bnfpo.
IF sy-subrc = 0.
CALL FUNCTION 'DEQUEUE_EMEBANE'
EXPORTING
banfn = it_eban-banfn
bnfpo = it_eban-bnfpo.
CALL TRANSACTION 'ME53N' AND SKIP FIRST SCREEN.
WAIT UP TO 1 SECONDS.
LEAVE TO TRANSACTION 'YME60_INK'.
ENDIF.
WHEN 'WF_OLD'.
ibf_object-catid = 'BO'.
ibf_object-typeid = 'ZBUS2105'.
ibf_object-instid(3) = '000'.
WRITE it_eban-banfn TO ibf_object-instid+3.
CALL FUNCTION 'SWI_WF_CONNECTIONS_DISPLAY'
EXPORTING
ibf_object = ibf_object
popup = space.
WHEN 'C_KOPTEKST'.
CALL SCREEN 510.
WHEN OTHERS.
ENDCASE.
Handle your own GUI functions here *
For example, handle a secondary ALV List *
WHEN co_sec_list.
PERFORM build_sec_list TABLES lta_list_sec.
PERFORM display_sec_list TABLES lta_list_sec
CHANGING utp_selfield.
Or some other GUI-functions *
WHEN 'OKCODE_01'.
Actions for this okcode
WHEN OTHERS.
ENDCASE.
ENDFORM. "R1_PROCESS_USER_COMMAND
*& Form build_comment
Create the internal table that is going to be the TOP-OF-PAGE
of the ALV grid or list.
FORM build_comment CHANGING cta_top_of_page TYPE slis_t_listheader.
DATA: lwa_line TYPE slis_listheader.
REFRESH cta_top_of_page.
LIST HEADING LINE: TYPE H
CLEAR lwa_line.
lwa_line-typ = 'H'.
LLINE-KEY: NOT USED FOR THIS TYPE
lwa_line-info = text-100.
APPEND lwa_line TO cta_top_of_page.
STATUS LINE: TYPE S
CLEAR lwa_line.
lwa_line-typ = 'S'.
lwa_line-key = text-101.
lwa_line-info = text-102.
APPEND lwa_line TO cta_top_of_page.
lwa_line-key = ' '.
lwa_line-key = text-103.
lwa_line-info = text-103.
APPEND lwa_line TO cta_top_of_page.
ACTION LINE: TYPE A
CLEAR lwa_line.
lwa_line-typ = 'A'.
LLINE-KEY: NOT USED FOR THIS TYPE
lwa_line-info = text-105.
APPEND lwa_line TO cta_top_of_page.
ENDFORM. " build_comment
FORM R2_SET_TOP_OF_PAGE *
Put the content of table TA_COMMENT on the top of the ALV *
FORM r2_set_top_of_page. "#EC CALLED
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = ta_comment
EXCEPTIONS
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. "R2_SET_TOP_OF_PAGE
*& Form build_group
text
<--P_TA_SP_GROUP[] text
FORM build_group CHANGING P_TA_SP_GROUP TYPE slis_t_sp_group_alv.
DATA: ls_sp_group TYPE slis_sp_group_alv.
clear ls_sp_group.
ls_sp_group-sp_group = 'A'.
ls_sp_group-text = 'ATBs ter goedkeuring bij adviseur'.
append ls_sp_group to P_TA_SP_GROUP.
ls_sp_group-sp_group = 'B'.
ls_sp_group-text = 'ATBs goedgekeurd'.
append ls_sp_group to P_TA_SP_GROUP.
ENDFORM. " build_group
*& Form BUILD_LAYOUT
Build layout for ALV grid report
form build_layout changing gd_layout type slis_layout_alv.
gd_layout-no_input = 'X'.
*gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_only = 'X'.
gd_layout-totals_text = 'Totaal'(201).
*gd_layout-group_change_edit = 'X'.
*gd_layout-GROUP_BUTTONS = 'A'.
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
I'll hope this is anough code?
Kind regards,
Richard Meijn -
Modify toolbar for alv using CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
Hi Experts,
I am using CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' inside an exit.
I need to modify the tolbar with just three options :-
a- add new row
b- delete rows
c- save data
Please guide me step by step as how to proceed as I am very new to ALV.
and after applying your solution to show the toolbar what should I do to Make these buttons working.
Thanks a lot for your replies in advance.
regards,
UditI'm not really sure why you would use an ALV grid display in a user exit. I'm not sure how that works. Another point is that the ALV object is really easier to use once you get used to it.
However:
Usually you would create a GUI status, and just add your buttons to it. Then when the function module is called specify the gui status, and user command.
For example
v_repid = sy-repid.
w_user_command = 'USER_COMMAND'
w_set_status = "Status you define below.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_bypassing_buffer = 'X'
i_callback_program = w_repid
i_callback_pf_status_set = w_set_status
i_callback_user_command = w_user_command
is_layout = w_layout
i_structure_name = 'ZGOODSMOVE'
tables
t_outtab = gt_outtab
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
message e000 with 'Error in Displaying the Output Report'(025).
endif.
Put your code for the different functions into one user function module
form user_command using r_comm like sy-ucomm
rs_selfield type slis_selfield.
read table it_final1 index rs_selfield-tabindex. " This will give you back the row you selected
if sy-subrc = 0.
endif.
endform.
To define the GUI Status:
Copy the status from
Then change it to add your fields -
Popup with the function 'Reuse_alv_grid_display'
Hello everyone,
I have a problem when I use the function module as pop_up where you can edit your input.
The table, after the function module was called, not always contains the values that the user typed.
An example is:
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZZBSEG'
CHANGING
ct_fieldcat = gt_fieldcat[].
READ TABLE gt_fieldcat WITH KEY fieldname = 'AUFNR'.
IF sy-subrc = 0.
gt_fieldcat-input = 'X'.
gt_fieldcat-edit = 'X'.
MODIFY gt_fieldcat INDEX sy-tabix.
ENDIF.
SELECT * INTO TABLE tab
FROM zzbseg
WHERE belnr = '0100000018'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
i_structure_name = 'ZZBSEG'
i_buffer_active = ' '
is_layout = l_layout
it_fieldcat = gt_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
i_save = space
IS_VARIANT = ' '
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
i_screen_start_column = 10
i_screen_start_line = 1
i_screen_end_column = 100
i_screen_end_line = 10
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = tab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
BREAK-POINT.If anyone else is interested:
SAP resolved an error in the coding,
now the IT_ALV_GRAPHICS can also be used
in REUSE_ALV_GRID_DISPLAY.
As for the line feed:
Use the constant
cl_abap_char_utilities=>cr_lf
in the CONCATENATE command. -
Dear All,
IN ABAP ALV reports, we r calling verious function. For ex 'REUSE_ALV_GRID_DISPLAY'. Could u provide me the information about these functions?.
AS What is the use of this function?
Which input parameter r required?
I tried SE37.
But how to use it?
Pl explain.
S Y CHAUDHARI
Moderator Message: RoE violation. Please search before posting.
Edited by: Suhas Saha on Sep 8, 2011 1:43 PMI have explained the simple usage of this function below.
type-pools : slis.
data : it_fieldcat type table of slis_fieldcat_alv,
wa_fieldcat type slis_fieldcat_alv,
it_listheader type slis_t_listheader with header line.
***use this syntax to generate the output fields required.
data : col_pos type i.
col_pos = col_pos + 1.
wa_fieldcat-fieldname = 'PLANT'.
wa_fieldcat-seltext_s = 'Plant'.
wa_fieldcat-col_pos = col_pos.
wa_fieldcat-tabname = 'IT_FINAL'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
It_final is your internal table containing information to diaplay in output.
***this is used to generate the header information
data : ls_line type slis_listheader.
move 'Demo Report' to ls_line.
it_listheader-info = ls_line.
it_listheader-typ = 'H'.
append it_listheader.
clear it_listheader.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE '
IT_FIELDCAT = it_fieldcat
I_SAVE = 'A'
TABLES
T_OUTTAB = it_final.
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = it_listheader[]
ENDFORM.
you should be able to view the output when executed using an executable program. -
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 -
How can I call functionality of ALV Grid by event of button outside grid?
Hello,
How can I call functionality of ALV Grid by event of button located outside ALV Grid? For example how to fire printing of this ALV Grid by button click elsewhere on the screen (not in toolbar of ALV Grid).
Best regards,
Josef Motlhi Motl,
these are steps to create a button in ALV and trigger an event from it..
1.Use the parameter i_callback_pf_status_set in the function module REUSE_ALV_GRID_DISPLAY
i_callback_program = gd_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
form set_pf_status using rt_extab type slis_t_extab.
set pf-status 'NEWALVSTATUS'.
endform.
You have to copy the standard ALV pf stauts to 'NEWALVSTATUS' and add your button.
2.You have to do the following to process the new button click.
i_callback_user_command = 'USER_COMMAND'
form user_command using i_ucomm like sy-ucomm
is_selfield type slis_selfield.
case i_ucomm.
3. to copy the standard pf status to a new one.go to the ALV screen and take the menu System -> Status. Then look for the standard pf status. Copy this to Z range and then add your new button.
reward points if helpful
regards
satesh -
Call function POPUP_TO_CONFIRM after Excel close
Good morning
I have written code like this
DATA: EXCEL TYPE OLE2_OBJECT.
DATA: BOOKS TYPE OLE2_OBJECT.
DATA: BOOK TYPE OLE2_OBJECT.
DATA: CELL TYPE OLE2_OBJECT.
DATA: FONT TYPE OLE2_OBJECT.
DATA: FILE TYPE OLE2_OBJECT.
CREATE OBJECT EXCEL 'EXCEL.APPLICATION'.
CALL METHOD OF EXCEL 'WORKBOOKS' = FILE.
CALL METHOD OF FILE 'OPEN'
EXPORTING
#1 = 'C:temp8D.xls'
#2 = 1.
CALL METHOD OF EXCEL 'CELLS' = CELL
EXPORTING
#1 = 6
#2 = 'C'.
SET PROPERTY OF CELL 'VALUE' = zak_pomoc.
CALL METHOD OF EXCEL 'QUIT'.
FREE OBJECT EXCEL.
If user has modified the 8D file I want display this file on the screen, but first function POPUP_TO_CONFIRM should ask him if he really wants to show file.
I make it like this.
call function 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Display report'
TEXT_QUESTION = 'Display report 8D?'
DEFAULT_BUTTON = '1'
DISPLAY_CANCEL_BUTTON = 'X'
START_COLUMN = 25
START_ROW = 6
IMPORTING
answer = ans.
if ans eq '1'.
DATA gs_excel TYPE ole2_object .
DATA gs_wbooks TYPE ole2_object .
DATA gs_wbook TYPE ole2_object .
DATA gs_application TYPE ole2_object .
CREATE OBJECT gs_excel 'EXCEL.APPLICATION' .
SET PROPERTY OF gs_excel 'Visible' = 1 .
GET PROPERTY OF gs_excel 'Workbooks' = gs_wbooks .
GET PROPERTY OF gs_wbooks 'Application' = gs_application .
*--Opening the existing document
CALL METHOD OF gs_wbooks 'Open' = gs_wbook
EXPORTING
#1 = 'c:temp8D.xls'.
endif.
But there is my problem because two windows: first- asking about saving the file and the second- asking about showing the file, pop up in this same time.
What condition should I write to call second window after this first one?
Please, any suggestions?
Thank you.Hello
I'm just beginner and there is one thing I don't understand. Between lines
CALL METHOD OF EXCEL 'QUIT'
and
FREE OBJECT EXCEL
the window 'Do you want save changes' appears. And in that moment what is the value that says if the user chooses OK or QUIT?
If I would know that value, I could call function POPUP_TO_CONFIRM in the right moment. -
Call Function Destination in a background job
I am having a problem using:
CALL FUNCTION 'TABLE_ENTRIES_GET_VIA_RFC'
DESTINATION p_dest
in a background job.
I am working on a program that would compare the same table in 2 different systems and write the differences. It works when I run it in the foreground. However, I want to run this in a nightly background job. However, it is failing and I beleive that it is the result of the program needing a user to interactively logon to the remote system.
How can I bypass the logon screen or enter information into the logon screen using a background job?
Thanks.
JonHi Jonathan,
Would you like to reward some points to the poster to thank them as a part of SDN Contributor Recognition Program?
You can click on the yellow star on the right of each post header to reward points.
For more information:
https://www.sdn.sap.com/sdn/index.sdn?page=crp_help.htm
John.
Maybe you are looking for
-
Line Order in Purchase Requisition Lines
Hi All, I noticed that when requisitions are created through 'Requisition Import' Concurrent process, Lines in the requisition are sorted based on Description. It is not considering the line order in interface table (po_requisitions_interface_all). I
-
Sql server agent job with SSIS
Hello Experts i have a sql server agent job that has four steps in tsql,ssis,tsql and tsql orders. the job run automatically every night and i copy paste the error message right here, any ideas please: Date 1/27/2014 7:30:00 AM L
-
Why is InDesign CC working so slow? The slowest version ever. I have worked with InDesign since the
-
hi.. i need to include a image containing metadata into database and at the same time i need to view and edit the metadata. can anybody suggest me how it is done. i used xml as a medium to exchange the files using cold fusion, is that a correct way?
-
Hey Martin, It wud be gr8 if U can give some example of enabling Alternative 2 for gateways (Exclusive). I am facing issue while evaluating condition for gateway...(Alternative2). Probably using a Scenario as given below would be of much help to me :