i have created a bobf object in cds named /BOBF/IF_FRW_VALIDATION~EXECUTE
to use it for validation purpose i have tried following code to stop updating the value using its export parameter eo_message.
DATA: ls_message TYPE symsg.
if lv_val = abap_false.
ls_message-msgty ='E'.
ls_message-msgid = 'SY'.
ls_message-msgno = '005'.
IF eo_message IS NOT BOUND.
eo_message = /bobf/cl_frw_factory=>get_message( ).
ENDIF.
ET_FAILED_KEY = IT_KEY.
APPEND VALUE #( key = ls_root-key ) TO et_failed_key.
CALL METHOD eo_message->add_message
EXPORTING
is_msg = ls_message.
endif.
but the update operation(for which i have created the bobf) is still being performed
in bobf validations object click on "trigger configuration" of your corresponding implementation class there i had to select on 'check before save' and also select checkbox of the check field along with update field.
Related
I am struggling with the following issue:
I have two tables (header and items) that I want to connect them by using a hotspot and the class CL_SALV_TABLE. I managed to display the header table and set a hotspot on the column with the number of the order. I want that the second table opens as a popup window after I click once on the number field (which was my hotspot). However, I don't know how to define the event. I know how to get a popup window by using the display method of CL_SALV_TABLE, e.g., this code:
CALL METHOD cl_salv_table=>factory(
* EXPORTING
* list_display = IF_SALV_C_BOOL_SAP=>FALSE
* r_container =
* container_name =
IMPORTING
r_salv_table = o_alv
CHANGING
t_table = it_tab )
.
CATCH cx_salv_msg .
ENDTRY.
o_alv->set_screen_popup( start_column = 1
end_column = 150
start_line = 1
end_line = 30 ).
o_alv->display( ).
Any comment or help is highly appreciated. Thank you in advance!
Here is a minimal example to execute code when an ALV hotspot field is clicked (when any cell in the column "Book number" is clicked, a popup is displayed with a text, but you can do whatever you want of course).
What is important to remember:
METHODS on_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid ... : this is the method to define the code to run when the hotspot field is clicked
SET HANDLER on_hotspot_click ... : to tell the Control Framework to trigger the method when the event occurs
Code:
CLASS lcl_app DEFINITION.
PUBLIC SECTION.
METHODS constructor.
METHODS on_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no.
DATA go_alv TYPE REF TO cl_gui_alv_grid.
DATA gt_sbook TYPE TABLE OF sbook.
ENDCLASS.
CLASS lcl_app IMPLEMENTATION.
METHOD constructor.
CREATE OBJECT go_alv EXPORTING i_parent = cl_gui_container=>screen0.
SELECT * FROM sbook INTO TABLE gt_sbook.
DATA(fieldcatalog) = VALUE lvc_t_fcat(
( fieldname = 'BOOKID' ref_table = 'SBOOK' ref_field = 'BOOKID' hotspot = 'X' ) ).
SET HANDLER on_hotspot_click FOR go_alv.
go_alv->set_table_for_first_display(
EXPORTING i_structure_name = 'SBOOK'
CHANGING it_outtab = gt_sbook it_fieldcatalog = fieldcatalog ).
ENDMETHOD.
METHOD on_hotspot_click.
READ TABLE gt_sbook INDEX es_row_no-row_id INTO DATA(ls_sbook).
IF sy-subrc = 0.
MESSAGE |click { ls_sbook-bookid } col { e_column_id-fieldname } row { es_row_no-row_id }| TYPE 'I'.
ENDIF.
ENDMETHOD.
ENDCLASS.
DATA go_app TYPE REF TO lcl_app.
PARAMETERS dummy.
AT SELECTION-SCREEN OUTPUT.
IF go_app IS NOT BOUND.
go_app = NEW lcl_app( ).
ENDIF.
Whenever an invalid value is entered in an ALV Grid, how do I disable the other fields (grey out) in the grid and force the user to fix the incorrect field.
I have tried adding protocol in DATA_CHANGED event. But protocol list only shows the error in popup. Editing is still possible and no fields are disabled.
But how do I disable the other fields. Sample behavior as shown below:
Here, the other fields are greyed out and the invalid entry is highlighted. Until the user fixes this error, he/she cannot proceed further.
Having screen 100 with container CCONTAINER1 paste this snippet
CLASS zcl_alv_test DEFINITION.
PUBLIC SECTION.
METHODS: constructor, display_grid, populate_grid.
DATA: lr_rtti_struc TYPE REF TO cl_abap_structdescr,
it_fldcat TYPE lvc_t_fcat,
grid_container1 TYPE REF TO cl_gui_custom_container,
grid1 TYPE REF TO cl_gui_alv_grid.
DATA: BEGIN OF gs_outtab.
INCLUDE TYPE spfli.
DATA: celltab TYPE lvc_t_styl.
DATA: END OF gs_outtab.
DATA gt_outtab1 LIKE TABLE OF gs_outtab INITIAL SIZE 0.
METHODS:
handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING er_data_changed,
handle_data_changed_finished FOR EVENT data_changed_finished OF cl_gui_alv_grid IMPORTING e_modified et_good_cells,
create_dynamic_fcat.
PRIVATE SECTION.
TYPES: ty_tab LIKE LINE OF gt_outtab1.
METHODS: refresh_grid, fill_celltab IMPORTING p_fieldname TYPE lvc_fname
CHANGING pt_celltab TYPE lvc_t_styl.
ENDCLASS.
CLASS zcl_alv_test IMPLEMENTATION.
METHOD constructor.
CREATE OBJECT grid_container1 EXPORTING container_name = 'CCONTAINER1'.
CREATE OBJECT grid1 EXPORTING i_parent = grid_container1.
SET HANDLER handle_data_changed FOR grid1.
SET HANDLER handle_data_changed_finished FOR grid1.
CALL METHOD grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
ENDMETHOD. "constructor
METHOD fill_celltab.
LOOP AT pt_celltab ASSIGNING FIELD-SYMBOL(<fs_fcat>).
IF <fs_fcat>-fieldname = p_fieldname.
<fs_fcat>-style = cl_gui_alv_grid=>mc_style_enabled.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD handle_data_changed.
DATA: lt_celltab TYPE lvc_t_styl.
LOOP AT it_fldcat ASSIGNING FIELD-SYMBOL(<fs_fcat>).
INSERT VALUE lvc_s_styl( style = cl_gui_alv_grid=>mc_style_disabled fieldname = <fs_fcat>-fieldname ) INTO TABLE lt_celltab.
ENDLOOP.
MODIFY gt_outtab1 FROM VALUE ty_tab( celltab = lt_celltab ) TRANSPORTING celltab WHERE connid IS NOT INITIAL.
LOOP AT er_data_changed->mt_mod_cells ASSIGNING FIELD-SYMBOL(<mods>).
READ TABLE gt_outtab1 ASSIGNING FIELD-SYMBOL(<sym>) INDEX <mods>-row_id.
fill_celltab( EXPORTING p_fieldname = <mods>-fieldname
CHANGING pt_celltab = <sym>-celltab ).
MODIFY gt_outtab1 FROM <sym> INDEX <mods>-row_id.
ENDLOOP.
refresh_grid( ).
ENDMETHOD.
METHOD handle_data_changed_finished.
DATA: lt_celltab TYPE lvc_t_styl.
LOOP AT it_fldcat ASSIGNING FIELD-SYMBOL(<fs_fcat>).
IF sy-tabix MOD 2 = 0.
DATA(style) = cl_gui_alv_grid=>mc_style_disabled.
ELSE.
style = cl_gui_alv_grid=>mc_style_enabled.
ENDIF.
INSERT VALUE lvc_s_styl( style = style fieldname = <fs_fcat>-fieldname ) INTO TABLE lt_celltab.
ENDLOOP.
MODIFY gt_outtab1 FROM VALUE ty_tab( celltab = lt_celltab ) TRANSPORTING celltab WHERE connid IS NOT INITIAL.
refresh_grid( ).
ENDMETHOD.
METHOD create_dynamic_fcat.
lr_rtti_struc ?= cl_abap_structdescr=>describe_by_name( 'SPFLI' ).
DATA(comps) = lr_rtti_struc->components.
LOOP AT comps ASSIGNING FIELD-SYMBOL(<comps>).
IF sy-tabix MOD 2 = 0.
DATA(edit) = abap_false.
ELSE.
edit = abap_true.
ENDIF.
APPEND VALUE lvc_s_fcat( edit = edit fieldname = <comps>-name datatype = <comps>-type_kind inttype = <comps>-type_kind intlen = <comps>-length decimals = <comps>-decimals coltext = <comps>-name lowercase = 'X' ) TO it_fldcat .
ENDLOOP.
ENDMETHOD. "create_dynamic_fcat
METHOD populate_grid.
SELECT * UP TO 1000 ROWS
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE gt_outtab1.
ENDMETHOD. "CHANGE_TITLE
METHOD display_grid.
create_dynamic_fcat( ).
grid1->set_table_for_first_display(
EXPORTING
is_layout = VALUE lvc_s_layo( zebra = abap_true stylefname = 'CELLTAB' )
CHANGING
it_outtab = gt_outtab1
it_fieldcatalog = it_fldcat ).
ENDMETHOD. "display_grid
METHOD refresh_grid.
cl_gui_cfw=>flush( ).
grid1->refresh_table_display( ).
ENDMETHOD.
ENDCLASS.
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
DATA: yalv TYPE REF TO zcl_alv_test.
CREATE OBJECT yalv.
yalv->populate_grid( ).
yalv->display_grid( ).
ENDMODULE.
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'RETURN'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
START-OF-SELECTION.
CALL SCREEN 100.
It uses the concept of cell styles, where each row in table is assigned a table of styles for each of the column in this row. There you can apply conditional attributes on a cell level, including editability.
When throwing an error through builtin checktables/domains, the grid is made not editable except erroneous cell, and when correcting the error, editability returns.
I have set a dropdown list for an ALV Grid cell. The dropdow works fine, but it allows to enter values from the dropdown value list only. Is it possible to allow free text entry in the cell?
My ABAP code is:
Creating a value list:
DATA: lt_dropdown TYPE lvc_t_dral,
ls_dropdown TYPE lvc_s_dral.
data: ls_taba TYPE dd07v,
lt_taba TYPE STANDARD TABLE OF dd07v,
lt_tabb TYPE STANDARD TABLE OF dd07v.
CALL FUNCTION 'DD_DOMA_GET'
EXPORTING
DOMAIN_NAME = 'ZBC_TRADE_NETWORK'
LANGU = SY-LANGU
WITHTEXT = 'X'
TABLES
DD07V_TAB_A = lt_taba
DD07V_TAB_N = lt_tabb
EXCEPTIONS
ILLEGAL_VALUE = 1
OP_FAILURE = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
return.
ENDIF.
loop at lt_taba into ls_taba.
ls_dropdown-handle = '1'.
ls_dropdown-int_value = ls_taba-domvalue_l.
ls_dropdown-value = ls_taba-ddtext.
APPEND ls_dropdown TO lt_dropdown.
endloop.
*method to display the dropdown in ALV
CALL METHOD go_grid->set_drop_down_table
EXPORTING
IT_DROP_DOWN_ALIAS = lt_dropdown.
Fill the field catalogue:
data: ls_fcat type lvc_s_fcat,
lt_fcat type lvc_t_fcat.
field-symbols: <lfs_fcat> type ls_fcat.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = gc_struct_name
changing
ct_fieldcat = lt_fcat
exceptions
others = 1.
loop at lt_fcat assigning <lfs_fcat>.
case <lfs_fcat>-fieldname.
when 'NETWORK'.
<lfs_fcat>-drdn_hndl = '1'.
<lfs_fcat>-drdn_alias = 'X'.
<lfs_fcat>-edit = abap_on.
endcase.
endloop.
Set ALV grid for display
go_grid->set_table_for_first_display(
exporting
i_save = lf_save
i_default = lf_default
is_variant = ls_vari
is_layout = ls_layo
it_toolbar_excluding = lt_excl
changing
it_outtab = <lfs_t_data>
it_fieldcatalog = lt_fcat
exceptions
others = 1
).
No. A drop-down field implies a fixed value set. If you want to have both a value catalog and a text editing facility, use a value help (F4 help) to implement the catalog access.
I need to call the same screen (question) repeatedly in a Movelet for filling and send its fields to SAP.
The number of calls to the screen will be set dinamically depending on a variable value.
Is it possible to do that? How can I do it?
Thanks in advance.
it is possible. Create a method for generating a screen called (for instance) ADD_LOOP_SCR:
IV_SCREEN_KEY TYPE /MOVI/LZR_ANSWER_KEY Movilizer: Answer Key
IV_NEXT_SCR_KEY TYPE /MOVI/LZR_ANSWER_KEY Movilizer: Answer Key
CS_MOVELET TYPE /MOVI/MS_ST_BUSSTEP_STRUCTURE Movelet structure
implementation (Epsilon example)
DATA:
lr_screen TYPE REF TO /movi/ms_st_screen_epsilon,
lr_answer TYPE REF TO /movi/ms_st_answer.
APPEND INITIAL LINE TO cs_movelet-epsilon_screens REFERENCE INTO lr_screen.
lr_screen->key = iv_screen_key.
APPEND INITIAL LINE TO lr_screen->answers REFERENCE INTO lr_answer.
CONCATENATE 'AK_' iv_screen_key INTO lr_answer->key.
CONCATENATE 'CK_' iv_screen_key INTO lr_answer->client_key.
lr_answer->next_screen_key = iv_next_scr_key.
lr_answer->followup_action = /movi/dsd_if_const=>movilizer-followup_action_none.
add_XXXXXX_mel(
EXPORTING
...... if needed
CHANGING
ct_mel_expressions = lr_screen->mel_expressions
ct_validations = lr_screen->validations
ct_restrictions = lr_screen->restrictions ).
and then mainly in the GENERATE method:
es_movelet-first_screen_key = 'SK_LOOPSCREEN_001'.
DATA:
lv_i TYPE numc3,
lv_sk TYPE /movi/lzr_answer_key,
lv_next_sk TYPE /movi/lzr_answer_key.
DO 5 TIMES.
lv_i = sy-index.
CONCATENATE 'SK_LOOPSCREEN_' lv_i INTO lv_sk.
ADD 1 TO lv_i.
IF lv_i > 5.
lv_next_sk = /movi/lzr_if_constants=>movilizer_movelet_exit_key.
ELSE.
CONCATENATE 'SK_LOOPSCREEN_' lv_i INTO lv_next_sk.
ENDIF.
add_generate_printout_data_scr( EXPORTING iv_screen_key = lv_sk
iv_next_scr_key = lv_next_sk
CHANGING cs_movelet = es_movelet ).
ENDDO.
Good luck, cheers,
Aleq
I have a report that should display an attachment list from an object.
For instance, in transaction FI02 (maintenance of banks), the GOS toolbar has the menu Attachment List:
I want to display this list. What is the best way to display it?
REPORT zay_gos_demo.
DATA ls_appl_object TYPE gos_s_obj.
DATA lo_gos_api TYPE REF TO cl_gos_api.
DATA lt_attachment_list TYPE gos_t_atta.
DATA lt_role_filter TYPE gos_t_rol.
DATA ls_attachment TYPE gos_s_atta.
DATA ls_attachm_cont TYPE gos_s_attcont.
DATA ls_atta_key TYPE gos_s_attkey.
ls_appl_object-typeid = 'KNA1'.
ls_appl_object-instid = '0000000001'.
ls_appl_object-catid = 'BO'. "BO - BOR Object
"CL - Persistent Class
START-OF-SELECTION.
* create instance of GOS API providing unique application object
TRY.
lo_gos_api = cl_gos_api=>create_instance( ls_appl_object ).
* get attachment list for this object (if needed restrict selection
* by adding certain roles to filter table; initial table means: get
* attachments in all roles)
APPEND cl_gos_api=>c_attachment TO lt_role_filter.
APPEND cl_gos_api=>c_annotation TO lt_role_filter.
APPEND cl_gos_api=>c_website TO lt_role_filter.
lt_attachment_list = lo_gos_api->get_atta_list( lt_role_filter ).
CATCH cx_gos_api.
* error handling
ENDTRY.
I found other example and I want to test it:
REPORT zay_attachment_list_display.
DATA: go_attachments TYPE REF TO cl_gos_attachments,
g_att_container TYPE REF TO cl_gui_custom_container,
ls_object TYPE borident,
lo_bitem TYPE REF TO cl_sobl_bor_item.
ls_object-objtype = 'KNA1'.
ls_object-objkey = '0000000001'.
IF NOT go_attachments IS INITIAL.
CLEAR go_attachments.
ENDIF.
CREATE OBJECT g_att_container
EXPORTING
container_name = 'ATTS'
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
ENDIF.
CREATE OBJECT lo_bitem
EXPORTING
is_bor = ls_object.
IF go_attachments IS INITIAL.
CREATE OBJECT go_attachments
EXPORTING
io_object = lo_bitem
ip_check_arl = 'X'
ip_check_bds = 'X'
io_container = g_att_container
* is_layout = ls_layout
* ip_mode = wf_mode
ip_notes = 'X'
ip_attachments = 'X'
ip_urls = 'X'.
ELSE.
go_attachments->set_container( g_att_container ).
ENDIF.
go_attachments->display( ).
I created a custom control in dynpro 0100 and I named it ATTS. I still can't get the attachment list of GOS. Did I miss something?
After weeks of searching and asking. it was really simple. just call the function GOS_ATTACHMENT_LIST_POPUP.
Example:
DATA: ls_object TYPE sibflporb,
save_request TYPE sgs_flag.
ls_object-instid = 'FR 1234567890'.
ls_object-typeid = 'BUS1011'.
ls_object-catid = 'BO'.
CALL FUNCTION 'GOS_ATTACHMENT_LIST_POPUP'
EXPORTING
is_object = ls_object
ip_mode = 'E' " Edit mode
IMPORTING
ep_save_request = save_request.
IF save_request = 'X'.
COMMIT WORK.
ENDIF.