Вы находитесь на странице: 1из 4

FOROSAP.

COM
Naming Conventions
All ABAP programs should follow the following naming convention:
Zwwxnnym
Where:
ww is the 2 character SAP module code (e.g. SD = Sales and Distribution, MM =
Materials Management).
x is the programs use, either: I (interface),
or R (report),
or T (take-on)
or F (SAPScript Form driver)
nn is a consecutive number.
y is the program type, either: B,
or I (include).
m is a consecutive number.
Programming Considerations
The following guidelines should be considered when writing ABAP code:
1. A program header comment should be at the top of every new Executable
program, with the following information:
1.
2.
3.
4.
5.
6.

Program Name.
Program Title.
Author.
Date Written.
Reference (Project name, Work Request or Help Request number).
Description.

2. Comments should be added to the top of an Executable program for every


amendment made, with the following information:
1.
2.
3.
4.
5.

Date
Author
Reference (Project name, Work Request or Help Request number)
Amendment Description
Amendment Scan Code (xx where xx is a consecutive number).
Amendments made to Include programs should be commented in the
header of the Executable program which uses the Include the only
exception is where an Include may be used in more than one
Executable program, in which case the Include should be
commented.

3. Global Types, Constants, Variables and Selection Parameters should be


placed in an Include program declared at the top of the main executable
program. Common and familiar subroutines such as those used for
controlling BDC sessions can also be defined in the Include program.
4. The main processing area of an Executable program should make full use of
the following Events wherever appropriate:
START-OF-SELECTION.
Should always be used place main selections here. Can also use for
updating data, writing reports and displaying Selection Screens.
END-OF-SELECTION.
Should always be used place code to be executed on completion of
program here. Can contain code for writing reports, updating data and
releasing SAP object locks.
TOP-OF-PAGE.
Should be used where a report is being produced. Use to write standard
report header (see 13.1) and column headings.
5. All code should be structured, making full use of Subroutines and ABAP
control structures together with program comments that describe what each
section of code is doing.
6. Indentation should be used to show control structures clearly within the
program. This together with use of lower & upper case (Program > Pretty
Printer).
7. On no account should program literals be used. All program texts should be
executed as Text Elements, Messages or Configuration Text Tables this is
to support Foreign Language texts using the standard SAP language
translation tools.
8. Where there is significant processing being carried out from a screen job
progress messages should be displayed. These are achieved by using the
SAP Function SAPGUI_PROGRESS_INDICATOR. This function allows text
messages to be displayed (using a text element) as well as a percentage to
completion indicator.
9. When using CALL TRANSACTION to mass process manual maintenance
tasks thought should be given to the live data which will be maintained, with
particular attention to possible warning and error messages!
10. When using CALL TRANSACTION to mass process manual maintenance
tasks the authority to run the called transaction should be checked using the

SAP standard function AUTHORITY_CHECK_TCODE.


11. When using CALL TRANSACTION to perform mass changes to Material
Masters, be aware that some of the Tab cards may be missing for certain
materials (eg. Material Classification) and that your program should cope with
this. With this in mind it is better to jump to specific Tabs rather than letting
the ENTER key work its way through the TAB cards.
12. Thought should be given to audit reports so that they are not filled with
meaningless data this was a particular problem with programs produced by
contract programmers.
13. When designing Report output the following points should be taken into
consideration:
1. The Report Header title box should include the following: Report Id
(sy-repid), User Name (sy-uname), Report Title (sy-title), Date
(sy-datum), Time (sy-uzeit) and Page (sy-pagno). The standard SAP
report header should not be used (NO STANDARD PAGE
HEADING).
2. Thought should be given when designing, to allow the report output to
be easily downloaded into a useful format for an Excel spreadsheet.
Things to consider here are the Report format size (LINE-SIZE and
LINE-COUNT) and the column nature that the data is presented,
particularly when line wrap around is used.
3. Thought should be given to foreign languages when deciding upon
the width of columns. Also if a columns data is wider than the English
text description the Text Element width should be set to the width of
the data. This then allows longer foreign language words to be easily
used.
4. Report Hotspots should be coloured in Yellow, so users are aware
that a drill-down function call is available for this piece of data (eg.
Purchase Order Number -> PO Inquiry ME23).
5. When using Hot-spots, to execute CALL TRANSACTION. Thought
should be given as to what screen should be displayed. ie. It is
useless displaying a Purchase Order Header screen if somebody
drilled-down from a Purchase Order line item!
14. When using Tab delimited spreadsheet uploads the standard SAP function
WS_UPLOAD should be used, this will prompt for the file name to be
selected as well as loading it into the internal table.

15. Program messages are to be defined in a general Message Class


Zenterprice. Other message classses have been used in the past, these
include ZEDI, ZINT, ZINT1 and ZTAKEON these should no longer be used.

Efficiency Considerations
ABAP SQL SELECT statements can easily be made more efficient using the
following guidelines:
1. Keep the result set small.
Use the WHERE clause to ensure that as few records as possible are
retrieved from the Database Server.
2. Minimise data transferred between the Database and Application
Servers.
Never use the SELECT * FROM form instead select only the required
fields e.g. SELECT VBELN POSNR FROM VBAP INTO. This will also
remove the need for a TABLES statement at the top of the program. Up to
40% improvement.
If it is necessary to directly update a table, use the
UPDATESETWHERE statement, rather than selecting and updating.
This avoids any data retrieval, only sending an instruction to the Database
Server. It is however, limited to setting fields to a specific value or simple
increments/decrements. Up to 40% improvement.
Use aggregate functions (COUNT, SUM, MAX, MIN, AVG) where possible,
rather than manually computing these values. This retrieves only the result of
the function and not all the records needed to calculate that result. Up to 58%
improvement with MAX function.
Note that calculations on the Database Server may use NULL values,
potentially producing different results to ABAP, e.g. AVG(1, 3, 0, 0) = 1 but
AVG(1, 3, null, null) = 2.
3. Minimise the number of transfers between the Database and
Application Servers.
When selecting several records from a Dictionary table, use
SELECTFROMINTO TABLE to retrieve records into an internal table
in a single move. Up to 65% improvement

Вам также может понравиться