1st) Add empty line after each part you want to separate and color it differently;
Adding empty lines will force you to delete all of them each time you'll do changes inside table displayed in grid and you'll have to do the calculation of position again, that's why today I will show you the second option.
When you use CL_GUI_ALV_GRID in edit mode or you change your internal table used to display data on ALV grid it may happen that after refreshing the grid using refresh_table_display your cursor or scroll goes to the begining of the grid. Users feels little lost in such situation but there is an easy solution for that.
data: is_stable type lvc_s_stbl.
is_stable-row = 'X'.
is_stable-col = 'X'.
is_stable = 'XX'.
is_stable = is_stable " With Stable Rows/Columns
* i_soft_refresh = i_soft_refresh " Without Sort, Filter, etc.
finished = 1
others = 2
if sy-subrc <> 0.
* message id sy-msgid type sy-msgty number sy-msgno
* with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EDIT: Method of mine which can be found bellow doesn't have to be used to achieve your goal. To be honest I can't remember why I created separate version of it as only the cursor act a bit different than oryginal one. I must have had mind eclipse at the time :-) . Excuse me for that.
So to keep scroll position and current cell we will need to use following methods of CL_GUI_ALV_GRID:
get_scroll_info_via_id - gets current scroll information
get_current_cell - gets current cell, we will use that data to set the cursor at the end
get_selected_rows - gets selected rows
get_selected_cells_id - if we didn't select any rows, we check for the selected cell information
refresh_table_display - then simple refresh of grid
set_selected_cells_id - after refresh it's time to set back all information, so set selected cell
set_selected_rows - or set seleted rows (depanding what we received at the begining)
set_scroll_info_via_id - set scroll position back
set_current_cell_via_id - set cursor back.
There is no special coding here, just standard ALV grid methods used in proper order.
Method definition, Importing parameters:
I_SOFT TYPE CHAR01 DEFAULT 'X'
I_SET_CURRENT TYPE CHAR01 DEFAULT SPACE
I_SET_SELECTED TYPE CHAR01 DEFAULT SPACE
GRID TYPE REF TO CL_GUI_ALV_GRIDAdd a comment
In previous post I've shown how to zip file directly on PC without using CL_ABAP_ZIP, this time I will show you how easy is to use OLE2_OBJECT to create an MS Outlook message with attachment and save it in Outlook's Drafts folder. OLE2_OBJECT in fact can be used with any application that allows it, but today I will only show a hint how to work with MS Outlook.
I know that most of us use CL_BCS to create and send the message directly from SAP, but in a situation when you're working on local files then It may be better to do it with Outlook. This is of course just a short sample of the possibilities, all functions for OLE & MS you can find in MSDN documents.
Add a comment
Here is the code with f_path parameter which is used to pass path of local file to attach to message:
From time to time you have to work on files that are stored in user PC, like when you're working with SOI (SAP Office Integration) for example. All operations that are done are save directly to a file which is stored on PC so if you would like to zip it with cl_abap_zip class then you would need to copy file to ABAP memory, then zip it using cl_abap_zip and then save back file to PC. Sometimes this is not the best solution, especially when working on slow connections via VPN or similar. So with help there goes cl_gui_frontend_services=>execute. This method allows you to run every file on PC directly - also a program with proper parameters. In my example I will use IZArc (it's free and fast).
So what I'm doing here is:
- passing full path to the file which will be zipped
- call cl_gui_frontend_services=>environment_get_variable to check program files directories
- concatenate file path with parameter of IZArc "-ad"
- concatenate program files directories with 'IZArc\IZArc.exe'
- check if IZArc exists with cl_gui_frontend_services=>file_exist
- if yes then I'm executing it with cl_gui_frontend_services=>execute.
Here is the full code for such function:Add a comment