Wednesday, April 30, 2008
SAP ABAP Editor Icons
If the help of the icons in the SAP ABAP Editor you can do the following from the initial screen.
Check the Program:
The program is checked for syntax errors. One the program is free of Syntax errors you can activate it.
Activate the Program:
Only activated version of the Program can be executed. You can have 2 versions of the program, Active and Inactive.
Run the Program
The program can be executed by this Icon.
Check the where used list.
You can check where all the current program is used in the SAP system. This can be useful for Includes and Function Modules.
Do the Environment Analysis
Gives a list of Objects used in the Program along with short description and development class.
Online Manual
Gives online documentation for ABAP Statements, Keywords, Objects
Delete the Program
Deletes the Program. Make sure that you have a backup of the program before deleting it. If you have transported the program to Quality or Production then it is possible to retrieve the program. As a general rule always back up the program.
Copy the Program
Makes a copy of the Program.
Rename the Program
Renames the Program
Start Debugging
You can start the debugger from here.
Execute the Program with a Variant
Execute the Program with a variant. You need to create a Variant first.
Get the Variant List.
If you have created a Variant you can get a list and choose the desired Variant.
SAP ABAP Function module to calculate the difference between 2 dates
The function module HR_HK_DIFF_BT_2_DATES in SAP ABAP can be used to calculate the difference between 2 dates.
Please check the following program. Experiment with the OUTPUT FORMAT (Example '01', '02', '03', '04', 05'). Make sure that Date1 is greater than Date2
Data: d_date1 like P0001-BEGDA,
d_date2 like P0001-BEGDA,
d_yrs like P0347-SCRYY,
d_months like P0347-SCRMM,
d_days like P0347-SCRDD.
* Date1 should be greater than date 2
d_date1 = '20050101'.
d_date2 = '20000104'.
* This function calculates the diference between date 1 and date 2
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
DATE1 = d_date1
DATE2 = d_date2
OUTPUT_FORMAT = '05'
IMPORTING
YEARS = d_yrs
MONTHS = d_months
DAYS = d_days
EXCEPTIONS
INVALID_DATES_SPECIFIED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write:/ 'Years = ', d_yrs, 'Months = ', d_months, 'Days = ', d_days.
The output of the the above program is as follows.
Years = 4.0000 Months = 11.0000 Days = 29
Tuesday, April 29, 2008
SAP ABAP Upload File with Path Selector Dialog Box
SAP ABAP provides a function modules to upload and download files. It also has a function module to call windows dialog box to select the path. We will examine the following function modules.
GUI_UPLOAD
EXAMPLE
Data: d_filename like IBIPPARMS-PATH,
d_file type string.
data : begin of itab occurs 0,
values(1000) type c,
end of itab.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = d_filename.
d_file = d_filename.
EXPORTING
FILENAME = d_file
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = itab
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Write:/ ITAB.
endloop.
The output of the above program would be as follows.
Filed1,Filed2,Field3,Filed4,Field5,Filed6
Monday, April 28, 2008
SAP ABAP Data Dictionary Tables
SAP ABAP Data Dictionary Tables
Find below a list of SAP ABAP Data Dictionary Tables.
Table Name | Short text |
DD01L | Domains |
DD01T | R/3 DD: domain texts |
DD02ALL | Table Parameters for ALLBASE |
DD02DB2 | DB2/390: Table Parameters |
DD02DB6 | Table Parameters for DB2 Version 2 |
DD02INF | Table Parameters for INFORMIX, Version 6 |
DD02L | SAP tables |
DD02MSS | Table Parameters for Microsoft SQL Server |
DD02ORA | Table parameters for ORACLE, version 6 |
DD02SYB | Storage Parameters for Tables in SYBASE |
DD02T | R/3 DD: SAP table texts |
DD03L | Table Fields |
DD03T | DD: Texts for fields (language dependent) |
DD04L | Data elements |
DD04T | R/3 DD: Data element texts |
DD05S | Foreign key fields |
DD06L | Pool/cluster structures |
DD06T | R/3 DD: texts on SQL tables |
DD07L | R/3 DD: values for the domains |
DD07T | DD: Texts for Domain Fixed Values (Language-Dependent) |
DD08L | R/3 DD: relationship definitions |
DD08T | Texts on the relationship definitions |
DD09C | ABAP/4: Sytem-dependent attributes of tech. settings |
DD09L | DD: Technical settings of tables |
DD10L | Lock table for DD activation |
DD12DB2 | DB2/390: Index Parameters |
DD12DB6 | Index Parameters for DB2 Universal Database Version 2 |
DD12INF | Index parameter for INFORMIX |
DD12L | R/3 S_SECINDEX: secondary indexes, header; |
DD12MSS | Index Parameters for MS SQL Server |
DD12ORA | Index Parameters for ORACLE |
DD12SYB | Index Parameters for SYBASE System_10 |
DD12T | Text Table for DD12L (Short Descriptions of Sec. Indexes) |
DD14S | R/3 DD: components of SAP objects |
DD15L | R/3 DD: SAP objects |
DD15T | R/3 DD: texts on SAP objects |
DD16S | R/3 DD: SQL table fields |
DD17S | R/3 S_SECINDEX: secondary indexes, fields |
DD20L | Matchcode objects |
DD20T | AS400-T_MCOBJECT: MC Object Texts |
DD21S | S-MCIDTABLE: Tables for a MC ID |
DD23L | Matchcode ID |
DD23T | AS400_L-MCID: Matchcode ID Texts |
DD24S | Fields of a matchcode ID |
DD25L | Aggregate Header (Views, MC Objects, Lock Objects) |
DD25T | Short Texts for Views and Lock Objects |
DD26S | Base tables and foreign key relationships for a view |
DD27S | Fields in an Aggregate (View, MC Object, Lock Object) |
DD28S | Lines of a selection condition |
DD29L | Selection Condition for Views and MC IDs |
DD29T | AS400_L-SELCOND: Selection Condition Texts |
DD30L | Search helps |
DD30T | Search help texts |
DD31S | Assignment of search helps to collective search helps |
DD32S | Search Help Parameter |
DD33S | Assignment of search help fields |
DD35L | Search help attachments to structures: Headers |
DD36S | Parameter-field assignments for search help attachment |
DD40L | Table types (internal tables defined in DD) |
DD40T | Text on table types |
DD42S | Key fields for table types (internal tab. defined in DD) |
DD90L | Header Information for External Index |
DD90T | R/3-DD: Text for External Index |
DD91S | DocID Key Definition of External Index |
DD92S | Mapping of R/3 Data on External Index |
DD93S | Attribute of an External Index |
DD94S | Languages of an Index Category |
DD96S | Synchronization Tables |
DD97S | Statements for Trigger and Stored Procedures |
DDACL | Exclusion times for ABAP/4 Dictionary actions |
DDALIAS | DD: Second name for accessing tables |
DDART | DD: Data Class in Technical Settings |
DDBUF | DD: For transferring the new buffering parameters |
DDCDIM | DD: Conversion, number of table lines |
DDCNVEXIT | DD: External conversion methods |
DDCNVSTAT | DD: Statistical Data for Conversion |
DDCNVTABL | DD: Contains incr. conv. tables depend. on release/component |
DDCNVTIMES | DD: Exclusion times for conversion |
DDCNVUSR | DD: Exception table of converter |
DDCPRO | DD: Conversion projects |
DDCPROT | DD: Text on conversion projects |
DDCPROTAB | DD: Table for conversion projects |
DDCQUEUE | DD: Queue for CNV Operations |
DDCSTA | DD: Conversion, number of table lines |
DDCSTAT | DD: Statistics table for conversions |
DDDTRENUPG | DD: Table for Renaming Data Elements During Upgrade |
DDF4PSINDX | Contains Information for Personalizing the F4 Help |
DDFTX | Run-time object with Screen Painter texts |
DDFTX* | |
DDFTX2 | |
DDFTX3 | |
DDFTX4 | |
DDFTX5 | |
DDFTX6 | |
DDFTX7 | |
DDFTX8 | |
DDFTX9 | |
DDICNVCTRL | Control String for Transaction ICNV |
DDICNVDAYS | DD: Days of Week |
DDICNVDIST | Distribution of data records of base tables |
DDICNVLST | Contains information on converter exits |
DDLBBUFTST | Test: Recognize Access to Buffered Tables |
DDLOADD | R3load-data table for migration |
DDLOADH | R3load-header table for migration |
DDPAMSCTRL | DD: Controls Parallel Handling during Mass Activation |
DDPART | DD: Partitioned form of TBATG |
DDPATH | DD: Definition of access paths |
DDPRH | R/3 DD: Log header |
DDPROF | DD: Settings for DDIC programs |
DDPRS | R/3 DD: log lines |
DDPRTUVAR | User settings for printing DD objects |
DDSERVPERF | DD: Performance Key Figures of Server for Par. Execution |
DDSHDEFSH | Default value - search help per user and collective s.h. |
DDSHENTITY | Table of data elements which need the value table help |
DDSHHVALUE | Historic Help Values |
DDSHLPVERS | Current Version of Search Help Activator |
DDSHPVALUE | Personal Help Values |
DDSPAR | Storage clause for tables and indexes |
DDSPAR1 | Storage clause for tables and indexes |
DDSPAR2 | Storage clause for tables and indexes |
DDSTATHIST | DD: Statistical Data for Conversion |
DDSTORAGE | Storage clause for tables and indexes |
DDSTORAGE1 | Storage clause for tables and indexes |
DDSTORAGE2 | Storage clause for tables and indexes |
DDSYN | Parameters for Buffer Synchronization |
DDTYPES | Table of all Dictionary types and classes |
DDTYPET | ABAP/4 Dictionary: Texts for type groups |
DDVE1 | Value Table for Domain DDVERINT4 |
DDVEPR | Check Table with Two Key Fields |
DDXTF | Nametab field structure for delayed writing |
DDXTT | Nametab header structure for delayed writing |
DDYTF | Substitution Nametab (shadow-shadow-nametab for DDXTF) |
DDYTT | Substitution Nametab (shadow-shadow-nametab for DDXTT) |
SAP ABAP COMPUTE ADD COLLECT and APPEND
SAP ABAP COMPUTE ADD COLLECT and APPEND
COMPUTE The COMPUTE statement is used to assign the result of the mathematical statement to a variable. The use of COMPUTE statement is optional. Please examine the following program.
d_num1 type i,
d_num2 type i.
COMPUTE d_result = d_num1 + d_num2.
is the same as
Note: If you want to add 2 numbers then it can also be done as follows in SAP ABAP.
COLLECT To Sum up the entries in the internal table you can use the COLLECT statement. The syntax is as shown below.
Please note that when using COLLECT you should ensure that all the fields that are not a part of the table key should be numeric. This means that fields that are not part of the table key should be either f,i or p.
Example
key(5) TYPE c,
num1(2) TYPE n,
num2 TYPE i,
END OF d_collect.
The result is as follows.
After first collect
First 20 30 >>>>> First 20 30 After Second Collect
First 20 15 >>>>> First 20 45 After Third Collect
Second 20 15 >>>>> First 20 45 Second 20 15
Please make a not that the first and the third COLLECT statements act as insertion statements and they just append the row to the table.
APPEND
The APPEND statement will just insert lines in the internal table. See the example given below.
Example:
key(5) TYPE c,
num1(2) TYPE n,
num2 TYPE i,
END OF d_append.
After first APPEND
First 20 30 >>>>> First 20 30 After Second APPEND
First 20 15 >>>>> First 20 30 First 20 15 After Third Collect
Second 20 15 >>>>> First 20 30 First 20 15 Second 20 15
Sunday, April 27, 2008
SAP ABAP Program Types
We will examine the different types of programs in ABAP. Please find below a list of program types.
Type 1
Type M
Type F
Type K
Type J
Type S
Type I
Type 1 Programs in SAP ABAP
These are controlled by the runtime environment. In these types of programs user action defines further processing. Type 1 programs are called as Executable programs as they can be executed by typing the name of the program. In these types of programs there is no need for the programmer to define his own screen. For defining and designing your own screen please refer to Module Pool Programming. Most of the times a Type 1 program is used for reporting, here the data is fetched from the database using queries, and the data is processed and finally displayed on the screen. Basically a report is an executable program which can be run using it program name, or a transaction. Reports or executable programs (Type 1 Programs) can also be run using a SUBMIT statement.
Type M Programs in SAP ABAP
Type M programs are used for Module Pool Programming. These types of programs are controlled by screen flow logic, these programs start with a Transaction Code. The programmer has to define his own screens and the screen flow logic. In these type of programs the programmer creates a series of screens and controlled is passed in between them using the logic. These types of programs are very useful for designing screens for external systems for example custom screens can be designed for Radios Frequency Devices (RFID), complex SAP transactions can be simplified by using Module Pool Programming if the data input fields is less for a particular transaction. For example if only a few fields need to be inputted for a purchase order or a Sales order from regional offices then a custom screen can be created for such users.
TYPE F Programs in SAP ABAP
Type F programs are basically containers for Function Modules, these types of programs cannot be started using a transaction code or a program name. These can be called from other executable programs or Module Pool programs by inserting the code of the Function Module. Type F programs are basically function groups. A function group can have several Function Modules. Function Modules and Function groups can be created using transaction code SE37 or SE80.
TYPE K Programs in SAP ABAP
Type K programs are basically containers for global classes in ABAP Objects. These type of programs cannot be started by using a program name or using a Transaction Code. These types of programs are created using a Class Builder.
Type J Programs in SAP ABAP
These are basically containers for Global Interfaces in ABAP Objects. These programs cannot be run using a program name or a transaction code.
Type S Programs in SAP ABAP
These types of programs are basically containers for subroutines., these subroutines can be called from other ABAP programs externally. They are called as subroutine Pools. These types of programs cannot be run using a program name or a transaction code.
Type I Programs in SAP ABAP
These type of programs are called as Includes. They are used to make code more simpler by breaking it into smaller units. This is also a modularization technique. Basically you can use small pieces of code that can be used in multiple programs into includes. These types of programs cannot be run using the program name or a transaction code.
Friday, April 25, 2008
Important Transaction Codes For SAP IDOCs
SAP R/3 can be interfaced with other systems using various techniques. EDI is one of them. For interfacing SAP R/3 with its partners (Vendors/Customers) the best way is using EDI. Please find below some of the important transaction codes used for IDOCs (intermediate document).
IDOC Monitoring
Transaction Code | Description |
WE02 | IDOC Display |
WE05 | IDOC List |
WE07 | IDOC Statistics |
WE20 | Maintain Partner Profiles Manually |
BD82 | Generate Partner Profiles Automatically |
WE21 | Port Definitions |
SM59 | RFC Destination |
BD64 | Maintain Customer Model |
Message Control
Transaction Code | Description |
NACE | Maintain condition records for various applications |
VOK2 | Message Control components for Sales and Distribution |
VOK3 | Message Control components for Purchasing |
VOFM | Maintain requirements for Message Control |
V/86 | Field Catalog for condition Tables |
Important Menus
Transaction Code | Description |
WEDI | Main Menu for EDI related activities |
BALE | Main menu for ALE related activities |
SWLD | Main menu for workflow related activities |
SALE | ALE Configuration |
NACE | Message Control Configuration |
IDOCs
Transaction Code | Description |
WE31 | Segment Editor |
WE30 | IDoc Editor to create and extend IDoc type |
BD53 | Reduce IDoc Types for Master Data |
WE60 | IDoc documentation (IDoc structure and segment definition) |
WE61 | IDoc documentation (Control Record, data record, and Status Record) |
WE19 | Test Tool fro IDOCs |
WE12 | Convert an Outbound IDOC to an Inbound IDOC |
WE16 | Process an incoming IDOC |
WE17 | Process an incoming status file |
BD87 | Manual processing of IDOCS |
Thursday, April 24, 2008
Some important Function Modules for Date Conversion in SAP ABAP
The function module DATE_TO_PERIOD_CONVERT can be used to get the current period by passing the current date. This function module need the following import parameters
I_MONMIT First day of the second half of the month
PERIV Fiscal year variant
I_MONMIT in this field you can pass '00'
PERIV in this filed you can pass the FISCAL YEAR for a list of Fiscal years run transaction OB37
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
I_DATE = SY-DATUM
I_MONMIT = 00
I_PERIV = 'K4'
IMPORTING
E_BUPER = D_PERIOD
E_GJAHR = D_YEAR
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4.
PERIOD_DAY_DETERMINE
The above mentioned function module will determine the first of the the Fiscal Year. If you want to know the first day of the Fiscal year for a Company, then you can use this function module. While trying this function module for company codes of different countries.
Data: d_gjahr like BKPF-GJAHR, "Fiscal year
d_monat like BKPF-MONAT, "Posting period
d_periv like T001-PERIV, "Period version
d_fday like BKPF-BUDAT, "First period day
d_lday like BKPF-BUDAT, "Last period day
d_SPERIOD like BKPF-BSTAT. "Special period indicator
Move: '2008' to d_gjahr,
'01' to d_monat,
'K4' to d_periv.
CALL FUNCTION 'PERIOD_DAY_DETERMINE'
EXPORTING
I_GJAHR = d_gjahr
I_MONAT = d_monat
I_PERIV = d_periv
IMPORTING
E_FDAY = d_fday
E_LDAY = d_lday
E_SPERIOD = d_SPERIOD
EXCEPTIONS
ERROR_PERIOD = 1
ERROR_PERIOD_VERSION = 2
FIRSTDAY_NOT_DEFINED = 3
PERIOD_NOT_DEFINED = 4
YEAR_INVALID = 5
OTHERS = 6
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Write:/ 'First Day Of the Fiscal Year =',d_fday.
First Day Of the Fiscal Year = 01/01/2008
Last Day Of the first period Fiscal Year = 01/31/2008
First Day Of the Fiscal Year = 04/01/2008
Last Day Of the first period Fiscal Year = 04/30/2008
ABAP TIPS
|
Always use Pretty Printer and Extended Program Check before releasing the code. Do not leave unused code in the program. Comment the code thoroughly. Align the comments and the Code. Follow the SAP Standards and SAP Best Practices guidelines. It’s a good practice to take a dump of the code on your local drive. |