06-20-2007 7:14 AM
Hi every one,
I have some output in alv format. From there the user can select which records he/she wants to get posted to a db. But the user always has to check two corresponding records i.e a debit and the corresponding credit for that record. I need to display a message before the posting to the db is done in case the user has checked the debit but forgot the credit and vice versa.
Can anyone please show me a way on how to do it.
Thanks
06-20-2007 7:20 AM
Hi ,
After choosing the record to be posted to Database; Make sure the validation and If subrc <> 0; give a POP_UP to display.
Regds,
Jyoti
06-20-2007 7:22 AM
Hi
First put the data of records that were selected on the ALV output into an internal table which consists of this Debit and Credit fields(like SHKZG field with H and S values)
So in the loop of that internal table before updating the records to DB table check whether field like SHKZG have vlues for Both Credit and Debit) if not fire an error message, if both are there then update the records from internal table to DB.
Reward points for useful Answers
Regards
Anji
06-20-2007 7:29 AM
Hi Anji,
thx for the answer! this is actually what I'm doing. For me the flag here is '40' for debit and '50' for credit. But in the loop, fields are being checked one by one, so after checking the first field for '40' it displays a message that '50' does not exist when it actually does and vice versa.
I think it must check simultaneously for one G/L a/c
06-20-2007 7:24 AM
Add User command functionality to ALVgrid report
In order to add user command functioality to the ALV grid you need to perform the following steps:
1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include 'USER_COMMAND' FORM
2. Create 'USER_COMMAND' FORM
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
I_callback_user_command = 'USER_COMMAND' "see FORM
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
* Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
here write the select statement from the table Bseg in your case and validate with debit credit and pass the message
if sy-subr = 0
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
else.
message e000(01) with ' debit credit was not mathing '.
endif .
ENDIF.
ENDCASE.
ENDFORM.
reward points if it is usefull...
Girish
06-20-2007 7:25 AM
Hi,
Check this out...
Controlling Data Changes
As we can now make our ALV Grid editable we may require controlling input data. The ALV Grid has events data_changed and data_changed_finished. The former method is triggered just after the change at an editable field is perceived. Here you can make checks for the input. And the second event is triggered after the change is committed.
You can select the way how the control perceives data changes by using the method register_edit_event. You have two choices:
i. After return key is pressed: To select this way, to the parameter i_event_id pass cl_gui_alv_grid=>mc_evt_enter.
ii. After the field is modified and the cursor is moved to another field:
For this, pass cl_gui_alv_grid=>mc_evt_modifies to the same parameter.
To make events controlling data changes be triggered, you must select either way by calling this method. Otherwise, these events will not be triggered.
To control field data changes, ALV Grid uses an instance of the class CL_ALV_CHANGED_DATA_PROTOCOL and passes this via the event data_changed. Using methods of this class, you can get and modify cell values and produce error messages.
Regards,
Ranjit Thakur.
<b>Please Mark The Helpful Answer.</b>