09-09-2008 12:14 PM
Hi,
I am developing an ALV grid with the first column as a Checkbox.
I want to capture if the checkbox is checked or not.
If YES then process them accordingly and if NO then something else.
Also I want a pushbutton on the screen.
I have used
i_callback_pf_status_set = 'ALV_SET_PF_STATUS'
i_callback_user_command = 'ALV_USER_COMMAND'
FORM alv_set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'PF_STATUS' EXCLUDING rt_extab.
SET TITLEBAR text-005.
ENDFORM. "set_pf
But this is not working. I don't get any button on the screen.
Your help will be greatly appreciated.
Thanks,
Payel
09-09-2008 12:18 PM
Hi,
For Checkboxes, please check the link:
http://saptechnicalinfo.blogspot.com/2008/08/alv-check-boxes-sample-code-in-sap-abap.html
Thanks,
Ruthra
09-09-2008 12:20 PM
Hi,
I hope the below links will help you.
http://help.sap.com/saphelp_nw04/helpdata/en/79/11269b0edf11d4b595006094192fe3/frameset.htm
Thanks,
Khushboo.
09-09-2008 12:21 PM
Hi,
Use method CHECK_CHANGED_DATA this update the internal table with the values changed on the screen.
Regards,
Kunjal
09-09-2008 12:29 PM
Hi Payel,
For setting up the pushbutton on ALV toolbar the easiest way is to copy the status of the statndard ALV program to your program.
for the same ,
GO to SE80 and give the program name SAPLSLVC_FULLSCREEN and in the GUI status copy the stautus STATNDARD_FULLSCREEN(rt click on the status and give copy) .Copy to your program with "Z" (in the pop up whn u select copy).
Now go to ur pgm and activate it.Now ull find the status name in your program's gui status (in SE80).add a new func code(for teh push button u need) in the status and give your required icon also.
Now in your FORM alv_set_pf_status
FORM alv_set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'the copied status name' EXCLUDING rt_extab.
ENDFORM.
Now ull find the push button on the ALV toolbar when u execute.
And keep in miond that u need to pass the parameter I_CALLBACK_PROGRAM in func mod REUSE_ALV_GRID_DISPLAY as sy-repid.
Now when u check the check box and click on the pushbutton ull get the correct record .
Hope this helps.
Neeraj
09-09-2008 1:20 PM
Hi Neeraj,
I have done that already, but it doesn't seem to work.
Is there any other way to achieve this.
~ Payel
09-09-2008 1:25 PM
Hi Payel Sarkar,
Do you know how to use object-oriented alv?
You will create a screen and put a custom control in it,
you can put buttons also on this screen.
Please tell me about whether you know object-oriented alv or not.
I will help you.
deniz.
09-09-2008 1:40 PM
Hi Deniz,
No I don't.
But it wil be really nice if you help me doing it.
Thanks ~ Payel
Edited by: Payel Sarkar on Sep 9, 2008 2:42 PM
09-09-2008 2:17 PM
You create a screen numbered as 0100, go to layout and put a custom control(a symbol that has a C on it) on this screen
and if you want put a button on this screen also and provide a name(Assume CC_ALV), text and by double-clicking on button go to Screen painter attributes and provide fctCode for this button.
You will use this fctCode at code page later.
Please call screen 0100 at code page as:
CALL SCREEN 0100.
At process before output of this screen,
you can select you data.
At process after input,
you can code the button and do what you want, use alv's methods etc.
Try and write me again.
09-09-2008 2:21 PM
define following variables:
DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid .
*--- Name of the custom control added on the screen
DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV' .
*--- Custom container instance reference
DATA gr_ccontainer TYPE REF TO cl_gui_custom_container.
*--- Field catalog table
DATA gt_fieldcat TYPE lvc_t_fcat.
*--- Layout structure
DATA gs_layout TYPE lvc_s_layo..
At process before output, after selecting the data:
-
*
MODULE displayALV OUTPUT.
perform displayALVOBJECT.
ENDMODULE. " displayALV OUTPUT
&----
*& Form displayALVOBJECT
&----
text
----
--> p1 text
<-- p2 text
----
FORM displayALVOBJECT.
IF gr_alvgrid IS INITIAL .
----Creating custom container instance
CREATE OBJECT gr_ccontainer
EXPORTING
container_name = gc_custom_control_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6 .
IF sy-subrc <> 0.
--Exception handling
ENDIF.
----Creating ALV Grid instance
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.
--Exception handling
ENDIF.
PERFORM prepare_field_catalog CHANGING gt_fieldcat .
----Preparing layout structure
PERFORM prepare_layout CHANGING gs_layout .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = sy-cprog
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USERCOMMAND_DEGISTIR'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = gt_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = itabTable[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = gs_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
CHANGING
it_outtab = itabTable[]
it_fieldcatalog = gt_fieldcat
IT_SORT =
IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4 .
IF sy-subrc <> 0.
--Exception handling
ENDIF.
ELSE .
CALL METHOD gr_alvgrid->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
finished = 1
OTHERS = 2 .
IF sy-subrc <> 0.
--Exception handling
ENDIF.
ENDIF .
ENDFORM. " displayALVOBJECT
09-09-2008 2:25 PM
Just copy the code:
FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.
ps_layout-zebra = 'X'.
ps_layout-grid_title = 'TEST'.
ps_layout-smalltitle = 'X' .
ps_layout-sel_mode = 'D'.
ps_layout-NO_HGRIDLN = 'X'.
"ps_layout-info_fname = 'LINE_COLOR'.
"ps_layout-edit = 'X'.
"ps_layout-No_toolbar = 'X'.
ENDFORM. " prepare_layoutENDFORM.
FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat .
DATA ls_fcat type lvc_s_fcat .
ls_fcat-fieldname = 'MATNR'.
ls_fcat-outputlen = '10'.
ls_fcat-coltext = 'Material No'.
ls_fcat-seltext = 'Material No'.
ls_fcat-col_pos = 0.
ls_fcat-key = 'X'.
APPEND ls_fcat to pt_fieldcat .
CLEAR ls_fcat .
"go on for other columns too
ENDFORM.