ALV Editable
HI all,
i am working on ALV Editable display where i need to save the edited data.i have a pblm while saving the data.when i am changing one cell the remaining cells data is getting as blank.please help here is my code in the perform of the evernt data_changed_finished.
loop at p_et_good_cells into wa_et_good_cells.
READ TABLE it_final ASSIGNING <fs_final> INDEX wa_et_good_cells-row_id.
IF sy-subrc = 0.
CASE wa_et_good_cells-fieldname.
WHEN 'DATE25'.
<fs_final>-date25 = wa_et_good_cells-value.
PERFORM change_hrs_sd CHANGING it_final.
WHEN 'DATE26'.
<fs_final>-date26 = wa_et_good_cells-value.
WHEN 'DATE27'.
<fs_final>-date27 = wa_et_good_cells-value.
WHEN 'DATE28'.
<fs_final>-date28 = wa_et_good_cells-value.
WHEN 'DATE29'.
<fs_final>-date29 = wa_et_good_cells-value.
WHEN 'DATE30'.
<fs_final>-date30 = wa_et_good_cells-value.
WHEN 'DATE31'.
<fs_final>-date31 = wa_et_good_cells-value.
WHEN 'DATE32'.
<fs_final>-date32 = wa_et_good_cells-value.
WHEN 'DATE33'.
<fs_final>-date33 = wa_et_good_cells-value.
WHEN 'DATE34'.
<fs_final>-date34 = wa_et_good_cells-value.
WHEN 'DATE35'.
<fs_final>-date35 = wa_et_good_cells-value.
WHEN 'DATE36'.
<fs_final>-date36 = wa_et_good_cells-value.
WHEN 'DATE37'.
<fs_final>-date37 = wa_et_good_cells-value.
WHEN 'DATE38'.
<fs_final>-date38 = wa_et_good_cells-value.
WHEN 'DATE39'.
<fs_final>-date39 = wa_et_good_cells-value.
WHEN 'DATE40'.
<fs_final>-date40 = wa_et_good_cells-value.
WHEN 'DATE41'.
<fs_final>-date41 = wa_et_good_cells-value.
WHEN 'DATE42'.
<fs_final>-date42 = wa_et_good_cells-value.
WHEN 'DATE43'.
<fs_final>-date43 = wa_et_good_cells-value.
WHEN 'DATE44'.
<fs_final>-date44 = wa_et_good_cells-value.
WHEN 'DATE45'.
<fs_final>-date45 = wa_et_good_cells-value.
WHEN 'DATE46'.
<fs_final>-date46 = wa_et_good_cells-value.
WHEN 'DATE47'.
<fs_final>-date47 = wa_et_good_cells-value.
WHEN 'DATE48'.
<fs_final>-date48 = wa_et_good_cells-value.
ENDCASE.
clear wa_et_good_cells.
unassign <fs_final>.
ENDIF.
ENDLOOP.
please help.
Hi Kiran,
u can try the same thing like this:-
METHOD handle_data_changed.
error_in_data = space.
CALL METHOD perform_checks( er_data_changed ).
IF error_in_data = 'X'.
CALL METHOD er_data_changed->display_protocol.
ENDIF.
ENDMETHOD. "handle_data_changed
METHOD perform_checks.
PERFORM data_checks USING pr_data_changed
CHANGING error_in_data.
ENDMETHOD.
FORM data_checks USING
p_data_changed TYPE REF TO cl_alv_changed_data_protocol
CHANGING p_error.
DATA: ls_good TYPE lvc_s_modi.
Data: l_tabix LIKE sy-tabix.
DATA: ls_fcat LIKE LINE OF p_data_changed->mt_fieldcatalog.
FIELD-SYMBOLS: <l_fs> TYPE ANY.
LOOP AT p_data_changed->mt_mod_cells INTO ls_good.
CLEAR:l_htype.
CASE ls_good-fieldname.
WHEN 'your field name here'.
CHECK ls_good-value IS NOT INITIAL.
variable = ls_good-value.
p_error = 'X'.
IF NOT p_error = 'X'.
CALL METHOD p_data_changed->get_cell_value
EXPORTING
i_row_id = ls_good-row_id
i_fieldname = 'IField name here'
IMPORTING
e_value = l_instance.
Checking the ALV Grid from which the method is being called
READ TABLE p_data_changed->mt_fieldcatalog
INTO ls_fcat WITH KEY fieldname = 'field name here'.
IF sy-subrc <> 0.
Message.
Modifying the Main Internal Table--Level 1 and 2
*&>>
READ TABLE <dyn_table> INTO <dyn_wa> INDEX ls_good-row_id.
IF sy-subrc = 0.
ASSIGN COMPONENT ls_good-fieldname OF
STRUCTURE <dyn_wa> TO <l_fs>.
<l_fs> = ls_good-value.
MOVE-CORRESPONDING <dyn_wa> TO wa_final.
MODIFY <dyn_table> FROM <dyn_wa> INDEX ls_good-row_id
ASSIGNING <l_fs> TRANSPORTING (ls_good-fieldname).
*Code for capturing the changed data in first grid "29/9/2008
READ TABLE <dyn_table> INTO <dyn_wa> INDEX ls_good-row_id.
READ TABLE it_final WITH KEY instance = l_instance.
MOVE-CORRESPONDING it_final TO it_final_tmp.
MOVE-CORRESPONDING <dyn_wa> TO it_final_tmp.
APPEND it_final_tmp. (same as your final table)
ENDIF.
PERFORM insert_modify_table USING p_data_changed CHANGING p_error.
ENDFORM. " DATA_CHECKS
In form insert_modify_table u can use the function module to save data.
Thanks & Regards
Ruchi Tiwari
Similar Messages
-
Hello Abapers,
I am not getting the desired output as per example.
I have followed all the steps as per the example but still a looser can anyone help me in this.
When I execute the program I get the following run time error
Field symbol has not been assigned.
I tried commenting the subroutine call
1} perform Change_fieldcatalogue and fetch data.
and i was getting the 2 custom container (top, bottom) on the screen output this time.
I have also created a screen 600 with all the attributes.
But i have doubt with this statement
Create a Custom container and name it CCONT and OK code as OK_CODE.
Save check and Activate the screen painter.
I hope on the layout screen the one which says custom control is only the custom container but i see that the fct code box is not highlighted then how can i assign a fctcode.
Could you plz also clear this.
Thanks in advance.
Ranjith Nambiar
Program code below
A small note about this program
*& AS : ALV report which displays the contents of the table T006
*& (as a docking container in the bottom) along with the
*& editable ALV which contains the ALV fieldcatalogue table structure.
*& With the available toolbar options of the editable ALV in the output,
*& user can change the fieldcatalogue as per his requirement.
*& When the user clicks 'SUBMIT',the display of the ALV with table T006
*& gets modified and customised accordingly to the user's requirement.
REPORT ZNRD_ALV_EDITABLE.
* Structure declaration for t006
types : begin of ty_t006.
include structure t006.
types : end of ty_t006.
* Internal table and work area declaration for t006.
data : it_t006 type standard table of ty_t006,
wa_t006 type ty_t006.
* Declaration for ALV
data : ok_code type sy-ucomm, " Ok code.
it_fcat type lvc_t_fcat, " Fieldcatalogue.
it_fieldcat type lvc_t_fcat, " Fieldcatalogue for Fieldcatalogue itself.
it_layout type lvc_s_layo.
*Declaration for toolbar functions
data : it_excl_func type ui_functions,
* Controls to display it_t006 and its fieldcatalogue
cont_dock type ref to cl_gui_docking_container,
cont_alvgd type ref to cl_gui_alv_grid,
* Controls to display fieldcatalogue as editable alv gridand container
cont_cust type ref to cl_gui_custom_container,
cont_editalvgd type ref to cl_gui_alv_grid.
initialization.
start-of-selection.
* Local class definition for data changed in fieldcatalogue alv
CLASS lcl_event_receiver definition.
public section.
methods handle_data_changed
for event data_changed of cl_gui_alv_grid
importing er_data_changed.
endclass. " lcl_event_receiver definition.
* Local class implementation for data changed in fieldcatalogue alv
CLASS lcl_event_receiver implementation.
method handle_data_changed.
endmethod. " handle_data_changed.
endclass. "lcl_event_receiver implementation
* Data declaration for event receiver
data : event_receiver type ref to lcl_event_receiver.
end-of-selection.
* Setting the screen for alv output for table display and changed fieldcatalogue display
set screen 600.
*& Module STATUS_0600 OUTPUT
* text
MODULE STATUS_0600 OUTPUT.
SET PF-STATUS 'STATUS600'.
SET TITLEBAR 'TITLE600'.
* Create ALV grid if doesn't exits.
if cont_dock is initial.
perform Create_alv.
endif.
ENDMODULE. " STATUS_0600 OUTPUT
*& Form Create_alv
* text
* --> p1 text
* <-- p2 text
FORM Create_alv.
* Create a docking container and dock the control at the bottom
create object cont_dock
exporting
dynnr = '600'
extension = 100
side = cl_gui_docking_container=>dock_at_bottom.
* Create ALV grid for displaying the table
create object cont_alvgd
exporting
i_parent = cont_dock.
* Create custom container for ALV
create object cont_cust
exporting
container_name = 'CCONT'.
* Create alv editable grid
create object cont_editalvgd
exporting
i_parent = cont_cust.
* Register events for the editable alv
create object event_receiver.
set handler event_receiver->handle_data_changed for cont_editalvgd.
call method cont_editalvgd->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
*Building fieldcatalogue for the initial display
perform Build_fieldcatalogue changing it_fcat it_fieldcat.
* Building the fieldcatalogue after the user has changed it
perform Change_fieldcatalogue changing it_fieldcat.
* Fetch data from the table.
perform Fetch_data.
* Get excluding functions for the alv editable tool bar
APPEND cl_gui_alv_grid=>mc_fc_loc_append_row TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_loc_insert_row TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_loc_cut TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_sort TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_sort_asc TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_sort_dsc TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_subtot TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_sum TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_graph TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_info TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_print TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_filter TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_views TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_mb_export TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_mb_sum TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_mb_sum TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_mb_paste TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_find TO it_excl_func.
APPEND cl_gui_alv_grid=>mc_fc_loc_copy TO it_excl_func.
*Alv display for the T006 table at the bottom
CALL METHOD cont_alvgd->set_table_for_first_display
CHANGING
it_outtab = it_t006[]
it_fieldcatalog = it_fcat[].
* optimize column width of grid displaying fieldcatalog
it_layout-cwidth_opt = 'X'.
* Get fieldcatalog of table T006 - alv might have
* modified it after passing.
CALL METHOD cont_alvgd->get_frontend_fieldcatalog
IMPORTING
et_fieldcatalog = it_fcat[].
*to Send Buffered Automation Queue to Frontend
CALL METHOD cl_gui_cfw=>flush.
* Display fieldcatalog of table T006 in editable alv grid
CALL METHOD cont_editalvgd->set_table_for_first_display
EXPORTING
is_layout = it_layout
it_toolbar_excluding = it_excl_func
CHANGING
it_outtab = it_fcat[]
it_fieldcatalog = it_fieldcat[].
ENDFORM. " Create_alv
*& Module USER_COMMAND_0600 INPUT
* text
MODULE USER_COMMAND_0600 INPUT.
case ok_code.
when 'SUBMIT'.
* To get the current fieldcatalogue from the front end
call method cont_alvgd->set_frontend_fieldcatalog
exporting
it_fieldcatalog = it_fieldcat.
call method cont_alvgd->refresh_table_display.
call method cl_gui_cfw=>flush.
when 'EXIT'.
leave program.
endcase.
ENDMODULE. " USER_COMMAND_0600 INPUT
*& Form Build_fieldcatalogue
* text
* <--P_IT_FCAT text
* <--P_IT_FIELDCAT text
FORM Build_fieldcatalogue CHANGING P_IT_FCAT
P_IT_FIELDCAT.
* Fieldcatalog for table T006: it_fldcat
* to generate the fields automatically
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'T006'
CHANGING
ct_fieldcat = it_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
* Fieldcatalog for table LVC_T_FCAT:it_fcat
* Generate fieldcatalog of fieldcatalog structure.
* This fieldcatalog is used to display fieldcatalog 'it_fldcat'
* on the top of the screen.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'LVC_S_FCAT'
CHANGING
ct_fieldcat = it_fcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
ENDFORM. " Build_fieldcatalogue
*& Form Change_fieldcatalogue
* After the user has modified the fieldcatalogue we build another fieldcat
* for the modified alv display
* <--P_IT_FIELDCAT text
FORM Change_fieldcatalogue CHANGING P_IT_FIELDCAT.
DATA ls_fcat TYPE lvc_s_fcat.
LOOP AT it_fcat INTO ls_fcat.
ls_fcat-coltext = ls_fcat-fieldname.
ls_fcat-edit = 'X'.
IF ls_fcat-fieldname = 'COL_POS' OR ls_fcat-fieldname = 'FIELDNAME'.
ls_fcat-key = 'X'.
ENDIF.
MODIFY it_fcat FROM ls_fcat.
ENDLOOP.
ENDFORM. " Change_fieldcatalogue
*& Form Fetch_data
* text
* --> p1 text
* <-- p2 text
FORM Fetch_data .
select * from t006 into table it_t006 up to 50 rows.
ENDFORM. " Fetch_datacomment this particular section deals with top container.
CALL METHOD cont_editalvgd->set_table_for_first_display
EXPORTING
is_layout = it_layout
it_toolbar_excluding = it_excl_func
CHANGING
it_outtab = it_fcat[]
it_fieldcatalog = it_fieldcat[].
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'LVC_S_FCAT' "This is deep strucure
CHANGING
ct_fieldcat = it_fcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
LVC_S_FCAT is a deep structure , so try to comment that section and see. if you want that part , populate the fieldcatalog manually. -
How to set column names in OVS search help of ALV EDIT
Hi All,
I have a OVS search help for my ALV EDIT column.This OVS will have two columns,I need to give the names(name1 , name2) to the columns.
I am writing the below codo in phase 0.
ls_text-name = 'Column1'.
ls_text-value = 'name1'.
INSERT ls_text INTO TABLE lt_column_texts.
ls_text-name = 'Column2'.
ls_text-value = 'name2'.
INSERT ls_text INTO TABLE lt_column_texts.
ovs_callback_object->set_configuration(
label_texts = lt_label_texts
column_texts = lt_column_texts
group_header = lv_group_header
window_title = lv_window_title
table_header = lv_table_header
col_count = 2
row_count = 20 ).
Below code in Phase 3.
Assign ovs_callback_object->selection->* to <ls_selection>.
if <ls_selection> is assigned.
ovs_callback_object->context_element->set_attribute(
name = `ATR1`
value = <ls_selection>-Column1 ).
endif.
But,the column names are not getting set.Please provide your inputs.
Regards,
Salmahi,
About your requirement, i don't know why you need to code in "Phase 3" of OVS.
"Phase 3" is used for transporting your selected value to Your ALV.
I think, the reason why you loose the result table including your customized column title, is that you loose the "Phase 2".
Generally, in the past i used OVS as the following code simply.Just one example:
* declare data structures for the fields to be displayed and
* for the table columns of the selection list, if necessary
types:
begin of lty_stru_input,
* add fields for the display of your search input here
carrid type string,
connid type string,
end of lty_stru_input.
types:
begin of lty_stru_list,
* add fields for the selection list here
carrid type string,
connid type string,
text type string,
end of lty_stru_list.
data: ls_search_input type lty_stru_input,
lt_select_list type standard table of lty_stru_list,
ls_text type wdr_name_value,
lt_label_texts type wdr_name_value_list,
lt_column_texts type wdr_name_value_list,
case ovs_callback_object->phase_indicator.
when if_wd_ovs=>co_phase_0. "configuration phase, may be omitted
* in this phase you have the possibility to define the texts,
* if you do not want to use the defaults (DDIC-texts)
ls_text-name = 'CARRID'. "must match a field name of search
ls_text-value = 'Search Field-Carrid'.
insert ls_text into table lt_label_texts.
ls_text-name = 'CONNID'. "must match a field name of search
ls_text-value = 'Search Field-Connid'.
insert ls_text into table lt_label_texts.
ls_text-name = 'CARRID'. "must match a field in list structure
ls_text-value = 'Result-Carrid'.
insert ls_text into table lt_column_texts.
ls_text-name = 'CONNID'. "must match a field in list structure
ls_text-value = 'Result-Connid'.
insert ls_text into table lt_column_texts.
ls_text-name = 'TEXT'. "must match a field in list structure
ls_text-value = 'Result-Text'.
insert ls_text into table lt_column_texts.
lv_group_header = 'Group Header'.
lv_window_title = 'Window Title'.
lv_table_header = 'Table Header'.
ovs_callback_object->set_configuration(
label_texts = lt_label_texts
column_texts = lt_column_texts
group_header = lv_group_header
window_title = lv_window_title
table_header = lv_table_header
col_count = 3
row_count = 8 ).
when if_wd_ovs=>co_phase_2.
* If phase 1 is implemented, use the field input for the
* selection of the table.
* If phase 1 is omitted, use values from your own context.
if ovs_callback_object->query_parameters is not bound.
******** TODO exception handling
endif.
assign ovs_callback_object->query_parameters->*
to <ls_query_params>.
SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_select_list FROM ZTABLE_FLIGHT
WHERE CARRID LIKE lw_carrid
AND CONNID LIKE lw_connid
*ovs_callback_object->set_output_table( output = lt_select_list ).*
Hope it can help.
Best wishes. -
Problem with alv edit and save
hi all,
can anyone find me a solution for alv edit and save...the issue is that i will be editing and just clicking on save button withot any row selction and the data changed should be updated in database.
sunil.Hi Bhaskar,
To make fields editable in ALV, while creating the field catalog for ALV, use:-
wa_field-edit = 'X'. " to make a field editable
To check the data changed in ALV, use code:-
ALV GRID Display
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy_repid " report id
i_callback_user_command = 'USER_COMMAND' " to handle user command
it_fieldcat = it_field " for field catalog
it_sort = it_sort " for sort records info
TABLES
t_outtab = it_final "internal table with records
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.
Sub-routine USER_COMMAND
FORM user_command USING v_okcode LIKE sy-ucomm selfield TYPE slis_selfield.
* assign the function code to variable v_okcode
v_okcode = sy-ucomm.
* handle the code execution based on the function code encountered
CASE v_okcode.
* when the function code is EXECUTE then process the selected records
WHEN 'EXECUTE'.
*to reflect the data changed into internal table
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
* refresh the ALV Grid output from internal table
selfield-refresh = c_check.
ENDCASE.
Hope this solves your problem.
Thanks & Regards,
Tarun Gambhir -
How to handle 'ENTER' Key on ALV Editable Grid on sub screen (Tabstrips)
Hello Experts ,
I have 2 questions with ALV Editable grid;
please help me if you have answers.
I created ALV grid on one of sub screens on a Tab Strip,
As soon as user types one of the columns of the ALV grid and press u2018ENTERu2019 key, it has to return corresponding details for that line.
I tried to implement this logic in ALV grid event u2018handle_data_changedu2019, but ALV internal table is not getting populated with new entry entered in the grid. but u2018double_clicku2019 event working my purpose, but user might need enter key.
and I thought I would do implement that logic in PAI event of the sub screen, u2018ENTERu2019 key not getting trigger on PAI event of the screen until cursor is on grid.
Another question 2: How do I control and not to be deleted a line on the grid (based on validation), where do I validate and by pass the delete function for a particular line, or suggest me to gray out only one line on the grid .
I would like to have delete function to work as it is ,except for some validations..
Can I implement using PAI event of the sub screen or any by ALV event.
Please suggest me..
Edited by: Ravindranath Arusam on May 13, 2010 2:42 PMIn DATA_CHANGED event, you will get the modified row into the attribute MP_MOD_ROWS of the impoerting object ER_DATA_CHANGED. Since this MP_MOD_ROWS is the Object reference to Data, you need to have the field symbol to get the value.
FIELD-SYMBOLS: <lft_mod_output> TYPE t_t_output.
ASSIGN er_data_changed->mp_mod_rows->* TO <lft_mod_output>.
You can get the Value of the Cell by using the method GET_CELL_VALUE of the same ER_DATA_CHANGED object and use the method MODIFY_CELL To update the value back to ALV.
To Restrict the row deletion:
When the row is deleted it is being added to Attribute mt_deleted_rows of the object ER_DATA_CHANGED. You can put the data back to the table in the DATA_CHANGE_FINISHED event. Visit this post http://help-abap.blogspot.com/2008/10/alv-disable-delete-key-on-keyboard-in.html for more information.
Regards,
Naimesh Patel -
ALV Editable Grid Control F4 help problem
HI Experts,
am facing some funny and critical problem in ALV Editable GRID,that is i used OOPS concept for ALV GRID Control output,
in fieldcatalog i given for fields as
wafieldcatlog-f4availabl = 'X'.
wafieldcatlog-ref_table = 'table'.
wafieldcatlog-ref_field = 'field'.
and for seven fields i given like this .
but in that editable if i use F4 help for the field and get that data and later save means that data is not considering and giving error message.
So can any one please help if u confused pls reply fo any clarifications, pls help me out in this situation.
THXwafieldcatlog-f4availabl = 'X'.
wafieldcatlog-ref_table = 'table'. "should be in caps
wafieldcatlog-ref_field = 'field'. "should be in caps.
what error you are getting while saving..? -
hi,
i am using normal alv edit report, in list 2 field date fields, this 2 fields are editable, how to get the date f4 help, pls give me solution
thanks
santhahi i have define this type,
types: begin of TY_FINAL,
CREDATE type SY-DATUM, "SY-DATUM,
DOCNUM(5) type C,
PERSON(35) type C,
TKNUM type TKNUM,
NAME1 type NAME1,
ORT01 type ORT01,
VBELN type VBELN,
AGENT_PNO(4) type C,
AGENT(10) type C,
TO_ORDER(7) type C,
INCO1 type INCO1,
INCO2 type INCO2,
LCNUM type LCNUM,
VSART type VSART,
DATXA type DATXA,
LOADING(10) type C,
DATLOAD(10) type C, "SY-DATUM,
SHIPDATE(10) type C, "SY-DATUM,
DATLOAD type dats "SY-DATUM,
SHIPDATE type SY-DATUM,
ABLAD type ABLAD,
SHIPLOAD type C,
IMPORT TYPE C,
VIA(10) type C,
PORT(10) type C,
MARKS(13) type C,
PRO_DESCR(10) type C,
NTGEW type NTGEW,
BRGEW type BRGEW,
NOTE(15) type C,
WH_SH_DOCU(15) type C,
WHEN_SHIP(15) type C,
ENCLOSURE(10) type C,
ZTERM type VBRK-ZTERM,
VTEXT type VTEXT,
BOX type C,
end of TY_FINAL.
LS_FIELDCAT-FIELDNAME = 'DATLOAD'.
LS_FIELDCAT-INPUT = 'X'.
LS_FIELDCAT-REF_FIELDNAME = 'ERDAT'.
LS_FIELDCAT-REF_TABNAME = 'VBRK'.
LS_FIELDCAT-DATATYPE = 'DATS'.
LS_FIELDCAT-INTTYPE = 'D'.
LS_FIELDCAT-EDIT = 'X'.
LS_FIELDCAT-SELTEXT_L = TEXT-116.
append LS_FIELDCAT to PT_FIELDCAT
Thanks
santha -
ALV editable with error lvc_t_style
Hi experts!!!
I have a problem, I need develop an alv editable and i've read the solutions you have proposed in another threads, my problem is when i declare "celltab" type lvc_t_styl, the check syntax tell 'the type "lvc_t_styl" is uknown.
Do you have any idea why this error???
thanks!!.
Antonio PiñWelcome to SDN.
Which version of SAP are you using?
a® -
ALV editable with traffic lights
Hello all,
I need some help about ALV editable; my reports display an ALV grid editable, and update all the new values on the DB table, but I have traffic lights as values on the DB table.
More informations:
So this is my internal table
<i>DATA: BEGIN OF it_table OCCURS 0,
document TYPE admi-document,
status TYPE admi-status, (traffic</i> lights from the table able to modify)
archiv_key TYPE admi_files-archiv_key,
status_opt TYPE admi_files-status_opt, (traffic lights from the table able to modify )
status_fil TYPE admi_files-status_fil, (traffic lights from the table able to modify )
END OF it_report.
</i>
I got all the match code form the table (DB) , so on my report I could modify all the traffic lights but when I save the modifications, I got a message error.
And the second problem was, I couldnt come back to the value initial and I getting the same message.
Can anybody help me please?
Thanks you.see the program and i am using traffic lights in my program --
REPORT ZWM_BIN_STOCK_REQ no standard page heading
message-id zwave.
D A T A D E C L A R A T I O N ****************************
Tables
tables : zpwvbap,
mara,
marc,
makt,
vbap,
zshift,
marm,
lqua.
TYPE-POOLS: SLIS.
Internal Table for Sales order
data : begin of i_vbap occurs 0,
matnr like zpwvbap-matnr," Material #
ZZCUTOFF like zpwvbak-ZZCUTOFF," Cutoff Time
vlpla like zpwvbap-vlpla,
kwmeng like zpwvbap-kwmeng," Quantity
vrkme like zpwvbap-vrkme, " Sales Unit
meins like zpwvbap-meins, " Unit of measure
end of i_vbap.
Internal Table for final Processing
data : begin of i_final occurs 0,
date(8) type c,
matnr like zpwvbap-matnr," Material #
zzshift like zshift-zzshift, " Wave Drop
maktx like makt-maktx," Desc
lgpla like lagp-lgpla, " Pick Bin
pverme like lqua-verme," Stock at Pick Bin
prverme like lqua-verme," Stock at Prod Bin
kwmeng like zpwvbap-kwmeng," Requiremnet from Wave Drop
vrkme like zpwvbap-vrkme, " Sales Unit
meins like zpwvbap-meins," Unit of measure
end of i_final.
Internal Table for Output
data : begin of i_output occurs 0,
field type c, " Traffic Lights
zzshift like zshift-zzshift, " Wave Drop
matnr like zpwvbap-matnr," Material #
maktx like makt-maktx," Desc
lgpla like lagp-lgpla, " Pick Bin
pverme like lqua-verme," Stock at Pick Bin
prverme like lqua-verme," Stock at Prod Bin
kwmeng like zpwvbap-kwmeng," Requiremnet from Wave Drop
vrkme like zpwvbap-vrkme," Sales Unit
meins like zpwvbap-meins," Unit of measure
diff like zpwvbap-kwmeng, " Diffrence
end of i_output.
Work Area for Final Internal Table
data wa_final like i_final.
data : w_zzcutoff(12) TYPE c,
v_date type sy-datum,
v_time(4) type c,
v_fldate(12) type c,
v_fhdate(12) type c,
v_pverme like lqua-verme,
v_prverme like lqua-verme,
v_diff like zpwvbap-kwmeng.
Variables for new check box
data : v_nverme like lqua-verme.
Internal Table for Pick Bin
data : begin of i_verme occurs 0,
verme like lqua-verme,
end of i_verme.
Internal table for Prod Bin
data : begin of i_pverme occurs 0,
verme like lqua-verme,
end of i_pverme.
Variables for ALV
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT_LN LIKE LINE OF FIELDCAT,
SORTCAT TYPE SLIS_T_SORTINFO_ALV,
SORTCAT_LN LIKE LINE OF SORTCAT,
EVENTCAT TYPE SLIS_T_EVENT,
EVENTCAT_LN LIKE LINE OF EVENTCAT,
LAYOUT TYPE SLIS_LAYOUT_ALV,
C_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: COL_POS TYPE I,
P_LIGNAM TYPE SLIS_FIELDNAME VALUE 'FIELD'.
DATA : V_REPID LIKE SY-REPID,
flag type c.
S E L E C T I O N - S C R E E N *************************
selection-screen : begin of block blk with frame title text-001.
parameter : p_plant like marc-werks obligatory default '1000'.
select-options : s_date for sy-datum obligatory ,
s_shift for zshift-zzshift,
s_matnr for mara-matnr,
s_dept for zpwvbap-zzdept,
s_pdept for marc-ZZPRODDEPT.
selection-screen: end of block blk.
parameters : p_check as checkbox ."default 'X'.
ranges r_cutoff for w_zzcutoff.
I N I T I A L I Z A T I O N ****************************
initialization.
V_REPID = SY-REPID.
s_date-low = sy-datum + 1.
append s_date.
S T A R T - O F - S E L E C T I O N ***********************
start-of-selection.
Get the Shift Data.
PERFORM GET_SHIFT_DETAILS.
Get the data from ZPWVBAP Table
PERFORM GET_DATA_VBAP.
E N D - O F - S E L E C T I O N **********************
end-of-selection.
if not i_output[] is initial.
sort i_output by field zzshift matnr.
Reset the all Fiedcatlog.
PERFORM RESETVALUES.
Traffic Lights
PERFORM BUILD_LAYOUT.
Fill the fieldcatlog values
PERFORM FILL_FIELDCATLOG.
Call the List Function module
PERFORM CALL_lIST.
endif.
*& Form GET_SHIFT_DETAILS
Get the Cutoff Time.
FORM GET_SHIFT_DETAILS.
clear : v_fldate,
v_fhdate.
if not s_shift-low is initial.
clear: v_time,
v_date.
if s_shift-low = '1'.
v_time = '2000'.
elseif s_shift-low = '2'.
v_time = '2300'.
endif.
v_date = s_date-low - 1.
concatenate v_date v_time into v_fldate.
endif.
if not s_shift-high is initial.
clear : v_date,
v_time.
if s_shift-high = '1'.
v_time = '2000'.
elseif s_shift-high = '2'.
v_time = '2300'.
endif.
if not s_date-high is initial.
v_date = s_date-high - 1.
else.
v_date = s_date-low - 1.
endif.
concatenate v_date v_time into v_fhdate.
endif.
if not v_fhdate is initial.
r_cutoff-low = v_fldate.
r_cutoff-high = v_fhdate.
r_cutoff-sign = 'I'.
r_cutoff-option = 'BT'.
append r_cutoff.
endif.
ENDFORM. " GET_SHIFT_DETAILS
*& Form GET_DATA_VBAP
Get the data from ZPWVBAP Table
FORM GET_DATA_VBAP.
Get the data from ZPWVBAP and ZPWVBAK Table
if not v_fhdate is initial.
select matnr ZZCUTOFF vlpla sum( kwmeng ) vrkme meins
into table i_vbap
from zpwvbap as a inner join zpwvbak as b on
a~vbeln = b~vbeln
where a~werks = p_plant
and a~matnr in s_matnr
and b~vdatu in s_date
and a~zzdept in s_dept
and b~zzcutoff in r_cutoff
group by matnr zzcutoff vlpla vrkme meins.
elseif not v_fldate is initial.
select matnr ZZCUTOFF vlpla sum( kwmeng ) vrkme meins
into table i_vbap
from zpwvbap as a inner join zpwvbak as b on
a~vbeln = b~vbeln
where a~werks = p_plant
and a~matnr in s_matnr
and b~vdatu in s_date
and a~zzdept in s_dept
and b~zzcutoff = v_fldate
group by matnr zzcutoff vlpla vrkme meins.
else.
select matnr ZZCUTOFF vlpla sum( kwmeng ) vrkme meins
into table i_vbap
from zpwvbap as a inner join zpwvbak as b on
a~vbeln = b~vbeln
where a~werks = p_plant
and a~matnr in s_matnr
and b~vdatu in s_date
and a~zzdept in s_dept
and b~zzcutoff in r_cutoff
group by matnr zzcutoff vlpla vrkme meins .
endif.
if sy-subrc ne 0.
message i000(zwave) with 'No data found for given selection'.
stop.
endif.
sort i_vbap by zzcutoff matnr.
loop at i_vbap.
clear : v_pverme,
v_prverme.
Compare the data with pick method
select single zzpick from marc into marc-zzpick
where matnr = i_vbap-matnr
and werks = p_plant
and zzpick = '01'.
if sy-subrc ne 0.
continue.
endif.
Compare the data from MARC Table with Production Department
select single zzPRODdept from marc into marc-zzPRODdept
where matnr = i_vbap-matnr
and werks = p_plant
and zzPRODdept in s_pdept.
if sy-subrc ne 0.
continue.
endif.
Get the Material Description from MAKT Table
Select single maktx from makt into makt-maktx
where matnr = i_vbap-matnr
and spras = 'E'.
if sy-subrc eq 0.
i_final-maktx = makt-maktx.
endif.
Get the Pick Bin
i_final-lgpla = i_vbap-vlpla.
refresh i_verme.
clear i_verme.
Get the stock at Pick bin
select verme from lqua into table i_verme
where lgpla = i_vbap-vlpla
and matnr = i_vbap-matnr
and LGNUM = '100'.
if sy-subrc eq 0.
loop at i_verme.
v_pverme = v_pverme + i_verme-verme.
endloop.
if sy-subrc eq 0.
i_final-pverme = v_pverme.
endif.
endif.
refresh i_pverme.
clear i_pverme.
Get the stock at Production bin
select verme from lqua into table i_pverme
where matnr = i_vbap-matnr
and LGNUM = '100'
and ( lgpla = '9595959595' or
lgpla = '2222222222' or
lgpla = '5555555555' or
lgpla = '3232323232' or
lgpla = '8080808080' or
lgpla = '4040404040' or
lgpla = '9090909090' ).
if sy-subrc eq 0.
loop at i_pverme.
v_prverme = v_prverme + i_pverme-verme.
endloop.
if sy-subrc eq 0.
i_final-prverme = v_prverme.
endif.
endif.
Compare the unit of measure and sales unit
if i_vbap-vrkme ne i_vbap-meins.
Get the data from MARM Table ( Unit of measure )
select single * from marm into marm
where matnr = i_vbap-matnr
and meinh = i_vbap-vrkme.
if sy-subrc eq 0.
i_final-pverme = ( i_final-pverme * marm-umren ) / marm-umrez.
endif.
endif.
Material #
i_final-matnr = i_vbap-matnr.
Quantity from ZPWVBAP
i_final-kwmeng = i_vbap-kwmeng.
Unit of Measure
i_final-meins = i_vbap-meins.
Sales Unit
i_final-vrkme = i_vbap-vrkme.
Wave Drop
if i_vbap-ZZCUTOFF+8(4) = '2000' .
i_final-zzshift = '1'.
endif.
if i_vbap-zzcutoff+8(4) = '2300'.
i_final-zzshift = '2'.
endif.
i_final-date = i_vbap-zzcutoff+0(8).
append i_final.
clear : i_final,
i_vbap.
**Difference
i_output-diff = i_output-pverme - i_vbap-kwmeng.
Traffic Lights Depends on value
if i_output-pverme > i_output-kwmeng.
i_output-field = '3'.
elseif i_output-pverme < i_output-kwmeng.
i_output-field = '1'.
elseif i_output-pverme = i_output-kwmeng.
i_output-field = '2'.
endif.
append i_output.
clear : i_output,
i_vbap.
endloop.
refresh i_vbap.
sort i_final by date matnr zzshift.
Processing the internal table to get same material with pick quantity
deduction even it for 2nd shift
loop at i_final.
Move the data into work area in order remove #
move i_final to wa_final.
clear : flag.
at new matnr.
move : wa_final-matnr to i_output-matnr," Material #
wa_final-maktx to i_output-maktx," Desc
wa_final-lgpla to i_output-lgpla," Pick Bin
wa_final-kwmeng to i_output-kwmeng," Order qty
wa_final-zzshift to i_output-zzshift," Shift
wa_final-pverme to i_output-pverme, " Pick bin qty
wa_final-vrkme to i_output-vrkme," Sales Unit
wa_final-prverme to i_output-prverme. " Prod Bin Qty
break sreddy.
Difference
i_output-diff = i_output-pverme - i_output-kwmeng.
New logic for Only HMR Department
if p_check = 'X'.
if i_output-pverme < i_output-kwmeng.
v_nverme = i_output-pverme + i_output-prverme.
if v_nverme > i_output-kwmeng.
if i_output-pverme < i_output-kwmeng.
i_output-field = '2'.
else.
Traffic Lights Depends on value
i_output-field = '3'.
endif.
elseif v_nverme < i_output-kwmeng.
i_output-field = '1'.
elseif v_nverme = i_output-kwmeng.
i_output-field = '2'.
endif.
elseif i_output-pverme > i_output-kwmeng.
i_output-field = '3'.
elseif i_output-pverme = i_output-kwmeng.
i_output-field = '3'.
endif.
else.
Traffic Lights Depends on value
if i_output-pverme > i_output-kwmeng.
i_output-field = '3'.
elseif i_output-pverme < i_output-kwmeng.
i_output-field = '1'.
elseif i_output-pverme = i_output-kwmeng.
i_output-field = '2'.
endif.
endif.
move i_output-diff to v_diff.
flag = 'X'.
endat.
if flag ne 'X'.
move : wa_final-matnr to i_output-matnr," Material #
wa_final-maktx to i_output-maktx," Desc
wa_final-lgpla to i_output-lgpla," Pick Bin
wa_final-kwmeng to i_output-kwmeng," Order qty
wa_final-zzshift to i_output-zzshift," Shift
wa_final-vrkme to i_output-vrkme," Sales Unit
wa_final-prverme to i_output-prverme. " Prod Bin Qty
Move Diffrence value
move v_diff to i_output-pverme.
clear: v_diff.
New logic for Only HMR Department
New logic for Only HMR Department
if p_check = 'X'.
if i_output-pverme < i_output-kwmeng.
v_nverme = i_output-pverme + i_output-prverme.
if v_nverme > i_output-kwmeng.
if i_output-pverme < i_output-kwmeng.
i_output-field = '2'.
else.
Traffic Lights Depends on value
i_output-field = '3'.
endif.
Traffic Lights Depends on value
i_output-field = '3'.
elseif v_nverme < i_output-kwmeng.
i_output-field = '1'.
elseif v_nverme = i_output-kwmeng.
i_output-field = '2'.
endif.
elseif i_output-pverme > i_output-kwmeng.
i_output-field = '3'.
elseif i_output-pverme = i_output-kwmeng.
i_output-field = '3'.
endif.
i_output-diff = i_output-pverme - i_output-kwmeng.
else.
Difference
i_output-diff = i_output-pverme - i_output-kwmeng.
Traffic Lights Depends on value
if i_output-pverme > i_output-kwmeng.
i_output-field = '3'.
elseif i_output-pverme < i_output-kwmeng.
i_output-field = '1'.
elseif i_output-pverme = i_output-kwmeng.
i_output-field = '2'.
endif.
endif.
endif.
append i_output.
clear : i_output,
wa_final,
i_final,
v_nverme.
endloop.
sort i_output by field zzshift matnr.
ENDFORM. " GET_DATA_VBAP
*& Form RESETVALUES
Reset the all fieldcatlogs
FORM RESETVALUES.
FIELDCAT_LN-KEY = SPACE.
FIELDCAT_LN-DO_SUM = SPACE.
FIELDCAT_LN-NO_OUT = SPACE.
FIELDCAT_LN-QFIELDNAME = SPACE.
FIELDCAT_LN-HOTSPOT = SPACE.
FIELDCAT_LN-OUTPUTLEN = '0'.
CLEAR: fieldcat_ln-seltext_l, fieldcat_ln-seltext_m,
fieldcat_ln-seltext_s, fieldcat_ln-reptext_ddic.
ENDFORM. " RESETVALUES
*& Form FILL_FIELDCATLOG
Fill the Fieldcatlog values
FORM FILL_FIELDCATLOG.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
Trafiic Light
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'FIELD'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 7.
LS_FIELDCAT-col_pos = '1'.
ls_fieldcat-seltext_L = 'Lights'.
ls_fieldcat-seltext_s = 'Lights'.
ls_fieldcat-seltext_m = 'Lights'.
APPEND LS_FIELDCAT TO FIELDCAT.
Wave Drop
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'ZZSHIFT'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 9.
LS_FIELDCAT-col_pos = '2'.
ls_fieldcat-seltext_L = 'Wave Drop'.
APPEND LS_FIELDCAT TO FIELDCAT.
Material
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MATNR'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 18.
LS_FIELDCAT-col_pos = '3'.
ls_fieldcat-seltext_L = 'Material'.
APPEND LS_FIELDCAT TO FIELDCAT.
Description
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MAKTX'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 40.
LS_FIELDCAT-col_pos = '4'.
ls_fieldcat-seltext_L = 'Description'.
APPEND LS_FIELDCAT TO FIELDCAT.
Pick Bin
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'LGPLA'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 15.
LS_FIELDCAT-col_pos = '5'.
ls_fieldcat-seltext_L = 'Pick Bin'.
APPEND LS_FIELDCAT TO FIELDCAT.
Trafiic Light
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'PVERME'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 16.
LS_FIELDCAT-col_pos = '6'.
ls_fieldcat-seltext_L = 'Stock at Pick Bin'.
APPEND LS_FIELDCAT TO FIELDCAT.
Stock at Prod Bin
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'PRVERME'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 16.
LS_FIELDCAT-col_pos = '7'.
ls_fieldcat-seltext_L = 'Stock at Prod Bin'.
APPEND LS_FIELDCAT TO FIELDCAT.
Req from wave drop
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KWMENG'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 23.
LS_FIELDCAT-col_pos = '8'.
ls_fieldcat-seltext_L = 'Requirement from Wave Drop'.
APPEND LS_FIELDCAT TO FIELDCAT.
Sales Unit
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VRKME'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 12.
LS_FIELDCAT-col_pos = '9'.
ls_fieldcat-seltext_L = 'Sales Unit'.
APPEND LS_FIELDCAT TO FIELDCAT.
Unit of Measure
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MEINS'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 9.
LS_FIELDCAT-col_pos = '10'.
ls_fieldcat-seltext_L = 'UNIT'.
ls_fieldcat-no_out = 'X'.
APPEND LS_FIELDCAT TO FIELDCAT.
Diffference
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'DIFF'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 12.
LS_FIELDCAT-col_pos = '11'.
ls_fieldcat-seltext_L = 'Difference'.
APPEND LS_FIELDCAT TO FIELDCAT.
ENDFORM. " FILL_FIELDCATLOG
*& Form CALL_lIST
Use ALV Function module to display output
FORM CALL_lIST.
Top - of - Page
PERFORM COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = g_user_command
I_CALLBACK_TOP_OF_PAGE = C_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 = LAYOUT
IT_FIELDCAT = 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
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = I_OUTPUT
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. " CALL_lIST
*& Form BUILD_LAYOUT
text
FORM BUILD_LAYOUT.
LAYOUT-GET_SELINFOS = 'X'.
Now we want a traffic light to say if the Truck is deleted
the variable p_lignam contains the name in IREPO which stores the
value for the traffic light
LAYOUT-LIGHTS_FIELDNAME = P_LIGNAM.
layout-HEADER_TEXT = 'Lights'.
LAYOUT-LIGHTS_CONDENSE = 'X'.
ENDFORM. " BUILD_LAYOUT
*& Form COMMENT_BUILD
text
-->P_GT_LIST_TOP_OF_PAGE[] text
FORM COMMENT_BUILD USING LT_TOP_OF_PAGE TYPE
SLIS_T_LISTHEADER.
data : v_day(2) type c,
v_mon(2) type c,
v_year(4) type c,
v_ldate(10) type c,
v_hdate(10) type c.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
data: d_date like sy-datum.
clear : v_ldate,
v_hdate.
Header Information.
LIST HEADING LINE: TYPE H
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-KEY: NOT USED FOR THIS TYPE
LS_LINE-INFO = 'Bin Replenishment report for HMR'.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
STATUS LINE: TYPE S
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = TEXT-003.
LS_LINE-INFO = TEXT-003.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
STATUS LINE: TYPE S
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = TEXT-003.
LS_LINE-INFO = TEXT-003.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
Get the data ( s_date_low) into proper format.
v_year = s_date-low+0(4).
v_mon = s_date-low+4(2).
v_day = s_date-low+6(2).
concatenate v_mon '/' v_day '/' v_year into v_ldate.
clear : v_mon,
v_year,
v_day.
Get the data ( s_date_high) into proper format.
v_year = s_date-high+0(4).
v_mon = s_date-high+4(2).
v_day = s_date-high+6(2).
concatenate v_mon '/' v_day '/' v_year into v_hdate.
clear : v_mon,
v_year,
v_day.
Delivery date
if not s_date-low is initial .
if not s_date-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Delivery date From:'.
LS_LINE-INFO = v_ldate.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Delivery date To :'.
LS_LINE-INFO = v_hdate.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
if not s_date-low is initial.
if s_date-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Delivery date :'.
LS_LINE-INFO = v_ldate.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
Wave Drop
if not S_SHIFT-LOW is initial.
if not S_SHIFT-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Wave Drop From :'.
LS_LINE-INFO = s_shift-low.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Wave Drop to :'.
LS_LINE-INFO = s_shift-high.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
if not S_SHIFT-LOW is initial.
if S_SHIFT-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Wave Drop :'.
LS_LINE-INFO = s_shift-low.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Wave Drop to :'.
LS_LINE-INFO = s_shift-high.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
Department
if not s_dept-low is initial .
if not s_dept-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Department From :'.
LS_LINE-INFO = s_dept-low.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Department to :'.
LS_LINE-INFO = s_dept-high.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
if not s_dept-low is initial .
if s_dept-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Department :'.
LS_LINE-INFO = s_dept-low.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
Production Department
if not S_PDEPT-LOW is initial.
if not S_PDEPT-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Production Department From :'.
LS_LINE-INFO = S_PDEPT-LOW.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Production Department to :'.
LS_LINE-INFO = S_PDEPT-high.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
if not S_PDEPT-LOW is initial.
if S_PDEPT-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Production Department :'.
LS_LINE-INFO = S_PDEPT-LOW.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
ENDFORM. " COMMENT_BUILD
FORM TOP_OF_PAGE *
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE
I_LOGO =
I_END_OF_LIST_GRID =
ENDFORM.
FORM USER_COMMAND *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield. "#EC CALLED
CASE R_UCOMM.
WHEN '&IC1'.
read table i_output index rs_selfield-tabindex.
SET PARAMETER ID 'MAT' FIELD i_output-matnr.
SET PARAMETER ID 'WRK' FIELD p_plant.
if not i_output-matnr is initial.
call transaction 'MD04' and skip first screen.
endif.
ENDCASE.
ENDFORM. -
History list in an ALV editable cell
Hello
I am trying to have a history list in my ALV editable cells as per described in the ALV Grid SAP documentation but I am unable to do so. The documentation indicates that u201Cif the cursor is on the first item cell you can use Backspace to call up a history listu201D.
I created a screen containing regular standard fields in the upper portion of the screen and I added an ALV grid (split into 3 sections) in the low part of the screen. The ALV contain several editable cells. The history list works very well for the regular fields on the screen but I cannot get the history list working for any of the editable cells in the ALV.
I have defined the field catalog for the editable cells as follows (including the AUTO_VALUE field):
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'SERNR'.
wa_fieldcat-reptext = text-002.
wa_fieldcat-edit = 'X'.
wa_fieldcat-auto_value = 'X'.
wa_fieldcat-checkbox = ' '.
wa_fieldcat-hotspot = ' ' .
wa_fieldcat-dd_outlen = ' '.
wa_fieldcat-icon = ' '.
wa_fieldcat-no_zero = 'X'.
APPEND wa_fieldcat TO it_fieldcat_notif.
I then generate the 3 splitted ALV as follows:
zlayout_header-grid_title = 'Repair Order and Delivery'.
zlayout_header-no_toolbar = 'X'.
zlayout_header-stylefname = 'CELLTAB'.
CALL METHOD ob_grid1->set_table_for_first_display
EXPORTING
is_variant = ls_vari
i_default = ' '
i_save = 'A'
is_layout = zlayout_header
CHANGING
it_fieldcatalog = it_fieldcat_repair
it_outtab = t_repair[].
zlayout_header-grid_title = 'Notification'.
zlayout_header-no_toolbar = 'X'.
zlayout_header-stylefname = 'CELLTAB'.
CALL METHOD ob_grid2->set_table_for_first_display
EXPORTING
is_variant = ls_vari
i_default = ' '
i_save = 'A'
is_layout = zlayout_header
CHANGING
it_fieldcatalog = it_fieldcat_notif
it_outtab = t_notif[].
zlayout_header-grid_title = 'Service Order'.
zlayout_header-no_toolbar = 'X'.
zlayout_header-stylefname = 'CELLTAB'.
CALL METHOD ob_grid3->set_table_for_first_display
EXPORTING
is_variant = ls_vari
i_default = ' '
i_save = 'A'
is_layout = zlayout_header
CHANGING
it_fieldcatalog = it_fieldcat_service
it_outtab = t_service[].
I searched forums and OSS notes but I could not find any more information (except for the ALV Grid u2013 SAP Documentation) about the history list for editable ALV cells. Currently, our application utilizes table controls in the lower part of the screen and the history list works well for the cells in the table control. However, when I replace the table control for an ALV grid, I can no longer use the history list for those cells.
Any help would be appreciated.Looks like the 2006 OSS note 825068 indicates the history list function is not supported for ALV grid.
-
How to make WD ALV Editable Fields (Cell) Mandatory (Obligatory) ?
Hello Friends,
I have requirement where I need to make WD ALV editable inputfield as Mandatory fields. I found out that there is no method available to do this.
If anybody has any solution then please reply to this thread.
Thanks,
ChandraHello Friends,
Thanks for your reply. I just wanted to elaborate more on this so that others will benefit from this thread.
I used method SET_STATE from class CL_SALV_WD_UIE_A_INPUT which is super class for class CL_SALV_WD_UIE_INPUT_FIELD.
The code looks as below,
Data: lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
CALL METHOD lr_input_field->set_state
EXPORTING
value = cl_wd_abstract_input_field=>e_state-required.
well, I just forgot to check super class and its available methods...But got clear hint from Tulasi.
Thanks to all.
Chandra -
Send sample prg for alv editable from ztable
Hi ,
Need of prg for alv editable . get data from ztable in standard tool bar i need to create record insert ,delete ,modify existing records .
Thanks in advance.
Regarding,
kumarHi Anil,
> Try like this code i wrote this code for fetch some records from database table and approve/ reject
> the records by clicking buttons.
REPORT zcl_timesheet_approval MESSAGE-ID zcl_msg.
CLASS L_CL_EVENTS DEFINITION *
Class for inserting buttons on the toolbar *
CLASS l_cl_events DEFINITION.
PUBLIC SECTION.
METHODS:
toolbar FOR EVENT toolbar
OF cl_gui_alv_grid
IMPORTING e_object
e_interactive,
user_command FOR EVENT user_command
OF cl_gui_alv_grid
IMPORTING e_ucomm .
ENDCLASS. " L_CL_EVENTS DEFINITION
CLASS L_CL_EVENTS IMPLEMENTATION *
Implementation of class L_CL_EVENTS *
CLASS l_cl_events IMPLEMENTATION.
METHOD toolbar.
PERFORM event_toolbar USING e_object.
ENDMETHOD. " TOOLBAR
METHOD user_command.
PERFORM event_ucomm USING e_ucomm.
ENDMETHOD. " USER_COMMAND
ENDCLASS. " L_CL_EVENTS IMPLEMENTATION
Tables decalration..................................................
TABLES:
zcl_timesheet. " Employee master table
CONSTANTS:
c_boolean_yes(1) TYPE c " Boolean - yes
VALUE 'X',
c_approve_status(1) TYPE c " Approval status
VALUE 'A',
c_rej_status(1) TYPE c " Rejected status
VALUE 'R',
c_save_status(1) TYPE c " Save status
VALUE 'S',
c_fcode_approve(7) TYPE c " Function code - APPROVE
VALUE 'APPROVE',
c_fcode_rej(6) TYPE c " Function code - REJECT
VALUE 'REJECT',
c_fcode_back(4) TYPE c " Function code - BACK
VALUE 'BACK',
c_fcode_onli(4) TYPE c " Function code - EXECUTE
VALUE 'ONLI',
c_fcode_exit(4) TYPE c " Function code - EXIT
VALUE 'EXIT',
c_fcode_cancel(6) TYPE c " Function code - CANCEL
VALUE 'CANCEL',
c_zero(1) TYPE c " Constant value 0
VALUE '0',
c_alv_scr(7) TYPE c " GUI status : ALV screen
VALUE 'ALV_SCR'.
Type definition...................................................
Type definition of the structure to hold data from table *
zcl_timesheet. *
TYPES:
BEGIN OF type_s_time,
empid TYPE zcl_timesheet-empid,
" Employee ID
workdate TYPE zcl_timesheet-workdate,
" Date
groupid TYPE zcl_timesheet-groupid,
" Group ID
projectid TYPE zcl_timesheet-projectid,
" Project ID
projectname TYPE zcl_timesheet-projectname,
" Project name
objectid TYPE zcl_timesheet-objectid,
" Object ID
objectname TYPE zcl_timesheet-objectname,
" Object name
activityid TYPE zcl_timesheet-activityid,
" Activity ID
activityname TYPE zcl_timesheet-activityname,
" Activity name
timeworked TYPE zcl_timesheet-timeworked,
" Time spent on work
description TYPE zcl_timesheet-description,
" Description
taskstatus TYPE zcl_timesheet-taskstatus,
" Status of the proj
billstatus TYPE zcl_timesheet-billstatus,
" Billing status
appstatus TYPE zcl_timesheet-appstatus,
" Staus of the record
wstatus TYPE zcl_timesheet-wstatus,
" Working status
mngcomment TYPE zcl_timesheet-mngcomment,
" Managers comment
END OF type_s_time.
Field-string declarations...........................................
DATA:
Field-string to build fieldcat.
fs_fcat TYPE lvc_s_fcat,
Field-string for t_timesheet
fs_timesheet TYPE zcl_timesheet.
Working variables...................................................
DATA:
w_valid(1) TYPE c, " To get the flag from check_data
w_display(1) TYPE c, " Flag to display all records
ok_code TYPE syst-ucomm, " Function code on dialog screens
w_okcode TYPE syst-ucomm, " Temporary function code
w_first(1) TYPE c, " To place buttons for first time
w_submit(1) TYPE c, " Flag to display submitted records
w_empid TYPE zcl_emprecord-empid.
" Employee ID for GET parameter
Internal table declarations........................................
DATA:
Internal table to build fieldcat.
t_fcat TYPE lvc_t_fcat,
Internal table to display data.
t_time TYPE TABLE OF type_s_time,
Internal table to hold submitted data.
t_timesheet TYPE TABLE OF zcl_timesheet.
For ALV ...........................................................
DATA:
To create instance for cl_gui_custom_container
g_grid TYPE REF TO cl_gui_custom_container,
To create instance for cl_gui_alv_grid
g_alv TYPE REF TO cl_gui_alv_grid,
To create instance for l_cl_events
g_events TYPE REF TO l_cl_events,
To assign name for custom container
g_container TYPE scrfname VALUE 'CONTAINER',
To assign layout
g_fcatlayo TYPE lvc_s_layo.
Selection screen elements............................................
SELECTION-SCREEN BEGIN OF BLOCK blck WITH FRAME TITLE text-000.
SELECT-OPTIONS:
s_group FOR zcl_timesheet-groupid " Group ID
NO INTERVALS,
s_prjid FOR zcl_timesheet-projectid, " Project ID
s_empid FOR zcl_timesheet-empid, " Employee ID
s_date FOR zcl_timesheet-workdate. " Date
SELECTION-SCREEN END OF BLOCK blck.
SELECTION-SCREEN BEGIN OF BLOCK blck1 WITH FRAME TITLE text-015.
PARAMETERS:
p_app RADIOBUTTON GROUP g1 USER-COMMAND app ,
" To approve timesheet
p_disp RADIOBUTTON GROUP g1. " To display timesheet
SELECTION-SCREEN END OF BLOCK blck1.
AT SELECTION-SCREEN EVENT *
AT SELECTION-SCREEN.
To perform user actions on the selection screen
PERFORM user_command.
MODULE STATUS_0100 OUTPUT *
This module will create the objects for the instance and display *
the records *
MODULE status_0100 OUTPUT.
SET PF-STATUS c_alv_scr.
PERFORM set_titlebar USING w_display.
If program executed in foreground.
IF sy-batch IS INITIAL.
If g_grid is empty.
IF g_grid IS INITIAL.
To create object for instance grid
CREATE OBJECT g_grid
EXPORTING
container_name = g_container.
To create object for object grid
CREATE OBJECT g_alv
EXPORTING
i_parent = g_grid.
ELSE.
CALL METHOD g_alv->refresh_table_display.
ENDIF. " IF G_GRID IS INITIAL
ENDIF. " IF SY-BATCH IS INITIAL
REFRESH t_fcat.
If w_display eq 'X' .
IF w_display EQ c_boolean_yes.
To display all records except saved data
PERFORM display_allrecords.
ENDIF. " IF W_FLAG EQ C_BOOLEAN_YES
IF w_submit EQ c_boolean_yes.
To display submitted records
PERFORM submitted_records.
ENDIF. " IF W_SUBMIT EQ C_BOOLEAN_YES
ENDMODULE. " STATUS_0100 OUTPUT
MODULE USER_COMMAND_0100 INPUT *
To perform user actions in the screen 100 *
MODULE user_command_0100 INPUT.
To update the data in the ALV grid
PERFORM check_changed_data.
w_okcode = ok_code.
CLEAR ok_code.
CASE w_okcode.
WHEN c_fcode_back.
LEAVE TO SCREEN 0.
WHEN c_fcode_exit OR c_fcode_cancel.
LEAVE PROGRAM.
ENDCASE. " CASE W_OKCODE
ENDMODULE. " USER_COMMAND_0100
FORM GET_DATA *
To get the submitted data from zcl_timesheet *
No parameters are passsed to this subroutine *
FORM get_data .
SELECT *
FROM zcl_timesheet
INTO TABLE t_timesheet
WHERE empid IN s_empid
AND workdate IN s_date
AND groupid IN s_group
AND projectid IN s_prjid
AND appstatus EQ c_boolean_yes.
IF sy-subrc NE 0.
MESSAGE e000 .
ELSE.
CALL SCREEN 100.
ENDIF. " IF SY-SUBRC NE 0
ENDFORM. " GET_DATA
FORM BUILD_FCAT *
To build the field catalog giving managers comment in editable mode *
-->PR_Tabname type lvc_tname *
-->PR_Fieldname type lvc_fname *
-->PR_Coltext type lvc_txtcol *
-->PR_Colpos type lvc_colpos *
FORM build_fcat USING pr_tabname TYPE lvc_tname
pr_fieldname TYPE lvc_fname
pr_coltext TYPE lvc_txtcol
pr_colpos TYPE lvc_colpos.
CLEAR fs_fcat.
fs_fcat-tabname = pr_tabname.
fs_fcat-fieldname = pr_fieldname.
fs_fcat-coltext = pr_coltext.
fs_fcat-col_pos = pr_colpos.
IF fs_fcat-fieldname EQ 'MNGCOMMENT'.
fs_fcat-edit = c_boolean_yes.
fs_fcat-lowercase = c_boolean_yes.
fs_fcat-dd_outlen = 60.
ELSE.
fs_fcat-edit = space.
ENDIF. " IF FS_FCAT-FIELDNAME...
APPEND fs_fcat TO t_fcat.
ENDFORM. " BUILD_FCAT
FORM BUILD_FCATD *
To build fieldcatalog in the display mode *
-->pr_Tabname type lvc_tname *
-->pr_Fieldname type lvc_fname *
-->pr_Coltext type lvc_txtcol *
-->pr_Colpos type lvc_colpos *
FORM build_fcatd USING pr_tabname TYPE lvc_tname
pr_fieldname TYPE lvc_fname
pr_coltext TYPE lvc_txtcol
pr_colpos TYPE lvc_colpos .
CLEAR fs_fcat.
fs_fcat-tabname = pr_tabname.
fs_fcat-fieldname = pr_fieldname.
fs_fcat-coltext = pr_coltext.
fs_fcat-col_pos = pr_colpos.
fs_fcat-edit = space.
APPEND fs_fcat TO t_fcat.
ENDFORM. " BUILD_FCATD
FORM ALV_DISPLAY *
To display data in ALV *
--> pr_table type standard table *
--> pr_fcat type lvc_t_fcat *
FORM alv_display USING pr_table TYPE STANDARD TABLE
pr_fcat TYPE lvc_t_fcat .
Local data declaration....
DATA: lt_exclude TYPE ui_functions.
To exclude buttons on the ALV grid
PERFORM exclude_tb_functions CHANGING lt_exclude.
To display ALV
CALL METHOD g_alv->set_table_for_first_display
EXPORTING
i_default = space
is_layout = g_fcatlayo
it_toolbar_excluding = lt_exclude
CHANGING
it_outtab = pr_table[]
it_fieldcatalog = pr_fcat[].
ENDFORM. " ALV_DISPLAY
FORM EVENT_TOOLBAR *
Setting toolbar in the alv grid *
-->E_OBJECT TYPE REF TO CL_ALV_EVENT_TOOLBAR_SET *
FORM event_toolbar USING e_object
TYPE REF TO cl_alv_event_toolbar_set.
Local declaration for the button.
DATA: ls_toolbar TYPE stb_button.
To add Approve button
ls_toolbar-function = c_fcode_approve.
ls_toolbar-butn_type = c_zero.
ls_toolbar-text = text-001.
APPEND ls_toolbar TO e_object->mt_toolbar.
To add Reject button
CLEAR ls_toolbar.
ls_toolbar-function = c_fcode_rej.
ls_toolbar-butn_type = c_zero.
ls_toolbar-text = text-013.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDFORM. " EVENT_TOOLBAR
FORM EXCLUDE_TB_FUNCTIONS *
To exclude buttons from ALV grid *
<--> PR_EXCLUDE TYPE UI_FUNCTIONS *
FORM exclude_tb_functions CHANGING pr_exclude TYPE ui_functions.
Local data declaration...
DATA ls_exclude TYPE ui_func.
To remove the buttons on the ALV grid.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
APPEND ls_exclude TO pr_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND ls_exclude TO pr_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND ls_exclude TO pr_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND ls_exclude TO pr_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
APPEND ls_exclude TO pr_exclude.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
FORM EVENT_UCOMM *
After Input in the ALV grid,if user select record and press *
approve or reject then the record will get updated *
--> PR_ucomm type sy-ucomm *
FORM event_ucomm USING pr_ucomm LIKE sy-ucomm.
CASE pr_ucomm.
If e_ucomm contains 'APP' i.e.function code for Approve button
WHEN c_fcode_approve. " To approve selected record
PERFORM app_timesheet USING c_approve_status.
If e_ucomm contains 'REJ' i.e. function code for Reject
WHEN c_fcode_rej. " To reject selected record
PERFORM app_timesheet USING c_rej_status.
ENDCASE. " CASE E_UCOMM
ENDFORM. " EVENT_UCOMM
FORM APP_TIMESHEET *
To get the selected records and update the records in database *
--> pr_status type char01 *
FORM app_timesheet USING pr_status TYPE char01 .
Local data declaration......
DATA:
lt_marked_rows TYPE lvc_t_roid, " Table to get rowid
l_fs_marked_row LIKE LINE OF lt_marked_rows.
" Field-string for lt_marked_rows
To get all the selected rows in the table lt_marked_rows
CALL METHOD g_alv->get_selected_rows
IMPORTING
et_row_no = lt_marked_rows.
Reading each row id and updating the database.
LOOP AT lt_marked_rows INTO l_fs_marked_row.
Reading the table t_timesheet with rowid
READ TABLE t_timesheet INTO fs_timesheet INDEX
l_fs_marked_row-row_id.
If record is there in the table.
IF sy-subrc EQ 0.
CLEAR fs_timesheet-appstatus.
GET PARAMETER ID 'ZEMPID' FIELD w_empid.
Changing the appstatus.
fs_timesheet-appstatus = pr_status.
fs_timesheet-approvedby = w_empid.
Updating the database table.
UPDATE zcl_timesheet FROM fs_timesheet.
IF sy-subrc EQ 0.
DELETE t_timesheet INDEX l_fs_marked_row-row_id.
PERFORM refresh_table USING pr_status.
ENDIF. " IF SY-SUBRC EQ 0.
ENDIF. " IF SY-SUBRC EQ 0
ENDLOOP. " LOOP AT LT_MARKED_ROWS...
ENDFORM. " APP_TIMESHEET
FORM CHECK_CHANGED_DATA *
To change the data *
No parameters are passsed to this subroutine *
FORM check_changed_data .
To change the data.
CALL METHOD g_alv->check_changed_data.
ENDFORM. " CHECK_CHANGED_DATA
FORM DISPLAY_ALL *
To display all the records *
No parameters are passsed to this subroutine *
FORM display_all .
SELECT empid " Employee ID
workdate " Workdate
groupid " Groupid
projectid " Project ID
projectname " Project name
objectid " Object ID
objectname " Object name
activityid " Activity ID
activityname " Activity name
timeworked " Time worked
description " Description
taskstatus " Task status
billstatus " Bill status
appstatus " Approved status
wstatus " Working status
mngcomment " Manager comment
FROM zcl_timesheet
INTO TABLE t_time
WHERE empid IN s_empid
AND workdate IN s_date
AND groupid IN s_group
AND projectid IN s_prjid
AND appstatus NE c_save_status.
IF sy-subrc NE 0.
MESSAGE e000.
ELSE.
CALL SCREEN 100.
ENDIF. " IF SY-SUBRC NE 0
ENDFORM. " DISPLAY_ALL
FORM REFFRESH_TABLE *
To refresh output table and issue message according p_status *
-->PR_STATUS TYPE CHAR01 *
FORM refresh_table USING pr_status TYPE char01.
To refresh output table.
CALL METHOD g_alv->refresh_table_display.
Depending upon pr_status message is given.
IF pr_status EQ c_approve_status.
MESSAGE s001.
ELSE.
MESSAGE s002.
ENDIF. " IF P_STATUS EQ C_APPROVE_STATUS
ENDFORM. " REFRESH_TABLE
FORM SET_TITLEBAR *
To set titlebar on the screen 100. *
-->PR_STATUS TYPE CHAR01 *
FORM set_titlebar USING pr_status TYPE char01.
If pr_status eq 'X'.
IF pr_status EQ c_boolean_yes.
SET TITLEBAR c_alv_scr WITH text-017.
ELSE.
SET TITLEBAR c_alv_scr WITH text-018.
ENDIF. " IF P_STATUS EQ C_BOOLEAN_YES
ENDFORM. " SET_TITLEBAR
FORM USER_COMMAND *
According to sy-ucomm the action is performed in the screen 100 *
No parameters are passsed to this subroutine *
FORM user_command .
CASE sy-ucomm.
If p_app is selected, submitted data will be displayed for approval
WHEN c_fcode_onli OR c_fcode_approve.
CLEAR sy-ucomm.
To display the submitted records.
IF p_app EQ c_boolean_yes.
w_submit = c_boolean_yes.
To get submitted records
PERFORM get_data.
ENDIF. " IF P_APP EQ C_BOOLEAN_YES
To display all records according to selection.
IF p_disp EQ c_boolean_yes.
w_display = c_boolean_yes.
To display
PERFORM display_all.
CLEAR w_display.
ENDIF. " IF P_DISP EQ C_BOOLEAN_YES
ENDCASE. " CASE SY-UCOMM
ENDFORM. " USER_COMMAND
FORM DISPLAY_ALLRECORDS *
To display all the records in the display mode *
No parameters are passsed to this subroutine *
FORM display_allrecords .
CLEAR w_display.
PERFORM build_fcatd USING 'T_TIME' 'WORKDATE' text-002 '1'.
PERFORM build_fcatd USING 'T_TIME' 'EMPID' text-009 '2'.
PERFORM build_fcatd USING 'T_TIME' 'PROJECTID' text-003 '3'.
PERFORM build_fcatd USING 'T_TIME' 'PROJECTNAME' text-004 '4'.
PERFORM build_fcatd USING 'T_TIME' 'OBJECTID' text-005 '5'.
PERFORM build_fcatd USING 'T_TIME' 'OBJECTNAME' text-006 '6'.
PERFORM build_fcatd USING 'T_TIME' 'ACTIVITYID' text-007 '7'.
PERFORM build_fcatd USING 'T_TIME' 'ACTIVITYNAME' text-008 '8'.
PERFORM build_fcatd USING 'T_TIME' 'TIMEWORKED' text-010 '9'.
PERFORM build_fcatd USING 'T_TIME' 'DESCRIPTION' text-011 '10'.
PERFORM build_fcatd USING 'T_TIME' 'APPSTATUS' text-012 '11'.
PERFORM build_fcatd USING 'T_TIME' 'BILLSTATUS' text-016 '12'.
PERFORM build_fcatd USING 'T_TIME' 'MNGCOMMENT' text-014 '13'.
PERFORM alv_display USING t_time t_fcat.
ENDFORM. " DISPLAY_ALLRECORDS
FORM SUBMITTED_RECORDS *
To display submitted records for the manager to approve *
No parameters are passsed to this subroutine *
FORM submitted_records .
CLEAR w_submit.
To create object for instance g_events
CREATE OBJECT g_events.
If w_first equal to space
IF w_first IS INITIAL.
SET HANDLER g_events->toolbar
FOR g_alv.
w_first = c_boolean_yes.
ENDIF. " IF W_FIRST IS INITIAL..
SET HANDLER g_events->user_command
FOR g_alv.
g_fcatlayo-sel_mode = c_approve_status.
REFRESH t_fcat.
PERFORM build_fcat USING 'T_TIMESHEET' 'WORKDATE' text-002 '1'.
PERFORM build_fcat USING 'T_TIMESHEET' 'EMPID' text-009 '2'.
PERFORM build_fcat USING 'T_TIMESHEET' 'PROJECTID' text-003 '3'.
PERFORM build_fcat USING 'T_TIMESHEET' 'PROJECTNAME' text-004 '4'.
PERFORM build_fcat USING 'T_TIMESHEET' 'OBJECTID' text-005 '5'.
PERFORM build_fcat USING 'T_TIMESHEET' 'OBJECTNAME' text-006 '6'.
PERFORM build_fcat USING 'T_TIMESHEET' 'ACTIVITYID' text-007 '7'.
PERFORM build_fcat USING 'T_TIMESHEET' 'ACTIVITYNAME' text-008 '8'.
PERFORM build_fcat USING 'T_TIMESHEET' 'TIMEWORKED' text-010 '9'.
PERFORM build_fcat USING 'T_TIMESHEET' 'DESCRIPTION' text-011 '10'.
PERFORM build_fcat USING 'T_TIMESHEET' 'APPSTATUS' text-012 '11'.
PERFORM build_fcat USING 'T_TIMESHEET' 'BILLSTATUS' text-016 '12'.
PERFORM build_fcat USING 'T_TIMESHEET' 'MNGCOMMENT' text-014 '13'.
PERFORM alv_display USING t_timesheet t_fcat.
ENDFORM. " SUBMITTED_RECORDS
Plzz Reward if it is useful,
Mahi. -
How to assign a tooltip for a field in ALV editable grid?
I have to display some instructions ( 50 chars long) for an editable field in alv.
How to do this?
BCALV_DEMO_TOOLTIP tells about assiging tooltip to an icon or symbol.
Thanks,
Ven..Neither of these two example programs help much in regards to tooltips against any field of any row. Both of these examples use tooltips for Icons. I have also been looking for a single example of tooltips usage outside of these two programs, and have found nothing in SAP, or on the internet, so far.
Having said that, I have tried to implement the same method used by the later example, but have not got this to work. What I think we need is an example of this functionality where these Icons are not used!. I believe.
Gary King -
Cell data not getting refreshed in which user enters data OO ALV(editable)
Hi Friends,
I am using OO ALV for editable grid display.
I am unable to change grid data in the cell in which user enters something, using OO ALV. Did through debugging of my own program and found that some problem with system program. Then I did all system debugging. Could not find out why is the grid not getting refreshed with the new data in the cell in which user had entered some value. Rest of the cell's data are getting refreshed with the values which i am updating in the final internal table. I can see that the data in the final internal table is changed for the cell in which user enters data. But even after the call of
CALL METHOD obj_alvgrid1->refresh_table_display
does not refreshes the data in the cell in which user had entered data. Rest of the cells data are getting refreshed.
Piece of code:
SET HANDLER obj_event_receiver->handle_data_changed
FOR obj_alvgrid1.
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.
METHOD handle_data_changed.
DATA : v_valid TYPE char1,
v_refresh TYPE char1.
*--check mt_good_cells semantically
CALL METHOD perform_semantic_checks( er_data_changed ).
*--If PBO is again visited, just refresh the ALV grid.
CALL METHOD obj_alvgrid1->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ENDMETHOD.
METHOD perform_semantic_checks.
LOOP AT er_data_changed->mt_good_cells INTO w_good.
v_index = sy-tabix.
CASE w_good-fieldname.
WHEN 'ZASCAS'.
*Now here based on some conditions I am changing my final internal table i_zamtsmatnp
MODIFY i_zamtsmatnp FROM w_zamtsmatnp INDEX
w_good-row_id TRANSPORTING
zascas modif.
User enters data in zascas field. Based on the data entered, I am changing other fields which is getting refreshed. I am also changing zascas in the program even after user had already entered the value which was bit wrong and i am correcting it in the program on the even "data_changed" even.
Please help me friends as i m strugling past hours wondering why the data is not getting refreshed for the cell in which user enter data.
Regards,
SuryaHi Surya,
The approach you are following is correct. You need to use the comibnation of all these things:
Event - DATA_CHANGED
Methods - CHECK_CHANGED_DATA
- GET_CHANGED_DATA.
However, here are few standard programs which are having similar functionality.
BCALV_EDIT_03
BCALV_EDIT_07
Check out these once.
Note: If anything is helpful, dont forget to reward points
Thanks,
Adithya K
SAP Practise
[email protected] -
ALV edit (qty field is not convertable)
in my ALV program i have used one field MENGE (13,3) (QTY field) in the out put it is showing as 1.000,
when user going to enter a value (5) it is showing as 0.005 but user need it as 5.000.
please solve this question experts.....
Regards
Prasad.EVhi venkatesh,
MENGE is QTY field,
instead of that u can give F (float) field then user can enter 5 it will be display 5.000.... that is best way to use it..
points please.. (if u have satisfied.)
Prasad.
Edited by: EV prasad on Jun 6, 2008 10:10 AM
Maybe you are looking for
-
Setting Recurring Dates in Calendar
Many times I need to set a recurring event in the Calendar based not on a fixed date but on a day of the week - such as the last Monday of each month or the last Monday of a given month. If this is not possible in the current version of Calendar, doe
-
Hi, What would be the best process from the point of export (in what video format) to actually burning an HD DVD when exporting from FCE 4.0 without losing quality? I have - DVDSP 4.0 Compressor 2.0 IDVD 7.0 MacBook Pro Intel
-
F4 help for file on selection screen thro objects
Hi Every one, this report is working , but as i am working ECC6.0 it is showing the obsolete statements how to rectify it . pls anybody let me know, tables rlgrap. TYPES : BEGIN OF TAB, MATNR TYPE MATNR , MTART TYPE MTART, END OF TAB. DATA : ITAB TYP
-
Photos didn't update iPhoto photos
Updates. Ugh. The fabulous new Photos app came up with no photos in it. Not a one. I have hundreds of pictures in iPhoto. After panicking and running around in circles, I figured out that iPhoto is still on the hard drive, and when I open it, it show
-
Oxford922 Panther bug . Should I upgrade to Tiger ?
I am running out of space and need a new external drive . The Fantom Titanium was recommended on another thread but at their site . http://www.fantomdrives.com/ I found this warning . http://www.micronet.com/support/fwpanthercomp.asp I have a tiger d