09-17-2007 2:13 PM
Dear SAP friends,
I have created HR report.
On the selection screen the User enters some initial data and ALV Grid get displayed.
In event Handle_toolbar the program adds a custom button to standard ALV grid toolbar named "ABSENCE/ATTENDANCE".
In event handle_menu_button the program adds functions to this button.
Then in event handle_user_command depending on the function selected "e_ucomm" the program repopulates the ALV Grid.
METHOD handle_toolbar.
* Append a separator to standard toolbar
CLEAR gs_toolbar.
gs_toolbar-butn_type = 3.
APPEND gs_toolbar TO e_object->mt_toolbar.
CLEAR gs_toolbar.
gs_toolbar-function = 'ABSENCE/ATTENDANCE'.
gs_toolbar-icon = icon_position_hr.
gs_toolbar-quickinfo = 'Absence/Attendance Type'.
gs_toolbar-butn_type = 2. " 2-Menu type, 0-single button type
gs_toolbar-disabled = space.
APPEND gs_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
*---------------------------------------------------------------------
METHOD handle_menu_button.
* Handle own menubuttons
IF e_ucomm = 'ABSENCE/ATTENDANCE'.
LOOP AT it_aa INTO it_aa_ln.
MOVE it_aa_ln-type TO w-fcode.
CONCATENATE it_aa_ln-type '=' it_aa_ln-text
INTO w-text
SEPARATED BY SPACE.
CALL METHOD e_object->add_function
EXPORTING
fcode = w-fcode
text = w-text.
ENDLOOP.
ENDIF.
ENDMETHOD. "handle_menu_button
*---------------------------------------------------------------------
METHOD handle_user_command.
MOVE e_ucomm TO w-abstype.
PERFORM abs_att USING w-abstype.
ENDMETHOD. "handle_user_command
Is there a way to select more than one line or e_ucomm in other words at a time?
I would like to give my user a choice of let's say one report with three types of absences at a time rather than three reports with one type each.
Thanks,
Tatyana
09-17-2007 2:29 PM
I don't exactly follow you, but it sounds like you would need three separate buttons with three separate funciton codes in order to allow your user to do three different things.
Unless you want to pop up something to ask your user which direction to go when clicking the absence button. Can you explain your requirement a little clearer?
Regards,
Rich Heilman
09-17-2007 3:21 PM
Rich,
When "Absence/Attendance" button is clicked - then a context menu gets displayed which looks like this:
ALL = All absences/attendances
4250 = On-call Pay
4305 = Hurricaine Comp Taken
4310 = Paid Vacation
4330 = Paid Sick
etc.
The list is of about 30 different absences/attendances.
I would like the User to be able to select let's say 4305 and 4330 - like click+CNTRL.
After he makes his selection - then the program will read Data base tables for 4305 and 4330 and repopulate the ALV grid.
Thanks,
Tatyana.
09-18-2007 11:17 PM
Hi Tatyana,
I am not sure if you can do that in a context menu. Personally, I would create a quick dialog box with an ALV (or maybe even a table control with check boxes) and then read the user's selection to use for displaying my report.
Displaying an ALV will be easier than a table control since all you need is an internal table with all possible options. You display it in the ALV grid control which automatically allows the user to select multiple rows. You can then determine the lines selected.
Regards,
Ryan
09-20-2007 1:05 PM
The whole point of a toolbar button is to do a specific function.
What I would actually do here is in your menu button add another option say "User Choice" and when this is clicked throw up another screen say another ALV grid where the user can choose the various combinations or do it via a POPUP. A second grid IMO would be the best way to do it as the user can select easily specific rows.
You can either display the 2nd grid in a 2nd custom container on your main screen where you are showing the ALV grid or pass control to a new screen / program. Using a 2nd container is better as you still will have your instance of the original grid available.
Cheers
Jimbo
09-21-2007 1:22 PM
Thank you guys!
Yes - in context menu jou can't make multiple selection. This is not the context menu is for.
I will go with 'User Choice' button and pop up dialog box when User Choice button is clicked.
Tatyana