SAPLab-SAP Tips! ABAP Tips!

SAP ABAP User!

SAP ABAP Performance Standards

SAP ABAP Performance Standards via saptechnical.com

Description

Result (Y, N or N/A)

Comments

Run Extended syntax checks with character literals checkbox switched on & Code Inspector to rectify all relevant errors and warning (e.g. Use the results of the above checks to remove all variables/constants etc that are declared but are not used)

   

Transaction SE30 (ABAP Runtime Analysis) must be checked to measure/compare program performance/runtime if program has multiple inefficient databases selects or complicated internal table operations

   

Use transaction ST05 (SQL Trace) to see what indices your database accesses are using. Check these indices against your “where” clause to assure they are significant. Check other indices for this table and where you have to change your “where” clause to use it. Create new indices if necessary, but do not forget to check the impact by consulting onsite coordinator.

   

TYPE (data element) command is used while declaring the fields whenever feasible instead of LIKE. Remember not always the data element name matches with the table field name

   

Internal Table is defined with “TYPE STANDARD TABLE OF” & Work-Areas is used instead of header lines

   

Global variables are minimized by declaring local variables or by passing variables through parameters & arguments while creating internal subroutine(s)

   

In SELECT statement, only the required fields are selected in the same order as they reside on the database table/structure/view

   

For selecting single row from a database table, “SELECT UP to 1 Rows” is used. “Select Single” is used only when full primary key combination is known

   

No SELECT * is used

   

Use “SELECT INTO TABLE” rather than “SELECT INTO CORRESPONDING FIELDS OF TABLE”

   

Always specify as many primary keys as possible in WHERE clause to make the Select efficient

   

Always select into an internal table, except when the table will be very large (i.e., when the internal table will be greater than 500,000 records). Use “Up to N Rows” when the number of records needed is known

   

Select statement within a GET event is not used

   

Wild cards like ‘A%’ is avoided as much as possible

   

Nested Select is not used instead “Inner Join” and/or “For all Entries” is used. “For all Entries” is to be used over “Loop at ITAB / Select / ENDLOOP” (FOR ALL ENTRIES retrieves a unique result set so ensure you retrieve the full key from the database)

   

When creating joins over database tables there should be an index at least on the inner table for the fields in the join condition else use “ FOR ALL ENTRIES” select statement

   

Usage of JOIN is limited to a maximum of 2 i.e. not more than 3 database tables are joined at one time

   

CHECK that the internal table used in FOR ALL ENTRIES is NOT empty as this will retrieve all entries from the table

   

Delete adjacent duplicate entries from internal table before selection from database table using “ FOR ALL ENTRIES” statement

   

For copying internal tables use ‘=’ operator instead of Looping & Appending

   

SORT inside a LOOP is not used

   

Sort internal table by fields in the correct order, which are used in a READ TABLE statement using BINARY SEARCH. If the order of sorting is invalid the BINARY SEARCH will never work

   

For large internal tables where only some rows are to be processed, use SORT and then the READ TABLE command is used to set index to first relevant row before looping from that index. Use CHECK or IF…EXIT…ENDIF as appropriate to exit from the loop

   

Sort fields and Sort Order on the SORT statement should be mentioned explicitly (e.g. SORT ITAB BY FLD1 FLD2 ASCENDING)

   

Hashed table is used for processing large amount of data (provided that you access single records only, and all with a fully specified key)

   

DELETE or SORT is not used on a hashed table since it increases memory consumption

   

Sorted table is used for range accesses involving table key or index accesses

   

Fields specified in the WHERE condition with the critical operators NOT and <> (negative SQL statements) cannot be used for a search using database indexes. Whenever possible formulate SQL statements positively

   

When coding IF or CASE, testing conditions are nested so that the most frequently true conditions are processed first. Also CASE is used instead of IF when testing multiple fields “equal to” something

   

LOOP AT ITAB INTO WORKAREA WHERE K = ‘XXX’ should be used instead of LOOP AT ITAB INTO WORKAREA / CHECK ITAB-K = ‘XXX’.

Also READ TABLE INTO WORKAREA should be used instead of only READ TABLE.

   

After the APPEND statement inside a loop, the work area that has been appended is cleared

   

Internal tables, Work areas & Global Variables are freed when no longer needed (e.g. using the FREE / REFRESH command), especially when the tables are large or the program is a batch program

   

Do not delete the records of internal table inside the Loop – End loop.

Do not use:

LOOP AT ITAB WHERE EQUNR = ‘00001011’.

DELETE ITAB.

ENDLOOP.

Use:

DELETE ITAB WHERE EQUNR = ‘00001011’. 

   

