10-13-2011 1:46 PM
Dear all,
I'm using the logic described in SAPs demo program BCALV_EDIT_03 to maintain and check data in an editable ALV Grid.
So far so good.
Additionally to checking the data when it's changed within the grid I want to perform all the checks on the complete data (all rows, all fields) BEFORE the data is displayed for the first time in the grid. In case of errors the grid should come up already the error message popup and highlited fields.
Background to that request is that the data is uploaded from a file and could be corrupted there. The ALV then is used as final check for user before data is actually posted to the SAP tables.
Is there any smart method to use the already implemented checking to be performed before first display of the data or some other idea???
Best regards,
Ulrich Meier
10-13-2011 10:43 PM
Check the below code to show the error log popup after the display...or check if you can call the handle_data_changed method with er_data_changed with all the data.
DATA LO_DATA_CHANGED TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
CREATE OBJECT LO_DATA_CHANGED
EXPORTING
I_CALLING_ALV = GO_GRID.
DATA LT_FIELDCAT_LVC TYPE LVC_T_FCAT.
CALL METHOD GO_GRID->GET_FRONTEND_FIELDCATALOG
IMPORTING
ET_FIELDCATALOG = LT_FIELDCAT_LVC.
LO_DATA_CHANGED->MT_FIELDCATALOG[] = LT_FIELDCAT_LVC.
LOOP AT GT_OUTPUT_DATA INTO GS_OUTPUT_DATA.
LV_TABIX = SY-TABIX.
* Check for errors...if errors found,
CALL METHOD LO_DATA_CHANGED->ADD_PROTOCOL_ENTRY
EXPORTING
I_MSGID = LV_MSGID
I_MSGNO = LV_MSGNO
I_MSGV1 = LV_FIELD_TEXT
I_MSGV2 = PV_CUST
I_MSGTY = GC_VALUE_E
I_FIELDNAME = 'FIELD'
I_ROW_ID = LV_TABIX.
LV_ERRORS = 'X'.
ENDLOOP.
IF LV_ERRORS is initial.
CALL METHOD LO_DATA_CHANGED->REFRESH_PROTOCOL.
else.
CALL METHOD LO_DATA_CHANGED->DISPLAY_PROTOCOL.
ENDIF.
10-13-2011 10:43 PM
Check the below code to show the error log popup after the display...or check if you can call the handle_data_changed method with er_data_changed with all the data.
DATA LO_DATA_CHANGED TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
CREATE OBJECT LO_DATA_CHANGED
EXPORTING
I_CALLING_ALV = GO_GRID.
DATA LT_FIELDCAT_LVC TYPE LVC_T_FCAT.
CALL METHOD GO_GRID->GET_FRONTEND_FIELDCATALOG
IMPORTING
ET_FIELDCATALOG = LT_FIELDCAT_LVC.
LO_DATA_CHANGED->MT_FIELDCATALOG[] = LT_FIELDCAT_LVC.
LOOP AT GT_OUTPUT_DATA INTO GS_OUTPUT_DATA.
LV_TABIX = SY-TABIX.
* Check for errors...if errors found,
CALL METHOD LO_DATA_CHANGED->ADD_PROTOCOL_ENTRY
EXPORTING
I_MSGID = LV_MSGID
I_MSGNO = LV_MSGNO
I_MSGV1 = LV_FIELD_TEXT
I_MSGV2 = PV_CUST
I_MSGTY = GC_VALUE_E
I_FIELDNAME = 'FIELD'
I_ROW_ID = LV_TABIX.
LV_ERRORS = 'X'.
ENDLOOP.
IF LV_ERRORS is initial.
CALL METHOD LO_DATA_CHANGED->REFRESH_PROTOCOL.
else.
CALL METHOD LO_DATA_CHANGED->DISPLAY_PROTOCOL.
ENDIF.
10-14-2011 12:39 PM
10-17-2011 9:07 AM
Hello,
you can try to call the ALV method "set_delta_cells" (which is unfortunately commented with "for internal use only"), and then call the "check_changed_data" method, which should trigger the "handle_data_changed" for each marked cell. But I don't know if this would work before the first display.
Regards,
Carsten
Edited by: Carsten Grafflage on Oct 17, 2011 10:08 AM
10-26-2011 2:32 PM
Thanks, Carsten!
That was final hint I needed. After some trial and error I found that additionally to your suggestion I need to call method refresh_table_display before calling set_delta_cells. Then data_change event was triggered even before first visual display of the ALV.
Regards,
Ulrich