Remove standard error message for check table in ALV grid - abap

I'm using editable OO ALV to display some records from custom table. The key is matnr in ref table is MARA. User can insert new records or edit existing records. I need to check if matnr exists in MARA, if doesn't display err message. But because the fieldacatolog has ref table if user insert not valid matnr, pop up message is displayed with error message. I want to remove this message and to display other custom message. I can't delete ref table in the fieldacatalog, because it's needed for search help. Also my err message is
MESSAGE ID '00' TYPE 'S' NUMBER 058 WITH matnr '' '' 'MARA' DISPLAY LIKE 'E'.

Popup up messages and the message you want to show are two different things, so you can disable the popup up messages and just display your own.
After creating your alv grid object, just use this function to disable the popup one:
go_your_alv_grid_object->activate_display_protocol( space ).
To enable it again, use this:
go_your_alv_grid_object->activate_display_protocol( 'X' ).

Related

CL_GUI_ALV_GRID editable field not refresh

I have an ALV grid with an editable field, if I check the data entered and display errors, the ALV updates, if I try to change the input data, other times the ALV does not update anymore.
The code in the PAI is:
ls_layout-cwidth_opt = abap_true.
CREATE OBJECT go_alv
EXPORTING
i_parent = cl_gui_custom_container=>screen0
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc EQ 0.
* Adapting field catalog
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZAMOUNT'
CHANGING
ct_fieldcat = lt_fieldcat.
IF sy-subrc EQ 0.
* Field catalog specifics
LOOP AT lt_fieldcat ASSIGNING <ls_fieldcat>.
IF <ls_fieldcat>-fieldname = 'DMBTR'.
<ls_fieldcat>-edit = abap_true.
ENDIF.
ENDLOOP.
ENDIF.
* Show data usig ALV class
go_alv->set_table_for_first_display(
EXPORTING
is_layout = ls_layout
CHANGING
it_outtab = gt_out
it_fieldcatalog = lt_fieldcat ).
go_alv->set_ready_for_input( EXPORTING
i_ready_for_input = 1 ).
CALL METHOD go_alv->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CALL METHOD go_alv->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
ENDIF.
The code in the PBO is:
IF go_alv IS NOT INITIAL.
CALL METHOD go_alv->check_changed_data( ).
PERFORM check_amounts TABLES gt_out
CHANGING gv_sum_amounts
gv_tot_amount.
CALL METHOD go_alv->refresh_table_display
EXPORTING
is_stable = VALUE #( row = abap_true
col = abap_true )
i_soft_refresh = 'X'.
cl_gui_cfw=>flush( ).
ENDIF.
In the perform check_amounts I populate a field of the ALV with the errors, if the user modifies the input field and the error is removed in the internal table but it is not shown in the ALV.
I also tried to implement the data_change_finished method by calling the refresh inside but I have not solved the anomaly.
Can you help me?
Thanks
I'm not quite sure if I understand your problem but here are some potential issues I see:
You have your validity checks split up. On the one hand there is the data_changed event. On the other hand you have the check_amounts perform.
If the data_changed event finds an input error, it'll show you the red outline on your grid. In your internal table ("gt_out") this field will stay the same as before (it'll not update the table with the invalid input !).
This might be why you think there should be a message in your grid but there isn't.
Did you define your own local version for the data_changed event? Than the handlers are missing. When you tried doing the refresh in the data_changed_finished event you definitly need the handler for that.
Also you said that you only put the refresh in the method for data_changed_finished. You need to put the check_amount perform there too then. Otherwise you called the refresh to early.
In the method for data_changed_finished you have the automatically updated table ("gt_out") from the data_changed method. You should be able to update it here and send it to your grid with a refresh.
I don't like that you call the check_changed_data method in your PBO. Because of the register_edit_event calls the data_changed event already triggers when you hit enter or jump to the next field. You usually only call this method when you received a seperat user command, that can be fired before the event can be triggered to be sure that you have correct data.
Not 100% sure about this but for your register_edit_event calls, the event id cl_gui_alv_grid=>mc_evt_modified should include the event id cl_gui_alv_grid=>mc_evt_enter already.
I'd try to define a local class to handle the data_changed and data_changed_finished events and put the check_amount and refresh in the method for the data_changed_finished event.
Maybe some of this helps you? If you have any questions about any of this, let me know and I can go into more detail.
regards

How to trigger the ALV DATA_CHANGE event manually?

I have an instance of CL_GUI_ALV_GRID referenced by variable mo_alv_grid.
I have a button column in this grid, which after some logic, updates the table mt_alv_grid (backing mo_alv_grid).
I need to be able to trigger the event DATA_CHANGED at this point.
I have tried many methods of CL_GUI_ALV_GRID, like CHECK_DATA_CHANGED and REFRESH_TABLE_DISPLAY
and even CL_GUI_CFW=>FLUSH and CL_GUI_CFW=>SET_NEW_OK_CODE( 'ENTER' ). but none of this has worked.
Is there a way to trigger the DATA_CHANGED event, or should I be doing things completely differently ?
I don't know if this solves your problem, but in order to update the ALV internal table in the PAI, you could use the following method:
DATA lv_entries_are_consisted TYPE abap_bool.
mo_grid->check_changed_data(
IMPORTING
e_valid = lv_entries_are_consisted
).
well, it's possible.
1) don't change values in internal table by program
2) create a change protocol of type LVC_T_MODI with a new values for lines needed
then call
CALL METHOD lo_grid->change_data_from_inside
EXPORTING
it_style_cells = lt_cells.
where lo_grid is instance of cl_gui_alv_grid and lt_cells table type LVC_T_MODI. please note, that you will need to set field VAL_DATA of layout structure (LVC_S_LAYO) to 'X' when calling ALV grid for the first time to make this work.
after this, class will automatically change internal table for you and call DATA_CHANGE event