Use the MODIFY ITAB … TRANSPORTING f1 f2 … for single line, and MODIFY ITAB … TRANSPORTING f1 f2 … WHERE condition for a set of line, to accelerate the updating of internal table

   

If possible, Update/Insert statement is used instead of Modify

   

Is the following steps ensured during database updates?

  • Lock data to be edited
  • Read current data from the database
  • Process data and write it to the database
  • Release the locks set at the beginning
   

Try to avoid logical databases. If your program uses a logical database, but does not require all fields belonging to a certain GET event, always use the FIELDS addition to reduce the amount of data selected by the logical database

   

Avoid the aggregate (Count, Max, Min) functions in the database selection

   

Use Parallel Cursor methods for nested loop into the internal tables if second internal table contains considerable number of records

   

In Smartform/ Sapscript do not make redundant data retrieval where data is available in interface

   

When I try to open Adobe Form’s layout of Adobe LiveCycle Designer with Tcode-SFP, I always get Windows Error Message   “Adobe LiveCycle Designer Error”.

How to solve the problem? Finally, there are  2 solutions to solve it.

1. If your Adobe Reader Version is 9.0, please try downgrading to  Version 8.0, you can download it from Adobe.com.

or

2. Create a windows user ID and run Adobe LiveCycle Designer on your SAP, so there will not display Windows Error Message again.

Following is FI/CO Interview Questions & Answers(PDF version). I got the document  from web.

FI/CO Interview Questions & Answers(PDF version)

Q: How to find menu path if i know t-code in spro?

A: You can use "SEARCH_SAP_MENU" and put t-code MM02( e.g).

1. Enter “SEARCH_SAP_MENU”.

image

2.Input t-code “mm02”

image

3. Result

image

About SAP IDOC AND ALE articles

Outbound Idoc Through ALE

https://www.sdn.sap.com/irj/scn/wiki?path=/display/ABAP/Outbound+Idoc+Through+ALE

Abap code snippet for triggering an existing IDOC through BADI

https://www.sdn.sap.com/irj/scn/wiki?path=/display/Snippets/Abap+code+snippet+for+triggering+an+existing+IDOC+through+BADI

ALE,IDOC

https://www.sdn.sap.com/irj/scn/wiki?path=/display/ABAP/ALE%252CIDOC

Outbound Idocs by ALE

https://www.sdn.sap.com/irj/scn/wiki?path=/display/A/Outbound+Idocs+by+ALE

ALE Business process

https://www.sdn.sap.com/irj/scn/wiki?path=/display/HOME/ALE+Business+process

ALE (Application Linking and Enabling)

https://www.sdn.sap.com/irj/scn/wiki?path=/display/HOME/ALE+Business+process

ALE Change Pointers

https://www.sdn.sap.com/irj/scn/wiki?path=/display/ABAP/ALE+Change+Pointers

ALE IDOCS

https://www.sdn.sap.com/irj/scn/wiki?path=/display/ABAP/ALE+IDOCS

ALE (Application Linking and Enabling)

https://www.sdn.sap.com/irj/scn/wiki?path=/display/HOME/ALE+%2528Application+Linking+and+Enabling%2529

Basics of IDoc…

Idoc with ABAP Port

https://www.sdn.sap.com/irj/scn/wiki?path=/display/profile/2007/09/12/Idoc+with+ABAP+Port

Administration of ALE Functions and Troubleshooting ALE

https://www.sdn.sap.com/irj/scn/wiki?path=/display/ABAP/Administration+of+ALE+Functions+and+Troubleshooting+ALE

Step by Step procedure for creation of IDOC

https://www.sdn.sap.com/irj/scn/wiki?path=/display/HOME/Step+by+Step+procedure+for+creation+of+IDOC

How to Improve the runtime of the 0FI_GL_4 extractor

https://www.sdn.sap.com/irj/scn/wiki?path=/display/Snippets/How+to+Improve+the+runtime+of+the+0FI_GL_4+extractor

Remote Function Module calling From SAP 4.7E to SAP ECC 5.0

https://www.sdn.sap.com/irj/scn/wiki?path=/pages/viewpage.action&pageId=39728

https://www.sdn.sap.com/irj/scn/wiki?path=/display/BI/Basics+of+IDoc

IDOC Steps

https://www.sdn.sap.com/irj/scn/wiki?path=/display/ABAP/IDOC+Steps

 

via Jack Wu’s Blog

There is a very good ABAP Programming Guidelines, it’s pdf version. If you want to download it,pls refer below link.

Official ABAP™ Programming Guidelines

