OOP ALV - Setting specific records as editable
Hello everyone,
Is there a way for an ALV grid/OOP ALV to set certain fields as editable?
I have tried setting specific columns as editable through field catalog setup, but I don't need all records of that column to be editable. I just need specific records to be editable. Is this possible with ALV or I have no other choice but to use Table Control?
Please help.
Sincerely,
Ice
Hi Ice,
this code will work 4 u.
*& Report ZDEMO_ALVGRID_EDIT *
*& Example of a simple ALV Grid Report *
*& The basic ALV grid, Enhanced to display specific fields as *
*& editable depending on field value *
REPORT ZDEMO_ALVGRID_EDIT .
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
field_style TYPE lvc_t_styl, "FOR DISABLE
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcat TYPE lvc_s_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE lvc_s_layo, "slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM set_specific_field_attributes.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-scrtext_m = 'Purchase Order'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 10.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-scrtext_m = 'PO Item'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'STATU'.
wa_fieldcat-scrtext_m = 'Status'.
wa_fieldcat-col_pos = 2.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-scrtext_m = 'Item change date'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-scrtext_m = 'Material Number'.
wa_fieldcat-col_pos = 4.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-scrtext_m = 'PO quantity'.
wa_fieldcat-col_pos = 5.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-scrtext_m = 'Order Unit'.
wa_fieldcat-col_pos = 6.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-scrtext_m = 'Net Price'.
wa_fieldcat-edit = 'X'. "sets whole column to be editable
wa_fieldcat-col_pos = 7.
wa_fieldcat-outputlen = 15.
wa_fieldcat-datatype = 'CURR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'PEINH'.
wa_fieldcat-scrtext_m = 'Price Unit'.
wa_fieldcat-col_pos = 8.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
Set layout field for field attributes(i.e. input/output)
gd_layout-stylefname = 'FIELD_STYLE'.
gd_layout-zebra = 'X'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gd_layout
it_fieldcat_lvc = it_fieldcat
i_save = 'X'
TABLES
t_outtab = it_ekko
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. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekko.
ENDFORM. " DATA_RETRIEVAL
*& Form set_specific_field_attributes
populate FIELD_STYLE table with specific field attributes
form set_specific_field_attributes .
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
Populate style variable (FIELD_STYLE) with style properties
The NETPR field/column has been set to editable in the fieldcatalog...
The following code sets it to be disabled(display only) if 'NETPR'
is gt than 10.
LOOP AT it_ekko INTO wa_ekko.
IF wa_ekko-netpr GT 10.
ls_stylerow-fieldname = 'NETPR' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
"set field to disabled
APPEND ls_stylerow TO wa_ekko-field_style.
MODIFY it_ekko FROM wa_ekko.
ENDIF.
ENDLOOP.
endform. " set_specific_field_attributes
kindly reward if found helpful.
cheers,
Hema.
Similar Messages
-
How to set a selected checkbox in output internal table of oops ALV grid
Hi All,
i have a checkbox as first column in my ALV grid output using oops alv, when i select some checkbox, that rows have to be selected and i need to process only selected rows in user command.
i have given the below code also in fieldcatolg.
f_fldcat-fieldname = 'checkbox'.
f_fldcat-tabname ='gi_output'
f_fldcat-checkbox = 'X'.
f_fldcat-edit = 'X'.
but the checkbox is not getting set in internal table when i select some checkboxes.
can anybody explain y the checkbox in internal table not getting set?
Thanks,
Srilakshmi.Hi,
i tried already whatever u said, but still not resolved.Pasted my code below..can u please look into it.
MODULE pbo OUTPUT.
PERFORM init_container.
PERFORM prepare_field_catalog.
PERFORM prepare_layout.
PERFORM display_output.
ENDMODULE. " PBO OUTPUT
*& Module PAI INPUT
text
MODULE pai INPUT.
DATA: lt_rows TYPE lvc_t_row.
CASE gv_okcode.
WHEN gc_exit OR gc_back OR gc_canc. " Finish program
LEAVE PROGRAM.
when 'PRINT'.
CALL METHOD gv_grid->get_selected_rows
IMPORTING et_index_rows = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
ENDCASE.
ENDMODULE. " PAI INPUT
*& Form INIT_CONTAINER
text
FORM init_container .
CREATE OBJECT gv_custom_container
EXPORTING
container_name = gc_container.
CREATE OBJECT gv_grid
EXPORTING
i_parent = gv_custom_container.
CREATE OBJECT gv_document
EXPORTING
style = 'ALV_GRID'.
*& Form PREPARE_FIELD_CATALOG
text
FORM prepare_field_catalog .
PERFORM fill_catalog USING:
'Table Name' 'Field Name' 'NoZero' 'sel-text'
'GI_OUTPUT' 'CHECKBOX' ' ' text-013 'X',
'GI_OUTPUT' 'KUNNR' 'X' text-003 ' ',
'GI_OUTPUT' 'NAME1' ' ' text-004 ' ',
'GI_OUTPUT' 'BELNR' 'X' text-005 ' ',
'GI_OUTPUT' 'BLART' ' ' text-006 ' ',
'GI_OUTPUT' 'BUDAT' ' ' text-007 ' ',
'GI_OUTPUT' 'BLDAT' ' ' text-008 ' ',
'GI_OUTPUT' 'DMBTR' ' ' text-009 ' ',
'GI_OUTPUT' 'WAERS' ' ' text-010 ' '.
ENDFORM. " PREPARE_FIELD_CATALOG
*& Form FILL_CATALOG
text
FORM fill_catalog USING fv_tabname
fv_fldname
fv_nozero
fv_seltxt
fv_checkbox.
DATA f_fldcat TYPE lvc_s_fcat.
f_fldcat-fieldname = fv_fldname.
f_fldcat-tabname = fv_tabname.
f_fldcat-no_zero = fv_nozero.
f_fldcat-coltext = fv_seltxt.
f_fldcat-checkbox = fv_checkbox.
IF fv_checkbox = gc_x.
f_fldcat-edit = gc_x.
ENDIF.
APPEND f_fldcat TO gi_fieldcat.
ENDFORM. " FILL_CATALOG
*& Form PREPARE_LAYOUT
text
FORM prepare_layout .
gs_layout-info_fname = 'COL'.
gs_layout-cwidth_opt = gc_x.
gs_layout-zebra = gc_x.
gs_layout-no_toolbar = gc_x.
gs_layout-no_rowmark = '1'.
gs_layout-sel_mode = 'A'.
ENDFORM. " PREPARE_LAYOUT
*& Form DISPLAY_OUTPUT
text
FORM display_output .
CALL METHOD gv_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = gi_output
it_fieldcatalog = gi_fieldcat.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR gv_grid.
CALL METHOD cl_gui_control=>set_focus EXPORTING control = gv_grid.
ENDFORM. " DISPLAY_OUTPUT -
In ALV Reports, i want to edit records manually in out put display
hello all,
in ALV Reports, i want to edit records manually in out put display. how can i do that?*& Report ZTEST1
REPORT ztest1.
TYPE-POOLS: slis.
DATA:i_sbook TYPE STANDARD TABLE OF sbook INITIAL SIZE 0,
i_sbook1 TYPE STANDARD TABLE OF sbook INITIAL SIZE 0,
i_fieldcatalog TYPE slis_t_fieldcat_alv,
wa_fieldcatalog LIKE LINE OF i_fieldcatalog,
wa_sbook TYPE sbook.
DATA:wa_layout TYPE slis_layout_alv.
SELECT-OPTIONS:
s_carrid FOR wa_sbook-carrid.
AT SELECTION-SCREEN.
IF s_carrid IS NOT INITIAL.
SELECT COUNT( * )
FROM scarr WHERE carrid IN s_carrid.
IF sy-subrc <> 0.
MESSAGE e000(ztest) WITH 'Invalid Airline Code'.
ENDIF.
ENDIF.
START-OF-SELECTION.
SELECT *
FROM sbook
INTO TABLE i_sbook
UP TO 50 ROWS
WHERE carrid IN s_carrid.
CHECK sy-subrc = 0.
i_sbook1[] = i_sbook[].
DATA: l_repid TYPE syrepid VALUE sy-repid.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = l_repid
i_internal_tabname = 'I_SBOOK'
i_structure_name = 'SBOOK'
i_client_never_display = 'X'
* I_INCLNAME =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = i_fieldcatalog
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 i_fieldcatalog INTO wa_fieldcatalog.
IF wa_fieldcatalog-fieldname = 'SMOKER'.
wa_fieldcatalog-edit = 'X'. " REUSE_ALV_GRID_DISPLAY
* wa_fieldcatalog-input = 'X'. " REUSE_ALV_LIST_DISPLAY
ENDIF.
MODIFY i_fieldcatalog FROM wa_fieldcatalog TRANSPORTING edit input.
ENDLOOP.
wa_layout-window_titlebar = 'My Title'.
wa_layout-zebra = 'X'.
wa_layout-colwidth_optimize = 'X'.
DATA repid TYPE syrepid VALUE sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'SUB_USER_COMMAND'
is_layout = wa_layout
it_fieldcat = i_fieldcatalog
TABLES
t_outtab = i_sbook
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.
*& Form sub_user_command
* text
* -->R_UCOMM text
* -->RS_SELFIELD text
FORM sub_user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'. "Double click
IF i_sbook1[] NE i_sbook[].
MESSAGE i001(00) WITH 'Hmm...some data changed'.
ENDIF.
ENDCASE.
ENDFORM. "sub_user_command
*& Form set_pf_status
* text
* -->RT_EXTAB text
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTANDARD'.
ENDFORM. "set_pf_status -
Create Edit Delete in Oops ALV
Hi Experts,
I need to create an ALV which will provide all the functionality of Create, Edit, Save and Delete records and update the Custom table accordingly.
I want to design it as follows -
1. Display should be in non-ediatble mode initially (because I don't want to make it completely ediatble at all times)
2. When the user clicks Create button a new line appends at the bottom and the ALV has to be made editable, for the values to be entered at the new row appended.
3. When the user presses Save, again the ALV goes into non-ediatble mode.
4. When the user presses Edit Button, the ALV is open for editing and again the whole ALV is editable. After Editing, the user will select those particular lines through Box Button and Press on Save Button to enable those particular lines to be modified and saved in ALV. Again at the press of Save button, the ALV will switch to Non-modifiable view.
5. For Deletion, select the particular line/lines through Box Button and Click on Delete.
This is how I plan to achieve the Create, Edit, Delete Functionality.
Can you please confirm the feasibilty of this Design, whether it is achievable.
There is some option of dynamically changing the Field Catalogue. If it is there, I'm thinking of utilising it for switching the modes on click of Create, Edit and Save Buttons. Click/Edit --> Modifiable. Save --> Non-modifiable.
Please do give your comments on the above functionality and feasibility. If you are knowing a different or easy approach please do share it. If you have done it then please do share it.
Thanks & Regards
TanuPlz ask your specific requirement otherwise mosarator will block the thread...
-
Set specific rows in ALV grid ready for input
Hi everyone,
I have a question about how to set specific rows in ALV grid ready for input.
I know that I can make some columns ready for input before the ALV displayed,but I have no idea how to make specific rows displayed in the ALV ready for input.Hello Aaron
For editable columns we can use the fieldcatalog (LVC_S_FCAT-EDIT = 'X') but for rows you need to define editability on cell level.
The required steps are documented in sample report BCALV_EDIT_02. Below I point out a few crucial points:
*§1.Extend your output table for a field, e.g., CELLTAB, that holds
* information about the edit status of each cell for the
* corresponding row (the table type is SORTED!).
DATA: BEGIN OF gt_outtab occurs 0. "with header line
include structure sflight.
DATA: celltab type LVC_T_STYL.
DATA: END OF gt_outtab.
*§3.Provide the fieldname of the celltab field by using field
* STYLEFNAME of the layout structure.
gs_layout-stylefname = 'CELLTAB'.
CALL METHOD grid1->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = gs_layout
CHANGING it_outtab = gt_outtab[].
Note: in the sample report only field SEATSMAX is editable. In your case you need
to fill CELLTAB for all fields in a row.
*§2.After selecting data, set edit status for each row in a loop
* according to field SEATSMAX.
LOOP AT gt_outtab.
l_index = sy-tabix.
refresh lt_celltab.
if gt_outtab-seatsmax ge 300.
perform fill_celltab using 'RW'
changing lt_celltab.
else.
perform fill_celltab using 'RO'
changing lt_celltab.
endif.
*§2c.Copy your celltab to the celltab of the current row of gt_outtab.
INSERT LINES OF lt_celltab INTO TABLE gt_outtab-celltab.
MODIFY gt_outtab INDEX l_index.
ENDLOOP.
ENDFORM. " SELECT_DATA_AND_INIT_STYLE
NOTE: LVC_T_STYL is a SORTED table type. Thus, take care that you are using the
INSERT ... INTO TABLE statement and not APPEND (because then nothing is appended
to the CELLTAB itab).
IF p_mode EQ 'RW'.
*§2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
* to status "editable".
l_mode = cl_gui_alv_grid=>mc_style_enabled.
ELSE. "p_mode eq 'RO'
*§2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell
* to status "non-editable".
l_mode = cl_gui_alv_grid=>mc_style_disabled.
ENDIF.
ls_celltab-fieldname = 'SEATSMAX'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
Regards
Uwe -
RE:ALV grid (oops concept)-to make selected row editable
Hi,
I have an object oriented alv which is having 5 rows of data.I have a pushbutton to make any row in editable mode.My requirement is i will select any row in oops alv grid and press
the button to make the row editable.How can i do this in oops alv.
thanks,
AlexHi,
Use the Link [http://www.sapdev.co.uk/reporting/alv/alvgrid_editable.htm]
Check demo pgm BCALV_EDIT_05.
*& Report ZUS_SDN_ALVGRID_EDITABLE_8
*& Description: editable ALV -> ENTER jumps to next row
*& Dynpro flow logic: no screen elements, ok_code = GD_OKCODE
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
REPORT zus_sdn_alvgrid_editable_8.
DATA:
gd_repid TYPE syst-repid,
gd_okcode TYPE ui_func,
gt_fcat TYPE lvc_t_fcat,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid TYPE REF TO cl_gui_alv_grid.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING
er_data_changed
e_onf4
e_onf4_before
e_onf4_after
e_ucomm
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_data_changed.
define local data
cl_gui_cfw=>set_new_ok_code( 'NEXT_ROW' ). " not possible on 4.6c
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'NEXT_ROW'
IMPORTING
RC =
" Triggers PAI of dynpro with ok_code = 'NEXT_ROW'
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
PARAMETERS:
p_bukrs TYPE bukrs DEFAULT '2000' OBLIGATORY.
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = p_bukrs.
Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
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 ALV grid
CREATE OBJECT go_grid
EXPORTING
i_parent = go_docking
EXCEPTIONS
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.
" Triggers event DATA_CHANGED when ENTER is pushed
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter
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.
SET HANDLER:
lcl_eventhandler=>handle_data_changed FOR go_grid.
Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog_knb1.
Display data
CALL METHOD go_grid->set_table_for_first_display
CHANGING
it_outtab = gt_knb1
it_fieldcatalog = gt_fcat
EXCEPTIONS
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.
Link the docking container to the target dynpro
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
CONTAINER =
EXCEPTIONS
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.
ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
SET TITLEBAR 'xxx'.
CALL METHOD go_grid1->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
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.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE user_command_0100 INPUT.
go_grid->check_changed_data( ).
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
" NOTE: ENTER button alone works apparently only if the cursor
" is placed within the command window (left-upper corner)
WHEN 'ENTER' OR
'NEXT_ROW'.
PERFORM set_cursor_next_row.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_FIELDCATALOG_KNB1
text
--> p1 text
<-- p2 text FORM build_fieldcatalog_knb1 .
define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
i_structure_name = 'KNB1'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
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 gt_fcat INTO ls_fcat
WHERE ( fieldname = 'ZUAWA' ).
ls_fcat-edit = abap_true.
ls_fcat-col_opt = abap_true.
MODIFY gt_fcat FROM ls_fcat.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG_KNB1
*& Form SET_CURSOR_NEXT_ROW
text
--> p1 text
<-- p2 text FORM set_cursor_next_row .
define local data
DATA:
ls_row TYPE lvc_s_row,
ls_col TYPE lvc_s_col.
CALL METHOD go_grid->get_current_cell
IMPORTING
E_ROW =
E_VALUE =
E_COL =
es_row_id = ls_row
es_col_id = ls_col
ES_ROW_NO =
ADD 1 TO ls_row-index. " next row
CALL METHOD go_grid->set_current_cell_via_id
EXPORTING
is_row_id = ls_row
is_column_id = ls_col
IS_ROW_NO =
ENDFORM. " SET_CURSOR_NEXT_ROW
HTH
Regards,
Dhruv Shah -
Perform setting OOP ALV for multiple reports using Field Symbols
Hi, Abapers ... i try to write a programme which using ONE oop ALV but 2 different structure internal table. the last result should be 2 radio button. first button is r_wbs and 2ns r_kpi. r_wbs will display 4 column answer and r_kpi will display 10 columns answer with different column name. i successfully implemented using FIELDS SYMBOLS but the problems i failed to perform customized setting forALV (report's tittle, column name, different layout etc) for 2 different reports. this is the programme. Please Give Opinion, simple example will be more helpful. Thanks You Very Much
*&this report experimental how to print into ONE alv
*&with 2 diffrent structure internal table
REPORT zfiroopalv.
SELECTION-SCREEN BEGIN OF BLOCK mode WITH FRAME TITLE text-002.
PARAMETERS r_wbs RADIOBUTTON GROUP mode DEFAULT 'X'.
PARAMETERS r_kpi RADIOBUTTON GROUP mode.
SELECTION-SCREEN END OF BLOCK mode.
CLASS lcl_main DEFINITION.
PUBLIC SECTION.
CLASS-DATA: md_wbs TYPE c LENGTH 1.
METHODS: process,
write.
DATA: mdo_data TYPE REF TO data.
TYPES: BEGIN OF st_wbs,
rsnum TYPE zmeime002a-rsnum,
rspos TYPE zmeime002a-rspos,
a TYPE zmmgitab01-menge,
b TYPE zmeime002a-bdmng,
c TYPE zmeime002a-bdmng,
d TYPE zmeime002a-bdmng,
e TYPE zmeime002a-bdmng,
f TYPE zmmgitab01-menge,
g TYPE zmmgitab01-menge,
END OF st_wbs.
TYPES: BEGIN OF st_kpi,
regio TYPE zmeime002a-regio,
gsber TYPE zmeime002a-gsber,
gtext TYPE zmeime002a-gtext,
x TYPE zmmgitab01-menge,
y TYPE zmmgitab01-menge,
z TYPE zmmgitab01-menge,
END OF st_kpi.
CLASS-DATA: it_wbs TYPE TABLE OF st_wbs,
wa_wbs LIKE LINE OF it_wbs.
CLASS-DATA: it_kpi TYPE TABLE OF st_kpi,
wa_kpi LIKE LINE OF it_kpi.
PRIVATE SECTION.
DATA: set_display_setting TYPE REF TO cl_salv_table.
DATA: display_settings TYPE REF TO cl_salv_display_settings.
DATA: salv_table TYPE REF TO cl_salv_table.
DATA: error TYPE REF TO cx_root.
DATA: errtext TYPE string.
ENDCLASS.
CLASS lcl_kpi DEFINITION INHERITING FROM lcl_main.
PUBLIC SECTION.
METHODS: process_kpi.
PRIVATE SECTION.
ENDCLASS.
* C.L.A.S.S lcl_main D.E.F.I.N.I.T.I.O.N
CLASS lcl_wbs DEFINITION INHERITING FROM lcl_main.
PUBLIC SECTION.
METHODS: process_wbs.
PRIVATE SECTION.
ENDCLASS.
* m.a.i.n. .p.r.o.g.r.a.m.
START-OF-SELECTION.
DATA: o_main TYPE REF TO lcl_main.
DATA: p_wbs TYPE c.
CREATE OBJECT o_main.
CASE 'X'.
WHEN r_wbs.
o_main->md_wbs = 'X'.
WHEN r_kpi.
o_main->md_wbs = ' '.
ENDCASE.
o_main->process( ).
o_main->write( ).
CLASS lcl_main IMPLEMENTATION.
*ENDMETHOD.
METHOD process. " NOTE: public method
DATA: o_main TYPE REF TO lcl_main,
o_wbs TYPE REF TO lcl_wbs,
o_kpi TYPE REF TO lcl_kpi.
CREATE OBJECT: o_wbs,o_kpi.
IF ( me->md_wbs = 'X' ).
CALL METHOD o_wbs->process_wbs( ). " NOTE: private method
GET REFERENCE OF me->it_wbs INTO me->mdo_data.
ELSE.
CALL METHOD o_kpi->process_kpi( ). " NOTE: private method
GET REFERENCE OF me->it_kpi INTO me->mdo_data.
ENDIF.
ENDMETHOD.
METHOD write.
FIELD-SYMBOLS:
<lt_outtab> TYPE table.
ASSIGN me->mdo_data->* TO <lt_outtab>.
cl_salv_table=>factory(
EXPORTING
list_display = if_salv_c_bool_sap=>false
IMPORTING
r_salv_table = salv_table
CHANGING
t_table = <lt_outtab>
salv_table->display( ).
ENDMETHOD.
ENDCLASS.
CLASS lcl_kpi IMPLEMENTATION.
METHOD process_kpi.
*********** run some select statement into it_kpi*******
ENDMETHOD.
ENDCLASS.
CLASS lcl_wbs IMPLEMENTATION.
METHOD process_wbs.
*********** run some select statement into it_wbs*******
ENDMETHOD.
ENDCLASS.Hi,
I had similar requirement wherein I was supposed to display different data using 2 different internal tables on a subscreen area.
The screen consists of two parts: 1) selection-screen with few input fields and two buttons 2) Subscreen area where the report need to be displayed. This report is displayed based on the button that the user is selecting. For this I have done the following things:
1. Capture the sy-ucomm when user is clicking on any of the two buttons in PAI. Then perform data fetch operation.
MODULE USER_COMMAND_9003 INPUT.
CASE OK_CODE.
WHEN 'DETAIL'.
GV_RPT = OK_CODE.
PERFORM F_GET_DETAIL_DATA.
WHEN 'REPORT'.
GV_RPT = OK_CODE.
PERFORM F_GET_REPT_DATA.
ENDCASE.
ENDMODULE. " USER_COMMAND_9003 INPUT
2. Declare two different ALV's with the fieldcat similar to 2 internal tables respectively. Use the above sy-ucomm PBO to call appropriate ALV.
MODULE DISPLAY_ALV OUTPUT.
IF GV_RPT EQ 'DETAIL'.
PERFORM F_FIELDCAT_DETAIL.
PERFORM F_LAYOUT_DETAIL.
PERFORM F_EXCLUDE_TOOLBAR_DETAIL.
PERFORM F_DISPLAY_ALV_DETAIL.
ELSEIF GV_RPT EQ 'REPORT'.
PERFORM F_FIELDCAT_REPT.
PERFORM F_LAYOUT_REPT.
PERFORM F_EXCLUDE_TOOLBAR_REPT.
PERFORM F_DISPLAY_ALV_REPT.
ENDIF.
ENDMODULE. " DISPLAY_ALV OUTPUT
3. Before displaying ALV you need to free the container and ALV.
FORM F_DISPLAY_ALV_DETAIL .
IF GC_CONTAINER_ES IS NOT INITIAL.
CALL METHOD GC_CONTAINER_ES->FREE
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_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.
ENDIF.
IF GC_ALV_GRID_ES IS NOT INITIAL.
CALL METHOD GC_ALV_GRID_ES->FREE
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_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.
ENDIF.
IF GC_CONTAINER_TB IS NOT INITIAL.
CALL METHOD GC_CONTAINER_TB->FREE
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_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.
ENDIF.
IF GC_ALV_GRID_TB IS NOT INITIAL.
CALL METHOD GC_ALV_GRID_TB->FREE
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_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.
ENDIF.
CREATE OBJECT GC_CONTAINER_ES
EXPORTING
CONTAINER_NAME = 'CC_9003'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
OTHERS = 6.
CREATE OBJECT GC_ALV_GRID_ES
EXPORTING
I_PARENT = GC_CONTAINER_ES
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
OTHERS = 5.
CALL METHOD GC_ALV_GRID_ES->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = GS_LAYOUT_ES
IT_TOOLBAR_EXCLUDING = GT_TOOLBAR_ES
CHANGING
IT_OUTTAB = GT_ES_REPT
IT_FIELDCATALOG = GT_FIELDCAT_ES
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4.
ENDFORM. " F_DISPLAY_ALV_DETAIL
Similarly define the FORM F_DISPLAY_ALV_REPT.
Hope this will be useful for you. If you have any more queries let me know. -
Problem with OOPS ALv-field editable
hi experts,
I am displaying one report using OOPS ALV. Now i am inserting a line in the output, so some mandatory fields are automatically filled up in the new line, and i am trying to fill new values for the remaining empty fields, So initially they are non-editable in the fieldcatalog.if i click on the 'INSERT LINE' button then only the fields shud be input enabled, how to do this.
Thanks in advance,maybe sample report BCALV_EDIT_04 might help you there.
-
Java API: Limiting search to a specific set of records ids?
Hello.
I'm trying to find a way to do the following: run a search (a pretty simple search, just check for a specific value in a specific field), but instead of running the search on an entire table I want to limit it to a specific set of record-ids, the point being that I know which record-ids I want to search on (I'm getting them from a listener event) and I'd like to make the search more effective.
Any ideas?
Thanks,
AlonAlon,
Are you on SP6? If so, have you tried the [RetrieveRecordsByIdCommand|http://help.sap.com/javadocs/MDM/SP06/com/sap/mdm/data/commands/RetrieveRecordsByIdCommand.html]?
Regards,
Doug -
How do I define Field-Catalog and Event-Catalog in OOPs ALV
Hi All,
This is the piece of the code on which I'm working upon. This program is giving an exception "No Field-Catalog Found".
I'm new to OOPs ALV. Could anybody please tell me how to define the field-catalog and event-catalog in this.
module PBO output.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container EXPORTING CONTAINER_NAME = 'CCCONTAINER'.
CREATE OBJECT g_grid EXPORTING I_PARENT = g_custom_container.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING I_STRUCTURE_NAME = 'IT_MATERIAL'
is_layout = layout
CHANGING IT_OUTTAB = gt_it_material.
ENDIF.
endmodule.
Regards,
Saurabhhi,
chk this sampl ceode.
TYPE-POOLS: slis.
CLASS lcl_event_receiver DEFINITION DEFERRED.
TABLES : zmpets_shipactiv, zmpets_chargebk, zmpets_shiphdr.
DATA : BEGIN OF int_crb OCCURS 0,
sel TYPE char1,
icon TYPE icon_d,
pernr LIKE zmpets_cil-pernr,
vorna LIKE pa0002-vorna,
movreason LIKE zmpets_shiphdr-movreason,
shipdocnum LIKE zmpets_chargebk-shipdocnum,
createdon LIKE zmpets_chargebk-createdon,
chargeamount LIKE zmpets_chargebk-chargeamount,
version LIKE zmpets_shipactiv-version,
activity LIKE zmpets_shipactiv-activity,
vendor LIKE zmpets_shiphdr-vendor,
smtp_addr LIKE adr6-smtp_addr,
empperid LIKE zmpets_167doc-empperid,
celltab TYPE lvc_t_styl,
END OF int_crb.
DATA : int_crb_ver LIKE int_crb OCCURS 0 WITH HEADER LINE.
DATA : int_crb_mail LIKE int_crb OCCURS 0 WITH HEADER LINE.
DATA : int_shipactiv LIKE zmpets_shipactiv OCCURS 0 WITH HEADER LINE.
DATA: gt_fieldcatalog TYPE lvc_t_fcat.
DATA : wf_flag TYPE i.
DATA : wf_res TYPE c.
DATA : wf_tabix TYPE sy-tabix.
DATA: BEGIN OF int_sin OCCURS 0,
shipdocnum LIKE zmpets_chargebk-shipdocnum,
shipdocnum LIKE zmpets_shipactiv-petsdocnumber,
END OF int_sin.
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
DATA l_num(3).
DATA: ok_code LIKE sy-ucomm,
w_repid LIKE sy-repid,
wl_sno TYPE i VALUE 0,
w_max TYPE i VALUE 100,
wf_layout TYPE lvc_s_layo,
cont_on_main TYPE scrfname VALUE 'GRID_CONTROL',
cont_on_dialog TYPE scrfname VALUE 'GRID_CONTROL',
grid1 TYPE REF TO cl_gui_alv_grid,
grid2 TYPE REF TO cl_gui_alv_grid,
custom_container1 TYPE REF TO cl_gui_custom_container,
custom_container2 TYPE REF TO cl_gui_custom_container,
event_receiver TYPE REF TO lcl_event_receiver,
lt_exclude TYPE ui_functions,
ls_celltab TYPE lvc_s_styl,
lt_celltab TYPE lvc_t_styl.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-001.
PARAMETERS : p_cash AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b3.
PERFORM fieldcatalog_init USING gt_fieldcatalog[].
Selection-Screen----
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
SELECT-OPTIONS:s_chdate FOR zmpets_chargebk-createdon,
s_pernr FOR zmpets_shiphdr-pernr,
s_mvrsn FOR zmpets_shiphdr-movreason,
s_sin FOR zmpets_chargebk-shipdocnum NO INTERVALS
NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK b1.
PERFORM f_clear_fields.
CALL SCREEN 100.
CLASS lcl_event_receiver DEFINITION
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
§ 2.In event handler method for event TOOLBAR: Append own functions
by using event parameter E_OBJECT.
DATA: ls_toolbar TYPE stb_button.
append a separator to normal toolbar
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
new button -
MOVE 'PROCESSED' TO ls_toolbar-function.
MOVE icon_execute_object TO ls_toolbar-icon.
MOVE 'Process the Record'(110) TO ls_toolbar-quickinfo.
MOVE ' Process '(200) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
§ 3.In event handler method for event USER_COMMAND: Query your
function codes defined in step 2 and react accordingly.
DATA: lt_rows TYPE lvc_t_row.
CASE e_ucomm.
WHEN 'PROCESSED'.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
defaultoption = 'N'
textline1 = 'Do you want to process the selected documents?'
TEXTLINE2 = ' '
titel = 'Process Documents'
START_COLUMN = 25
START_ROW = 6
CANCEL_DISPLAY = 'X'
IMPORTING
answer = wf_res.
*--IF THE USER CONFIRMS 'YES',
IF wf_res = 'J'.
PERFORM f_modify_activity.
CALL METHOD grid1->refresh_table_display.
PERFORM SENDINGMAIL.
ENDIF.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
MODULE pbo_100 OUTPUT
MODULE pbo_100 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
w_repid = sy-repid.
IF custom_container1 IS INITIAL.
*get the data from charge back table
PERFORM select_table_chb.
create a custom container control for our ALV Control
CREATE OBJECT custom_container1
EXPORTING
container_name = cont_on_main
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = w_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(510).
ENDIF.
CREATE OBJECT grid1
EXPORTING i_parent = custom_container1.
Set a titlebar for the grid control
wf_layout-grid_title = 'Charge Back'(100).
allow to select multiple lines
wf_layout-sel_mode = 'C'.
wf_layout-stylefname = 'CELLTAB'.
Exclude all edit functions in this example since we do not need them:
PERFORM exclude_tb_functions CHANGING lt_exclude.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = wf_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
it_toolbar_excluding = lt_exclude
IT_HYPERLINK =
IT_ALV_GRAPHICS =
CHANGING
it_outtab = int_crb[]
it_fieldcatalog = gt_fieldcatalog.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR grid1.
SET HANDLER event_receiver->handle_toolbar FOR grid1.
CALL METHOD grid1->set_toolbar_interactive.
ENDIF. "IF grid1 IS INITIAL
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid1.
ENDMODULE. "pbo_100 OUTPUT
MODULE pai_100 INPUT
MODULE pai_100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
PERFORM f_clear_fields.
LEAVE PROGRAM.
WHEN 'CANCEL'.
PERFORM f_clear_fields.
LEAVE TO SCREEN 0.
WHEN 'BACK'.
PERFORM f_clear_fields.
LEAVE TO SCREEN 0.
ENDCASE.
CLEAR ok_code.
ENDMODULE. "pai_100 INPUT
**& Form select_table_chb
text
FORM select_table_chb.
IF p_cash = 'X'.
*Consider the pending documents also.
*get the documents which are not processed yet,
*Doctype -> 06 = Charge Back document type.
SELECT zmpets_shiphdrpernr pa0002vorna
zmpets_shiphdrmovreason zmpets_chargebkshipdocnum
zmpets_chargebkcreatedon zmpets_chargebkchargeamount
zmpets_shipactivversion zmpets_shipactivactivity
zmpets_shiphdr~vendor
adr6~smtp_addr
zmpets_167doc~empperid
INTO CORRESPONDING FIELDS OF TABLE int_crb_ver
FROM zmpets_chargebk
JOIN zmpets_shiphdr
ON zmpets_chargebkshipdocnum = zmpets_shiphdrshipdocno
JOIN zmpets_shipactiv
ON zmpets_chargebkshipdocnum = zmpets_shipactivpetsdocnumber
JOIN pa0002
ON zmpets_shiphdrpernr = pa0002pernr
JOIN lfa1
ON lfa1lifnr = zmpets_shiphdrvendor
JOIN adr6
ON adr6addrnumber = lfa1adrnr
JOIN zmpets_167doc
ON zmpets_167docpernr = pa0002pernr
WHERE zmpets_shipactiv~doctype = '06'
zmpets_shipactiv~activity NE '30'
ZMPETS_CHARGEBK~CREATEDON IN s_chdate
AND ZMPETS_SHIPHDR~pernr IN s_pernr
AND ZMPETS_SHIPHDR~MOVREASON IN s_mvrsn
AND ZMPETS_CHARGEBK~SHIPDOCNUM IN s_sin
AND zmpets_chargebk~loekz NE 'X'
AND zmpets_shipactiv~loekz NE 'X'
AND zmpets_shiphdr~loekz NE 'X'.
IF sy-subrc <> 0.
*Message is 'No Pending Documents Available.'.
MESSAGE s196(zm050).
ELSE.
LOOP AT int_crb_ver.
*Not yet processed. set to red
int_crb_ver-icon = '@0A@'.
MODIFY int_crb_ver.
ENDLOOP.
PERFORM f_filter_data_pending.
ENDIF.
ELSE.
*Get the document details from pa0002,zmpets_shipactiv,ZMPETS_CHARGEBK
*table.
*Consider document type as '01' during the selection.
*Doctype -> 06 = Charge Back document type.
SELECT zmpets_shiphdrpernr pa0002vorna zmpets_shiphdr~movreason
zmpets_chargebkshipdocnum zmpets_chargebkcreatedon
zmpets_chargebkchargeamount zmpets_shipactivversion
zmpets_shipactivactivity zmpets_shiphdrvendor
*adr6~smtp_addr
zmpets_167doc~empperid
INTO CORRESPONDING FIELDS OF TABLE int_crb_ver
FROM zmpets_chargebk
JOIN zmpets_shiphdr
ON zmpets_chargebkshipdocnum = zmpets_shiphdrshipdocno
JOIN zmpets_shipactiv
ON zmpets_chargebkshipdocnum = zmpets_shipactivpetsdocnumber
JOIN pa0002
ON zmpets_shiphdrpernr = pa0002pernr
JOIN lfa1
ON lfa1lifnr = zmpets_shiphdrvendor
JOIN adr6
ON adr6addrnumber = lfa1adrnr
JOIN zmpets_167doc
ON zmpets_167docpernr = pa0002pernr
WHERE zmpets_chargebk~createdon IN s_chdate
AND zmpets_shiphdr~pernr IN s_pernr
AND zmpets_shiphdr~movreason IN s_mvrsn
AND zmpets_chargebk~shipdocnum IN s_sin
AND zmpets_shipactiv~activity NE '30'
AND zmpets_shipactiv~doctype = '06'
AND zmpets_chargebk~loekz NE 'X'
AND zmpets_shipactiv~loekz NE 'X'
AND zmpets_shiphdr~loekz NE 'X'.
IF sy-subrc <> 0.
*Message is 'No Charge Back Documents Available.'.
MESSAGE s201(zm050).
ELSE.
PERFORM f_filter_data.
ENDIF.
ENDIF.
ENDFORM. "select_table_chb
*& Form UPDATE_RECORDS
text
--> p1 text
<-- p2 text
FORM update_records TABLES p_et_index_rows
STRUCTURE lvc_s_row.
DATA: ls_selected_line LIKE lvc_s_row,
lf_row_index TYPE lvc_index.
LOOP AT p_et_index_rows INTO ls_selected_line.
lf_row_index = ls_selected_line-index.
ENDLOOP.
ENDFORM. " UPDATE_RECORDS
**& Form fieldcatalog_init
text
-->P_GT_FIELDCATALOG[] text
FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat.
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'SEL'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-col_pos = 1.
ls_fieldcatalog-edit = 'X'.
ls_fieldcatalog-reptext = 'Select for Processing'.
ls_fieldcatalog-coltext = 'Select for Processing'.
ls_fieldcatalog-seltext = 'Select for Processing'.
ls_fieldcatalog-tooltip = 'Select for Processing'.
ls_fieldcatalog-checkbox = 'X'.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'ICON'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-datatype = 'CHAR'.
ls_fieldcatalog-col_pos = 2.
ls_fieldcatalog-intlen = '4'.
ls_fieldcatalog-reptext = 'Status'.
ls_fieldcatalog-coltext = 'Status'.
ls_fieldcatalog-seltext = 'Status'.
ls_fieldcatalog-tooltip = 'Status'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'PERNR'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-datatype = 'NUMC'.
ls_fieldcatalog-col_pos = 2.
ls_fieldcatalog-intlen = '8'.
ls_fieldcatalog-reptext = 'Employee Number'.
ls_fieldcatalog-coltext = 'Employee Number'.
ls_fieldcatalog-seltext = 'Employee Number'.
ls_fieldcatalog-tooltip = 'Employee Number'.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'VORNA'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-col_pos = 3 .
ls_fieldcatalog-datatype = 'CHAR'.
ls_fieldcatalog-outputlen = '20'.
ls_fieldcatalog-reptext = 'Employee Name'.
ls_fieldcatalog-coltext = 'Employee Name'.
ls_fieldcatalog-seltext = 'Employee Name'.
ls_fieldcatalog-tooltip = 'Employee Name'.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'MOVREASON'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-col_pos = 4.
ls_fieldcatalog-datatype = 'NUMC'.
ls_fieldcatalog-outputlen = '10'.
ls_fieldcatalog-reptext = 'Move Reason'.
ls_fieldcatalog-coltext = 'Move Reason'.
ls_fieldcatalog-seltext = 'Move Reason'.
ls_fieldcatalog-tooltip = 'Move Reason'.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'SHIPDOCNUM'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-datatype = 'NUMC'.
ls_fieldcatalog-outputlen = '10'.
ls_fieldcatalog-col_pos = 5.
ls_fieldcatalog-reptext = 'Shipping Document Number'.
ls_fieldcatalog-coltext = 'Shipping Document Number'.
ls_fieldcatalog-seltext = 'Shipping Document Number'.
ls_fieldcatalog-tooltip = 'Shipping Document Number'.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'CREATEDON'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-col_pos = 6.
ls_fieldcatalog-datatype = 'DATS'.
ls_fieldcatalog-outputlen = '8'.
ls_fieldcatalog-reptext = 'Created On'.
ls_fieldcatalog-coltext = 'Created On'.
ls_fieldcatalog-seltext = 'Created On'.
ls_fieldcatalog-tooltip = 'Created On'.
ls_fieldcatalog-DO_sum = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'CHARGEAMOUNT'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-col_pos = 7.
ls_fieldcatalog-datatype = 'CURR'.
ls_fieldcatalog-outputlen = '13'.
ls_fieldcatalog-reptext = 'Charge Back Amount'.
ls_fieldcatalog-coltext = 'Charge Back Amount'.
ls_fieldcatalog-seltext = 'Charge Back Amount'.
ls_fieldcatalog-tooltip = 'Charge Back Amount'.
ls_fieldcatalog-DO_sum = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ENDFORM. "fieldcatalog_init
*& Form f_modify_activity
Modify the activity to 79 in zmpets_shipaciv table.
--> p1 text
<-- p2 text
FORM f_modify_activity .
REFRESH int_crb_mail.
int_crb_mail[] = int_crb[].
*All the document number which is to be processed is stored in
*the internel table 'INT_SIN'.
LOOP AT int_crb INTO int_crb.
IF int_crb-sel ='X'.
MOVE int_crb-shipdocnum TO int_sin.
APPEND int_sin.
CLEAR int_sin.
*Removing the processed documents.
DELETE int_crb.
ENDIF.
CLEAR int_crb.
ENDLOOP.
*Get the details from shipactiv table.
IF int_sin[] IS NOT INITIAL.
SELECT * FROM zmpets_shipactiv
INTO TABLE int_shipactiv
FOR ALL ENTRIES IN int_sin
WHERE petsdocnumber = int_sin-shipdocnum.
*Modify the activity code, version, actual date and last changed date.
SORT int_shipactiv BY petsdocnumber version DESCENDING.
CLEAR wf_tabix.
LOOP AT int_shipactiv.
wf_tabix = sy-tabix.
AT NEW petsdocnumber.
READ TABLE int_shipactiv INDEX wf_tabix.
int_shipactiv-activity = '030'.
int_shipactiv-version = int_shipactiv-version + 1.
int_shipactiv-actdate = sy-datum.
int_shipactiv-lastchangedby = sy-uname.
int_shipactiv-lastchangedt = sy-datum.
*Modify the data base table
MODIFY zmpets_shipactiv FROM int_shipactiv.
ENDAT.
CLEAR int_shipactiv.
AT LAST.
*Message is 'Data Processed Successfully.'.
MESSAGE s203(zm050).
ENDAT.
ENDLOOP.
*-send mail to the vendor and employee that the shipment is cleared for
LOOP AT int_crb_mail WHERE sel = 'X'.
PERFORM f_send_mail.
ENDLOOP.
REFRESH int_crb_mail.
CALL SELECTION-SCREEN 1000.
ELSE.
*Message is 'No Data Selected for Processing.'.
MESSAGE s200(zm050).
ENDIF.
ENDFORM. " f_modify_activity
*& Form f_clear_fields
text
--> p1 text
<-- p2 text
FORM f_clear_fields .
CLEAR int_crb.
CLEAR int_crb_ver.
CLEAR int_sin.
REFRESH int_crb.
REFRESH int_crb_ver.
REFRESH int_sin.
CLEAR int_shipactiv.
REFRESH int_shipactiv.
CLEAR wf_flag.
CLEAR wf_tabix.
ENDFORM. " f_clear_fields
*& Form f_filter_data
text
--> p1 text
<-- p2 text
FORM f_filter_data .
*Take the latest Version Data.
*take all the activities, including the activity '30'.
then put the details in internal table 'INT_CRB'.
SORT int_crb_ver BY shipdocnum version DESCENDING.
CLEAR wf_tabix.
CLEAR int_crb.
REFRESH int_crb.
LOOP AT int_crb_ver.
wf_tabix = sy-tabix.
AT NEW shipdocnum.
READ TABLE int_crb_ver INDEX wf_tabix.
MOVE-CORRESPONDING int_crb_ver TO int_crb.
APPEND int_crb.
CLEAR int_crb.
ENDAT.
ENDLOOP.
IF int_crb[] IS INITIAL.
*Message is 'No Records Available.'.
MESSAGE s202(zm050).
ELSE.
CLEAR wf_tabix.
LOOP AT int_crb.
wf_tabix = sy-tabix.
REFRESH lt_celltab.
ls_celltab-fieldname = 'SEL'.
IF int_crb-activity = '030'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
*status becomes green. ie processed
int_crb-icon = '@08@'. "Green
ELSE.
ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
*status set to red. ie not yet processed
int_crb-icon = '@0A@'. "Red
ENDIF.
INSERT ls_celltab INTO TABLE lt_celltab.
INSERT LINES OF lt_celltab INTO TABLE int_crb-celltab.
MODIFY int_crb INDEX wf_tabix.
ENDLOOP.
ENDIF.
ENDFORM. " f_filter_data
*& Form f_filter_data
text
--> p1 text
<-- p2 text
FORM f_filter_data_pending.
*Take the latest Version Data.
*take all the activities, including the activity '30'.
*then filter it with out the activities '30' and having the lastest
*version. then put the details in internal table 'INT_CRB'.
SORT int_crb_ver BY shipdocnum version DESCENDING.
CLEAR wf_tabix.
CLEAR int_crb.
REFRESH int_crb.
LOOP AT int_crb_ver.
wf_tabix = sy-tabix.
AT NEW shipdocnum.
READ TABLE int_crb_ver INDEX wf_tabix.
IF int_crb_ver-activity NE '030'.
MOVE-CORRESPONDING int_crb_ver TO int_crb.
APPEND int_crb.
CLEAR int_crb.
ENDIF.
ENDAT.
ENDLOOP.
IF int_crb[] IS INITIAL.
*Message is 'No Records Available.'.
MESSAGE s202(zm050).
ENDIF.
ENDFORM. " f_filter_data_pending
*& Form EXCLUDE_TB_FUNCTIONS
text
<--P_LT_EXCLUDE text
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
DATA ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
APPEND ls_exclude TO pt_exclude.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*& Form f_send_mail
text
--> p1 text
<-- p2 text
FORM f_send_mail .
*store the vendor name, vendor email id , employee name and employee
*email id in the internal table int_crb
Creation of the document to be sent
CLEAR doc_chng.
REFRESH objpack.
REFRESH objhead.
REFRESH reclist.
REFRESH objtxt.
File Name
doc_chng-obj_name = 'SHIPMENT'.
Mail Subject
CONCATENATE 'Shipment Document No.' int_crb_mail-shipdocnum
'Cleared.'
INTO doc_chng-obj_descr SEPARATED BY ' '.
Mail Contents
objtxt-line = 'Hi,'.
APPEND objtxt.
objtxt-line = ' '.
APPEND objtxt.
CONCATENATE 'Shipment Document Number ' int_crb_mail-shipdocnum
' cleared for move.' INTO objtxt-line SEPARATED BY ' '.
APPEND objtxt.
objtxt-line = ' '.
APPEND objtxt.
CLEAR objtxt.
objtxt-line = 'Regards '.
APPEND objtxt.
objtxt-line = ' '.
APPEND objtxt.
objtxt-line = 'SAP '.
APPEND objtxt.
CLEAR objtxt.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN(
objtxt ).
Creation of the entry for the compressed document
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
Completing the recipient list
target recipent
CLEAR reclist.
reclist-receiver = int_crb_mail-empperid. "employee email ID
"wf_empperid.
reclist-express = 'X'.
reclist-rec_type = 'U'.
APPEND reclist.
copy recipents
CLEAR reclist.
reclist-receiver = 'anversha.shahul@'."int_crb_mail-smtp_addr
reclist-express = 'X'.
reclist-rec_type = 'U'.
reclist-copy = 'X'.
APPEND reclist.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
COMMIT WORK.
SUBMIT rsconn01
WITH mode = 'INT'
WITH output = ' '
AND RETURN.
ENDFORM. " f_send_mail
rgds
anver
pls mark hlpful answers -
How to raise error message from PAI of oops ALV report
Hi All,
I have a requirement to raise error message form editable oops alv . After entering the data and then press SAVE button .
Please help.
Thanks in AdvanceHI SK,
Write a Local class (Event Handeler) to handel the events. In Editable ALV once the user enter a value, CL_GUI_ALV_GRID will raise an event called DATA_CHANGED.
1. Define and Implement a local class to handle that event.
In the implementation of this class you need to get data from imported object to an internal table, then compare the same with the ALV output table.
* Local Class to handler the events raised from the ALV Grid
CLASS LCL_EVENT_HANDLER DEFINITION.
PUBLIC SECTION.
* Method to handel EDIT event, DATA_CHANGED of CL_GUI_ALV_GRID
METHODS : ON_DATA_CHANGE FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID
IMPORTING ER_DATA_CHANGED.
ENDCLASS.
* Event handler class Implementation
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
METHOD ON_DATA_CHANGE.
DATA : LT_MODIFY TYPE LVC_T_MODI,
LS_MODIFY TYPE LVC_S_MODI.
* Copying changed data into intenal table from Object
LT_MODIFY = ER_DATA_CHANGED->MT_MOD_CELLS.
* Modifying the ouptut table with the changed values
IF LT_MODIFY[] IS NOT INITIAL.
*Compare the ALV Output table with LT_MODIFY
ENDIF.
ENDMETHOD.
ENDCLASS.
Then raise a message on required condition in the same method.
Note: To trigger the above method, you need to set event handler before displaying ALV (before calling method SET_TABLE_FOR_FIRST_DISPLAY)
* Creating object for the Local event handler class
CREATE OBJECT GR_HANDLER.
* Set handler (call method of Event_handler) to handler Edit event
SET HANDLER GR_HANDLER->ON_DATA_CHANGE FOR GR_GRID.
Regards,
Vijay -
Runtime error while trying to execute custom F4 help in OOP ALV grid.
Dear All,
I am trying to add custom search help for one of my column in ALV grid. I'm using OOP ALV, when i click for search help for that column, the system shows runtime error like below.
I am new to OOP concept and tried to follow program BCALV_EDIT_03. But not getting this error occur. Please help me.
With regards.Hi,
In order to be able to provide a search help for a field in an ALV you must do the following things.
1) The field where F4 help need to be attached needs to be made editable.
2) Create an event handler class to handle the ONF4 event. You can refer the following code:
CLASS lcl_alv1_handler DEFINITION.
PUBLIC SECTION.
"Tohandle F4 helps
METHODS handle_f4 FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING e_fieldname e_fieldvalue es_row_no er_event_data
et_bad_cells e_display.
ENDCLASS.
CLASS lcl_alv1_handler IMPLEMENTATION.
METHOD handle_f4.
CASE e_fieldname.
WHEN 'LIFNR'. "Set F4 for courier vendor
SELECT lifnr name1 FROM lfa1 INTO TABLE lt_lifnr.
IF lt_lifnr IS NOT INITIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'LIFNR'
window_title = 'Vendors'
value_org = 'S'
TABLES
value_tab = lt_lifnr
return_tab = lt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc = 0.
READ TABLE gt_final INTO wa_final_t INDEX es_row_no-row_id.
IF sy-subrc = 0.
READ TABLE lt_return INTO wa_return INDEX 1.
IF sy-subrc = 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_return-fieldval
IMPORTING
output = lv_lifnr.
wa_final_t-lifnr = lv_lifnr.
MODIFY gt_final FROM wa_final_t INDEX es_row_no-row_id.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDCASE.
CALL METHOD o_alv->refresh_table_display.
ENDMETHOD.
ENDCLASS.
In the above method, GT_FINAL-LIFNR is being overwritten by the LIFNR you had selected from F4 help. So we will call the refresh_table_display after it to see the result in the ALV.
3) After creating the ALV object, add the fields to which the F4 has to be added. For this you
need to declare an internal table based on lvc_t_f4. Use the following code. Here O_ALV is my ALV object.:
CREATE OBJECT o_container
EXPORTING
container_name = 'CUSTCON'
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 o_alv
EXPORTING
i_parent = o_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.
CLEAR : gt_f4, wa_f4.
wa_f4-fieldname = 'LIFNR'.
wa_f4-register = 'X'.
wa_f4-getbefore = space.
wa_f4-chngeafter = space.
APPEND wa_f4 TO gt_f4.
Here I am assigning F4 to LIFNR field in the final internal table that is displayed using ALV.
After this register this field for F4.
CALL METHOD o_alv->register_f4_for_fields
EXPORTING
it_f4 = gt_f4.
CREATE OBJECT o_alv_handler.
SET HANDLER : o_alv_handler->handle_f4 FOR o_alv1.
The object o_alv_handler is created based on the event handler class.
I hope that this will solve your issue. Revert if this is solved.
Rgards,
Abijith -
hi experts,
event double click.
when double click on vbeln it should go to va03 transaction . how would i do that in oops alv.hai,
you can go through code below .
*& Report Z_CLARIFY *
REPORT Z_CLARIFY .
DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: L_VALID TYPE C,
V_FLAG,
V_DATA_CHANGE,
V_ROW TYPE LVC_S_ROW,
V_COLUMN TYPE LVC_S_COL,
V_ROW_NUM TYPE LVC_S_ROID.
DATA: IT_ROW_NO TYPE LVC_T_ROID,
X_ROW_NO TYPE LVC_S_ROID.
DATA:BEGIN OF ITAB OCCURS 0,
VBELN LIKE LIKP-VBELN,
POSNR LIKE LIPS-POSNR,
CELLCOLOR TYPE LVC_T_SCOL, "required for color
DROP(10),
END OF ITAB.
*The Below Definitions Must.....
DATA:
Reference to document
DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT,
Reference to split container
DG_SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
Reference to grid container
DG_PARENT_GRID TYPE REF TO CL_GUI_CONTAINER,
Reference to html container
DG_HTML_CNTRL TYPE REF TO CL_GUI_HTML_VIEWER,
Reference to html container
DG_PARENT_HTML TYPE REF TO CL_GUI_CONTAINER.
"up to here
CLASS lcl_event_handler DEFINITION
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
**Hot spot Handler
HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
**Double Click Handler
HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN ES_ROW_NO,
TOP_OF_PAGE FOR EVENT TOP_OF_PAGE "event handler
OF CL_GUI_ALV_GRID
IMPORTING E_DYNDOC_ID.
END_OF_LIST FOR EVENT end_of_list "event handler
OF CL_GUI_ALV_GRID
IMPORTING E_DYNDOC_ID.
ENDCLASS. "lcl_event_handler DEFINITION
CLASS lcl_event_handler IMPLEMENTATION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
*Handle Hotspot Click
METHOD HANDLE_HOTSPOT_CLICK .
CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
V_ROW = E_ROW_ID.
V_COLUMN = E_COLUMN_ID.
V_ROW_NUM = ES_ROW_NO.
MESSAGE I000 WITH V_ROW 'clicked'.
CLEAR IT_ROW_NO[].
X_ROW_NO-ROW_ID = V_ROW.
APPEND X_ROW_NO TO IT_ROW_NO .
CALL METHOD G_GRID->SET_SELECTED_ROWS
EXPORTING
IT_ROW_NO = IT_ROW_NO.
ENDMETHOD. "lcl_event_handler
*Handle Double Click
METHOD HANDLE_DOUBLE_CLICK.
CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
V_ROW = E_ROW.
V_COLUMN = E_COLUMN.
V_ROW_NUM = ES_ROW_NO.
IF E_COLUMN = 'VBELN'.
SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
ENDIF.
IF E_COLUMN = 'POSNR'.
SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN."
ENDIF.
ENDMETHOD. "handle_double_click
METHOD END_OF_LIST. "implementation
Top-of-page event
PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
ENDMETHOD. "top_of_page
METHOD TOP_OF_PAGE. "implementation
Top-of-page event
PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
ENDMETHOD. "top_of_page
ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION
*& Global Definitions
DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
"Container1
G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
DATA: OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM,
G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
GS_LAYOUT TYPE LVC_S_LAYO.
data: v_lines type i.
data: v_line(3) type c.
*- Fieldcatalog for First and second Report
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
X_FIELDCAT TYPE LVC_S_FCAT,
LS_VARI TYPE DISVARIANT.
START-OF_SELECTION
START-OF-SELECTION.
SELECT VBELN
POSNR
FROM LIPS
UP TO 20 ROWS
INTO CORRESPONDING FIELDS OF TABLE ITAB.
describe table itab lines v_lines.
END-OF-SELECTION.
IF NOT ITAB[] IS INITIAL.
CALL SCREEN 100.
ELSE.
MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
ENDIF.
*& Form CREATE_AND_INIT_ALV
text
FORM CREATE_AND_INIT_ALV .
DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
"attention.....from here
"split your container here...into two parts
"create the container
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = 'SCR100_CUST'.
"this is for top of page
Create TOP-Document
CREATE OBJECT DG_DYNDOC_ID
EXPORTING STYLE = 'ALV_GRID'.
Create Splitter for custom_container
CREATE OBJECT DG_SPLITTER
EXPORTING PARENT = G_CUSTOM_CONTAINER
ROWS = 2
COLUMNS = 1.
Split the custom_container to two containers and move the reference
to receiving containers g_parent_html and g_parent_grid
"i am allocating the space for grid and top of page
CALL METHOD DG_SPLITTER->GET_CONTAINER
EXPORTING
ROW = 1
COLUMN = 1
RECEIVING
CONTAINER = DG_PARENT_HTML.
CALL METHOD DG_SPLITTER->GET_CONTAINER
EXPORTING
ROW = 2
COLUMN = 1
RECEIVING
CONTAINER = DG_PARENT_GRID.
CALL METHOD DG_SPLITTER->GET_CONTAINER
EXPORTING
ROW = 2
COLUMN = 1
RECEIVING
CONTAINER = DG_PARENT_HTML.
CALL METHOD DG_SPLITTER->GET_CONTAINER
EXPORTING
ROW = 1
COLUMN = 1
RECEIVING
CONTAINER = DG_PARENT_GRID.
"you can set the height of it
Set height for g_parent_html
CALL METHOD DG_SPLITTER->SET_ROW_HEIGHT
EXPORTING
ID = 1
HEIGHT = 5.
"from here as usual..you need to specify parent as splitter part
"which we alloted for grid
CREATE OBJECT G_GRID
EXPORTING I_PARENT = DG_PARENT_GRID.
Set a titlebar for the grid control
CLEAR GS_LAYOUT.
GS_LAYOUT-GRID_TITLE = TEXT-003.
GS_LAYOUT-ZEBRA = SPACE.
GS_LAYOUT-CWIDTH_OPT = 'X'.
GS_LAYOUT-NO_ROWMARK = 'X'.
GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
CALL METHOD G_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
CREATE OBJECT G_HANDLER.
SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
SET HANDLER G_HANDLER->END_OF_LIST FOR G_GRID.
SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.
DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
DATA: L_INDEX TYPE SY-TABIX.
"Here i am changing the color of line 1,5,10...
"so you can change the color of font conditionally
LOOP AT ITAB.
L_INDEX = SY-TABIX.
IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
LS_CELLCOLOR-FNAME = 'VBELN'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '0'.
LS_CELLCOLOR-COLOR-INV = '1'.
APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
LS_CELLCOLOR-FNAME = 'POSNR'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '0'.
LS_CELLCOLOR-COLOR-INV = '1'.
APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
ENDIF.
ENDLOOP.
setting focus for created grid control
CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
EXPORTING
CONTROL = G_GRID.
Build fieldcat and set editable for date and reason code
edit enabled. Assign a handle for the dropdown listbox.
PERFORM BUILD_FIELDCAT.
PERFORM SET_DRDN_TABLE.
Optionally restrict generic functions to 'change only'.
(The user shall not be able to add new lines).
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
**Vaiant to save the layout
LS_VARI-REPORT = SY-REPID.
LS_VARI-HANDLE = SPACE.
LS_VARI-LOG_GROUP = SPACE.
LS_VARI-USERNAME = SPACE.
LS_VARI-VARIANT = SPACE.
LS_VARI-TEXT = SPACE.
LS_VARI-DEPENDVARS = SPACE.
**Calling the Method for ALV output
CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
IS_VARIANT = LS_VARI
IS_LAYOUT = GS_LAYOUT
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = IT_FIELDCAT
IT_OUTTAB = ITAB[].
"do these..{
Initializing document
CALL METHOD DG_DYNDOC_ID->INITIALIZE_DOCUMENT.
Processing events
CALL METHOD G_GRID->LIST_PROCESSING_EVENTS
EXPORTING
I_EVENT_NAME = 'TOP_OF_PAGE'
I_DYNDOC_ID = DG_DYNDOC_ID.
"end }
Set editable cells to ready for input initially
CALL METHOD G_GRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.
ENDFORM. "CREATE_AND_INIT_ALV
*& Form EXCLUDE_TB_FUNCTIONS
text
-->PT_EXCLUDE text
FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
Only allow to change data not to create new entries (exclude
generic functions).
DATA LS_EXCLUDE TYPE UI_FUNC.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*& Form build_fieldcat
Fieldcatalog
FORM BUILD_FIELDCAT .
DATA: L_POS TYPE I.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-NO_ZERO = 'X'.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-HOTSPOT = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Item'(025).
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
X_FIELDCAT-FIELDNAME = 'DROP'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-DRDN_HNDL = '1'.
X_FIELDCAT-DRDN_ALIAS = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
ENDFORM. " build_fieldcat
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF G_CUSTOM_CONTAINER IS INITIAL.
**Initializing the grid and calling the fm to Display the O/P
PERFORM CREATE_AND_INIT_ALV.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
there are many such examples
goto->se38->type bcalv* and press f4, u can see many examples.
Reward points if helpful.
Thanks and regards
Swetha Singh. -
OO ALV Cell Merge Problem when editable fields
Hi there!
I'm using OO ALV ( CL_GUI_ALV_GRID ) and experiencing a strange problem.
I'm interested in the cells merging functionality of ALV, when i sort data for a specific field.
It works fine but only if i do not set any field as editable ( lvc_s_fcat-edit = 'X' ).
For some reason ALV loses some of its functionality when you set a field as editable.
I've noticed it also with the functionality of expanding/supressing data when using subtotals.
If any field is set as editable then subtotals come always expanded, you cannot supress them...
Has anyone else experienced somethng like this before? Any help will be appreciated!
BR
George ZervasHi,
Check This [Thread|http://forums.sdn.sap.com/thread.jspa?threadID=928573] to solve your issue.
Check the User Command, first line should be call method cl_gui->check_changed_data().
Check this [url|http://wiki.sdn.sap.com/wiki/display/ABAP/InteractiveEditableOOALVgridwithdynamicitab,FCATandENTERkeyeventtrigger] for code to work on Interactive Editable OO ALV grid .
Hope will solve your issue.
Regards,
Saravana.S
Edited by: saravanasap on Feb 14, 2012 7:38 AM -
Prob. while using error message in OOPS ALV
Friends,
I have developed an OOPS ALV to display the records with cost field as editable. And the cost should not accept decimals values, if the user enter the same (12.56) and click the save button (user-defined) then need to populate the error message. I am populating the error message, then the user change the value (12) and click the save, then in the ALV screen the chanegd value 12 is automatically back to prv. one 12.56 and the same error messgae is displaying.
If i change the message type from Error to Info, then its working fine... but the client wants only error message. So anybody came across the same scenario? if yes.. pls share the solution..
Ganesh CHi,
In this case, after the error message issued though the value is corrected , corrected data is not transferred to progarm.
Program still works with old data. Check how you are issuing message and how you refereshing the table after user inputs.
you can check program BCALV_EDIT_03 for vlidating fileds.
I believe you can simply refer a data element which does not accepts decimal values.
Regards,
Ravi.
Maybe you are looking for
-
Accounting document not generated for cancled credit memo
Hi, its related to rebet den cancled credit memo.but accounting document not generated. after that created new rebet and accounting document generated..so in document flow status showing open for cancled credti memo. how to delete or clear this? or h
-
Here's a question about working with iweb and Aperture that I asked in the iweb group with no luck. Here's the deal: iweb is not updating available Aperture photos. What is wanted, of course, is to work in both apps, and for newly added photos to Ape
-
Why am a i getting a question mark in a box instead of an apple upon start
My mac pro 2008 has given me a grey screen, tried restarting got same scren with a box that has a question mark....can you please help me accessing my mac pro? much appreciated
-
How do you print the slides in the question pool in captivate 6?
how do you print the slides in the question pool in captivate 6?
-
Problem with String to Int conversion
Dear Friends, Problem with String to Int conversion I am having a column where most of the values are numeric. Only 4 values are non numeric. I have replaces those non numeric values to numeric in order to maintain the data type. CASE Grade.Grade WH