Doubt in alv layout variant.
hi experts,
I have a requirement that my selection screen should have 'ALV LAYOUT' as one of my parameter. I am using PNPCE LDB , now my issue is I can get the layout option when f4 is press on the alv layout parameter but the respective layout is not displaying in my output.
ex: I have layout A and B .
A have only pernr and name
b have only pernr and address
my normal alv layout is pernr name and address. if i choose A in my ALV LAYOUT parameter also its displaying in default layout alv same is happening for while am choosing B. I not getting the alv output for respective layout I chosen.
{code}
FORM GET_VARIANT .
DATA: lw_variant TYPE disvariant,
l_exit TYPE char1.
lw_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = lw_variant
i_save = 'A'
IMPORTING
e_exit = l_exit
es_variant = lw_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 l_exit EQ space.
p_layout = lw_variant-variant.
IF NOT p_layout IS INITIAL.
PERFORM get_w_variant.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " GET_VARIANT
*& Form GET_W_VARIANT
* text
* --> p1 text
* <-- p2 text
FORM GET_W_VARIANT .
DATA: lw_variant TYPE disvariant.
lw_variant-report = sy-repid.
lw_variant-handle = space.
lw_variant-log_group = space.
lw_variant-username = space.
lw_variant-variant = p_layout.
lw_variant-text = space.
lw_variant-dependvars = space.
ENDFORM. " GET_W_VARIANT
*& Form ALV_DISPLAY
* text
* --> p1 text
* <-- p2 text
FORM ALV_DISPLAY .
* DATA: l_table TYPE REF TO cl_salv_table.
* TRY.
* CALL METHOD CL_SALV_TABLE=>FACTORY
** EXPORTING
** LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
** R_CONTAINER =
** CONTAINER_NAME =
* IMPORTING
* R_SALV_TABLE = L_TABLE
* CHANGING
* T_TABLE = GT_ALV
* CATCH CX_SALV_MSG .
* ENDTRY.
* l_table->display( ).
DATA: lw_variant TYPE disvariant.
DATA:I_FIELD TYPE SLIS_T_FIELDCAT_ALV,
iWA TYPE SLIS_FIELDCAT_ALV.
IWA-FIELDNAME = 'PERNR'.
IWA-SELTEXT_L = 'EMPLOYEE ID'.
APPEND IWA TO i_FIELD.
IWA-FIELDNAME = 'NAME'.
IWA-SELTEXT_L = 'NAME'.
APPEND IWA TO I_FIELD.
IWA-FIELDNAME = 'DEPT'.
IWA-SELTEXT_L = 'DEPT'.
APPEND IWA TO I_FIELD.
IWA-FIELDNAME = 'UNION'.
IWA-SELTEXT_L = 'UNION'.
APPEND IWA TO I_FIELD.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = 'ZTESTPRGFOR20' "Program name
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = i_field
* it_sort = i_sort
i_save = 'X'
is_variant = Lw_variant
TABLES
t_outtab = GT_ALV
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_DISPLAY
{code}
hi Mohammed Quddus,
thanks for your reply . but if you look at my code the concept are same as same as that link code.
am getting all the things right.
i Can able to change the layout by the button on alv and
able to save that new layout
the saved layout are displaying in the my parameter if I press f4. the problem is if I choose the saved layout that layout is not coming in my alv output always its showing default layout.
if anything you find wrong in my code please let me know.
Similar Messages
-
ALV layout variant missing in background job.
hi guys,
Having problem on getting the default ALV layout variant when run the job in backgorund. Please advise any correction needed in the following code.
Thanks.
*& Include Z_MM_KBR_AGSUBCONINV_MOD2 *
MODULE status_0100 OUTPUT.
SET PF-STATUS '100'.
SET TITLEBAR '100'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module display_data OUTPUT
text
MODULE display_data OUTPUT.
IF sy-batch IS INITIAL. "Foreground
IF w_container IS INITIAL.
IF cl_gui_alv_grid=>offline( ) IS INITIAL.
*Creating the container
CREATE OBJECT w_container
EXPORTING
container_name = c_container
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.
ENDIF.
*Creating the ALV GRID
CREATE OBJECT w_grid
EXPORTING
i_parent = w_container
i_appl_events = c_check
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.
else.
exit.
ENDIF.
ELSE.
*Creating the ALV GRID
CREATE OBJECT w_grid
EXPORTING
i_parent = go_dock_container
i_appl_events = c_check
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
WRITE:/ 'Error in grid'.
ENDIF.
CREATE OBJECT w_grid
EXPORTING i_parent = go_dock_container.
ENDIF.
*getting the variant option
wa_variant-report = sy-repid.
wa_variant-username = sy-uname.
wa_layout-grid_title = sy-title.
wa_layout-cwidth_opt = c_check.
wa_layout-zebra = c_check.
wa_layout-no_f4 = c_check.
wa_layout-sel_mode = 'D'.
*Excluding the unwanted buttons
PERFORM exclude_toolbar_buttons.
build field catalog.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = c_check
i_structure_name = c_fcat_str
i_bypassing_buffer = c_check
CHANGING
ct_fieldcat = t_fieldcat
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.
loop at t_fieldcat into w_fieldcat.
if w_fieldcat-FIELDNAME = 'AGING1'.
W_FIELDCAT-NO_ZERO = 'X'.
MODIFY t_fieldcat FROM W_FIELDCAT INDEX SY-TABIX.
ENDIF.
endloop.
Generate sort critria
PERFORM generate_sort.
Create object of class lcl_event_receiver.
CREATE OBJECT w_event.
Handler for events.
SET HANDLER w_event->handle_top_of_page FOR w_grid.
SET HANDLER w_event->handle_print_top_of_page FOR w_grid.
SET HANDLER w_event->handle_print_end_of_list FOR w_grid.
SET HANDLER w_event->handle_hotspot_click FOR w_grid.
*Displaying the alv
IF NOT sy-batch IS INITIAL.
PERFORM create_snp.
ENDIF.
t_data = i_final.
CALL METHOD w_grid->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = wa_layout
is_variant = wa_variant
CHANGING
it_outtab = t_data
it_fieldcatalog = t_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDIF.
ENDMODULE. " display_data OUTPUT
*& Module user_command_0100 INPUT
text
MODULE user_command_0100 INPUT.
DATA: lt_rows TYPE lvc_t_row,
w_rows TYPE lvc_s_row.
CASE sy-ucomm.
WHEN c_back.
LEAVE TO SCREEN 0.
WHEN c_exit.
LEAVE TO SCREEN 0.
WHEN c_cancel.
LEAVE TO SCREEN 0.
WHEN 'BILDET'.
CALL METHOD w_grid->get_selected_rows
IMPORTING
et_index_rows = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc EQ 0.
READ TABLE lt_rows INTO w_rows INDEX 1.
READ TABLE i_vbfa INTO w_vbfa INDEX w_rows-index.
IF sy-subrc EQ 0.
CLEAR i_zbw_br_nf4.
LOOP AT i_zbw_br_nf3 INTO w_zbw_br_nf3 WHERE
refkey = w_vbfa-v_vbeln.
APPEND w_zbw_br_nf3 TO i_zbw_br_nf4.
ENDLOOP.
call dialog screen and display new alv control
CALL SCREEN 101 STARTING AT 10 5.
ENDIF.
ENDIF.
WHEN 'NOTAF'.
CALL METHOD w_grid->get_selected_rows
IMPORTING
et_index_rows = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc EQ 0.
READ TABLE lt_rows INTO w_rows INDEX 1.
READ TABLE i_zbw_br_nf3 INTO w_zbw_br_nf3 INDEX w_rows-index.
DATA docnum LIKE j_1bdydoc-docnum.
docnum = w_zbw_br_nf3-docnum.
SET PARAMETER ID 'JEF' FIELD docnum.
CALL TRANSACTION 'J1B3N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDMODULE. " user_command_0100 INPUT
*& Form modify_col_name
text
-->P_<FCAT> text
-->P_TEXT_H01 text
FORM modify_col_name USING pwa_fcat TYPE lvc_s_fcat
value(pw_text) TYPE any.
pwa_fcat-coltext = pw_text.
pwa_fcat-scrtext_l = pw_text.
pwa_fcat-scrtext_m = pw_text.
pwa_fcat-scrtext_s = pw_text.
ENDFORM. " modify_col_name
FORM display_hotspot *
FORM display_hotspot USING pw_row_id TYPE lvc_s_row
pw_column_id TYPE lvc_s_col.
FIELD-SYMBOLS <l_data> TYPE zbrforecast.
READ TABLE t_br_nf_acum ASSIGNING <l_data> INDEX pw_row_id-index.
CHECK sy-subrc = 0.
IF pw_column_id = ' '.
ENDIF.
ENDFORM. "display_hotspot
*& Form generate_sort
Genereate Sort criteria
FORM generate_sort.
Local variables
DATA: wal_sort TYPE lvc_s_sort,
wl_pos TYPE numc2.
wl_pos = 01.
sort ORDER
wal_sort-spos = wl_pos.
wal_sort-fieldname = c_aufnr.
wal_sort-up = c_check.
APPEND wal_sort TO t_sort.
ENDFORM. "generate_sort
*& Form f4_variant
text
<--PW_VARI text
FORM f4_variant CHANGING pw_vari TYPE disvariant-variant.
wa_variant-report = sy-cprog.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = wa_variant
i_save = c_u
IMPORTING
es_variant = wa_variant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc IS INITIAL.
pw_vari = wa_variant-variant.
ELSE.
MESSAGE s208(00) WITH text-t04.
ENDIF.
ENDFORM. " f4_variant
*& Form validate_layout
*This subroutine is to validate the layout
No parameters are passed to this subroutine
FORM validate_layout.
IF NOT p_layout IS INITIAL.
Check Layout
wa_variant-report = sy-repid.
wa_variant-username = sy-uname.
wa_variant-variant = p_layout.
CALL FUNCTION 'LVC_VARIANT_EXISTENCE_CHECK'
EXPORTING
i_save = c_u
CHANGING
cs_variant = wa_variant
EXCEPTIONS
OTHERS = 01.
IF NOT sy-subrc IS INITIAL.
SET CURSOR FIELD 'P_LAYOUT'.
MESSAGE s001(00) WITH text-t06 p_layout.
STOP.
ENDIF.
ELSE.
clear wa_variant.
ENDIF.
ENDFORM. " validate_layout
*& Form validate_data
text
FORM validate_data .
PERFORM validate_layout.
ENDFORM. " validate_dataHi,
Before the call to method set_table_for_first_display, populate
wa_variant-report = sy-repid.
Best regards,
Prashant -
Unable to save the ALV layout variant and display of selection screen on F4
Hi All,
The end user wants to directly select the layout variant (SLIS_VARI). I have used the following code to display the layout variant on selection screen. But, I am unable to save the variant on ALV. Whenever I am trying to select the layout variants (by doing F4 on selection screen) its displaying "No Layout found".
Following is the code for displaying layout variant:
PARAMETERS: p_var TYPE slis_vari.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var.
PERFORM f4_variant CHANGING p_var.
FORM f4_variant CHANGING c_variant TYPE slis_vari.
DATA: ls_variant TYPE disvariant,
l_exit TYPE char1.
ls_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = ls_variant
i_save = 'A'
IMPORTING
e_exit = l_exit
es_variant = ls_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 l_exit EQ space.
c_variant = ls_variant-variant.
ENDIF.
ENDIF.
ENDFORM. " f4_variant
and following is the code for displaying the ALV:
FORM edition_alv.
ws_variant2 = ls_variant.
* Call ALV editor in list mode
IF p_list = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = ws_extract1-report
i_callback_user_command = ws_user_command
is_layout = ws_layout
it_fieldcat = wt_fieldcat
it_sort = wt_sort
i_save = 'A'
is_variant = ws_variant2
it_events = wt_events[]
TABLES
t_outtab = wt_edition.
* Call ALV editor in grid mode
ELSE.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = ws_extract1-report
i_callback_user_command = ws_user_command
it_fieldcat = wt_fieldcat
it_sort = wt_sort
i_save = 'A'
is_variant = ws_variant2
it_events = wt_events[]
TABLES
t_outtab = wt_edition.
ENDIF.
ENDFORM.
I am not sure whats going wrong, but I am unable to save variants.
Please help.
Thanks,
Vishal.The F4 will display you the existing layouts only. So you need to save the layout first & then execute the report again & check if you are getting F4 values for that field.
The Layout needs to get stored with variant.
Regards,
Mahesh -
Hi Gurus,
In my ALV report there are two Layout variants.
a) Default Layout - /DEFAULT created by someone else earlier.
b) User specific - created and saved by me (name CS Layout)
I am using this function module
alv_variant-report = sy-repid.
alv_variant-username = sy-uname.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = 'U'
CHANGING
cs_variant = xalv_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_vari = xalv_variant-variant.
ENDIF.
PROBLEM: Even though I am passing user specific information to this FM, but it is returning me the Default layout, but
I want the user specific layout(CS Layout) which I created and saved.
Please help !Hi Chandan,
alv_variant-report = sy-repid.
alv_variant-username = sy-uname.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = 'U'
CHANGING
cs_variant = xalv_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_vari = xalv_variant-variant---------->What does this variable contain.
ENDIF.
You are not populating any value to the variable xalv_variant,again you are passing it again to p_vari.
Check this link once.
[REUSE_ALV_GRID_DISPLAY - layout variant|REUSE_ALV_GRID_DISPLAY - layout variant;
Have a look at rich's reply
Regards,
Lakshman. -
Page-break in alv background job for alv output variant not coming correctl
Hi,
I have created an ALV grid report. When i run the report in background i get the output with correct page-break on FIELD1. Now when i run the report in background with an "ALV output variant" (its the ALV variant that controls the fields display in the output; this is not the program variant), i do not get the page-break on FIELD1. I have already build the sort criteria and using:
gs_sort-group = '* '. "New-Page
Please let me know what could be reason for not getting the page-break in background when i am using the alv output variant and how do i correct this problem.
Regards,
RakeshHello Everyone,
I have solved the problem. While running the program in background, we get the page-breaks when we use the below part of code in the sort catalogue with the condition that the program variant should not use any ALV layout variant.
gs_sort-group = '* '. "New-Page
If you are using the ALV layout variant in the program variant then we can check the ROWPOS, COLPOS, and NO_OUT for that ALV layout variant and pass them along in the fieldcatalog table. You should be careful with not to pass the layout variant in the DISVARIANT. You can notice that i have cleared it and simply passing the program name into that.
*C-- Process separately for jobs running in Background. Actually
*C-- sortcat-group solves the problem only in Foreground. In background
*C-- when ALV layout variant is not selected then it works otherwise it
*C-- fails. So for background jobs we are reading the fieldcat and then
*C-- passing the same in the display FM.
IF sy-batch = 'X'.
CALL FUNCTION 'REUSE_ALV_VARIANT_SELECT'
EXPORTING
i_dialog = ' '
i_user_specific = ' '
i_default = ' '
* I_TABNAME_HEADER =
* I_TABNAME_ITEM =
it_default_fieldcat = gt_fieldcat
i_layout = gs_layout
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
IMPORTING
* E_EXIT =
et_fieldcat = lt_fieldcat
* et_sort = gt_sort[]
* ET_FILTER =
* es_layout = gs_layout
CHANGING
cs_variant = gs_disvariant
EXCEPTIONS
wrong_input = 1
fc_not_complete = 2
not_found = 3
program_error = 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.
CLEAR gs_fieldcat.
LOOP AT gt_fieldcat INTO gs_fieldcat.
*C-- Transfer all position changes to gt_fieldcat from lt_fieldcat
CLEAR ls_fieldcat.
READ TABLE lt_fieldcat
INTO ls_fieldcat
WITH KEY fieldname = gs_fieldcat-fieldname.
IF sy-subrc = 0.
gs_fieldcat-row_pos = ls_fieldcat-row_pos.
gs_fieldcat-col_pos = ls_fieldcat-col_pos.
gs_fieldcat-no_out = ls_fieldcat-no_out.
MODIFY gt_fieldcat FROM gs_fieldcat INDEX sy-tabix.
CLEAR gs_fieldcat.
ENDIF.
ENDLOOP.
*C-- Clear the disvariant for the background job as it contains the ALV
*C-- layout varinat
CLEAR gs_disvariant.
gs_disvariant-report = 'ZGPPMP0001'.
Then pass gt_fieldcat to 'REUSE_ALV_GRID_DISPLAY'.
The reason i'm doing it this way is that when we pass the layout variant name, the contents in gt_fieldcat were getting modified.
One more thing i'd like to point out is that that, i tried to delete the fields with no_out = 'x'. Now when i ran the program in background with all the fields in sort catalog (suppose there are 2 fields field1 and field2) also in fieldcatalog it ran fine. In the next run in background i removed one of the fields in sort catalog from the fieldcatalog (delete the fields with no_out = 'x') and i got dump. Basically i had hidden field1 and so the code which was deleting fields with no_out = 'x' deleted this field from gt_fieldcat. So basically we should not delete fields with no_out = 'x'.
I was getting ABAP runtime errors MESSAGE_TYPE_X in the following part of the standard code.
000310 LOOP AT CT_SORT INTO LS_SORT.
000320
000330 READ TABLE IT_FIELDCAT ASSIGNING <LS_FIELDCAT>
000340 WITH KEY FIELDNAME = LS_SORT-FIELDNAME BINARY SEARCH.
000350 IF SY-SUBRC NE 0.
> MESSAGE X000(0K).
000370 ENDIF.
000380
000390 LS_SORT-SELTEXT = <LS_FIELDCAT>-SELTEXT.
i have just mentioned this part because when i checked the forum many people were getting such errors "MESSAGE_TYPE_X". This could also be one of the reasons. -
ALV + layout varient on selection screen
hiii
with ALV list i want to know with how to allow to put the layout on the selection screen and when user press F4 he will be able to use the list of layout he has save on the ALV output
Note for the layout button to appear i had to activate shown below:
i_save = c_x
please give me sample code where user can choose layout on selection screen and this layout will be used to display on ALVHi,
Please refer the code below for layout variants :
DATA: gt_rsparams TYPE TABLE OF rsparams.
* Data for ALV variant
DATA gv_repname LIKE sy-repid.
DATA gv_x_variant LIKE disvariant.
DATA gv_exit(1) TYPE c.
DATA gv_save(1) TYPE c.
DATA gv_variant LIKE disvariant.
PARAMETERS: sp_vari LIKE disvariant-variant. "Dispaly Variant
INITIALIZATION.
gv_repname = sy-repid.
REFRESH : gt_glacct,
gr_rcomp,
gt_output,
gt_fieldcat,
gt_sort.
* Initialize ALV Layout variant
PERFORM f_initialize_variant.
FORM f_initialize_variant .
CLEAR gv_variant.
gv_save = 'X'.
gv_variant-report = gv_repname.
gv_x_variant = gv_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = gv_save
CHANGING
cs_variant = gv_x_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
sp_vari = gv_x_variant-variant.
ENDIF.
ENDFORM. " f_initialize_variant
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sp_vari.
PERFORM f_f4_for_variant.
FORM f_f4_for_variant .
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = gv_variant
i_save = gv_save
IMPORTING
e_exit = gv_exit
es_variant = gv_x_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 gv_exit = space.
sp_vari = gv_x_variant-variant.
ENDIF.
ENDIF.
ENDFORM. " f_f4_for_variant
AT SELECTION-SCREEN.
* Validating selection screen fields
PERFORM f_at_selection_screen.
FORM f_at_selection_screen .
* ALV Layout variant
IF NOT sp_vari IS INITIAL.
MOVE gv_variant TO gv_x_variant.
MOVE sp_vari TO gv_x_variant-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = gv_save
CHANGING
cs_variant = gv_x_variant.
gv_variant = gv_x_variant.
ELSE.
PERFORM f_initialize_variant.
ENDIF.
FORM f_initialize_variant .
CLEAR gv_variant.
gv_save = 'X'.
gv_variant-report = gv_repname.
gv_x_variant = gv_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = gv_save
CHANGING
cs_variant = gv_x_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
sp_vari = gv_x_variant-variant.
ENDIF.
ENDFORM. " f_initialize_variant
Thanks,
Sriram POnna. -
How to pass layout variant in background job?
Dear Gurus,
I have set layout variant as PARAMETERS in my program.
The report will be executed successfully in front-end, but if I set it in background , it will pop up error msg: Program (IS_VARIANT-REPORT) not specified.
But the alv function I have check...
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_BYPASSING_BUFFER = 'X'
I_CALLBACK_PROGRAM = W_REPID
I_GRID_TITLE = V_GRID_TITLE
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
* I_CALLBACK_USER_COMMAND = 'FORM_USER_COMMAND'
* I_STRUCTURE_NAME = 'ZSDS0005'
I_SAVE = 'A'
IS_LAYOUT = I_LAYOUT
* IS_VARIANT = STRU_DISVAR
IS_VARIANT = DEF_VARIANTE_F4
IT_FIELDCAT = I_FIELDCAT_ALV[]
IT_SORT = XT_SORT[]
TABLES
T_OUTTAB = IT_OUT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
JamieThank you so much, but the sample code have one bug, and I have already modified the code.
The variant will be caught only after clicking F4 list, if there's already one default variant, system will ignore it.
AT SELECTION-SCREEN.
* Validating selection screen fields
PERFORM F_AT_SELECTION_SCREEN.
*& Form f_at_selection_screen
* text
* --> p1 text
* <-- p2 text
FORM F_AT_SELECTION_SCREEN .
* ALV Layout variant
IF NOT P_VARI IS INITIAL.
MOVE GX_VARIANT TO G_VARIANT.
MOVE P_VARI TO G_VARIANT-VARIANT.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
I_SAVE = 'A'
CHANGING
CS_VARIANT = G_VARIANT.
GX_VARIANT = G_VARIANT.
ELSE.
PERFORM F_INITIALIZE_VARIANT.
ENDIF.
ENDFORM. " f_at_selection_screen
*& Form f_initialize_variant
* text
* --> p1 text
* <-- p2 text
FORM F_INITIALIZE_VARIANT .
* CLEAR DEF_VARIANTE_F4.
* gv_save = 'X'.
GX_VARIANT-REPORT = SY-REPID.
* DEF_VARIANTE = DEF_VARIANTE_F4.
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.
ENDFORM. " f_initialize_variant -
Hi,
I need to attach an ALV Layout Variant to a Transport Request. Is there any program with which I can do this?
Thanks,
AbhishekHi
http://help.sap.com/saphelp_sm32/helpdata/en/bd/839d37664e4d45e10000009b38f8cf/content.htm
Page no : 35.
http://help.sap.com/printdocu/core/print46b/en/data/en/pdf/cagtflv.pdf
Regards,
Sravanthi -
Hello Every1,
Please let me know how to read the ALV layout variant contents . I need to find the list fields defined in the layout varint.
Thanks in advance.
Regards,
Siva.Hi ,
try these Fm
PLM_DMS_46_LAYER
PORTAL_ALV_PLM_VARIANT_DB
PLM_DMS_GENERAL
PORTAL_ALV_PLM_VARIANT
RMLT0
RM_ALV_FILL_VARIANT
SALV ABAP List viewer
REUSE_ALV_VARIANT_ALL_MAINTAIN Maintain all disp
REUSE_ALV_VARIANT_DEFAULT_GET Read default layo
REUSE_ALV_VARIANT_EXISTENCE Checks whether a
REUSE_ALV_VARIANT_F4 Display variant s
REUSE_ALV_VARIANT_MAINTAIN Definition of a l
REUSE_ALV_VARIANT_SAVE
REUSE_ALV_VARIANT_SELECT Read a layout -
Download alv report using layout variant in background
Hi All,
I want to download an Alv report using layout varaint in background job.
can any one please help me.
i.e...
I am facing a problem in downloading a text file to the Application server.
My requirement is, when the user downloads a file with the layout variant, the file should have only the columns which was selected in the variant.
Will rewards to helpfull ans
regards
Chetanhey seshu,
I am facing a problem in downloading a text file to the Application server.
My requirement is, when the user downloads a file with the layout variant, the file should have only the columns which was selected in the variant. -
DB Table for Layout Variant in ALV report
Please help me by providing the table name which will get an entry when we save Layout Variant in ALV(OO ALV grid) output.
Hi,
I have seen the table LTDX which is giving me the Variant names for a particular program. Hope this will help you.
Database table is LTDX
Database view is V_LTDX.
Regards,
Venaktesh -
Issues in Change layout Variant of ALV grid
Hi all,
I am using a ALV gird to display the data with some table column. I am able to save/ choose the Layout variant. I choose the existing layout varaint it works fine but when I change the column fields display from selected layout then it will immidiately looks fine, but if I perform some event, it goes to the initial stage of the choosed layout varaint.
I can solve this issue if I clear the Variant from the is_variant (of set_table_for_first_display method). So if I can find the fieldcatalog for layout Variant, then it will solved very easily.
Please suggest, if you have any idea on this.
Thanks,
Sanket SethiI got the solution. You can find the Variant field catalog by using Function module 'LVC_VARIANT_SELECT'. You can set the dialog box based on your requirements as well. So closing this thread. Thanks..
-
Issue in setting layout variant in ALV tables
Hi,
I have 2 ALV’s displaying in a view, 1’st is a header data & 2’nd Item data.
Based on the row selection in the Header ALV, the data is determined and displayed in the 2’nd ALV i.e., the Item data.
Now the 2’nd ALV (Item data) can contain 20 columns so based on certain requirement I want to save a layout variant with only 10 Columns for display in the 2’nd ALV.
But the issue what is happening is once I change my row selection in the 1’st ALV (Header data) the layout in the second ALV is refreshing back to the 20 fields EVEN though the name of the variant layout still displays the one I saved earlier.
I have searched the SCN for this issue and found http://scn.sap.com/thread/1986147, but it does NOT work.
Could anyone please suggest a solution.
Thanks & Regards,
DivakerHi Katrice,
Thank you for the reply and the links, I will go through them, but please find below the code that I presently have in place, could you please advise if there is anything missing or wrong in here.
Thanks & Regards,
Divaker
lo_cmp_usage = wd_this->wd_cpuse_pwq_alv( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
lo_interfacecontroller = wd_this->wd_cpifc_pwq_alv( ).
* enable column adjustment
lv_value = lo_interfacecontroller->get_model( ).
*-- Get the API reference
lo_api_interfacecontroller = lo_interfacecontroller->wd_get_api( ).
CALL METHOD lo_api_interfacecontroller->get_personalization_manager
RECEIVING
pers_manager = lo_pers.
IF lo_pers IS NOT INITIAL.
CALL METHOD lo_pers->get_variants
RECEIVING
variants = lt_var.
ENDIF.
IF lt_var IS NOT INITIAL.
READ TABLE lt_var INTO ls_var INDEX 1.
IF sy-subrc = 0.
ls_config_key-config_id = ls_var-config_id.
ls_config_key-config_type = ls_var-config_type.
ls_config_key-config_var = ls_var-config_var.
ENDIF.
TRY.
CALL METHOD lo_pers->set_default_variant
EXPORTING
config_key = ls_config_key
set = abap_true.
CATCH cx_wd_personalization .
ENDTRY.
CALL METHOD lo_pers->load_config_by_key
EXPORTING
config_key = ls_config_key
fetch_default_variant = abap_true.
ENDIF. -
Reg. copying Layout Variants from 1 ALV pgm to another
Hi Friends,
I am currently copying an ALV program Ztest1 to ztest2 through ztest5. While doing so I want the LAYOUT variants that are available for ztest1 also to be copied to these other programs.
All I am aware is that the table LTDX stores all the layout variants for a particular program.
Could anybody provide me the right inputs on this.
Thanks in Advance.
Rgrds,
Gayathri N.I took this approach and it worked for me:
1) Change your program so that everytime an ALV function is called it is using the original program name in the variant declaration, ensure you keep the original code commented out, you will need to put it back later. Examples:
FORM variant_init USING varname TYPE slis_vari.
CLEAR g_variant.
g_variant-report = g_repid.
g_variant-report = 'ORIGINAL_PROGRAM_NAME'.
FORM f4_for_variant.
g_variant-report = sy-repid.
g_variant-report = ORIGINAL_PROGRAM_NAME.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
FORM check_variant.
IF NOT p_vari IS INITIAL.
g_variant-report = sy-repid.
g_variant-report = ORIGINAL_PROGRAM_NAME.
g_variant-variant = p_vari.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
2) Display function lt_variant_save via SE37, set a breakpoint at the first executable line:
perform variant_save tables it_fieldcat
4) Run your program with the layout variant you wish to copy.
5) Hit Save Variant. You are now in debug mode.
6) Enter variable CS_VARIANT-REPORT in the variables 1 panel.
7) Double-click on CS_VARIANT-REPORT.
8) Hit the Change Field Content button
9) Change the value to the name of your new program, then hit Enter.
10) Hit Execute (F8). You have now saved the variant under your new program name.
11) Exit and rerun your program as necessary for as many variants as you want to copy
12) Change your program back to using sy-repid (or whatever else it was referencing) wherever you changed it in step 1.
13) The variants have now been copied and you can run your program with the new variants. -
Get layout variant created in ALV in WDA
Dear all,
I created some layout variant in my ALV table in my WD abap
I need to create an abap report to send the ALV table by mail, and I need to retrieve the layout variant created on the WD and use it in my abap report.
I found the table WDY_CONF_USER and WDY_CONF_USERT but I don't know where are stored the details of the columns of the variant.
These 2 tables are not available by SE16 or SM30.
Do you know if I can use some method of class or something else ?
Thanks for your quick help.
VéroniqueHi,
Before the call to method set_table_for_first_display, populate
wa_variant-report = sy-repid.
Best regards,
Prashant
Maybe you are looking for
-
Address Book and Mail - Using Groups for e-mail
I've noticed something strange about Mail and Address Book in Tiger: I created a new Group in Address Book. The Group contains people who are involved in a project. I have names, home addresses and phone numbers for eveyone, but a few people do not h
-
ok so every time i try to download an app it wont load it just says waiting. I have tried shutting off my phone and restarting it, ive tried to delete the app and download again (no luck), ive also tried backing up my phone as well. It seems like e
-
I flashed the BIOS on my 875P NEO-FIS2R (old 1.x version Neo) to 2.0 and now all my games have significatly lower frame rates. I've tried installing the latest drivers for EVERYTHING in my computer and nothing seems to help. Is there a setting in t
-
How to Cancel restrictions of Dates input box must input?
when I Create a activity , On tab Dates , I must Input "From to" "End to", This Type date is Configurated use SPRO. If I do not Input ,It will gives Error messages. How can i cancel this restrictions?
-
Sim not valid for unlocked phone
I brought my unlocked iPhone 6(at&t) to South Korea. However, my phone did not work (sim not valid sign shows up every time) I tried all the ways to fix it, but It did not work. I think my iPhone is a defective one. Do I have to exchange my iPhone?