sap tips/ sap 小技巧
Other Useful Tips
Adding Custom Fields to POs, Outline Agreements, and RFOs
Authorization Failures on Fixed Asset Reports
Find Programs That Use a Layout Set
Understanding Date Selections Using the HR Logical Database
Printing Blank Lines
Central Address Management
Useful User Paramters
Maintaining Trailing spaces when downloading to PC
Up/Downloading Dynpros in 4.x
List Boxes on Selection Screens
Adding Custom Fields to an Infotype
Step by step the method for batch input of data without using ABAP/4 or other programming language
Using Application Logging
Where in IMG is a table configured
Finding User Exits
Mass Generation of ABAP Source
Specifying the Index for a Select Statement to use
Hiding ABAP Source Code
Standard Conversion Exits
Finding a transaction code via SE93
List of ways to transport variants
List of methods to FTP from within SAP
How to Archive (and delete) Material Master Records
Explantion of Return Codes from the AUTHORITY-CHECK Command
Editor Tips (*EJECT and *$*$)
Change the font on the X_65_255 paper size
How to find a single quote within a string
Helping the DBMS find the correct index
Reading from the Database
Saving screens created with Screen Painter
Help Views
Additional Help View Information
Authorization Object for a printer - S_SPO_DEV
Field Exits
BSEG Access
Example of joining tables
How to change development class of a SAPscript
How to transport Standard Texts
Importing Graphics (Logos) into SAPScript
Other useful programs for SAPScript (provided by Paul Kjaer)
Debug SAPScript (provided by Paul Kjaer)
How to Change Standard Price in Material Master
Authorization Failures on Fixed Asset Reports
In Fixed Assets, a user may be unable to run a report, or unable to get results from a report without getting any authorization failures. The reason for this is the the Fixed Asset reports convert the users authorizations to select statements in logical database ADA. The authorizations are never checked directly.
The authorizations that are required to run Fixed Asset reports are A_S_ANLAL, A_S_WERK, A_S_GSBER, and A_S_KOSTL. OSS note 141876 deals with this problem, but it misses one of the required authorizations (A_S_KOSTL).
Printing Blank Lines
Use the command SET BLANK LINES ON. After that, blank lines should be printed.
Useful User Paramters
GR8 - File Download Path default
GR9 - File Upload Path default
TTD - SAPScript Form Debugger (X = start debugger)
Maintaining Trailing spaces when downloading to PC
Before calling DOWNLOAD or WS_DOWNLOAD, do a perform SET_TRAIL_BLANKS(saplgrap) using 'X'
To set the length of each record including your blanks add this code: perform SET_FIXLEN(saplgrap) using '0' '100'
Up/Downloading Dynpros in 4.x
The option to download dynpros does not appear in the menu structure in 4.x. The function is there but you just don't have access through the menu. Type 'UTDL' in the command field to dowload a dynpro (you must be in display or change mode). To upload it into another system for example, create a new dynpro and enter in edit mode. Type 'UTUL' in the command field.
Note that this works in version 3.1 and up of SAP.
Thanks for Francois Henrotte for the tip.
Adding Custom Fields to an Infotype
Starting in Version 4.5, SAP allows easy customizing of the infotype screens by providing customers with subscreens and customer specific includes for infotypes.
Transaction PM01 is used to customize the infotype, and the online help is reasonably useful in walking you through the steps needed to add your own fields to the infotype.
Step by step the method for batch input of data without using ABAP/4 or other programming language
The instructions on how to do this can be found in this document (PDF format) -
Where in IMG is a table configured
Use SM31, enter the table name.
Click on Customizing.
Enter an IMG project, or click w/o proj button.
Click enter. Gives you IMG path(s) which lead to updating given table.
Finding User Exits
Notes about user exits (valid up to at least SAP release 4.0B)
One way to find user exits applicable for a given SAP screen. From the SE38 screen, enter the desired screen main program, and click Utilities > Find In Source Code, and "CUSTOMER-FUNCTION" as the text to search for. This will give you a list of the user exits and where they are called from for all screens in the module pool.
Note: format of ABAP statement is CALL CUSTOMER-FUNCTION '009', for example. This is the statement called by a submodule attached to the main program.
Actual related function is EXIT_SAPLCOIH_009, for example. This example refers to customer function 9 in main program SAPLCOIH. Not all user exit functions are names as such, but this is the usual format.
If you are doing data validation and want to set an error message with a field open, you must be sure that the user exit you are using is linked to a calling module in the PAI section of the screen and the field you wish to be open was in the CHAIN statement which caused the PAI module to be invoked.
If you use a customer function which was invoked by a PBO module to validate data, the "MESSAGE" statement will cause the screen to return with the desired message at the bottom, but with all screen fields closed for input.
When you make changes to the include module for a given customer function, you must regenerate the related function group before you will see the changes included in the screen behaviour.
Mass Generation of ABAP Source
You can use the ABAP Load Generator (transaction SGEN) to generate ABAP loads for large numbers of programs, function groups, module pools, and so on.
This is particularly important after an upgrade, since at this point the system only contains a few ABAP loads. A load is generated automatically when you start a program if it does not already exist, however this may lead to poor performance.
The transaction SGEN replaces the report program RDDGENLD. This report program only let you regenerate those loads that were already in the system before the upgrade. No loads were generated for new programs.
The transaction SGEN has the following advantages over RDDGENLD:
You have much greater influence over the number of loads generated. This is especially important for new programs for which there were no loads before the upgrade. For example, you can generate loads only for those components that you want to use (such as HR, LO, AC or BC). This saves space in the database.
You can use the Job Monitor in transaction SGEN to control more effectively the background job that generates the load.
For a detailed description of transaction SGEN, click the pushbutton Information on any dialog box in the transaction.
Specifying the Index for a Select Statement to use
This is valid from 4.0 on.
Example:
REPORT z_generic_test_program .
TABLES: csks.
START-OF-SELECTION.
SELECT * UP TO 10 ROWS FROM csks
WHERE kokrs <> space AND
kostl <> space
%_HINTS ORACLE 'index(csks"J")'.
WRITE: / csks.
ENDSELECT.
Hiding ABAP Source Code
Please note, this tip does not appear to work in versions of SAP >= 4.6. It is very easy to hide your source code in ABAP. Simply enter *@#@@
on the very first line of your program. This text should be the only text on the line. There is no easy way to get your source code back, so make sure you make a backup and save it to a local drive!
Standard Conversion Exits
Most conversion exits used in screens by SAP are actually function modules. You can find them by searching for CONVERSION_EXIT_name_INPUT and CONVERSION_EXIT_name_OUTPUT.
Finding a transaction code via SE93
Go to Transaction SE93 and press F4 and then Press All selections button. It will give you a better search to look for a transaction than directly going to table TSTC. (Submited by Ram Mullapudi)
List of ways to transport variants
There are at least three ways that I know of that you can transport a variant for a program.
How to Archive (and delete) Material Master Records
Use the FILTER option on the OPEN DATASET command
Have an external step in your job that runs after the dataset has been created. The external step will call a script with parameters to do the ftp.
This document was provided by Jon Davatz - Homepage for SAP Professionals -
Download the document here -
Explantion of Return Codes from the AUTHORITY-CHECK Command
Return Code Explanation
0 Passed the check.
4 User is not authorized to perform the task
8 The number of fields has exceeded 10
12 Object specified does not exist
24 FIELD names specified in the check do not match the object
28 System Error
32 System Error
36 System Error
If you have several status' for a program that are nearly identical, it can be easier to setup and maintain a single status, and just hide parts of it as required. Rember, this is sample code only. It is a snippet from a real program, and I may have forgotten to include some things.
Example:
data: BEGIN OF MTAB_UCOMM_EXCLUDE OCCURS 0,
VALUE(4) TYPE C,
END OF MTAB_UCOMM.
AT USER-COMMAND.
PERFORM SET_PF_STATUS. ...
*---------------------------------------------------------------------*
* FORM SET_PF_STATUS *
*---------------------------------------------------------------------*
* Set up the menus/buttons for the report *
*---------------------------------------------------------------------*
FORM SET_PF_STATUS.
CLEAR MTAB_UCOMM_EXCLUDE.
REFRESH MTAB_UCOMM_EXCLUDE.
CASE MI_CURRENT_PAGE.
WHEN 1.
*-- Do not want any pushbuttons that point to items to the right
*-- since the list is at its rightmost position
MTAB_UCOMM_EXCLUDE-UCOMM = 'FRST'.
APPEND MTAB_UCOMM_EXCLUDE.
MTAB_UCOMM_EXCLUDE-UCOMM = 'PREV'.
APPEND MTAB_UCOMM_EXCLUDE.
WHEN MI_TOTAL_PAGES.
*-- Do not want any pushbuttons that point to items to the left
*-- since the list is at its leftmost position
MTAB_UCOMM_EXCLUDE-UCOMM = 'LAST'.
APPEND MTAB_UCOMM_EXCLUDE.
MTAB_UCOMM_EXCLUDE-UCOMM = 'NEXT'.
APPEND MTAB_UCOMM_EXCLUDE.
WHEN OTHERS.
*-- Want all pushbuttons to appear on any other page
ENDCASE.
SET PF-STATUS 'MAIN' EXCLUDING MTAB_UCOMM_EXCLUDE.
ENDFORM. " SET_PF_STATUS
Editor Tips (*EJECT and *$*$)
*EJECT - If you put *EJECT at the start of a line, it will force a new page when you print your source code. This comes in real handy when you would like to have subroutines start at the top of a new page.
*$*$* - By placing *$*$ at the beginning of a comment line will lock the line for editing. You are able to edit the line until you hit the enter key.
Change the font on the X_65_255 paper size
This tip was taken from the SAP-R3 mailing list, and is by Sheila Tichener.
If you need to use a large line-size to get all your data in I know the sap version of X_65_255 for hp laser jet 4 gives an unnecessarily small font .
You can change it in SPAD (or copy to Y_65_255) as follows.
Example:
Choose Device formats, Change
hplj4
x_65_255
Execute
Double click on printer initialisation
Change from:-
# select Courier 16.67 CPI normal font
\e(s0p16.67h0s0b4099T
to:-
# select arial 24 cpi 15 point normal
\e(s0p24h15v0s0b16602T
................
Also bold as follows:-
# select arial 24 cpi 15 point bold
\e(s0p24h15v0s3b16602T
It still fits and looks better.
Also the error you get when changing a format in the output screen is only a warning and can be overidden by pressing the green tick.
If the sap standard formats don't fit your requirements you can create your own eg Y_65_170 . It seems to be the numbers in the name that somehow triggers which one the abap chooses.
Sheila
How to find a single quote within a string
Use 4 single quotes to find one quote in a string. The following code snippet will replace a single quote with a double quote.
Example:
replace '''' with '"' into field
Helping the DBMS find the correct index
Sometime, you may find that the a SELECT that you have coded is very slow, even though you have put all the fields needed for an index in your where clause. Usually, this means that the DBMS is selecting the wrong index, you can tell if this is the case by doing an SQL trace (System - Utilities - SQL Trace). You can help the DBMS select the correct index by providing hints, include all fields from the index, and make sure that the fields are in the same order as they appear in the index.
Reading from the Database
(Provided by Paul Kjaer)
For efficiency, consider loading tables into internal tables. 200000 calls from memory structure are much more efficient than 200000 DB calls.
Saving screens created with Screen Painter
(Provided by Paul Kjaer)
If you are in Object Browser looking at the module program, you can highlight the screens and click the print button. Click no to print immediately, then go into System -- Services -- Output Control to select the spool request and then go into List -- Save -- Local File. (Of course, you can send it to a printer to see documentation on your screen).
Help Views
(Provided by Paul Kjaer)
For instance, I set this up in a multi-language environment when you have a code and text combination you want to set up. Typically, you have to set up two tables: One with just the valid codes i.e. Zxxx where the only field is the code field, the second is ZxxxT which contains the code and language as the primary index with the description as the data field. In this case, then you usually define a view H_Zxxx which is a join on these two tables. The key thing is that the Foreign Key definition for the code field in the ZxxxT must have the must have the type "Key Fields of a Text Table". This results in the Table Maintenance generator (SM30) generating a screen that allows you to maintain the code and description together for the system language.
In a related note, to set up a customer transaction for a Table Maintenance generated dialog, use SE80 and enter the function group used for the table maintenance dialog. Then Create a transaction (Zxxx) of type parameter. Fill in text, specify Transaction SM30, click on "skip initial screen" and set up default values of VIEWNAME set to Zxxx and UPDATE set to X.
Additional Help View Information
Hi,
I was reading your Hint on help view. I want to add some details to this hint.
* After defining a foreign key relation of type KEY FIELDS IN A TEXT TABLE the system automatically combines updates of the base table and the text table. Try defining two tables and the foreign key as stated above. So creating a help view is not needed for this purpose.
* The help view is useful when you want to have a matchcode-like F4 help on a specific field. Every field that is based on same domain automatically uses the help view if no other F4 help (Matchcode, Process on value request) is related. For a value table only one help view can be defined.
Example:
If you define in your abap a parameter or select-options 'parameters: pa_bukrs like t001-bukrs.' you will see that is automatically has a F4 help. This help is provided by helpview H_T001.
Kind regards,
Ben Meijs
Ben.Meijs@ctac.nl
Authorization Object for a printer - S_SPO_DEV
(Provided by Paul Kjaer)
Field Exits
(Provided by Paul Kjaer)
You cannot debug a field exit. You can at best create a small module pool with a screen that has the appropriate fields and in your PAI, call a module which calls your function that is the field exit and debug the small module pool. Good idea to keep as much of one around if you do field exits regularly.
I used CNEX0007 and CNEX0006 to add fields to the PRPS and PROJ tables respectively in the PS Module. As probably the case with most of these exits, have fun trying to figure out how to protect the fields in display mode. We lived with the fact that the save was disabled so it could not save the changes anyway. A test of the transaction code would not be complete. Use transaction SMOD to do SAP enhancements/field exits. In SMOD, you can get list of SAP enhancements that exist by Utilities - SAP Enhancements. Trying to figure out what they can be used for and how to accomplish the desired results is a major challenge.
How to change development class of a SAPscript
Use program RSWBO052 (provided by Alan Cecchini)
How to transport Standard Texts
Use Program RSTXTRAN or enter directly in transport
Put entry directly into the transport:
R3TR TEXT TEXT,Text Name,ST,Language
R3TR TEXT TEXT,Z_ALLERGAN_SWISS_DISTRIBUTOR,ST,E
Importing Graphics (Logos) into SAPScript
The program RSTXLDMC can be used to upload graphics (file extension .tif on PC files) into individual standard text.
Other useful programs for SAPScript (provided by Paul Kjaer)
RSTXFCON
Converts SAPScript page formats
RSTXSCRP
Upload and download SAPScript layout sets
Calling an ABAP form from SAPScript (provided by Paul Kjaer)
Example:
In Layout Set:
DEFINE &X& = ...
DEFINE &Y& = ...
DEFINE &Z& = ...
PERFORM XXXXXXIN Zxxxxxxx
USING &X&
USING &Y&
CHANGING &Z&
In ABAP program Zxxxxxx
FORM XXXXXX TABLES INPUT1 STRUCTURE ITCSY
OUTPUT1 STRUCTURE ITCSY
*get input parameters
LOOP AT INPUT1.
CASE INPUT1-NAME.
WHEN 'X'.
INPUT_X = INPUT1-VALUE.
WHEN 'Y'.
INPUT_Y = INPUT1-VALUE.
ENDCASE.
ENDLOOP.
{logic to use program variable input_x and input_y to set say program variable output_z}
*set output variables:
REFRESH OUTPUT1.
OUTPUT1-NAME= 'Z'.
OUTPUT1-VALUE = OUTPUT_Z.
APPEND OUTPUT1.
Debug SAPScript (provided by Paul Kjaer)
You can debug a SAPScript: Use Tools - Word Processing - Layout Set. Enter name of layout set and then Utilities - Activate Debugger.
A further note to the tip above was provided by John Verbestel: It is of no consequence which layoutset you enter when selecting the SAPscript debugger. (Menu path: Tools-Wordprocessing - Forms, Utilities - Activate Debugger) The next layoutset called will invoke the debugger. This is quite handy when verifying which layoutset is being called (Verifying customizing settings).
Another way to set the SAPScript debugger is to run program RSTXDBUG. Thanks to Amanda for this tip.
How to Change Standard Price in Material Master
The standard price can not be updated directly.
One way to update the standard price is to fill the fields Future Price (MBEW-ZKPRS) and the Effective Date (MBEW-ZKDAT) for the material on the accounting view.
Next, go to Logistics -> Materials Management -> Valuation -> Valuation
Price Determination -> Future Price -> Activate
(TCODE MR2B, program RMMR2100)
Lastly, run the BDC that was created to update the standard price.
页:
[1]