Today I'll start to show you how you can prepare some methods to be able to read classification data without carrying each time about the kind of characteristics. If you follow my suggestions then you'll be able to use this methods each time you deal with classifications. In this part I will show you how to prepare a method to create a structure and table for classification data. I know that some of you can say we can create such structure manually with data or types statement directly in each of our development, but one day you'll see that sometimes it's easier to prepare a function or method which will do it for you so you can keep the logic in each of your program without doing maual work.
To create the structure of the class I will use FM BAPI_CLASS_READ to read class data, then I will use FM BAPI_CHARACT_GETDETAIL to read the characteristics and in each step I'll be using classes cl_abap_elemdescr, cl_abap_structdescr and cl_abap_tabledescr to create the structure I need.
i_classtype klah-class-> class number
i_classtypetype klah-klart ->class type i_key_datetype sy-datumdefaultsy-datum-> key date for class
e_structuretype ref to cl_abap_structdescr-> structure for our class et_datatype ref to data-> table created on a base of class structure e_tabletype ref to cl_abap_tabledescr-> table type for our class
We know already how to use chart designer and we're able to save/read it's result to/from standard texts. So let's go for most interesting part - rendering the chart. Of course we will need some data but I will use dummy one just to show you how to create the chart, you can replace this part with loop on your internal table or even better change it in the way that you'll pass internal table.
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.
In part one for this tutorial I quickly shown you how to create a chart customizing using Chart Designer, in this part I will show how I store and use such customizing. For the beginning I'll tell you that there are many ways to store the customizing, you can keep it in GOS, or in APP server or load it directly from PC, but my favorite one is to keep the customizing in standard texts (SO10) and read it from there. It's easy to do changes there and it can be restricted in authorizations who can do changes for such text.
So I'll go to SO10 and create new text for customization there:
At the beginning of my work with SAP I was disappointed with the charts that was available in standard transactions. In fact I am still :) But when I have to create own program with nice looking chart then it's no longer a problem as we can use CL_GUI_CHART_ENGINE together with chart designer provided by SAP. Chart designer is a tool which allows you to create a customizing for your chart and save it in XML file which can be used in ABAP after.
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.
In article Save variant for single selection screen subscreen I've shown you how to save a variant for single selection-screen subscreen with a little help of FM RS_ISOLATE_1_SELSCREEN & RS_CREATE_VARIANT. If you use method shown there it may happen that when you're loading a variant to a screen it overrides also values from other fields. To avoid that I've prepared a method to fill only fields from one subscreen. I will use here FM RS_VARIANT_CATALOG to allow user to select variant for subscreen, FM RS_VARIANT_CONTENTS to read it's content, FM RS_ISOLATE_1_SELSCREEN to get the fields of subscreen and field-symbols to put them on place. So let's start.
As input parameter I will use only subscreen number:
In one of the previous articles I described how to Convert date to and from external date type, so we can display in grid or in screen field properly formated date. Today I will show how to create a F4 help for such external date. I will use today FM 'F4_DATE' to show the date popup and already know FM 'PERIOD_AND_DATE_CONVERT_OUTPUT' to convert internal date to external type.
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
When building a program with multiple selection screens sometimes it may be needed to save the variant with entries only for one of the subscreens and not for the others. If you want to do that you have to firstly use FM 'RS_REFRESH_FROM_SELECTOPTIONS' to get all fields and values for all select-options, then you need to use FM 'RS_ISOLATE_1_SELSCREEN' to get the fieldnames for selected subscreen. When you have this data you can easily filter fileds and it's values to this which you have on your subscreen. After that run FM 'RS_CREATE_VARIANT' to create a new variant, if variant exists and you want to overwrite it then you have to use 'RS_CHANGE_CREATED_VARIANT'. Few lines and you can use this in many developments.
I_DYNNR TYPE SY-DYNNR - Current Screen Number
I_VARNAME TYPE RSVAR-VARIANT - Variant Name
I_VARTEXT TYPE VARIT-VTEXT - Program variant short text
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.