‎2007 Sep 05 3:12 PM
Hi , I am new to the concept of ALV with OOP ,
I have built an internal table to be displayed , it is required that it need to be editable at the report screen , so I will have to use oops . I have been going through the sflight examples , Since I have my own internal table what should I pass in i_structure_name = ' ' , and if there is a simple source code to help me better understand this concept , i will really appreciate it.
thank you
‎2007 Sep 05 4:03 PM
Hi.
You can use cl_salv_table for display data. https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5dc3e690-0201-0010-1ebf-b85b3bed...
*&---------------------------------------------------------------------*
*& Report SALV_DEMO_TABLE_REAL_SIMPLE
*&---------------------------------------------------------------------*
*& Thisisthemostsimple form of callingthenewALV objectmodel
*& Isn'titREALLY simple?
*&---------------------------------------------------------------------*
REPORT SALV_DEMO_TABLE_REAL_SIMPLE.
data: gt_outtabtypetableof SFLIGHT.
data: gr_tabletyperefto cl_salv_table.
*... Selectdata
select* fromSFLIGHT intocorrespondingfieldsof tablegt_outtab.
*... CreateInstance
callmethodcl_salv_table=>factory
IMPORTING
R_SALV_TABLE = gr_table
changing
t_table= gt_outtab.
*... Display table
gr_table->display( ).-
but, If you need set editable alv use CL_GUI_ALV_GRID: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4544e790-0201-0010-c29c-e46c389f...
In the fieldcat use edit = 'X' to set it editable.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'DATE'.
wa_fieldcat-col_pos = 1.
wa_fieldcat-decimals_o = 0.
wa_fieldcat-datatype = 'DATS'.
wa_fieldcat-no_zero = 'X'.
wa_fieldcat-edit = 'X'.
wa_fieldcat-outputlen = 8.
APPEND wa_fieldcat TO gt_fieldcat.
‎2007 Sep 05 3:13 PM
Please also if possible post the field catalog , how it need to be filled.
Thankyou
‎2007 Sep 05 3:18 PM
Hi Krish,
You need to follow these simple steps.
1). Define a screen in your program and using se51 just place a custom container object on the screen and drag it to size of the ALV display you need.
2). use the code below in your PBO module
MODULE status_0901 OUTPUT.
SET PF-STATUS c_zvxxstatus. <=== what ever menu you need
SET TITLEBAR c_zvxxtitle. <=== what ever title you need
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = c_zsxx_zrpo_struc <=== Structure of your internal table
i_client_never_display = c_x
CHANGING
ct_fieldcat = i_fieldcat_lvc[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF ob_custom_container IS INITIAL.
CREATE OBJECT ob_custom_container
EXPORTING
container_name = c_container.
CREATE OBJECT ob_grid
EXPORTING
i_parent = ob_custom_container.
* make the rows zebra pattern and optimize the width of the colum
MOVE c_x TO e_layout-zebra.
MOVE c_x TO e_layout-cwidth_opt.
* set table for first display
CALL METHOD ob_grid->set_table_for_first_display
EXPORTING
* i_structure_name = c_zsxx_zrpo_struc
is_layout = e_layout
CHANGING
it_outtab = t_orders[]
it_fieldcatalog = i_fieldcat_lvc
it_sort = t_sort[].
ENDIF.3). In the PAI module create a routine to handle the actions on the screen and menus
MODULE user_command_0901 INPUT.
* actions according to the function code of the buttons
MOVE w_ok_code TO w_save_ok.
CLEAR w_ok_code.
CASE w_save_ok.
WHEN c_exit OR c_cancel OR c_back.
PERFORM f_do_exit.
WHEN OTHERS.
* do nothing
ENDCASE.
ENDMODULE.
Check the code above its pretty simple to get a alv output using OOPS
Hope this helps
Cheers
VJ
‎2007 Sep 05 3:57 PM
I am not able to pass the internal table in i_structure_name and it_outtab. I get an error message .
‎2007 Sep 05 4:03 PM
Hi.
You can use cl_salv_table for display data. https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5dc3e690-0201-0010-1ebf-b85b3bed...
*&---------------------------------------------------------------------*
*& Report SALV_DEMO_TABLE_REAL_SIMPLE
*&---------------------------------------------------------------------*
*& Thisisthemostsimple form of callingthenewALV objectmodel
*& Isn'titREALLY simple?
*&---------------------------------------------------------------------*
REPORT SALV_DEMO_TABLE_REAL_SIMPLE.
data: gt_outtabtypetableof SFLIGHT.
data: gr_tabletyperefto cl_salv_table.
*... Selectdata
select* fromSFLIGHT intocorrespondingfieldsof tablegt_outtab.
*... CreateInstance
callmethodcl_salv_table=>factory
IMPORTING
R_SALV_TABLE = gr_table
changing
t_table= gt_outtab.
*... Display table
gr_table->display( ).-
but, If you need set editable alv use CL_GUI_ALV_GRID: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4544e790-0201-0010-c29c-e46c389f...
In the fieldcat use edit = 'X' to set it editable.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'DATE'.
wa_fieldcat-col_pos = 1.
wa_fieldcat-decimals_o = 0.
wa_fieldcat-datatype = 'DATS'.
wa_fieldcat-no_zero = 'X'.
wa_fieldcat-edit = 'X'.
wa_fieldcat-outputlen = 8.
APPEND wa_fieldcat TO gt_fieldcat.