List output in ALV grid
Hi all,
I need the list output of one program in my program in a grid(single column).
I am doing the below..
TYPES: BEGIN OF tp_ascitab ,
line(150),
END OF tp_ascitab.
DATA: dt_ascitab TYPE TABLE OF tp_ascitab,
ds_ascitab TYPE tp_ascitab.
SUBMIT zlist_program WITH p-gmn EQ matno
WITH p-plant EQ plant
EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = gmn_info_tab
EXCEPTIONS
not_found = 1
OTHERS = 2.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listobject = gmn_info_tab
listasci = dt_ascitab.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF dg_gridcont IS INITIAL.
Create controls
CREATE OBJECT dg_gridcont
EXPORTING container_name = 'GRID_CONT'.
ENDIF.
CREATE OBJECT dg_grid
EXPORTING i_parent = dg_gridcont.
ds_layout-no_hgridln = 'X'.
ds_layout-no_toolbar = 'X'.
CALL METHOD dg_grid->set_table_for_first_display
EXPORTING
is_layout = ds_layout
CHANGING
it_fieldcatalog = dt_fcat[]
it_outtab = dt_ascitab.
The table dt_ascitab has data in correct format until it is passed to grid.
After that, there is change in alignmentt. The grid output has data with
improper alignment. Could anyone help me with this.
thanks,
Keerthi.
Hi Keerthi,
Try Using following FM before Method 'set_table_for_first_display'
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = ' '
i_structure_name = 'structure in which format u need output'
i_client_never_display = 'X'
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = dt_fcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
Hope, it will help u.
Similar Messages
-
Event for the List Box in ALV Grid Control
Hello,
I have the below urgent requirment.
I have an ALV Grid Control built using ABAP Objects. In the grid, I have few fields and one of these fields is a List Box. Depending on the values selected, I need to enable or disable some fields. So, is there any event for the List box in ALV Grid Control.
For ex: I have 2 Fields, Designation and Commission. The designation field is a List Box field having 'Software Engineer' and 'Manager' as values. When I select 'Software Engineer', the commission field should be disabled. When I select 'Manager', the comission field should be enabled.
Early reply is hightly appreciated.
PriyaREPORT ZTEST1234 MESSAGE-ID ZZ .
DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: L_VALID TYPE C,
V_FLAG,
V_DATA_CHANGE,
V_ROW TYPE LVC_S_ROW,
V_COLUMN TYPE LVC_S_COL,
V_ROW_NUM TYPE LVC_S_ROID.
DATA: OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM,
G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
GS_LAYOUT TYPE LVC_S_LAYO.
DATA:BEGIN OF ITAB OCCURS 0,
VBELN LIKE LIKP-VBELN,
POSNR LIKE LIPS-POSNR,
COMISN(10),
CELLCOLOR TYPE LVC_T_SCOL, "required for color
DROP(20),
<b> HANDLE_STYLE TYPE LVC_T_STYL,</b>
END OF ITAB.
* CLASS lcl_event_handler DEFINITION
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
**Hot spot Handler
HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
<b>**Handler to Check the Data Change
HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
OF CL_GUI_ALV_GRID
IMPORTING ER_DATA_CHANGED
E_ONF4
E_ONF4_BEFORE
E_ONF4_AFTER,</b>
**Double Click Handler
HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN ES_ROW_NO.
ENDCLASS. "lcl_event_handler DEFINITION
* CLASS lcl_event_handler IMPLEMENTATION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
*Handle Hotspot Click
METHOD HANDLE_HOTSPOT_CLICK .
CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
V_ROW = E_ROW_ID.
V_COLUMN = E_COLUMN_ID.
V_ROW_NUM = ES_ROW_NO.
MESSAGE I000 WITH V_ROW 'clicked'.
ENDMETHOD. "lcl_event_handler
*Handle Double Click
METHOD HANDLE_DOUBLE_CLICK.
ENDMETHOD. "handle_double_click
<b>**Handle Data Change
METHOD HANDLE_DATA_CHANGED.
DATA: X_CHANGE TYPE LVC_S_MODI,
X_FINAL TYPE ITAB,
L_FLAG,
LS_OUTTAB LIKE LINE OF ITAB.
DATA: LS_EDIT TYPE LVC_S_STYL,
LT_EDIT TYPE LVC_T_STYL.
LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.
IF X_CHANGE-FIELDNAME = 'DROP' AND X_CHANGE-VALUE = 'S/W ENGINEER'.
LS_EDIT-FIELDNAME = 'COMISN'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
LS_EDIT-STYLE2 = SPACE.
LS_EDIT-STYLE3 = SPACE.
LS_EDIT-STYLE4 = SPACE.
LS_EDIT-MAXLEN = 8.
INSERT LS_EDIT INTO TABLE LT_EDIT.
INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
MODIFY ITAB INDEX X_CHANGE-ROW_ID FROM LS_OUTTAB TRANSPORTING
HANDLE_STYLE .
else.
LS_EDIT-FIELDNAME = 'COMISN'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
LS_EDIT-STYLE2 = SPACE.
LS_EDIT-STYLE3 = SPACE.
LS_EDIT-STYLE4 = SPACE.
LS_EDIT-MAXLEN = 8.
INSERT LS_EDIT INTO TABLE LT_EDIT.
INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
MODIFY ITAB INDEX X_CHANGE-ROW_ID FROM LS_OUTTAB TRANSPORTING
HANDLE_STYLE .
ENDIF.
ENDLOOP.
CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY
EXCEPTIONS
FINISHED = 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.
ENDMETHOD. "HANDLE_DATA_CHANGED</b>
ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION
*& Global Definitions
DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
*- Fieldcatalog for First and second Report
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
X_FIELDCAT TYPE LVC_S_FCAT,
LS_VARI TYPE DISVARIANT.
* START-OF_SELECTION
START-OF-SELECTION.
SELECT VBELN
POSNR
FROM LIPS
UP TO 20 ROWS
INTO CORRESPONDING FIELDS OF TABLE ITAB.
END-OF-SELECTION.
IF NOT ITAB[] IS INITIAL.
CALL SCREEN 100.
ELSE.
MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
ENDIF.
*& Form CREATE_AND_INIT_ALV
* text
FORM CREATE_AND_INIT_ALV .
DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = G_CONTAINER1.
CREATE OBJECT G_GRID
EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
* Set a titlebar for the grid control
CLEAR GS_LAYOUT.
GS_LAYOUT-GRID_TITLE = TEXT-003.
<b>GS_LAYOUT-STYLEFNAME = 'HANDLE_STYLE'.</b>
GS_LAYOUT-ZEBRA = SPACE.
GS_LAYOUT-CWIDTH_OPT = 'X'.
GS_LAYOUT-NO_ROWMARK = 'X'.
GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
<b> CALL METHOD G_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.</b>
CREATE OBJECT G_HANDLER.
SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
<b> SET HANDLER G_HANDLER->HANDLE_DATA_CHANGED FOR G_GRID.</b>
DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
DATA: L_INDEX TYPE SY-TABIX.
"Here i am changing the color of line 1,5,10...
"so you can change the color of font conditionally
LOOP AT ITAB.
L_INDEX = SY-TABIX.
IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
LS_CELLCOLOR-FNAME = 'VBELN'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '0'.
LS_CELLCOLOR-COLOR-INV = '1'.
APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
LS_CELLCOLOR-FNAME = 'POSNR'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '0'.
LS_CELLCOLOR-COLOR-INV = '1'.
APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
ENDIF.
ENDLOOP.
* setting focus for created grid control
CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
EXPORTING
CONTROL = G_GRID.
* Build fieldcat and set editable for date and reason code
* edit enabled. Assign a handle for the dropdown listbox.
PERFORM BUILD_FIELDCAT.
PERFORM SET_DRDN_TABLE.
* Optionally restrict generic functions to 'change only'.
* (The user shall not be able to add new lines).
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
**Vaiant to save the layout
LS_VARI-REPORT = SY-REPID.
LS_VARI-HANDLE = SPACE.
LS_VARI-LOG_GROUP = SPACE.
LS_VARI-USERNAME = SPACE.
LS_VARI-VARIANT = SPACE.
LS_VARI-TEXT = SPACE.
LS_VARI-DEPENDVARS = SPACE.
CALL METHOD G_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.
**Calling the Method for ALV output
CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
IS_VARIANT = LS_VARI
IS_LAYOUT = GS_LAYOUT
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = IT_FIELDCAT
IT_OUTTAB = ITAB[].
* Set editable cells to ready for input initially
CALL METHOD G_GRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.
ENDFORM. "CREATE_AND_INIT_ALV
*& Form EXCLUDE_TB_FUNCTIONS
* text
* -->PT_EXCLUDE text
FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
* Only allow to change data not to create new entries (exclude
* generic functions).
DATA LS_EXCLUDE TYPE UI_FUNC.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*& Form build_fieldcat
* Fieldcatalog
FORM BUILD_FIELDCAT .
DATA: L_POS TYPE I.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-NO_ZERO = 'X'.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-HOTSPOT = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Item'(025).
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
X_FIELDCAT-FIELDNAME = 'DROP'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-DRDN_HNDL = '1'.
X_FIELDCAT-DRDN_ALIAS = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Comissn'(025).
X_FIELDCAT-FIELDNAME = 'COMISN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-EDIT = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
ENDFORM. " build_fieldcat
*& Module STATUS_0100 OUTPUT
* text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF G_CUSTOM_CONTAINER IS INITIAL.
**Initializing the grid and calling the fm to Display the O/P
PERFORM CREATE_AND_INIT_ALV.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form SET_DRDN_TABLE
* text
FORM SET_DRDN_TABLE.
DATA:LT_DRAL TYPE LVC_T_DRAL,
LS_DRAL TYPE LVC_S_DRAL.
LS_DRAL-HANDLE = '1'.
LS_DRAL-VALUE = 'S/W Engineer'.
LS_DRAL-INT_VALUE = 'S/W Engineer'.
APPEND LS_DRAL TO LT_DRAL.
LS_DRAL-HANDLE = '1'.
LS_DRAL-VALUE = 'Manager'.
LS_DRAL-INT_VALUE = 'Manager'.
APPEND LS_DRAL TO LT_DRAL.
**Setting the Drop down table for Reason Code
CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
EXPORTING
IT_DROP_DOWN_ALIAS = LT_DRAL.
ENDFORM. " set_drdn_table
Regards
vijay -
Wan to add push button in the output of ALV Grid display.
Hi Friends,
I wan to add a Push button in the output of ALV GRID display with STANDARD ikons.
How to copy standard ikons of GRID output.
How to apply the copied status into my code.
Regards,
VijiHi,
Goto SE41, create a pf-status for your alv report program.
On the next screen, click menu EXTRAS --> click option ADJUST TEMPLATES and select radiobutton LIST VIEWER --> you will get all standard buttons of alv in the pf-status.
Delete the unwanted buttons and also you can add new buttons if reqd.
Activate pf-status --> and apply in alv program.
Now to apply this pf-status in your alv report follow code:-
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_rep_id " report id
i_callback_pf_status_set = 'PF' " for PF-STATUS
i_callback_user_command = 'USER_COMMAND' " for User-Command
is_layout = wa_layout " for layout
it_fieldcat = it_field " field catalog
it_sort = it_sort " sort info
TABLES
t_outtab = it_final " internal table
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*& Form pf
* SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
* ON WHICH THE ALV GRID IS DISPLAYED
* -->RT_EXTAB
FORM pf USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZTG_STAT'. "<--pass pf-status name here
ENDFORM. "pf
*& Form USER_COMMAND
* SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
* AND EXECUTE THE APPROPIATE CODE
* -->LV_OKCODE used to capture the function code
* of the user-defined push-buttons
* -->L_SELFIELD text
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.
* assign the function code to variable v_okcode
lv_okcode = sy-ucomm.
* handle the code execution based on the function code encountered
CASE lv_okcode.
WHEN '<function_code>'. "<--to handle user actions
ENDCASE.
ENDFORM. "USER_COMMAND
Hope this helps you.
Regards,
Tarun -
Want to export output of alv grid to excel automatically
hi friends.............
i want to export output of alv grid without displaying on screen to excel file .......................
how i m able to do it ..............................
in the same way as after alv grid display click on LOCAL FILE-> SPREADSHEET-> ........................
plz rply me soon if anyone of u know abt that.................
thanks allot.............actually in output through 'REUSE_ALV_GRID_DISPLAY' some title is also there through TOP_OF_PAGE how can download it also and data table in excel sheet ...................
actually when an alv output is displayed then some title data is also displayed in alv grid then we can download it by clicking on icon 'local file--> spreadsheet........and soon ' ..........
my req. is download it automatically without doing this process and without displaying it on screen......... it means i want to interrupt to alv grid output to only download without displaying it in output screen............
if u clear my question then reply me............. -
Selecting a row in the output of alv grid
hi,
how do i select a row in the output of alv grid?plz help...
regards,
sheeba.Hi,
Please refer the code below:
*& Report ZDEMO_ALVGRID_SELROW *
*& Example of a simple ALV Grid Report *
*& The basic ALV grid, Enhanced to display capture each row a user has *
*& selected *
REPORT zdemo_alvgrid_selrow .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
SEl, "stores which row user has selected
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
* fieldcatalog-do_sum = 'X'.
* fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'. "Display column total
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
form build_layout.
gd_layout-box_fieldname = 'SEL'.
"set field name to store row selection
gd_layout-edit = 'X'. "makes whole ALV table editable
gd_layout-zebra = 'X'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
* i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
* IT_EVENTS = GT_XEVENTS
i_save = 'X'
* is_variant = z_template
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into corresponding fields of table it_ekko.
endform. " DATA_RETRIEVAL
* FORM USER_COMMAND *
* --> R_UCOMM *
* --> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
* Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
WHEN '&DATA_SAVE'. "user presses SAVE
loop at it_ekko into wa_ekko.
if wa_ekko-sel EQ 'X'.
* Process records that have been selected
endif.
endloop.
ENDCASE.
ENDFORM.
Thanks,
Sriram Ponna. -
Hi all,
How to bring a list box in ALV Grid
Regards,
Vijayakumar
Message was edited by:
Vijayakumar VHello Vijayakumar
You have to do 2 steps (inbetween creating the fieldcatalog and displaying the ALV list):
(1) Set dropdown handle in fieldcatalog, e.g.
* Set Drop-Down handle for column 'LOGSYS'
CLEAR l_wa_fcat.
* l_wa_fcat-drdn_field = 'DROP_DOWN_HANDLE'.
l_wa_fcat-drdn_hndl = c_drdn_handle_logsys. " just a unique number
MODIFY me->mt_fcat FROM l_wa_fcat
TRANSPORTING drdn_hndl
WHERE ( fieldname = 'LOGSYS' ).
(2) Register the dropdown handle, e.g.
* Set listbox for available source systems (according to
* SOM Customizing and selection on selection screen)
CLEAR l_wa_drop.
l_wa_drop-handle = c_drdn_handle_logsys.
LOOP AT me->mt_rfc_check INTO l_wa_rfccheck.
l_wa_drop-value = l_wa_rfccheck-logsys.
APPEND l_wa_drop TO lt_drop.
ENDLOOP.
CALL METHOD me->mo_alvgrid->set_drop_down_table
EXPORTING
it_drop_down = lt_drop.
Regards
Uwe -
Double click on list field in ALV grid control
Hello all,
I developed a report with a ALV grid control. I would like to move some functionality from marking a line and pressing a button in the status line to double clicking a specific field in the output list and execute a command there (i.e. double click on PO number and go to PO display TAC then). Can anybody provide some example coding for that?
Thanks so much for your help!
TorstenHere is your sample program. Copy this code into a z program. Create the screen 100 with a container in it and name it "ALV_CONTAINER". Create the gui-status with "BACK".
report zrich_0001.
tables: ekko.
data: begin of i_alv occurs 0,
ebeln type ekko-ebeln,
end of i_alv.
* CLASS cl_event_receiver DEFINITION Handles Double Click
class cl_event_receiver definition.
public section.
methods handle_double_click
for event double_click of cl_gui_alv_grid
importing e_row e_column.
private section.
endclass.
* CLASS CL_EVENT_RECEIVER IMPLEMENTATION Handles Double Click
class cl_event_receiver implementation.
method handle_double_click.
perform drill_down using e_row-index.
endmethod.
endclass.
data: alv_container type ref to cl_gui_custom_container.
data: event_receiver type ref to cl_event_receiver.
data: alv_grid type ref to cl_gui_alv_grid.
data: layout type lvc_s_layo.
data: fieldcat type lvc_t_fcat.
selection-screen begin of block b1 with frame title text-001 .
select-options: s_ebeln for ekko-ebeln.
selection-screen end of block b1.
start-of-selection.
perform get_data.
call screen 100.
* Module status_0100 OUTPUT
module status_0100 output.
set pf-status '0100'.
set titlebar '0100'.
data: variant type disvariant.
variant-report = sy-repid.
variant-username = sy-uname.
* Create Controls
create object alv_container
exporting
container_name = 'ALV_CONTAINER'.
create object alv_grid
exporting
i_parent = alv_container.
* Create Event Receiver
create object event_receiver.
* Populate Field Catalog
perform get_fieldcatalog.
call method alv_grid->set_table_for_first_display
exporting
is_layout = layout
is_variant = variant
i_save = 'U'
i_structure_name = 'I_ALV'
changing
it_outtab = i_alv[]
it_fieldcatalog = fieldcat[].
* handler for ALV grid
set handler event_receiver->handle_double_click for alv_grid.
endmodule.
* Module USER_COMMAND_0100 INPUT
module user_command_0100 input.
case sy-ucomm.
when 'BACK' or 'CANC'.
if not alv_container is initial.
call method alv_container->free.
clear: alv_container.
free : alv_container.
endif.
if sy-subrc = 0.
set screen 0.
leave screen.
else.
leave program.
endif.
when 'EXIT'.
if not alv_container is initial.
call method alv_container->free.
clear: alv_container.
free : alv_container.
endif.
leave program.
endcase.
endmodule.
* FORM GET_DATA
form get_data.
select * into corresponding fields of table i_alv
from ekko
where ebeln in s_ebeln.
sort i_alv ascending by ebeln.
endform.
* Form Get_Fieldcatalog - Set Up Columns/Headers
form get_fieldcatalog.
data: ls_fcat type lvc_s_fcat.
refresh: fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'PO Number'.
ls_fcat-coltext = 'PO Number'.
ls_fcat-fieldname = 'EBELN'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '12'.
ls_fcat-col_pos = 1.
append ls_fcat to fieldcat.
endform.
* DRILL_DOWN
form drill_down using index.
read table i_alv index index.
if sy-subrc = 0.
set parameter id 'BES' field i_alv-ebeln.
call transaction 'ME23' and skip first screen.
if not alv_container is initial.
call method alv_container->free.
clear: alv_container.
free : alv_container.
endif.
endif.
endform.
Regards,
Rich Heilman -
List box in alv grid control through slis and reuse_alv grid_display metho
hello,
i want to display list box in one column of alv by slis method.can u suggest me how to do it?
neonHi,
plz check below code :
TYPE-POOLS : slis.
*data declarations for ALV container,ALV grid, Fieldcatalogues & layout
DATA: g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo.
*INTERNAL TABLE AND WA DECLARATIONS FOR t517 A table
DATA: gt_outtab TYPE STANDARD TABLE OF t517a INITIAL SIZE 0,
wa_outtab TYPE t517a.
*initialisation event
INITIALIZATION.
*Start of selection event
START-OF-SELECTION.
*Call to ALV
CALL SCREEN 600.
*On this statement double click it takes you to the screen painter SE51.
*Create a Custom container and name it CCONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
*Now a normal screen with number 600 is created which holds the ALV grid.
PBO of the actual screen , Here we can give a title and customized menus
Here we also call the subroutine for ALV output.
MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
set pf-status 'xxx'.
set titlebar 'MAIN100'.
Subroutine to display the output in alv
PERFORM alv_output.
ENDMODULE. "pbo OUTPUT
PAI module of the screen created. In case we use an interactive ALV or
*for additional functionalities we can create OK codes and
based on the user command we can do the coding.
MODULE PAI INPUT *
MODULE pai INPUT.
ENDMODULE. "pai INPUT
*& Form BUILD_FIELDCAT
FORM build_fieldcat.
DATA ls_fcat TYPE lvc_s_fcat.
*Build the field catalogue
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'T517A'
CHANGING
ct_fieldcat = gt_fieldcat.
To assign dropdown in the fieldcataogue
LOOP AT gt_fieldcat INTO ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'SLART'.
*drdn-hndl = '1' is the first list box
ls_fcat-drdn_hndl = '1'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
*drdn-hndl = '2' is the second list box
WHEN 'ABART'.
ls_fcat-drdn_hndl = '2'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
ENDCASE.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form ALV_OUTPUT
FORM alv_output .
*Create object for container
CREATE OBJECT g_custom_container
EXPORTING container_name = 'CCONT'.
*create object for grid
CREATE OBJECT g_grid
EXPORTING i_parent = g_custom_container.
Build fieldcat and set column
*Assign a handle for the dropdown listbox.
PERFORM build_fieldcat.
*Build layout
PERFORM build_layout.
Define a drop down table.
PERFORM dropdown_table.
*fetch values from the T517A table
SELECT * FROM t517a INTO TABLE gt_outtab.
*Display ALV output
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gt_outtab.
ENDFORM. "ALV_OUTPUT
*& Form dropdown_table
text
--> p1 text
<-- p2 text
FORM dropdown_table.
*Declarations for drop down lists in ALV.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
First SLART listbox (handle '1').
ls_dropdown-handle = '1'.
ls_dropdown-value = '01 Primary school'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '02 Lower Secondary'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '03 Upper Secondary'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '04 Professional School'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '05 College'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '06 University'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '09 Other Establishment'.
APPEND ls_dropdown TO lt_dropdown.
Second ABART listbox (handle '2').
ls_dropdown-handle = '2'.
ls_dropdown-value = '10 Primary School certificate'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '20 Lower secondary/Junior high'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '30 High school diploma(B-levels)'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '31 Vocational'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '32 Matriculation'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '40 Specialist vocational certificate'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '50 College degree Level1'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '51 College degree Level2'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '52 Masters degree'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '60 Univ Degree level1'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '61 Bachelors degree'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '62 Masters degree'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '63 Licenciate'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '64 Doctors Degree Ph.D'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '89 None'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '90 Unknown'.
APPEND ls_dropdown TO lt_dropdown.
*method to display the dropdown in ALV
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown.
ENDFORM. " dropdown_table
*& Form build_layout
text
*layout for ALV output
FORM build_layout .
gs_layout-cwidth_opt = 'X'.
gs_layout-grid_title = 'ALV DROPDOWN LISTS'.
gs_layout-no_toolbar = 'X'.
ENDFORM. " build_layout
reference : wiki. -
Regarding downlaod the output from ALV grid format
Hi
i want to download the output ALV grid format into excel sheet .
but condition is when ever user press the button (&ZDL) the should be downloaded.
and also how to convert the output into CSV format.hi,
when '&ZDL'.
use this condition
check this one for down loading
try to download an ALV report in excel format using (list ->export -> local file-> soread sheet )
Re: advantages of alv reports
Excel Download to ALV report
hi this is full program
REPORT ZCR_BOMPLANT_DOWNLOAD.
TABLES : MAST , "Material to BOM Link
STKO , "BOM Header
MARA . "General Material Data
TYPES : BEGIN OF TY_MASTER ,
MATNR TYPE MAST-MATNR , "Material Number
WERKS TYPE MAST-WERKS , "Plant
STLAN TYPE MAST-STLAN , "BOM Usage
STLNR TYPE MAST-STLNR , "Bill of material
STLAL TYPE MAST-STLAL , "Alternative BOM
ANDAT TYPE MAST-ANDAT , "Date record created on
AEDAT TYPE MAST-AEDAT , "Date of Last Change
AENAM TYPE MAST-AENAM , "Name of Person Who Changed Object
STLST TYPE STKO-STLST , "BOM status
ZPLP1 TYPE MBEW-ZPLP1 , "Future Planned Price 1
DWERK TYPE MVKE-DWERK , "Delivering Plant (Own or External)
END OF TY_MASTER .
TYPES : MY_TYPE(20) TYPE C.
DATA : IT_MASTER TYPE STANDARD TABLE OF TY_MASTER,
WA_MASTER TYPE TY_MASTER .
DATA : IT_HEADER TYPE TABLE OF MY_TYPE.
DATA : W_PTH TYPE RLGRAP-FILENAME.
DATA : W_FILE TYPE RLGRAP-FILENAME.
*--- Add Header Fields to Header Table ---
APPEND 'Material Number' TO IT_HEADER .
APPEND 'Plant' TO IT_HEADER .
APPEND 'BOM Usage' TO IT_HEADER .
APPEND 'Bill Code' TO IT_HEADER .
APPEND 'Alternative BOM' TO IT_HEADER .
APPEND 'Created On' TO IT_HEADER .
APPEND 'Changed On' TO IT_HEADER .
APPEND 'Changed By' TO IT_HEADER .
APPEND 'BOM Status' TO IT_HEADER .
APPEND 'Planned Price' TO IT_HEADER .
APPEND 'Delivery Plant' TO IT_HEADER .
IF SY-MANDT = '700'.
W_PTH = '
lkdb01\ISD\IS\Software Developments\Developments\Data Files\SAP Dumps\BOM_Available\'.
ELSE.
W_PTH = 'C:\'.
ENDIF.
START-OF-SELECTION.
*--- Load Data to Internal Table ---
SELECT MASTMATNR MASTWERKS MASTSTLAN MASTSTLNR MASTSTLAL MASTANDAT MASTAEDAT MASTAENAM STKO~STLST
INTO TABLE IT_MASTER
FROM MAST
INNER JOIN STKO ON STKOSTLNR EQ MASTSTLNR
AND STKOSTLAL EQ MASTSTLAL
INNER JOIN MARA ON MARAMATNR EQ MASTMATNR
WHERE MARA~MTART LIKE 'ZFG%'
AND STKO~LKENZ NE 'X'
AND STKO~LOEKZ NE 'X'
AND STKO~STLST EQ '1'.
SELECT MAST~MATNR MAST~WERKS MAST~STLAN MAST~STLNR MAST~STLAL MAST~ANDAT MAST~AEDAT MAST~AENAM STKO~STLST MBEW~ZPLP1 MVKE~DWERK
INTO TABLE IT_MASTER
FROM MAST
INNER JOIN STKO ON STKO~STLNR EQ MAST~STLNR
AND STKO~STLAL EQ MAST~STLAL
INNER JOIN MARA ON MARA~MATNR EQ MAST~MATNR
INNER JOIN MBEW ON MBEW~MATNR EQ MAST~MATNR
AND MBEW~BWKEY EQ MAST~WERKS
INNER JOIN MVKE ON MVKE~MATNR EQ MAST~MATNR
WHERE MARA~MTART LIKE 'ZFG%'
AND STKO~LKENZ NE 'X'
AND STKO~LOEKZ NE 'X'
AND STKO~STLST EQ '1'.
IF SY-SUBRC <> 0.
MESSAGE I014(ZLOAD).
ENDIF.
*--- Set Path to Function Module ---
CONCATENATE W_PTH SY-DATUM ' - ' 'BOM_AVAILABLE_PLANT.XLS' INTO W_FILE.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = W_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_MASTER
FIELDNAMES = IT_HEADER
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_EIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10.
IF SY-SUBRC = 0.
SUBMIT ZI005_MARA_DUMP_SOLIDEAL_N.
MESSAGE I023(ZLOAD) WITH text-001.
ELSE.
MESSAGE I022(ZLOAD) WITH W_FILE. "Errors while downloading.
ENDIF.
END-OF-SELECTION.
SUBMIT ZI005_MARA_DUMP_SOLIDEAL_N. -
Converting ME2N Output to ALV Grid
Hello,
Is there any Class or Function Module which converts the output of ME2N into ALV Grid.
Thanks and Regards,
Prabhjot SinghHi Prabhjot Singh,
you can select ALV Output in parameter "scope of list" within ME2n
Regards
REA -
List header for alv grid using abap objects
Hai all,
I have displayed alv grid in container control using abap objects i.e. using method set_table_for_first_display.
now i need to display list header for this alv grid.
please help me how to create with a sample coding.
Thanks and regards,
Prabu S.Create a splitter using CL_GUI_EASY_SPLITTER_CONTAINER with a top and bottom half. Put the alv grid in the bottom half. Use cl_dd_document (documented in help.sap.com ) to build the header in the top half. Use events on CL_GUI_ALV_GRID to handle the top-of-list printing.
Or, if available, use CL_SALV_TABLE, and read the documentation on that. When I needed a header for my report, that's what I did. There's plenty of good documentation about if you'll search for it.
matt -
Regarding output using alv grid display
Hi experts,
i have a program
FS_TAB1-A = P_T1.
IF P_T1 = 0.
TEMP1 = 1.
DO TEMP1 TIMES.
FS_TAB1-A = P_T1 * DUMMY1.
APPEND FS_TAB1 TO T_TAB1.
DUMMY1 = DUMMY1 + 1.
ENDDO.
now i have to diplay the p_t1*dummy1 using alv grid display like it goes into thew loop for ten times then i have to show it 10 times like
10 1 102 103 104 111 112 like that can u help mehi,
you have to get the result of the multiplication at each row and then concatenate the result and the factor to show the final result in multiples value and multiplication factor... -
hi all,
there is a very typicall requirement to be achieved in ALV grid display.
i need to display the subtotal of a field for which line item should not be shown.
In this case "Number of Purchase orders" should not have any line itme but it should get poplulated with the total number of Purchase order ducument number for a vendor.
here is the required ouput format
vendor number Purchase order document number Number of Purchase orders
32915 1999009090
1999009091
SUM 2
32916 1999009092
SUM 1
SUM total 2
the value to be displayed has been calculated ina variable. the problem is how to display it.
please help.Hi,
Try like this....
TYPE-POOLS slis.
TYPES : BEGIN OF ta ,
d1(10) TYPE c,
d2 TYPE i,
d3 TYPE i,
line_color(4),
END OF ta .
DATA : it TYPE STANDARD TABLE OF ta,
wa TYPE ta,
it1 TYPE STANDARD TABLE OF ta,
wa1 TYPE ta,
n TYPE i,
N1 TYPE I.
DATA : it_layout TYPE STANDARD TABLE OF slis_layout_alv WITH HEADER LINE,
wa_fcat TYPE slis_fieldcat_alv,
it_fcat TYPE slis_t_fieldcat_alv.
DATA : it_sort TYPE slis_t_sortinfo_alv WITH HEADER LINE,
count TYPE i.
wa-d1 = 1.
wa-d2 = 12.
APPEND wa TO it.
wa-d1 = 1.
wa-d2 = 13.
APPEND wa TO it.
wa-d1 = 1.
wa-d2 = 14.
APPEND wa TO it.
wa-d1 = 1.
wa-d2 = 15.
APPEND wa TO it.
wa-d1 = 2.
wa-d2 = 12.
APPEND wa TO it.
wa-d1 = 2.
wa-d2 = 12.
APPEND wa TO it.
wa-d1 = 2.
wa-d2 = 12.
APPEND wa TO it.
wa-d1 = 3.
wa-d2 = 12.
APPEND wa TO it.
wa-d1 = 3.
wa-d2 = 12.
APPEND wa TO it.
SORT it BY d1.
LOOP AT it INTO wa .
count = count + 1.
n = n + 1.
n1 = n1 + 1.
IF count = 1.
wa-d1 = wa-d1.
ELSE.
wa-d1 = ' '.
ENDIF.
wa1-d1 = wa-d1.
wa1-d2 = wa-d2.
APPEND wa1 TO it1.
AT END OF d1.
CLEAR count.
wa1-d1 = 'SUM'.
wa1-d2 = n.
* wa1-d3 = n.
wa1-line_color = 'C400' . "'C300'.
APPEND wa1 TO it1.
CLEAR : n .
CLEAR wa1-line_color.
ENDAT.
ENDLOOP.
wa1-d1 = 'GRAND SUM'.
wa1-d2 = n1.
wa1-line_color = 'C511'.
APPEND wa1 TO it1.
it_layout-info_fieldname = 'LINE_COLOR'.
DEFINE macro4fcat.
wa_fcat-col_pos = &1.
wa_fcat-fieldname = &2.
wa_fcat-tabname = &3.
wa_fcat-seltext_l = &4.
wa_fcat-do_sum = &5.
append wa_fcat to it_fcat.
clear wa_fcat.
END-OF-DEFINITION.
macro4fcat '1' 'D1' 'IT1' 'First' ' ' .
macro4fcat '2' 'D2' 'IT1' 'Amount' ' ' .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = it_layout
it_fieldcat = it_fcat
i_save = 'A'
TABLES
t_outtab = it1
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.
Regards
Debarshi -
To display output of ALV GRID in background.
Hi,
I have a report which is giving TIMEOUT error .This report is interactive( it calls a standard transaction based on user action ) If i run this report in background then I can see the output through spool in basic list .
Whether it is possible to run this report in BACKGROUND and after it gets executed , display the output in foreground so that it does not looses the functionality of intractableness.hi Tushar,
one idea : you can save the output (which is an internal table in fact) to a Z table. Than in another program you read this Z table to internal table and display with ALV.
ec -
Change of list printing to ALV grid printing
Hi everybody
I have requirement to convert the following code to Grid display
can any body help me out in this.
NEW-PAGE PRINT ON
NO DIALOG
LINE-COUNT 58
LINE-SIZE 170 LAYOUT 'X_58_170'
NEW LIST IDENTIFICATION 'X'
KEEP IN SPOOL 'X'
NEW-SECTION
IMMEDIATELY P_ERRLP
DESTINATION P_DEVICE
SAP COVER PAGE 'X'
LIST NAME 'ZFFR070E'.
advance thanksYou can do that
See this thread
CL_ALV_GRID header
Here the data is being displayed in the header, instead you can display in the bottom container rather than top container and display the grid in the top container.
Regards,
Ravi
Note : Please mark all the helpful answers
Maybe you are looking for
-
I'm thinking about buying iPod Video, should i wait for a new iPod or?
I was thinking about getting myself a Video iPod, but then i would hate it if i was to get one let's say this month and next month a new iPod will come out, so should i buy a Video or is there a new iPod coming out anytime soon? Thanks.
-
Problem with the TV@nywhere Master's sound
Hi, I have TV@nywhere Master. The TV picture is OK, but the sound swithcing off after about 90 seconds of playing. Then I change station and the sound is back. But after 90 seconds it switch off again. etc. Does someone know how to solve this proble
-
How to create a field with combo or check box group in a form
1 - i created a database table messages (sender_name , date , message_type , message_body) message type accept only COMPLAINT , SUGESSTION OR OPENION 2 - I created a form which has a field called message_type 3 - i want the message type appear in the
-
Reg: My photo is not showing in my business Card
Dear All, In my profile i am uploading my photo as the way of https://wiki.sdn.sap.com/wiki/download/attachments/21693264/251220071326.jpg this URL i given in my personal URL. And it will be showing in my business card. when other persons are clickin
-
Safari does not display full URL
Safari 6.0.5 will not display full URL until I click in the URL Location bar. For example, the full URL of this page is: https://discussions.apple.com/community/mac_os/question-post!input.jspa?containe rType=14&container=2131&fromWidget=true&questio