Table Maintenance Generator for event Number 01and 05.
Create Maintenance view for the database table and write the following code in Include.
*&————————————————————–* *& Form create_entry *&————————————————————–*
FORM create_entry.
zvmaint-zcreatedate = sy-datum. ” Creation Date
zvmaint-zcreatetime = sy-uzeit. ” Creation Time
zvmaint-zcreateuser = sy-uname. ” Created By
zvmaint-zupdateuser = sy-uname. ” Last Update user
zvmaint-zupdatedate = sy-datum . ” Last Update date
zvmaint-zupdatetime = sy-uzeit. ” Last Update time
ENDFORM. ” _CREATE_ENTRY *&———————————————————————* *& Form modify_entry *&———————————————————————*
FORM modify_entry.
DATA: lv_index TYPE sy-tabix. ” Number of lines found
CONSTANTS : lc_action_update TYPE c VALUE ‘U’, “Updating current record
lc_action_create TYPE c VALUE ‘N’. “Creating new record * Clearing data objects.
CLEAR : lv_index. *– Check the all entries of records in table by looping each record.
LOOP AT zvmaint_total. *– Check record updated.
IF <action> = lc_action_update . * Read the EXTRACT table with current record.
READ TABLE extract WITH KEY zvmaint_total.
IF sy-subrc EQ 0.
lv_index = sy-tabix.
ELSE.
CLEAR lv_index.
ENDIF. * Populating updated fields to table.
zvmaint_total-zupdateuser = sy-uname. “Last Update name
zvmaint_total-zupdatedate = sy-datum . ” Last Update date
zvmaint_total-zupdatetime = sy-uzeit. “Lase Update time * Modify the current record in the table.
MODIFY zvmaint_total.
CHECK lv_index GT 0.
extract = zvmaint_total.
MODIFY extract INDEX lv_index.
* Check the record created.
ELSEIF <action> = lc_action_create .
READ TABLE extract WITH KEY zvmaint_total.
IF sy-subrc EQ 0.
lv_index = sy-tabix.
ELSE.
CLEAR lv_index.
ENDIF.
* Modify the current record in the table.
MODIFY zvmaint_total.
CHECK lv_index GT 0.
extract = zvmaint_total.
MODIFY extract INDEX lv_index.
ELSEIF zvmaint_total IS INITIAL.
READ TABLE extract WITH KEY zvmaint_total.
IF sy-subrc EQ 0.
lv_index = sy-tabix.
ELSE.
CLEAR lv_index.
ENDIF.
* Make desired changes to the line total.
DELETE zvmaint_total.
CHECK lv_index GT 0.
DELETE extract INDEX lv_index.
ENDIF.
CLEAR: lv_index.
ENDLOOP.
sy-subrc = 0.
ENDFORM. “modify_entry
<!– –>
No labels
2 Comments
Former Member
These are the events CREATE and CHANGE table entry…….!!!!
We can populate the fields automatically using the events and those will be in display mode only.
Permalink
Nov 07, 2013
<!– –>
Vamshi Mohan
Hi,
Why do we really need to touch the EXTRACT table. Whatever changes done in TOTAL are reflecting in the dbase.
If you develop now UI for SAP, you use Web IDE. If you are doing backend and ABAP, you use ADT (ABAP in Eclipse). But sometimes you still need to come back to SAP GUI and ABAP Workbench and use the “New” ABAP Editor.
For that rare cases when you are doing ABAP in old fashion way I have some suggestions, which maybe someone not aware of, and that may help be more productive. In this blog, I will try to explain most useful functions added in ABAP Editor (from my point of view) and will try to collect links to other useful resources related to ABAP Editor for SAP GUI.
Do not expect too much in the beginning, but the list will grow up on demand.
I am long time not responsible for the ABAP Editor in Workbench so I cannot add or fix something. And I am not ABAP Workbench expert in general – I can only give details about that white area where you type your code. But for that white area, I can explain how it was designed and if the thing you want is in or is theoretically possible.
Quick start
It was designed, that when one starts “New” ABAP editor in the ABAP workbench for the first time, he gets an introduction page, explaining new features of the editor. But I never saw this working :).
The page is located aside to ABAP Editor user settings in:
“%APPDATA%SAPSAP GUIABAP Editorqstart.htm” Copy => Win + R => Paste => Enter
And here is most valuable part of the page:
Block / Column Selection
Alt + Shift + Left/Right/Up/Down
The ABAP editor allows you not only use standard (called “stream” selection) but also allow to select a rectangular block of text, which does not start from the beginning of the line:
You can select text block using the keyboard commands (Alt + Shift + Arrows) or with a mouse, keeping left Alt key during selection:
After selection, you can apply many of the editing functions in block mode:
Delete, Insert, Multi Edit
Copy/paste from Clipboard
Case conversion
Indent etc.
Multi Editing
Null Width Selection
The degenerated version of the block selection is Null Width selection (not visualized ), which you can use for indenting of text blocks.
Clipboard Ring or Multi Clipboard or Clipboard History
Ctrl + Shift + V
If you want to see all text pieces you have copied during your editing session, just press Ctrl + Shift + V, instead of normal Ctrl + V. Then you get a history of the clipboard items (up to 12, in chronological sequence) where you can select and paste any of the items (it also overwrites current Windows clipboard content).
Case Modification
Ctrl + L -> lower case
Ctrl + U -> UPPER CASE
Ctrl + K -> sWAP cASE
Ctrl + J -> Capitalize Text
Ctrl + T -> Like in sentence
You can easily modify text case, without using a pretty print function. It works with stream and with block selection.
Lines move
Ctrl + Alt + Up/Down
The feature is useful when you need a block of lines, but do not want to overwrite keyboard content. You can move selected block of lines up or down. If no selection is done, the current line is moved.
Line duplicate
Ctrl + D
Sometimes it is much faster to duplicate the current line and adjust content than typing it once more.
Word/Line Selection
The ABAP editor supports different kinds of word/line selection:
Ctrl + Left/Right to select till word borders
Ctrl + Left Mouse Click on a word
Left Mouse Click on number margin to select lines
Incremental Search
Ctrl + I, Ctrl + Shift + I
In many cases when you want to do a simple text search you can achieve it without calling Find dialog and losing your editing context. Just start Incremental Search mode by pressing Ctrl + I and start typing.
Press Ctrl + I to search for next occurrence
Ctrl + Shift + Ifor search of the previous occurrence
Backspace to correct your input
Esc to exit incremental search mode
See editor status bar for current search query
Code Hints
Code Hints were designed as proactive, not intrusive alternative for standard code completing list called by Ctrl + Space. It shall be very prudent to resources, but same time giving the user a way to speed up typing.
Code Hints may suggest syntactical construction, variables and code templates (somewhen before it was also auto correction suggestions in). The editor collects all fitting suggestions, rank them by type, usage count, input method and shows you the best hit. Code Templates are always won against keywords and variables, keywords (syntactical constructions) win against keywords.
Suggest Non-Keywords from the Text
The mentioned option is OFF by default (for some reason), but it brings a lot of value. “Non-Keywords from the Text” means in ABAP scope – your variables. So, if you enable the feature, you get your variables suggested by code hints (code completion list will show them independently of the flag) and this may save some typing effort especially if you are using “self-explaining”, meaningful variable names ;). Especially the flag would be useful, if you are forced to work on systems below SAP_BASIS 7.02, where full blown code completion is not enabled, and this flag and code hints the only “completion” you may get :).
Code Hint Color
When you using Code Hints, you see that it sometimes has light, standard background:
And sometimes it has inverted, dark background:
Have you ever asked yourself: what does this crap mean?
The secret meaning of the Code Hint background color:
ADT (ABAP in Eclipse) has also emulated implementation of Code Hints in some way, but the “secret knowledge” was lost, and the only inverted color is left :
Why my code highlighted differently when I paste it in an email?
You may wonder, why when you copy/paste your code from the editor into email (or any other editor supporting HTML formatting) syntax highlighting of the ABAP code looks different from the one you had in ABAP editor.
ABAP Editor:
MS Outlook:
The reason here – different highlighters that used for rendering of text in both cases. The one in ABAP editor, it is a highly sophisticated one, which works in respect of ABAP grammar available on ABAP system you work (and require fully qualified input), and the second one, is rudimental highlighter, which works based on keywords and can highlight even invalid code, but is not in sync to actual ABAP grammar. On the example above we see that keyword based parser has not highlighted OCCURRENCE, REGEX RESULTS (while in time the editor was written, these keywords were not yet known J ) but has highlighted the VALUE in the second sentence, that has been marked as an error by ABAP parser.
You would not be able to get code pasted into an email, always looking as one in ABAP editor, but you can extend syntax scheme of the keyword based parser, by simply adding missing keywords into abap_spec.xml file in ABAP Editor settings directory to get missing keywords highlighted:
Display list of assigned ABAP Editor keyboard shortcuts
The easiest way to get an overview of currently assigned keyboard shortcuts in your instance of the ABAP editor is a preview of the keyboard mapping scheme file in Internet Explorer (not in Chrome, you need a browser supporting XSLT transformations).
Paste the following path in your Windows Explorer:
%APPDATA%SAPSAP GUIABAP Editorkeymap.xml
If you are lucky and your default browser is still IE, you will get something like this:
The list is searchable and contains all assigned keyboard shortcuts and command IDs and descriptions for all installed keyboard mapping schemes.
If the command is not on the list, it means, there is no shortcut assigned to it.
Most of you know that it is possible to change the color of syntax elements shown in ABAP Editor. Using that “Settings” button in the status bar. But most of you a bit lazy to change that consistently and create new color scheme (Dark one for example) in a way that you can use and share with others.
But there are guys who did it. Check this GitHub repository if you want to get alternative color schemes for ABAP editor.
And if you have your own one – share it with the community!
Probably everyone used the ABAP Editor has also used Code Templates, speeding up typing of routine code. And definitely, there were some cases when you would like to have a new code template for some code block and have not found it among the standard SAP pre-installed ones (for example METHOD/ENDMETHOD.).
Floorplan Manager and other UI technologies (SAP UI5 perhaps).
ABAP for SAP HANA.
Figure: a small gift got in SAP D-KOM 2017 in Shanghai,China
As another ABAP veteran who has been programming using ABAP in SAP for ten years, I have some additional points. I saw the term “SAP’s latest technology” within the communication of that blog, no doubt it could be quite good for an ABAPer to keep learning them, and IMHO it could be even better if an ABAPer has some basic awareness of the latest technique trends in open source community. Perhaps it is difficult for a traditional ABAPer to touch some of these trends in their daily work, however I do think that by knowing them, it can help you to become a better programmer, not just a better ABAPer.
Some of them come into my mind which are related to ABAPers’ life:
In stackoverflow, there are already lots of discussion on it. See this one:
Per my experience, by mastering a kind of functional programming language, it gives you as a programmer a completely different way of problem-thinking-and resolving direction. You can never get such feelings when you use imperative and object oriented languages. After that you can look back into your current ABAP coding for example which will perform really time-consuming calculation on big internal table? Have you ever thought of the possibility that such big internal table could be splited into small pieces and handled in parallel just as a functional programming language does?
In my opinion, BOPF has successfully achieved some cool features of Spring to some degree, for
example inversion of control and dependency injection. While BOPF fulfills them via countless
configuration tables ( I prefer to call TDD in ABAP as Table-Driven-Development ), Spring uses annotation as another elegant approach.
You can of course learn OO Design pattern via the toy program written in books, however actually most frequently used patterns already spread heavily in Spring source code, by studying those codes you can know how the patterns are applied to resolve real requirement by Spring gurus.
By knowing how Spring works under the hood, it helps you to understand BOPF more thoroughly in turn. When you are familiar with the mechanism of
those framework enough, you are now able to write some mini-framework in your application code, which helps you to avoid code duplication, break tight dependency among components, and make your future maintenance and
, it could not be purely supported in ABAP from language perspective due to the fact that unfortunately ABAP Virtual Machine cannot support dynamic proxy as JVM does.
Nevertheless we still have
Pre/Post exit
which can be leveraged to simulate AOP, from which customer can still benefit a lot, to build their own extensions. Meanwhile, there is another blog talking about AOP in ABAP:
I had been using CRM WebClient UI in the past to build UI, and I know it is not possible to build state-of-the-art responsive UI using this technology, and I have very limited knowledge on floor-plan manager so I am not sure whether it has the same problem. As far as I observe, UI5 plays a more and more important in SAP UX strategy, at least in my location, almost all customer facing UI are built by UI5. If you are an excellent ABAPer, you can develop high quality backend service which could be consumed by UI5 via OData, that’s fine. However if you would not like to limit yourself as just a backend developer, but instead, you wanna become a Full-Stack developer, then it is a must that you should learn Javascript. Three years ago ( in 2014 ) I once wrote a blog
Its source code could be found from github repository.
While HANA knowledge is quite important for an ABAPer, have you ever wondered that why NoSQL database will come out although there are many powerful relational database in the world?Again Google with keyword “why nosql”:
I will keep updating this list once new topic comes to my mind which is really related to ABAP. I believe you will tower over normal ABAPers once you get familiar with those stuffs.
How time flies! One year has passed again. Here is another point which I think should be added to ABAPer’s TO-LEARN list.
ABAP veterans might get confused that what could they do in current cloud world. Good news is, they are never abandoned by SAP at all.
I have written a series of blogs which compare the language feature among ABAP, JavaScript and Java. You can find a list of them below:
In that blog I use the curry idea in the example below:
output:
jerry-java
In this blog, as blog title, I will show another approach by leveraging built-in function reduce in JavaScript Array and Reduce keyword in ABAP to fulfill the same requirement.
First see official documentation for Array.reduce here.
Follow the idea of functional programming, I first declare three dedicated functions which are responsible for a specific task in line 6 ~ 8.
Then in line 10, I construct a new composite function which will finally executes the three small functions driven by reduce.
Output:
jerry-java-scala
Reduce in ABAP
Now let’s see how we can achieve the same function in ABAP.
If we use the traditional imperative programming paradigm, the code is written as:
Now let’s try with Reduce. Here is the ABAP documentation for keyword REDUCE.
See how ABAP code can be re-written using REDUCE:
This version looks quite clear and more human-readable compared with the first imperative one:
1. in line 11~13 there are three command instance created and inserted into a command queue held by variable lo_queue.
2. command queue ZCL_COMMAND_QUEUE internally execute the commands one by one using REDUCE as the execution engine.
The rough design of ABAP solution using REDUCE is listed below:
1. I have declare an interface ZIF_COMMAND which has one method DO to perform concrete command, one method GET_RESULT to return command execution result and method SET_TASK to specify command input.
2. ZCL_COMMAND_QUEUE has internally maintained a command queue. The enqueue operation is provided by public method INSERT.
Another public method EXECUTE is defined to fire the command queue execution.
Inside this method, ABAP keyword is used. The last command in the queue will be returned and its interface method get_result is called to return the final calculation request to consumer call.
Hope this small example can help you understand the reduce usage in functional programming world and how to use command design pattern to resolve some real problem.