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
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'
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 -
Can we display ICONS in ALV list?
Hi,
Is it possible to display icons (ICON_GREEN_LIGHT) in the ALV list using the function module REUSE_ALV_LIST_DISPLAY.
Is there any possibility of displaying a list using object oriented ALV?
Thanks and Regards,
Lakshmi.Hi Lakshmi,
Just check this once.
REPORT Zxxx MESSAGE-ID ZZ .
*& TABLES DECLARATION *
TABLES: VBAK.
*& TYPE POOLS DECLARATION *
TYPE-POOLS: SLIS.
*& INTERNAL TABLE DECLARATION *
DATA: BEGIN OF ITAB OCCURS 0,
ICON TYPE ICON-ID,
VBELN LIKE VBAK-VBELN,
AUDAT LIKE VBAK-AUDAT,
VBTYP LIKE VBAK-VBTYP,
AUART LIKE VBAK-AUART,
AUGRU LIKE VBAK-AUGRU,
NETWR LIKE VBAK-NETWR,
WAERK LIKE VBAK-WAERK,
END OF ITAB.
*INTERNAL TABLE FOR FIELD CATALOG
DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV
WITH HEADER LINE,
*INTERNAL TABLE FOR EVENTS
DATA: IT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT,
*INTERNAL TABLE FOR SORTING
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV,
*INTERNAL TABLE FOR LAYOUT
WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
*& VARIABLE DECLARATION *
DATA : V_REPID TYPE SY-REPID,
V_PAGNO(4) TYPE N,
V_DATE(8) TYPE C.
*& CONSTANTS *
CONSTANTS: C_X TYPE C VALUE 'X'.
*& SELECTION SCREEN *
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN,
S_VBTYP FOR VBAK-VBTYP DEFAULT 'C'.
SELECTION-SCREEN: END OF BLOCK B1.
SELECTION-SCREEN: BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) TEXT-003.
PARAMETERS: P_LIST RADIOBUTTON GROUP RAD1 DEFAULT 'X'.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) TEXT-004.
PARAMETERS: P_GRID RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN: END OF BLOCK B2.
AT SELECTION-SCREEN.
PERFORM VALIDATE_SCREEN.
*& START OF SELECTION *
START-OF-SELECTION.
CLEAR: ITAB, ITAB[].
V_REPID = SY-REPID.
PERFORM GET_DATA.
PERFORM DISPLAY_DATA.
*& END OF SELECTION *
END-OF-SELECTION.
*--DO ALV Process
V_REPID = SY-REPID.
*--Sort the Output Fields
PERFORM SORT_FIELDS.
*--Build Field catalog for the Output fields
PERFORM BUILD_FIELDCAT.
*--Set the Layout for ALV
PERFORM SET_LAYOUT.
*& Form GET_DATA
text
TO GET THE DATA FROM TABLES INTO ITAB
FORM GET_DATA .
SELECT VBELN
AUDAT
VBTYP
AUART
AUGRU
NETWR
WAERK
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM VBAK
WHERE VBELN IN S_VBELN AND
AUDAT > '04.04.2005'
AND NETWR > 0.
LOOP AT ITAB.
IF ITAB-NETWR < 10000.
ITAB-ICON = '@08@'.
ELSEIF ITAB-NETWR > 10000 AND ITAB-NETWR < 100000.
ITAB-ICON = '@09@'.
ELSEIF ITAB-NETWR > 100000.
ITAB-ICON = '@0A@'.
ENDIF.
MODIFY ITAB INDEX SY-TABIX.
ENDLOOP.
ENDFORM. " GET_DATA
*& Form sort_fields
FORM SORT_FIELDS .
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'VBTYP'.
WA_SORT-SPOS = '1'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'NETWR'.
WA_SORT-SPOS = '2'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
ENDFORM. " sort_fields
*& Form build_fieldcat
*FORM BUILD_FIELDCAT .
IT_FIELDCAT-COL_POS = '1'.
IT_FIELDCAT-FIELDNAME = 'ICON'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '10'.
IT_FIELDCAT-SELTEXT_L = 'LIGHT'.
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '2'.
IT_FIELDCAT-FIELDNAME = 'VBELN'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '10'.
IT_FIELDCAT-SELTEXT_L = 'SALES DOC NUMBER'(009).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '3'.
IT_FIELDCAT-FIELDNAME = 'AUDAT'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '4'.
IT_FIELDCAT-SELTEXT_L = 'DOCUMENT DATE'(010).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '4'.
IT_FIELDCAT-FIELDNAME = 'VBTYP'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '4'.
IT_FIELDCAT-SELTEXT_L = 'CATEGORY'(011).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '5'.
IT_FIELDCAT-FIELDNAME = 'AUART'.
IT_FIELDCAT-OUTPUTLEN = '4'.
IT_FIELDCAT-SELTEXT_L = 'DOCUMENT TYPE'(012).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '6'.
IT_FIELDCAT-FIELDNAME = 'AUGRU'.
IT_FIELDCAT-OUTPUTLEN = '12'.
IT_FIELDCAT-SELTEXT_L = 'Order reason'(013).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '7'.
IT_FIELDCAT-FIELDNAME = 'NETWR'.
IT_FIELDCAT-OUTPUTLEN = '12'.
IT_FIELDCAT-SELTEXT_L = 'NET VALUE'(014).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '8'.
IT_FIELDCAT-FIELDNAME = 'WAERK'.
IT_FIELDCAT-OUTPUTLEN = '12'.
IT_FIELDCAT-SELTEXT_L = 'SD DOC CURR'(015).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
*ENDFORM. " build_fieldcat
*& Form set_layout
FORM SET_LAYOUT .
IF P_LIST = C_X .
WA_LAYOUT-WINDOW_TITLEBAR = 'LIST DISPLAY'(016).
WA_LAYOUT-ZEBRA = 'X'.
*-- ALV LIST DISPLAY
PERFORM LIST_DISPLAY TABLES ITAB.
*-- ALV GRID DISPLAY
ELSEIF P_GRID = C_X.
WA_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'(017).
WA_LAYOUT-ZEBRA = 'X'.
PERFORM GRID_DISPLAY TABLES ITAB.
ENDIF.
ENDFORM. " set_layout
*& Form list_display
FORM LIST_DISPLAY TABLES P_ITAB .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_SORT = IT_SORT[]
I_SAVE = 'U'
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " list_display
*& Form GRID_DISPLAY
FORM GRID_DISPLAY TABLES P_ITAB .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_SORT = IT_SORT[]
IT_EVENTS = IT_EVENT
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " GRID_DISPLAY
*& Form VALIDATE_SCREEN
text
--> p1 text
<-- p2 text
FORM VALIDATE_SCREEN .
DATA: LV_VBELN LIKE VBAK-VBELN.
IF NOT S_VBELN IS INITIAL.
SELECT VBELN
INTO LV_VBELN
UP TO 1 ROWS
FROM VBAK
WHERE VBELN IN S_VBELN.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'INVALID SALES DOC'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_SCREEN
*& Form display_data
text
--> p1 text
<-- p2 text
FORM DISPLAY_DATA .
DEFINE M_FIELDCAT.
ADD 1 TO WA_FIELDCAT-COL_POS.
WA_FIELDCAT-FIELDNAME = &1.
WA_FIELDCAT-REF_TABNAME = 'VBAK'.
WA_FIELDCAT-DO_SUM = &2.
WA_FIELDCAT-CFIELDNAME = &3.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
END-OF-DEFINITION.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
m_fieldcat 'ICON' '' ''.
m_fieldcat 'VBELN' '' ''.
m_fieldcat 'AUDAT' '' ''.
m_fieldcat 'VBTYP' '' ''.
m_fieldcat 'AUART' '' ''.
m_fieldcat 'AUGRU' '' ''.
m_fieldcat 'NETWR' 'C' 'WAERK'.
m_fieldcat 'WAERK' '' ''.
ENDFORM. " display_data
hope it helps u
regards
laxmi -
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 -
Display Total in ALV-List-urgent
Hi,
I have an ALV-List with an amount column...I have to show the total at the end of the list..Calculation of total can be done in the internal table but how to display it neatly just below the itab-amount with a tag Total : 29000000 .Kindly help.
Thanks..see this below example
REPORT yktest.
*& TABLES DECLARATION *
TABLES : ekko, ekpo, t001w, t161t, lfa1.
*& INTERNAL TABLE DECLARATION *
TYPES : BEGIN OF tp_itab1,
bukrs TYPE ekko-bukrs,
lifnr TYPE ekko-lifnr,
ebeln TYPE ekko-ebeln,
waers TYPE ekko-waers,
bsart TYPE ekko-bsart,
ekorg TYPE ekko-ekorg,
ekgrp TYPE ekko-ekgrp,
ebelp TYPE ekpo-ebelp,
txz01 TYPE ekpo-txz01,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
netwr TYPE ekpo-netwr,
name1 TYPE t001w-name1,
header_text(132),
chk TYPE c,
END OF tp_itab1.
DATA : t_itab1 TYPE STANDARD TABLE OF tp_itab1,
wa_itab1 TYPE tp_itab1,
ws_name1 TYPE t001w-name1.
DATA : f_itab1 TYPE STANDARD TABLE OF tp_itab1,
wa_fitab1 TYPE tp_itab1.
DATA : f_itab2 TYPE STANDARD TABLE OF tp_itab1,
wa_fitab2 TYPE tp_itab1.
TYPES : BEGIN OF tp_name1,
werks TYPE t001w-werks,
name1 TYPE t001w-name1,
END OF tp_name1.
DATA : t_name1 TYPE STANDARD TABLE OF tp_name1,
wa_name1 TYPE tp_name1.
DATA : t_lfa1 TYPE STANDARD TABLE OF lfa1,
wa_lfa1 TYPE lfa1.
DATA: hold_tabix TYPE sy-tabix.
DATA : t_tlinetab TYPE STANDARD TABLE OF tline,
wa_tlinetab TYPE tline.
DATA: ws_name TYPE thead-tdname,
ws_repid TYPE sy-repid VALUE 'YKTEST'.
DATA : repid TYPE sy-repid.
DATA : total TYPE p DECIMALS 2,
quantity TYPE p DECIMALS 3.
CONSTANTS : ws_id TYPE thead-tdid VALUE 'F01',
ws_object TYPE thead-tdobject VALUE 'EKKO',
lc_view(1) TYPE c VALUE 'F',
lc_form(10) TYPE c VALUE 'YK_FORM'.
*& ALV DECLARATION *
TYPE-POOLS : slis.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv,
lf_fieldcat TYPE slis_fieldcat_alv.
DATA: lh_index LIKE lf_fieldcat-col_pos.
DATA: l_layout TYPE slis_layout_alv.
DATA : l_sort TYPE slis_t_sortinfo_alv,
w_sort TYPE slis_sortinfo_alv.
*& SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP 2.
SELECT-OPTIONS: s_bukrs FOR ekko-bukrs OBLIGATORY.
SELECT-OPTIONS: s_lifnr FOR ekko-lifnr OBLIGATORY.
SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
PARAMETERS: p_bsart TYPE ekko-bsart.
SELECT-OPTIONS: s_matnr FOR ekpo-matnr.
SELECT-OPTIONS: s_ekorg FOR ekko-ekorg.
SELECT-OPTIONS: s_ekgrp FOR ekko-ekgrp.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN END OF BLOCK a1.
*& START-OF-SELECTION *
START-OF-SELECTION.
FETCHING DATA
PERFORM fetch_data.
BUILD FIELD CATALOG
PERFORM build_fieldcatalog.
BUILD LAYOUT
PERFORM build_layout.
SORT LAYOUT
PERFORM sort_layout.
*& END-OF-SELECTION. *
END-OF-SELECTION.
*DISPLAY GRID
PERFORM display_grid.
*& Form fetch_data *
FORM fetch_data.
IF p_bsart IS INITIAL.
SELECT ekko~bukrs
ekko~lifnr
ekko~ebeln
ekko~waers
ekko~bsart
ekko~ekorg
ekko~ekgrp
ekpo~ebelp
ekpo~txz01
ekpo~matnr
ekpo~werks
ekpo~menge
ekpo~meins
ekpo~netpr
ekpo~netwr
INTO TABLE t_itab1 FROM
ekko INNER JOIN ekpo ON ekkoebeln = ekpoebeln
WHERE ekko~ebeln IN s_ebeln AND
ekko~bukrs IN s_bukrs AND
ekko~lifnr IN s_lifnr AND
ekko~ekorg IN s_ekorg AND
ekko~ekgrp IN s_ekgrp AND
ekpo~matnr IN s_matnr.
ELSE.
SELECT ekko~bukrs
ekko~lifnr
ekko~ebeln
ekko~waers
ekko~bsart
ekko~ekorg
ekko~ekgrp
ekpo~ebelp
ekpo~txz01
ekpo~matnr
ekpo~werks
ekpo~menge
ekpo~meins
ekpo~netpr
ekpo~netwr
INTO TABLE t_itab1 FROM
ekko INNER JOIN ekpo ON ekkoebeln = ekpoebeln
WHERE ekko~ebeln IN s_ebeln AND
ekko~bukrs IN s_bukrs AND
ekko~lifnr IN s_lifnr AND
ekko~ekorg IN s_ekorg AND
ekko~ekgrp IN s_ekgrp AND
ekpo~matnr IN s_matnr AND
ekko~bsart = p_bsart.
ENDIF.
IF NOT t_itab1[] IS INITIAL.
FETCHING NAME1
SELECT werks
name1
FROM t001w
INTO TABLE t_name1
FOR ALL ENTRIES IN t_itab1
WHERE werks = t_itab1-werks.
SORT t_itab1 BY werks.
SORT t_name1 BY werks.
IF sy-subrc = 0.
LOOP AT t_itab1 INTO wa_itab1.
hold_tabix = sy-tabix.
READ TABLE t_name1 INTO wa_name1 WITH KEY werks = wa_itab1-werks
BINARY SEARCH.
IF sy-subrc = 0.
wa_itab1-name1 = wa_name1-name1.
MODIFY t_itab1 INDEX hold_tabix FROM wa_itab1.
ENDIF.
FETCHING HEADER TEXT
MOVE wa_itab1-ebeln TO ws_name.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = ws_id
language = sy-langu
name = ws_name
object = ws_object
TABLES
lines = t_tlinetab
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc = 0.
LOOP AT t_tlinetab INTO wa_tlinetab.
wa_itab1-header_text = wa_tlinetab-tdline.
MODIFY t_itab1 FROM wa_itab1.
ENDLOOP.
ENDIF. " IF sy-subrc = 0.
CLEAR : wa_itab1,
hold_tabix,
wa_name1.
ENDLOOP.
ENDIF.
ENDIF. " IF NOT t_itab1[] IS INITIAL.
IF t_itab1[] IS INITIAL.
MESSAGE i000(zg) WITH text-008.
ENDIF.
SORT : t_itab1 BY bukrs lifnr ebeln ebelp.
ENDFORM. " fetch_data
*& Form build_fieldcatalog *
FORM build_fieldcatalog .
COMPANY CODE
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'BUKRS'.
lf_fieldcat-ref_tabname = 'EKKO'.
lf_fieldcat-ref_fieldname = 'BUKRS'.
lf_fieldcat-fix_column = 'X'.
APPEND lf_fieldcat TO lt_fieldcat.
VENDOR
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'LIFNR'.
lf_fieldcat-ref_tabname = 'EKKO'.
lf_fieldcat-ref_fieldname = 'LIFNR'.
lf_fieldcat-fix_column = 'X'.
APPEND lf_fieldcat TO lt_fieldcat.
PURCHASING DOCUMENT NUMBER
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'EBELN'.
lf_fieldcat-ref_tabname = 'EKKO'.
lf_fieldcat-ref_fieldname = 'EBELN'.
lf_fieldcat-key = 'X'.
lf_fieldcat-do_sum = 'X'.
lf_fieldcat-fix_column = 'X'.
APPEND lf_fieldcat TO lt_fieldcat.
ITEM NUMBER OF PURCHASING DOCUMENT
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'EBELP'.
lf_fieldcat-ref_tabname = 'EKPO'.
lf_fieldcat-ref_fieldname = 'EBELP'.
APPEND lf_fieldcat TO lt_fieldcat.
SHORT TEXT
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'TXZ01'.
lf_fieldcat-ref_tabname = 'EKPO'.
lf_fieldcat-ref_fieldname = 'TXZ01'.
APPEND lf_fieldcat TO lt_fieldcat.
MATERIAL NUMBER
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'MATNR'.
lf_fieldcat-ref_tabname = 'EKPO'.
lf_fieldcat-ref_fieldname = 'MATNR'.
APPEND lf_fieldcat TO lt_fieldcat.
PLANT
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'WERKS'.
lf_fieldcat-ref_tabname = 'EKPO'.
lf_fieldcat-ref_fieldname = 'WERKS'.
APPEND lf_fieldcat TO lt_fieldcat.
NAME
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'NAME1'.
lf_fieldcat-ref_tabname = 'T001W'.
lf_fieldcat-ref_fieldname = 'NAME1'.
APPEND lf_fieldcat TO lt_fieldcat.
PURCHASE ORDER QUANTITY
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'MENGE'.
lf_fieldcat-ref_tabname = 'EKPO'.
lf_fieldcat-ref_fieldname = 'MENGE'.
lf_fieldcat-do_sum = 'X'.
lf_fieldcat-qfieldname = 'MEINS'.
APPEND lf_fieldcat TO lt_fieldcat.
UNIT
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'MEINS'.
lf_fieldcat-ref_tabname = 'EKPO'.
lf_fieldcat-ref_fieldname = 'MEINS'.
APPEND lf_fieldcat TO lt_fieldcat.
NET PRICE IN PURCHASING DOCUMENT
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'NETPR'.
lf_fieldcat-ref_tabname = 'EKPO'.
lf_fieldcat-ref_fieldname = 'NETPR'.
lf_fieldcat-cfieldname = 'WAERS'.
lf_fieldcat-do_sum = 'X'.
APPEND lf_fieldcat TO lt_fieldcat.
NET ORDER VALUE IN PO CURRENCY
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'NETWR'.
lf_fieldcat-ref_tabname = 'EKPO'.
lf_fieldcat-ref_fieldname = 'NETWR'.
lf_fieldcat-cfieldname = 'WAERS'.
lf_fieldcat-do_sum = 'X'.
APPEND lf_fieldcat TO lt_fieldcat.
CURRENCY
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'WAERS'.
lf_fieldcat-ref_tabname = 'EKKO'.
lf_fieldcat-ref_fieldname = 'WAERS'.
APPEND lf_fieldcat TO lt_fieldcat.
HEADER TEXT
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'HEADER_TEXT'.
lf_fieldcat-seltext_m = 'Header Text'.
APPEND lf_fieldcat TO lt_fieldcat.
ENDFORM. " build_fieldcatalog
*& Form display_grid *
FORM display_grid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = ws_repid
i_callback_pf_status_set = 'PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
is_layout = l_layout
it_fieldcat = lt_fieldcat
it_sort = l_sort
i_save = 'X'
IMPORTING
TABLES
t_outtab = t_itab1
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " display_grid
*& Form build_layout *
FORM build_layout .
l_layout-colwidth_optimize = 'X'.
l_layout-zebra = 'X'.
l_layout-box_fieldname = 'CHK'.
l_layout-box_tabname = 'T_ITAB1' .
ENDFORM. " build_layout
*& Form sort_layout *
FORM sort_layout .
CLEAR w_sort.
w_sort-fieldname = 'BUKRS'.
w_sort-tabname = 'T_ITAB1'.
w_sort-spos = 1.
w_sort-up = 'X'.
w_sort-subtot = 'X'.
APPEND w_sort TO l_sort.
CLEAR w_sort.
w_sort-fieldname = 'EBELN'.
w_sort-tabname = 'T_ITAB1'.
w_sort-spos = 1.
w_sort-up = 'X'.
w_sort-subtot = 'X'.
APPEND w_sort TO l_sort.
ENDFORM. " sort_layout
*& Form PF_STATUS
FORM pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STANDARD1' EXCLUDING rt_extab.
ENDFORM. " PF_STATUS
*& Form user_command
FORM user_command USING s_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
CLEAR wa_itab1.
READ TABLE t_itab1 INTO wa_itab1 INDEX rs_selfield-tabindex.
CASE s_ucomm.
WHEN 'POD'.
SET PARAMETER ID 'BES' FIELD wa_itab1-ebeln.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
CLEAR wa_itab1.
WHEN 'MAT'.
SET PARAMETER ID 'MAT' FIELD wa_itab1-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
WHEN '&IC1'.
IF rs_selfield-fieldname = 'MATNR'.
SET PARAMETER ID 'MAT' FIELD wa_itab1-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ELSEIF rs_selfield-fieldname = 'EBELN'.
SET PARAMETER ID 'BES' FIELD wa_itab1-ebeln.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
WHEN 'PRINT'.
PERFORM multiple_sel.
PERFORM call_form.
CLEAR : f_itab1, f_itab2.
WHEN 'SMART'.
PERFORM multiple_sel.
PERFORM call_smartform.
ENDCASE.
ENDFORM. "user_command -
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 -
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 -
I want to display icons in ALV
Hi friends,
I want to display icon indicators in ALV ???
can anybody tell me ??/
Thanks...Hi sturdy,
this code will help u...copy paste and run...
*& Report ZFI_TEST *
REPORT ZFI_ICON_TEST MESSAGE-ID zz .
*& TABLES DECLARATION *
TABLES: vbak.
*& TYPE POOLS DECLARATION *
TYPE-POOLS: slis.
*& INTERNAL TABLE DECLARATION *
DATA: BEGIN OF itab OCCURS 0,
icon TYPE icon-id, "itab-icon = '@08@' -> Green ; '@09@' -> Yellow ; '@0A@' -> Red
vbeln LIKE vbak-vbeln,
audat LIKE vbak-audat,
vbtyp LIKE vbak-vbtyp,
auart LIKE vbak-auart,
augru LIKE vbak-augru,
netwr LIKE vbak-netwr,
waerk LIKE vbak-waerk,
END OF itab.
*INTERNAL TABLE FOR FIELD CATALOG
DATA: wa_fieldcat TYPE slis_fieldcat_alv,
it_fieldcat TYPE slis_t_fieldcat_alv.
IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV
WITH HEADER LINE,
*INTERNAL TABLE FOR EVENTS
DATA: it_event TYPE slis_t_event,
wa_event TYPE slis_alv_event,
*INTERNAL TABLE FOR SORTING
it_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv,
*INTERNAL TABLE FOR LAYOUT
wa_layout TYPE slis_layout_alv.
*& VARIABLE DECLARATION *
DATA : v_repid TYPE sy-repid,
v_pagno(4) TYPE n,
v_date(8) TYPE c.
*& CONSTANTS *
CONSTANTS: c_x TYPE c VALUE 'X'.
*& SELECTION SCREEN *
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln,
s_vbtyp FOR vbak-vbtyp DEFAULT 'C'.
SELECTION-SCREEN: END OF BLOCK b1.
SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text-003.
PARAMETERS: p_list RADIOBUTTON GROUP rad1 DEFAULT 'X'.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text-004.
PARAMETERS: p_grid RADIOBUTTON GROUP rad1.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN: END OF BLOCK b2.
AT SELECTION-SCREEN.
PERFORM validate_screen.
*& START OF SELECTION *
START-OF-SELECTION.
CLEAR: itab, itab[].
V_REPID = SY-REPID.
PERFORM get_data.
PERFORM display_data.
*& END OF SELECTION *
END-OF-SELECTION.
*--DO ALV Process
v_repid = sy-repid.
*--Sort the Output Fields
PERFORM sort_fields.
*--Build Field catalog for the Output fields
PERFORM BUILD_FIELDCAT.
*--Set the Layout for ALV
PERFORM set_layout.
*& Form GET_DATA
text
TO GET THE DATA FROM TABLES INTO ITAB
FORM get_data .
SELECT vbeln
audat
vbtyp
auart
augru
netwr
waerk
INTO CORRESPONDING FIELDS OF TABLE itab
FROM vbak
WHERE vbeln IN s_vbeln AND
audat > '04.04.2005'
AND netwr > 0.
LOOP AT itab.
IF itab-netwr < 10000.
itab-icon = '@08@'.
ELSEIF itab-netwr > 10000 AND itab-netwr < 100000.
itab-icon = '@09@'.
ELSEIF itab-netwr > 100000.
itab-icon = '@0A@'.
ENDIF.
MODIFY itab INDEX sy-tabix.
ENDLOOP.
ENDFORM. " GET_DATA
*& Form sort_fields
FORM sort_fields .
CLEAR wa_sort.
wa_sort-fieldname = 'VBTYP'.
wa_sort-spos = '1'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
wa_sort-fieldname = 'NETWR'.
wa_sort-spos = '2'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO it_sort.
ENDFORM. " sort_fields
*& Form set_layout
FORM set_layout .
IF p_list = c_x .
wa_layout-window_titlebar = 'LIST DISPLAY'(016).
wa_layout-zebra = 'X'.
*-- ALV LIST DISPLAY
PERFORM list_display TABLES itab.
*-- ALV GRID DISPLAY
ELSEIF p_grid = c_x.
wa_layout-window_titlebar = 'GRID DISPLAY'(017).
wa_layout-zebra = 'X'.
PERFORM grid_display TABLES itab.
ENDIF.
ENDFORM. " set_layout
*& Form list_display
FORM list_display TABLES p_itab .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = wa_layout
it_fieldcat = it_fieldcat[]
it_sort = it_sort[]
i_save = 'U'
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " list_display
*& Form GRID_DISPLAY
FORM grid_display TABLES p_itab .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = wa_layout
it_fieldcat = it_fieldcat[]
it_sort = it_sort[]
it_events = it_event
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " GRID_DISPLAY
*& Form VALIDATE_SCREEN
text
--> p1 text
<-- p2 text
FORM validate_screen .
DATA: lv_vbeln LIKE vbak-vbeln.
IF NOT s_vbeln IS INITIAL.
SELECT vbeln
INTO lv_vbeln
UP TO 1 ROWS
FROM vbak
WHERE vbeln IN s_vbeln.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'INVALID SALES DOC'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_SCREEN
*& Form display_data
text
--> p1 text
<-- p2 text
FORM display_data .
DEFINE m_fieldcat.
add 1 to wa_fieldcat-col_pos.
wa_fieldcat-fieldname = &1.
wa_fieldcat-ref_tabname = 'VBAK'.
wa_fieldcat-do_sum = &2.
wa_fieldcat-cfieldname = &3.
append wa_fieldcat to it_fieldcat.
END-OF-DEFINITION.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
m_fieldcat 'ICON' '' ''.
m_fieldcat 'VBELN' '' ''.
m_fieldcat 'AUDAT' '' ''.
m_fieldcat 'VBTYP' '' ''.
m_fieldcat 'AUART' '' ''.
m_fieldcat 'AUGRU' '' ''.
m_fieldcat 'NETWR' 'C' 'WAERK'.
m_fieldcat 'WAERK' '' ''.
ENDFORM. " display_data[/code] -
How to display data in alv through double click
Hello Friends,
I am new to this community,please tell me if I make any mistake while posting.
Friends I had written this code. ALV is displayed at first time but when I am double clicking on the row then error is coming related to mismatch of actual and formal paramaters while calling function 'USER_COMMAND'. I am unable to locate where the error is. Please help me out.
REPORT ZALV12.
TYPE-POOLS SLIS.
DATA: it_vbak type standard table of VBAK,
it_vbap type table of VBAP.
DATA: wa_vbak like line of it_vbak,
wa_vbap like line of it_vbap.
DATA syrepid like sy-repid.
DATA:fld_vbak type SLIS_T_FIELDCAT_ALV,
fld_vbap type SLIS_T_FIELDCAT_ALV.
DATA:fld_wa_vbak type SLIS_FIELDCAT_ALV,
fld_wa_vbap type SLIS_FIELDCAT_ALV.
DATA:vevent type SLIS_T_EVENT,
waevent type SLIS_ALV_EVENT.
DATA:LST_HEADR type SLIS_T_LISTHEADER.
DATA title_alv type LVC_TITLE value 'LIST FOR VBAK'.
INITIALIZATION.
syrepid = sy-repid.
perform get_event.
perform populate_event.
perform set_list_headr using LST_HEADR.
perform field_cat.
START-OF-SELECTION.
..... "code for displaying data from table VBAK in ALV.
form USER_COMMAND using R_UCOMM type SY-UCOMM. "error is in this function.
data r_selfield type SLIS_SELFIELD.
case R_UCOMM.
when '&IC1'.
read table it_vbak into wa_vbak index r_selfield-TABINDEX.
perform data_select.
perform list_heading using LST_HEADR.
perform event_get.
perform build_event.
perform alv_display.
endcase.
endform.
form data_select.
select * from VBAP into table it_vbap up to 20 rows.
endform.
form list_heading using i_lst type SLIS_T_LISTHEADER.
data HLINE type SLIS_LISTHEADER.
HLINE-TYP = 'H'.
HLINE-INFO = 'FOR VBAP'.
append HLINE to i_lst.
endform.
form alv_display.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = syrepid
I_STRUCTURE_NAME = 'VBAP'
I_GRID_TITLE = 'SCREEN2_VBAP'
TABLES
T_OUTTAB = it_vbap
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.
form event_get.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = vevent
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.
endform.
form build_event.
read table vevent into waevent with key name = 'TOP_OF_PAGE'.
if sy-subrc = 0.
waevent-form = 'F_TOP_OF_PAGE'.
modify vevent from waevent transporting form
where name = 'TOP_OF_PAGE'.
endif.
endform.
form F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = LST_HEADR
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
endform.You missed one paramete in user_command form
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Regards,
Raymond -
Function module used for formatting alv
hi gurus,
which function module is uesd to format alv?Hi
see the following
ABAP List Viewer
The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
This helps us to implement all the features mentioned very effectively.
Using ALV, We can have three types of reports:
1. Simple Report
2. Block Report
3. Hierarchical Sequential Report
There are some function modules which will enable to produce the above reports without much effort.
All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
1. SIMPLE REPORT.
The important function modules are
a. Reuse_alv_list_display
b. Reuse_alv_fieldcatalog_merge
c. Reuse_alv_events_get
d. Reuse_alv_commentary_write
e. Reuse_alv_grid_display
A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
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. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
The Important Parameters are :
I. Export :
i. I_program_name : report id
ii. I_internal_tabname : the internal output table
iii. I_inclname : include or the report name where all the dynamic forms are handled.
II Changing
ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
declared in the type pool SLIS.
C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
Parameters :
I. Import :
Et_Events : The event table is returned with all possible CALLBACK events
for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
II. Export :
I_List_type :
0 = simple list REUSE_ALV_LIST_DISPLAY
1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
3 = hierarchical-sequential block list
REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
Parameters :
I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
This internal table has three fields :
Typ : H header, S selection , A - action
Key : only when typ is S.
Info : the text to be printed
E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
Parameters : same as reuse_alv_list_display
This is an example for simple list.
2. BLOCK REPORT
This is used to have multiple lists continuously.
The important functions used in this report are:
A. REUSE_ALV_BLOCK_LIST_INIT
B. REUSE_ALV_BLOCK_LIST_APPEND
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_BLOCK_LIST_DISPLAY
A. REUSE_ALV_BLOCK_LIST_INIT
Parameters:
I. I_CALLBACK_PROGRAM
II. I_CALLBACK_PF_STATUS_SET
III. I_CALLBACK_USER_COMMAND
This function module is used to set the default gui status etc.
B. REUSE_ALV_BLOCK_LIST_APPEND
Parameters :
Export :
I. is_layout : layout settings for block
II. it_fieldcat : field catalog
III. i_tabname : internal table name with output data
IV. it_events : internal table with all possible events
Tables :
i. t_outtab : internal table with output data.
This function module adds the data to the block.
Repeat this function for all the different blocks to be displayed one after the other.
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
This function module is used for hierarchical sequential blocks.
D. REUSE_ALV_BLOCK_LIST_DISPLAY
Parameters : All the parameters are optional.
This function module display the list with data appended by the above function.
Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
3. Hierarchical reports :
Hierarchical sequential list output.
The function module is
A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
Parameters:
I. Export:
i. I_CALLBACK_PROGRAM
ii. I_CALLBACK_PF_STATUS_SET
iii. I_CALLBACK_USER_COMMAND
iv. IS_LAYOUT
v. IT_FIELDCAT
vi. IT_EVENTS
vii. i_tabname_header : Name of the internal table in the program containing the
output data of the highest hierarchy level.
viii. i_tabname_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
ix. is_keyinfo : This structure contains the header and item table field
names which link the two tables (shared key).
II. Tables
i. t_outtab_header : Header table with data to be output
ii. t_outtab_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using REUSE_ALV_FIELDCATALOG_MERGE.
Important Attributes :
A. col_pos : position of the column
B. fieldname : internal fieldname
C. tabname : internal table name
D. ref_fieldname : fieldname (dictionary)
E. ref_tabname : table (dictionary)
F. key(1) : column with key-color
G. icon(1) : icon
H. symbol(1) : symbol
I. checkbox(1) : checkbox
J. just(1) : (R)ight (L)eft (C)ent.
K. do_sum(1) : sum up
L. no_out(1) : (O)blig.(X)no out
M. outputlen : output length
N. seltext_l : long key word
O. seltext_m : middle key word
P. seltext_s : short key word
Q. reptext_ddic : heading (ddic)
R. ddictxt(1) : (S)hort (M)iddle (L)ong
S. datatype : datatype
T. hotspot(1) : hotspot
Simple ALV report
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
Check the program in the following link:
http://sap-img.com/abap/display-secondary-list-using-alv-grid.htm
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
13. Top-of-page in ALV
selection-screen and top-of-page in ALV
14. ALV Group Heading
http://www.sap-img.com/fu037.htm
How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
15. ALV output to PDF conversion
It has an example code for PDF Conversion.
http://www.erpgenie.com/abap/code/abap51.htm
converting the output of alv in pdf
Go thru these programs they may help u to try on some hands on
ALV Demo program
BCALV_DEMO_HTML
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
BCALV_GRID_DEMO Simple ALV Control Call Demo Program
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO
BC_ALV_DEMO_HTML_D0100
Regards
Anji -
Hi guru's what are the function modules are used in ALV
hi guru's what are the function modules are used in ALV
Hi vasu,
There are some function modules which will enable to produce the reports without much effort.
All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
1. SIMPLE REPORT.
The important function modules are
a. Reuse_alv_list_display
b. Reuse_alv_fieldcatalog_merge
c. Reuse_alv_events_get
d. Reuse_alv_commentary_write
e. Reuse_alv_grid_display
A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
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. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
The Important Parameters are :
I. Export :
i. I_program_name : report id
ii. I_internal_tabname : the internal output table
iii. I_inclname : include or the report name where all the dynamic forms are handled.
II Changing
ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
declared in the type pool SLIS.
C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
Parameters :
I. Import :
Et_Events : The event table is returned with all possible CALLBACK events
for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
II. Export :
I_List_type :
0 = simple list REUSE_ALV_LIST_DISPLAY
1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
3 = hierarchical-sequential block list
REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
Parameters :
I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
This internal table has three fields :
Typ : H header, S selection , A - action
Key : only when typ is S.
Info : the text to be printed
E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
Parameters : same as reuse_alv_list_display
This is an example for simple list.
2. BLOCK REPORT
This is used to have multiple lists continuously.
The important functions used in this report are:
A. REUSE_ALV_BLOCK_LIST_INIT
B. REUSE_ALV_BLOCK_LIST_APPEND
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_BLOCK_LIST_DISPLAY
A. REUSE_ALV_BLOCK_LIST_INIT
Parameters:
I. I_CALLBACK_PROGRAM
II. I_CALLBACK_PF_STATUS_SET
III. I_CALLBACK_USER_COMMAND
This function module is used to set the default gui status etc.
B. REUSE_ALV_BLOCK_LIST_APPEND
Parameters :
Export :
I. is_layout : layout settings for block
II. it_fieldcat : field catalog
III. i_tabname : internal table name with output data
IV. it_events : internal table with all possible events
Tables :
i. t_outtab : internal table with output data.
This function module adds the data to the block.
Repeat this function for all the different blocks to be displayed one after the other.
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
This function module is used for hierarchical sequential blocks.
D. REUSE_ALV_BLOCK_LIST_DISPLAY
Parameters : All the parameters are optional.
This function module display the list with data appended by the above function.
Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
3. Hierarchical reports :
Hierarchical sequential list output.
The function module is
A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
Parameters:
I. Export:
i. I_CALLBACK_PROGRAM
ii. I_CALLBACK_PF_STATUS_SET
iii. I_CALLBACK_USER_COMMAND
iv. IS_LAYOUT
v. IT_FIELDCAT
vi. IT_EVENTS
vii. i_tabname_header : Name of the internal table in the program containing the
output data of the highest hierarchy level.
viii. i_tabname_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
ix. is_keyinfo : This structure contains the header and item table field
names which link the two tables (shared key).
II. Tables
i. t_outtab_header : Header table with data to be output
ii. t_outtab_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using REUSE_ALV_FIELDCATALOG_MERGE.
Important Attributes :
A. col_pos : position of the column
B. fieldname : internal fieldname
C. tabname : internal table name
D. ref_fieldname : fieldname (dictionary)
E. ref_tabname : table (dictionary)
F. key(1) : column with key-color
G. icon(1) : icon
H. symbol(1) : symbol
I. checkbox(1) : checkbox
J. just(1) : (R)ight (L)eft (C)ent.
K. do_sum(1) : sum up
L. no_out(1) : (O)blig.(X)no out
M. outputlen : output length
N. seltext_l : long key word
O. seltext_m : middle key word
P. seltext_s : short key word
Q. reptext_ddic : heading (ddic)
R. ddictxt(1) : (S)hort (M)iddle (L)ong
S. datatype : datatype
T. hotspot(1) : hotspot
some theory regarding alv:
This table tells ALV which events are processed by the caller by CALLBACK.
The table of possible events per list type can be initialized using the module REUSE_ALV_EVENTS_GET.
You can display the names of the constants in the type pools SLIS which represent the individual events using the individual test function in the function module
REUSE_ALV_EVENT_NAMES_GET. Only events with a form routine name are processed.
The table structure contains the fields:
IT_EVENTS-NAME
Name of the Callback event.
Possible Callback events:
Action
USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD
Process actions on the list
As this is a frequently-used Callback event, the form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_USER_COMMAND.
PF_STATUS_SET USING RT_EXTAB TYPE SLIS_T_EXTAB
If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).
The STANDARD status of the function group SALV should be used as a template for a user-specific status.
As this is a frequently-used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.
ITEM_DATA_EXPAND USING RS_SELFIELD TYPE SLIS_SELFIELD RFLG_ALL TYPE C
Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT.
Exit for passing item entries (ITEM table) for a header record which was expanded interactively by the user.
RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header which is to be expanded.
RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that entries are not repeated in the item table. RS_SELFIELD is initial in this case.
CALLER_EXIT USING RS_DATA Is called at the beginning of the function module to make special settings. It is not usually used.
List processing events
IMPORTANT: The application Callback routine must not manipulate the internal output table and/or its header record. This restriction applies to all Callbacks which are called in the list output and run under the 'List processing events'.
TOP_OF_LIST no USING parameter. Information output at the start of the list
END_OF_LIST no USING parameter. Information output at the end of the list
TOP_OF_PAGE no USING parameter
Equivalent to the list processing TOP-OF-PAGE event
END_OF_PAGE no USING parameter. Not available for hierarchical-sequential lists.
Information output at the end of a page. This is only called for printing.
TOP_OF_COVERPAGE no USING parameter
The selection information and list status are output together (if they exist) on a separate page by default. See also the documentation of the parameters:
IS_PRINT-NO_COVERPAGE
IS_PRINT-NO_PRINT_SELINFOS
IS_PRINT-NO_PRINT_LISTINFOS
IS_LAYOUT-GET_SELINFOS
The user can format the header area of the 'cover page' himself or herself by specifying a Callback routine for this event.
END_OF_COVERPAGE no USING parameter
Analogously to TOP_OF_COVERPAGE the user can add other information to the information output by ALV (selection information, list status) at this event.
FOREIGN_TOP_OF_PAGE no USING parameter
The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).
In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.
FOREIGN_END_OF_PAGE no USING parameter
The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).
In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.
BEFORE_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO
Output information before each output line. Should only be used in justified cases because it costs a lot of performance.
AFTER_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO
Output information after each output line. Should only be used in justified cases because it costs a lot of performance.
Internal use only
LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME
R_INDEX LIKE SY-TABIX
R_INDEX_ITEM LIKE SY-TABIX
R_INDEX_SUM LIKE SY-TABIX
IT_EVENTS-FORM
Name of the form routine which should be called in the calling program at the event.
Field_catalog:
Field catalog with field descriptions
2.7.1. Description
Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields). A field catalog is required for every ALV list output.
The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module
See also the documentation of the function module REUSE_ALV_FIELDCATALOG_MERGE.
The minimal field catalog is documented under 'default'. The caller can use the other optional parameters to assign output attributes to a field which differ from the default.
A field catalog need not be built-up and passed explicitly only under the following conditions:
The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE.
all fields in this structure are to be output
the structure name is passed to ALV in the parameter I_STRUCTURE_NAME.
See also the documentation of the IMPORTING paramter I_STRUCTURE_NAME.
Positioning
row_pos (row position)
value set: 0, 1 - 3
Only relevant if the list output is to be multi-line (two or three lines) by default.
A multi-line list can also be defined by the user interactively if the default list is one-line.
The parameter specifies the relative output line of the column in a multi-line list.
col_pos (column position)
value set: 0, 1 - 60
only relevant when the default relative column positions differ from the field catalog field sequence. The parameter specifies the relative column position of the field in the list output. The column order can be changed interactively by the user. If this parameter is initial for all field catalog entries, columns appear in the field catalog field sequence.
Identification
fieldname (field name)
value set: internal output table field name (required parameter)
Name of the internal output table field which is described by this field catalog entry
tabname (internal output table)
value set: SPACE, internal output table name
This parameter is used in 'manual' field catalog build-up only for hierarchical-sequential lists.
Name of the internal output table which contains the field FIELDCAT-FIELDNAME.
Data Dictionary reference
ref_fieldname (reference field name)
value set: SPACE, Data Dictionary field name
Name of the Data Dictionary field referred to.
This parameter is only used when the internal output table field described by the current field catalog entry has a reference to the Data Dictionary (not a program field), and the field name in the internal output table is different from the name of the field in the Data Dictionary. If the field names are identical, naming the Data Dictionary structure or table in the FIELDCAT-REF_TABNAME parameter is sufficient.
ref_tabname (reference table/structure field name)
value set: SPACE, name of a Data Dictionary structure or table
Structure or table name of the referred Data Dictionary field.
This parameter is only used when the internal output table field described by the current field catalog entry has a Data Dictionary reference (not a program field).
Reference to fields with currency/measurement unit
Each internal output table sum or quantity field whose decimal places are to be formatted appropriately for the unit in the list must follow the convention:
the field is of data type QUAN or CURR (internal type P) (the field must really have this physical data type. Overwriting the physical data type with the parameter FIELDCAT-DATATYPE has no effect)
There is a field in the internal output table which contains the associated unit.
There is also an entry in the field catalog for the unit field.
(If the unit is not to appear as a column in the list, and cannot be interactively displayed as a column, e.g. because it is always unambiguous and is therefore explicitly output by the caller in the list header, the field catalog units field entry can take the parameter FIELDCAT-TECH = 'X'.
The association of a value field to a unit affects the output as follows:
appropriate decimal places display for the unit
an initialized field with a link to a non-initial unit is output as '0' for the unit (if FIELDCAT-NO_ZERO is initial). When this field is summed, this unit affects whether the units are homogeneous.
an initialized field with a link to an initial unit is output as SPACE. When this field is summed, the unit SPACE does not affect the homogeneity of the units.
When non-initial fields with an initial unit are summed, the unit SPACE is considered to be a unit.
Link to currency unit
cfieldname (currency unit field name)
value set: SPACE, output table field name
Only relevant for amount columns with associated unit.
Name of the internal output table field containing the currency unit associated with the amount field FIELDCAT-FIELDNAME. The field in FIELDCAT-CFIELDNAME must have its own field catalog entry.
ctabname (internal currency unit field output table)
value set: SPACE, output table field name
only relevant for hierarchical-sequential lists
Name of the internal output table containing the FIELDCAT-CFIELDNAME field.
Link to measurement unit
qfieldname (measurement unit field name)
value set: SPACE, output table field name
only relevant for quantity columns with unit link.
Name of the internal output table field containing the measurement unit associated with the quantity field FIELDCAT-FIELDNAME.
The field in FIELDCAT-QFIELDNAME must have its own field catalog entry.
qtabname (internal measurement unit field output table)
value set: SPACE, output table field name
only relevant for hierarchical-sequential lists
Name of the internal output table containing the FIELDCAT-QFIELDNAME field.
Column output options
outputlen (column width)
value set: 0 (initial), n
For fields with a Data Dictionary link this parameter can be left initial.
For fields without a Data Dictionary link (program field) the parameter must be given the value of the desired field list output length (column width).
initial = column width is the output length of the referred Data Dictionary field (domain).
n = column width is n characters
key (key column)
value set: SPACE, 'X' 'X' = kex field (key field output in color)
Key fields can not be interactively hidden. Parameter FIELDCAT-NO_OUT must be left initial.
For exceptions see the documentation of the FIELDCAT-KEY_SEL parameter.
key_sel (hideable key column)
value set: SPACE, 'X'
only relevant when FIELDCAT-KEY = 'X'
Key field which can be hidden interactively.
The key column sequence cannot be changed interactively by the user.
The output is controlled by the FIELDCAT-NO_OUT parameter analogously to non-key fields.
no_out (field in field list)
value set: SPACE, 'X' 'X' = field is not displayed in the current list.
The user can interactively choose the field for output from the field list.
The user can display the contents of these fields at line level using the 'Detail' function.
See also the 'Detail screen' documentation of the parameter IS_LAYOUT.
tech (technical field)
value set: SPACE, 'X' 'X' = technical field
Field cannot be output in the list and cannot be displayed interactively.
Field can only be used in the field catalog (not in IT_SORT, ...).
emphasize (highlight columns in color)
value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off '1'=on)
'X' = column is colored with the default column highlight color.
'Cxyz' = column is colored with a coded color:
C: Color (coding must begin with C)
x: color number
y: bold
z: inverse
hotspot (column as hotspot)
value set: SPACE, 'X'
'X' = column cells are output as hotspots
fix_column (fix column)
value set: SPACE, 'X'
Not relevant for block lists (output of several lists consecutively)
'X' = column fixed (does not scroll horizontally)
All columns to be fixed must have this flag, starting from the left. If a column without this flag is output, only the columns to the left of this column are fixed. The user can change the column fixing interactively. See also the documentation of the Layout parameter
IS_LAYOUT-NO_KEYFIX of the IMPORTING paramter IS_LAYOUT.
do_sum (sum over column)
value set: SPACE, 'X' 'X' = a sum is to be calculated over this internal output table field.
This function can also be called by the user interactively.
no_sum (sums forbidden)
value set: SPACE, 'X' 'X' = no sum can be calculated over this field, although the data type of the field would allow summing.
input (column ready for input)
Function not available
Format column contents
icon
value set: SPACE, 'X' 'X' = column contents to be output as an icon.
The caller must consider the printability of icons.
symbol
value set: SPACE, 'X' 'X' = column contents are to be output as a symbol.
The internal output table column must be a valid symbol character.
The caller must consider the printability of symbols.
Symbols can usually be printed, but may not always be output correctly, depending on the printer configuration.
just (justification)
value set: SPACE, 'R', 'L', 'C'
Only relevant for fields of data type CHAR or NUMC
' ' = default justification for this data type
'R' = right-justified output
'L' = left-justified output
'C' = centered output
The justification of the column header always follows the justification of the columns. Independent justification of the column neader is not possible.
lzero (leading zeros)
value set: SPACE, 'X'
Only relevant for fields of data type NUMC
ALV outputs NUMC fields right-justified without leading zeros by default.
'X' = output with leading zeros
Note: If a NUMC field is output left-justified or centered by FIELDCAT-JUST, leading zeros are output. If the output of leading zeros is suppressed by a Data Dictionary reference ALPHA conversion exit, the output is always left-justified.
no_sign (no +/- sign) Only relevant for value fields
value set: SPACE, 'X' 'X' = value output without +/ sign
no_zero (suppress zeros) Only relevant for value fields
value set: SPACE, 'X' 'X' = suppress zeros
edit_mask (field formatting)
value set: SPACE, template
template = see documentation of WRITE formatting option USING EDIT MASK template
The output conversion conv can be made by template = '== conv'.
Texts
The following text parameters should be specified for program fields without a Data Dictionary reference. The texts are taken from the Data Dictionary for fields with a Data Dictionary reference. If this is not desired, the text parameters can also be specified. The Data Dictionary texts are then ignored. If the user changes the column width interactively, the column header text with the appropriate length is always used. The interactive function 'Optimize column width' takes account of both the field contents and the column headers: if all field contents are shorter than the shortest column header, the column width depends on the column header.
The 'long field label' is also used in display variant definition, sort, etc. popups.
seltext_l (long field label)
seltext_m (medium field label)
seltext_s (short field label)
reptext_ddic (header)
analogous to the Data element maintenance 'Header'
The specified text is not necessarily output in the list, an optimum among all texts is sought.
ddictxt (specify text)
value set: SPACE, 'L', 'M', 'S'
You can specify with values 'L', 'M', and 'S', the keyword that should always be used as column header. If the column width changes, no attempt is made in this case to find an appropriate header for the new output width.
Parameters for program fields without Data Dictionary reference
see also 'Text' parameters
datatype (data type)
value set: SPACE, Data Dictionary data type (CHAR, NUMC,...)
Only relevant for fields without Data Dictionary reference
Program field data type
ddic_outputlen (external output length)
value set: 0 (initial), n
Only relevant for fields without Data Dictionary reference whose output is nevertheless to be modified by a conversion exit.
Prerequisites:
FIELDCAT-EDIT_MASK = '==conv'
see also the documentation of the parameter FIELDCAT-EDIT_MASK
FIELDCAT-INTLEN = n
see also the documentation of the parameter FIELDCAT-INTLEN
n = external format field output length
The column width FIELDCAT-OUTPUTLEN need not be the same as the external format output length (FIELDCAT-DDIC_OUTPUTLEN).
intlen (internal output length)
value set: 0 (initial), n
Only relevant for fields without Data Dictionary reference whose output is nevertheless to be modified by a conversion exit.
Prerequisites:
FIELDCAT-EDIT_MASK = '==conv'
see also the documentation of the parameter FIELDCAT-EDIT_MASK
FIELDCAT-DDIC_OUTPUTLEN = n
see also the documentation of the parameter FIELDCAT-DDIC_OUTPUTLEN
n = internal format field output length
rollname (data element)
value set: SPACE, Data Dictionary data element name
F1 help can be provided for a program field without a Data Dictionary reference, or F1 help which differs from the Data Dictionary help can be provided for a field with a Data Dictionary reference, using this parameter.
When F1 help is called for this field, the documentation of the specified data element is displayed.
If the FIELDCAT-ROLLNAME is initial for fields with a Data Dictionary reference, the documentation of the data element of the referred Data Dictionary field is output.
Others
sp_group (field group key)
value set: SPACE, CHAR(1)
Field group key.
Keys are assigned to group names in the IT_SPECIAL_GROUPS parameter (see also the documentation of the parameter IT_SPECIAL_GROUPS).
When such an assignment is made in the field catalog and in IT_SPECIAL_GROUPS, the fields are grouped correspondingly in the display variant popup.
reprep (Report/Report interface selection criterion)
value set: SPACE, 'X'
Prerequisites:
The system contains the Report/Report interface (function group RSTI, table TRSTI)
Parameter LAYOUT-REPREP = 'X'
(see also the documentation of the parameter LAYOUT-REPREP of the IMPORTING parameter IS_LAYOUT )
'X' = When the Report/Report interface is called, the value of this field is passed in the selected interface start record as a selection criterion.
2.7.2. Default
The following entries are usually sufficient for internal table fields with a reference to a field defined in the Data Dictionary :
fieldname
ref_tabname
Notes:
ALV gets the remaining information from the Data Dictionary.
If no relative column position (COL_POS) is specified, the fields are output in the list in the order in which they were added to the field catalog.
REF_FIELDNAME need only be specifid when the name of the internal table field differs from the name of the referred Data Dictionary field.
Information which is explicitly entered in the field catalog is not overwritten by information from the Data Dictionary.
Priority rule:
Entries in the field catalog have priority over differing entries in the Data Dictionary.
The following entries are usually sufficient for internal table fields without a reference to the Data Dictionary (program fields):
fieldname
outputlen
datatype
seltext_s
seltext_m
seltext_l
Notes:
F1 help can be provided for program fields by assigning a data element to the parameter ROLLNAME.
If the parameters SELTEXT_S, SELTEXT_M, SELTEXT_L, and REPTEXT_DDIC contain appropriate field labels, the program field column headers are also adjusted appropriately when the column width changes
sites :
http://www.sapdevelopment.co.uk/reporting/alv/alv_variousfcat.htm
<b>plese reward if useful </b>
Message was edited by:
sunil kairam -
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 -
Is it possible to put colors while displaying report using ALVs?
Gayathri
hi
i think the following code is the ur solution
TABLES VBAK.
TYPE-POOLS SLIS.
* Data Declaration
TYPES: BEGIN OF T_VBAK,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
ERNAM TYPE VBAK-ERNAM,
AUDAT TYPE VBAK-AUDAT,
VBTYP TYPE VBAK-VBTYP,
NETWR TYPE VBAK-NETWR,
VKORG TYPE VBAK-VKORG,
VKGRP TYPE VBAK-VKGRP,
<b> LINE_COLOR(4) TYPE C,</b>
END OF T_VBAK.
DATA: IT_VBAK TYPE STANDARD TABLE OF T_VBAK INITIAL SIZE 0,
WA_VBAK TYPE T_VBAK.
* ALV Data Declaration
DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV,
GD_REPID TYPE SY-REPID.
* I_EVENTS TYPE SLIS_T_EVENT,
* W_EVENTS LIKE LINE OF I_EVENTS.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BLD_FLDCAT.
PERFORM BLD_LAYOUT.
PERFORM DISPLAY_ALV_REPORT.
* Build Field Catalog for ALV Report
FORM BLD_FLDCAT.
FLDCAT-FIELDNAME = 'VBELN'.
FLDCAT-SELTEXT_M = 'Sales Document'.
FLDCAT-COL_POS = 0.
*FLDCAT-EMPHASIZE = 'C411'.
FLDCAT-OUTPUTLEN = 20.
FLDCAT-KEY = 'X'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'ERDAT'.
FLDCAT-SELTEXT_L = 'Record Date created'.
FLDCAT-COL_POS = 1.
FLDCAT-KEY = 'X'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'ERNAM'.
FLDCAT-SELTEXT_L = 'Cteated Object Person Name'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'AUDAT'.
FLDCAT-SELTEXT_M = 'Document Date'.
FLDCAT-COL_POS = 3.
FLDCAT-EMPHASIZE = 'C110'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'VBTYP'.
FLDCAT-SELTEXT_L = 'SD Document category'.
FLDCAT-COL_POS = 4.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'NETWR'.
FLDCAT-SELTEXT_L = 'Net Value of the SO in Document Currency'.
FLDCAT-COL_POS = 5.
FLDCAT-OUTPUTLEN = 60.
FLDCAT-DO_SUM = 'X'.
FLDCAT-DATATYPE = 'CURR'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'VKORG'.
FLDCAT-SELTEXT_L = 'Sales Organization'.
FLDCAT-COL_POS = 6.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'VKGRP'.
FLDCAT-SELTEXT_M = 'Sales Group'.
FLDCAT-COL_POS = 7.
FLDCAT-EMPHASIZE = 'C801'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
ENDFORM.
* Build Layout for ALV Grid Report
FORM BLD_LAYOUT.
GD_LAYOUT-NO_INPUT = 'X'.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.
GD_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.
*GD_LAYOUT-TOTALS_TEXT = 'GRAND TOTAL'.
ENDFORM.
* Display report using ALV grid
FORM DISPLAY_ALV_REPORT.
DATA T_EVENT TYPE SLIS_T_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = T_EVENT.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
GD_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = GD_REPID
IS_LAYOUT = GD_LAYOUT
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = 'SALES DOCUMENT HEADER'
IT_FIELDCAT = FLDCAT[]
I_SAVE = 'X'
TABLES
T_OUTTAB = IT_VBAK
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.
* Retrieve data from VBAK table and populate itab IT_VBAK
FORM DATA_RETRIEVAL.
<b>DATA LD_COLOR(1) TYPE C.</b>
SELECT VBELN ERDAT ERNAM AUDAT VBTYP NETWR VKORG
UP TO 20 ROWS
FROM VBAK
INTO TABLE IT_VBAK.
<b>LOOP AT IT_VBAK INTO WA_VBAK.
LD_COLOR = LD_COLOR + 1.
IF LD_COLOR = 8.
LD_COLOR = 1.
ENDIF.
CONCATENATE 'C' LD_COLOR '10' INTO WA_VBAK-LINE_COLOR.
MODIFY IT_VBAK FROM WA_VBAK.
ENDLOOP.</b>
ENDFORM.
FORM TOP_OF_PAGE.
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
W_HEADER TYPE SLIS_LISTHEADER.
W_HEADER-TYP = 'H'.
W_HEADER-INFO = 'WELCOME HEADER LIST'.
APPEND W_HEADER TO T_HEADER.
W_HEADER-TYP = 'S'.
W_HEADER-KEY = 'REPORT:'.
W_HEADER-INFO = SY-REPID.
APPEND W_HEADER TO T_HEADER.
W_HEADER-TYP = 'S'.
W_HEADER-KEY = 'DATE:'.
CONCATENATE SY-DATUM+6(2) ' / ' SY-DATUM+4(2) ' / ' SY-DATUM(4) INTO W_HEADER-INFO.
APPEND W_HEADER TO T_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM.
reward points,if it is useful -
Hi all Good Morning.
In ALV report am inserted my own icons. But the problem is at output screen am getting only those icons which i created, remaining are not displaying in standard tool bar .
Please tell me how to solve this. I want to display all default icons with my own created icons in standard tool bar .
Regards,
Prajwal K.
Edited by: prajwal k on Jan 24, 2008 4:39 AMHi Prajwal, this code will solve ur problem.
go to SE41.
Give SAPLKKBL as program name and STANDARD_FULLSCREEN as status....
now click on Copy Status and in that give ur program and status name into To.....
now in REUSE_ALV_GRID_DISPLAY
FORM display_list.
g_f_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_f_repid
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_STAT'
it_fieldcat = g_t_fieldcat[]
it_events = g_t_events[]
TABLES
t_outtab = g_t_itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " display_list
FORM set_stat USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTAT' EXCLUDING rt_extab.
ENDFORM. "set_stat
here my status name is ZSTAT which i gave in SE41...
and in user_command form...
FORM user_command USING u_comm LIKE sy-ucomm selfield TYPE slis_selfield.
CASE u_comm.
WHEN 'DET'.
........ur logic.........
ENDCASE.
ENDFORM. "user_command
kindly reward if found helpful.
cheers,
Hema.
Maybe you are looking for
-
How do i get my contacts from different resources to icloud?
My contacts comes from different resources (gmail.com, icloud), How do i get my contacts from before icloud into icloud?
-
Process Chain behavior changed after SP upgrade
Hi all, we've recently updated SP from SAP_BW 700, SAPKW70016 to SAPKW70021. We realized about a particular process chain behavior: We have many process chains configured to execute the next step "Always" (whatever it happens with the previous proces
-
Can't switch to old 3.2.2 Aperture library (using 3.5.1)
Hello there, I use Aperture 3.2.2 (with a 100GB Library on an external drive) and I've just bought a new MacBook Pro which is running the latest version of Aperture (3.5.1). When I go to 'file > Switch to library > Other/new' and click the 'Other lib
-
Looks like there will be some learning at the "professional's" expense. It starts with four identical books ordered - a wedding - and yes - the wedding date on an inside page is wrong. Lesson 1 - they don't proof your text -- date was September 16, 2
-
Characteristic 0BPARTNER is blocked by conversion
Hello, I´m trying to activate 0BPARTNER characteristic but it is blocked by conversion. System sais that problem will be solved activating 0BPARTNER but it is impossible to do it: Message no. R7476 Diagnosis The conversion of master data tables from