ABAP Trainer's Document
ABAP Trainer's Document
CONCEPTS
The Successful Interview
This Document provides an overview of the core ABAP concepts to brush up in a quick time to
get through any Technical Interview for Profiles with 5 to 9 Years of experience.
9/7/2017
INDEX
1. Custom Reports and Transactions
1.1 Report Events……………………………………………………………………………………………………………...03
1.2 ALV (using Factory Methods)……………….……………………………………………………………………….03
2. Procedural Programming and Modularization
2.1 Function Module………………………………………………………………………………………………………….09
2.2 Subroutines………………………………………………………………………………………………………………….10
3. Object Oriented Programming
3.1 Class……………………………………………………………………………………………………………………………..11
3.2 Interface…………………………………………..………………………………………………………………………….11
3.3 Abstract Class……………………………………………………………………………………………………………….12
3.4 Inheritance…………………………………………………………………………………………………………………..12
4. Module Pool Programming
4.1 Basic Control Commands………………………………………………………………………………………………13
4.2 Events..…………………………………………………………………………………………………………………………13
4.3 Screen Navigation…………………….……………………................................................................13
4.4 Controls…………………………………….…...................................................................................13
5. Interface Techniques
5.1 IDOCS……………………………………………………………………………………………………………………………17
5.2 ABAP Proxies………………………………………………………………………………………………………………..37
6. Data Migration
6.1 BDC………………………………………………………………………………………………………………………………43
6.2 LSMW…………………………………………………………………………………………………………………………..45
6.3 BAPI……………………………………………………………………………………………………………………………..46
6.4 BW Extractor Function Modules........…………………………………………………………………………..56
7. Forms
7.1 SAP Scripts……………………………………………………………………………………………………………………70
7.2 SMARTFORMS……………………………………….……………………………………………………………………..72
8. Enhancements
8.1 User Exit……………………………………………………………………………………………………………………….78
8.2 BADI……………………………………………………………………………………………………………………………..78
8.3 BTE……………………………………………………………………………………………………………………………….80
8.4 Implicit and Explicit Enhancements……….……………………………………………………………………..82
8.5 VOFM Routines.……………………………………………………………………………………………………………82
9. Performance Tuning
9.1 Performance Analysis Tools……………..…………………………………………………………………………..83
9.2 Code Fine Tuning Techniques………..……….…………………………………………………………………….87
10. Upgrade
10.1 Sequence of Activities………………………………………………………………………………………………….89
10.2 ABAP Activities……………………………………………………………………………………………………………..89
1
10.3 Procedure to fix impacted objects in SPDD & SPAU………………………………………………………89
11. Debugging
11.1 Break Point…………………………………………………………………………………………………………………..91
11.2 Watch Point………………………………………………………………………………………………………………….92
11.3 Update Debugging……………………………………………………………………………………………………….92
2
1. CUSTOM REPORTS & TRANSACTIONS
1.1 Report Events:
3
go_column TYPE REF TO cl_salv_column,
go_layout TYPE REF TO cl_salv_layout,
go_sorts TYPE REF TO cl_salv_sorts,
go_sort TYPE REF TO cl_salv_sort,
go_aggregations TYPE REF TO cl_salv_aggregations,
gw_layout_key TYPE salv_s_layout_key.
* Generate an instance of the ALV table object
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = go_table
CHANGING
t_table = gt_output.
* Subtotal of all Accrued, Paid and Remaining Amounts for each Vendor
go_sorts = go_table->get_sorts( ).
* Sort the ALV by Vendor Number
go_sort = go_sorts->add_sort( columnname = 'LIFNR' ).
* Inform the ALV that subtotal is required
go_sort->set_subtotal( value = abap_true ).
* Set Total for Accrued, Paid and Remaining Amounts
go_aggregations = go_table->get_aggregations( ).
go_aggregations->add_aggregation( columnname = 'ACCRUED' ).
go_aggregations->add_aggregation( columnname = 'PAID' ).
go_aggregations->add_aggregation( columnname = 'REMAIN' ).
4
Button in ALV Tool Bar:
1. Copy standard PF-Status to custom PF-Status via SE41.
2. In the application tool bar, provisions will be there for new buttons. Name the provisions, assign
Function Code and Icon. Save the PF-Status.
3. Call the PF-Status in the program as below.
l_o_table->set_screen_status( pfstatus = 'ZPP_DOL_SALV_STATUS'
report = sy-repid
set_functions = l_o_table>c_functions_all ).
Events in ALV:
1. Create New include for creating ALV event handler classes.
INCLUDE z365n_pp_dol_seq_part_vldt_alv. "Include to handle ALV Events
2. Select from the list of events in class CL_SALV_EVENTS.
PUBLIC SECTION.
METHODS: on_user_command FOR EVENT added_function OF cl_salv_events
IMPORTING e_salv_function.
5
CLASS cl_handle_events IMPLEMENTATION.
METHOD on_user_command.
CASE e_salv_function.
WHEN 'SUMMARY'.
* declaration of objects for alv factory methods
DATA: l_o_table TYPE REF TO cl_salv_table,
l_o_functions TYPE REF TO cl_salv_functions,
l_o_columns TYPE REF TO cl_salv_columns_table,
l_o_column TYPE REF TO cl_salv_column,
l_o_layout TYPE REF TO cl_salv_layout,
l_o_display TYPE REF TO cl_salv_display_settings,
l_o_events TYPE REF TO cl_salv_events_table,
l_o_events_handler TYPE REF TO cl_handle_events,
l_w_layout_key TYPE salv_s_layout_key,
l_f_salv_exception TYPE REF TO cx_salv_msg,
l_f_message TYPE string.
REFRESH g_t_summary.
CLEAR l_f_mnglg_total.
l_t_output = g_t_output.
SORT l_t_output BY idnrk.
6
MESSAGE l_f_message TYPE l_c_info DISPLAY LIKE l_c_error.
ENDTRY.
WHEN 'PRINT'.
* Local Variables Declaration
DATA: l_o_selections TYPE REF TO cl_salv_selections,
Lt_rows TYPE salv_t_row,
L_w_rows LIKE LINE OF l_t_rows,
l_f_fname TYPE rs38l_fnam,
l_f_serno TYPE int4,
l_f_oldaf TYPE aufnr,
l_f_oldcm TYPE z365_commodity.
* Local Constants Declaration
CONSTANTS: l_c_fname TYPE tdsfname VALUE 'Z365SF_PP_DOL_SEQ_PRT_VALIDATE'.
l_o_selections = gr_table->get_selections( ).
7
L_t_rows = lr_selections->get_selected_rows( ).
REFRESH g_t_print.
LOOP AT l_t_rows INTO l_w_rows.
READ TABLE g_t_output INTO g_w_output INDEX l_w_rows.
g_w_print-serial_no = g_w_output-ser_no.
g_w_print-commodity = g_w_output-commodity.
g_w_print-aufnr = g_w_output-aufnr.
g_w_print-variant = g_w_output-plnbez.
g_w_print-variant_desc = g_w_output-plnmtx.
g_w_print-part_number = g_w_output-idnrk.
g_w_print-part_desc = g_w_output-idnmtx.
g_w_print-revlv = g_w_output-revlv.
g_w_print-labst = g_w_output-labst.
l_f_oldaf = g_w_output-aufnr.
l_f_oldcm = g_w_output-commodity.
APPEND g_w_print TO g_t_print.
CLEAR: g_w_print, g_w_output.
ENDLOOP.
* Sorting Form Output by Commodity to introduce page break in smart form based on commodity
SORT g_t_print BY commodity serial_no.
ENDMETHOD. "on_user_command
ENDCLASS. "cl_handle_events IMPLEMENTATION
8
2. PROCEDURAL PROGRAMMING AND MODULARIZATION
UPDATE TASK:
The update work processes are responsible for updating the database. When an ABAP program reaches a
COMMIT WORK statement, any function modules from CALL FUNCTION... IN UPDATE TASK statements
are released for processing in an update work process.
On execution of a Program that contains UPDATE TASK, it will get registered in VBLOG table on priority
basis. It will not get executed until COMMIT WORK statement is reached. Debugging can be done via
Update Debugging in settings.
BACKGROUND TASK:
Running a Function module in back-ground task means assigning the module to separate LUW. It can be
run in parallel and is an asynchronous process.
9
To debug our background task we need to switch on ‘Do not process’ in debugging mode as shown below.
On execution of Program containing FM with BACKGROUND TASK, FM will get execute in background task
and it will be assigned to a separate LUW. We can see this LUW registered in t-code SM58 and execute,
debug and delete manually. If the checkbox in above screen shot is checked, LUW will not get registered
in SM58 and we cannot debug.
If checkbox ‘In background task’ is checked, LUW gets registered in SM58. Now we can go to SM58, select
the record and Debug the LUW.
2.2 SUBROUTINES
PERFORM <Subroutine Name> USING <Parameters>
CHANGING <Parameters>
TABLES <Parameters>
Note: TABLES parameter is now obsolete and internal tables can be passed via USING / CHANGING itself.
10
3. OBJECT ORIENTED PROGRAMMING
3.1 CLASS
GLOBAL CLASS
Transaction – SE24
These Classes support reusability and can be used in any custom program created.
LOCAL CLASS
PUBLIC SECTION.
METHODS: on_user_command FOR EVENT added_function OF cl_salv_events
IMPORTING e_salv_function.
METHOD on_user_command.
CASE e_salv_function.
WHEN 'SUMMARY'.
* declaration of objects for alv factory methods
DATA: l_o_table TYPE REF TO cl_salv_table,
l_o_functions TYPE REF TO cl_salv_functions,
l_o_columns TYPE REF TO cl_salv_columns_table,
l_o_column TYPE REF TO cl_salv_column,
l_o_layout TYPE REF TO cl_salv_layout,
l_o_display TYPE REF TO cl_salv_display_settings,
l_o_events TYPE REF TO cl_salv_events_table,
l_o_events_handler TYPE REF TO cl_handle_events,
l_w_layout_key TYPE salv_s_layout_key,
l_f_salv_exception TYPE REF TO cx_salv_msg,
l_f_message TYPE string.
ENDMETHOD. "on_user_command
3.2 INTERFACE
Interfaces have only the definition for the functionalities supported via Methods. However, none of the
methods will hold implementation.
Transaction – SE24
Interfaces should begin with ZIF_ and Classes should begin with ZCL_. Based on the name provided at the
time of creation, SAP will automatically determine if it’s an interface or class.
11
3.3 ABSTRACT CLASS
Abstract Class is a class which contains at least one abstract method (method with no implementation).
The class which inherits the abstract class will contain implementation for the abstract method. If the
class inheriting the abstract class doesn’t contain implementation for the abstract method, then this will
also be termed as an abstract class. In addition to abstract methods, an abstract class can contain also
normal methods with implementation unlike interfaces.
3.4 INHERITANCE
To inherit from another class, click on the button highlighted and provide the super class name / Interface
/ Abstract Class.
12
4. MODULE POOL PROGRAMMING
4.1 BASIC CONTROL COMMANDS
CHAIN-ENDCHAIN
Set of fields to be validated together.
On Error, All fields within CHAIN-ENDCHAIN are input enabled and all other fields are disabled.
MODULE inside CHAIN-ENDCHAIN is used to validate the field immediately after input. When the
MODULE throws Error or Warning, all fields inside CHAIN-ENDCHAIN are open for input.
AT-EXIT COMMAND
Used to exit from the screen even if a field in the screen throws error.
The Button used to exit should have Function Type ‘E’.
4.2 EVENTS
PROCESS BEFORE OUTPUT (PBO) - The event is triggered during Screen Load.
PROCESS AFTER INPUT (PAI) - The event is triggered on any user action on screen.
SET SCREEN <XXXX> - Used to set the next screen number overriding the one given in the screen
properties as shown in the screen properties below.
LEAVE SCREEN – Leaves to the screen indicated in SET SCREEN or under Next Screen in Screen Attributes.
It ends the processing in current screen.
LEAVE TO SCREEN <XXXX> - It is equal to combining SET SCREEN and LEAVE SCREEN.
4.4 CONTROLS
TABLE CONTROL
13
Populating Table Control – For e.g. G_T_TABL is the final internal table.
Create a screen 100 (screen on which Tab Strip is going to be placed) and Sub-Screens 110 & 130(which
are going to be placed in the screen areas of the tabs in Tab Strip control).
Go to Layout of main screen and create a Tab Strip control (for e.g. name it as tabstrip) with tabs.
Assign Sub-screens to respective Tabs and Function Codes (to identify which tab the user selects) to tabs.
Go to the Sub-screens and create necessary fields.
14
OK_CODE LIKE SY-UCOMM.
CONTROLS TABSTRIP TYPE TABSTRIP.
CALL SCREEN 100.
CALL SCREEN 110.
CALL SCREEN 130.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'BACK'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'TAB1'.
TABSTRIP-ACTIVETAB = 'TAB1'.
WHEN 'TAB2'.
TABSTRIP-ACTIVETAB = 'TAB2'.
RESULT = NUMBER1 + NUMBER2.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0130 INPUT
*&---------------------------------------------------------------------*
text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0130 INPUT.
RESULT = NUMBER1 + NUMBER2.
ENDMODULE. " USER_COMMAND_0130 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0110 INPUT
*&---------------------------------------------------------------------*
text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0110 INPUT.
N1 = NUMBER1.
N2 = NUMBER2.
ENDMODULE. " USER_COMMAND_0110 INPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0110 OUTPUT
*&---------------------------------------------------------------------*
text
*----------------------------------------------------------------------*
MODULE STATUS_0110 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
15
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0110 OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0130 OUTPUT
*&---------------------------------------------------------------------*
text
*----------------------------------------------------------------------*
MODULE STATUS_0130 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
RESULT = NUMBER1 + NUMBER2.
ENDMODULE. " STATUS_0130 OUTPUT
16
5. INTERFACE TECHNIQUES
5.1 IDOCS
EDI (Electronic Document interchange) - EDI is the electronic exchange of business documents between
the computer systems of business partners, using a standard format over a communication network.
EDI is also called paperless exchange.
Advantages:
Reduced Data entry errors
Reduced processing time
Availability of data in electronic form
Reduced paperwork
Reduced Cost
Reduced inventories and better planning
Standard means of communications
Better business process
Outbound Process:
Application document is created.
IDOC is generated
IDOC is transferred from SAP to Operating system layer
IDOC is converted into EDI standards
Edi document is transmitted to the business partner
The Edi Subsystem report status to SAP
Inbound Process:
1.EDI transmission received
2.EDI document is converted into an IDOC
3.IDOC is transferred to the SAP layer
4.The application document is created
5.The application document can be viewed.
IDOC: IDOC is a container that can be used to exchange data between any two processes.
Each IDOC is assigned a unique number for tracking and future reference.
IDOC consists of several segments, and segments contain several fields.
17
In IDOCs the following terms are to be known.
PORT:
Port is used in the outbound process to determine the name of the EDI subsystem program, the directory
path where the IDOC file will be created at the operating system level, the IDOC file names and the RFC
destinations.
RFC Destination:
Used to define the characteristics of communication links to a remote system on which a functions needs
to be executed.
Partner Profile:
Partner profile specified the various components used in an outbound process (Partner number, IDOC
type, message type, Port, Process code), the mode in which it communicates with the subsystem (batch or
immediate) and the person to be notified in case of errors.
Message Control:
Used in pricing, account determination, material determination, and output determination. The message
control component enables you to encapsulate business rules with out having to write ABAP programs.
In Destination System:
Creating FM SE37
Assign FM to Logical Message WE57
Define I/P method for Inbound FM BD51
Create Process Code WE42
Generate Partner Profile BD64
18
In Client 900 I have created a customized table and inserted some records.
In Client 800 I have created only table.
Define Logical Systems. Specify the Logical System name and description.
Note: Logical System Naming convention is <SID>CLNT<NNN>
19
Click on New Entries
In dialog box you can select either Generate port name or own port name. If you select Generate Port
name system will generate automatically. Here I selected Own port name. Click on continue.
20
Specify the description and RFC destination name and save.
Repeat the same above process in other client. By using opposite client instead of 900 specify 800.
21
Insert some records in table.
22
Creating Basic IDOC Type:
Go to TCODE WE30
Specify a name to your IDOC and click on create button.
In next dialog box select create new option and specify the description of IDOC and click on continue.
In dialog box specify the segment name which you created, check mandatory check box (If this segment is
mandatory to hold data) and save.
Minimum Number – Minimum number of times the segment will come in the IDOC.
Maximum Number – Maximum number of times the segment will repeat in the IDOC.
For e.g. If the segment is going to hold line items of a Sales Order, then it would repeat multiple times (we
do not know the number of line items) and hence we would set Maximum Number to 999.
23
Go to menu EDIT ->Click Set Release
Specify description of model view and technical name in dialog box and press continue.
Select your model view and click on Edit menu -> Add Message type
24
Click on Environment Menu -> Generate Partner profile
25
Come back to BD64 and Click on Edit Menu -> Model View -> Distribute.
In displayed dialog box select the partner system and click continue
26
To check partner profile Go to TCODE WE20. In displayed screen select the partner system in left
side tree under Partner Type LS.
Write a Report Program in SE38 to create IDOC control records and transfer it to destination
partner system.
The following is the program to generate the IDOC control records and process it.
*&---------------------------------------------------------------------*
*& Report ZSHAN_IDOC_STUD
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSHAN_IDOC_STUD.
TABLES: ZSTUDENTS.
DATA : S_CTRL_REC LIKE EDIDC, "Idoc Control Record
S_ZSHSTUSEG LIKE ZSHSTUSEG. "CUSTOMER Header Data
DATA : T_ZSTUDENTS LIKE ZSTUDENTS OCCURS 0 WITH HEADER LINE.
DATA : T_EDIDD LIKE EDIDD OCCURS 0 WITH HEADER LINE. "Data Records
DATA : T_COMM_IDOC LIKE EDIDC OCCURS 0 WITH HEADER LINE. "Generated Communication IDOc
CONSTANTS :C_ZSHSTUSEG LIKE EDIDD-SEGNAM VALUE 'ZSHSTUSEG'.
CONSTANTS: C_IDOCTP LIKE EDIDC-IDOCTP VALUE 'ZSHSTUDIDOCS'.
*** Selection Screen
SELECT-OPTIONS : S_STUID FOR ZSTUDENTS-ZSTUID OBLIGATORY.
PARAMETERS : C_MESTYP LIKE EDIDC-MESTYP DEFAULT 'ZSHSTUDMT', "Message Type
C_RCVPRT LIKE EDIDC-RCVPRT DEFAULT 'LS', "Partner type of receiver
C_LOGSYS LIKE EDIDC-RCVPRN DEFAULT 'IT3CLNT800',
C_RCVPOR LIKE EDIDC-RCVPOR DEFAULT 'PORTSH800',
C_SNDPRN LIKE EDIDC-SNDPRN DEFAULT 'IT3CLNT900',
C_SNDPRT LIKE EDIDC-SNDPRT DEFAULT 'LS'. "Destination System
***START-OF-SELECTION
START-OF-SELECTION.
PERFORM GENERATE_DATA_RECORDS.
27
PERFORM GENERATE_CONTROL_RECORD.
PERFORM SEND_IDOC.
*&---------------------------------------------------------------------*
*& Form GENERATE_DATA_RECORDS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GENERATE_DATA_RECORDS .
SELECT * FROM ZSTUDENTS
INTO TABLE T_ZSTUDENTS
WHERE ZSTUID IN S_STUID.
IF SY-SUBRC NE 0.
MESSAGE E398(00) WITH 'No Students Found'.
ENDIF.
PERFORM ARRANGE_DATA_RECORDS.
ENDFORM. " GENERATE_DATA_RECORDS
*&---------------------------------------------------------------------*
*& Form GENERATE_CONTROL_RECORD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GENERATE_CONTROL_RECORD .
S_CTRL_REC-RCVPOR = C_RCVPOR. "Receiver Port
S_CTRL_REC-MESTYP = C_MESTYP. "Message type
S_CTRL_REC-IDOCTP = C_IDOCTP. "Basic IDOC type
S_CTRL_REC-RCVPRT = C_RCVPRT. "Partner type of receiver
S_CTRL_REC-RCVPRN = C_LOGSYS. "Partner number of receiver
S_CTRL_REC-SNDPRT = C_SNDPRT. "Sender Partner type
S_CTRL_REC-SNDPRN = C_SNDPRN. "Sender Partner Number
ENDFORM. " GENERATE_CONTROL_RECORD
*&---------------------------------------------------------------------*
*& Form SEND_IDOC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SEND_IDOC .
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
MASTER_IDOC_CONTROL = S_CTRL_REC
* OBJ_TYPE = ''
* CHNUM = ''
TABLES
28
COMMUNICATION_IDOC_CONTROL = T_COMM_IDOC
MASTER_IDOC_DATA = T_EDIDD
EXCEPTIONS
ERROR_IN_IDOC_CONTROL =1
ERROR_WRITING_IDOC_STATUS =2
ERROR_IN_IDOC_DATA =3
SENDING_LOGICAL_SYSTEM_UNKNOWN =4
OTHERS =5
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
COMMIT WORK.
LOOP AT T_COMM_IDOC.
WRITE:/ 'IDoc Generated - ', T_COMM_IDOC-DOCNUM.
ENDLOOP.
ENDIF.
ENDFORM. " SEND_IDOC
*&---------------------------------------------------------------------*
*& Form ARRANGE_DATA_RECORDS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ARRANGE_DATA_RECORDS .
DATA: W_INDEX1 LIKE SY-TABIX,
W_INDEX2 LIKE SY-TABIX.
SORT T_ZSTUDENTS BY ZSTUID.
LOOP AT T_ZSTUDENTS.
S_ZSHSTUSEG-ZSTUID = T_ZSTUDENTS-ZSTUID.
S_ZSHSTUSEG-ZSNAME = T_ZSTUDENTS-ZSNAME.
T_EDIDD-SEGNAM = C_ZSHSTUSEG.
T_EDIDD-SDATA = S_ZSHSTUSEG.
APPEND T_EDIDD.
CLEAR T_EDIDD.
ENDLOOP.
ENDFORM. " ARRANGE_DATA_RECORDS
Now execute the program, and specify the range of records to transfer
29
Go to TCODE WE02 to check the generated IDOC control records.
Create a Function Module. This function module will contain the program lines required to create
the necessary transactional data as per Business Requirements.
30
Specify the below Export parameters.
Write program lines to pick data from the IDOC Data Records and update Database Table.
FUNCTION ZSHAN_IDOC_ZSHSTUDMT.
*"--------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
*" REFERENCE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
*" EXPORTING
*" REFERENCE(WORKFLOW_RESULT) LIKE BDWF_PARAM-RESULT
*" REFERENCE(APPLICATION_VARIABLE) LIKE BDWF_PARAM-APPL_VAR
*" REFERENCE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK
*" REFERENCE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS
*" TABLES
*" IDOC_CONTRL STRUCTURE EDIDC
*" IDOC_DATA STRUCTURE EDIDD
*" IDOC_STATUS STRUCTURE BDIDOCSTAT
*" RETURN_VARIABLES STRUCTURE BDWFRETVAR
*" SERIALIZATION_INFO STRUCTURE BDI_SER
31
*" EXCEPTIONS
*" WRONG_FUNCTION_CALLED
*"--------------------------------------------------------------------
* Include File containing ALE constants
INCLUDE MBDCONWF.
TABLES: ZSTUDENTS.
DATA: W_ZSHSTUSEG LIKE ZSHSTUSEG.
DATA: T_ZSTUDENTS LIKE ZSTUDENTS OCCURS 0 WITH HEADER LINE.
WORKFLOW_RESULT = C_WF_RESULT_OK.
LOOP AT IDOC_CONTRL.
IF IDOC_CONTRL-MESTYP NE 'ZSHSTUDMT'.
RAISE WRONG_FUNCTION_CALLED.
ENDIF.
* Before reading a new entry, clear application buffer
LOOP AT IDOC_DATA WHERE DOCNUM EQ IDOC_CONTRL-DOCNUM.
W_ZSHSTUSEG = IDOC_DATA-SDATA.
MOVE-CORRESPONDING W_ZSHSTUSEG TO T_ZSTUDENTS.
INSERT INTO ZSTUDENTS VALUES T_ZSTUDENTS.
ENDLOOP.
UPDATE ZSTUDENTS FROM T_ZSTUDENTS.
IF SY-SUBRC EQ 0.
IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
IDOC_STATUS-STATUS = '53'.
IDOC_STATUS-MSGTY = 'I'.
IDOC_STATUS-MSGID = 'YM'.
IDOC_STATUS-MSGNO = '004'.
IDOC_STATUS-MSGV1 = T_ZSTUDENTS-ZSTUID.
APPEND IDOC_STATUS.
CLEAR IDOC_STATUS.
ELSE.
IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
IDOC_STATUS-STATUS = '51'.
IDOC_STATUS-MSGTY = 'E'.
IDOC_STATUS-MSGID = 'YM'.
IDOC_STATUS-MSGNO = '005'.
IDOC_STATUS-MSGV1 = T_ZSTUDENTS-ZSTUID.
APPEND IDOC_STATUS.
CLEAR IDOC_STATUS.
WORKFLOW_RESULT = C_WF_RESULT_ERROR.
RETURN_VARIABLES-WF_PARAM = 'Error_Idocs'.
RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
APPEND RETURN_VARIABLES.
CLEAR RETURN_VARIABLES.
ENDIF.
ENDLOOP.
ENDFUNCTION.
32
Specify created FM name, Function Type, Basic Type (IDOC), Message Type, and Direction and click
on SAVE button.
Go to TCODE BD51, Click on Display / Change button and Add New Entry.
Specify FM name and Input Types as 2. And Click on Save and Back buttons.
In next screen select the FM name and click on SAVE button and Click on BACK button.
33
It will take to you previous screen. Double Click on Logical Message in left side tree.
Select Logical Message and Click on New Entries button
34
Generating the Partner Profile:
Go to TCODE BD64.
Select the Model View which you distributed in client 900.
35
To check the partner profile details. Go to TCODE WE20. Select the partner system name.
36
Debugging:
Inbound IDOC – WE19Select Function Module and Execute.
Outbound IDOC – Break Point at FM MASTER_IDOC_DISTRIBUTE.
PI Settings
Create Data Type.
37
Create Service Interface.
ECC Settings
Inbound Proxy:
atio atio
n n 38
Syst Syst
em) em)
Give Package Name and Prefix: Click on Continue.
After completing the creation process, the below screen will be there.
39
Activate and double click on Provider Class.
Outbound Proxy:
atio atio
n n
Syst Syst
em) em) 40
• For Outbound Proxy, an executable code in ABAP will be written to call that proxy.
• In this Example, we are writing that code in Executable program in SE38.
• First Pick data from Table.
• Fill Proxy Structure & send to Integration System (PI).
Data Declaration –
41
Filling Proxy structure and sending to integration system (PI).
Debugging:
Go to Transaction SXI_MONITOR and download the Inbound XML Payload as an XML file to
the Presentation Server.
Go to Transaction SPROXY, execute the Proxy and upload the XML file.
Place a break-point in the Proxy Class Method.
Now execute and the debugger will get triggered.
42
6. DATA MIGRATION
6.1 BDC:
MODE:
N - Background Mode.
A – Foreground Mode.
E – Display Screen on Error.
P – Branches into debugging once breakpoint is reached.
UPDATE:
A – Asynchronous Update
S – Synchronous Update
L – Local Updates
43
Step4: OPEN JOB
DATA: jobname LIKE tbtco-jobname,
jobnumb LIKE rsjobinfo-jobnumb,
Jobname = wa_session-groupid.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobgroup = 'BATCH-INPUT'
jobname = jobname
sdlstrtdt = sy-datum
sdlstrttm = sy-uzeit
IMPORTING
jobcount = jobnumb
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 99.
44
Step 7: Update Session info
UPDATE apqi SET qstate = 'S'
WHERE destsys = wa_session-destsys
AND destapp = wa_session-destapp
AND datatyp = wa_session-datatyp
AND groupid = wa_session-groupid
AND progid = wa_session-progid
AND formid = wa_session-formid
AND qattrib = wa_session-qattrib
AND qid = wa_session-qid.
COMMIT WORK.
6.2 LSMW
45
Maintaining Field Mapping & Conversion Rules – Mapping the fields in BDC Recording with the Structure
fields created in Step 3. Field Level Code Logic can also be written here.
6.3 BAPI:
BAPI Extensions
It is used to update additional custom fields that are not supported by original BAPI.
Feasibility
Check import parameters if the BAPI has extension structure.
Example
Assume that there is extra information that we want to save to the database while creating a new
purchase order. I.e. Prepared By, Checked By, Approved By.
46
the database table and the table extension are always identical.
47
Extension container
Also, an extension parameter (Extension In) in the BAPI interface is used to pass on the enhancements to
the BAPI in container format. This extension parameter is always based on data structure BAPIPAREX.
Using this parameter BAPI understands the format of the data to be passed.
Here, the STRUCTURE refers to the name of the BAPI table extension though which extra information is
to be sent whereas VALUEPART1 to VALUEPART4 are the values that will be inserted in the additional
table fields along with the table key field. Key field, here, purchase_order_no is the extra information
that needs to be passed to know the line in the database table where the data record needs to be written.
..
Here, ‘3300000180’ is the key field for EKKO table specifying which row to be updated. And “Nikhil Pravin
Parvati” is the extra fields of EKKO specified in BAPI_TE_MEPOHEADER.
48
Source Code
Once the BAPI Extension Table and Extension Container are filled, Execute the BAPI by passing Extension
Container as a table type argument.
Create a RFC Function Module with necessary parameters. Make sure you have a table parameter of type
BAPIRET2 to capture the messages generated within the FM. Write necessary coding based on Business
Requirement inside the FM.
49
Now click on the methods to drop down and see what methods are provided by default. There would be
two methods, showing in red color which comes by default while creating the BAPI.
50
Click or select the method as shown above and go to the path “UtilitiesAPI methodsAdd methods”.
On the screen that follows, provide the function module name and click on the continue icon.
In the ultimate pop-up, click the next step icon. We observe that the information is predefined in the
fields.
This is the next screen where you would just click on the “next” icon.
51
Click on Yes. You can see an information message reading ZBAPIFMT001 inserted.
Now save after you add the method. Select & Double click on the API method.
52
Go to Tab: ABAP Check 'API Function'.
53
Select the Radio button reading “API Function” as already said above.
54
The above shown screen will be displayed. Click on yes.
The message shows, the object type status set to modeled. (Or already modeled)
Go to EditChange Release StatusObject type To Implemented.
55
Similarly, change the status for Object Type component also.
Go to EditChange Release StatusObject type componentTO Modeled.
Now, if you go to BAPI transaction you can find your Custom BAPI.
The BW Extract program (Function module) is called twice. The first time the extractor program is called,
the extraction parameters are retrieved and then the function module is called once again when the
actual data extraction takes place.
This is handled by using a flag 'I_INITFLAG'. This Flag is a part of the FM input Interface and is set during
the first call and reset for all subsequent calls.
The Data extract should be done only when it is called the second time.
IMPORT PARAMETERS
I_DSOURCE - Datasource Name
I_INITFLAG - Initialize flag is for Initialize call up: When the FM is called for the first time, this parameter
is set to 'X', afterwards it is set to ' ' (blank).
I_MAXSIZE - Package size: This parameter contains the no of rows expected for a read call up.
I_REQUNR - Request number
56
TABLES PARAMETERS
I_T_SELECT - Input Selection Criteria
I_T_FIELDS - Output Structure
E_T_DATA - Output Data
STEPS
STEP 1: Create an Extract Structure in SE11 according to your requirement; here we will create a structure
for Shipment Item details for a Delivery with necessary fields.
STEP 2: Go to t code SE80 & copy the function group RSAX & give the name as ZZRSAX for the new
function group & then copy only the function module RSAX_BIW_GET_DATA_SIMPLE as
ZZRSAX_BIW_GET_DATA_SIMPLE as shown below.
57
Now go to the Tables tab for the FM ZZRSAX_BIW_GET_DATA_SIMPLE & change the Associated Type for
the parameter E_T_DATA as ZZVTTPLIKP (Extract Structure that we have created using SE11 in step 1) as
shown below:
FUNCTION ZZRSAX_BIW_GET_DATA_SIMPLE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL
*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL
*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL
*" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF
*" TABLES
*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
*" E_T_DATA STRUCTURE ZZVTTPLIKP OPTIONAL
*" EXCEPTIONS
58
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
*"----------------------------------------------------------------------
* Example: DataSource for table SFLIGHT
* Change the structure from sflight to ZZVTTPLIKP********
TABLES: ZZVTTPLIKP.
* Auxiliary Selection criteria structure
DATA: L_S_SELECT TYPE SRSC_S_SELECT.
* Maximum number of lines for DB table
STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,
* counter
S_COUNTER_DATAPAKID LIKE SY-TABIX,
* cursor
S_CURSOR TYPE CURSOR.
* Create a range for Delivery Number
RANGES: L_R_VBELN FOR LIKP-VBELN.
* Initialization mode (first call by SAPI) or data transfer mode
* (following calls) ?
IF I_INITFLAG = SBIWA_C_FLAG_ON.
************************************************************************
* Initialization: check input parameters
* buffer input parameters
* prepare data selection
************************************************************************
* Check DataSource validity
CASE I_DSOURCE.
* Give the datasource a name which we will create in RSO2
WHEN 'ZZ_SHIPMENT_DATA '.
WHEN OTHERS.
IF 1 = 2. MESSAGE E009(R3). ENDIF.
* this is a typical log call. Please write every error message like this
LOG_WRITE 'E' "message type
'R3' "message class
'009' "message number
I_DSOURCE "message variable 1
' '. "message variable 2
RAISE ERROR_PASSED_TO_MESS_HANDLER.
ENDCASE.
APPEND LINES OF I_T_SELECT TO S_S_IF-T_SELECT.
* Fill parameter buffer for data extraction calls
S_S_IF-REQUNR = I_REQUNR.
S_S_IF-DSOURCE = I_DSOURCE.
S_S_IF-MAXSIZE = I_MAXSIZE.
* Fill field list table for an optimized select statement
* (in case that there is no 1:1 relation between InfoSource fields
* and database table fields this may be far from beeing trivial)
APPEND LINES OF I_T_FIELDS TO S_S_IF-T_FIELDS.
ELSE. "Initialization mode or data extraction ?
********************************************************************
* Data transfer: First Call OPEN CURSOR + FETCH
* Following Calls FETCH only
********************************************************************
* First data package -> OPEN CURSOR
59
IF S_COUNTER_DATAPAKID = 0.
* fill range with VBELN & change the name of range table
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'VBELN'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_VBELN.
APPEND L_R_VBELN.
ENDLOOP.
* Determine number of database records to be read per FETCH statement
* from input parameter I_MAXSIZE. If there is a one to one relation
* between DataSource table lines and database entries, this is trivial.
* In other cases, it may be impossible and some estimated value has to
* be determined.
OPEN CURSOR WITH HOLD S_CURSOR FOR
* Write your Select Query to fetch the data:
Select LIKP~VBELN
LIKP~ERNAM
LIKP~ERDAT
LIKP~VKORG
LIKP~LFDAT
LIKP~KUNNR
LIKP~KUNAG
VTTP~TKNUM
VTTP~TPNUM
from LIKP INNER JOIN VTTP
on LIKP~VBELN = VTTP~VBELN
where LIKP~VBELN IN L_R_VBELN.
ENDIF. "First data package ?
* Fetch records into interface table.
* named E_T_'Name of extract structure'.
FETCH NEXT CURSOR S_CURSOR
APPENDING CORRESPONDING FIELDS
OF TABLE E_T_DATA
PACKAGE SIZE S_S_IF-MAXSIZE.
IF SY-SUBRC <> 0.
CLOSE CURSOR S_CURSOR.
RAISE NO_MORE_DATA.
ENDIF.
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
ENDIF. "Initialization mode or data extraction ?
ENDFUNCTION.
STEP 3: Go to t-code RSO2 & create a DataSource with the same name that we have used in our FM i.e.,
ZZ_SHIPMENT_DATA & as we are uploading transactional data so select the radiobutton for Transaction
data as shown below.
60
Select Application Component as SD & maintain the text for short, medium & long description & then click
on the tab Extraction by FM as shown below.
Now enter the name of the Extract Structure & FM that we have created in step 1 & 2 respectively & then
click on Save.
61
STEP 4: Go to t code RSA3, enter the name of our DataSource & click on Start Extractor to check the data
in the datasource using Extractor.
STEP 5: Go to t code RSA1 in our BI system, here go to DataSources, right click on application component
Sales and Distribution & Replicate data as shown below.
62
Click on Continue & proceed as shown below.
63
STEP 6: In RSA1 click on InfoProvider in the right hand panel, create an InfoArea & then create a DataStore
Object in it as shown below.
64
STEP 7: In RSA1 click on DataSources in the right hand panel, go to our DataSource ZZ_SHIPMENT_DATA &
right click on it & click on Create Transformation as shown below.
In the Target of Transformation give Object Type as DataStore Object and name of DSO that we have
created in Step 6 as shown.
65
STEP 8: Go to DataSource ZZ_SHIPMENT_DATA right click on it & create InfoPackage as shown below.
66
Now go to the Monitor.
STEP 9: Right click on the DataStore Object ZDEMODSO & Create Data Transfer Process as shown below:
67
Click on Yes as shown below to continue.
STEP 10: Right click on the DataStore Object ZDEMODSO & click on Manage to check the result.
68
Go to the Content tab of InfoProvider Administrator screen & click on New Data as shown below.
69
7. FORMS
Window Types
MAIN – This is the window in which continuous text is output. This is the window used by dialog users of a
print program and layout set. For example the body text of a letter would be entered in MAIN.
VAR – Window with variable contents. The text can vary on each page in which the window is positioned.
Variable windows are formatted for each page.
CONST – Window with constant contents which is only formatted once.
Header data - Data related to development (created by, development class, etc.) and layout set
information (which elements are used) are both stored in the header data. A start page must be entered
here.
Paragraph formats - Paragraph formats are required in layout sets - as in styles - in order to format texts.
However, they are also used for word processing in layout sets, for example, to format text elements.
Character formats - You can also use character formats to format texts or paragraphs. Unlike paragraph
formats, however, they are used to format text within a paragraph.
Windows - Windows are names and window types, which are not physically positioned until they are
allocated to pages and units of measurement are specified.
Pages - Pages are defined to provide the system with a start and end point in text formatting.
Page windows - Page windows are the combination of windows and pages, where the dimensions of a
window and its position on a page are specified.
Logo in Sap Script
The report RSTXLDMC allows a TIFF graphics file to be uploaded from the file system of the R/3 GUI to a
standard text in the R/3 word processor SAP script. Specify the TIFF file path and type as shown below,
enter the Name of the standard text to be generated and execute.
70
The details of the upload will be displayed as below.
Page Protection (A portion of Content to be displayed in single page i.e. should not get split up between
pages.)
/: PROTECT
Contents
/: ENDPROTECT
Page Break
/: NEW-PAGE
Insert SO10 Text in SAP Script
/: INCLUDE <zstandardtxt> OBJECT <txt> ID <st> LANGUAGE <lang>
71
REPORT QCJPERFO.
FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA: PAGNUM LIKE SY-TABIX, "page number
NEXTPAGE LIKE SY-TABIX. "number of next page
READ TABLE IN_PAR WITH KEY ‘PAGE’.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY ‘NEXTPAGE’.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE OUT_PAR WITH KEY ‘BARCODE’.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = ‘|’. "First page
ELSE.
OUT_PAR-VALUE = ‘||’. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = ‘L’. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
7.2 SMARTFORMS
Logo
Go to transaction SE78 (Administration of Form Graphics).
Double-click on “GRAPHICS” node and click on “Import (F5)” to import the image.
72
Select the file name by using the F4 functionality available. Name your graphic and enter a short
description. If you have color image, select the radio button “Color Bitmap image”. Click on tick mark to
proceed.
73
Now go to transaction SMARTFORM and create a new form and give a short description for the same.
Page Break
Click on main area and create a loop, give internal table & workarea as shown
74
Right click on loop and create command, followed by table line Create table line for the loop. we will get
four columns now. Create text for every column
In cell 5 i.e first column, create a code by right clicking on that cell->create->flow logic->programming
lines.
In that code, write the following code and pass variables to output parameters.
Under General Attributes in command, tick Go to New Page and mention the Page.
75
Total and Subtotal
Create LOOP in MAIN Area under the Table. Inside the loop under SORT CRITERIA give the name of the
field with which you want to sort and when it has to be displayed,(here EVENT SORT BEGIN).It works like
AT-NEW event in loop. Now write the field for which the subtotal to be calculated in the SORT CRITERIA
and select the event. Here EVENT ON END. This works like AT-NEW event in loop. Mention the field (Sort-
Field for subtotal) based on which Subtotal is required under the events SORT BEGIN and SORT END.
Calculate Total for the required field (field for which Subtotal is required).
76
In the event CARRID EVENT ON SORT END which will be called at the end of current CARRID, create a table line
and text under that to display the Subtotal. Also create Code Program Lines to clear the SUM so that SUM is back
to zero for the next CARRID.
77
8. ENHANCEMENTS
SMOD – Search Exit using Package Details, Debug & keep breakpoint at ‘CALL CUSTOMER-FUNCTION’.
CMOD – Create implementation.
SD Exits – MV45AFZZ, MV50AFZZ, RV60AFZZ.
8.2 BADI
Works on interface concept. Hence, multiple implementations of any method in the BADI is possible since
each implementation creates a new Class inheriting from the Interface.
BADI Filters
T-code - SE18
Tick Checkbox Filter-Dependant. Use F4 on Filter Type to search appropriate Data Element.
If a BADI implementation exists, system will try to adjust the implementation since the BADI defenition
has changed.
78
Now check the parameters of the method any implementation, you can find a new parameter FLT_VAL
which will act as filter to be used inside the method.
Now, this implementation will be called only for the user ‘SAPUSER’.
79
8.3 BTE
Transaction – FIBF
80
Write addidional Logic in FM as per requirement.
Create a Product.
81
8.4 Implicit and Explicit Enhancements
Implicit Enhancements
Found with sequence of “ (generally at end of Forms, Includes and FMS). We need to right click and create
implementation.
Explicit Enhancements
Enhancement Section – possibility to replace Standard code with Custom Code.
Enhancement Spot – Cannot replace but can add new implementations. Multiple implementations
possible.
Transaction – VOFM
Condition Base Value – KWERT
Condition Value – KBETR
Create new routine and activate. Code inside to change values.
82
9. PERFORMANCE TUNING
ST05
It contains SQL Trace plus RFC, Enqueue and Buffer Trace. Mainly the SQL trace is used to measure the
performance of the select statements of the program.
SE30
It is used to measure performance of Programming Lines (LOOPS and READS).
SAT
It is the replacement of the pretty outdated SE30. It provides same functionality as SE30 plus some
additional features.
ST12
This transaction (part of ST-A/PI software component) is a combination of ST05 and SAT.
ST12 Demonstration
Enter User Name and Start Trace.
83
Now Click on End Traces and Collect.
84
Select the necessary traces from the ALV and hit Enter. Then, select Full Screen to display list of traces.
85
Now, select the necessary trace and click on Analysis Button ( ).
Now click on Per ModUnit to Sort the Trace based on subroutines for easier analysis.
Now you will get records sorted on Subroutines, FMs and Methods.
To analyze any of these, for e.g. subroutine FINAL_DATA, expand the same. Now you can see the time
taken for LOOPs and READs.
86
After this analysis, code fine tuning can be done accordingly.
1. DATABASE
a. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved. Very important!!
b. Design your Query to Use as much index fields as possible in your WHERE statement
c. Use INNER (or OUTER under some circumstances) JOINS in your SELECT statement to retrieve the
matching records at one shot instead of FOR ALL ENTRIES.
d. Avoid using nested SELECT statement and SELECT within LOOPs, better use JOINs or FOR ALL ENTRIES. Use
FOR ALL ENTRIES when the internal table is already there or the end of some processing. Try JOINs if the
SELECT are right behind each other
e. Avoid using INTO CORRESPONDING FIELDS OF TABLE during buffered access. Otherwise use the most
appropriate for the program.
f. Avoid using SELECT * and Select only the required fields from the table.
g. Avoid using ORDER BY in SELECT statements if it differs from used index (instead, sort the resulting
internal table), because this may add additional work to the database system which is unique, while there
may be many ABAP servers
h. INDEX: Creation of Index for improving performance should not be taken without thought. Index speeds
up the performance but at the same time adds two overheads namely; memory and insert/append
performance. When INDEX is created, memory is used up for storing the index and index sizes can be
quite big on large transaction tables! When inserting new entry in the table, all the indexes are updated.
More index more time. More the amount of data, bigger the indices, larger the time for updating all the
indices
i. Avoid Executing an identical Select (same SELECT, same parameter) multiple times in the program. Buffer
in your ABAP code.
j. Avoid using join statements if adequate standard views exist - no performance impact.
2. TABLE BUFFER
a. Defining a table as buffered (SE11) can help in improving the performance but this has to be used with
caution. Buffering of tables leads to data being read from the buffer rather than from table. Buffer sync
with table happens periodically, only if something changes which is happen rarely. If this table is a
transaction table, chances are that the data is changing for a particular selection criteria; therefore
application tables are usually not suited for table buffering. Using table buffering in such cases is not
recommended. Use Table Buffering for configuration data and sometimes for Master Data.
87
b. Avoid using complex Selects on buffered tables-, because SAP may not be able to interpret this request,
and may transmit the request to the database- The code inspector tells which commands bypass the
buffer.
3. Internal tables
a. Use HASHED tables where-ever possible. Otherwise SORTED tables. STANDARD tables should be the last
choice.
b. Use assign instead of into in LOOPs for table types with large work areas, if the data is being modified.
c. When in doubt call transaction SE30 and check your code.
d. If you must use a STANDARD table and you are using a READ, sort the table appropriately and use the
addition BINARY SEARCH to speed up the search.
4. Miscellaneous
a. PERFORM: When writing a subroutine, always provide type for all the parameters. This reduces the
overhead which is present when system determines on its own each type from the formal parameters
that are passed. It also makes for more robust programming.
88
10.UPGRADE
SPDD
To fix the impact on Data Dictionary Objects due to upgrade.
Transaction – SPDD
SPAU
To fix the impact on program code due to upgrade.
Transaction – SPAU
Any standard object that contains custom code due to enhancements or any other method and has been
modified by SAP as part of this new upgrade version will reflect in the transactions SPDD (Data Dictionary)
and SPAU (Program Lines).
Following actions are posible to fix the impacted objects in SPDD & SPAU –
Reset to Original – Considers only SAP’s Standard changes and removes our custom changes.
89
Following are possible scenarios w.r.t objects in SPDD & SPAU –
Any custom changes / enhancements done has been standardized by SAP – This means that our
cutom changes have been adopted by SAP in this upgrade and hence we need to ‘Reset to
Original’.
SAP has modified the object’s standard but has not standardized the custom changes – This
means that SAP has upgraded it’s standard alone and has not adopted our custom changes.
Hence, we need to ‘Adopt Modifications’ and include our custom changes as well.
90
11.DEBUGGING
In the debugging session, we can set breakpoints at run time on a statement (using Keywords),
subroutine, Function Module, Message.. etc.
Here we need to specify the Message Details and the breakpoint will be set..
91
11.2 Watch Point
Watch-point is used to monitor change in value of any variable during run time. The debugger will stop at
the statement that changes the value of the variable specified in the Watch-point. In a watch-point, we
can also specify value conditions on that variable based on which the debugger must start.
In general, in any transaction, all the DB Update happens in background after the transaction is complete
in foreground and COMMIT WORK is triggered. Update Debugging can be used to debug the statements
that are executed after COMMIT WORK.
92
Go to Settings -> Change Debugger Profile/ Settings.
Now, once the normal debugging session get’s complete, a new session will open for update debugging.
Here, we can use breakpoints and watchpoints to debug.
93