SAP provide a alot of sample code.
For demo about selection screen validation, dynamic selection screen, find them in DEMO_SEL_SCREEN*
For demo about select data, dynamic condition, find them in in DEMO_SELECT*
Demo about write output to list can be found in program DEMO_LIST*
You can find also demo about object oriented programming, tree control, drap & drop menu (contect menu)
To find all the demos, find program including word *DEMO* in program name.
Enjoy exploring SAP demo :)
Monday, July 28, 2008
ABAP sample code provided by SAP
Diposting oleh alionzo di 7:30 PM 177 komentar
Label: ABAP Tutorial
Wednesday, October 31, 2007
SAP and ABAP Tutorials in PDF
Here are some SAP & ABAP Tutorials in PDF:
Complete SAP 46c Tutorials Index
Tutorial related to ABAP
ABAP Programming (BC-ABA)
ALV Gird Control (BC-SRV-ALE)
BC - ABAP Dictionary
BC ABAP Workbench Tools
BC ABAP Workbench Tutorial
Diposting oleh alionzo di 7:06 PM 42 komentar
Label: ABAP Tutorial
Monday, September 3, 2007
Conversion routine
Write this simple code.
REPORT ZFIELDCONV.
data: d_auart LIKE vbak-auart.
d_auart = 'TA'.
WRITE d_auart.
What the result output on screen do you expect, "TA"? No, the result will be "OR".
The result comes from conversion routine of its domain. In SE11 open table VBAK, find field AUART, double click to go to data element AUART, then double click to open domain AUART. You will see its conversion routine, named AUART. Double click the conversion routine, you got at least two conversion routine conversion routine input & output. They are function module, you can test them in SE37.
The INPUT routine performs the conversion from display format to internal format. The OUTPUT routine performs the conversion from internal format to display format. Take attention when we hard code value as a condition value in "WHERE condition", you must convert its value into internal format.
Other commonly used conversion routine is ALPHA. It is conversion used to insert leading zero for document number. For example, in sales order (VBAK-VBELN length 10), when we key in order no, for example we key in '4302', conversion routine input will automatically add leading zero, so it will become '0000004302', this is real value stored in table VBAK. On conversion routine output, it will delete leading zero.
In SE16, we can view the data wheather in internal format or display format, to toggle format, in display list, go to Setting->User Parameter, in tab strip "Data browser" choose "format, field conversion exit".
Read More......
Diposting oleh alionzo di 11:45 PM 16 komentar
Label: ABAP Tutorial
Monday, August 27, 2007
Screen Painter
Screen Painter is an ABAP Editor tools allowed us to create dialog screen. Dialog screen usually created as a screen to catch user input. It can be accessed by tcode SE51.
Screen Painter Architecture:
1. Screen Attributes
Define screen title, define its type (normal, subscreen).
2. Flow logic
Flow logic control flow of program. The event block is introduced by the corresponding keyword statement, and it concludes either when the next block is introduced, or at the end of the program.
There are four event blocks, each of which is introduced with the screen keyword PROCESS:
PROCESS BEFORE OUTPUT.
...
PROCESS AFTER INPUT.
...
PROCESS ON HELP-REQUEST.
...
PROCESS ON VALUE-REQUEST.
A simple sample of flow logic.
PROCESS BEFORE OUTPUT.
MODULE PBO_module1.
MODULE PBO_module2.
PROCESS AFTER INPUT.
MODULE PAI_module1.
MODULE PAI_module2.
Flow logic structured on event, in above example we can see there are two event involved, "process before output" (PBO) and "process after input" (PAI).
PBO processed before the screen is displayed. It allow us to define toolbar and title, positioning the cursor, showing and hiding fields and changing field attributes dynamically.
PAI processed after user command (double click, push button). It is allow us to validate user input, and determine next process based on user command.
In flow logic, we only define module name to define program flow, to create "real code", double click on module name to create it, then write program in it.
3. Layout Editor
We use layout editor to place screen element in screen layout. There are two modes in editing layout: Graphical and alphanumeric. Both modes offer the same functions but use different interfaces. In graphical mode, you use a drag and drop interface similar to a drawing tool. In alphanumeric mode, you use your keyboard and menus. It is easier to work in graphical mode, to toggle beetween this mode, in SE51 go to: Utilities->Settings: in screen painter tabs check graphical layout editor.
Layout editor containing this tools:
i. Element pallete
On left screen you will find list of element (textbox, label, checkbox) you can use. Drag and drog element to put it on screen.
ii. Name & Text
Aftef put element on screen, write its name and text (in textbox, text will set default value).
iii. Attributes Window
Double click the element to display its attributes, or select it then click :Goto->Secondary window->attributes. For example, in textbox element, we can set its length, read only mode, in this window.
iv. Dictionary/program field.
If we want to create a field refer to field in data dictionay or field already declared in program, use this menu to create text field with the same type compared to its referral.
4. Element list.
Element list shown all element in screen. We rarely use this menu, because it easier to maintain element in layout editor.
Diposting oleh alionzo di 3:26 AM 32 komentar
Label: ABAP Tutorial
Thursday, August 23, 2007
Find out table source in SAP
Find out where the data is stored in SAP is a very challenging task. In some cases, we can find it easily in few minutes, but in another case it takes more then one day to find it.
I will try to give tips to find it out step by step.
1. Technical Information.
Put cursor in screen field, press F1, it will show description about this field. Then press "Technical Information" button, you can get field name and table / structure / view. If you get a table / view field, check the data in table / view, you may find it there. But, if you get structure field, go to next step.
Example of table field: tcode VA03 (display sales order), screen field order (VBAK-VBELN)
Example of stucture field: tcode IE03 (display equipment), screen field equipment (RM63E-EQUNR).
2. Exploring Search help (display available list to help input value by pressing F4 in screen field).
Sometimes field with search help can be found be displaying field in its search help. Example, tcode XD03 (display customer) field Customer (RF02D-KUNNR). It is a stucture field, to find the table, place cursor in screen field, press F4 (display search help), run search help until it show available list. In this list, place cursor in field customer, then press F1 to display technical info. You will get table/view field for this.
3. SQL Trace
Open your transaction , before type anything in screen, open transaction ST05 (SQL trace) in another session, start SQL trace by pressing "Trace on". SQL trace is a tools to record database request. Make sure you don't run other program beside transaction you want to trace. After starting SQL trace then go back to your transaction, run it until you get field to search shown in screen. Then go to SQL trace session, end SQL trace by pressing "Trace off". Then click "List trace", here you will get all table requested while SQL trace on. Explore table listed there, usually stucture field and table field having same field name.
4. Explore based on SAP module.
Go to SE16. Click F4, then click "SAP Application". Here you got table tree groupped in SAP module.
5. Find it in source code.
Well... you already finished up to step 4, but didn't find the table source yet. It's time to take a harder step. Click F1 then technical information to get program name and field name. Then go to SE38, open the program, then find field name. May be your detective instinct can help out there.
6. Debugging abap program.
Debugging abap could be a sweating task. "Watchpoints" will help you very much in debugging. Considering it could be more than one day to accomplish this task, don't forget to capture and create documentation while debugging when you reached an interesting point. I always do that, when I saw good point, I capture it by "print screen", paste it into Microsoft word, then give a remark on it.
Here is another tips that could help you.
1. Adjacent table will have similar prefix:
sample in sales order, prefik ( V / VB ) : VBAK, VBAP, VBPA...
sample in material management ( M ) : MKPF, MSEG, MARD, MARC,..
2. Almost all SAP Table have a view
To find related table, goto SE11, click where-used list, choose Views.
3. Another tools to find table field:
Goto SE15, Choose: ABAP Dictionary -> Field -> Table Fields.
Diposting oleh alionzo di 9:23 PM 19 komentar
Label: ABAP Tutorial
Thursday, August 16, 2007
BDC (Batch Data Communication) Tutorial for Data Transfer
What is BDC
BDC ( Batch Data Communication ) is used for uploading mass data into SAP system. In SAP system BDC also referred to batch input or data tranfer.
Typical Uses
Typical uses of batch input include the one-time import of data from a legacy system into a newly installed R/3 System. Another typical use is for periodic transfers of data from external systems or legacy systems that are still in use into SAP.
Background of BDC
To ensure data consistency in SAP system, we must not update SAP data directly from ABAP program. We must upload data through similar program flow compared to manual input by user. SAP provide this by BDC. BDC works by simulating the user input from transactional screen via an ABAP program. This means that you do not bypass any of the standard SAP consistency checks, authorisations, update conjunction tables, etc.
How it works
Data input entered by user simulated in BDC by data packet. The transaction then started using this internal table as the input and executed in the background.
Data packet is an internal table has a structure of BDCDATA, it has fields:
1. PROGRAM (program name)
2. DYNPRO (screen number)
3. DYNBEGIN (New screen start) X=new screen
4. FNAM (Field name)
5. FVAL (Field value)
Data packet contain of screen by screen packets. One screen packet contain:
1. Screen no
2. Cursor position
3. User command
4. Input fields
It implemented in internal table in this format:PROGRAM DYNPRO DYNBEGIN FNAM FVAL program1 screen1 X BDC_CURSOR pos1 BDC_OKCODE comm1 fieldname1 fieldvalue1 fieldname2 fieldvalue2 program2 screen2 X BDC_CURSOR pos1 BDC_OKCODE comm1 fieldname1 fieldvalue1 fieldname2 fieldvalue2
For example, we want to create a BDC to change ABAP program title.
Here is what we do manually: Go to screen SE38, enter program, select radiobutton "Attributes", then click "Change". After that, change title then press "Save" button.
In BDC, we simulate this by following internal table:PROGRAM DYNPRO DYNBEGIN FNAM FVAL SAPLWBABAP 100 X BDC_CURSOR RS38M-FUNC_HEAD BDC_OKCODE =CHAP RS38M-PROGRAMM ZAALTESTBDC RS38M-FUNC_EDIT RS38M-FUNC_HEAD X SAPLSEDTATTR 200 X BDC_CURSOR RS38M-REPTI BDC_OKCODE =CONT RS38M-REPTI Test change title BDC TRDIR-SUBC 1 TRDIR-FIXPT X SAPLWBABAP 100 X BDC_CURSOR RS38M-PROGRAMM BDC_OKCODE =BACK RS38M-PROGRAMM ZAALTESTBDC RS38M-FUNC_HEAD X
To accomodate you to build data packet, SAP provide BDC recording in tcode SHDB.
Do following action:
1. Go to tcode SHDB
2. click "New recording", enter recording name to identified your record, and TCode to be recorded.
3. You will enter recording mode of the transaction, simulate action you want to perform in this transaction
4. At the end it will result internal table ready to upload to data transfer methods (Call transaction or BDC sessions).
After internal table created then we pass this to data transfer methods. There are two alternatives of data transfer methods, using Call Transaction or BDC session.
Call transaction performed by calling command ‘Call Transaction’. ABAP program must do the error handling based on returning table from call transaction command. It is used for real-time interfaces and custom error handling & logging features. This is suitable when processing sequential update, it means, next data will depend on previous data.
In BDC Sessions, the ABAP program creates a session with all the transactional data, and this session can be viewed, scheduled and processed (using Transaction SM35) at a later time. The latter technique has a built-in error processing mechanism too.
Other useful article:
BDC Tutorial in SAP-Img
Diposting oleh alionzo di 2:32 AM 69 komentar
Label: ABAP Tutorial
Monday, August 13, 2007
Site Map ABAP Sample Code
ABAP Sample Code:
ALV
Simple ALV
Field Catalog in ALV
Change Layout Format in ALV
FTP
FTP
Business Document
Store Document / File to SAP
Get Document / File Stored in SAP
Selection Screen
Help Value Request (F4)
Add Toolbar Button in Selection Screen
Hide Parameter / Select Option in Selection Screen
Tab Strip in Selection Screen
Miscellaneous
Dynamic Table Maintenance
Diposting oleh alionzo di 10:44 PM 19 komentar
Label: ABAP Sample Code