official abap programming guildelines

FI/CO Interview Questions & Answers

There is a PDF version of FI/CO Interview Questions & Answers.

FI/CO Interview Questions & Answers

What is SAP SMARTFORM? There is a PDF version tutorial about SMARTFORM by SDN.

SMARTFORM-tutorial Download

What is IDOC?

What is IDOC
• IDOC = Intermediate Document
• IDOC is simply a data container used to exchange information between any two processes that can understand the syntax and semantics of the data.
• When we execute an outbound ALE or EDI Process, an IDOC is created
• In an inbound ALE or EDI process, an IDOC serves as input to create an application document.
• In the SAP System, IDOCs are stored in database.
• Every IDOC has an unique number(within a client).
• IDOCs are independent of the sending and receiving systems.(SAP-to-SAP as well as Non-SAP)
• IDOCs are based on EDI standards, ANSI ASC X12 and EDIFACT. In case of any conflict in data size, it adopts one with greater length
• IDOCs are independent of the direction of data exchange e.g. ORDERS01: Purchasing module : Inbound and Outbound
• IDOCs can be viewed in a text editor. Data is stored in character format instead of binary format.
IDOC Components
Basic IDOC Type (we30)
• Basic IDOC Type defines the structure and format of the business document that is to be exchanged.
• IDOC Type has a
– specific name
– list of permitted segments
– hierarchy of segments
– mandatory/optional segments
– minimum/maximum range of each segment.
Segments
• Segment defines the format and structure of a data record. Segments are reusable components.
• For each segment SAP creates
– Segment Type (version independent)
– Segment Definition (version dependent)
– Segment Documentation
• The last 3 characters is the version of the segment
• Definitions keep changing as per the version but the segment type remains the same
IDOC Run-Time Components
• An IDOC is an instance of an IDOC Type
• At run time the following events occur
– A unique IDOC no. is allocated by SAP
– One control record is attached to the IDOC
– Segments translate into data records
– Status records are attached
– Syntax rules are checked.
• Each IDOC has 3 parts
– Control Record
– Data Record
– Status Record
• We02 or We05
Control Record
• All control record data is stored in EDIDC table. The key to this table is the IDOC Number
• It contains information like IDOC number, sender, recipient information, channel it is using, which port it is using etc.
Data Record
• Data record contains application data like employee header info, weekly details, client details etc
• All data record data is stored in EDI_DD40 table and EDI_DD
Status Record
• Status record are attached to an IDOC at every milestone or when it encounter errors.
• All status record data is stored in EDID8 table.
Where and How IDOC is created
Where and How an IDOC is created?
• Lets take an example to understand this:
• Whenever a Purchase Order (PO) is created we want to send the IDOC to a vendor.
• The PO is sent in the form of an IDOC to the vendor (partner). That partner has to be EDI enabled in that system.. SAP should realize that it could send doc to this vendor electronically. (Creating a vendor is not sufficient). Partner Profile should be EDI enabled i.e. A partner profile should exist in the sap system.
• Quotation, RFQ, PO, SO, Invoice, delivery challan etc are some of the commonly exchanged documents through IDOCs
• We create only one profile for both inbound and outbound IDOCs.
• Partner profile should contain message type……to be able to exchange the IDOC.
• We define partner type, partner function and message type (it distinguish if an IDOC is being sent to same person in same function for different reason e.g. SO)
Process Code
Creating Outbound Process Code (WE41)
• What is Process Code?
Process of filling the IDOC with application data is done by Function Module. But, function module is not assigned to a Partner. It is encapsulated by a Process Code and this Process Code is assigned to a Partner in Partner Profile.
• Assigning Function Module to Process Code
- Go to Transaction WE41.
- Switch to “Change” Mode and click “New Entries”.
- Enter Process Code Name and assign the Function Module created.
Partner Profile
Creating Partner Profile (WE20)

