Layout in ALV
Hi,
I have created an ALV report in which 5 radio buttons are there for different sort options in selection-screen.Now, I want to remove those radio buttons and keep only one layout field for user selection.The report should display report for appropriate sort options(selected in layout field through F4 help).How to do this?
Thanks,
Lakshmanan
Hi,
Fill the SORTCAT table conditionally.
if layout = 1.
perform fill_sortcat1.
elseif layout = 2.
perform fill_sortcat2.
endif.
regards,
lavanya
Similar Messages
-
How to Keep Default Layout of ALV
I changed layout of ALV, then pressed button "Enter" but not "Save". But when I entered the screen again, the layout was changed to the setting which I changed last time, not default setting.
Source code is shown below.
DATA lt_acc_bal_fcat TYPE lvc_t_fcat.
DATA lt_trans_dtl_fcat TYPE lvc_t_fcat.
CLEAR gt_copc_bal.
APPEND LINES OF it_copc_bal TO gt_copc_bal.
CLEAR gt_trans_detail.
APPEND LINES OF it_trans_detail TO gt_trans_detail.
_adjust_data_for_display( ).
IF gv_grid_inited NE abap_true.
CLEAR gs_grid_variant.
CLEAR gs_grid_variant_detail.
CLEAR gt_trans_dtl_fcat.
gs_grid_layout-no_rowmark = abap_true.
" gs_grid_layout-sel_mode = 'A'.
gs_grid_layout-stylefname = 'FLD_STYL'.
gs_grid_variant-report = sy-repid.
gs_grid_variant-username = sy-uname.
gs_grid_variant-log_group = '001'.
"load account balance data to ALV
CREATE OBJECT go_acc_bal_container
EXPORTING
container_name = 'ACC_BAL_CONTAIN'.
CREATE OBJECT go_acc_bal_grid
EXPORTING
i_appl_events = abap_true
i_parent = go_acc_bal_container.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'EPIC_S_COPC_BAL'
CHANGING
ct_fieldcat = lt_acc_bal_fcat.
DATA lt_acc_bal_fcat_a TYPE lvc_t_fcat.
_adjust_bal_alv_dsp(
EXPORTING
it_fcat = lt_acc_bal_fcat " Field Catalog for List Viewer Control
IMPORTING
et_fcat = lt_acc_bal_fcat_a " Field Catalog for List Viewer Control
go_acc_bal_grid->set_table_for_first_display(
EXPORTING
is_layout = gs_grid_layout
is_variant = gs_grid_variant
i_save = 'A'
CHANGING
it_outtab = gt_copc_bal
it_fieldcatalog = lt_acc_bal_fcat_a
"load trasaction detail data to ALV
CREATE OBJECT go_acc_trans_dtl_container
EXPORTING
container_name = 'TRANS_DTL_CONTAIN'.
CREATE OBJECT go_acc_trans_dtl_grid
EXPORTING
i_appl_events = abap_true
i_parent = go_acc_trans_dtl_container.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'COPC_S_TRANS_DETAIL'
CHANGING
ct_fieldcat = lt_trans_dtl_fcat.
DATA lt_trans_dtl_fcat_a TYPE lvc_t_fcat.
_adjust_detail_alv_dsp(
EXPORTING
it_fcat = lt_trans_dtl_fcat " Field Catalog for List Viewer Control
IMPORTING
et_fcat = gt_trans_dtl_fcat " Field Catalog for List Viewer Control
gs_grid_variant_detail = gs_grid_variant.
gs_grid_variant_detail-log_group = '002'.
go_acc_trans_dtl_grid->set_table_for_first_display(
EXPORTING
is_layout = gs_grid_layout
is_variant = gs_grid_variant_detail
i_save = 'A'
CHANGING
it_outtab = gt_trans_detail
it_fieldcatalog = gt_trans_dtl_fcat
gv_grid_inited = abap_true.
ENDIF.
go_acc_bal_grid->refresh_table_display( ).
go_acc_trans_dtl_grid->refresh_table_display( ).
I want to keep layout of ALV default setting when I enters screen each time. Please help me solve this problem.Hi,
are you refreshing ALV when pressing enter? maybe you should not refresh when pressing enter, or provide the right variant when refreshing.
regards
Stefan Seeburger -
Sving layout with ALV block list
1) I am not able to save layout for alv block. How this can be done?
2) Can this be saved for all blocks if the fields of all blocks are the same?Hi,
1. not possible with the ALV BLOCK list.
2. No option avaialble for this in case of Block list.
for normal list you have variant option.
Regards
vijay -
Hi everyone, I have created an ALV report, and now I've been ask to upgrade this report putting a parameter in the selection screen where the user can select a layout, and then execute the report so when the data is display appear as the layout already chosen by the user.
Can anyone tell me how to add this functionality to my alv report.
Thanks in advanced,
FidelHI Fidel,
Here is example program for List and Grid
whichever u choose that report format will be displayed
check this once.
*& Report ZLAXMI_ALVEXER2 *
*& NAME : VENKATA LAXMI *
*& DATE : 24-02-2006 *
*& PROGRAM TO PRINT THE REPORT IN ALV LIST FORMAT AND GRID FORMAT *
*& WITH TRAFFIC LIGHTS *
REPORT ZLAXMI_ALVEXER2 MESSAGE-ID ZZ .
*& TABLES DECLARATION *
TABLES: VBAK.
*& TYPE POOLS DECLARATION *
TYPE-POOLS: SLIS.
*& INTERNAL TABLE DECLARATION *
DATA: BEGIN OF ITAB OCCURS 0,
ICON TYPE ICON-ID,
VBELN LIKE VBAK-VBELN,
AUDAT LIKE VBAK-AUDAT,
VBTYP LIKE VBAK-VBTYP,
AUART LIKE VBAK-AUART,
AUGRU LIKE VBAK-AUGRU,
NETWR LIKE VBAK-NETWR,
WAERK LIKE VBAK-WAERK,
END OF ITAB.
*INTERNAL TABLE FOR FIELD CATALOG
DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV
WITH HEADER LINE,
*INTERNAL TABLE FOR EVENTS
DATA: IT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT,
*INTERNAL TABLE FOR SORTING
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV,
*INTERNAL TABLE FOR LAYOUT
WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
*& VARIABLE DECLARATION *
DATA : V_REPID TYPE SY-REPID,
V_PAGNO(4) TYPE N,
V_DATE(8) TYPE C.
*& CONSTANTS *
CONSTANTS: C_X TYPE C VALUE 'X'.
*& SELECTION SCREEN *
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN,
S_VBTYP FOR VBAK-VBTYP DEFAULT 'C'.
SELECTION-SCREEN: END OF BLOCK B1.
SELECTION-SCREEN: BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
*SELECTION-SCREEN : BEGIN OF LINE.
*SELECTION-SCREEN COMMENT 1(20) TEXT-003.
PARAMETERS: P_LIST RADIOBUTTON GROUP RAD1 DEFAULT 'X'.
*SELECTION-SCREEN : END OF LINE.
*SELECTION-SCREEN : BEGIN OF LINE.
*SELECTION-SCREEN COMMENT 1(20) TEXT-004.
PARAMETERS: P_GRID RADIOBUTTON GROUP RAD1.
*SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN: END OF BLOCK B2.
AT SELECTION-SCREEN.
PERFORM VALIDATE_SCREEN.
*& START OF SELECTION *
START-OF-SELECTION.
CLEAR: ITAB, ITAB[].
V_REPID = SY-REPID.
PERFORM GET_DATA.
PERFORM DISPLAY_DATA.
*& END OF SELECTION *
END-OF-SELECTION.
*--DO ALV Process
V_REPID = SY-REPID.
*--Sort the Output Fields
PERFORM SORT_FIELDS.
*--Build Field catalog for the Output fields
PERFORM BUILD_FIELDCAT.
*--Set the Layout for ALV
PERFORM SET_LAYOUT.
*& Form GET_DATA
text
TO GET THE DATA FROM TABLES INTO ITAB
FORM GET_DATA .
SELECT VBELN
AUDAT
VBTYP
AUART
AUGRU
NETWR
WAERK
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM VBAK
WHERE VBELN IN S_VBELN AND
AUDAT > '04.04.2005'
AND NETWR > 0.
LOOP AT ITAB.
IF ITAB-NETWR < 10000.
ITAB-ICON = '@08@'.
ELSEIF ITAB-NETWR > 10000 AND ITAB-NETWR < 100000.
ITAB-ICON = '@09@'.
ELSEIF ITAB-NETWR > 100000.
ITAB-ICON = '@0A@'.
ENDIF.
MODIFY ITAB INDEX SY-TABIX.
ENDLOOP.
ENDFORM. " GET_DATA
*& Form sort_fields
FORM SORT_FIELDS .
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'VBTYP'.
WA_SORT-SPOS = '1'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'NETWR'.
WA_SORT-SPOS = '2'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
ENDFORM. " sort_fields
*& Form build_fieldcat
*FORM BUILD_FIELDCAT .
IT_FIELDCAT-COL_POS = '1'.
IT_FIELDCAT-FIELDNAME = 'ICON'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '10'.
IT_FIELDCAT-SELTEXT_L = 'LIGHT'.
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '2'.
IT_FIELDCAT-FIELDNAME = 'VBELN'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '10'.
IT_FIELDCAT-SELTEXT_L = 'SALES DOC NUMBER'(009).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '3'.
IT_FIELDCAT-FIELDNAME = 'AUDAT'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '4'.
IT_FIELDCAT-SELTEXT_L = 'DOCUMENT DATE'(010).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '4'.
IT_FIELDCAT-FIELDNAME = 'VBTYP'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '4'.
IT_FIELDCAT-SELTEXT_L = 'CATEGORY'(011).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '5'.
IT_FIELDCAT-FIELDNAME = 'AUART'.
IT_FIELDCAT-OUTPUTLEN = '4'.
IT_FIELDCAT-SELTEXT_L = 'DOCUMENT TYPE'(012).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '6'.
IT_FIELDCAT-FIELDNAME = 'AUGRU'.
IT_FIELDCAT-OUTPUTLEN = '12'.
IT_FIELDCAT-SELTEXT_L = 'Order reason'(013).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '7'.
IT_FIELDCAT-FIELDNAME = 'NETWR'.
IT_FIELDCAT-OUTPUTLEN = '12'.
IT_FIELDCAT-SELTEXT_L = 'NET VALUE'(014).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '8'.
IT_FIELDCAT-FIELDNAME = 'WAERK'.
IT_FIELDCAT-OUTPUTLEN = '12'.
IT_FIELDCAT-SELTEXT_L = 'SD DOC CURR'(015).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
*ENDFORM. " build_fieldcat
*& Form set_layout
FORM SET_LAYOUT .
IF P_LIST = C_X .
WA_LAYOUT-WINDOW_TITLEBAR = 'LIST DISPLAY'(016).
WA_LAYOUT-ZEBRA = 'X'.
*-- ALV LIST DISPLAY
PERFORM LIST_DISPLAY TABLES ITAB.
*-- ALV GRID DISPLAY
ELSEIF P_GRID = C_X.
WA_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'(017).
WA_LAYOUT-ZEBRA = 'X'.
PERFORM GRID_DISPLAY TABLES ITAB.
ENDIF.
ENDFORM. " set_layout
*& Form list_display
FORM LIST_DISPLAY TABLES P_ITAB .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_SORT = IT_SORT[]
I_SAVE = 'U'
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " list_display
*& Form GRID_DISPLAY
FORM GRID_DISPLAY TABLES P_ITAB .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_SORT = IT_SORT[]
IT_EVENTS = IT_EVENT
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " GRID_DISPLAY
*& Form VALIDATE_SCREEN
text
--> p1 text
<-- p2 text
FORM VALIDATE_SCREEN .
DATA: LV_VBELN LIKE VBAK-VBELN.
IF NOT S_VBELN IS INITIAL.
SELECT VBELN
INTO LV_VBELN
UP TO 1 ROWS
FROM VBAK
WHERE VBELN IN S_VBELN.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'INVALID SALES DOC'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_SCREEN
*& Form display_data
text
--> p1 text
<-- p2 text
FORM DISPLAY_DATA .
DEFINE M_FIELDCAT.
ADD 1 TO WA_FIELDCAT-COL_POS.
WA_FIELDCAT-FIELDNAME = &1.
WA_FIELDCAT-REF_TABNAME = 'VBAK'.
WA_FIELDCAT-DO_SUM = &2.
WA_FIELDCAT-CFIELDNAME = &3.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
END-OF-DEFINITION.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
m_fieldcat 'ICON' '' ''.
m_fieldcat 'VBELN' '' ''.
m_fieldcat 'AUDAT' '' ''.
m_fieldcat 'VBTYP' '' ''.
m_fieldcat 'AUART' '' ''.
m_fieldcat 'AUGRU' '' ''.
m_fieldcat 'NETWR' 'C' 'WAERK'.
m_fieldcat 'WAERK' '' ''.
ENDFORM. " display_data
Regards,
Laxmi -
Hi,
I have to save layout in ALV grid which should persist every time when i start the transaction.I am able to get save, change and manage option in the grid and also able to set the default layout but this default layout doesnot work.
please see the code :
l_repvar = sy-repid.
ls_variant = l_repvar.
l_varient = 'A'.
ls_variant-variant = l_varient.
draft_layout-sel_mode = 'D'.
draft_layout-stylefname = 'CELLPROP'.
draft_layout-no_f4 = 'X'.
DISPLAY THE DATA ON THE GRID
CALL METHOD draft_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'PSHLP_DRAFT_ST'
is_layout = draft_layout
it_toolbar_excluding = g_it_exclude
is_variant = ls_variant
i_save = 'A'
i_default = 'X'
CHANGING
it_fieldcatalog = draft_fieldcat
it_outtab = l_draft[].
i have tried by chaging i_save to 'X' and 'U' but no difference.
Useful answers will be rewarded.
Thanks and Regards,
Harshhi,
try with this code,
DATA: wa_disvariant LIKE disvariant.
wa_disvariant-report = g_repid.
wa_disvariant-username = sy-uname.
and pass these values in your function module,
i_save = 'X'
is_variant = wa_disvariant
thanks and regards,
muralidhar. -
Changing layout of ALV to excel and displaying the data there
Dear All,
My requirement is that I have to develop an ALV report, and also plot the graphs for the same.
I need different types of graphs, so I have searched on SDN, and I found out a blg:-
"Report with a Graph.. An Approach!"
Here is what the person has done:-
I developed a simple ABAP report using ALV and just dumped all my data on it.
After this I downloaded the Standard Excel template available in the ALV.
Defined my own worksheets in this template, wrote some macros to pick up the data from the RawHeader sheet, which is available by default and will contain the ALV data.
I inserted 1 chart in this Excel template. In this chart I used the same chart type as was being used by the user for his graph. Just right clicked on the Graph area and made the changes in the source data and made it point to the sheet containing the final data.
Thats it my job is almost done.
After this uploaded this template back into the report output through
the layout settings->Change Layout Tab.
Save it as a variant and made it a default. (Do not default it if you have more than 1 user and more than 1 template . Select the appropriate variant for the appropriate user and then display)
Well, this also was not that easy as I had thought. I landed up into 1 trouble.
In my report the number of columns displayed was not constant and kept changing based on the input. This fact was taken care by designing a variable field catalogue. But now I had gone past the simple ALV display and was giving the output in an Excel sheet using a pre-defined template. Well, I immediately found a solution to this with the set_frontend_fieldcatalogue method of CL_GUI_ALV_GRID class and fixed the field catalogue every time after calling the set_table_for_first_display method. This solved most of my problems, which were not many though.
Now here are my issues:-
I have developed the ALV report, and I have also changed the layout to excel.
But, I am unable to get the ALV Report data in the RawHeader Sheet, which is available by default.
Could anyone please guide me through this method??
It is urgent.
Points are assured for helpful answers.
Thanks and regards,
PrernaHi Satya Priya,
Do I have to create my own template, or the Standard ones available will do?
HEre is what I do:-
Once I get my ALV output, I goto Change LAyout->View tab.->Prefered view->Microsoft Excel.
Here I get a list of available excel templates There are 2:-
sap_mm.xls, and sap_om.xls
I select one of these, and the excel spreadsheet is displayed on the ALV screen.
But the re is another button, "Upload Document to BDS".
Do I have to upload one of the above templated to BDS?
And please tell me in detail, what is BDS???
Thanks for your help, and waiting for reply,
Prerna -
PS report S_ALR_87013558 - add layout for alv output
Hi Friends
In Standard report of PS S_ALR_87013558 I hav to add a selection screen field for selecting layout and accordingly the ALV layout will be displayed. Can it be achieved by enhancing, or we need to copy the report and modify and configure or is there any other way to do it.
Thanks
MoumitaHi,
I think that can be achived through the dynamic selections to add fields to the dynamic selector you check the transaction CATS_SELVIEW press f4 on name of view and select standard then display you can see all functional groups, tables, table fields. Assign the respective according to your critaria. -
Creating layouts in ALV report
Hi all,
I have created a report when a user creates a layout in the report it should save the variant(layout) and display in the selection-screen with alv_variant and search help.Its working properly.
But I have to create different layouts like the following:
Layout with sort and subtotals,
layout with sort and filter conditions like that.
Can anybody help me regarding this matter.
with regards
chanduSai,
Here is a little sample program which shows you how to recall saved ALV Layouts. It requires the user to run the report, create their own variants, and this program allwos them to recall it from the selection screen.
You can create gobal layouts (for your sorts, and totals) which canbe accessed by any user.
Hope this helps.
Cheers,
Pat.
*& Report ZPATS_ALV *
REPORT zpats_alv .
TABLES: kna1.
TYPE-POOLS: kkblo.
* structures *
DATA: st_fieldcat TYPE slis_fieldcat_alv.
DATA: st_variant1 LIKE disvariant.
DATA: st_variant2 LIKE disvariant.
* internal tables *
DATA: BEGIN OF tbl_kna1 OCCURS 0,
kunnr LIKE kna1-kunnr,
name1 LIKE kna1-name1,
stras LIKE kna1-stras,
telf1 LIKE kna1-telf1,
ort01 LIKE kna1-ort01,
pstlz LIKE kna1-pstlz,
sortl LIKE kna1-sortl,
ernam LIKE kna1-ernam,
spras LIKE kna1-spras,
END OF tbl_kna1.
DATA: tbl_fieldcat TYPE slis_t_fieldcat_alv.
* global variables *
DATA: fieldname(30) TYPE c.
DATA: variant_exit(1) TYPE c,
variant_save(1) TYPE c,
variant_def(1) TYPE c.
* Seelction Screen
PARAMETERS: p_vari LIKE disvariant-variant.
* Initialization Event
INITIALIZATION.
PERFORM variant_init USING st_variant1.
st_variant2 = st_variant1.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = 'A'
CHANGING
cs_variant = st_variant2
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_vari = st_variant2-variant.
ENDIF.
* At Selection Screen On Value Request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
* Start of Selection Event
START-OF-SELECTION.
SELECT kunnr name1 stras telf1 ort01 pstlz sortl ernam spras
INTO CORRESPONDING FIELDS OF TABLE tbl_kna1
FROM kna1.
* End of Selection Event
END-OF-SELECTION.
PERFORM get_fieldcat.
PERFORM create_report.
*& Form get_fieldcat
* text
* --> p1 text
* <-- p2 text
FORM get_fieldcat.
PERFORM write_fieldcat USING 'KUNNR' 'X' 1.
PERFORM write_fieldcat USING 'NAME1' 'X' 2.
PERFORM write_fieldcat USING 'STRAS' ' ' 3.
PERFORM write_fieldcat USING 'TELF1' ' ' 4.
PERFORM write_fieldcat USING 'ORT01' ' ' 5.
PERFORM write_fieldcat USING 'PSTLZ' ' ' 6.
PERFORM write_fieldcat USING 'SORTL' ' ' 7.
PERFORM write_fieldcat USING 'ERNAM' ' ' 8.
PERFORM write_fieldcat USING 'SPRAS' ' ' 9.
ENDFORM. " get_fieldcat
*& Form write_fieldcat
* text
* -->P_0060 text
* -->P_0061 text
* -->P_0062 text
* -->P_0063 text
* -->P_1 text
FORM write_fieldcat USING name
key
pos.
st_fieldcat-fieldname = name.
st_fieldcat-tabname = 'TBL_KNA1'.
st_fieldcat-ref_tabname = 'KNA1'.
st_fieldcat-key = key.
st_fieldcat-col_pos = pos.
IF name = 'PSTLZ'.
st_fieldcat-row_pos = '2'.
ENDIF.
APPEND st_fieldcat TO tbl_fieldcat.
CLEAR st_fieldcat.
ENDFORM. " write_fieldcat
*& Form create_report
* text
* --> p1 text
* <-- p2 text
FORM create_report.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_interface_check = ' '
i_callback_program = 'ZPATS_ALV'
i_callback_user_command = 'USER_COMMANDS'
it_fieldcat = tbl_fieldcat
i_default = 'X'
i_save = 'A'
is_variant = st_variant2
TABLES
t_outtab = tbl_kna1
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. " create_report
*& Form USER_COMMANDS
* text
* --> p1 text
* <-- p2 text
FORM user_commands USING syst-ucomm LIKE syst-ucomm
selfield TYPE slis_selfield.
CASE syst-ucomm.
WHEN '&IC1'.
READ TABLE tbl_kna1 INDEX selfield-tabindex.
SET PARAMETER ID 'KUN' FIELD tbl_kna1-kunnr.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
WHEN OTHERS.
ENDCASE.
ENDFORM. " USER_COMMANDS
*& Form VARIANT_INIT
FORM variant_init USING g_variant LIKE disvariant.
* Initialise the Variant Structure
CLEAR g_variant.
g_variant-report = sy-repid.
ENDFORM. " VARIANT_INIT
*& Form f4_for_variant
FORM f4_for_variant.
CLEAR st_variant1.
st_variant1-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = st_variant1
i_save = 'A'
IMPORTING
e_exit = variant_exit
es_variant = st_variant2.
IF variant_exit = space.
p_vari = st_variant2-variant.
ENDIF.
ENDFORM. " f4_for_variant -
hi experts, in my ALV report, layout selected from select-options(F4) is not displaying, after the initial list dispaly if i select from the layouts then it is comming, pls help me,
i did all the required things like i_save = 'X' ,is_variant = alv_variant, in FM reuse_alv_grid_display,
i also use the FM in this order
1)INITIALIZATION -> REUSE_ALV_VARIANT_DEFAULT_GET
2)AT SELECTION-SCREEN ON VALUE-REQUEST FOR -
>REUSE_ALV_VARIANT_F4
3)AT SELECTION-SCREEN---->REUSE_ALV_VARIANT_DEFAULT_GET
4)start-of-selection.
perform f001-data_retrieval.
perform f002-build_fieldcatalog.
perform f003-build_layout.
perform f004-display_alv_report.
thanks & regardsREPORT z_demo_alv_event_exit_1.
>********************************************************************
This report reads and displays data from table TRDIR, *
using the FM : REUSE_ALV_LIST_DISPLAY *
The columns are displayed in the same order than the Sort Order *
There is an underline if the sort is by UNAM or UDAT *
Author : Michel PIOUD *
Email : [email protected] HomePage : http://www.geocities.com/mpioud *
SELECTION-SCREEN :
BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(3) TYPE n DEFAULT '99' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
TYPE-POOLS slis. " ALV Global Types
TYPES:
BEGIN OF ty_trdir,
name TYPE trdir-name, " ABAP program name
cnam TYPE trdir-cnam, " Created by
cdat TYPE trdir-cdat, " Created on
unam TYPE trdir-unam, " Last changed by
udat TYPE trdir-udat, " Last changed on
END OF ty_trdir.
DATA:
gt_trdir TYPE TABLE OF ty_trdir. " Data displayed
INITIALIZATION.
v_1 = 'Maximum of records to read'.
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
Form f_read_data
FORM f_read_data.
SELECT name cnam cdat unam udat
INTO TABLE gt_trdir
UP TO p_max ROWS
FROM trdir
WHERE name LIKE 'Z%'.
ENDFORM. " F_READ_DATA
Form f_display_data
FORM f_display_data.
Macro definition
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = 'TRDIR'.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_event_exit.
clear ls_event_exit.
ls_event_exit-ucomm = &1.
ls_event_exit-after = 'X'.
append ls_event_exit to lt_event_exit.
END-OF-DEFINITION.
DATA :
ls_layout TYPE slis_layout_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_event_exit TYPE slis_t_event_exit,
ls_event_exit TYPE slis_event_exit.
Build Field Catalog
m_fieldcat 'NAME'.
m_fieldcat 'CNAM'.
m_fieldcat 'CDAT'.
m_fieldcat 'UNAM'.
m_fieldcat 'UDAT'.
Build Event Exit Table
m_event_exit '&OUP'. " Sort up
m_event_exit '&ODN'. " Sort Down
ls_layout-zebra = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_event_exit = lt_event_exit
TABLES
t_outtab = gt_trdir.
ENDFORM. " F_DISPLAY_DATA
FORM USER_COMMAND *
FORM user_command USING u_ucomm TYPE syucomm
us_selfield TYPE slis_selfield. "#EC CALLED
CASE u_ucomm.
WHEN '&OUP' OR '&ODN'. " Sort
PERFORM f_modif_fieldcat.
us_selfield-refresh = 'X'.
ENDCASE.
ENDFORM. " USER_COMMAND
Form F_MODIF_FIELDCAT
FORM f_modif_fieldcat.
DATA:
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv.
FIELD-SYMBOLS :
<sort> TYPE slis_sortinfo_alv,
<fieldcat> TYPE slis_fieldcat_alv.
Read current ALV list information
CALL FUNCTION 'REUSE_ALV_LIST_LAYOUT_INFO_GET'
IMPORTING
et_fieldcat = lt_fieldcat
et_sort = lt_sort
EXCEPTIONS
no_infos = 1
program_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
EXIT.
ENDIF.
CHECK NOT lt_sort[] IS INITIAL.
Fieldcat modification
DESCRIBE TABLE lt_fieldcat.
LOOP AT lt_fieldcat ASSIGNING <fieldcat>.
<fieldcat>-col_pos = <fieldcat>-col_pos + sy-tfill.
ENDLOOP.
LOOP AT lt_fieldcat ASSIGNING <fieldcat>.
READ TABLE lt_sort ASSIGNING <sort>
WITH KEY fieldname = <fieldcat>-fieldname.
CHECK sy-subrc EQ 0.
<fieldcat>-col_pos = <sort>-spos.
ENDLOOP.
SORT lt_fieldcat BY col_pos.
LOOP AT lt_fieldcat ASSIGNING <fieldcat>.
<fieldcat>-col_pos = sy-tabix.
ENDLOOP.
Underline if the sort is by UNAM or UDAT
READ TABLE lt_sort ASSIGNING <sort> INDEX 1.
IF <sort>-fieldname = 'UNAM' OR
<sort>-fieldname = 'UDAT'.
<sort>-group = 'UL'.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_LAYOUT_INFO_SET'
EXPORTING
it_sort = lt_sort
it_fieldcat = lt_fieldcat.
ENDFORM. " F_MODIF_FIELDCAT
END OF PROGRAM Z_DEMO_ALV_EVENT_EXIT_1 *********************** -
Hi
i'm using ALV-GRID OO and i have problems with
saving my own layout.
In the output-liste i have a button to chage the output, but i'm missig
a button to save the new layout.
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = GT_EXCLUDE
IS_LAYOUT = GS_LAYOUT
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = GT_FIELDCAT
IT_OUTTAB = ITAB.
Any idea?
Regards, DieterMake sure that you pass the variant also.
data: variant type disvariant.
variant-report = sy-repid.
variant-username = sy-uname.
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = GT_EXCLUDE
IS_LAYOUT = GS_LAYOUT
is_variant = variant
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = GT_FIELDCAT
IT_OUTTAB = ITAB.
Regards,
Rich Heilman -
Error displaying data in Excel Layout of ALV
Hi,
I am trying to display ALV data in a Excel layout. After changing the layout i am not able to view the data, rather the excel template is alone displayed.
Is there setting that i am supposed. I did not try this on a custom report but i used SE16 to display data.
Any help will be really appreciated!!!
Thanks in advance,
KathirvelHi,
Please make sure that you have made a <b>global</b>
<b>declaration</b> for the ALV Grid control.If not try
with this
Please reward points if this explanation is useful.
Regards,
Siva -
Problem in changing layout of ALV to excel
Hello everyone,
I have developed an ALV program, wherein I need to show the graphs for the same.
For this, I need my data in excel format, so that I can write some macros ,and do the further processing on it(I am using an appraoch I found on SDN, "Report with graph").
I got to know, that I need <b>SAP R/3: Add On:Interactive Excel</b>.
I asked the BASIS guys to install it, but even after installing it, I am unable to view the data in Excel layout, when I do Change LAyout->View->Microsoft Excel.
Could anyone let me know if there is any other setting which is required to view the data in excel?On the excel side, we can change the security level(Tools->Macro->Security) to either low, medium or high.
Is there any such provision in SAP?
Kindly suggest your answers, as it is important for me to get the data in excel.
Points will be rewarded.
Thanks and regards,
PrernaHi,
I have already tried what you have just mentioned.
I searched the entire SDN, for this, and this was one of the replies
But still we don't get the data(Even you didn't get it, right?).
when we change the layout to excel(Excel Inplace), there are 2 sheets by default:-
Rawheader and Rawdata.The data comes in RAwheader sheet.
But there is some setting on the BASIS side, which need to be done, in order for it to work.
I have asked my BASIS colleagues and some of my senior consultants to look into the same.
They will let me know.
I would also suggest you try your program on another PC.
I will let you know as soon as I get any replies from my colleagues.
Thanks and regards,
Prerna -
Problem in saving layout in ALV's
Hi all!
I am getting a strange problem in ALV's .For an ALV report some users are able to save the layouts where as some are not able to save .Why is it happening so? I have mentioned IS_SAVE = 'X' in my func.module REUSE_ALV_GRID_DISPLAY.Please help.Hi,
You Have to call the Fm Reuse_alv_variant_f4
SELECTION-SCREEN : BEGIN OF BLOCK blk3 WITH FRAME TITLE text-003.
PARAMETER:p_var TYPE disvariant-variant MODIF ID p2. "Variant Part
SELECTION-SCREEN:END OF BLOCK blk3.
Data: wa_variant TYPE disvariant,
wa_variant1 TYPE disvariant.
CONSTANTS:c_x(1) TYPE c VALUE'X',
lc_a(1) TYPE c VALUE 'A',
FORM alv_variant .
wa_variant-username = sy-uname.
wa_variant-report = sy-repid.
*For variant Part
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = wa_variant
i_save = lc_a
IMPORTING
es_variant = wa_variant1
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
p_var = wa_variant-variant.
ELSE.
p_var = wa_variant1-variant.
ENDIF.
ENDFORM. " alv_variant
After That
*display variant
wa_variant-report = sy-repid.
IF NOT p_var IS INITIAL.
wa_variant-variant = p_var.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
is_layout = lwa_layout
it_fieldcat = gi_fieldcat
is_variant = wa_variant
i_default = c_x
i_save = lc_a
TABLES
t_outtab = gi_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
Regards
Sandipan -
Hello All,
I am using the class 'cl_salv_table' to create an ALV. In the application toolbar I have the option to change the layout displayed in tha ALV but I am not able to save my changed layout. Please suggest how do I enable the save layout button in the toolbar.
Thanks,
AnjuThis demo example creates a PF status for displaying the buttons, Can I not get the buttons using the standard functions available with the ALV. I am getting the change layout on its own I am not reqd to create a PF status for it. Can I not enable the button save layout also. Also if I create the PF status I would have to add all the buttons reqd in the ALV in the PF status manually
thanks,
Anju -
Manipulate Layout on ALV Grid with dynamic table
Dear all
i'm generating a dynamic table depending of a date selection. That means that I show columns for weeks and the quantity of weeky migh change.
Now the users wants to have a specific layout of the ALV grid with totals. When he saves the layout, only the weeks at this selection will show the next time he runs the programm with a larger selection.
a) Is it possible to modify the layout during runtime by programming?
b) Do you have any other ideas how to solve this problem?
Thank youYou don't know the names of your columns? hmm you do, because before you created dynamic table you had to create field catalog, so the structure and column names of newly (dynamically) created table will be the same like defined in the field catalog.
The last loop also does not look good, in my opinion should be something like:
LOOP AT lt_datatable +(my first table)+ ASSIGNING <ls_data4>.
AT NEW pernr.
APPEND initial line to <fs_1> assigning <fs_2>.
<fs_2>-pernr = <ls_data4>-pernr.
ENDAT.
ASSIGN COMPONENT <ls_data4>-wage_type OF STRUCTURE <fs_2> TO <fs_5>.
<fs_5> = <ls_data4>-amount.
ENDLOOP.
also keep in mind that number of calls of method cl_alv_table_create=>create_dynamic_table is limited to 36 (?) calls within one program session because it uses dynamic subroutine pool behind so you will have short dump if you will execute that 37 times. -
Hi,
I am using both is_variant, i_save parameters in this method, but still am not getting save layout button on my grid.
ls_variant-REPORT = sy-repid.
CALL METHOD w_alv1->set_table_for_first_display
EXPORTING
is_variant = ls_variant
i_save = 'A'
i_default = 'X'
is_layout = it_layout
CHANGING
it_outtab = <fs1>
it_fieldcatalog = it_fcat
it_sort = it_sort
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
Please sujjest me.
Thanks,
Prathapsample code:
gs_variant-report = g_repid. "Program name
CALL METHOD grid1->set_table_for_first_display
EXPORTING it_toolbar_excluding = gt_ui_functions
is_print = gs_print
is_layout = gs_layout
i_save = x_save
is_variant = gs_variant
CHANGING it_outtab = gt_deldef
it_fieldcatalog = pt_fieldcat.
Also c
heck if you have authorization to all basic ALV functiobnalities.
Maybe you are looking for
-
Unable to retrieve Object. Failed to load database information
I am getting the following error when trying to run my reports from Crystal XI with SQL Server 2005. CrystalReportViewer Error in File 180+DAYREP.EWARP: Failed to load database information. Unable to retrieve Object. Error in File 180+DAYREP.EWARP: F
-
MacBook Retina 13 fan goes up all the time and wlan crashes every few minutes
Hello, I've got a MacBook Retina 13" Haswell edition and as soon I open any kind of app or if I just idle at the desktop the fan goes up to 100% and the temperature of the CPU goes over 90celsius all the time. Also my wifi connection drops all the ti
-
Hi Experts I am trying do UAT in FI box(because of the link between HR and FI box and i was told to like this to do testing in FI box,though configuration of time exists in HR box ) related to CATS and I cannot see any plan hours (Time sheet:Data ent
-
Do not allow User to Booked Sales Order if Line QTY is not enough.
Hi All, Is there a way in Order Management setup to not allow sales people to Booked their Sales Order if there are order lines where the qty is not enough in the Inventory, where it will cause 'Backorder' if picked and shipped? Regards, Ja
-
JDeveloper tutorial 404 Not Found
JDeveloper Studio Edition Version 11.1.1.3.0 Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660 I am attempting to complete the "Build a Fusion Web Application" tutorial/labs. After completing "Part 2: Create a Simple User Interface", I execute the