Save layout Button in Object Oriented ALV
Hi gurus,
I am working on Object Oriented ALV. I am facing one problem when the outpput get shown on the screen the save layout and select layout buttons are not appearing on the application toolbar of alv.
TRY .
cl_salv_table=>factory( IMPORTING r_salv_table = g_alv_out
CHANGING t_table = i_alv ).
Set status GUI
g_alv_out->set_screen_status(
pfstatus = 'STANDARD'
report = sy-repid
set_functions = g_alv_out->C_FUNCTIONS_ALL ).
g_columns = g_alv_out->get_columns( ).
Set new description texts for columns
PERFORM f_set_column_name USING:
'LTEXT' text-001 text-001 text-001 space,
'NAME1' text-002 text-002 text-002 space,
'TXZ01' text-003 text-007 text-007 space,
'KWERT' text-004 text-004 text-004 space,
'WEMNG' text-005 text-010 text-011 space,
'BALNC' text-012 text-013 text-014 space,
'AFNAM' text-006 text-008 text-009 space.
PERFORM f_set_column_name USING 'WEMNG'
space space space 'WAERS'.
PERFORM f_set_column_name USING 'KWERT'
space space space 'WAERS'.
Set column as hotspot
g_column ?= g_columns->get_column( 'EBELN' ).
g_column->set_cell_type( g_column->hotspot ).
g_events = g_alv_out->get_event( ).
CREATE OBJECT gr_events .
SET HANDLER gr_events->on_double_click FOR g_events.
Display report
g_alv_out->display( ).
CATCH cx_salv_msg.
ENDTRY.
where in the Status STANDARD I have entered all the buttons includeing these two buttons
Can you please Help me in solving this issue.
thanks,
Vinod.
Edited by: vinod parhad on Jul 2, 2010 1:35 PM
data: gr_layout type ref to cl_salv_layout,
gr_alv type ref to cl_salv_table,
gs_key type salv_s_layout_key,
* in your SALV routine.... after FACTORY call
gs_key-report = sy-repid.
* User can save layout.
gr_layout = gr_alv->get_layout( ). "layouts
gr_layout->set_key( gs_key ). "Pass Program Name
gr_layout->set_save_restriction( cl_salv_layout=>restrict_none ). "User can save
See also Rich Heilman's excellent tutorials on SALV by searching for SALV Tutorial,
See also programs named: SALV* for demonstrations of SALV outputs and how to code.
Edited by: BreakPoint on Jul 2, 2010 1:46 PM add references for tutorials
Similar Messages
-
'Save layout' button missing in the ALV report layout screen
Hi Friends,
In one of our ALV report the 'save layout' button is missing in the report output screen.i have used the OO concept for creating the ALV output and not the function module.I have attached the code below used for creating the ALV grid.
CREATE OBJECT alv_grid
EXPORTING i_parent = g_container_2.
CALL METHOD alv_grid->set_table_for_first_display
exporting
i_structure_name = 'PA0002'
is_layout =
CHANGING
it_outtab = gt_outtab
it_fieldcatalog = wa_fieldcat.
But i'm not able to trace why the 'save layout' button is missing in the output.Can anyone of you help me in sorting out this problem.
Thanks and Regards,
Vadivel.Pass <u><i><b>A to I_SAVE</b></i></u> parameter. That will give the options to the user to save the layout outs.
I_SAVE = SPACE
Layouts cannot be saved.
I_SAVE = 'U'
Only user-defined layouts can be saved.
I_SAVE = 'X'
Only global layouts can be saved.
I_SAVE = 'A'
Both user-defined and global layouts can be saved.
Regards,
Ravi
Note : Please mark all the helpful answers
Message was edited by: Ravikumar Allampallam -
How to add 'Save Layout' button when use OO ALV?
thx
Hi,
Try passing this parameter :
<b>
wa_variant-report = sy-repid.</b>
*-- Display Report
CALL METHOD o_alvgrid->set_table_for_first_display
EXPORTING
it_toolbar_excluding = lt_excl_func
<b> is_variant = wa_variant</b>
i_save = c_a
is_layout = p_layout
CHANGING
it_outtab = p_output[]
it_fieldcatalog = p_fieldcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE i050 WITH text-004. " Error in Displaying
LEAVE LIST-PROCESSING.
ENDIF. -
'Reuse_alv_grid_display' - how to enable save layout button
Hi,
am not getting the option 'save layout' button in my ALV. I have tried the following code.
s_layout-colwidth_optimize = c_on.
s_layout-zebra = c_on.
s_variant-report = sy-repid.
s_variant-username = sy-uname.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = s_layout
it_fieldcat = t_fieldcat
is_variant = s_variant
is_save = 'A'
TABLES
t_outtab = rt_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
Please help.Dear Arvind,
If you are using "REUSE_ALV_GRID_DISPLAY" and not passing "I_CALLBACK_PROGRAM = SY-REPID", You will not be able to save layout.
So I request all to pass following parameters to save layout.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
I_SAVE = 'X'
IS_VARIANT = 'X'
TABLES
T_OUTTAB = IT_DATA
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
With Regards,
Tushar Trivedi. -
Field symbols in Object Oriented ALV
Hi Friends....Can somebody explain me what is the significance of field symbols in OO ALV. Why it is assigned to Field catalog. Also explain me the basic steps to do Object Oriented ALV. Thanks in advance...
Hi Satyesh,
Field symbols are symbolic names to which a memory area can be assigned during program runtime. A field symbol can be used instead of data objects at operand positions of statements.
Please go through this following code. This uses field symbols for OO ALV.
LCL_TABLE_DISPLAY DEFINITION
CLASS lcl_table_display DEFINITION.
PUBLIC SECTION.
TYPE-POOLS: abap, slis.
CLASS-METHODS: display_list IMPORTING in_data TYPE STANDARD TABLE,
display_grid IMPORTING in_data TYPE STANDARD TABLE.
METHODS: constructor IMPORTING in_data TYPE STANDARD TABLE
EXCEPTIONS casting_error
empty_fieldcat.
METHODS: output_list,
output_grid.
METHODS: set_table_name IMPORTING in_tabname TYPE any,
set_alv_title IMPORTING in_title TYPE any,
set_alv_settings IMPORTING in_settings TYPE any,
set_alv_layout IMPORTING in_layout TYPE any,
set_alv_event IMPORTING in_name TYPE any
in_form TYPE any.
PRIVATE SECTION.
CLASS-DATA: g_table_object TYPE REF TO lcl_table_display.
TYPES: BEGIN OF ty_defin,
fieldname TYPE fieldname,
ref_tabname TYPE tabname,
ref_fieldname TYPE fieldname,
END OF ty_defin.
DATA: g_repid TYPE repid,
g_struc TYPE tabname,
g_table TYPE tabname.
DATA: gt_data TYPE REF TO data.
DATA: g_title TYPE lvc_title,
gt_fcat TYPE slis_t_fieldcat_alv,
gs_sett TYPE lvc_s_glay,
gs_layo TYPE slis_layout_alv,
gt_evnt TYPE slis_t_event.
DATA: gt_defin TYPE TABLE OF ty_defin,
g_level TYPE tabname.
METHODS: output_table IMPORTING data TYPE REF TO data
mode TYPE c,
fill_fieldcat IMPORTING repid TYPE repid
struc TYPE tabname
CHANGING fcat TYPE slis_t_fieldcat_alv
EXCEPTIONS no_definition,
get_definition IMPORTING repid TYPE repid
struc TYPE tabname
CHANGING abap TYPE rsfb_source,
recursive_definition IMPORTING repid TYPE repid
CHANGING abap TYPE rsfb_source,
map_structure IMPORTING source TYPE any
CHANGING destin TYPE any.
ENDCLASS.
LCL_TABLE_DISPLAY IMPLEMENTATION
CLASS lcl_table_display IMPLEMENTATION.
Display table in ALV list
METHOD display_list.
IF NOT g_table_object IS INITIAL.
FREE: g_table_object.
ENDIF.
CREATE OBJECT g_table_object EXPORTING in_data = in_data.
CALL METHOD g_table_object->output_list.
ENDMETHOD.
Display table in ALV grid
METHOD display_grid.
IF NOT g_table_object IS INITIAL.
FREE: g_table_object.
ENDIF.
CREATE OBJECT g_table_object EXPORTING in_data = in_data.
CALL METHOD g_table_object->output_grid.
ENDMETHOD.
Create table display
METHOD constructor.
DATA: ls_data TYPE REF TO data.
DATA: ob_desc TYPE REF TO cl_abap_structdescr.
DATA: l_absol TYPE char200,
l_repid TYPE repid,
l_struc TYPE tabname.
FIELD-SYMBOLS: <table> TYPE STANDARD TABLE,
<struc> TYPE ANY.
Get data and store it into attribute
CREATE DATA me->gt_data LIKE in_data.
ASSIGN me->gt_data->* TO <table>.
<table> = in_data.
Get global data definition
CREATE DATA ls_data LIKE LINE OF <table>.
ASSIGN ls_data->* TO <struc>.
CATCH SYSTEM-EXCEPTIONS assign_casting_illegal_cast = 1.
ob_desc ?= cl_abap_typedescr=>describe_by_data( <struc> ).
ENDCATCH.
IF sy-subrc = 1.
RAISE casting_error.
ENDIF.
Get program name and main type used to define table
l_absol = ob_desc->absolute_name.
SPLIT l_absol AT '\TYPE=' INTO l_repid l_struc.
SHIFT l_repid UP TO '='.
SHIFT l_repid.
CHECK l_struc NP '%_*'.
IF me->g_repid NE l_repid
OR me->g_struc NE l_struc.
Set attributes
me->g_repid = l_repid.
me->g_struc = l_struc.
me->g_table = l_struc.
REPLACE 'TY' WITH 'WT' INTO me->g_table.
Field catalog
CALL METHOD fill_fieldcat EXPORTING repid = l_repid
struc = l_struc
CHANGING fcat = me->gt_fcat.
IF me->gt_fcat IS INITIAL.
RAISE empty_fieldcat.
ENDIF.
ENDIF.
ENDMETHOD.
Output list
METHOD output_list.
CALL METHOD output_table EXPORTING data = me->gt_data
mode = 'L'.
ENDMETHOD.
Output grid
METHOD output_grid.
CALL METHOD output_table EXPORTING data = me->gt_data
mode = 'G'.
ENDMETHOD.
Output table
METHOD output_table.
DATA: ls_vari TYPE disvariant.
FIELD-SYMBOLS: <table> TYPE STANDARD TABLE.
ASSIGN me->gt_data->* TO <table>.
Get default user variant
ls_vari-report = me->g_repid.
ls_vari-username = sy-uname.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = 'U'
CHANGING
cs_variant = ls_vari
EXCEPTIONS
OTHERS = 0.
Display table contents
IF mode = 'G'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = me->g_repid
i_grid_title = me->g_title
i_grid_settings = me->gs_sett
is_layout = me->gs_layo
it_fieldcat = me->gt_fcat
i_save = 'U'
is_variant = ls_vari
it_events = me->gt_evnt
TABLES
t_outtab = <table>
EXCEPTIONS
OTHERS = 0.
ELSE.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = me->g_repid
is_layout = me->gs_layo
it_fieldcat = me->gt_fcat
i_save = 'U'
is_variant = ls_vari
it_events = me->gt_evnt
TABLES
t_outtab = <table>
EXCEPTIONS
OTHERS = 0.
ENDIF.
ENDMETHOD.
Fill field catalog
METHOD fill_fieldcat.
DATA: lt_abap TYPE TABLE OF rssource.
DATA: ls_defin TYPE ty_defin.
DATA: lt_dfies TYPE TABLE OF dfies,
ls_dfies TYPE dfies,
ls_dd04v TYPE dd04v,
ls_dd01v TYPE dd01v,
l_flong TYPE dfies-lfieldname,
l_dname TYPE dfies-domname.
DATA: ls_fcat TYPE slis_fieldcat_alv,
ls_fcat2 TYPE slis_fieldcat_alv.
DATA: l_index TYPE i,
l_nbfld TYPE i.
FREE: me->gt_defin.
Process data definition
CALL METHOD get_definition EXPORTING repid = repid
struc = struc
CHANGING abap = lt_abap.
Process sub levels if required
CALL METHOD recursive_definition EXPORTING repid = repid
CHANGING abap = lt_abap.
IF me->gt_defin IS INITIAL.
RAISE no_definition.
ENDIF.
LOOP AT me->gt_defin INTO ls_defin.
CLEAR: ls_fcat.
MOVE-CORRESPONDING ls_defin TO ls_fcat.
Retrieve info about this field
FREE: ls_dfies, ls_dd04v, ls_dd01v, l_dname.
l_flong = ls_fcat-ref_fieldname.
SET LOCALE LANGUAGE 'E'.
TRANSLATE: ls_fcat-ref_tabname TO UPPER CASE,
ls_fcat-ref_fieldname TO UPPER CASE,
l_flong TO UPPER CASE.
IF NOT ls_fcat-ref_tabname IS INITIAL.
Try to get info about field in table
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = ls_fcat-ref_tabname
fieldname = ls_fcat-ref_fieldname
lfieldname = l_flong
IMPORTING
dfies_wa = ls_dfies
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc = 0.
MOVE-CORRESPONDING ls_dfies TO ls_fcat.
ls_fcat-fieldname = ls_defin-fieldname.
MOVE: ls_dfies-keyflag TO ls_fcat-key,
ls_dfies-scrtext_m TO ls_fcat-seltext_l,
ls_dfies-domname TO l_dname.
ENDIF.
ELSE.
Try to get info about structure
ls_defin-ref_tabname = ls_defin-ref_fieldname.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = ls_defin-ref_tabname
TABLES
dfies_tab = lt_dfies
EXCEPTIONS
OTHERS = 0.
IF NOT lt_dfies IS INITIAL.
Process fields of this structure
LOOP AT lt_dfies INTO ls_dfies.
CLEAR: ls_fcat.
MOVE-CORRESPONDING ls_dfies TO ls_fcat.
CONCATENATE ls_defin-fieldname ls_fcat-fieldname
INTO ls_fcat-fieldname
SEPARATED BY '-'.
MOVE ls_dfies-keyflag TO ls_fcat-key.
MOVE ls_dfies-scrtext_m TO ls_fcat-seltext_l.
ls_fcat-tabname = me->g_table.
CLEAR: ls_fcat-col_pos,
ls_fcat-offset.
IF ls_fcat-ref_tabname IS INITIAL.
ls_fcat-ddictxt = 'L'.
ENDIF.
Display Yes/No fields as checkboxes
IF ls_dfies-domname = 'XFELD'.
ls_fcat-checkbox = 'X'.
ENDIF.
Add field to field catalog
APPEND ls_fcat TO fcat.
ENDLOOP.
ELSE.
Try to get info about data element
CALL FUNCTION 'DDIF_DTEL_GET'
EXPORTING
name = ls_fcat-ref_fieldname
langu = sy-langu
IMPORTING
dd04v_wa = ls_dd04v
EXCEPTIONS
illegal_input = 1
OTHERS = 2.
IF sy-subrc = 0.
MOVE-CORRESPONDING ls_dd04v TO ls_fcat.
MOVE: ls_dd04v-scrtext_m TO ls_fcat-seltext_l,
ls_dd04v-domname TO l_dname.
ELSE.
Finally try to get info about domain
CALL FUNCTION 'DDIF_DOMA_GET'
EXPORTING
name = ls_fcat-ref_fieldname
langu = sy-langu
IMPORTING
dd01v_wa = ls_dd01v
EXCEPTIONS
illegal_input = 1
OTHERS = 2.
IF sy-subrc = 0.
MOVE-CORRESPONDING ls_dd01v TO ls_fcat.
MOVE: ls_dd01v-ddtext TO ls_fcat-seltext_l,
ls_dd01v-domname TO l_dname.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
Table name must be internal table containing data
ls_fcat-tabname = g_table.
No offset
CLEAR: ls_fcat-offset.
Default text is stored in long text
IF ls_fcat-ref_tabname IS INITIAL.
ls_fcat-ddictxt = 'L'.
ENDIF.
Display Yes/No fields as checkboxes
IF l_dname = 'XFELD'.
ls_fcat-checkbox = 'X'.
ENDIF.
Add field to field catalog
APPEND ls_fcat TO fcat.
ENDLOOP.
Link between fields
DESCRIBE TABLE fcat LINES l_nbfld.
LOOP AT fcat INTO ls_fcat.
IF sy-tabix NE l_nbfld.
l_index = sy-tabix + 1.
READ TABLE fcat INTO ls_fcat2 INDEX l_index.
IF sy-subrc = 0.
IF ls_fcat-datatype = 'CURR'.
Currency unit
IF ls_fcat2-datatype = 'CUKY'.
ls_fcat-cfieldname = ls_fcat2-fieldname.
ls_fcat-ctabname = ls_fcat2-tabname.
MODIFY fcat FROM ls_fcat.
ELSE.
LOOP AT fcat INTO ls_fcat2
FROM l_index
WHERE datatype = 'CUKY'.
First currency unit after field
ls_fcat-cfieldname = ls_fcat2-fieldname.
ls_fcat-ctabname = ls_fcat2-tabname.
MODIFY fcat FROM ls_fcat.
EXIT.
ENDLOOP.
IF sy-subrc NE 0.
No currency unit after field, try before
READ TABLE fcat INTO ls_fcat2
WITH KEY datatype = 'CUKY'.
IF sy-subrc = 0.
ls_fcat-cfieldname = ls_fcat2-fieldname.
ls_fcat-ctabname = ls_fcat2-tabname.
MODIFY fcat FROM ls_fcat.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
IF ls_fcat-datatype = 'QUAN'.
Quantity unit
IF ls_fcat2-datatype = 'UNIT'.
ls_fcat-cfieldname = ls_fcat2-fieldname.
ls_fcat-ctabname = ls_fcat2-tabname.
MODIFY fcat FROM ls_fcat.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
Get definition of type from code source
METHOD get_definition.
DATA: l_strng TYPE rssource,
ls_abap TYPE rssource,
l_fdpos TYPE i,
l_first TYPE i,
l_lastr TYPE i.
DATA: lt_incl TYPE TABLE OF repid,
ls_incl TYPE repid.
Get program code
READ REPORT repid INTO abap.
CHECK sy-subrc EQ 0.
Get first line of definition
CONCATENATE 'BEGIN OF' struc INTO l_strng
SEPARATED BY space.
LOOP AT abap INTO ls_abap.
IF ls_abap CS l_strng.
l_fdpos = strlen( l_strng ) + sy-fdpos.
IF ls_abap+l_fdpos(1) CA ', "'.
l_first = sy-tabix.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
IF l_first IS INITIAL.
Table is defined in an include
CALL FUNCTION 'RS_GET_ALL_INCLUDES'
EXPORTING
program = repid
TABLES
includetab = lt_incl
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
LOOP AT lt_incl INTO ls_incl.
Try to find definition in this include
READ REPORT ls_incl INTO abap.
LOOP AT abap INTO ls_abap.
IF ls_abap CS l_strng.
l_fdpos = strlen( l_strng ) + sy-fdpos.
IF ls_abap+l_fdpos(1) CA ',. "'.
l_first = sy-tabix.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
IF NOT l_first IS INITIAL.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
Get last line of definition
CONCATENATE 'END OF' struc INTO l_strng
SEPARATED BY space.
LOOP AT abap INTO ls_abap.
IF ls_abap CS l_strng.
l_fdpos = strlen( l_strng ) + sy-fdpos.
IF ls_abap+l_fdpos(1) CA ',. "'.
l_lastr = sy-tabix - l_first.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
Keep only relevant code lines
IF l_first LE 0
OR l_lastr LE 0.
REFRESH abap.
ELSE.
DELETE abap TO l_first.
DELETE abap FROM l_lastr.
ENDIF.
ENDMETHOD.
Get definition of type recursively
METHOD recursive_definition.
DATA: lt_token TYPE TABLE OF stokex,
ls_token TYPE stokex,
lt_state TYPE TABLE OF sstmnt,
ls_state TYPE sstmnt.
DATA: ls_defin TYPE ty_defin,
l_reffld TYPE fieldname.
DATA: lt_recu TYPE TABLE OF rssource.
Retrieve tokens
SCAN ABAP-SOURCE abap
TOKENS INTO lt_token
STATEMENTS INTO lt_state.
LOOP AT lt_state INTO ls_state.
CLEAR: ls_defin.
Field name
READ TABLE lt_token INTO ls_token
INDEX ls_state-from.
ls_defin-fieldname = ls_token-str.
Reference type
READ TABLE lt_token INTO ls_token
INDEX ls_state-to.
l_reffld = ls_token-str.
Check if this type is defined in program
FREE: lt_recu.
CALL METHOD get_definition EXPORTING repid = repid
struc = l_reffld
CHANGING abap = lt_recu.
IF lt_recu IS INITIAL.
IF NOT g_level IS INITIAL.
CONCATENATE g_level ls_defin-fieldname INTO ls_defin-fieldname
SEPARATED BY '-'.
CONDENSE ls_defin-fieldname.
ENDIF.
IF l_reffld CS '-'.
SPLIT l_reffld AT '-'
INTO ls_defin-ref_tabname
ls_defin-ref_fieldname.
IF ls_defin-ref_tabname = 'SY'.
ls_defin-ref_tabname = 'SYST'.
ENDIF.
ELSE.
ls_defin-ref_fieldname = ls_token-str.
ENDIF.
APPEND ls_defin TO me->gt_defin.
ELSE.
Process sub levels
IF me->g_level IS INITIAL.
me->g_level = ls_defin-fieldname.
ELSE.
CONCATENATE me->g_level ls_defin-fieldname INTO me->g_level
SEPARATED BY '-'.
ENDIF.
CALL METHOD recursive_definition EXPORTING repid = repid
CHANGING abap = lt_recu.
IF me->g_level CS '-'.
SHIFT me->g_level RIGHT UP TO '-'.
SHIFT me->g_level RIGHT.
SHIFT me->g_level LEFT DELETING LEADING space.
ELSE.
CLEAR: me->g_level.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
Set table name
METHOD set_table_name.
me->g_table = in_tabname.
ENDMETHOD.
Set title
METHOD set_alv_title.
me->g_title = in_title.
ENDMETHOD.
Set settings
METHOD set_alv_settings.
CALL METHOD map_structure EXPORTING source = in_settings
CHANGING destin = me->gs_sett.
ENDMETHOD.
Set layout
METHOD set_alv_layout.
CALL METHOD map_structure EXPORTING source = in_layout
CHANGING destin = me->gs_layo.
ENDMETHOD.
Add event
METHOD set_alv_event.
DATA: ls_evnt TYPE slis_alv_event.
ls_evnt-name = in_name.
ls_evnt-form = in_form.
COLLECT ls_evnt INTO gt_evnt.
ENDMETHOD.
Map fields from incoming structure into attribute
METHOD map_structure.
DATA: ob_desc TYPE REF TO cl_abap_structdescr,
ls_compo TYPE abap_compdescr.
FIELD-SYMBOLS: <field> TYPE ANY,
<struc> TYPE ANY.
ob_desc ?= cl_abap_typedescr=>describe_by_data( destin ).
LOOP AT ob_desc->components INTO ls_compo.
ASSIGN COMPONENT ls_compo-name OF STRUCTURE source TO <field>.
IF <field> IS ASSIGNED.
ASSIGN COMPONENT ls_compo-name OF STRUCTURE destin TO <struc>.
CATCH SYSTEM-EXCEPTIONS conversion_errors = 1.
MOVE <field> TO <struc>.
ENDCATCH.
UNASSIGN <field>.
ENDIF.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
PLZ REWARD POINTS -
How to display horizontal line in top-of-page by using object oriented ALV?
How to display horizontal line in top-of-page by using object oriented ALV.
I am created top-of-page in object oriented alv.
But not be successes in showing horizontal line in it.
Can any one pls give solution for this..
Thanks and regards..Hi
Try like this
data: gt_list_top_of_page type slis_t_listheader. " Top of page text.
Initialization.
perform comment_build using gt_list_top_of_page[].
form top_of_page.
* Note to self: the gif must be loaded into transaction OAOR with
* classname 'PICTURES' AND TYPE 'OT' to work with ALV GRID Functions.
* I Loaded NOVALOGO2 into system.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
* I_LOGO = 'NOVALOGO2'
* i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = gt_list_top_of_page.
endform. " TOP_OF_PAGE
form comment_build using e04_lt_top_of_page type slis_t_listheader.
data: ls_line type slis_listheader.
clear ls_line.
ls_line-typ = 'A'.
ls_line-info = 'Special'(001).
fgrant = xgrant.
concatenate ls_line-info fgrant
'Stock Option Report to the board'(002)
into ls_line-info separated by space.
condense ls_line-info.
append ls_line to e04_lt_top_of_page.
endform. " COMMENT_BUILD
Use following syntex for footer print in alv:
* For End of Page
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
* For End of Report
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform.
check this link
http://abapprogramming.blogspot.com/
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5dc3e690-0201-0010-1ebf-b85b3bed962d
Changing width of a custom container dynamically
Display Page numbers in ALV
Insert picture in selection screen.
Logo in OO ALV Grid
Reward all helpfull answers
Regards
Pavan -
How to enable the SAVE LAYOUT button?
When using CALL METHOD G_ALVGRID_HDR->SET_TABLE_FOR_FIRST_DISPLAY, how do I enable the SAVE LAYOUT push button?
It shows the Change layout button but does not allow me to save the layout as the SAVE LAYOUT button is not available.
I am using the following code but it does not show the SAVE LAYOUT button.
CALL METHOD G_ALVGRID_HDR->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_SAVE = L_SAVE
IS_VARIANT = LS_VARIANT
IS_LAYOUT = LS_LAYOUT
IS_PRINT = LS_PRINT
IT_TOOLBAR_EXCLUDING = I_EXCLUDE
CHANGING
IT_SORT = I_SORT_HDR
IT_OUTTAB = I_OUTTAB_HDR[]
IT_FIELDCATALOG = I_FCAT_HDR
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 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.
Pl advise.
Thanks,
Venpass the variant and enable is_save = 'A'.
in my case I had to upgrade the gui also. -
HOw to make an Object oriented alv respond to double click
Hi all,
HOw to make an Object oriented alv respond to double click.SAmple code will be helpful.
Thanks in advance,
Alex.Hi,
1. Create a Control (for Custom and Split Containers only)
2. Instantiate a Container Object (in case of Custom and Split Containers, specify the control which is created by us in Screen painter) CREATE OBJECT
3. Instantiate an Object of the kind of report that has to be displayed (List, Grid or Tree). CREATE OBJECT . Here we need to specify the Parent Container as the so that it sits in that container.
4. Call appropriate methods to display the report on the screen. CALL METHOD ->
DATA : g_dock TYPE REF TO cl_gui_docking_container,
g_split TYPE REF TO cl_gui_easy_splitter_container,
g_cont1 TYPE REF TO cl_gui_container,
g_cont2 TYPE REF TO cl_gui_container,
g_grid1 TYPE REF TO cl_gui_alv_grid,
g_grid2 TYPE REF TO cl_gui_alv_grid.
i_mara is an internal table of structure MARA
SELECT * FROM mara INTO TABLE i_mara.
i_kna1 is an internal table of structure KNA1
SELECT * FROM kna1 INTO TABLE i_kna1.
To create an Object of type Docking Container
CREATE OBJECT g_dock
EXPORTING
side = cl_gui_docking_container=>dock_at_top
extension = 200 .
To Create an Object of Type Split Container. Here we can see that the Docking *Container Created above has been used as a parent .
CREATE OBJECT g_split
EXPORTING
parent = g_dock
orientation = 1 .
Easy Split container splits one Control into 2 manageable controls, each of them is used * to handle one GUI Container each
g_cont1 = g_split->top_left_container.
g_cont2 = g_split->bottom_right_container.
To Create an Object of type Grid . Here we can see that the Left Split Container * Created above has been used as a parent .
CREATE OBJECT g_grid1
EXPORTING
i_parent = g_cont1 .
To Create an Object of type Grid . Here we can see that the Right Split Container * Created above has been used as a parent .
CREATE OBJECT g_grid2
EXPORTING
i_parent = g_cont2 .
The method of Grid Control Object is used to display the Data.
CALL METHOD g_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'MARA'
CHANGING
it_outtab = i_mara[] .
The method of Grid Control Object is used to display the Data.
CALL METHOD g_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'KNA1'
CHANGING
it_outtab = i_kna1[] .
Regards
Hari -
How to capture index/row no of row in table using object oriented alv.
i have a table with many fields. i have an alv grid table displayed using object oriented alv. when i double click on a record, i call another screen. there i want to display the record number. eg, if i doubleclick on the third row, i will go to next screen and display 3 there.
please let me know how it is done as it is urgent.
thanks in advance.Hi,
Use the following code to get rowno.
CLASS lcl_grid_events DEFINITION DEFERRED.
DATA:
grid1_events TYPE REF TO lcl_grid_events.
CLASS lcl_grid_events DEFINITION.
PUBLIC SECTION.
METHODS:
dbclk
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no.
ENDCLASS. "lcl_grid_events DEFINITION
CLASS lcl_grid_events IMPLEMENTATION.
METHOD dbclk.
*access e_row variable, which contains the record no.
ENDMETHOD. "dbclk
ENDCLASS. "lcl_grid
write the following code after method call of set_table_for_first_display
CREATE OBJECT grid1_events.
SET HANDLER grid1_events->dbclk
FOR grid1.
reward point if useful. -
Interactive object oriented alv
hi friends,
i want interactive object oriented alv report. i want some example program for that.try like this
*& Report ZALV_OOP
REPORT zalv_oop.
CLASS lcl_event_handler DEFINITION
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*--Double-click control
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column es_row_no.
PRIVATE SECTION.
ENDCLASS. "lcl_event_handler DEFINITION
CLASS lcl_event_handler IMPLEMENTATION
CLASS lcl_event_handler IMPLEMENTATION .
*--Handle Double Click
METHOD handle_double_click .
PERFORM handle_double_click USING e_row e_column es_row_no .
ENDMETHOD . "handle_double_click
ENDCLASS . "lcl_event_handler IMPLEMENTATION
TABLES : mseg.
DATA : BEGIN OF itab OCCURS 0,
mblnr LIKE mseg-mblnr,
matnr LIKE mseg-matnr,
menge LIKE mseg-menge,
END OF itab.
DATA : gr_alvgrid TYPE REF TO cl_gui_alv_grid,
gr_ccontainer TYPE REF TO cl_gui_custom_container,
gt_fcat TYPE lvc_t_fcat,
gs_layo TYPE lvc_s_layo.
DATA gr_event_handler TYPE REF TO lcl_event_handler .
DATA : ok_code LIKE sy-ucomm.
DATA : t_mat LIKE mara-matnr.
DATA: variant TYPE disvariant.
SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_mblnr FOR mseg-mblnr.
SELECTION-SCREEN : END OF BLOCK blk1.
START-OF-SELECTION.
SET SCREEN 100.
CREATE OBJECT gr_event_handler .
PERFORM get_data.
PERFORM dis_data.
*& Form get_data
text
FORM get_data.
SELECT mblnr matnr menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab
WHERE mblnr IN s_mblnr.
variant-report = sy-repid.
variant-username = sy-uname.
ENDFORM. "get_data
*& Form dis_data
text
FORM dis_data.
IF gr_alvgrid IS INITIAL.
CREATE OBJECT gr_ccontainer
EXPORTING
container_name = 'CC_ALV'
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.
CREATE OBJECT gr_alvgrid
EXPORTING
i_parent = gr_ccontainer
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.
PERFORM create_fcat CHANGING gt_fcat.
PERFORM create_layout CHANGING gs_layo.
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
is_variant = variant
i_save = 'A'
is_layout = gs_layo
CHANGING
it_outtab = itab[]
it_fieldcatalog = gt_fcat
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 HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .
ENDIF.
ENDFORM. "dis_data
*& Form create_fcat
text
<--P_GT_FCAT text
FORM create_fcat CHANGING pt_fcat TYPE lvc_t_fcat.
DATA : ls_fcat TYPE lvc_s_fcat.
ls_fcat-fieldname = 'MBLNR'.
ls_fcat-coltext = 'Material Doc.'.
APPEND ls_fcat TO pt_fcat.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-coltext = 'Material'.
APPEND ls_fcat TO pt_fcat.
ls_fcat-fieldname = 'MENGE'.
ls_fcat-coltext = 'Quantity'.
APPEND ls_fcat TO pt_fcat.
ENDFORM. " create_fcat
*& Form create_layout
text
<--P_GS_LAYO text
FORM create_layout CHANGING ps_layo TYPE lvc_s_layo.
ps_layo-zebra = 'X'.
ENDFORM. " create_layout
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'ZALV_OOP'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE user_command_0100 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'BACK' OR 'UP' OR 'CANC'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form handle_double_click
text
-->I_ROW text
-->I_COLUMN text
-->IS_ROW_NO text
FORM handle_double_click USING i_row TYPE lvc_s_row
i_column TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.
READ TABLE itab INDEX is_row_no-row_id .
IF sy-subrc = 0 .
IF i_column = 'MATNR'.
t_mat = itab-matnr.
SET PARAMETER ID 'MAT' FIELD t_mat.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
SET PARAMETER ID 'MAT' FIELD space.
ELSEIF i_column = 'MBLNR'.
CALL TRANSACTION 'MIGO'.
ENDIF .
ENDIF.
ENDFORM . "handle_double_click
here in screen 100 i have taken one custom control with name cc_alv -
Why do we use cl_gui_cfw= flush method in Object Oriented ALV programming
Dear Friends,
Please solve my query regarding control framework. Why do we use cl_gui_cfw=>flush method in Object Oriented ALV programming. I studied and found that this method transfers automation queue to Front end. But I could not find any further update on this.
Thanks & Regards
Amit SharmaGenerally this is to restrict the traffic b/w frontend and backend. This means that every operation in Control Framework should be first buffered in the backend and synchronized with the frontend at certain points (one of this point is calling synchronization method cl_gui_cfw=>flush ). This explicit order of synchronization is due to RFC call needed for every communication b/w front/back end. So to avoid to many RFC calls we do it only at certain time.
Please refer [Automation Queue|http://help.sap.com/saphelp_wp/helpdata/en/9b/d080ba9fc111d2bd68080009b4534c/frameset.htm]. I think it explains the concept quite well.
Regards
Marcin -
Hi All,
I want to know the advantages of using OOPS ALV over the normal ALV function modules and how should we decide whether we need to use Object oriented ALV or normal ALV.
Regards,
S.SubasreeHI
please check out the following links
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIDOCK/BCCIDOCK.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIGOF/BCCIGOF.pdf
hope this helps
regards
Aakash Banga -
Select layout & save layout button missing in the toolbar
Hi guys,
I've just developed my first ALV using ABAP objects, but the tollbat doesn't contain buttons select &save layout.
what could be worng?
Thanks a lot!
olianLook at ALV display variant related parameters
- is_variant Don't forget to give the report name is_variant-report = sy-repid before calling set_table_for_first_display.
- is_save Give to is_save a value allowing to save variant to get the save icon. (X-standard, A-all, U-user variants, not space)
(Also take a look at [ALV Gird Control (BC-SRV-ALE)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf])
Regards -
Object Oriented ALV - Editable
hi, Could anyone advice me please....as I'm trying to modify and save the values after displaying in ALV...but value which i'm modifying is not reflecting in ALV, it is displaying the old value....this problem is occuring only when I change the value for the first time...and prob is not occuring from second time....please correct me...
*& Form display_alv
FORM display_alv .
IF w_grid IS INITIAL.
CREATE OBJECT W_DOCK_CONTAINER
RATIO = '95'
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.
CREATE OBJECT W_GRID
I_PARENT = W_DOCK_CONTAINER
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.
PERFORM prepare_field_catalog CHANGING w_lvc_t_fcat.
PERFORM prepare_layout CHANGING w_lvc_layo.
W_DISVARIANT-REPORT = SY-REPID.
CALL METHOD W_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_VARIANT = W_DISVARIANT
I_SAVE = 'A'
IS_LAYOUT = W_LVC_LAYO
CHANGING
IT_OUTTAB = I_YIBRK_EARNINGS[]
IT_FIELDCATALOG = W_LVC_T_FCAT
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 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.
ELSE.
*-- refresh table
CALL METHOD W_GRID->refresh_table_DISPLAY
* EXPORTING
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.
ENDIF.
ENDFORM. " display_alv
*& Module USER_COMMAND_9500 INPUT
MODULE USER_COMMAND_9500 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'. " BACK BUTTON
SET SCREEN 0.
LEAVE SCREEN.
WHEN 'EXIT' OR 'CANCEL'. " EXIT AND CANCEL BUTTON
LEAVE PROGRAM.
WHEN 'SUBMIT'. "SUBMIT
PERFORM submit_data.
WHEN 'SAVE'. "SAVE
PERFORM save_data.
ENDCASE.
ENDMODULE. " USER_COMMAND_9500 INPUT
*& Form save_data
FORM save_data.
*-- if data changes
CALL METHOD W_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = cl_gui_alv_grid=>mc_evt_enter " modified
EXCEPTIONS
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. " save_dataHi
Send me the code within perform submit_data
You have call the grid method check_changed_data on save .Which will raise the data_changed event of cl_alv_gui_grid.
METHOD HANDLE_DATA_CHANGED.
DATA : ROW_ID TYPE I,
FIELDNAME TYPE LVC_FNAME,
DATE1 TYPE I,
DATE2 TYPE I,
DATE3 TYPE I.
DATA : LV_VALUE TYPE I,
LV_VAL(10) TYPE N,
LV_VAL1 TYPE N.
DATA : COUNTER TYPE I VALUE 1,
COUNT TYPE I,
LS_DEL_ROW TYPE LVC_S_MOCE.
data : lv_eff_dt type /CPC/TCTMBRHST-CONTMBREFFDATE.
GV_FLAG = 'X'.
CLEAR ERROR_DATA.
SORT GT_PRICE_DATA BY COUNTER.
DATA : FS LIKE TABLE OF GT_PRICE_DATA.
FIELD-SYMBOLS :
<FS1> TYPE ANY,
<FS3> TYPE ANY,
<FS2> LIKE GS_PRICE_DATA.
CREATE DATA NEW_LINE LIKE LINE OF GT_PRICE_DATA.
ASSIGN NEW_LINE->* TO <GS_PRICE_DATA>.
CLEAR VAR.
*****Check for Inserted and Modified Rows
LOOP AT ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELLS.
ASSIGN COMPONENT LS_MOD_CELLS-FIELDNAME OF STRUCTURE
<GS_PRICE_DATA>
TO <FS1>.
See the above method
Please reward if useful. -
Error for object oriented alv running in background.
Hi all,
I have an ALV report done using object oriented functionality.
When I am trying to run that report in background , it is giving me error.
I want to know why it is happening and how it can be corrected.
Regards,
Vaibhav.Create a docky container :
c_docking_cont TYPE REF TO cl_gui_docking_container.
*For background execution
IF sy-batch EQ c_x.
CREATE OBJECT c_alv
EXPORTING
i_parent = c_docking_cont.
ENDIF.
ALV for display field details
CALL METHOD c_alv->set_table_for_first_display
EXPORTING
is_layout = t_lay
CHANGING
it_outtab = t_table[]
it_fieldcatalog = t_field_cat.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Edited by: Madhavi t on Nov 2, 2009 1:34 PM
Maybe you are looking for
-
It happens on my iMac, and now that I have transferred some photos from that computer to my MacBook it is happening there, too. If I say that I don't want to import it, it "saves" it automatically to a file somewhere on the hard drive. That folder
-
Reg: Calling Function from an ESB Service
I receive the following error while calling a db function returning a number value, using db adapter service <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><env:Fault xmlns:env="http://schemas.xmlsoap.org/s
-
Can't get my iPhone (iPad or iPod touch) to connect to wifi
I cannot get my iPhone 4s to connect to wifi in my home since the last two updates. It sees my network but says unable to connect. This not only happens to my iPhone 4s but to my iPad 2 and my iPod touch. Idk what else to do to get it to connect. My
-
Rename 'Home' link in portfolio
Hi! It's possible to rename 'Home' link in PDF portfolio (I want write other words and in two different laguages). Thank for help
-
Is 5 bpm really the slowest tempo in Logic Pro?
Hi: Am I missing something? Why can't I set the tempo to .1, like I used to be able to in every version of Logic since Creator 1.3 on the Atari?