Out put in ALV grid format
Hi,
i need a help from you my dear friend I'm providing you the following information in which i have extract some of the fields from two internal tables and i have to display it in the alv grid format. All the work was done successfully but the problem is the values from internal table are moved but the values are not coming in output in ALV grid format. so pleease try to solve my problem.
Thanking you
TABLES: J_1IEXCHDR, J_1IEXCDTL.
type-pools: slis.
DATA: ITAB1 TYPE J_1IEXCHDR OCCURS 0 WITH HEADER LINE.
DATA: ITAB2 TYPE J_1IEXCHDR OCCURS 0 WITH HEADER LINE.
DATA: ITAB3 TYPE J_1IEXCHDR OCCURS 0 WITH HEADER LINE.
DATA: OK_CODE LIKE SY-UCOMM,
GT_SFLIGHT TYPE TABLE OF itab,
G_CONTAINER TYPE SCRFNAME VALUE 'BCALV_GRID_DEMO_0100_CONT1',
GRID1 TYPE REF TO CL_GUI_ALV_GRID,
G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
DATA: G_TABNAME TYPE SLIS_TABNAME VALUE 'RTAB_ALV'.
data: fieldcat type slis_t_fieldcat_alv.
data: begin of itab occurs 0,
lifnr type j_1iexchdr-lifnr,
docno type j_1iexchdr-docno,
exyear type j_1iexchdr-exyear,
budat type j_1iexchdr-budat,
exbed type j_1iexcDTL-exbed,
rdoc1 type j_1iexcDTL-rdoc1,
ecs type j_1iexcDTL-ecs,
exbas type j_1iexcDTL-exbas,
end of itab.
start-of-selection.
perform get_data.
perform call_alv.
form get_data.
select * into corresponding fields of table itab
from J_1IEXCHDR
inner join J_1IEXCDTL
on J_1IEXCDTLlifnr = J_1IEXCHDRlifnr
where J_1IEXCHDr~status = 'P'.
append itab.
endform.
CALL_ALV
form call_alv.
perform build_field_catalog.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
IT_SORT = gt_sort
it_fieldcat = fieldcat[]
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.
Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
tables
t_outtab = itab.
endform.
form build_field_catalog.
clear: fieldcat. refresh: fieldcat.
data: tmp_fc type slis_fieldcat_alv.
tmp_fc-reptext_ddic = 'Vendor No'.
tmp_fc-fieldname = 'lifnr'.
tmp_fc-tabname = 'itab'.
tmp_fc-outputlen = '10'.
append tmp_fc to fieldcat.
tmp_fc-reptext_ddic = 'docno'.
tmp_fc-fieldname = 'docno'.
tmp_fc-tabname = 'itab'.
tmp_fc-outputlen = '10'.
append tmp_fc to fieldcat.
tmp_fc-reptext_ddic = 'exyear'.
tmp_fc-fieldname = 'exyear'.
tmp_fc-tabname = 'itab'.
tmp_fc-outputlen = '10'.
append tmp_fc to fieldcat.
tmp_fc-reptext_ddic = 'budat'.
tmp_fc-fieldname = 'budat'.
tmp_fc-tabname = 'itab'.
tmp_fc-outputlen = '10'.
append tmp_fc to fieldcat.
tmp_fc-reptext_ddic = 'exbas'.
tmp_fc-fieldname = 'exbas'.
tmp_fc-tabname = 'itab'.
tmp_fc-outputlen = '10'.
append tmp_fc to fieldcat.
tmp_fc-reptext_ddic = 'exbed'.
tmp_fc-fieldname = 'exbed'.
tmp_fc-tabname = 'itab'.
tmp_fc-outputlen = '10'.
append tmp_fc to fieldcat.
tmp_fc-reptext_ddic = 'rdoc1'.
tmp_fc-fieldname = 'rdoc1'.
tmp_fc-tabname = 'itab'.
tmp_fc-outputlen = '10'.
append tmp_fc to fieldcat.
tmp_fc-reptext_ddic = 'ecs'.
tmp_fc-fieldname = 'ecs'.
tmp_fc-tabname = 'itab'.
tmp_fc-outputlen = '10'.
append tmp_fc to fieldcat.
endform.
*loop at itab.
*WRITE: / ITAB-LIFNR,
ITAB-DOCNO,
ITAB-EXYEAR,
ITAB-BUDAT,
ITAB-EXBAS,
ITAB-EXBED,
ITAB-RDOC1,
ITAB-ECS.
*endloop.
Hi Praveen,
In the field cat internal tabel for fieldname you have to pass the values in caps.look at the followig eg:
tmp_fc-fieldname = 'LIFNR'.
let me know if you still have a problem after this change.
regards,
Raju
Similar Messages
-
Dear All,
There is t code called MB51 which the user use, we recommend them to execute that report in the background using this method -- t code-- execute in background--- enter the printer name and generate the temporary spool to veiw the report, however when we veiw that report using spo2, the <b>tool bar</b> (that comes when we execute in the foreround) is missing, which is used to veiw it in the ALV grid format, actually the user easily select the feilds in that format and download them to excel sheets, in the background that <b>" Details"</b> <b>option</b> is not there, is there any work around for this.
Thanks,..
Ravi.Hi Clemens,
Thanks for that valuable suggestion, atleast I got a direction to think about, so from here on its gotta be xml...
But, since I have no idea about xml coding, also I went through those 2 links you had sent, but I'm still unable to understand the following points:
1.How do I generate the xml code, relevant to formatting that I did in ALV Grid using the FM "REUSE_ALV_GRID_DISPLAY"?
2. How do I go about saving the xml file onto the Application server?
3. Can you please provide any sample ALV report code, where such XML formatting has been used?
Thanks in advance.
Regards,
Azeem Ahmed Matte -
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. -
I hav an internal table with 35 fields. I want to get the output in the ALV grid format.
How can i Pl help meHi
Dont bother about how many fields are there in internal table just write your coding in a simple and easy way such that there should not be any performance issue
Check this sample report
*& Report ZALVGRID_WITH_RADIOBUTTONS *
REPORT ZALVGRID_WITH_RADIOBUTTONS .
TYPE-POOLS: abap, icon. " INCLUDE <icon>. for releases < 6.20
TYPES: BEGIN OF ty_s_sflight.
INCLUDE TYPE sflight.
TYPES: button1 TYPE iconname.
TYPES: button2 TYPE iconname.
TYPES: button3 TYPE iconname.
TYPES: button4 TYPE iconname.
TYPES: END OF ty_s_sflight.
DATA:gt_sflight TYPE STANDARD TABLE OF ty_s_sflight,
gs_layout TYPE lvc_s_layo,
gt_fcat TYPE lvc_t_fcat.
DATA:gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid TYPE REF TO cl_gui_alv_grid.
*icon_wd_radio_button_empty TYPE REF TO icon_wd_radio_button_empty.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_hotspot_click.
* define local data
FIELD-SYMBOLS:
<ls_entry> TYPE ty_s_sflight,
<ld_fld> TYPE ANY.
READ TABLE gt_sflight ASSIGNING <ls_entry> INDEX es_row_no-row_id.
CHECK ( <ls_entry> IS ASSIGNED ).
* Set all radio buttons "unselected"
<ls_entry>-button1 = icon_wd_radio_button_empty.
<ls_entry>-button2 = icon_wd_radio_button_empty.
<ls_entry>-button3 = icon_wd_radio_button_empty.
<ls_entry>-button4 = icon_wd_radio_button_empty.
ASSIGN COMPONENT e_column_id-fieldname OF STRUCTURE <ls_entry>
TO <ld_fld>.
IF ( <ld_fld> IS ASSIGNED ).
* Set selected radio button "selected".
<ld_fld> = icon_wd_radio_button.
ENDIF.
* Force PAI followed by refresh of table display in PBO
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'REFRESH'
* IMPORTING
* RC =
ENDMETHOD. "handle_hotspot_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
* MAIN *
START-OF-SELECTION.
PERFORM select_data.
PERFORM init_controls.
PERFORM build_fieldcatalog.
PERFORM set_layout.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
* i_structure_name = 'SFLIGHT'
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fcat
it_outtab = gt_sflight.
* Link docking container to dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
lifetime_dynpro_dynpro_link = 3
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL SCREEN 100.
END-OF-SELECTION.
* MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
ENDMODULE. "PBO OUTPUT
* MODULE PAI INPUT *
MODULE pai INPUT.
* Leave report
CASE gd_okcode.
WHEN 'BACK' OR
'EXIT' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
* Refresh table display
WHEN 'REFRESH'.
PERFORM refresh_display.
WHEN OTHERS.
* do nothing
ENDCASE.
CLEAR gd_okcode.
ENDMODULE. "PAI INPUT
*& Form BUILD_FIELDCATALOG
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'ICON'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DELETE gt_fcat WHERE ( fieldname <> 'NAME' ).
* NOTE: field ICON-NAME has data element ICONNAME.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'SFLIGHT'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'NAME'.
IF ( syst-subrc = 0 ).
DELETE gt_fcat INDEX syst-tabix.
ENDIF.
ls_fcat-fieldname = 'BUTTON4'.
ls_fcat-coltext = ls_fcat-fieldname.
ls_fcat-icon = 'X'.
ls_fcat-hotspot = 'X'.
INSERT ls_fcat INTO gt_fcat INDEX 5.
ls_fcat-fieldname = 'BUTTON3'.
ls_fcat-coltext = ls_fcat-fieldname.
INSERT ls_fcat INTO gt_fcat INDEX 5.
ls_fcat-fieldname = 'BUTTON2'.
ls_fcat-coltext = ls_fcat-fieldname.
INSERT ls_fcat INTO gt_fcat INDEX 5.
ls_fcat-fieldname = 'BUTTON1'.
ls_fcat-coltext = ls_fcat-fieldname.
INSERT ls_fcat INTO gt_fcat INDEX 5.
* Renumbering of the columns
LOOP AT gt_fcat INTO ls_fcat.
ls_fcat-col_pos = syst-tabix.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG
*& Form SELECT_DATA
* text
* --> p1 text
* <-- p2 text
FORM select_data .
* define local data
DATA:
ls_sflight TYPE ty_s_sflight.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_sflight.
ls_sflight-button1 = icon_wd_radio_button. " selected radiobutton
ls_sflight-button2 = icon_wd_radio_button_empty.
ls_sflight-button3 = icon_wd_radio_button_empty.
ls_sflight-button4 = icon_wd_radio_button_empty.
* Alternatively: create icons using function module 'ICON_CREATE'
* on SAP releases where these icons are not available.
MODIFY gt_sflight FROM ls_sflight
TRANSPORTING button1 button2 button3 button4
WHERE ( carrid IS NOT INITIAL ).
ENDFORM. " SELECT_DATA
*& Form INIT_CONTROLS
* text
* --> p1 text
* <-- p2 text
FORM init_controls .
CHECK ( go_docking IS NOT BOUND ).
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
* REPID =
* DYNNR =
* SIDE = DOCK_AT_LEFT
* EXTENSION = 50
* STYLE =
* LIFETIME = lifetime_default
* CAPTION =
* METRIC = 0
ratio = 90
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Size of container = full screen size
CALL METHOD go_docking->set_extension
EXPORTING
extension = 99999
EXCEPTIONS
cntl_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.
* Create ALV grid instance
CREATE OBJECT go_grid
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = go_docking
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_NAME =
* I_FCAT_COMPLETE = SPACE
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Set event handler for event HOTSPOT_CLICK
SET HANDLER:
lcl_eventhandler=>handle_hotspot_click FOR go_grid.
ENDFORM. " INIT_CONTROLS
*& Form REFRESH_DISPLAY
* Refresh table display after switching the radiobuttons
* --> p1 text
* <-- p2 text
FORM refresh_display .
* define local data
DATA:
ls_stable TYPE lvc_s_stbl.
ls_stable-row = abap_true.
ls_stable-col = abap_true.
CALL METHOD go_grid->refresh_table_display
EXPORTING
is_stable = ls_stable
* I_SOFT_REFRESH =
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.
ENDFORM. " REFRESH_DISPLAY
*& Form SET_LAYOUT
* Set layout for ALV list
* --> p1 text
* <-- p2 text
FORM set_layout .
CLEAR: gs_layout.
gs_layout-cwidth_opt = abap_true. " optimize column width
gs_layout-zebra = abap_true.
ENDFORM. " SET_LAYOUT
Reward all helpfull answers
Regards
Pavan -
To Display Report in a ALV GRID Format
Hi All,
I want to display dome information in ALV Grid format.
Can anybody give example for displaying data in ALV Grid Format.
Thanks in advance.
Thanks & Regards,
Rayeez.Hi ,
1.FOR ALV Lists..
REPORT Y_DEMO_ALV NO STANDARD PAGE HEADING.
Data to be displayed
DATA: I_SFLIGHT TYPE TABLE OF SFLIGHT.
Selection
SELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT.
Call ABAP List Viewer (ALV)
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
TABLES
T_OUTTAB = I_SFLIGHT.
2.Using Grids..
REPORT Y_DEMO_ALV_1.
Data to be displayed
DATA: I_SFLIGHT TYPE TABLE OF SFLIGHT.
Selection
SELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT.
Call ABAP List Viewer (ALV)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
TABLES
T_OUTTAB = I_SFLIGHT.
3.Demo Using most of the ALv Functionalities..
REPORT ZSATTRIAL4.
TYPE-POOLS: slis.
DB-Table
TABLES sflight.
Includes
INCLUDE <icon>.
INCLUDE <symbol>.
CONSTANTS:
c_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_layout TYPE slis_layout_alv,
i_sp_group TYPE slis_t_sp_group_alv,
i_events TYPE slis_t_event,
i_print TYPE slis_print_alv,
i_sort TYPE slis_t_sortinfo_alv.
*internal table for data to be displayed
DATA: BEGIN OF i_sflight OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA: box,
lights.
DATA: END OF i_sflight.
DATA: w_repid LIKE sy-repid.
DATA: i_list_top_of_page TYPE slis_t_listheader.
Report Selections
SELECT-OPTIONS s_carrid FOR sflight-carrid.
SELECT-OPTIONS s_connid FOR sflight-connid.
SELECT-OPTIONS s_fldate FOR sflight-fldate.
*SELECTION-SCREEN SKIP 1.
Parameters
PARAMETERS: p_maxrow TYPE i DEFAULT 30."to limit the selection
SELECTION-SCREEN SKIP 1.
Variant for ALV display
SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE text-000.
PARAMETERS: p_varnt LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK 0.
Layout of the report display
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
PARAMETERS: p_zebra AS CHECKBOX DEFAULT ' ', "Striped pattern
p_nocolh AS CHECKBOX DEFAULT ' ', "No column heading
p_novlin AS CHECKBOX DEFAULT ' ', "No vertical lines
p_colopt AS CHECKBOX DEFAULT ' ', "Optimizes col. wd
p_keyhot AS CHECKBOX DEFAULT ' ', "Key fields hot
p_noinpt AS CHECKBOX DEFAULT ' '. "No field for input
SELECTION-SCREEN END OF BLOCK a.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.
PARAMETERS: p_lights AS CHECKBOX DEFAULT 'X',
p_lightc AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK b.
SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-003.
PARAMETERS: p_totonl AS CHECKBOX DEFAULT ' ',
p_totext(60),
p_sttext(60).
SELECTION-SCREEN END OF BLOCK c.
SELECTION-SCREEN BEGIN OF BLOCK d WITH FRAME TITLE text-004.
PARAMETERS: p_chkbox AS CHECKBOX DEFAULT 'X',
p_detpop AS CHECKBOX DEFAULT 'X',
p_groupb AS CHECKBOX DEFAULT ' ',
p_groups AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN END OF BLOCK d.
SELECTION-SCREEN BEGIN OF BLOCK e WITH FRAME TITLE text-005.
PARAMETERS: p_print AS CHECKBOX DEFAULT ' ',
p_nosinf AS CHECKBOX DEFAULT ' ',
p_nocove AS CHECKBOX DEFAULT ' ',
p_nonewp AS CHECKBOX DEFAULT ' ',
p_nolinf AS CHECKBOX DEFAULT ' ',
p_reserv TYPE i.
SELECTION-SCREEN END OF BLOCK e.
DATA: w_boxnam TYPE slis_fieldname VALUE 'BOX',
w_f2code LIKE sy-ucomm VALUE '&ETA',
w_lignam TYPE slis_fieldname VALUE 'LIGHTS',
w_save(1) TYPE c,
w_default(1) TYPE c,
w_exit(1) TYPE c,
i_variant LIKE disvariant,
i_variant1 LIKE disvariant.
INITIALIZATION.
w_repid = sy-repid.
PERFORM fieldcat_init USING i_fieldcat.
PERFORM eventtab_build USING i_events.
PERFORM comment_build USING i_list_top_of_page.
PERFORM sp_group_build USING i_sp_group.
PERFORM t_sort_build USING i_sort.
Set Options: save variant userspecific or general
'A or 'U' are for user-specific variants list
'X' or 'space' for general
w_save = 'A'.
PERFORM variant_init.
Get default variant
i_variant1 = i_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = w_save
CHANGING
cs_variant = i_variant1
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_varnt = i_variant1-variant.
ENDIF.
Process on value request (list of possible variants)
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varnt.
PERFORM f4_for_variant.
PAI
AT SELECTION-SCREEN.
PERFORM pai_of_selection_screen.
START-OF-SELECTION.
PERFORM selection.
END-OF-SELECTION.
PERFORM layout_build USING i_layout. "wg. Parameters
PERFORM print_build USING i_print. "wg. Parameters
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = w_repid
i_internal_tabname = 'I_SFLIGHT'
i_structure_name = 'SFLIGHT'
i_client_never_display = 'X'
i_inclname = w_repid
CHANGING
ct_fieldcat = i_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Call ABAP/4 List Viewer
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
i_callback_program = w_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
i_structure_name = 'SFLIGHT'
i_background_id = 'ALV_BACKGROUND'
I_GRID_TITLE =
I_GRID_SETTINGS =
is_layout = i_layout
it_fieldcat = i_fieldcat[]
IT_EXCLUDING =
it_special_groups = i_sp_group[]
it_sort = i_sort[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
i_save = w_save
is_variant = i_variant
it_events = i_events[]
IT_EVENT_EXIT =
is_print = i_print
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = i_sflight
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.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = w_repid
i_structure_name = 'SFLIGHT'
is_layout = i_layout
it_fieldcat = i_fieldcat[]
IT_EXCLUDING =
it_special_groups = i_sp_group[]
it_sort = i_sort[]
IT_FILTER =
IS_SEL_HIDE =
i_default = W_DEFAULT
i_save = w_save
is_variant = i_variant
it_events = i_events[]
IT_EVENT_EXIT =
is_print = i_print
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
TABLES
t_outtab = i_sflight.
FORM FIELDCAT_INIT *
--> L_FIELDCAT *
FORM fieldcat_init USING l_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SEATSOCC'.
*The field is not displayed in the initial output, can be interactively
chosen for display
ls_fieldcat-no_out = 'X'.
*This field is assigned to a special group with tech. key 'A' and can be
*displayed using the special group buttons
ls_fieldcat-sp_group = 'A'.
*The field cannot be summed irrespective of its data type
ls_fieldcat-no_sum = 'X'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SEATSMAX'.
ls_fieldcat-no_out = 'X'.
ls_fieldcat-sp_group = 'A'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'PRICE'.
ls_fieldcat-no_out = 'X'.
ls_fieldcat-sp_group = 'B'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'CARRID'.
ls_fieldcat-outputlen = 7.
APPEND ls_fieldcat TO l_fieldcat.
ENDFORM.
FORM DATA_ADD *
--> L_SFLIGHT
FORM data_add TABLES l_sflight STRUCTURE i_sflight.
LOOP AT l_sflight.
IF sy-tabix > 10.
l_sflight-box = 'X'.
l_sflight-lights = '3'.
ELSE.
IF sy-tabix = 1.
l_sflight-lights = '2'.
ELSE.
l_sflight-lights = '1'.
ENDIF.
ENDIF.
MODIFY l_sflight.
ENDLOOP.
ENDFORM.
FORM EVENTTAB_BUILD *
--> l_EVENTS *
FORM eventtab_build USING l_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = l_events.
READ TABLE l_events WITH KEY name = slis_ev_top_of_page INTO ls_event.
IF sy-subrc = 0.
MOVE c_formname_top_of_page TO ls_event-form.
APPEND ls_event TO l_events.
ENDIF.
ENDFORM.
FORM COMMENT_BUILD *
--> L_TOP_OF_PAGE *
FORM comment_build USING l_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
***Header
CLEAR ls_line.
ls_line-typ = 'H'.
LS_LINE-KEY: not used for this type
ls_line-info = 'Heading list'.
APPEND ls_line TO l_top_of_page.
***Selection
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = 'Key 1'.
ls_line-info = 'Information'.
APPEND ls_line TO l_top_of_page.
ls_line-key = 'Key 2'.
APPEND ls_line TO l_top_of_page.
***Action
CLEAR ls_line.
ls_line-typ = 'A'.
LS_LINE-KEY: not used for this type
Ls_line-info = 'Status list'.
APPEND ls_line TO l_top_of_page.
ENDFORM.
FORM LAYOUT_BUILD *
<-> LS_LAYOUT *
FORM layout_build USING ls_layout TYPE slis_layout_alv.
ls_layout-f2code = w_f2code.
ls_layout-zebra = p_zebra.
ls_layout-colwidth_optimize = p_colopt.
IF p_chkbox = 'X'.
*Fieldname for check box on the report output
ls_layout-box_fieldname = w_boxnam.
ELSE.
ls_layout-box_fieldname = space.
ENDIF.
ls_layout-no_input = p_noinpt.
ls_layout-no_vline = p_novlin.
ls_layout-no_colhead = p_nocolh.
IF p_lights = 'X' OR p_lightc = 'X'.
**Fieldname for lights on the report output
ls_layout-lights_fieldname = w_lignam.
ELSE.
CLEAR ls_layout-lights_fieldname.
ENDIF.
ls_layout-lights_condense = p_lightc.
ls_layout-totals_text = p_totext.
ls_layout-subtotals_text = p_sttext.
ls_layout-totals_only = p_totonl.
ls_layout-key_hotspot = p_keyhot.
ls_layout-detail_popup = p_detpop.
ls_layout-group_change_edit = p_groups.
E05_LS_LAYOUT-GROUP_BUTTONS = P_GROUPB.
ls_layout-group_buttons = 'X'.
ENDFORM.
FORM SP_GROUP_BUILD *
--> L_SP_GROUP *
FORM sp_group_build USING l_sp_group TYPE slis_t_sp_group_alv.
DATA: ls_sp_group TYPE slis_sp_group_alv.
*Fields are assigned to the special group
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'A'.
ls_sp_group-text = 'Reservation status'.
APPEND ls_sp_group TO l_sp_group.
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'B'.
ls_sp_group-text = 'Flight charges'.
APPEND ls_sp_group TO l_sp_group.
ENDFORM.
FORM SELECTION *
FORM selection.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE i_sflight
UP TO p_maxrow ROWS WHERE carrid IN s_carrid
AND connid IN s_connid AND fldate IN s_fldate.
PERFORM data_add TABLES i_sflight.
ENDFORM.
FORM TOP_OF_PAGE *
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = i_list_top_of_page.
ENDFORM.
FORM F4_FOR_VARIANT *
FORM f4_for_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = i_variant
i_save = w_save
it_default_fieldcat =
IMPORTING
e_exit = w_exit
es_variant = i_variant1
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF w_exit = space.
p_varnt = i_variant1-variant.
ENDIF.
ENDIF.
ENDFORM.
*& Form PAI_OF_SELECTION_SCREEN
to check whether right variant is entered on the selection scr
FORM pai_of_selection_screen.
IF NOT p_varnt IS INITIAL.
MOVE i_variant TO i_variant1.
MOVE p_varnt TO i_variant1-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = w_save
CHANGING
cs_variant = i_variant1.
i_variant = i_variant1.
ELSE.
PERFORM variant_init.
ENDIF.
ENDFORM. " PAI_OF_SELECTION_SCREEN
*& Form VARIANT_INIT
FORM variant_init.
CLEAR i_variant.
i_variant-report = w_repid.
ENDFORM. " VARIANT_INIT
FORM PRINT_BUILD *
FORM print_build USING l_print TYPE slis_print_alv.
l_print-print = p_print.
l_print-no_print_selinfos = p_nosinf.
l_print-no_coverpage = p_nocove.
l_print-no_new_page = p_nonewp.
l_print-no_print_listinfos = p_nolinf.
l_print-reserve_lines = p_reserv.
l_print-print = p_print.
ENDFORM.
FORM T_SORT_BUILD *
FORM t_sort_build USING l_sort TYPE slis_t_sortinfo_alv.
DATA: ls_sort TYPE slis_sortinfo_alv.
ls_sort-fieldname = 'CARRID'.
ls_sort-spos = 1.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
APPEND ls_sort TO l_sort.
ps : reward points for helpful answers and mark the post as closed.. -
MRP Out Put Schedule lines date format to month
Hi Friends,
I am working on SAP4.7 Version.
I have maintained all the relavent MRP datas in material master.
Like MRP type - PD,
Lot Size- MB ( Monthly Lot size).
I have created planned independent requirement in MD61 monthly wise for that material.
I have given Schedule agreement number in Source in List with MRP indicator - 2.
I am running MRP for a material with MD02 with MRP parameter Delivery schedules -3 (Schedule lines) .
The MRP running succesfully and creating delivery Lines with delivery dates.
But the requirement by the client is..
The delivery lines should be generated in month wise.
How to convert the schedule lines generated in day format to Month format in MRP run out put?
While creating schedule lines with ME38. we have option to select the day format / month format/ week wise?
But the MRP out put always generated in date wise?
Any one knows what changes i should make?
Guide me ..
Thanks & Best Regards
GiriHai Boss
Can you throw some light , how you set default mrp indicator month wise with the help of ABAPER.
My client requirement also same like you. Yours is month, mine is week. Pl help me out.
regards
ssp -
Hi,
Is it possible that when a user higlights a row in ALV, the entire row will be uneditable? Please teach me how.
Thanks,
JimThis code works for grey cells...But it could be adapted to lines -;) It uses OO ALV...
*& Report Z_DUMMY_ATG
REPORT Z_DUMMY_ATG NO STANDARD PAGE HEADING.
TABLES: SPFLI.
*============================================================
* Variables
*============================================================
DATA: OK_CODE TYPE SY-UCOMM,
L_MODE TYPE RAW4,
W_TABIX TYPE SY-TABIX.
*============================================================
* Tablas internas
*============================================================
DATA: L_S_LAYO TYPE LVC_S_LAYO.
DATA: WA_EDIT TYPE LVC_T_STYL WITH HEADER LINE.
DATA: IT_EDIT TYPE LVC_T_STYL WITH HEADER LINE.
DATA: BEGIN OF G_WA_SFLIGHT.
INCLUDE STRUCTURE SPFLI.
DATA: CELL_TAB TYPE LVC_T_STYL.
DATA: END OF G_WA_SFLIGHT.
TYPES: BEGIN OF SPFLI_TAB.
INCLUDE STRUCTURE SPFLI.
TYPES: CELL_TAB TYPE LVC_T_STYL.
TYPES: END OF SPFLI_TAB.
TYPES: SPFLI_TABS TYPE STANDARD TABLE OF SPFLI_TAB.
DATA: GI_SFLIGHT TYPE SPFLI_TABS.
DATA: BEGIN OF AUX_TAB OCCURS 0,
CARRID LIKE SPFLI-CARRID,
CONNID LIKE SPFLI-CONNID,
CITYFROM LIKE SPFLI-CITYFROM,
AIRPFROM LIKE SPFLI-AIRPFROM,
CITYTO LIKE SPFLI-CITYTO,
AIRPTO LIKE SPFLI-AIRPTO,
END OF AUX_TAB.
DATA: SPFLI_TAB_WA LIKE G_WA_SFLIGHT.
FIELD-SYMBOLS: <SF> STRUCTURE G_WA_SFLIGHT
DEFAULT SPFLI_TAB_WA.
*============================================================
* Objetos
*============================================================
DATA: CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
ALV_LIST TYPE REF TO CL_GUI_ALV_GRID.
*============================================================
* Selección de Datos
*============================================================
SELECT *
FROM SPFLI
INTO CORRESPONDING FIELDS OF TABLE AUX_TAB .
LOOP AT AUX_TAB.
MOVE-CORRESPONDING AUX_TAB TO <SF>.
APPEND <SF> TO GI_SFLIGHT.
ENDLOOP.
*============================================================
* Instancimiento de Objetos
*============================================================
CREATE OBJECT CONTAINER
EXPORTING CONTAINER_NAME = 'LIST_AREA'.
CREATE OBJECT ALV_LIST
EXPORTING I_PARENT = CONTAINER.
*============================================================
* Procesamiento
*============================================================
LOOP AT GI_SFLIGHT INTO G_WA_SFLIGHT.
W_TABIX = SY-TABIX.
IF G_WA_SFLIGHT-CITYTO EQ 'SAN FRANCISCO'.
L_MODE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
MOVE 'CITYTO' TO WA_EDIT-FIELDNAME.
MOVE L_MODE TO WA_EDIT-STYLE.
INSERT WA_EDIT INTO IT_EDIT INDEX W_TABIX.
G_WA_SFLIGHT-CELL_TAB[] = IT_EDIT[].
ENDIF.
MODIFY GI_SFLIGHT FROM G_WA_SFLIGHT.
ENDLOOP.
MOVE 'CELL_TAB' TO L_S_LAYO-STYLEFNAME.
CALL METHOD ALV_LIST->SET_READY_FOR_INPUT
EXPORTING I_READY_FOR_INPUT = 1.
CALL METHOD ALV_LIST->SET_TABLE_FOR_FIRST_DISPLAY(
EXPORTING I_STRUCTURE_NAME = 'SPFLI'
IS_LAYOUT = L_S_LAYO
CHANGING IT_OUTTAB = GI_SFLIGHT ).
*============================================================
* Dynpro
*============================================================
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '100'.
ENDMODULE.
*& Module USER_COMMAND_0100 INPUT
MODULE USER_COMMAND_0100 INPUT.
OK_CODE = SY-UCOMM.
IF OK_CODE = 'BACK'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR OK_CODE.
ENDIF.
ENDMODULE.
Greetings,
Blag. -
Hi,
I have a web dynpro alv table that has many columns (about 20) I would like it to be displayed so that the user does not have to scroll right to see all the data.
at the moment columns:
col1 col2 col3 ......col19 col20
i would like the second half of the table under the 1sta half:
col1 col2 col3...col9 col10
col11 col12...col19 col20
Is there any way that i can get the table to be split into two or some other nice way to display without scrolling?You won't be able to do this with a single ALV. I suppose you could have two ALVs and bind them both to the same context. You wouldn't be able to sync the veritcal scrolling between the the two ALVs however. I'm also not sure how usage this design is from a UI design pattern. I would think the acceptible approach would be to use horizontal scrolling within the ALV. You don't have to make the ALV display all columns at once as this can make your entire page very wide and require using the browser scrolling. Instead consider using the set_scrollable_col_count method.
-
Video out put not a valid format
Hi
I am having a problem with iMovie when i go to share my finnished products.
It works fine when i export to DVD, but when i select to share as a full quality movie, iMovie creates the video file but when i try to run it i get an error saying Error opeining movie movie could not be opened.
Any one else had this problem?Quite a few of us have got into a tangle since the FCP X 10.1.2 updTE
READ HERE:
Blu-Ray burning error after Final Cut Pro 10.1.2 update.
Some tricks work and some not.
Al -
Need option to count the no. of pernrs based on org unit in ALV Grid Format
Hi ,
Do we have any option to count the no. of pernrs in an org. unit to be printed with subtotals in the pernrs column itself.
Do we have any option for counter in SLIS itself.
Thanks in advance,
SarikaHi Sarika,
Create an additional column in your output for integer field and populate the same with value 1 fro each row.
Then, SORT the internal table by Org. Unit and Job and perform sum operation on the column for integer field.
You can SORT by adding fields to the IT_SORT parameter in REUSE_ALV_GRID_DISPLAY and mark the DO_SUM in the new integer column fieldcatalog entry.
Cheers,
Aditya
Edited by: Aditya Laud on Feb 14, 2008 2:25 AM -
Hi guys,
I generated a report which gives out put in ALV grid.
In the ALV grid output, I have some editable fields.
Lets suppose, there are some editable fields with no data in it.
I have userdefined pushbutton in Application toolbar, when I press the pushbutton the cursor should go to the empty field in the ALV grid output.
Can this be possible through SET CURSOR statement?
Thanks,
Shivaa......Hi,
You can set the cursor field on the output list that too for the output fields which are vissible on the screen only.
syntax
SET CURSOR 11 3. ---> 11Coloumn and 3 line
for dynamically setting cursor, first you have to search for the empty fields then set the cursor dynamically.
look at this help document it might be helpful
http://help.sap.com/saphelp_nw70/helpdata/EN/9f/dba47e35c111d1829f0000e829fbfe/content.htm
Regards
Bala KRishna -
Hi
Following is my Final internal table
vbeln matnr posnr Flax
123 23 10 X
124 24 10
125 25 10 X
126 26 10
I want to display the records in Red colour where Flag = X
how to do this. Pls help meHi Sunil,
Check out with the demo program. Just copy and paste it you will see the coloring is tehre and do some modificatio based on your logic it will defiantly work.
&************Reward point if helpful***************&
report zuseofhashedtables.
** Program: ZUseOfHashedTables **
** Author: Horacio Zapettini **
** Versions: 4.6b - 4.6c **
** Notes: **
** this program shows how we can use hashed tables to improve **
** the responce time. **
** It shows, **
** 1. how to declare hashed tables **
** 2. a cache-like technique to improve access to master data **
** 3. how to collect data using hashed tables **
** 4. how to avoid deletions of unwanted data **
** Results: the test we run read about 31000 rows from mkpf, 150000 **
** rows from mseg, 500 rows from makt and 400 from lfa1. **
** it filled ht_lst with 24500 rows and displayed them in **
** alv grid format. **
** It took about 65 secodns to perform this task (first time **
** we run it when all the db buffers are empty. **
** The same program with standard tables needed 140 seconds **
** to run with the same recordset and with buffers filled in **
** A simmilar test over more than a million rows
** Objetive: show a list that consists of all the material movements **
** '101' - '901' for a certain range of dates in mkpf-budat. **
** the columns to be displayed are: **
** mkpf-budat, **
** mkpf-mblnr, **
** mseg-lifnr, **
** lfa1-name1, **
** mkpf-xblnr, **
** mseg-zeile **
** mseg-charg, **
** mseg-matnr, **
** makt-maktx, **
** mseg-erfmg, **
** mseg-erfme. **
** or show a sumary list by matnr - menge **
** You'll have to create a pf-status called vista - **
** See form set_pf_status for details **
** tables used -
tables: mkpf,
mseg,
lfa1,
makt.
** global hashed tables used
data: begin of wa_mkpf, "header
mblnr like mkpf-mblnr,
mjahr like mkpf-mjahr,
budat like mkpf-budat,
xblnr like mkpf-xblnr,
end of wa_mkpf.
data: ht_mkpf like hashed table of wa_mkpf
with unique key mblnr mjahr
with header line.
data: st_mkpf like standard table of wa_mkpf
with header line.
data: begin of wa_mseg, " line items
mblnr like mseg-mblnr,
mjahr like mseg-mjahr,
zeile like mseg-zeile,
bwart like mseg-bwart,
charg like mseg-charg,
matnr like mseg-matnr,
lifnr like mseg-lifnr,
erfmg like mseg-erfmg,
erfme like mseg-erfme,
end of wa_mseg.
data ht_mseg like hashed table of wa_mseg
with unique key mblnr mjahr zeile
with header line.
data st_mseg like standard table of wa_mseg
with header line.
** cache structure for lfa1 records
data: begin of wa_lfa1,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
end of wa_lfa1.
data ht_lfa1 like hashed table of wa_lfa1
with unique key lifnr
with header line.
** cache structure for material related data
data: begin of wa_material,
matnr like makt-matnr,
maktx like makt-maktx,
end of wa_material.
data: ht_material like hashed table of wa_material
with unique key matnr
with header line.
** result table
data: begin of wa_lst, "
budat like mkpf-budat,
mblnr like mseg-mblnr,
lifnr like mseg-lifnr,
name1 like lfa1-name1,
xblnr like mkpf-xblnr,
zeile like mseg-zeile,
charg like mseg-charg,
matnr like mseg-matnr,
maktx like makt-maktx,
erfmg like mseg-erfmg,
erfme like mseg-erfme,
mjahr like mseg-mjahr,
end of wa_lst.
data: ht_lst like hashed table of wa_lst
with unique key mblnr mjahr zeile
with header line.
data: begin of wa_lst1, " sumary by material
matnr like mseg-matnr,
maktx like makt-maktx,
erfmg like mseg-erfmg,
erfme like mseg-erfme,
color_line(4) TYPE c, " Line color
color_cell TYPE lvc_t_scol, " Cell color
celltab type LVC_T_STYL,
end of wa_lst1.
data: ht_lst1 like hashed table of wa_lst1
with unique key matnr
with header line.
** structures for alv grid display.
** itabs
type-pools: slis.
data: it_lst like standard table of wa_lst with header line,
it_fieldcat_lst type slis_t_fieldcat_alv with header line,
it_sort_lst type slis_t_sortinfo_alv,
it_lst1 like standard table of wa_lst1 with header line,
it_fieldcat_lst1 type slis_t_fieldcat_alv with header line,
it_sort_lst1 type slis_t_sortinfo_alv.
** structures
data: wa_sort type slis_sortinfo_alv,
ls_layout type slis_layout_alv.
** color management.
DATA : wa_color TYPE lvc_s_scol.
* Internal table for color management.
DATA : it_color TYPE TABLE OF lvc_s_scol.
* itab for input enabling.
DATA: lt_celltab TYPE lvc_t_styl. "
** global varialbes
data: g_lines type i.
data: g_repid like sy-repid,
ok_code like sy-ucomm.
** selection-screen
"text: Dates:
select-options: so_budat for mkpf-budat default sy-datum.
"text: Material numbers.
select-options: so_matnr for mseg-matnr.
selection-screen uline.
selection-screen skip 1.
"Text: show summary by material.
parameters: gp_bymat as checkbox default ''.
parameters: gp_hier as checkbox default 'X'.
start-of-selection.
perform get_data.
perform show_data.
end-of-selection.
* FORM get_data *
form get_data.
select mblnr mjahr budat xblnr
into table ht_mkpf
from mkpf
where budat in so_budat. " make use of std index.
** have we retrieved data from mkpf?
describe table ht_mkpf lines g_lines.
if g_lines > 0.
** if true then retrieve all related records from mseg.
** Doing this way we make sure that the access is by primary key
** of mseg.
** The reason is that is faster to filter them in memory
** than to allow the db server to do it.
select mblnr mjahr zeile bwart charg
matnr lifnr erfmg erfme
into table ht_mseg
from mseg
for all entries in ht_mkpf
where mblnr = ht_mkpf-mblnr
and mjahr = ht_mkpf-mjahr.
endif.
** fill t_lst or t_lst1 according to user's choice.
if gp_bymat = ' '.
perform fill_ht_lst.
else.
perform fill_ht_lst1.
endif.
endform.
form fill_ht_lst.
refresh ht_lst.
** Example: how to discard unwanted data in an efficient way.
loop at ht_mseg.
* filter unwanted data
check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
check ht_mseg-matnr in so_matnr.
* read header line.
read table ht_mkpf with table key mblnr = ht_mseg-mblnr
mjahr = ht_mseg-mjahr.
clear ht_lst.
* * note : this may be faster if you specify field by field.
move-corresponding ht_mkpf to ht_lst.
move-corresponding ht_mseg to ht_lst.
perform read_lfa1 using ht_mseg-lifnr changing ht_lst-name1.
perform read_material using ht_mseg-matnr changing ht_lst-maktx.
insert table ht_lst.
endloop.
endform.
form fill_ht_lst1.
data: colorear.
refresh ht_lst1.
** Example: how to discard unwanted data in an efficient way.
** hot to simulate a collect in a faster way
loop at ht_mseg.
* filter unwanted data
check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
check ht_mseg-matnr in so_matnr.
* * note : this may be faster if you specify field by field.
read table ht_lst1 with table key matnr = ht_mseg-matnr
transporting erfmg.
if sy-subrc <> 0. " if matnr doesn't exist in sumary table
" insert a new record
clear ht_lst1.
ht_lst1-matnr = ht_mseg-matnr.
perform read_material using ht_mseg-matnr changing ht_lst1-maktx.
ht_lst1-erfmg = ht_mseg-erfmg.
ht_lst1-erfme = ht_mseg-erfme.
if colorear = ''.
colorear = 'X'.
refresh it_color.
ht_lst1-color_cell[] = it_color[].
MOVE 'C410' TO ht_lst1-color_line.
else.
colorear = ' '.
refresh it_color. clear it_color.
MOVE 'MATNR' TO wa_color-fname.
MOVE '6' TO wa_color-color-col.
MOVE '1' TO wa_color-color-int.
MOVE '1' TO wa_color-color-inv.
APPEND wa_color TO it_color.
MOVE 'MAKTX' TO wa_color-fname.
MOVE '3' TO wa_color-color-col.
MOVE '1' TO wa_color-color-int.
MOVE '1' TO wa_color-color-inv.
APPEND wa_color TO it_color.
MOVE 'ERFMG' TO wa_color-fname.
MOVE '5' TO wa_color-color-col.
MOVE '1' TO wa_color-color-int.
MOVE '1' TO wa_color-color-inv.
APPEND wa_color TO it_color.
ht_lst1-color_cell[] = it_color[].
clear ht_lst1-color_line.
endif.
insert table ht_lst1.
else." a record was found.
" collect erfmg. To do so, fill in the unique key and add
" the numeric fields.
ht_lst1-matnr = ht_mseg-matnr.
add ht_mseg-erfmg to ht_lst1-erfmg.
modify table ht_lst1 transporting erfmg.
endif.
endloop.
endform.
** implementation of cache for lfa1.
form read_lfa1 using p_lifnr changing p_name1.
read table ht_lfa1 with table key lifnr = p_lifnr
transporting name1.
if sy-subrc <> 0.
clear ht_lfa1.
ht_lfa1-lifnr = p_lifnr.
select single name1
into ht_lfa1-name1
from lfa1
where lifnr = p_lifnr.
if sy-subrc <> 0. ht_lfa1-name1 = 'n/a in lfa1'. endif.
insert table ht_lfa1.
endif.
p_name1 = ht_lfa1-name1.
endform.
** implementation of cache for material data
form read_material using p_matnr changing p_maktx.
read table ht_material with table key matnr = p_matnr
transporting maktx.
if sy-subrc <> 0.
ht_material-matnr = p_matnr.
select single maktx into ht_material-maktx
from makt
where spras = sy-langu
and matnr = p_matnr.
if sy-subrc <> 0. ht_material-maktx = 'n/a in makt'. endif.
insert table ht_material.
endif.
p_maktx = ht_material-maktx.
endform.
form show_data.
if gp_hier = 'X'. "no anda.
* perform show_hierarchicalALV.
else.
if gp_bymat = ' '.
perform show_ht_lst.
else.
perform show_ht_lst1.
endif.
endif.
endform.
form show_hierarchicalALV.
st_mkpf[] = ht_mkpf[].
st_mseg[] = ht_mseg[].
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
* exporting
* I_INTERFACE_CHECK = ' '
* I_CALLBACK_PROGRAM =
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IS_LAYOUT =
* IT_FIELDCAT =
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* i_tabname_header =
* i_tabname_item =
* I_STRUCTURE_NAME_HEADER =
* I_STRUCTURE_NAME_ITEM =
* is_keyinfo =
* IS_PRINT =
* IS_REPREP_ID =
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
tables
t_outtab_header = st_mkpf
t_outtab_item = st_mseg
* 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.
form show_ht_lst.
"needed because the FM can't use a hashed table.
it_lst[] = ht_lst[].
perform fill_layout using 'full display'
changing ls_layout.
perform fill_columns_lst.
* perform sort_lst.
g_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
is_layout = ls_layout
it_fieldcat = it_fieldcat_lst[]
* it_sort = it_sort_lst
tables
t_outtab = it_lst
exceptions
program_error = 1
others = 2.
endform.
form show_ht_lst1.
"needed because the FM can't use a hashed table.
it_lst1[] = ht_lst1[].
perform fill_layout using 'Sumary by matnr'
changing ls_layout.
perform fill_columns_lst1.
* perform sort_lst.
g_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
is_layout = ls_layout
it_fieldcat = it_fieldcat_lst1[]
* it_sort = it_sort_lst
tables
t_outtab = it_lst1
exceptions
program_error = 1
others = 2.
endform.
form fill_layout using p_window_titlebar
changing cs_layo type slis_layout_alv.
clear cs_layo.
cs_layo-window_titlebar = p_window_titlebar.
cs_layo-edit = 'X'.
cs_layo-edit_mode = space.
MOVE 'COLOR_LINE' TO cs_layo-info_fieldname.
* Field that identify cell color in inetrnal table
MOVE 'COLOR_CELL' TO cs_layo-coltab_fieldname.
* move 'CELLTAB' TO cs_layo-stylefname.
endform. " armar_layout_stock
form set_pf_status using rt_extab type slis_t_extab.
** create a new status
** and then select extras -> adjust template -> listviewer
set pf-status 'VISTA'.
endform. "set_pf_status
define add_lst.
clear it_fieldcat_lst.
it_fieldcat_lst-fieldname = &1.
it_fieldcat_lst-outputlen = &2.
it_fieldcat_lst-ddictxt = 'L'.
it_fieldcat_lst-seltext_l = &1.
it_fieldcat_lst-seltext_m = &1.
it_fieldcat_lst-seltext_m = &1.
if &1 = 'MATNR'.
it_fieldcat_lst-emphasize = 'C111'.
endif.
append it_fieldcat_lst.
end-of-definition.
define add_lst1.
clear it_fieldcat_lst.
it_fieldcat_lst1-fieldname = &1.
it_fieldcat_lst1-outputlen = &2.
it_fieldcat_lst1-ddictxt = 'L'.
it_fieldcat_lst1-seltext_l = &1.
it_fieldcat_lst1-seltext_m = &1.
it_fieldcat_lst1-seltext_m = &1.
append it_fieldcat_lst1.
end-of-definition.
form fill_columns_lst.
* set columns for output.
refresh it_fieldcat_lst.
add_lst 'BUDAT' 10.
add_lst 'MBLNR' 10.
add_lst 'LIFNR' 10.
add_lst 'NAME1' 35.
add_lst 'XBLNR' 15.
add_lst 'ZEILE' 5.
add_lst 'CHARG' 10.
add_lst 'MATNR' 18.
add_lst 'MAKTX' 30.
add_lst 'ERFMG' 17.
add_lst 'ERFME' 5.
add_lst 'MJAHR' 4.
endform.
form fill_columns_lst1.
* set columns for output.
refresh it_fieldcat_lst1.
add_lst1 'MATNR' 18.
add_lst1 'MAKTX' 30.
add_lst1 'ERFMG' 17.
add_lst1 'ERFME' 5..
endform.
Horacio Zapettini
Program to Calculate FI Opening Balance
How to find the Opening balance for a given period in FI Module for a Particular GL A/c.
I was calculated opening balance, code is below maybe it will be helpful.
*find period.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = s_budat-low
i_periv = i_tab-periv "'K4'
IMPORTING
e_buper = v_donem
e_gjahr = v_gjahr
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
*calc opening balance hesabý
SELECT * FROM knc1 WHERE kunnr = i_tab-kunnr
AND bukrs = i_tab-bukrs " s_bukrs
AND gjahr EQ v_gjahr.
v_dnm = v_donem.
* opening balance first calc > old year ,
WHILE v_dnm > 1.
v_dnm = v_dnm - 1.
CONCATENATE 'knc1-um' v_dnm 's' INTO v_field_name_borc.
CONCATENATE 'knc1-um' v_dnm 'h' INTO v_field_name_alacak.
ASSIGN (v_field_name_borc) TO <fs1> .
ASSIGN (v_field_name_alacak) TO <fs2> .
i_tab-dmbtr_s = i_tab-dmbtr_s + ( <fs1> ). " borc
i_tab-dmbtr_h = i_tab-dmbtr_h + ( <fs2> ). " borc
ENDWHILE.
*opening balance last calc> old
* add days which is from selected date-low month
IF v_donem > 1.
v_dnm = v_donem - 1.
ELSE.
v_dnm = v_donem.
ENDIF.
SELECT SINGLE * FROM t009b WHERE periv = i_tab-periv "'K4'
AND bdatj = s_budat-low+0(4)
AND poper = v_dnm.
t009b-butag = t009b-butag + 1.
IF s_budat-low+6(2) NE t009b-butag.
v_date_high = s_budat-low - 1.
IF v_donem = 1.
v_date_low = s_budat-low.
v_date_low+4(4) = '0101'.
ELSE.
CONCATENATE t009b-bdatj t009b-bumon t009b-butag INTO
v_date_low.
ENDIF.
SELECT * FROM bsad WHERE bukrs EQ i_tab-bukrs "IN s_bukrs
AND kunnr = i_tab-kunnr
AND budat BETWEEN v_date_low AND
v_date_high
AND umskz = space
AND blart IN s_blart.
IF bsad-shkzg = 'S'.
i_tab-dmbtr_s = i_tab-dmbtr_s + ( bsad-dmbtr ).
ELSEIF bsad-shkzg = 'H'.
i_tab-dmbtr_h = i_tab-dmbtr_h + ( bsad-dmbtr ).
ENDIF.
ENDSELECT.
SELECT * FROM bsid WHERE bukrs EQ i_tab-bukrs "IN s_bukrs
AND kunnr = i_tab-kunnr
AND budat BETWEEN v_date_low AND
v_date_high
AND umskz = space
AND blart IN s_blart.
* AND gsber IN gsber.
IF bsid-shkzg = 'S'.
i_tab-dmbtr_s = i_tab-dmbtr_s + ( bsid-dmbtr ).
ELSEIF bsid-shkzg = 'H'.
i_tab-dmbtr_h = i_tab-dmbtr_h + ( bsid-dmbtr ).
ENDIF.
ENDSELECT.
ENDIF.
"opening balance ( þirket bazlý )z1 degeri
i_tab-z1 = i_tab-z1 + ( knc1-umsav + i_tab-dmbtr_s - i_tab-dmbtr_h ).
* for israel
i_tab-dmbtril_s = i_tab-dmbtr_s .
i_tab-dmbtril_h = i_tab-dmbtr_h .
ENDSELECT. -
How to get default lay out set in my ALV out put.
I need to have default layout in my ALV output.
My functional consultant idea was to make sure they have an ALV variant selected.
When he first run the program, how will need to get a "/DEFAULT" variant created.
How can I do that ?
Initialization - For ALV variant
INITIALIZATION.
ws_repid = sy-repid.
g_save = 'A'.
CLEAR g_variant.
g_variant-report = ws_repid.
Get default variant.
gx_variant = g_variant.
gx_variant = g_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_vari = gx_variant-variant.
ENDIF.
&--F4 HELP - FOR ALV VARIANT GET--
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = g_variant
i_save = g_save
IMPORTING
e_exit = g_exit
es_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF g_exit = space.
p_vari = gx_variant-variant.
ENDIF.
ENDIF.
&--AT SELECTION-SCREEN.- For ALV Variant--
AT SELECTION-SCREEN.
*Getting variant Existence
PERFORM get_exist_variant.
*& Form GET_EXIST_VARIANT *
text *
FORM get_exist_variant .
IF NOT p_vari IS INITIAL.
MOVE g_variant TO gx_variant.
MOVE p_vari TO gx_variant-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = g_save
CHANGING
cs_variant = gx_variant.
g_variant = gx_variant.
ELSE.
CLEAR g_variant.
g_variant-report = ws_repid.
ENDIF.
ENDFORM. " GET_EXIST_VARIANT
*& Form alv_display *
This subroutine is to display the out put in ALV. *
FORM alv_display .
Local data
DATA: y_x LIKE boole VALUE 'X'.
DATA: lh_index LIKE lf_fieldcat-col_pos.
For variant
DATA: ws_repid LIKE sy-repid,
g_save TYPE c VALUE 'A',
g_exit TYPE c,
g_variant LIKE disvariant,
gx_variant LIKE disvariant.
For 1st field.( RPT_LOC )
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'RPT_LOC'.
lf_fieldcat-tabname = 'GT_ZGXMIT_L'.
lf_fieldcat-ref_tabname = 'ZGXMIT'.
lf_fieldcat-ref_fieldname = 'RPT_LOC'.
lh_index = lh_index + 1.
lf_fieldcat-col_pos = lh_index.
lf_fieldcat-key = y_x.
lf_fieldcat-no_sum = y_x.
APPEND lf_fieldcat TO lt_fieldcat.
For 2nd field.( BAL_XMIT )
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'BAL_XMIT'.
lf_fieldcat-tabname = 'GT_ZGXMIT_L'.
lf_fieldcat-ref_tabname = 'ZGXMIT'.
lf_fieldcat-ref_fieldname = 'BAL_XMIT'.
lh_index = lh_index + 1.
lf_fieldcat-col_pos = lh_index.
lf_fieldcat-key = y_x.
lf_fieldcat-no_sum = y_x.
APPEND lf_fieldcat TO lt_fieldcat.
4,5,....fields appening
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = ws_repid
I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = v_alv_layout
it_fieldcat = lt_fieldcat
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
i_save = 'A'
IS_VARIANT =
it_events = events[]
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
TABLES
t_outtab = gt_zgxmit_l
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " alv_displayHello SAm,
U have to set like DATA: IT_VARIANT LIKE DISVARIANT,
G_S_SORT LIKE LINE OF IT_SORT.
DATA : G_R_DISP_VARIANT TYPE DISVARIANT.
SORT G_T_OUTTAB BY PSPID POSID.
CLEAR: G_R_DISP_VARIANT.
For storing the variant layout
IT_VARIANT-REPORT = SY-REPID.
IF NOT P_VARIAN IS INITIAL.
G_R_DISP_VARIANT-VARIANT = P_VARIAN.
ELSE.
IT_VARIANT-VARIANT = '/Z48M'.
ENDIF.
CLEAR G_T_OUTTAB.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = IT_VARIANT-REPORT
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
I_SAVE = 'A'
IS_VARIANT = IT_VARIANT
IS_LAYOUT = IT_LAYOUT
IT_SORT = IT_SORT[]
TABLES
T_OUTTAB = G_T_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.
If u want F4 help in the selection screen then do like this.
SELECTION-SCREEN BEGIN OF BLOCK VARIANT WITH FRAME TITLE TEXT-013.
PARAMETERS: P_VARIAN LIKE DISVARIANT-VARIANT DEFAULT '/STANDARD'.
SELECTION-SCREEN END OF BLOCK VARIANT.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARIAN.
PERFORM SHOW_EXISTING_DISPLAY_VARIANTS.
FORM SHOW_EXISTING_DISPLAY_VARIANTS.
DATA: G_R_DISP_VARIANT TYPE DISVARIANT.
G_R_DISP_VARIANT-REPORT = SY-REPID.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = G_R_DISP_VARIANT
I_SAVE = 'A'
IMPORTING
ES_VARIANT = G_R_DISP_VARIANT
EXCEPTIONS
NOT_FOUND = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC = 0.
P_VARIAN = G_R_DISP_VARIANT-VARIANT.
ENDIF.
ENDFORM. " SHOW_EXISTING_DISPLAY_VARIANTS
If useful reward.
Vasanth -
Hi,
iam getting out put by alv
but when i caluclate totlal on quntity field iam getting runtime error like this
plz tell the solution for correct it.
error is:
What happened?
The current application program detected a situation which really
should not occur. Therefore, a termination with a short dump was
triggered on purpose by the key word MESSAGE (type X).
Short text of error message:
Long text of error message:
Technical information about the messag
Message class....... "0K"
Number.............. 000
Variable 1.......... " "
Variable 2.......... " "
Variable 3.......... " "
Variable 4.......... " "Hi sivaram,
after you got a solution to your question you should close the thread and let us know what the solution was.
Regards,
Clemens -
Hi ,related to CSV files out put.
hi all,
I am taking out put in ALV and .CSV format (in unix path ) .
And the ALV out put is fine.
In one of the material description the text is like this :
my name is (Activ.Foil+S,sr)
so for description in CSV it is taking like this : my name is (Activ.Foil+S
and for the next field the remaining text is going
i.e , for material group it is getting : sr)
and all the values are shifted by one field.
so the BW team facing the problem while extracting data ,
can any one please help me out how to solve this probelm.
Thanks and Regards.
C.Shamsundher.Hi Prem,
In such case you need to change the delimitter or else remove the comma from Material description once you retrieve data from database into internal table.
REPLACE ALL OCCURRENCES OF ',' in WA_TAB-DESC with ' '.
Then move the material descritpion to the CSV file.
Best regards,
Prashant
Maybe you are looking for
-
Simple math and a variable in an mc instance name
i have several movie clips with instance names in the format of screened1, screened2, screened3, and so on. i am trying to reference a movie clip as shown below, but it's not working. what am i doing wrong? how do i fix it? this.screened[numOfItems-8
-
How to create a FAT32 partition that is primary instead of logical with disc utility?
I am trying to create a partition on an external drive, so I can use it as a hard drive for my XBOX 360. I already have data on the drive, and there is more data than I can back up. I have tried using disc utility to partition it and I use the MS-DOS
-
I think that my hard drive is very slow. That's how it seems. This is what hdparm shows: [kirk@localhost ~]$ sudo hdparm -Tt /dev/sdb3 /dev/sdb3: Timing cached reads: 1660 MB in 2.00 seconds = 829.94 MB/sec Timing buffered disk reads: 236 MB in
-
Thumbnails for XLS, DOC, etc
Hello, is it possible to have XLS file checked in and to have thumbnail for it? As far as I can see, one option is to use XLS -> PDF conversion with Inbound Refinery and then we will have thumbnail. I can agree that we need to have M$ Office installe
-
Could Apple have repaired my iMac with a different part?
I sent my iMac to be repaired, following graphics problems, and have just received the repair receipt, but to my dismay, the graphics card has only been replaced with the 1gb version, although I always though that I had a 2gb graphics card, is there