• What is Partner Profile?
We must maintain the business partners with whom we communicate via IDocs, in Partner Profiles.
• Steps to create Partner Profile
- Goto Transaction WE20.
- Click on Create Button.
- Enter the Number of Vendor Created in Partner No. and ‘LI’ in Partner Type fields.
- Save the Data.
- For Outbound Partner Profile we have to create Outbound Parameters
- Specify Partner Function, Message type created, Port (create a port in WE21),Basic Type and Output Mode.
- Goto “Message Control” Tab and link the Message Type and Process Code created.
- Save.
Change Application Data to be transmitted
• Change Purchase Order Created using transaction ME22n for the Vendor to which partner profile has been created.
• Go to “Messages” , add the new “Message Type” to the list and Save the Purchase Order.
• An IDOC will be created for the purchase order and will be dispatched to PORT mentioned.
Check the status of IDOC (WE02)
• The IDOC status can be checked using transaction WE02
• If the status is ’03’, it implies that IDOC is passed to Port.
Summary: IDOC Workflow
The sequence:
1. Checks whether Partner profile exists or not
2. Whether that PP has a outbound parameter
3. Whether NEU message type is there or not (message control)
4. Checks the process code (gives the name of Function module)
5. Checks immediate transfer or batch transfer
6. Based on that it checks the receiver port
7. Then it will trigger the RFC destination
8. Then it triggers the event on subsystem/customer system
9. Transfer the IDOC to a port and transfer the Idoc in terms of file and it triggers the customer system
10. Customer knows from where it should pick up the file ….it picks up the file.
Extending an Existing IDOC Type
• Used in cases where some additional information is required in addition to that supplied by the Standard IDOC Type.
• In Transaction WE30 we create the IDOC as an Extension and specify the basic type for which it is an extension.
• We add the segments needed as children to existing ones.
• None of the Reference Segments can be deleted or changed.
Extension Child Segs
Basic Type (ORDERS01)
F1
F2
F3
F4
F5
Cannot be modified
IDOC Views
• An IDOC type can be used for more than one message type, which results in IDOCs containing more fields than required for a particular message type.
• IDOC views are used to improve performance in generating IDOCs to ensure only the relevant segments are filled with data.
• IDOC Views are important only for Outbound Processing.
IDOC Type
F1
F2
F3
F4
F5
Processing Logic
• The processing logic associated with the IDOC is the function module that is written to handle the inbound/outbound IDOC.
• Its written just like any function module but has to follow a standard interface (i.e. Import, Export, Changing & Tables) parameters and it is should be RFC enabled.
• In this function module we are effectively building up a table of type EDID4 (IDOC Data table) and change the control record.

Business Add-Ins are a new SAP enhancement technique based on ABAP Objects. They can be inserted into the SAP System to accommodate user requirements too specific to be included in the standard delivery. Since specific industries often require special functions, SAP allows you to predefine these points in your software. 

As with customer exits two different views are available:

In the definition view, an application programmer predefines exit points in a source that allow specific industry sectors, partners, and customers to attach additional software to standard SAP source code without having to modify the original object. 

In the implementation view, the users of Business Add-Ins can customize the logic they need or use a standard logic if one is available.

In contrast to customer exits, Business Add-Ins no longer assume a two-level infrastructure (SAP and customer solutions), but instead allow for a multi-level system landscape (SAP, partner, and customer solutions, as well as country versions, industry solutions, and the like). Definitions and implementations of Business Add-Ins can be created at each level within such a system infrastructure.

SAP guarantees the upward compatibility of all Business Add-In interfaces. Release upgrades do not affect enhancement calls from within the standard software nor do they affect the validity of call interfaces. You do not have to register Business Add-Ins in SSCR.

The Business Add-In enhancement technique differentiates between enhancements that can only be implemented once and enhancements that can be used actively by any number of customers at the same time. In addition, Business Add-Ins can be defined according to filter values. This allows you to control add-in implementation and make it dependent on specific criteria (on a specific Country value, for example).

All ABAP sources, screens, GUIs, and table interfaces created using this enhancement technique are defined in a manner that allows customers to include their own enhancements in the standard. A single Business Add-In contains all of the interfaces necessary to implement a specific task.

The actual program code is enhanced using ABAP Objects. In order to better understand the programming techniques behind the Business Add-In enhancement concept, SAP recommends reading the section on ABAP Objects.

What is difference between badi and user-exists?
What is difference between enhancements and user-exists? and what is the full form of BADI?

I have another doubt in BDC IN BDC WE HAVE MSEGCALL (i did not remember the > correct name) where the error logs are stored, MSEGCALL is a table or structure.

What is the system landscape?

1) Difference between BADI and USER-EXIT.
    i) BADI’s can be used any number of times, where as USER-EXITS can be used only one time.
       Ex:- if your assigning a USER-EXIT to a project in (CMOD), then you can not assign the same to other project.
    ii) BADI’s are oops based.

2) About ‘BDCMSGCOLL’ it is a structure.  Used for finding error records.
3) Full form of BADI ‘Business addins’.
3) System land scape will be depends on your project 
    Ex:- ‘Development server’–>’Quality server’—> ‘Production server’…… 

via http://www.sap-img.com/abap/difference-between-badi-and-user-exits.htm

« Previous Entries  
<-- Google fenxi --!> <-- google fenxi end --!>