In the method provided bellow I firstly create custom container object (cl_gui_custom_container) to place the chart in it, then I create chart engine (cl_gui_chart_engine), then using if_xml I create an xml data container which in fact can be written using simple concatenate statement but it's not nice to change and easy to mess.
So after we receive an xml with data then I will pass it to chart engine, then I will run the method prepared in previous part (Create a nice looking chart with CL_GUI_CHART_ENGINE - Part 2 - Customization ) to read the customization of the chart and I will pass it also to engine. Finally I will render the chart.
So first of all we need to download chart designer from SDN so you can google "sap chart designer" to get it. After you'll have it just run one of the versions available there (640 or 700) depending on your GUI version. All files which you'll find in the package are shown below, XML Format.pdf file will tell you how to prepare chart data depending on chart type.
i_dynnr type sy-dynnr -> subscreen number
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.
IM_DISPLAY TYPE CHAR1 - Display only? (no selection)
IM_ELPEI TYPE TPRG-PRGBZ (OPTIONAL) - External date type
EX_EEIND TYPE RVDAT-EXTDATUM - External date
EX_ELPEI TYPE TPRG-PRGBZ - External date type
I_DYNNR TYPE SY-DYNNR - Current Screen Number
I_VARNAME TYPE RSVAR-VARIANT - Variant Name
I_VARTEXT TYPE VARIT-VTEXT - Program variant short text
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
Not once, not twice I've search for a solution to do changes in routings (task lists) in some wise way. I hate BDC but in this case I thought that there is no other solution. Fortunately I was wrong ! While reading one of the post asking about same thing one of the users has mention something really nice - SAPNote 488765 "Do-it-yourself EWB programming". This note shows how to use FM used in CEWB, so we can create/change/delete bom and routings. The example available in the note shows how to change an routing operation description. The rest you have to figure out alone but once you start to use the functions or you'll check "where used" then it became quite easy (but not less time consuming). When you find the function you're seeking then it's piece of cake.
It was like that also with delete routing function which I share with you today. There is no BAPI_ROUTING_DELETE (yet), so firsty we had to load the task to EWB memory with 'CP_CC_S_LOAD_COMPLEX_BY_TSK' ,then it's time to set deletion indicator in MAPL ('CP_CC_S_DELETE_BY_MTK') and in PLKO ('CP_CC_S_DELETE_BY_TSK'). At the end we have to save the changes with 'CP_CC_S_SAVE' and dequeue task with 'CP_CL_TSK_UNLOCK'. If you need you may also delete the operations but in my opinion this is not needed here.Add a comment
I had a thought one day to use a code saved in database table for easy change of some calculation rules and I've prepared code to run SE38 like editor for such code. Maybe some of you also had such need, so today I will explain briefly how to do this. I will use FM 'EDITOR_TABLE_WITH_STATUS' to display an editor which you know from SE38/SE80 , 'SAPGUI_SET_FUNCTIONCODE' for setting OK_CODE for editor, 'PRETTY_PRINTER' to make our code looks readable. I will also use one trick that allows you to assign data which is available in calling program but not in our function. But before we need to prepare our own GUI status with some basic buttons like 'Patern' or 'Pretty Printer'.
Add 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
You might have a task to use or download one or all files attached to document saved via CV01N transaction. This is not a big deal really, you just need to use some FMs available in standard of SAP like 'CVAPI_DOC_GETDETAIL', 'CVAPI_DOC_CHECKOUTVIEW' or SCMS_DOC_READ'. These FMs allows you the check the details of document, check it and then read its content. Of course sometimes you'll have to zip the files before the downloading and here in my code I used method "zip" for which code you can find here. While reading the code you may also find another Z-method called "get_filename_from_path", its code is posted here. The method I'm posting bellow allows you to choose if during download of files from document you want to zip them all together into one zip file or if you want to zip them separatelly. In table ET_FILES you'll find all files that were attached to document, field "UPDATEFLAG" will be set to 'D' if file was succesfully downloaded to PC. If you don't want to download the file but you want to get it for futher use you'll have to request ET_XSTRING table. In other case do not request this parameter as it is a sign for method that you don't want to donwload the files.
TT_RA_FILENAME type range of CVAPI_DOC_FILE-FILENAME.
TT_XSTRING type table of xstring.
I_DOKAR TYPE DRAW-DOKAR ->Document Type
I_DOKNR TYPE DRAW-DOKNR ->Document number
I_DOKTL TYPE DRAW-DOKTL ->Document Part
I_DOKVR TYPE DRAW-DOKVR ->Document Version
I_DOWNLOAD_DIRECTORY TYPE STRING -> path to download the fiels
I_ZIP_FILES TYPE C OPTIONAL -> mark it 'X' if you want to zip the files before downloading
I_ZIP_SEPARATELY TYPE C OPTIONAL -> mark it 'X' if you want to zip each file found in document separately
I_NAME_FILTER TYPE TT_RA_FILENAME OPTIONAL -> Range for filter filenames - select which documents you want to download
I_FILENAME TYPE CSEQUENCE OPTIONAL -> filename for zip - used if you zip all files into zip container
ET_FILES TYPE CVAPI_TBL_DOC_FILES -> Table with all files found in document
ET_XSTRING TYPE TT_XSTRING -> TT_XSTRING -> Table of xstrings (each file in separated line)
ZIP_ERROR -> Error while zipping
DOCUMENT_ERROR -> Error while reading document