Automatic filling of NAME_1 when entered a valid KUNNR - SM30

I've made a table with three fields: KUNNR, NAME_1 and Z_CLASS. KUNNR has KUNNR as data element, NAME_1 has NAME1_GP and Z_CLASS has a data element that I made with 3 values (1, 2 or 3). I've made the table maintenance generator and put some data in with SM30. Now, I need to make the name of the client show automatically (NAME_1) when I enter a client number (KUNNR) and press enter; and need to make sure that the Z_CLASS is filled and not leaved in blank. I don't really know how to search for the solution because I'm new to SAP. Thank you.
PROCESS BEFORE OUTPUT.
MODULE LISTE_INITIALISIEREN.
LOOP AT EXTRACT WITH CONTROL
TCTRL_Z10FICLASSFICA CURSOR NEXTLINE.
MODULE LISTE_SHOW_LISTE.
ENDLOOP.
*
PROCESS AFTER INPUT.
MODULE LISTE_EXIT_COMMAND AT EXIT-COMMAND.
MODULE LISTE_BEFORE_LOOP.
LOOP AT EXTRACT.
MODULE LISTE_INIT_WORKAREA.
CHAIN.
FIELD Z10FICLASSFICA-KUNNR .
FIELD Z10FICLASSFICA-NAME1 .
FIELD Z10FICLASSFICA-Z_CLASS .
MODULE SET_UPDATE_FLAG ON CHAIN-REQUEST.
ENDCHAIN.
FIELD VIM_MARKED MODULE LISTE_MARK_CHECKBOX.
CHAIN.
FIELD Z10FICLASSFICA-KUNNR .
MODULE LISTE_UPDATE_LISTE.
ENDCHAIN.
ENDLOOP.
MODULE LISTE_AFTER_LOOP.
As for the name, do not keep it as a reundant field. Define a foreign key relationship and then use a maintenance view to display the name that corresponds to the customer number.
For the mandatory field check, edit the generated screen and add a module that checks whether the required fields are filled out. It should also be possible to set the field to mandatory in the screen field options, but I wouldn't recommend this because then the field will be displayed as mandatory even for empty lines.
I've found the answer for both problems. For automatic filling the name of the client I used a form routine with the event "Filling hidden fields" (no. 21). In the generated include I used this code:
FORM fill_hidden.
DATA: lc_name1 TYPE kna1-name1.
Data: lc_kunnr TYPE kna1-kunnr.
lc_kunnr = z10ficlassfica-kunnr.
SELECT SINGLE name1 INTO lc_name1 FROM kna1 WHERE kunnr = lc_kunnr.
z10ficlassfica-name1 = lc_name1.
endform.
For the mandatory field I went to Maintenance Screens, Element List tab, Special Attributes tab and choose mandatory from the drop down menu in the Entry column.
Worked like a charm. Thanks for all your answers :)

How to get select box options from GetCustomFields() method of jira

I was curious if anyone else had an idea how to get a select box options of the custom field in JIRA using soap api, if you have have custom field id.
You can reference select list values by their id. To get id go to Custom Field configuration -> Edit Options. Hover over the option's 'Edit' operation (or click on Edit) and check link address. It will be something like 'secure/admin/EditCustomFieldOptions!edit.jspa?fieldConfigId=10480&selectedValue=10030'
selectedValue is the id of select list option.

How to get the selected entry in WebDynpro ABAP table?

I have a webdynpro containing a table displaying numerous lines. After the user clicks the delete button I want to delete the selected line of the table.
My problem right now is, that I don't know how to implement this in the event-call.
How can I identify the selected line of the table?
If by "table" you mean an editable ALV, there's a preset function for this. Take a look at http://help.sap.com/saphelp_nw04s/helpdata/EN/5f/ec57c72a1349c8bfdda56d976e9399/frameset.htm and http://help.sap.com/saphelp_nw04s/helpdata/EN/5f/ec57c72a1349c8bfdda56d976e9399/frameset.htm For details on how to process the selection manually, see http://help.sap.com/saphelp_nw04s/helpdata/EN/5f/ec57c72a1349c8bfdda56d976e9399/frameset.htm.
I finally got the solution:
In the button event implement the following, to access the node and finally the id-value:
method ONACTIONZSS10_15_ONDELETE .
DATA ls_cust type wd_this->element_IT_Cust.
DATA lo_nd_cust TYPE REF TO if_wd_context_node.
DATA lo_el_cust TYPE REF TO if_wd_context_element.
" Get the selected element
lo_nd_cust = wd_context->get_child_node( name = 'IT_CUST' ).
lo_el_cust = lo_nd_cust->get_element( ).
" Get the attributes of the node-element
lo_el_cust->get_static_attributes(
IMPORTING
static_attributes = ls_cust ).
" Call the delete-function
CALL FUNCTION 'ZSS10_15_CUST_FM_DELETE'
EXPORTING
custid = ls_cust-ID
.
endmethod.