Thursday, August 30, 2007
Frequently Used Commands in SAP
/n This terminates the transaction. This generally corresponds to pressing F3 to go back.
/nend This termiantes all separate sessions and logs off (corresponds to System - Logoff).
/nex This terminates all separate sessions and logs off immediately (without any warning!).
/oxxxx This opens a new session and starts transaction xxxx in This session.
/o This lists existing sessions and allows deletion or opening of a new session.
/i This terminates the current session corresponds to System End
/i1, /i2,... This terminates the session with the number given.
ABAP/4
/h This switches into debugging mode.
/hs This switches into debugging mode and activates the debugging of sys functions.
Batch
The following commands can be entered in correction mode
'Process in foreground' or 'Display errors only')when processing a batch input session:
/bdel This deletes the current batch input transaction.
/bend This terminates batch input processing and sets the session to Failed
/bda This switches from Display errors only to Process in foreground
/bde This switches from Process in foreground to Display errors only
Buffer
WARNING: Resetting buffers can significantly change the performance of the entire system for a long time.It should therefore only be used where there is a good reason tdso. As of release 3.0B system administator authorization is required (authorization object (S_ADMI_FCD). The action is noted in the system log.
/$SYNC This resets all buffers of the application server
/$CUA This resets the CUA buffer of the application server
/$TAB This resets the TABLE buffers of the application server
/$NAM This resets the nametab buffer of the application server
/$DYNP This resets the screen buffer of the application server
Conversion of SAPSCRIPT to SMARTFORMS
This is basically a function module, called FB_MIGRATE_FORM. You can start this function module through SE37,or create a small ABAP program which migrates all SAPscript forms automatically.
You can also do this one-by-one in transaction SMARTFORMS, under
Utilities -> Migrate SAPscript form.
You could also write a small batch program calling transaction SMARTFORMS and running the migration tool.
How to convert Sapscript spools request to PDF
Specify the spool number and you will be able to download the sapscripts spool into your local harddisk.
It will look exactly like what you see during a spool display.Please note that it is not restricted to sapsciprts spool only.Any reports in the spool can be converted using the program 'RSTXPDFT4'.
How to improve the performance of ABAP Program.
2. Avoid for all entries in JOINS
3. Try to avoid joins and use FOR ALL ENTRIES.
4. Try to restrict the joins to 1 level only ie only for tables
5. Avoid using Select *.
6. Avoid having multiple Selects from the same table in the same object.
7. Try to minimize the number of variables to save memory.
8. The sequence of fields in 'where clause' must be as per primary/secondary index
9. Avoid creation of index as far as possible
10. Avoid operators like <>, > , < & like % in where clause conditions 11. Avoid select/select single statements in loops. 12. Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH. 13. Avoid using aggregate functions(SUM, MAX etc) in selects( GROUP BY,HAVING,) 14. Avoid using ORDER BY in selects. 15. Avoid Nested Selects 16. Avoid Nested Loops of Internal Tables 17. Try to use FIELD SYMBOLS. 18. Try to avoid into Corresponding Fields of 19. Avoid using Select Distinct, Use DELETE ADJACENT Note: Also by going to transaction SE30->tips and tricks you can get the idea
Performance Optimization
Q) What is "Performance Tuning"? Why do we need it?
Depending on the complexity and volumes of data, ABAP programs often are vulnerable to time-out issues and short dumps. Users, in general (SAP/Non SAP) get annoyed by time consumiung applicationsas they (the programs) often affect user productivity, TCO of software and many more critical factors pertaining to the management of the software. This is where the need "Performance Tuning" arises.
So, what exactly is Performance Tuning?
This simply means - ensuring that an ABAP program performs efficiently. A good ABAP program to bring the desired output to the user within the desired timeframe. Thus increasing the productivity of users, saving a lot of time and keeping the management happy in the bargain.
- Maximum user productivity
- Minimum time-outs
- Lower total cost of ownership - due to reduced timelines and increased productivity of users
- Faster ROI (return on investment)
- Easier upgradation
Q) List out the steps for Performance Tuning/Optimization.
Data declaration
- Remove all code and variables that are not used in the program
- Avoid declaring internal tables using LIKE or TYPE reference. Instead, use BEGIN OF...
... END OF ITAB. - Avoid declaring internal tables using 'occurs 0' & 'with header line'
SELECTs & DB access
- Use selection criteria to effectively select and limit the number of database reads
- Select only those columns that are needed – Do not use a SELECT * unless necessary
- To populate an internal table thru a SELECT, use the INTO TABLE addition
- To update table entries, specify the columns
- Design your SELECT Query to Use as much index fields as possible from left to right in your WHERE statement
- Use a SELECT SINGLE if the primary keys are known, otherwise SELECT UPTO 1 ROWS
- Do not use nested SELECTs – Use views, joins or the FOR ALL ENTRIES option
- Avoid using INTO CORRESPONDING FIELDS OF TABLE. Instead use INTO TABLE.
- Do not use SELECTs in loops
- Restrict the database access by using the WHERE clause – do not use a CHECK
- Use indexes wherever available
- Avoid NOT in the WHERE condition
- Do not select the same data more than once
- Avoid the SELECT DISTINCT Statement. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplicate rows.
Processing data
- Use aggregate functions wherever required instead of additional logic
- Use sort on the internal table for small amounts of data and database ORDER BY for larger amount
- Whenever using READ TABLE use BINARY SEARCH addition to speed up the search. Be sure to sort the internal table before binary search.
- Use "CHECK" instead of IF/ENDIF whenever possible.
- Use "CASE" instead of IF/ENDIF whenever possible.
- Use "MOVE" with individual variable/field moves instead of "MOVE-CORRESPONDING"
Performing Checks
- Perform the Extended Program Check
- Perform Runtime Analyses
Q) List out the tools used Performance Tuning/Optimization.
- Run time analysis transaction SE30
This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing. - SQL Trace transaction ST05
The trace list has many lines that are not related to the SELECT statement in the ABAP program. This is because the execution of any ABAP program requires additional administrative SQL calls. To restrict the list output, use the filter introducing the trace list.
Wednesday, August 29, 2007
Difference between Conversion and Interface
That is when you write some programs(BDC/LSMW) which will read that data and load it into SAP. Imagine a purchasing system. You are now replacing all that with SAP. But until SAP goes live, you want to keep using the purchasing system. So during go-live, you want to transfer the POs from your legacy system to SAP. Now a PO in your legacy system may not have the same fields as a PO in SAP. So you convert the data.
Interfacing is connecting two or more different entities. In our case, it is connecting one or more systems with SAP. Now extending our previous example, you are replacing some legacy applications but there are some applications that you don't want to replace yet. You need to somehow pass data back and forth between SAP and these remaining systems. Data may be going one way or the other way or both ways. You will still need to do some data transformations/translations etc to make the data understandable to the receiving system. This will continue as long as you want to keep the systems running alongside SAP.
Ex: idoc,bapi
In short, conversions are written to load data into SAP one-time. These are typically file based.
Interfaces are written to exchange/update/send/receive data between SAP and other systems on an ongoing basis. These can be in many forms, file based, idoc based, real time(business connector, XI etc are useful in this), xml, etc.,
SAP Links
http://sample-code-abap.blogspot.com/
ABAP in 21 days link
http://www.sapbrainsonline.com/TUTORIALS/TECHNICAL/ABAP_tutorial.html
http://help.sap.com/saphelp_40b/helpdata/en/4f/991f82446d11d189700000e8322d00/applet.htm
ABAP Tips
http://www.henrikfrank.dk/abaptips/abapindex.htm
Authorization
http://www.saptechies.com/checking-user-authorizations-in-your-abap-program-2/ http://www.saptechies.com/category/authorization/
Complete ABAP Areas Introduction
http://abapcode.blogspot.com/
http://www.abapprogramming.net/
Syntax in ABAP
http://www.abapprogramming.net/2008/04/sap-abap-syntex-for-clear.html
Data Dictionary:
http://www.sappoint.com/PHPWebUI/Documents/ABAP%20Reporting%20-%20Data%20Dictionary.pdf
Reporting:
http://www.sappoint.com/PHPWebUI/Documents/ABAP%20Reporting%20-%20Dialog%20Programming.pdf
Screen and Menu Painter:
http://www.sappoint.com/PHPWebUI/Documents/ABAP%20Reporting%20-%20Screen%20Painter%20and%20Menu%20Painter.pdf
Dialog Programming:
http://www.sappoint.com/PHPWebUI/Documents/ABAP%20Reporting%20-%20Dialog%20Programming.pdf
Internal Tables:
http://www.sappoint.com/PHPWebUI/Documents/ABAP%20Reporting%20-%20Internal%20Tables.pdf
User Exits:
http://www.sappoint.com/PHPWebUI/Documents/ABAP%20Reporting%20-%20User%20Exits.pdf
System Fields:
http://www.sappoint.com/PHPWebUI/Documents/ABAP%20Reporting%20-%20System%20Fields.pdf
BDC:
http://www.sappoint.com/PHPWebUI/Documents/ABAP%20Reporting%20-%20BDC%20Concept.pdf
http://www.sappoint.com/PHPWebUI/Documents/ABAP%20Reporting%20-%20BDC%20Recording.pdf
http://www.sappoint.com/PHPWebUI/Documents/ABAP%20Reporting%20-%20BDC%20-%20Sequential%20Files.pdf
BAPI:
Calling BAPIs From SAP Web Application Server
http://www.sappoint.com/PHPWebUI/Documents/Calling%20BAPIs%20from%20the%20SAP%20Web%20Application%20Server.pdf
BAPI Introduction
http://www.sappoint.com/PHPWebUI/Documents/Introduction%20to%20BAPIs.pdf
BAPI Programming
http://www.sappoint.com/PHPWebUI/Documents/BAPI%20Programming.pdf
BAPI ActiveX Control
http://www.sappoint.com/PHPWebUI/Documents/BAPI%20Active%20X%20Control.pdf
BAPI List
http://www.sappoint.com/PHPWebUI/Documents/BAPI%20List.pdf
SAP TABLES
http://www.sap-topjobs.com/SAPIntTables.pdf
Thursday, August 9, 2007
Adobe Forms - Step by Step
Normally Adobe forms are developed if the Customer needs to Convert the Existing SAP Scripts or Smartforms if any to PDF form. In any case, it can also be developed from scratch for a whole new req.
Some quick steps that can be followed for Conversion from Script to Adobe forms are:
1. Collect the MetaData from the SAPSCRIPTS by downloading the form. Check the windows how they are getting populated from which structure etc.
2. Design a Struture, Say STRU in SE11 with all the fields req in the Form.
3. With this information, goto Txn SFP, and first select the Interface button to create the Interface b/w the Form and the Print Program.
Here you define an Interface of type STRU.The interface defines which data a program can possibly pass on to a form. It also contains global data and initialization coding that can be used in a form. Interfaces are reusable. They are Repository objects. Save and Activate the Interface.
4. Then Come back, and select the Form Radiobutton to Create the actual Form.
5. Under this, it is divided into 2 parts, Context and Layout.
Context is the Data Container for the form that is retrived Via the Interface that will now be visible on the left side of the window.
Drag the Interface stuffs into your Context and you can also add any more fields required like system date,time etc into the context.
6. With this information, goto Layout Tab to design the form using the Standard Palettes available for Box,Text, Numeric field, Checkbox etc... Grouping can be done using the Subform UI.
Well, Play with those palettes , you will understand what all it can offer.
7. Now,Print Prog : We can use the existing Print Prog if SAPSCRIPTS or design a new one. There is some diff b.w the F.M's here... In Place of "Open_Form", we have "FP_Job_Open". In Place of "Close_Form", we have "FP_Job_Close".
Similar to Smartform, a FM is generate for the form that has to be determined in the program by calling a FM " FP_FUNCTION_MODULE_NAME ".
Pass the form name in the parametrs, it will import the FM name that was generated with that form.
Then call the Generated FM. Well, I guess its always going to be tough to explain this way....
Monday, August 6, 2007
Calling a dialog screen from a report and passing data
Make a report
- Add a pf-status with a botton to call the dialog screen
- Make the dialog screen.
For every field in the dialog screen you want to pass to the report, mark the SET parameter checkbox, and apply a ParameterID in the attrubutes window of the screen. - Create a transaction code for the dialog screen
Place the following code in the report:
* p_rc is for receiving data from the dialog screen
data: p_rc type i.
at user-command.
* Call the dialog screen. ZRE1 is the transaction code of the screen
call transaction 'ZRE1'.
* Get parameter from the dialog screen. ZRZ is the parameterID for the field in the dialog
* screen you want to pass to the report.
get parameter id 'ZRC' field p_rc.
Assign Variable Type at Runtime
To assign a variable a type at runtime, use the ABAP statement ASSIGN with the option TYPE.
For instance:
DATA: D_TYPE,
D_FIELD(35).
DATA: D_TEST TYPE P.
FIELD-SYMBOLS:
D_FIELD = 'D_TEST'.
D_TYPE = 'P'.
ASSIGN (D_FIELD) TO
Additionally you can use the option DECIMALS of the ASSIGN statement if your type is 'P'.
You can even change the type at runtime of previously assigned field symbol like
ASSIGN
One more thing for dynamic programing. With the following coding you can access every DDIC table with the key you want:
SELECT SINGLE * FROM (DF_TNAME) INTO S_TMP WHERE (IF_KEY).
Standard Texts in Scripts
Standard texts are fixed texts that can be included in scripts. A standard text can be maintained in severaƦ languages.
Creating a standard text
Standard texts a created in transaction SO10
In SO10 choose menu Utillties->Copy from client
Transporting a standard text
Go transaction SE38 and submit report RSTXTRAN:
Choose language
Run the report
The standard texts that satisfies the criterias on the selection scren are shown. marj the texts that you want to transport:
After pressing the button you will nbe prompted for a change request. Select an existing og create a new.
Using a standard text in a SapScript form
Friday, August 3, 2007
Graphs in ABAP
There are two main methods for creating charts in ABAP
Using the class CL_GFW
Using the function module GFW_PRES_SHOW
There are also other classes and function modules derived from these ones.
Use transaction GRAL to explore all possibilities provided by this class and this FM.
The following are two short examples of the huge potential of function module GFW_PRES_SHOW :
The Code:
* Contain the constants for the graph type
TYPE-POOLS: GFW.
DATA: VALUES TYPE TABLE OF GPRVAL WITH HEADER LINE,
COLUMN_TEXTS TYPE TABLE OF GPRTXT WITH HEADER LINE.
REFRESH VALUES.
REFRESH COLUMN_TEXTS.
VALUES-ROWTXT = 'Salary'.
VALUES-VAL1 = 50000.
VALUES-VAL2 = 51000.
APPEND VALUES.
VALUES-ROWTXT = 'Life cost'.
VALUES-VAL1 = 49000.
VALUES-VAL2 = 51200.
APPEND VALUES.
COLUMN_TEXTS-COLTXT = '2003'.
APPEND COLUMN_TEXTS.
COLUMN_TEXTS-COLTXT = '2004'.
APPEND COLUMN_TEXTS.
* Call a chart into a standard container, this function could be used for many different graphic
* types depending on the presentation_type field :
* gfw_prestype_lines
* gfw_prestype_area
* gfw_prestype_horizontal_bars
* gfw_prestype_pie_chart
* gfw_prestype_vertical_bars
* gfw_prestype_time_axis
CALL FUNCTION 'GFW_PRES_SHOW'
EXPORTING
CONTAINER = 'CONTAINER' "A screen with an empty container must be defined PRESENTATION_TYPE = GFW_PRESTYPE_LINES
TABLES
VALUES = VALUES
COLUMN_TEXTS = COLUMN_TEXTS
EXCEPTIONS
ERROR_OCCURRED = 1
OTHERS = 2.
The Output:
Thursday, August 2, 2007
SAP HTML Viewer
This example uses the SAP HTML viewer to browse the internet. The navigation buttons are placed on a SAP Toolbar control. The Goto URL button and field are normal dynpro elements, and so is the Show URL field.
Steps:
- Create a screen and place a container named go_html_container for the HTML viewer.
- Create a dynpro button with the text Goto url and functioncode GOTOURL.
- Create a dynpro input/output field named G_SCREEN100_URL_TEXT. This field is used to key in the URLl.
- Create a dynpro input/output field named G_SCREEN100_DISPLAY_URL.
- This field is used to show the current URL The screen:
Wednesday, August 1, 2007
Text Edit Control
Steps:
1. Create a report
2. In the start of selection event add: SET SCREEN '100'.
3. Create screen 100
4. Place a custom control on the screen by choosing the custom control icon which can be recognized by the letter 'C', and give it the name MYCONTAINER1.
5. To be able to exit the program, add a pushbutton with the function code EXIT.
6. In the elements list enter the name OK_CODE for the element of type OK.
The code
REPORT sapmz_hf_controls1 .
CONSTANTS: line_length TYPE i VALUE 254.
DATA: ok_code LIKE sy-ucomm.
* Create reference to the custom container
DATA: custom_container TYPE REF TO cl_gui_custom_container,
* Create reference to the TextEdit control
editor TYPE REF TO cl_gui_textedit,
repid LIKE sy-repid.
START-OF-SELECTION.
SET SCREEN '100'.
*---------------------------------------------------------------------*
* MODULE USER_COMMAND_0100 INPUT *
*---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.ENDMODULE.
" USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
* The TextEdit control should only be initialized the first time the
* PBO module executes IF editor IS INITIAL.
repid = sy-repid.
* Create obejct for custom container
CREATE OBJECT custom_container
EXPORTING
container_name = 'MYCONTAINER1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6 .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Create obejct for the TextEditor control
CREATE OBJECT editor
EXPORTING
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true
parent = custom_container
EXCEPTIONS error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5
others = 6 .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
The Output: