Sunteți pe pagina 1din 64

-1-

ABAP Lab-Guide

Sno. Table of Contents Page No.


1 Example Tables 2
2 Transaction Codes 2
3 Function:
a) creation (without exception) 4
b) creation (with exception) 4
c) call Functions (a,b) 5
d) creation (with tables) 6
e) call Function (d) 6
4 Document (or) Form:
a) create Form using SAP Script 8
b) create Form using SMARTFORMS 11
c) modify ‘Standard-Form’ layout using NACE 13
d) use existing Form in ABAP program 14
5 LDB (Logical DataBase) or (VIEW) – creation 15
6 Reports: [see also ‘abapdocu’ simple & complex lists]
a) Simple report program (using LDB) 18
b) SAP Queries (using Tool) 19
c) ALV (ABAP List Viewer) 21
d) Hierarchial Sequential 23
e) Simple (Interactive) 25
f) Complex (Interactive) 25
g) Complex (with Events) 27
7 ABAP Dictionary:
a) creation of TypeGroup (user defined Type) 28
b) creation of Table (user defined Table) 29
8 SCREEN Program:
a) simple screen program (executable) 31
b) screen program (module pool) 33
c) create transaction code (to execute module pool program) 34
d) screen program (with Table-Control) 35
e) screen program (with TabStrip-Control) 36
f) screen program – data insert, update, delete (in user defined table) 41
9 BDC (Batch Data Communication):
a) Call Transaction – method 45
b) Session – method 50
c) LSMW (Legacy System Migration Workbench) 52
10 RFC (Remote Function Call)
a) create Remote-Function 56
b) call Remote-Function 57
11 IDOC (Intermediate DOCument)
a) creation 58
b) sending/receiving 60
c) in runtime 60
12 ALE: (Application Linking Enabling) 60
13 EDI (Electronic Data Interchange) 61
14 BAPI (Business API) 62

SASIDHAR 9963855143
-2-
ABAP Lab-Guide

Example Tables: following tables are used in most of the database-table related examples.

Table: KNA1
Desc: Customer master
Field Name Field Description
1 KUNNR Customer number
2 NAME1 Customer name
3 LAND1 Country
4 ORT01 City

Table: VBAK
Desc: Sales order header
Field Name Field Description
1 VBELN Sales order number
2 ERDAT Order date
3 NETWR Net value
4 KUNNR Customer number

Table: VBAP
Desc: Sales order details
Field Name Field Description
1 POSNR Item number
2 ARKTX Item description
3 WERKS Plant code
4 VBELN Order number

Transaction codes:
following transaction codes(T.Code) are used to carry out various tasks:

T.Code Transaction details


SE10 Transport organizer
SE11 ABAP dictionary
SE12
SE13 ABAP dictionary [technical settings]
SE14 ABAP dictionary [database utility]
SE15 Object navigator
SE16 Data browser
SE17 General table display
SE18 Business add-ins [initial definition maintenance screen]
SE19 Business add-ins [initial implementation screen]
SE21 Package builder [initial screen]

SE24 Class builder


SE25

SASIDHAR 9963855143
-3-
ABAP Lab-Guide

SE29 Application packets


SE30 ABAP runtime analysis
SE32 SAP R/3
SE33 Context builder
SE35 Maintain dialog modules
SE36 Logical database builder
SE37 Function builder
SE38 ABAP editor
SE39 ABAP split screen editor
SE40 Menu painter
SE41
SE43 Area menu maintenance
SE48 Call history
SE49 Program analysis
SE51 Screen painter
SE53 General table maintenance dialog
SE54
SE55
SE56
SE57
SE61 Document maintenance
SE71 Form painter [NACE]
SE72 Style
SE73 SAP script font maintenance
SE74 SAP script format conversion
SE75 SAP script setting
SE76 SAP script form translation
SE77 SAP script style conversion
SE78 SAP script graphics management
SE80 Object navigator
SE81 Application hierarchy
SE82 Create application hierarchy
SE83 Display reuse library
SE84 R/3 repository info
SE15
SE89 R/3 repository info maintain tree display
SE91 Message maintenance
SE92 System log message maintenance
SE93 Maintain transaction
SE94 Simulation: customer (enhancement to SE38)
SE95 Modification browser
SE97 Maintain transaction: call authorixation in CALL TRANSACTION

NACE To modify existing standard layout


SQ01 SAP Queries
SQ02
SQ03
VA01 Sales & distribution
VA03

SASIDHAR 9963855143
-4-
ABAP Lab-Guide

(1a) FUNCTION – Creation

Steps Action
1 SE37 (transaction code for Function-Builder)
2 On menu-bar , GoTo  FunctionGroup  CreateGroup
3 Function Group: ZmyGRP (give any name)
Short Description: my function group (enter any text)
4 click on continue(tick-mark)
5 LocalObject
6 Function Module: ZmyFUNC (give any name)
7 Create
8 Function Module: ZmyFUNC [see step-6]
Function Group: ZmyGRP [see step-3]
Short Description: my sample function (enter any text)
9 Save
** Import (TAB):
10 IMPORT(TAB)
Parameter names type associated type
X type i
Y type i
** Export (TAB):
11 EXPORT(TAB)
Parameter names type associated type
Z type i
** Source code (TAB):
12 SOURCE CODE(TAB)
…Enter the logic…
z = x + y.
13 Save , Check , Activate , Continue , Execute
14 Enter test data values for x , y
15 Execute

(1b) FUNCTION– Creation (WITH EXCEPTION)

Steps Action
1 SE37 (transaction code for Function-Builder)
2 On menu-bar , GoTo  FunctionGroup  CreateGroup
3 Function Group: ZmyGRP (give any name)
Short Description: my function group (give any description)
4 click on continue (tick-mark)
5 LocalObject
6 Function Module: ZmyFUNC (give any name)
7 Create
8 Function Module: ZmyFUNC, [see step-6]
Function Group: ZmyGRP [see step-3]
Short Description: my sample function (enter any text)
9 Save

SASIDHAR 9963855143
-5-
ABAP Lab-Guide

** Import (TAB):
10 IMPORT(TAB)
Parameter names type associated type
X type i
Y type i
** Export (TAB):
11 EXPORT(TAB)
Parameter names type associated type
Z type i
** Exception (TAB):
12 EXCEPTION(TAB)
Exception short description
MyException1 divide by zero
** Source code (TAB):
13 SOURCE CODE(TAB)
if y = 0.
Raise MyException1.
Else.
Z = x / y.
Endif.
14 Save , Check , Activate , Continue , Execute
15 Enter test data for x , y
16 Execute

FUNCTION – Call (1a, 1b)

Steps Action
1 SE38 (transaction code for ABAP editor)
2 Program name: ZmyCallFunc (give any name)
3 Type: Executable Program
4 Save , LocalObject
5 Data: a type i, b type i, c type i.
(or)
Parameters: a type i, b type i.
Data: c type i.

a = 10. b = 5.
6 Place cursor where call-function code to be inserted.
Click on ‘Pattern’ to generate codes.
(select function name: ZmyFunc) [see ‘Function with exception’ step-6]
7 Continue
8 Exporting
X = a
Y = b
Importing
Z = c.
Write: / c.
9 Save , check, activate, Execute

SASIDHAR 9963855143
-6-
ABAP Lab-Guide

(2a) FUNCTION – Creation (WITH TABLES)

Steps Action
1 SE37 (transaction code for Function-Builder)
2 On menu-bar , GoTo  FunctionGroup  CreateGroup
3 Function Group: ZmyGrp (enter any name)
Short Description: my function group (enter any text)
4 click on (tick-mark)
5 LocalObject
6 Function module: ZmyFunc (give any name)
7 Create
8 Function Module: ZmyFunc [see step-6]
Function Group: ZmyGrp [see step-3]
Short Description: my sample function (enter any text)
9 Save
** Import (TAB):
10 IMPORT(TAB)
Parameter names type associated type
custno type KNA1-kunnr
** Tables (TAB):
11 TABLES(TAB)
Parameter names type associated type
ITAB like KNA1
** Source code (TAB):
12 SOURCE CODE(TAB)
…Enter the logic…
select * from KNA1 into table ITAB
where kunnr = custno.
13 Save , check, activate, continue, Execute
14 Enter test data values for custno [see step-10]
15 Execute

FUNCTION – Call (2a)

Steps Action
1 SE38 (transaction code for ABAP editor)
2 Program name: ZmyCallFunc
3 Type: Executable Program
4 Save, enter the following source codes
5 Tables: KNA1.
Data: cno type KNA1-kunnr.
Data: intab type KNA1 occurs 1 with header line.
cno = ‘1000’.
6 Click on ‘Pattern’ to generate function code at cursor position (select Function Name:
ZmyFunc) [see ‘Function with tables’ step-6]
7 Click on Continue (tick mark)
8 Exporting
custno = cno.
Tables

SASIDHAR 9963855143
-7-
ABAP Lab-Guide

ITAB = intab.

Loop at intab.
Write: / intab-kunnr.
Endloop.
9 Save , check, activate, Execute

DOCUMENT (SCRIPT/FORM)

Script: script in SAP is known as Document.

SAP bussiness documents (Examples):

a) sales order
b) invoice
c) bill
d) purchase order
e) debit memo
f) credit memo
etc.

DESIGN AND PRINTING OF SAP BUSINESS DOCUMENTS:

PRINT
PROGRAM

Database

SASIDHAR 9963855143
-8-
ABAP Lab-Guide

Every business documents consists of following 2 components:


 layout (template)
 print program.

(Note: in general enterprise business more than 200+ business documents are used.)

SAP has identified most commonly used business documents and provided standard layouts and print
programs for them in the system.

Role of ABAP developer:


 80% : to modify existing layouts and print programs.
 20% : to develop new layouts and print programs.

Methods to generate SAP business documents:


 sapscripts (traditional method)
 smart forms (available since release 4.6c onwards)

ABAPer’s tasks:
 to develop new layout and print program.
 to modify existing layout.

FORM - Creation (using ‘SAP-SCRIPT’) (similar to mail-merge)


(NOTE: need to specify window sizes.)

Create Windows:
 LOGO
 HEADER
 ADDRESS
 MAIN (default )
 FOOTER

Steps Action
1 SE71 (transaction code for Form-Painter)
2 Form: ZmySapScriptFORM (enter any name)
3 Create, Continue (tick mark) in pop up box
4 Description: my form (enter any text)
Translate: (Select radio-button) ‘Do not Translate’
5 Save, LocalObject
6 Click ‘Pages’ button (F6)
7 Page: Mypage (give any name)
8 Save
9 Next page: Mypage [see step-7]
Description: my page (enter any text)
** Pages: Create Windows:
10 Click on ‘Windows’ button (F7)
11 MAIN is default window
12 on menu-bar, EDIT  CreateElement (or) (Shift+F6)
13 (Pop-up box to create LOGO window)
Window: LOGO
Description: logo window (enter any text)
Click on Continue(tick mark)

SASIDHAR 9963855143
-9-
ABAP Lab-Guide

14 on menu-bar, EDIT  CreateElement (or) (Shift+F6)


15 (Pop-up box to create HEADER window)
Window: HEADER
Description: header window (enter any text)
Click on Continue(tick mark)
16 on menu-bar, EDIT  CreateElement (or) (Shift+F6)
17 (Pop-up box to create FOOTER window)
Window: FOOTER
Description: footer window (enter any text)
Click on Continue(tick mark)
18 on menu-bar, EDIT  CreateElement (or) (Shift+F6)
19 (Pop-up box to create ADDRESS window)
Window: ADDRESS
Description: address window (enter any text)
Click on Continue(tick mark)
** PageWindows: Define Window size:
20 Click ‘Page Windows’ button in the top Tool-bar
21 on menu-bar, EDIT  CreateElement (or) (Shift+F6)
22 Dbl .click on ‘LOGO’ in the windows list box (or) select & rt-click  choose (or) F2
23 (Define dimensions in the lower panel)
Left margin : 1 cm width: 3 cm
Upper margin: 1 cm height:3 cm
24 on menu-bar, EDIT  CreateElement (or) (Shift+F6)
25 Dbl .click on ‘HEADER’ in the windows list box (or) select & rt-click  choose (or) F2
26 (Define dimensions in lower panel)
Left margin : 5 cm width: 14 cm
Upper margin: 1 cm height: 3 cm
27 on menu-bar, EDIT  CreateElement (or) (Shift+F6)
28 Dbl .click on ‘ADDRESS’ in the windows list box (or) select & rt-click  choose (or) F2
29 (Define dimensions in the lower panel)
Left margin : 1 cm width: 5 cm
Upper margin: 5 cm height:5 cm
30 on menu-bar, EDIT  CreateElement (or) (Shift+F6)
31 Dbl .click on ‘MAIN’ in the windows list box (or) select & rt-click  choose (or) F2
32 (Define dimensions in the lower panel)
Left margin : 2 cm width: 17 cm
Upper margin: 11 cm height:15 cm
33 on menu-bar, EDIT  CreateElement (or) (Shift+F6)
34 Dbl .click on ‘FOOTER’ in the windows list box (or) select & rt-click  choose (or) F2
35 (Define dimensions in the lower panel)
Left margin : 1 cm width: 17 cm
Upper margin: 26 cm height: 2 cm
36 Save
** Create Paragraph-Format:
37 Click on ‘ParagraphFormats’ button on the top tool-bar
38 Paragraph: P1 (give any name)
39 Save
40 Descript.: my paragraph format (enter any description)
(click on ‘Font’ button)
Font size: 18
Family: Arabic simplified (click inside the textBox and select a Fontfamily from the list)
Radio buttons: BOLD, ITALIC, UNDERLINED (select [On, Off, Retain] as per your choice)
** Create Character-Format:
41 Click on ‘CharacterFormats’ button on the top tool-bar

SASIDHAR 9963855143
-10-
ABAP Lab-Guide

42 Character Format: C1 (give any name)


Save
Descript.: my character format (enter any description)
Font size: 18
Family: Arabic simplified (click inside the textBox and select a Fontfamily from the list)
Radio buttons: BOLD, ITALIC, UNDERLINED (select [On, Off, Retain] as per your choice)
43 Save
44 On menu-bar, GOTO  HEADER (or F5)
45 Click on ‘BasicSettings’ button
46 First page: Mypage [see step-7] (or select from List-box)
Default paragraph: P1 [see step-37]
47 Save
** define Window Contents:
48 Click on ‘PageWindows’ button
49 Dbl.click on ‘LOGO’ in the windows list box (or) select & rt-click  choose (or) F2
50 Click on ‘TextElements’ icon on top tool-bar (F9)
51 On menu-bar: INSERT  GRAPHICS
52 (NOTE: select any image to appear in the Logo window)

‘Stored On Document Server’ (TAB)


Select radio-button, ‘Color Bitmap Image’
Name: ENJOY (click inside the textBox and select an image, e.g ‘ENJOY’)

NOTE: in the ‘Name’ box, click icon at the right corner. Click on ‘Execute’(F8) to list out the
bitmap image names. Select any image. e.g. ‘ENJOY’. Click on ‘Copy’ (tick mark)

Resolution: 100 (DPI=dots per inch)

Continue(tick-mark)
53 Back(F3)
54 Dbl.click on ‘HEADER’ in the windows list box (or) select & rt-click  choose (or) F2
55 Click on ‘Text Elements’ icon on top tool-bar (or F9)
56 (NOTE: write any text to appear in the header line e.g.)

MY Software Solutions Inc. USA


57 Back( F3)
58 Dbl.click on ‘ADDRESS’ in the windows list box (or) select & rt-click  choose (or) F2
59 Click on ‘Text Elements’ icon on top tools-bar (or F9)
60 (NOTE: write any text to appear in the address line. Get data from KNA1 table fields)

To, &KNA1-kunnr& &KNA1-name1& &KNA1-ort01&


61 Back(F3)
62 Dbl.click on ‘MAIN’ in the windows list box (or) select & rt-click  choose (or) F2
63 Click on ‘Text Elements’ icon on top tools-bar (or F9)
64 (NOTE: write any text to appear in the main body. Get data from KNA1 table fields)

Dear Sir, we received the order from &KNA1-kunnr&


65 Back(F3)
66 Dbl.click on ‘FOOTER’ in the windows list box (or) select & rt-click  choose (or) F2
67 Click on ‘Text Elements’ icon on top tools-bar (or F9)
68 (NOTE: write any text to appear in the footer line)

Our goal is Customer Satisfaction


69 Back(F3)

SASIDHAR 9963855143
-11-
ABAP Lab-Guide

** check Form definitions, texts , Print-Preview:


70 On menu-bar, FORM  CHECK  DEFINITIONS
71 On menu-bar, FORM  CHECK  TEXTs , continue(tick-mark) in pop-up box
[Note: it may not work for version 4.7]
72 On menu-bar, FORM  ACTIVATE
73 On menu-bar, UTILITIES  TEST PRINT (or TEST PRINTING in ver 4.7)
74 Output device: LP01
75 Click on ‘Print Preview’ (or) F8 [to view the generated Form]

FORM - Creation (using SMARTFORMS) (similar to mail-merge)


(NOTE: use built-in FORM-PAINTER to specify window sizes).

Create Windows:
 LOGO
 MAIN (created by default)
 HEADER
 FOOTER

Steps Action
1 SMARTFORMS (transaction code)
** Create Style:
2 Select radio-button, Style: ZmySmartSTYLE (enter any name)
3 Create
[ Screen divided into Left and Right panels ]
** Define Paragraph-Format:
4 On left-panel, Rt.-Click ParagraphFormat  CreateNode
5 In the pop-up box, ParagraphFormat: P1 (enter any name e.g P1)
6 Enter (tick mark)
7 Description: my paragraph format (enter any text)
8 Font (TAB) : define font characteristics for ‘Paragraph format’
Font family:
Font size: 11
Font style: Bold
Color:
Underline:
** Define Character-Format:
9 On left-panel, Rt.-Click CharacterFormat  CreateNode
10 In the pop-up box, CharacterFormat: C1 (enter any name e.g C1)
11 Enter (tick mark)
12 Description: my character format (enter any text)
13 Font(TAB) : define font characteristics for ‘Character format’
Font family:
Font size: 12
Font style: Italic
Color:
Underline:
14 Save , LocalObject
15 Back (F3)
** Create Form:
16 Select radio-button, Form: ZmySmartFORM (enter any name)
17 Create
** Define Global Data:

SASIDHAR 9963855143
-12-
ABAP Lab-Guide

18 On left-panel, dbl.-click ‘Global Definitions’ (or) select & press ‘ENTER’ key
19 GlobalData (TAB)
Variable name type assignment associated type (‘reference type’ in 4.6)
Intab like standard table of KNA1
Outtab type KNA1
** Create Windows & define Contents:
** Create window: LOGO:
20 On left-panel, Rt.-Click ‘%PAGE1 New page’
21 Create  Window
22 Window: LOGO
Description: logo window (enter any text or leave it blank)
(press ‘ENTER’ key)
23 On left-panel, Rt.-Click ‘LOGO’
24 Create  Graphic
25 Name: ENJOY (click inside the textBox and select a Graphic image, e.g. ENJOY)
Object:
Id:
NOTE: in the ‘Name’ box, click icon at the right corner. Select ‘color’ or ‘black & white’ bitmap
image from the pop-up panel. Click on ‘Execute’(F8) to list out the bitmap image names. Select
any image. e.g. ‘ENJOY’. Click on ‘Copy’ (tick mark)

Resolution: 100 (give any resolution, preferably 100DPI, dots per inch)
** Create window: HEADER:
26 On left-panel, Rt.-Click ‘%PAGE1 New page’
27 Create  Window
28 Window: HEADER
Desccription: header window (enter any text or leave it blank)
(Press ‘ENTER’ key)
29 On left-panel, Rt.-Click ‘HEADER’
30 Create  Text
(enter any text at the blinking cursor position, e.g. MY software technologies inc. USA)
** Create window: FOOTER:
31 On left-panel, Rt.-Click ‘%PAGE1 New page’
32 Create  Window
33 Window: FOOTER
Description: footer window (enter any text or leave it blank)
(Press ‘ENTER’ key)
34 On left-panel, Rt.-Click ‘FOOTER’
35 Create  Text
(enter any text at the blinking cursor position, e.g. YOUR future begins here)
** Define Window size, location:
36 Click ‘FORM-PAINTER’ (F9) to show/hide the window design screen.
37 On lt-panel , Dbl-click on the window names (e.g. LOGO, HEADER etc.)
Drag them onto the ‘Designer Canvas’ on rt-panel.
Resize and relocate the windows as you like
Note: it requires some practice
** Define Program Lines:
38 On left-panel, Rt.-Click ‘MAIN window’
(Note: this window is created by default)
39 Create  FlowLogic  ProgramLines (Create  ProgramLines in 4.6)
(Note: if the ‘Designer Canvas’ is still visible, hide it by clicking on ‘Form Painter’)
40 GeneralAttributes (TAB)
Input parameter Output parameters
Intab Outtab

SASIDHAR 9963855143
-13-
ABAP Lab-Guide

41 (write the following statement in right-bottom panel TextArea.) [NOT available in 4.6]
Select * from KNA1 into corresponding fields of table Intab.
42 Save , ‘LocalObject’
** Define LOOP:
43 On left-panel, Rt.-Click ‘%CODE1 New Program Lines1’
44 Create  FlowLogic  LOOP (Create  LOOP in 4.6)
45 Data (TAB)
‘Operand’[‘internal table’ in 4.6]: checkbox (Tick-mark)
‘Intab’ INTO ‘Outtab’ (enter internal-table names on either side of the word ‘INTO’)
46 On left-panel, Rt.-Click ‘%LOOP1 New Loop 1’
47 Create  Text
48 (Note: click ‘Insert Field’ icon with ‘+’ sign on the right-panel.
enter the following lines in the pop-up window and click ‘Continue’ (tick-mark).
To delete any selected field: highlight the field and click on ‘Delete Field’ icon with ‘-’ sign)

&outtab-kunnr&
&outtab-land1&
&outtab-name1&
&outtab-ort01&
49 Save, Check, Activate, Test (F8)
50 Function module: is generated (e.g. /1BCDWB/SF00000024)
51 SingleTest (F8) , Execute (F8)
52 Output Device: LP01
53 Click on ‘Print Preview’ (F8) [to view the generated Form]

FORM: - copy & modify (STANDARD LAYOUT) [layout and print Program defined by SAP]

Steps Action
** view exising STANDARD Form-name:
1 NACE (transaction code to view Standard Layouts/applications)
2 Select any Application from the list e.g V1 (sales)
3 Click on ‘Output Types’ (F5)
4 On right panel, select BA00 (order confirmation)
5 On left panel, dbl. click on ‘Processing Routines’
6 Just remember the Form to modify (e.g. RVORDER01) from the right-side list
7 Go back to initial screen by pressing ‘Back’(F3) several times (normally 3 times)
** Copy the Form:
8 SE71 (transaction code for Form-Painter)
9 On menu-bar, UTILITIES  COPY FROM CLIENT
10 Form Name: RVORDER01 [see step-6]
Target Form: ZRVORDER01 (give any name)
Source Client: 800 (client code during login)
11 Execute(F8) , LocalObject , Back(F3) , Back(F3)
** Modify the layout:
12 Form: ZRVORDER01 [see step-10] target form name
13 Change
14 Click on ‘Page Windows’ (F8)
15 Dbl.click on ‘HEADER’ (or select any window to modify) [in the top ‘Page Window’ panel]
16 Click on ‘Text Elements’ icon on tool-bar (or F9)
17 Change the text (as per requirement)
18 Back (F3) to move to the ‘Page Window’ List

SASIDHAR 9963855143
-14-
ABAP Lab-Guide

** check Form definitions, texts , Print-Preview:


19 On menu-bar, FORM  CHECK  DEFINITIONS
20 On menu-bar, FORM  CHECK  TEXTs , continue(tick-mark) in pop-up box
21 Select print Program ‘RVADOR01’ in the pop-up box, click ‘Copy’ (tick-mark), Back(F3)
22 On menu-bar, FORM  ACTIVATE
23 On menu-bar, UTILITIES  TEST PRINT (‘PRINTING TEST’ in version 4.7)
24 Output Device: LP01
25 Click on ‘Print Preview’ (F8)
26 Go back to initial screen by pressing ‘Back’ (F3) several times
** Replace the Form name:
27 NACE (transaction code to view Standard Layouts/Applications)
28 Select V1 (sales) [see step-2]
29 Click on ‘Output Types’ (F5)
30 On right-panel, select BA00 (order confirmation)
31 On left-panel, Dbl. click ‘Processing Routines’
32 On right-panel, Select the entire-row where ‘Form’ name (e.g. RVORDER01) to be changed
33 Click ‘Change/Display (Ctrl+F1)’ icon on tool-bar
34 Replace the ‘Form’ name.(e,g, RVORDER01 with ZRVORDER01) [see step-10]
35 Save , Continue(tick-mark) [operation successful]

FORM: use existing Form in ABAP Program

Steps Action
1 SE38 (transaction code for ABAP editor)
2 Program name: ZmyPRG1 (give any name)
3 Create
4 Title: MY Form program (give any text)
Type: Executable Program
5 Save, ‘Local object’
** add following Sourse Codes:
6 REPORT ZMYPRG1.

Tables: KNA1.
Select-options: cno for KNA1-kunnr.
*-------------------------------
** insert function: OPEN_FORM:
7 Click ‘Pattern’ (or) Ctrl+F6 , Call function: OPEN_FORM , continue (tick mark)
8 (Un-comment the following 3 lines)
EXPORTING
Form = ‘ZmySapScriptFORM‘ [see ‘SAP script’ step-2]
Language = SY-LANGU

** SQL query:
9 (insert the following codes and place cursor after the last comment line)

SASIDHAR 9963855143
-15-
ABAP Lab-Guide

*----------------------------------
Select * from KNA1 where kunnr in cno. [see step-4] (Note: not available in 4.6)
*---------------------------------
** insert function: START_FORM:
10 Ctrl+F6, Call function: START_FORM , continue (tick mark)
11 (Un-comment the following 5 lines)
EXPORTING
Form = ‘ZmySapScriptFORM’ [see ‘SAP script’ step-2]
Language = SY-LANGU
Start page = ‘Mypage’ [see ‘SAP script’ step-7]
Program = ‘ZmyPRG1’ [see step-2]
12 (place cursor at the last line of program codes and add the following demarcation line)
*----------------------------------------
** insert function: WRITE_FORM:
13 Ctrl+F6, Call function: WRITE_FORM , continue (tick mark)
14 (Un-comment the following 2 lines)
EXPORTING
Window = ‘ADDRESS’ [see ‘SAP script’ step-17]
15 (place cursor at the last line of program codes and add the following demarcation line)
*----------------------------------------
** insert function: WRITE_FORM:
16 Ctrl+F6 , Call function: WRITE_FORM , continue (tick mark)
17 (Un-comment the following 2 lines)
EXPORTING
Window = ‘MAIN’ [see ‘SAP script’ step-9]
18 (place cursor at the last line of program codes and add the following demarcation line)
*----------------------------------------
** insert function: END_FORM:
19 Ctrl+F6 , Call function: END_FORM , continue (tick mark)
20 (place cursor at the last line of program codes and add the following demarcation line)
*----------------------------------------
** END SELECT:
21 (place cursor at the last line and add the following codes..)

ENDSELECT.
*---------------------------------------
** insert function: CLOSE_FORM:
22 Ctrl+F6 , Call function: CLOSE_FORM , continue (tick mark)
23 Save
** Execute & Preview the Form:
24 Check , Activate , Execute (‘Direct processing’) F8
25 Cno: 1000 to 2000 (customer number: enter any range)
26 Execute (F8)
27 Output Device: LP01
28 Click on ‘Print preview’ [to display the Form output]

LOGICAL DATABASES (LDB):

SASIDHAR 9963855143
-16-
ABAP Lab-Guide

Definition: Logical Databases (LDBs) are special ABAP programs that retrieve data and make it available
to application programs.

A) the most common use of LDBs is to read data from different database tables by linking them to
executable ABAP programs.

PRG 1

PRG 2 LDB DATA BASE

PRG 3

instead of programs interacts directly with databases, they interacts with logical databases.
b) in sap, ldbs are extensively used in HR-modules. (info-type) (hr-abap).
c) ldbs contain open sql statements that read data from the databases, so we there fore use sql statements in
or programs.
d) the ldb reads the program, stores in the program if necessary, and then passes them line by line to the
application program.
e) the data structure in a logical database is hierarchial.
f) many tables in the r/3 system are linked to each other using foreign key relation ships.
g) some of these dependencies form tree-like hierarchical structures.
h) logical databases read from database tables that are part of them structures.

tasks of logical databases: -


- reading the same data for several programs.
- defining the same user interface for several programs.
- improving performance.

a logical data base is made up of 3 components.

1* structure:
the structure defines the data view of the logical database.

2* selections:
the selections dfine a selection screen, which forms the user interface of the executable programs that
use the logical databases. it’s layout usually determined by a structure.

3* database program:
the data base program contains the abap statements used to read the data and pass it to the user of the
logical database.

we need to define only structure, the rest of two (selections & database program) are auto-generated by the
system.

SASIDHAR 9963855143
-17-
ABAP Lab-Guide

Nodes:

KNA1
|--------- VBAK
|---------- VBAP

LDB: - Create ‘Logical DataBase’ (or VIEW)

Steps Action
1 SE36 (transaction for LDB creation)
2 Logical database: ZmyLDB (give any name)
3 Create
4 (in the pop-up box)
Short text: (give any text)
5 Click on ‘Create’ icon, ‘Local object’
** define parent node KNA1:
6 (in the pop-up box)
Name of Root Node: KNA1
Text: customer master table (give any text)
Select radio-button, ‘Database Table’ : KNA1
Click on ‘Create’ icon
** create child node VBAK:
7 Structure(TAB)
Under ‘Node Name’,
Right-click KNA1  InsertNodes
8 (in the pop-up box)
Node name: VBAK (2nd level node name)
Text: sales order table (enter any text)
Hierarchically under: KNA1 (parent node, by default)
Select radio-button, ‘Database table:’ VBAK
9 Click on ‘Insert new node’ (or F5)
** create child node VBAP:
10 Structure(TAB)
Under ‘Node Name’,
Right-click on VBAK  InsertNodes
11 (in the pop-up box)
Node name: VBAP (3rd level node name)
Text: item order information
Hierarchically under: VBAK (parent node, by default)
Select radio-button, ‘Database table:’ VBAP
12 Click on ‘Insert new node’ (or F5)
13 Save
** generate ‘Selection Screen’ Source codes:
14 Click on ‘Selections’
15 Click on ‘Yes’ in the pop-up box
16 Click on ‘No’ in the pop-up box
17 We can see 2 types of selections in top and bottom panels
1. free selections (in Top panel)
2. field selections (in Bottom panel)
18 Select fields from ‘Free selections’ panel. (e.g. KNA1, VBAK, VBAP) check-box
19 Click on ‘Transfer’ (tick-mark)
** un-comment generated Source codes:

SASIDHAR 9963855143
-18-
ABAP Lab-Guide

20 Some codes are automatically generated


21 (Un comment)
select-options: ? FOR kna1-kunnr (replace ? with cno)
select-options: ? FOR vbak-vbeln (replace ? with ono)
22 Save , Activate , Back (F3)
23 Click ‘Source code’ on tool-bar
24 Click on ‘Yes’ in the pop-up box
25 Double-click on include DBZmyLDBNXXX. “all system routines
** KNA1 (SELECT statement):
26
Again double-click on ‘Include xxxxxx KNA1’

27 (NOTE: uncomment the following 3 lines only and put ‘.’ After cno)
Select * from kna1
Where kunnr in cno.
Endselect.
28 Save , Check , Activate , Continue (tick mark) , Back(F3)
** VBAK (SELECT statement):
29 Again double-click on ‘Include xxxxxxx VBAK’
30 (NOTE: uncomment the following 3 lines only and put ‘.’ After ono)
Select * from vbak
Where vbeln in ono.
Endselect.
31 Save , Check , Activate , Continue (tick mark) , Back(F3)
** VBAP (SELECT statement):
32 Again double-click on ‘Include xxxxxxx VBAP’
33 (NOTE: uncomment the following 3 lines only and put ‘.’ After vbak-vbeln)
Select * from vbap
Where vbeln = vbak-vbeln.
Endselect.
34 Save , Check , Activate , Continue (tick mark) , Back (F3)
** save, check , activate the Nodes:
35 Save , Activate , Continue (tick mark) , Back (F3)
36 Save , Activate , Continue (tick mark) , Back(F3) , Back(F3)

Note: don’t click ‘Save’ again in the Node-Tree(KNA1, VBAK, VBAP) screen
** test newly created LDB and view data:
37 Select ‘Logical Database:’ ZmyLDB [see step-2] (displayed by default)
38 Click on ‘Test’ icon (F8) on tool-bar
39 cno: 1000 to 1001 (customer number, Enter values)
ono: ---- to ---- (order number, leave it blank)
40 Click on Execute (F8) on tool-bar
Note: it may take few minutes to display the LDB content

REPORTS:
Popular methods to generate report are:
a) using reporting TOOL
b) using LDB
c) using SELECT statement

REPORT: - Simple Report program (using LDB) with 3 tables KNA1,VBAK,VBAP

Steps Action

SASIDHAR 9963855143
-19-
ABAP Lab-Guide

1 SE38
2 Program name: ZmyLDBPrg (give any name)
3 Create
4 Title: my LDB program (enter any text)
Type: Executable Program
Logical Database: ZmyLDB (which is already created) [see ‘create LDB’ step-2]
5 Save , ‘Local object’ , [write the following source codes..]
6
REPORT ZMYLDBPRG.

Nodes: KNA1, VBAK, VBAP.

*--- column headings


Write: /5 ‘cust no’,
20 ‘cust name’,
40 ‘country’,
60 ‘order no’,
80 ‘order value’,
90 ‘item no’.

Get KNA1.
Get VBAK.
Get VBAP.

*--- column/field contents


Write: /5 KNA1-kunnr color 6 inverse on,
20 KNA1-name1 color 4 inverse on,
40 KNA1-land1 color 3 inverse on,

60 VBAK-vbeln color 2 inverse on,


80 VBAK-netwr color 1 inverse on,

90 VBAP-posnr color 6 inverse on.

7 Save , check , activate , continue , Execute(‘Direct processing’) F8


8
cno: 1000 to 1001 (customer number, Enter values )
ono: ---- to ---- (order number, leave it blank)
9 Click on Execute (F8) [to generate Report]

SASIDHAR 9963855143
-20-
ABAP Lab-Guide

SAP queries

ZGSRUSRGRP1 1
5
QUERY 3 USER 1
4 USER 2
USER 3
USER 4
USER 5
USER 6
INFOSET USER 7
USER 8
USER 9

LOGICAL
DATABASE

DATABASE

REPORT: - SAP-QUERIES [report generation Tool] generates report without any ABAP coding.
using LDB

Steps Action
1 SQ03 (transaction code) – create a usergroup
2 SQ02 (transaction code) – create a infoset
3 SQ03 (transaction code) – assign user and infoset to usergroup
4 SQ02 (transaction code) – assign usergroup to infoset
5 SQ01 (transaction code) – design the query layout , test/execute query

Steps Action
** create USERGROUP:
1 SQ03 (transaction code to create a usergroup)
2 User group: ZmyGrp (give any name)

SASIDHAR 9963855143
-21-
ABAP Lab-Guide

3 Click ‘Create’
4 Short description: my group (enter any text)
5 Save , ‘Local object’ , Back
** create INFOSET:
6 SQ02 (transaction code to create a infoset)
7 Infoset: ZmyInfoset (give any name)
8 Create
9 Name: santanu’s infoset (give any text)
Authorization group: ZmyGrp [see step-2]
Select radio-button, ‘Logical Database’ : ZmyLDB
[see user defined table in LDB step-2]
10 Click on continue (tick mark)
11 New screen appears with TWO panels – Left and Right
** add Fields to FieldGroup: **
12 Select NODE ‘Customer Master Table’ from Right panel
13 In the Left panel , click on right-arrow icon beside ‘Customer Master Table KNA1’
14 right-click on field-name  ‘Add field to field group’
(e.g. customerNumber KNA1-kunnr). And Follow the same procedure for other fields (KNA1-
name1, KNA1-land1, KNA1-ort01)

Note: Select the required fields


15 Select another NODE from right panel and follow the same procedure as mentioned above for
VBAK (fields: vbeln, erdat, netwr, kunnr) , VBAP (fields: posnr, arktx, werks, vbeln)
16 Save , ‘Local object’
17 On manu-bar, Click on ‘Generate’ icon (or shift-F6) to generate the infoset
18 Save , Back , click ‘Yes’ in the pop-up box , Back
** assign USER and INFOSET to USERGROUP:
19 SQ03 (transaction code to assign user and infoset to usergroup)
20 Click on ‘Assign Users & Infoset’
21 Users and Change authorization for query
User name: SAPUSER [in the top left box] (username while logging in)
22 Press ‘Enter’ , Save
23 Click on ‘Assign Infoset’ (F5)
24 Select the Infoset you have created ‘ZmyInfoset’ from the list [see step-7]
25 Save , Back , Back , Back
** assign USERGROUP to INFOSET:
26 SQ02 (transaction code to assign usergroup to infoset)
27 Select newly created infoset e.g. ‘ZmyInfoset’ from the list [see step-7]
28 Click on ‘Role/UserGroup Assignment’
29 Select your user-group from the generated list e.g. ‘ZmyGrp’ [see step-2]
30 Save , Back , Back
** design the Query Layout: (4.6c):
31 Note: following steps are for SAP 4.6c [ 4.7 version codes are given after step-48 ]

SQ01 (transaction code to design the query layout)


32 Query : ZmyQry (give any name)
33 Select the created Infoset e.g. ‘ZmyInfoset’ [see step-7]
34 Click on ‘Copy’ icon (tick mark)
35 Title: my SAP query using LDB (give any text)
Notes: my SAP query research work (give any text)
List format: Columns: 130
36 Select radio-button, ‘ABAP LIST ‘ under heading ‘output format’
37 Save
38 Click on ‘Basic LIST’

SASIDHAR 9963855143
-22-
ABAP Lab-Guide

39 New screen appears with 4 panels(windows):


upper-left panel displays the following items:
 General data information- KNA1
 VBAK sales document
 VBAP sales document
40 On left panel , Click on right-arrow beside  ‘General data information- KNA1’ ,
And Select the required fields by clicking on (checkboxes) e.g. city, name1, country
41 On left-panel, Click on right-arrow beside  ‘VBAK sales document’,
And Select the required fields by clicking on (checkboxes)
42 On left-panel, Click on right-arrow beside  ‘VBAP sales document’,
And Select the required fields by clicking on (checkboxes)
43 Save
Click on ‘Test’ , click on Continue (tick mark) in the pop-up box
44 Enter the customer number: e.g.
cno: 1000 to 1001
45 Execute
46 Report is generated successfully
47 Optional:*** Click on ‘ALV’ button to generate user defined customized reports
48 The following operations can be performed by clicking the respective icons.
1. sort in ascending order
2. sort in descending order
3. filter
4. total
5. sub total
6. print preview
7. Microsoft excel view
8. word processing
9. mail receipt
10. ABC analysis
11. graphic view
12. change layout
13. select layout
14. save layout
** design the Query Layout: (4.7):
31 Note: following steps are for SAP 4.7

SQ01 (transaction code to design the query layout)


32 Query : ZmyQry (give any name)
33 click ‘Other user group’ icon (shift+F7) on the tool-bar
34 select the user group name ‘ZmyGRP’ from the list , click on ‘Choose’
35 enter Query: ZmyQRY (any name)
36 click on ‘Infoset query’
37 select User Group: ZmyGRP (from the list)
38 select Infoset Name: ZmyInfoset
39 click ‘Continue’ (tick-mark)
40 New screen appears with 3 panels(windows)
41 upper-left panel displays the following items:
 Selection fields from InfoSet
 Customer Master Table
 Sales Order Table
 Item Order Information
42 click on the right-arrow icon beside  Selection fields from InfoSet
43 select CNO, ONO by clicking on the check-boxes
44 click on the right-arrow icon beside  Customer Master Table

SASIDHAR 9963855143
-23-
ABAP Lab-Guide

45 select required fields by clicking on the (Output)check-boxes


46 click on the right-arrow icon beside  Sales Order Table
47 select required fields by clicking on the (Output)check-boxes
48 click on the right-arrow icon beside  Item Order Information
49 select required fields by clicking on the (Output)check-boxes
50 Save , Continue (tick-mark) , Continue (tick-mark)
51 Back (F3)
52 select newly created QUERY from the list, click ‘Test’ icon (Ctrl-F8) on the tool-bar
53 click ‘Continue’ (tick-mark)
54 Enter the customer number: e.g.
cno: 1000 to 1001
55 Execute
56 Report is generated successfully

REPORT: ALV [ABAP List Viewer] Report generation through ABAP program (using SELECT).
using a single table KNA1 with 4 columns .

Steps Action
1 SE38
2 Program name: ZmyALV (enter any name)
3 Create
4 Title: my report (enter any text)
Type: Executable Program
5 Save , ‘Local object’ , [enter the following source code]
6 REPORT ZMYALV.

*--- specify the type group.


TYPE-POOLS: SLIS.

*--- define the work area for the internal table


*--- to store the lay-out details.
DATA: W_FCAT TYPE SLIS_FIELDCAT_ALV.

*--- define the work area for the internal table


*--- to store the lay-out details.
DATA: T_FCAT TYPE SLIS_T_FIELDCAT_ALV.

*--- define the lay-out and fill the catalog-internal-table.


W_FCAT-COL_POS = 1. “1st column
W_FCAT-FIELDNAME = 'KUNNR'. “field name
W_FCAT-SELTEXT_M = 'CUST NO'. “column/field heading
APPEND W_FCAT TO T_FCAT. “append data from work area to internal table
**------
W_FCAT-COL_POS = 2. “2nd column
W_FCAT-FIELDNAME = 'NAME1'. “field name
W_FCAT-SELTEXT_M = 'CUST NAME'. “column/field heading
APPEND W_FCAT TO T_FCAT. “append data from work area to internal table
**------
W_FCAT-COL_POS = 3. “3rd column
W_FCAT-FIELDNAME = 'ORT01'. “field name
W_FCAT-SELTEXT_M = 'CITY'. “column/field heading

SASIDHAR 9963855143
-24-
ABAP Lab-Guide

APPEND W_FCAT TO T_FCAT. “append data from work area to internal table
*------
W_FCAT-COL_POS = 4. “4th column
W_FCAT-FIELDNAME = 'LAND1'. “field name
W_FCAT-SELTEXT_M = 'COUNTRY'. “column/field heading
APPEND W_FCAT TO T_FCAT. “append data from work area to internal table

*--- specify tables


TABLES: KNA1.

*--- specify types


TYPES: BEGIN OF TY_KNA1,
KUNNR TYPE KNA1-KUNNR,
NAME1 TYPE KNA1-NAME1,
ORT01 TYPE KNA1-ORT01,
LAND1 TYPE KNA1-LAND1,
END OF TY_KNA1.

*--- specify work area


DATA: W_KNA1 TYPE TY_KNA1.

*--- specify internal table


DATA: T_KNA1 TYPE STANDARD TABLE OF TY_KNA1
INITIAL SIZE 1.

*--- extract data


SELECT KUNNR NAME1 ORT01 LAND1
FROM KNA1
INTO TABLE T_KNA1.

** call function REUSE_ALV_GRID_DISPLAY:


7 Place cursor after the last line , click on ‘Pattern’ (Ctrl+F6)
8 Call function: REUSE_ALV_GRID_DISPLAY , continue(tick mark)
9 (Un-comment following 4 lines)
EXPORTING
IT_FIELDCAT = T_FCAT
TABLES
T_OUTTAB = T_KNA1
10 Save , Check , Activate , Continue (tick mark)
11 Execute (direct processing) F8
12 Report is successfully generated.
(we can customize the report by selecting various icons on the tool-bar)

REPORT: Hierarchial Sequential Report (using SELECT) [using 2 tables VBAK, VBAP]

Steps Action
1 SE38
2 Program name: ZmyHierALV (enter any name)
3 Create
4 Title: my report (enter any text)

SASIDHAR 9963855143
-25-
ABAP Lab-Guide

Type: Executable Program


5 Save , LocalObject
6 REPORT ZMYHIERALV.

TYPE-POOLS: SLIS.

*--- define the work area for the internal table


*--- to store the lay-out details.

DATA: W_FCAT TYPE SLIS_FIELDCAT_ALV.

*--- define the work area for the internal table


*--- to store the lay-out details.

DATA: T_FCAT TYPE SLIS_T_FIELDCAT_ALV.


DATA: W_KEYINFO TYPE SLIS_KEYINFO_ALV.

*--- type VBAK


TYPES: BEGIN OF TY_VBAK,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
NETWR TYPE VBAK-NETWR,
END OF TY_VBAK.

**--- type VBAP


TYPES: BEGIN OF TY_VBAP,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
ARKTX TYPE VBAP-ARKTX,
WERKS TYPE VBAP-WERKS,
END OF TY_VBAP.

**--- work area


DATA: W_VBAK TYPE TY_VBAK,
W_VBAP TYPE TY_VBAP.

**--- internal tables


DATA: T_VBAK TYPE STANDARD TABLE OF TY_VBAK INITIAL SIZE 1,
T_VBAP TYPE STANDARD TABLE OF TY_VBAP INITIAL SIZE 1.

**--- constants
CONSTANTS: C_VBAK TYPE SLIS_TABNAME VALUE 'W_VBAK',
C_VBAP TYPE SLIS_TABNAME VALUE 'W_VBAP'.

**--- define layout and fill the Catalog internal table


**--- VBAK
W_FCAT-COL_POS = 1. “1st column
W_FCAT-FIELDNAME = 'VBELN'. “field name
W_FCAT-SELTEXT_M = 'ORDER NO'. “column/field heading
W_FCAT-TABNAME = C_VBAK. “assign constant value
APPEND W_FCAT TO T_FCAT. “append work area value to internal table
**----------
W_FCAT-COL_POS = 2. “2nd column
W_FCAT-FIELDNAME = 'ERDAT'. “field name
W_FCAT-SELTEXT_M = 'ORDER DATE'. “column/field heading

SASIDHAR 9963855143
-26-
ABAP Lab-Guide

W_FCAT-TABNAME = C_VBAK. “assign constant value


APPEND W_FCAT TO T_FCAT. “append work area value to internal table
**----------
W_FCAT-COL_POS = 3. “3rd column
W_FCAT-FIELDNAME = 'NETWR'. “field name
W_FCAT-SELTEXT_M = 'ORDER VALUE'. “column/field heading
W_FCAT-TABNAME = C_VBAK. “assign constant value
APPEND W_FCAT TO T_FCAT. “append work area value to internal table

**---- VBAP
W_FCAT-COL_POS = 1. “1st column
W_FCAT-FIELDNAME = 'POSNR'. “field name
W_FCAT-SELTEXT_M = 'ITEM NO'. “column/field heading
W_FCAT-TABNAME = C_VBAP. “assign constant value
APPEND W_FCAT TO T_FCAT. “append work area value to internal table
*---------
W_FCAT-COL_POS = 2. “2nd column
W_FCAT-FIELDNAME = 'ARKTX'. “field name
W_FCAT-SELTEXT_M = 'ITEM DESC'. “column/field heading
W_FCAT-TABNAME = C_VBAP. “assign constant value
APPEND W_FCAT TO T_FCAT. “append work area value to internal table
*---------
W_FCAT-COL_POS = 3. “3rd column
W_FCAT-FIELDNAME = 'WERKS'. “field name
W_FCAT-SELTEXT_M = 'PLANT CODE'. “column/field heading
W_FCAT-TABNAME = C_VBAP. “assign constant value
APPEND W_FCAT TO T_FCAT. “append work area value to internal table
*---------

W_KEYINFO-HEADER01 = 'VBELN'.
W_KEYINFO-ITEM01 = 'VBELN'.

SELECT VBELN ERDAT NETWR


FROM VBAK
INTO TABLE T_VBAK.

SORT T_VBAK BY VBELN.

SELECT VBELN POSNR ARKTX WERKS


FROM VBAP
INTO TABLE T_VBAP
FOR ALL ENTRIES IN T_VBAK
WHERE VBELN = T_VBAK-VBELN.

SORT T_VBAP BY POSNR.

** call function REUSE_ALV_HIERSEQ_LIST_DISPLAY:


7 Place cursor after the last line , click on ‘Pattern’
8 Call function: REUSE_ALV_HIERSEQ_LIST_DISPLAY
(or select REUSE_ALV_HIERSEQ_GRID_DISPLAY)
9 (un-comment following 8 lines)
EXPORTING
IT_FIELDCAT = T_FCAT
I_TABNAME_HEADER = C_VBAK
I_TABNAME_ITEM = C_VBAP

SASIDHAR 9963855143
-27-
ABAP Lab-Guide

IS_KEYINFO = W_KEYINFO
TABLES
T_OUTTAB_HEADER = T_VBAK
T_OUTTAB_ITEM = T_VBAP
10 Save , Check , Activate , Continue (tick mark)
11 Execute
12 Report is successfully generated.
(we can customize the report by selecting various icons on the tool-bar)

REPORT: Simple Interactive Report [demo without data]

Steps Action
1 SE38
2 Program name: ZmyInterReport (give any name)
3 Create
4 Short Desc: (write any text)
Type: Executable Program
5 Save , LocalObject , [enter the following source codes]
6 REPORT ZMYINTERREPORT.

Write: / ‘This is the first MAIN screen of my report’.

*-- EVENT
At line-selection.

Case SY-LSIND.
When ‘1’
Write: / ‘this is the second screen’ , SY-LSIND.
When ‘2’
Write: / ‘this is the third screen’ , SY-LSIND.
When others.
Write: / SY-LSIND.
Endcase.
7 Save , check , activate , continue
8 Execute
9 Double-click on the screen headings to move to the next level of screens
(upto 21 screens)

REPORT: Complex Interactive Report (using SELECT) [with hot-spot] with 3 tables KNA1, VBAK,
VBAP. [using selection screen for parameter input]

Steps Action
1 SE38
2 Program name: ZmyInterReportComplex1 (give any name)
3 Create
4 Title: my report (write any text)
Type: Executable Program
5 Save , LocalObject , [enter the following source codes]

SASIDHAR 9963855143
-28-
ABAP Lab-Guide

6 REPORT ZMYINTERREPORTCOMPLEX1.

Tables: KNA1, VBAK, VBAP.

Select-options: cno for KNA1-kunnr. “cno = customer number


Parameters: cnt type KNA1-land1. “cnt = country

ULINE.
*--- column headings of table KNA1
Write: /5 ‘custno’,
20 ‘custname’,
40 ‘country’.

Select * from KNA1


where kunnr in cno
and cnt = land1.

*--- column/field contents of table KNA1


Write: /5 KNA1-kunnr color 6 inverse on HotSpot on,
20 KNA1-name1 color 4 inverse on,
40 KNA1-land1 color 3 inverse on.

Hide KNA1-kunnr.
Endselect.

**--- EVENT , when clicked on a line(row)


At line-selection.

Case SY-LSIND.
When ‘1’. “1st level screen
Write: /30 ‘Sales order information list’.
ULINE.
*--- column headings of table VBAK
Write: /5 ‘order no’,
20 ‘order date’,
60 ‘order value’.
ULINE.

Select * from VBAK


where kunnr = KNA1-kunnr.

*--- column/field contents of table VBAK


Write: /5 VBAK-vbeln color 5 inverse on HotSpot on,
20 VBAK-erdat color 6 inverse on,
60 VBAK-netwr color 5 inverse on.

Hide VBAK-vbeln.
Endselect.
Endcase.

**--- EVENT , when clicked on a line(row)


At line-selection.

Case SY-LSIND.
When ‘2’. “2nd level screen

SASIDHAR 9963855143
-29-
ABAP Lab-Guide

Write: /30 ‘Item information list’.


ULINE.
*--- column headings of table VBAP
Write: /5 ‘item no’,
21 ‘item description’,
61 ‘plant code’.
ULINE

Select * from VBAP


where vbeln = VBAK-vbeln.

*--- column/field contents of table VBAP


Write: /5 VBAP-posnr color 6 inverse on HotSpot on,
20 VBAP-arktx color 5 inverse on,
60 VBAP-werks color 3 inverse on.
Endselect.
Endcase.

7 Save , check , activate , continue


8 Execute
9 Enter:
Cno: 1000 to 1001
Cnt: DE (country code for Germany)
10 click ‘Execute’ F8
11 Report is generated successfully.
12 Click on HotSpot fields to jump over to next level
e.g. click on ‘custno’ 1000  click on ‘orderno’ 5069  click on ‘item no’ 10

REPORT: Complex Report with Reporting-Events (using SELECT) [2 tables KNA1, VBAK using
inner join]

Steps Action
1 SE38
2 Program name: ZmyComplexReport (give any name)
3 Create
4 Title: my report (write any text)
Type: Executable Program
5 Save , ‘Local object’ , [enter the following source codes]
6 REPORT ZMYCOMPLEXREPORT.

TABLES: KNA1, VBAK.

types: BEGIN OF ITAB ,


KUNNR TYPE KNA1-KUNNR,
NAME1 TYPE KNA1-NAME1,
LAND1 TYPE KNA1-LAND1,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
NETWR TYPE VBAK-NETWR,
END OF ITAB.

*--- define work-area

SASIDHAR 9963855143
-30-
ABAP Lab-Guide

data: wtab type ITAB.

*--- define internal table


data: t_itab type standard table of ITAB
with default key
initial size 1
with header line.

*--- define screen select options


SELECTION-SCREEN BEGIN OF BLOCK B1.
SELECT-OPTIONS: CNO FOR KNA1-KUNNR. “CNO = customer number
parameters: CNT type KNA1-land1. “CNT = country
SELECTION-SCREEN END OF BLOCK B1.

*--- top-of-page event


top-of-page.

*--- column/field headings


WRITE: /5 'CUSTNO',
15 'CUSTNAME',
35 'COUNTRY',
45 'SALESORDER',
60 'ORDER DATE',
75 'ORDER VALUE'.

ULINE. "underline

*--- event
start-of-selection.

*--- Query with INNER JOIN

SELECT K~KUNNR K~NAME1 K~LAND1


V~VBELN V~ERDAT V~NETWR
INTO TABLE t_ITAB
FROM KNA1 AS K
INNER JOIN
VBAK AS V
ON K~KUNNR = V~KUNNR
WHERE K~KUNNR IN CNO
AND K~LAND1 = cnt.

*-- show output


loop at t_itab into wtab.
WRITE: /5 wtab-KUNNR,
15 wTAB-NAME1,
35 wTAB-LAND1,
45 wTAB-VBELN,
60 wTAB-ERDAT,
75 wTAB-NETWR.

at end of kunnr.

SASIDHAR 9963855143
-31-
ABAP Lab-Guide

sum.
write:/ 'sub total of order value' , 100 wtab-netwr.
endat.

endloop.

**---Event
end-of-page.
ULINE.
7 Save , check , activate , continue
8 Execute
9 Enter: Cno: 1000 to 1002
Cnt: DE (country code for Germany)

click ‘Execute’ F8
10 Report is generated with control breaks and sub-totals

ABAP DICTIONARY: create Type-Group [User Defined TYPE]

Steps Action
1 SE11
2 Select radio-button, ‘Type Group:’ Zmy1 (give any name)
3 Create
4 Short text:
5 Save
6 types: zmy1_name(10) type c,
zmy1_numc type i.

types: begin of zmy1_temp,


A type i,
B type i,
end of zmy1_temp.
7 Save , check , activate , continue (tick mark) , back
8 SE38
9 Program name: ZmyTypeProgram (give any name)
10 Create
11 Short desc:
Type: executable program
12 Save , ‘Local object’ , enter the following source codes
13 type-pools: zmy1.

data: w_itab type zmy1_temp,


c type zmy1_numc.

w_itab-a = 10.
w_itab-b = 20.

c = w_itab-a + w_itab-b.

write: / c.
14 Save , check , activate , continue(tick mark)

SASIDHAR 9963855143
-32-
ABAP Lab-Guide

15 Execute

ABAP DICTIONARY: create User Defined TABLE [ ZmyEMPt , ZmyDEPT ] see step-13,24

Steps Action
1 SE11
2 Select radio-button, ‘Data type:’ YmyTP , ‘Create’ (create data element to link 2 tables)
3 Select radio-button, ‘Data element’ , click on ‘Continue’ (tick-mark) in pop-up box
** DataType(TAB):
4 Short description: (enter any text)

DataType(TAB)
Select radio-button, ‘Built-in-type’
Data type: NUMC
Length: 10
** Field label(TAB):
6 Field label(TAB)

Length Field label


Short 10 empno
7 Save , LocalObject, check , activate , continue (tick-mark) , back(F3)
** create 1st table, ZmyEMPt:
8 Select radio-button, ‘Database table:’ ZmyEMPt (give any name)
9 Short description: (enter any text)
** Delivery & Maintenance(TAB):
11 Delivery & Maintenance(TAB)

Delivery class: A [application table (master & transaction data)]


Data browser/table view maint: Display maintenance allowed [select from list box]
** Fields(TAB):
13 Fields(TAB)

Field Key DataElement Dtype Length Short description


Empno tick NUMC 10
Empname CHAR 10
Deptno YmyTP[see step-2]

(Note: click on ‘Built-in type’ to select NUMC, CHAR


click on ‘Data Element’ to enter YmyTP, and press ENTER key to fill in Dtype , Length)
14 Save, LocalObject, ‘continue’(tick-mark)
15 Click on ‘Technical Settings’ (ctrl+shift+F9) on tool-bar
16 Data class: APPL0 [select from list box, choose(F2)] (master data, transparent tables)
17 Size category: 0 (zero)
Select radio-button, ‘Buffering NOT allowed’
18 Save , check , activate(revised<->active)shift+F8 , continue (tick-mark) , back(F3), back(F3)
** create 2nd table, ZmyDEPT:
19 Select radio-button, ‘Database table:’ ZmyDEPT (give any name)
20 Short description: (enter any text)
** Delivery & Maintenance(TAB):

SASIDHAR 9963855143
-33-
ABAP Lab-Guide

22 Delivery & Maintenance(TAB)

Delivery class: A [application table (master & transaction data)]


Data browser/table view maint: Display maintenance allowed [select from list box]
** Fields(TAB):
24 Fields(TAB)

Field Key DataElement Dtype Length Short description


Depno tick YmyTP [see step-2]
Depname CHAR 20

(Note: click on ‘Built-in type’ to select CHAR


click on ‘Data Element’ to enter YmyTP, and press ENTER key to fill in Dtype , Length)
25 Save, LocalObject, ‘continue’(tick-mark)
26 Click on ‘Technical Settings’ on tool-bar
27 Data class: APPL0 [select from list box, choose(F2)] (master data, transparent tables)
28 Size category: 0 (zero)
Select radio-button, ‘Buffering NOT allowed’
29 Save , check , activate(revised<->active)shift+F8 , continue (tick-mark) , back(F3)
** enter data into table ZmyDEPT:
30 To enter data into table: [Note: table must be activated first (click ‘activate’,’continue’]
select from menu-bar, Utilities  TableContents  CreateEntries
31 Enter record one by one & click SAVE (crtl+S) to store data into table
Back (F3)
32 To view data from table: [Note: table must be activated first (click ‘activate’,’continue’]
select from menu-bar, Utilities  TableContents  Display , Execute(F8)

Create ‘FOREIGN KEY’ to link tables: (ZmyEMPt , ZmyDEPT)


NOTE: 2 tables can be linked, only by using user defined ‘data element’
[see step-13, step-24]
1 Select the row containing field name Deptno [see step-13]
2 Click on ‘Foreign Key’ icon (in ‘Fields’ TAB)
3 Short text: linking two tables (give any text)
Check table: ZmyDEPT [see step-19] (Note: give the other table name e.g. ZmyDEPT)
4 Click on ‘Generate Proposal’ (Fields are filled with values)
5 Click on Copy (tick-mark)
6 Save , continue, check , activate, continue(tick-mark)
** enter data into table ZmyEMPt:
7 To enter data into table: [Note: table must be activated first (click ‘activate’,’continue’]
select from menu-bar, Utilities  TableContents  CreateEntries
8 Enter record one by one & click ‘SAVE’ to store data into table
(Note: when DEPTNO is selected a list-box icon appears in right corner)
9 Select ‘Deptno’ from the list-box or enter the value
10 To view data from table:
select from menu-bar, Utilities  TableContents  Display

SCREEN: Simple Screen Program: (Executable Program) with inputBox, checkboxes, commandButton

SASIDHAR 9963855143
-34-
ABAP Lab-Guide

Steps Action
1 SE38
2 Program: ZMYSCREEN (enter any name)
3 Create
4 Title: my screen program (enter any text)
5 Type: Executable Program
6 Save , LocalObject , continue
7 Enter the line call screen 100. after REPORT ZMYSCREEN
8 REPORT ZMYSCREEN.

CALL SCREEN 100.


9 Dbl. Click on screen number 100.
10 Click ‘Yes’ in pop-up box , click ‘Yes’ in next pop-up box
11 Short description: my screen (enter any text)
** Layout ctrl+F7:
12 Click ‘Layout’ to design the screen
13 Drag and drop following control elements from the left side Tool-Box into the work-area
a Input box , two check boxes and a command button
14 Dbl. click on INPUT-BOX to enter properties:
I/O box
Name: IO1
15 Dbl. click on 1st CHECK-BOX (to enter properties)
CheckBox-1
Name: CB1
Text: SAP
FctCode: EX1
16 Dbl. click on 2nd CHECK-BOX (to enter properties)
CheckBox-2
Name: CB2
Text: ABAP
FctCode: EX2
17 Dbl. click on COMMAND-BUTTON (to enter properties)
PushButton
Name: CMD1
Text: EXIT
FctCode: EX

[NOTE: Ok type(hidden. system default) OK ]


** Flow Logic:
18 Click ‘Flow Logic’ to define the program flow
19 Flow logic(TAB) [other tabs are ‘Attributes’, ‘Element list’]

PROCESS BEFORE OUTPUT.


* MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.

20 Un-comment the line MODULE USER_COMMAND_0100.


21 Dbl. click on the module name USER_COMMAND_0100.
22 You are in the program editor now
23 Enter the following codes between the lines..

SASIDHAR 9963855143
-35-
ABAP Lab-Guide

MODULE USER_COMMAND_0100 INPUT.

ENDMODULE. " USER_COMMAND _0100 INPUT


24
MODULE USER_COMMAND_0100 INPUT.

DATA: CB1 TYPE C,


CB2 TYPE C,
IO1(5) TYPE C.

CASE SY-UCOMM.
WHEN 'EX'.
LEAVE PROGRAM.

WHEN 'EX1'.
IF CB1 = 'X'.
IO1 = 'SAP'.
ELSE.
IO1 = ' ' .
ENDIF.

WHEN 'EX2'.
IF CB2 = 'X'.
IO1 = 'ABAP'.
ELSE.
IO1 = ' ' .
ENDIF.
ENDCASE.

ENDMODULE. " USER_COMMAND _0100 INPUT


25 Save , check , activate , continue(tick-mark)
26 Execute

SCREEN: Simple Screen Program: (Module Pool) with inputBox, checkboxes, commandButton

Steps Action
1 SE38
2 Program: ZMYSCREEN1 (enter any name)
3 Create
4 Title: (enter any text)
5 Type: Module Pool
6 Save, LocalObject, continue
7 Enter the line call screen 100. after PROGRAM ZMYSCREEN1.
8 PROGRAM ZMYSCREEN1.

CALL SCREEN 100.


9 Dbl. click on the screen number 100
10 Click ‘Yes’ in pop-up box , click ‘Yes’ in next pop-up box
11 Short description: my screen (enter any text)
** Layout ctrl+F7:
12 Click ‘Layout’ to design the screen
13 Drag and drop following control elements from the left side Tool-Box into the work-area

SASIDHAR 9963855143
-36-
ABAP Lab-Guide

a Input box , two check boxes and a command button


14 Dbl. click on INPUT-BOX to enter properties:
I/O box
Name: IO1
15 Dbl. click on 1st CHECK-BOX (to enter properties)
CheckBox-1
Name: CB1
Text: SAP
FctCode: EX1
16 Dbl. click on 2nd CHECK-BOX (to enter properties)
CheckBox-2
Name: CB2
Text: ABAP
FctCode: EX2
17 Dbl. click on COMMAND-BUTTON (to enter properties)
PushButton
Name: CMD1
Text: EXIT
FctCode: EX

[NOTE: Ok type(hidden. system default) OK ]


** Flow Logic:
18 Click ‘Flow Logic’ to define the program flow
19 Flow logic(TAB) [other tabs are ‘Attributes’, ‘Element list’]

PROCESS BEFORE OUTPUT.


* MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.

20 Un-comment the line MODULE USER_COMMAND_0100.


21 Dbl. click on the line MODULE USER_COMMAND_0100.
22 You are in the program editor now
23 Enter the following codes between the lines..

MODULE USER_COMMAND_0100 INPUT.

ENDMODULE. " USER_COMMAND _0100 INPUT


24
MODULE USER_COMMAND_0100 INPUT.

DATA: CB1 TYPE C,


CB2 TYPE C,
IO1(5) TYPE C.

CASE SY-UCOMM.
WHEN 'EX'.
LEAVE PROGRAM.

WHEN 'EX1'.
IF CB1 = 'X'.
IO1 = 'SAP'.
ELSE.
IO1 = ' ' .

SASIDHAR 9963855143
-37-
ABAP Lab-Guide

ENDIF.

WHEN 'EX2'.
IF CB2 = 'X'.
IO1 = 'ABAP'.
ELSE.
IO1 = ' ' .
ENDIF.
ENDCASE.

ENDMODULE. " USER_COMMAND _0100 INPUT


25 Comment or delete the line CALL SCREEN 100.
26 Save , check , activate , continue(tick-mark)
27 NOTE: you cannot Execute a ‘Module Pool’ program by clicking “Execute’ button.
You need to create a TRANSACTION-CODE to execute this program.

Transaction Code: creation

Steps Action
1 SE93
Transaction code: ZmyTrans1 (first letter must be Z or Y)
Create
Short text: (enter any text)
Select radio-button ‘Program and Screen (dialog transaction)’
Click ‘continue’ (enter)
Program: ZMYSCREEN1 (the module pool program name)
Screen number: 100 (same as module pool screen number)
Save, package: $TMP , localObject
Transaction code ZmyTrans1 is created
Enter ZmyTrans1 to execute the module pool program ‘ZMYSCREEN1’

SCREEN: Screen Program (with Table-Control)

Steps Action
1 REPORT ZSANSCREENPRG3 .

*REPORT demo_dynpro_tabcont_loop.

CONTROLS flights TYPE TABLEVIEW USING SCREEN 101.

TABLES: demo_conn, spfli.

DATA: itab TYPE TABLE OF demo_conn,


fill TYPE i.

CALL SCREEN 101.

MODULE status_0101 OUTPUT.

SASIDHAR 9963855143
-38-
ABAP Lab-Guide

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.

SET PF-STATUS 'SCREEN_101'.


DESCRIBE TABLE itab LINES fill.
flights-lines = fill.
ENDMODULE.

MODULE fill_table_control OUTPUT.


READ TABLE itab INTO demo_conn INDEX flights-current_line.
ENDMODULE.

*&---------------------------------------------------------------------*
*& Module exit INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE exit INPUT.
case sy-ucomm.
when 'EX'.
leave program.
endcase.
ENDMODULE. " exit INPUT

[Note: ‘spfli’ is a TABLE. Whereas ‘demo_conn’ is a VIEW]


** Flow Logic:
2 PROCESS BEFORE OUTPUT.
MODULE STATUS_0101.
LOOP WITH CONTROL FLIGHTS.
MODULE FILL_TABLE_CONTROL.
ENDLOOP.

PROCESS AFTER INPUT.


LOOP WITH CONTROL FLIGHTS.

ENDLOOP.

module exit.

** Layout:ctrl+F7
3 Table control
Name: FLIGHTS

Table-name: DEMO_CONN
Fileds:
CARRID
CONNID
CITYFROM
CITYTO

SASIDHAR 9963855143
-39-
ABAP Lab-Guide

SCREEN: Screen Program (with TabStripControl)

Steps Action
1 SE38
2 Program: zdemo_dynpro_tabstrip_local (enter any name)
3 Create
4 Title: (enter any text)
5 Type: Executable Program
6 Save
7
REPORT ZDEMO_DYNPRO_TABSTRIP_LOCAL.

CONTROLS mytabstrip TYPE TABSTRIP.

DATA: ok_code TYPE sy-ucomm,


save_ok TYPE sy-ucomm.

DATA: NUM1 TYPE i,


NUM2 TYPE i,
ANS TYPE p decimals 2.

DATA: ADD(1) TYPE C,


SUB(1) TYPE C,
MUL(1) TYPE C,
DIV(1) TYPE C.

mytabstrip-activetab = 'PUSH1'.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.


SET PF-STATUS 'SCREEN_100'.
SET TITLEBAR 'MYTITLE'.
ENDMODULE.

MODULE cancel INPUT.


LEAVE PROGRAM.
ENDMODULE.

MODULE user_command INPUT.


save_ok = ok_code.
CLEAR ok_code.
IF save_ok = 'OK'.
MESSAGE i888(sabapdocu) WITH 'MYTABSTRIP-ACTIVETAB ='
mytabstrip-activetab.
ENDIF.
ENDMODULE.

MODULE calculation.

CASE SY-UCOMM.
WHEN 'RADIO'.
IF ADD = 'X'.
ANS = NUM1 + NUM2.

SASIDHAR 9963855143
-40-
ABAP Lab-Guide

mytabstrip-activetab = 'PUSH3'.

ELSEIF SUB = 'X'.


ANS = NUM1 - NUM2.
mytabstrip-activetab = 'PUSH3'.

ELSEIF MUL = 'X'.


ANS = NUM1 * NUM2.
mytabstrip-activetab = 'PUSH3'.

ELSEIF DIV = 'X'.


ANS = NUM1 / NUM2.
mytabstrip-activetab = 'PUSH3'.

ENDIF.
ENDCASE.

ENDMODULE.

Note: dbl-click SCREEN_100, MYTITLE to define PF-STATUS , TITLEBAR


create screen: 100
8 double-click on screen number 100 to create screen 100
** Flow Logic: screen 100
9 PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
CALL SUBSCREEN: SUB1 INCLUDING SY-REPID '0110',
SUB2 INCLUDING SY-REPID '0120',
SUB3 INCLUDING SY-REPID '0130'.
PROCESS AFTER INPUT.
MODULE CANCEL AT EXIT-COMMAND.
CALL SUBSCREEN: SUB1,
SUB2,
SUB3.
MODULE USER_COMMAND.

** Layout screen 100


10 Note: place a tabStrip control with 3 tabs
(each tab containing a subscreen area)

tabstrip control:
name: MYTABSTRIP
tab title: 3

(tab1)push-button:
name: PUSH1
text: Tab_page_1
fctCode: PUSH1

(tab2)push-button:
name: PUSH2
text: Tab_page_2
fctCode: PUSH2

(tab3)push-button:
name: PUSH3
text: Tab_page_3
fctCode: PUSH3

SASIDHAR 9963855143
-41-
ABAP Lab-Guide

subscreen area(1):
name: SUB1

subscreen area(2):
name: SUB2

subscreen area(3):
name: SUB3

push-button:
name: BUTTON
text: Cont.
icon: ICON_OKAY
fctCode: OK

system-defined hidden field:


type: OK
name: OK_CODE

Create sub-screen: 110


11 SE51
12 Program: ZDEMO_DYNPRO_TABSTRIP_LOCAL [see step-1]
Screen number: 0110
13 Create
14 Short description: sub screen 1 (give any text)
15 Select radio-button ‘SubScreen’ under ‘Screen Type’
16 Layout subScreen 110: Click ‘Layout’ on tool-bar
17 Note: place a text-field near top-left corner of the screen

Text-field:
Name: TEXT1
Text: Subscreen 1

Note: place 2 text-fields and


2 i/o fields

Text-field:
Name: LABEL1
Text: Number1:

Text-field:
Name: LABEL2
Text: Number2:

i/o-field:
Name: NUM1

i/o-field:
Name: NUM2

Note: select ‘Element list’ -> ‘General attr’ tab.


for NUM1 and NUM2 i/o fields , select format as ‘NUMC’ (to disallow entry of
characters in the input fields)
18 Save , activate

SASIDHAR 9963855143
-42-
ABAP Lab-Guide

Create sub-screen: 120


19 Program: ZDEMO_DYNPRO_TABSTRIP_LOCAL [see step-1]
Screen number: 0120
20 Create
21 Short description: sub screen 2 (give any text)
22 Select radio-button ‘SubScreen’ under ‘Screen Type’
23 Layout subScreen 120: Click ‘Layout’ on tool-bar
24 Note: place a text-field near top-left corner of the screen

Text-field:
Name: TEXT2
Text: Subscreen 2

Note: place 4 radio buttons

Radio-button:
name: ADD
text: Addition
fctCode: RADIO

Radio-button:
name: SUB
text: Subtraction
fctCode: RADIO

Radio-button:
name: MUL
text: Multiplication
fctCode: RADIO

Radio-button:
name: DIV
text: Division
fctCode: RADIO

flow logic: subScreen 120


PROCESS BEFORE OUTPUT.
PROCESS AFTER INPUT.

module calculation.

25 Save, activate

Create sub-screen: 130


26 Program: ZDEMO_DYNPRO_TABSTRIP_LOCAL [see step-1]
Screen number: 0130
27 Create
28 Short description: sub screen 3 (give any text)
29 Select radio-button ‘SubScreen’ under ‘Screen Type’
30 Layout subScreen 130: Click ‘Layout’ on tool-bar
31 Note: place a text-field near top-left corner of the screen

Text-field:
Name: TEXT3

SASIDHAR 9963855143
-43-
ABAP Lab-Guide

Text: Subscreen 3

Note: place a text-field and


a i/o-field

Text-field:
Name: RESULT
Text: Result

i/o-field:
Name: ANS
remove Tick-mark from ‘input field’ to make it read only

Note: select Tab ‘Element list’ -> ‘General attr’ .


for ANS i/o field, select format as ‘INT4’ (to allow decimal places and disallow entry of
characters in the input field)
Save, activate

execute the screen program


go to source-code of screen-program ZDEMO_DYNPRO_TABSTRIP_LOCAL
click Check(ctrl+F2) , Activate(ctrl+F3) , Execute(Direct processing F8)

SCREEN: Screen Program – data insert, update, delete in user defined table (using Table Control)

Steps Action
1 create an user-defined table ‘ZAJDEPT’

field type length key


DNO NUMC 10 tick
DNAME CHAR 10

Note: DNO is a primary key field


see ‘ABAP Dictionary - create user-defined tables’..
2 SE38
3 Program: ZSANDATAENTRYSCREEN (enter any name)
4 Create
5 Title: (enter any text)
6 Type: Executable Program
7 Save
** Program source code:
8
REPORT ZSANDATAENTRYSCREEN.

CONTROLS MY_TBL_CTRL TYPE TABLEVIEW USING SCREEN 100.

TABLES: ZAJDEPT.

SASIDHAR 9963855143
-44-
ABAP Lab-Guide

DATA: itab TYPE TABLE OF ZAJDEPT,


fill TYPE i.

DATA: IO_DNO type ZAJDEPT-DNO,


IO_DNAME type ZAJDEPT-DNAME.

DATA: IO_STATUS(40) type C.

call screen 100.

*---[MODULE] STATUS_010
MODULE STATUS_0100 OUTPUT.
SELECT * FROM ZAJDEPT INTO CORRESPONDING FIELDS OF TABLE itab.

DESCRIBE TABLE itab LINES fill.


MY_TBL_CTRL-lines = fill.
ENDMODULE. " STATUS_0100 OUTPUT

*---[MODULE] FILL TABLE CONTROL


MODULE fill_table_control OUTPUT.
READ TABLE itab INTO ZAJDEPT INDEX MY_TBL_CTRL-current_line.
ENDMODULE.

*---[MODULE] BUTTON ACTION


MODULE button_action INPUT.

CASE SY-UCOMM.

*--- EXIT
WHEN 'EXIT'.
LEAVE PROGRAM.

*--- INSERT
WHEN 'INSERT'.
ZAJDEPT-DNO = IO_DNO.
ZAJDEPT-DNAME = IO_DNAME.
INSERT ZAJDEPT.

IF SY-SUBRC <> 0.
IO_STATUS = 'SORRY! ENTRY ALREADY EXISTS'.
ELSE.
IO_STATUS = 'INSERTED DATA SUCCESSFULLY'.
ENDIF.

*--- UPDATE
WHEN 'UPDATE'.
ZAJDEPT-DN0 = IO_DNO.
ZAJDEPT-DNAME = IO_DNAME.
UPDATE ZAJDEPT.

IF SY-SUBRC <> 0.
IO_STATUS = 'SORRY! RECORD DOES NOT EXIST'.

SASIDHAR 9963855143
-45-
ABAP Lab-Guide

ELSE.
IO_STATUS = 'UPDATED DATA SUCCESSFULLY'.
ENDIF.

*--- DELETE
WHEN 'DELETE'.
ZAJDEPT-DN0 = IO_DNO.
DELETE ZAJDEPT.

IF SY-SUBRC <> 0.
IO_STATUS = 'SORRY! RECORD DOES NOT EXIST'.
ELSE.
IO_STATUS = 'DELETED RECORD SUCCESSFULLY'.
ENDIF.

ENDCASE.

ENDMODULE. " button_action INPUT

create screen: 100


9 double-click on screen number 100
** Flow Logic:
10
*--- PBO
PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

LOOP WITH CONTROL MY_TBL_CTRL.


MODULE FILL_TABLE_CONTROL.
ENDLOOP.

*--- PAI
PROCESS AFTER INPUT.

LOOP WITH CONTROL MY_TBL_CTRL.

ENDLOOP.

MODULE button_action.

** Layout:
11
text-field:
name: LABEL_HEADING
text: DATA_management_in_table_ZAJDEPT-_by_Santanu

Box:
name: BOX_DATA_ENTRY
text: data_entry

Note: place the following 4 fields inside the rectangular BOX area BOX_DATA_ENTRY

text-field:

SASIDHAR 9963855143
-46-
ABAP Lab-Guide

name: LABEL_DNO
text: Department_no:

i/o-field:
name: IO_DNO
format: NUMC

text-field:
name: LABEL_DNAME
text: Department_name:

i/o-field:
name: IO_DNAME
format: CHAR

i/o-field:
name: IO_STATUS
input field: <remove tick mark> to use it as read only field

table-control:
name: MY_TBL_CTRL
seperators: vertical, horizontal <select tick mark>

Note: [it is used to display table contents during runtime]


click on ‘Dictionary/program fields window (F6)’ icon on the tool-bar.
enter ‘ZAJDEPT’ in the Table/Field name text-box and press ‘ENTER’ key.
select fields.. DNO, DNAME by clicking on the extreme left button.
place the selected fields inside the table-control MY_TBL_CTRL

push-button:
name: INSERT
text: Insert_data
fctCode: INSERT

push-button:
name: UPDATE
text: Update_data
fctCode: UPDATE

push-button:
name: DELETE
text: Delete_data
fctCode: DELETE

push-button:
name: EXIT
text: Exit
fctCode: EXIT

SASIDHAR 9963855143
-47-
ABAP Lab-Guide

12 Save, activate
13 click on Back(F3) icon to go back to program source code screen
14 Save, check, activate, Execute
15 Now you can insert, modify , delete data in your table ZAJDEPT [see step-1]

BDC: (Batch Data Communication) is used to MIGRATE data from SAP to SAP system or from a non-
SAP legacy-system to SAP system.

Different methods of BDC are:

(a) Call-Transaction - method


(b) Session - method
(c) LSMW (Legacy System Migration Workbench) - tool

In all the above methods you have to prepare a flat file containing the data in the required format to be
uploaded to the SAP system. You need to call the function ' UPLOAD' to do this. Then the contents of the
flat file have to copied to your internal table and then u need to call the transaction through which you want
to update the database. You internal table should also have the information relating to the structure
BDCDATA which is having the details like the module pool program name, screen no. The basic concept of
updating the database is same in all the 3 methods but only the method differs.

In session method after the data transfer program is coded, in order to process that particular session you
have to go to TC: SM 35 to process the session.

BDC: Call-Transaction – method (migrate data from text file ‘c:\my.txt’ to table LFA1)

Steps Action

Note: to avoid obstacle during data migration process remember the following points..

a) view the destination table(LFA1) data before data migration [using SE16. see step-37]

b) for example, if the last record data in table:LFA1, field:LIFNR(vendor code) is 1600, then the
first value of the same field in data file ‘C:\MY.TXT’ should be 1602 (1600+2).

c) during recording process a set of data is entered through the screen, which also gets
inserted into the same table (LFA1). Ensure that LIFNR(vendor code) value during screen-
recording is given as 1601 (1600+1) [see step-6] and the same value does not exist in table LFA1.

d) there should not be any duplicate data in LIFNR (it is a primary field with unique data)

** create data file:


1 [see step-37] to view content of table LFA1 before migrating the data

SASIDHAR 9963855143
-48-
ABAP Lab-Guide

Create tab-separated text file (c:\my.txt) to store sample data:

1602 0001 0001 ANIL YR IN INR


1603 0001 0001 SAM AV IN INR

Note: 1st column data should not exist in table LFA1


1st column represents LIFNR(vendor code)
2nd column represents EKORG(purchase organization)
3rd column represents KTOKK(account group)
4th column represents NAME1(name)
5th column represents SORTL(search term)
6th column represents LAND1(country)
7th column represents WAERS(currency)

** Recording:
2 SHDB (transaction code for) Transaction Recorder: recording overview
3 Click ‘New recording’ on tool-bar
4 (in pop-up window..)
Recording: ZmyRec (give any name)
Transaction code: MK01 (prepare a technical Log for MK01)

(Note: MK01 is the transaction-code for SAP standard data entry screen create vendor –
purchasing )
5 Click on ‘Start recording’
6
Vendor: 1601 (select a non-existing vendor code)
Purchase organization: 0001 (give any code)
Account group: 0001 (give any code)

Press ‘Enter’ key

Name: santanu
Search term: SN
Country: IN

Press ‘Enter’ key , ‘Enter’ key… to move to next page

Currency: INR

Press ‘Enter’ key

(Note: this record also gets inserted into table LFA1)


(provide data for mandatory fields…flagged with tick-marks)
7 Save(ctrl+S) , Save(ctrl+S) [technical Log is created] , Back(F3)
8 Recording: ZmyRec [see step-4] (select from List)
** generate program codes:
9 Click on ‘Program’ (shift+F5) on tool-bar
10 Program name: ZmyCallTrans (give any name)
Select radio-button ‘Transfer from recording’
Click ‘continue’ (tick-mark)
11 Title: BDC call transaction (enter any text)
Type: Executable program
12 Click on ‘Source Code’ (F5), ‘Local Object’
13 Auto generated program is displayed

SASIDHAR 9963855143
-49-
ABAP Lab-Guide

14 Save , go back to initial screen by clicking ‘Back’(F3) few times


** program source codes (add/modify):
15 SE38 (transaction code for ABAP editor)
16 Program name appears (e.g. ZmyCallTrans) [see step-10]
17 Click on ‘Change’
18 (Add following codes after the line ‘report ZMYCALLTRANS …..’ )

*--- define source internal table


Data: begin of ITAB occurs 1,
F1 type LFA1-LIFNR,
F2 type LFA1-EKORG,
F3 type LFA1-KTOKK,
F4 type LFA1-NAME1,
F5 type LFA1-SORTL,
F6 type LFA1-LAND1,
F7 type LFA1-WAERS,
End of ITAB.

*--- create destination internal table


Data: JTAB type BDCDATA occurs 1 with header line.

19 Dbl. click on the line ‘Include BDCRECx1’


20 Click ‘YES’ in the pop-up box
21 Click on ‘Display’ (F7)
22 Copy last two code blocks, ‘Start new screen’, ‘Insert field’
23 Back(F3)
24 Paste the copied blocks [see step-22] after the line ‘perform close_group’
25 Place cursor just after the line ‘perform open_group’
26 Ctrl+F6 or Click on ‘Pattern’ (to select the function name and generate codes)
27 Call function: WS_UPLOAD , click on ‘continue’ (tick-mark)

Note: WS_UPLOAD (for 4.6c) , GUI_UPLOAD (for 4.7e)


If any Warning message-box appears, just click on Tick-mark
28 (Un-comment these 4 lines)
EXPORTING
Filename: ‘ C:\my.txt ‘ [see step-1] (Note: blank space before and after the file name)
Filetype: ‘DAT’ (for tab separated fields) (Note: in CAPS only)
Data_tab: ITAB [see step-23]

(you may delete the extra commented lines for readability. But not mandatory)
29 (Replace particular fields with Internal-table fields)
e.g.

perform bdc_field using 'RF02K-LIFNR'


ITAB-F1.
perform bdc_field using 'RF02K-EKORG'
ITAB-F2.
perform bdc_field using 'RF02K-KTOKK'
ITAB-F3.
perform bdc_field using 'LFA1-NAME1'
ITAB-F4.
perform bdc_field using 'LFA1-SORTL'
ITAB-F5.
perform bdc_field using 'LFA1-LAND1'
ITAB-F6.

SASIDHAR 9963855143
-50-
ABAP Lab-Guide

perform bdc_field using 'LFM1-WAERS'


ITAB-F7.
30 (Delete following 5 lines..)

Include bdcrecx1.
Start_of_selection.
Perform open_group.

Perform bdc_transaction using ‘MK01’.


Perform close_group.
31 (Place cursor just before the 1st line of ‘perform bdc_ …..’ and add the following 2 lines)
LOOP AT ITAB.
REFRESH JTAB.
32 (Place cursor just after the last line of ‘perform bdc_ …..’ and add the following 2 lines)
CALL TRANSACTION 'MK01' USING JTAB MODE 'A'.
ENDLOOP.
33 (under the bottom 2 code-blocks ‘start new screen’ , ‘insert field’ , Replace all…)
BDCDATA with JTAB
34 (under the bottom code-block ‘insert field’ , Replace …)
NoData with ‘ ‘ or SPACE
35 Save , Check , Activate, continue(tick-mark) , Execute , Continue (tick-mark) in pop up box
36 Click on ‘Enter’ key many times (still the recording procedure is complete).
** view contents of Table LFA1:
37 (Note: use steps 37-40 to view data before and after migration)

SE16 (transaction code) to view newly migrated data from file ‘C:\my.txt’ [see step-1]
38 Table name: LFA1 , click on ‘Table Contents’ icon (F7)
39 Cno: 1600 to 1650 (enter any vendor-code range) [this step is optional]
40 Execute
Note: ** completed program should look like this:
Report ZMYCALLTRANS no standard page heading line-size 255.

*--- define source internal table


data: begin of ITAB occurs 1,
F1 type LIFNR,
F2 type EKORG,
F3 type KTOKK,
F4 type NAME1,
F5 type SORTL,
F6 type LAND1,
F7 type WAERS,
end of ITAB.

*--- create destination internal table


data: JTAB type BDCDATA occurs 1 with header line.

*--- upload source data from flatfile to source internal table


CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = ' C:\MY.TXT '
FILETYPE = 'DAT'
TABLES
DATA_TAB = ITAB.

SASIDHAR 9963855143
-51-
ABAP Lab-Guide

LOOP AT ITAB.
REFRESH JTAB.

perform bdc_dynpro using 'SAPMF02K' '0107'.


perform bdc_field using 'BDC_CURSOR'
'RF02K-KTOKK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
ITAB-F1.
perform bdc_field using 'RF02K-EKORG'
ITAB-F2.
perform bdc_field using 'RF02K-KTOKK'
ITAB-F3.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-DATLT'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFA1-NAME1'
ITAB-F4.
perform bdc_field using 'LFA1-SORTL'
ITAB-F5.
perform bdc_field using 'LFA1-LAND1'
ITAB-F6.
perform bdc_dynpro using 'SAPMF02K' '0120'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0310'.
perform bdc_field using 'BDC_CURSOR'
'LFM1-WAERS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFM1-WAERS'
ITAB-F7.
perform bdc_dynpro using 'SAPMF02K' '0320'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-LIFNR'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
CALL TRANSACTION 'MK01' USING JTAB MODE 'A'.
ENDLOOP.

*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR JTAB.
JTAB-PROGRAM = PROGRAM.
JTAB-DYNPRO = DYNPRO.
JTAB-DYNBEGIN = 'X'.
APPEND JTAB.
ENDFORM.

SASIDHAR 9963855143
-52-
ABAP Lab-Guide

*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> SPACE.
CLEAR JTAB.
JTAB-FNAM = FNAM.
JTAB-FVAL = FVAL.
APPEND JTAB.
ENDIF.
ENDFORM.

Note: for subsequent data transfer follow the steps below:


a) change the data in file (c:\my.txt) [see step-1]
b) create a fresh recording with new set of data [step2 – step7]
c) execute the progra ZmyCallTrans [see step-15,16]
d) view the newly inserted data in table LFA1 [step37 - step40]

BDC: Session - method

Steps Action

Note: to avoid obstacle during data migration process remember the following points..

a) view the destination table(LFA1) data before data migration [using SE16]

b) for example, if the last record data in table:LFA1, field:LIFNR(vendor code) is 1600, then the
first value of the same field in data file ‘C:\MY.TXT’ should be 1602 (1600+2).

c) during recording process a set of data is entered through the screen, which also gets
inserted into the same table (LFA1). Ensure that LIFNR(vendor code) value during screen-
recording is given as 1601 (1600+1) [see step-25]and the same value does not exist in table
LFA1.

d) there should not be any duplicate data in LIFNR (it is a primary field with unique data)

*** Same as BDC-Call transaction. (just add the following steps) ***

1 Create tab-separated text file (c:\my.txt) to store sample data:

1602 0001 0001 ANIL YR IN INR


1603 0001 0001 SAM AV IN INR

Note: 1st column data should not exist in table LFA1


1st column represents LIFNR(vendor code)
2nd column represents EKORG(purchase organization)
3rd column represents KTOKK(account group)
4th column represents NAME1(name)
5th column represents SORTL(search term)
6th column represents LAND1(country)
7th column represents WAERS(currency)

SASIDHAR 9963855143
-53-
ABAP Lab-Guide

2 SE38
3 Program: ZmySessionTrans (enter any name)
4 Create
5 Title: my BDC session transaction (enter any text)
Type: Executable Program
6 Save , LocalObject
7 Copy and paste entire Call-transaction program codes already done.
8 Place cursor just before the line ‘Loop at ITAB’
** call function BDC_OPEN_GROUP:
9 Ctrl+F6 or Click on ‘Pattern’ (to select the function name and generate codes)
10 Call function: BDC_OPEN_GROUP , click on continue (tick mark)
11 (Un-comment following 4 lines)
EXPORTING
Client = sy-mandt (Note: represents login ClientNumber. e.g. ‘800’)
Group = ‘mySession’ (Note: represents SessionName) [give any name]
User = sy-uname (Note: represents login UserName. e.g. ‘sapuser’)
12 Place cursor just before the line ‘ENDLOOP’
** call function BDC_INSERT:
13 Ctrl+F6 or Click on ‘Pattern’
14 Call function: BDC_INSERT , click on continue (tick mark)
15 (Un-comment following 3 lines)
EXPORTING
Tcode = ‘MK01’
DynProTab = JTAB
16 Place cursor after the line ‘ENDLOOP’
** call function BDC_CLOSE_GROUP:
17 Ctrl+F6 or Click on ‘Pattern’
18 Call function: BDC_CLOSE_GROUP , click on continue (tick mark)
19 Save , Check , Activate, continue(tick-mark) , Back(F3), Back(F3)
**Start Recording:
20 SM35 (transaction code for Session Manager)
21 Click ‘Recording’ (ctrl+F8) on tool bar
22 Click ‘New recording’ on tool-bar
23 (in pop-up window..)
Recording: ZmyRec (give any name)
Transaction code: MK01 (prepare a technical Log for MK01)

(Note: MK01 is the transaction-code for SAP standard data entry screen create vendor –
purchasing )
24 Click on ‘Start recording’
25
Vendor: 1601 (select a non-existing vendor code)
Purchase organization: 0001 (give any code)
Account group: 0001 (give any code)

Press ‘Enter’ key

Name: santanu
Search term: SN
Country: IN

Press ‘Enter’ key , ‘Enter’ key… to move to next page

SASIDHAR 9963855143
-54-
ABAP Lab-Guide

Order Currency: INR

Press ‘Enter’ key

(Note: this record also gets inserted into table LFA1)


(provide data for mandatory fields…flagged with tick-marks)
Create and Schedule JOB
26 SM36
27 Job name: MyJOB
28 Click ‘Enter’ key
29 Click on ‘ABAP Program’
30 Name: ZmySession [see step-3]
Language: en (default)
31 Save (ctrl-S)
32 Click on ‘Job Selection’ (shift-F1) on menu-bar
33 Job name: MyJOB
User name: SAPUSER (default)
34 Set values for..
FROM-DATE , TO-DATE
FROM-TIME , TO-TIME
Select necessary checkboxes: JobStatus:- tickmark on [Scheduled] checkbox
(remove tickMarks from other checkBoxes)
ABAP program name: ZmySession [see step-3]
35 Execute
36 Job is now submitted as SCHEDULED for timebound execution (but not Released yet)
37 NOTE: if you want to RELEASE the job immediately..follow the steps below..
a) select the JOB from the List by clicking on the left-most button
b) click on Release (ctrl-shift-F10)on the tool-bar
c) Click on Immediate button in the pop-up window,
d) click on Save

BDC: LSMW (Legacy System Migration Workbench) - tool

The LSMW comprises the following main steps:


 Read data (legacy data in spreadsheet tables and/or sequential files).
 Convert data (from the source into the target format).
 Import data (to the database used by the R/3 application).
But, before these steps, you need to perform following steps :
 Define source structure : structure of data in the source file.
 Define target structure : structure of SAP that receives data.
 Field mapping: Mapping between the source and target structure with conversions, if any.
 Specify file: location of the source file

List of Radio-buttons:
1. Maintain object attributes
2. Maintain source structures

SASIDHAR 9963855143
-55-
ABAP Lab-Guide

3. Maintain source fields


4. Maintain structure relations
5. Maintain field mapping and conversion rules
6. Maintain fixed values, translations, user-defined routines
7. Specify files
8. Assign files
9. Import data
10. Display imported data
11. Convert data
12. Display converted data
13. Create batch input session
14. Run batch input session

Steps Action

Note: to avoid obstacle during data migration process remember the following points..

a) view the destination table(LFA1) data before data migration [using SE16. see step-95]

b) for example, if the last record data in table:LFA1, field:LIFNR(vendor code) is 1600, then the
first value of the same field in data file ‘C:\MY.TXT’ should be 1602 (1600+2).

c) during recording process a set of data is entered through the screen, which also gets
inserted into the same table (LFA1). Ensure that LIFNR(vendor code) value during screen-
recording is given as 1601 (1600+1) [see step-20] and the same value does not exist in table
LFA1.

d) there should not be any duplicate data in LIFNR (it is a primary field with unique data)

1 ** create data file C:\MY.TXT:


Create tab-separated data file C:\MY.TXT

1602 0001 0001 ANIL YR IN INR


1603 0001 0001 SAM AV IN INR

Note: 1st column data should not exist in table LFA1


1st column represents LIFNR(vendor code)
2nd column represents EKORG(purchase organization)
3rd column represents KTOKK(account group)
4th column represents NAME1(name)
5th column represents SORTL(search term)
6th column represents LAND1(country)
7th column represents WAERS(currency)

2 ** create fields file C:\MYFIELDS.TXT:


Create a file ‘C:\myfields.txt’ in NOTEPAD with following fields:
LIFNR
EKORG
KTOKK
NAME1
SORTL
LAND1
WAERS
1 LSMW (transaction code)
2 On menu-bar, EDIT  Create Entry

SASIDHAR 9963855143
-56-
ABAP Lab-Guide

** Define Project, subProject, Object:


3 Project: MyPROJ (give any name)
Description: (enter any text)
4 Click on ‘continue’ (tick-mark)
5 Sub project: MySUB (give any name)
Description: (enter any text)
6 Click on ‘continue’ (tick-mark)
7 Object: MYSESSION (enter any session name)
Name: (enter any text)
8 Click on ‘continue’ (tick-mark)
9 Click ‘Continue’ (F8) icon on tool-bar
1. [Maintain Object Attributes] :
10 Select 1st radio-button, ‘Maintain Object Attributes’
11 ‘Execute’ (ctrl-F8) on tool-bar
12 Click ‘Display/Change’ (ctrl-F1) icon on tool-bar
13 Select radio-button, ‘Batch Input Recording’
14 Click on ‘Recordings Overview’ icon (or)
on menu-bar, GOTO  Recordings Overview (or) [shift+F9]
15 Click ‘Create Recording’ (ctrl-F1) icon on tool-bar
16 Recording: ZmyREC (give any name)
Description: (enter any text)
17 Click on ‘continue’ (tick-mark)
18 Transaction code: MK01

(Note: MK01 is the transaction-code for SAP standard data entry screen create vendor –
purchasing )
19 Click on ‘continue’ (tick-mark)
20
Vendor: 1601 (select a non-existing vendor code)
Purchase organization: 0001 (give any code)
Account group: 0001 (give any code)

Press ‘Enter’ key

Name: santanu
Search term: SN
Country: IN

Press ‘Enter’ key , ‘Enter’ key… to move to next page

Order Currency: INR

Press ‘Enter’ key

(Note: this record also gets inserted into table LFA1)


(provide data for mandatory fields…flagged with tick-marks)
21 Click ‘Enter’ key
22 Save (ctrl+S)
23
24 A ‘create recording’ tree-structure appears
25 click Place the cursor on top-right empty block (of RF02K-LIFNR or RF02K-KTOKK)
26 Click on ‘Default All’ (ctrl-F2) on tool bar to pre-populate the field values & labels
27
28 Save , Back(F3) , Back(F3)

SASIDHAR 9963855143
-57-
ABAP Lab-Guide

29 Recording: ZmyREC [see step-16]


30 Save , Back(F3)
2. [Maintain Source Structures ] :
31 Select 2nd radio-button, ‘Maintain Source Structures’
32 Click Execute (ctrl-F8) on tool-bar
33 Click ‘Display/Change’ (ctrl-F1) icon on tool-bar
34 Click ‘Create a structure’ (ctrl-F4) icon on tool-bar
35 Source structure: ZmySRC (give any name)
Description: (enter any text)
36 Click on ‘continue’ (tick-mark)
37 Save , Back(F3)
3. [Maintain Source Fields] :
38 Select 3rd radio-button, ‘Maintain Source Fields’
39 Click Execute (ctrl+F8)
40 Click ‘Display/Change’ (ctrl-F1) icon on tool-bar
41 Place cursor(click) on ‘ZmySRC’ [see step-34]
42 On menu-bar, SourceFields  CopyFields
43 Select radio-button, ‘Upload’
44 Click on ‘continue’ (tick-mark) , Click on ‘continue’ (tick-mark)
45 Select the FIELDS file ‘C:\myfields.txt’ [see step-2] to pre populate fieldlength, type
(select file in the file-browser window and click ‘Open’)
46 Save , Back(F3)
4. [Maintain Structure Relations] :
47 Select 4th radio-button, ‘Maintain Structure Relations’
48 Click Execute (ctrl+F8)
49 Click ‘Display/Change’ (ctrl-F1) icon on tool-bar
50 Save , Back(F3)
5. [Maintain Field Mapping & Conversion Rules] :
51 Select 5th radio-button, ‘Maintain Field Mapping & Conversion Rules’
52 Click Execute (ctrl+F8)
Fields-tree appears
53 Click ‘Display/Change’ (ctrl-F1) icon on tool-bar
54 Place cursor just beside the first ‘I’ icon (NOT on the icon) and click
55 On menu-bar, Extras  AutoFieldMapping
56 Click on ‘continue’ (tick-mark) in the pop-up box
57 Click on ‘Accept Proposal’ continuously until ‘autofield mapping’ is completed
58 Click on ‘continue’ (tick-mark)
59 Field tree-structure with recorded data appears
60 Save , Back(F3)
**Don’t use** 6. [Maintain fixed values, translations, user-defined routines] :
61 DON’T Select 6th radio-button, ‘Maintain fixed values, translations, user-defined routines’
7. [Specify Files] :
62 Select 7th radio-button, ‘Specify Files’
63 Click Execute (ctrl-F8)
64 Click ‘Display/Change’ (ctrl-F1) icon on tool-bar
65 Select(click) ‘Legacy Data on the PC(Front End)’
66 Click ‘Add entry’ (ctrl-F2) icon on tool-bar
67 File: C:\my.txt [see step-1]
Name: my Flat File (give any name)
Select radio-button, ‘Tabulator’ (under heading ‘Separators’) [for Tab separated data file]
68 Click on ‘continue’ (tick-mark)
69 Save , Back(F3)
8. [Assign Files] :

SASIDHAR 9963855143
-58-
ABAP Lab-Guide

70 Select 8th radio-button, ‘Assign Files’


71 Click Execute (ctrl-F8)
72 Click ‘Display/Change’ (ctrl-F1) icon on tool-bar
73 Save , Back(F3)
9. [Import Data] :
74 Select 9th radio-button, ‘Import Data’
75 Click Execute (ctrl-F8) , Execute (F8) , Back(F3), Back(F3)
10. [Display Imported Data] :
76 Select 10th radio-button, ‘Display Imported Data’
77 Click Execute (ctrl-F8) , Click on ‘continue’ (tick-mark) , Back(F3)
11. [Convert Data] :
78 Select 11th radio-button, ‘Convert Data’
79 Click Execute(ctrl-F8) , Execute(F8) , Back(F3) , Back(F3)
12. [Display Converted Data] :
80 Select 12th radio-button, ‘Display Converted Data’
81 Click Execute(ctrl-F8) , Click on ‘continue’ (tick-mark) , Back(F3)
13. [Create Batch Input Session] :
82 Select 13th radio-button, ‘Create Batch Input Session’
83 Click Execute(ctrl-F8) , Execute(F8) , Click on ‘continue’ (tick-mark) in pop-up box
14. [Run Batch Input Session] :
84 Select 14th radio-button, ‘Run Batch Input Session’
85 Click Execute(ctrl-F8)
86 Select the ‘Session name’ MYSESSION from the list [see step-7]
(select entire row by clicking on extreme left corner button)

[Note: it will be in NEW state]


87 Click ‘Process’ [process session] (F8) on tool-bar
88 Select radio-button, ‘Process/Foreground’
89 Click on ‘Process’ (enter) in the pop-up window
90 Press ‘Enter’ key (or click ‘tick-mark’) continuously until ‘session overview’ pop-up appears
with message ‘processing of batch input session completed’
91 click on ‘session overview’ or ‘exit batch input’
** Data Migration COMPLETED **
92 LOG --to view the session log-book [this step is optional]

Click ‘Log’ (F7) on tool-bar ,


Now select the session name by clicking on the left-most button ,
Click on ‘Display’ (F2) on tool-bar
93 ANALYSIS – to view analysis report [this step is optional]

select the session name by clicking on the left-most button ,


Click ‘Analysis’ (‘Analyze Session’ F2) on tool-bar
94 STATISTICS –to view the statistics [this step is optional]

select the session name by clicking on the left-most button ,


Click ‘Statistics’ (shift- F1) on tool-bar
** view table data:
95 SE16
96 Table name: LFA1 , click on ‘Table Contents’ icon (F7)
enter a range of LIFNR values (e.g. 1600 to 1650) [optional]
97 click Execute (F8) on tool-bar

Note: for subsequent data migration from the same data file ‘C:\MY.TXT’(with different sets of data)

SASIDHAR 9963855143
-59-
ABAP Lab-Guide

into the same destination table(LFA1), just follow the steps from step-74 onwards

RFC: Remote Function – Creation (1a)

Steps Action
1 SE37 (transaction code for Function-Builder)
2 GoTo (on menu bar)
3 Function Groups
4 Create Group
5 function group: zmygrp
short description: my function group
6 click on tick-mark
7 Local object
8 Function module: ZmyFunc
9 Create
10 Function module: ZmyFunc [see step-8]
Function group: zmygrp [see step-5]
Short description: my sample RFC (give any text)
11 Save , ‘Local object’
12 Click on ATTRIBUTE(tab)
Select radio-button ‘Remote-enable module’
** IMPORT(tab):
13 Click on IMPORT(tab)
Parameter names type associated type pass value **(mandatory)
X type i tick (select)
Y type i tick (select)
** EXPORT(tab):
14 Click on EXPORT(tab)
Parameter names type associated type pass value **(mandatory)
Z type i tick (select)
** SOURCE CODE (tab):
15 Click on SOURCE CODE(tab)
…Enter the logic…
z = x + y.
16 Save , Check , Activate , Continue , Execute
17 Enter test data values for x , y
18 Click ‘Execute’ (F8) to test the function

RFC: Remote Function Call - function call (1a)

Steps Action
1 SE38 (transaction code for ABAP editor)
2 Program name: ZmyRFC
Create
3 Executable
Short description: santanu’s RFC

SASIDHAR 9963855143
-60-
ABAP Lab-Guide

Type: executable program


4 Save , ‘Local object’
5 Data: a type i, b type i, c type i.
(or)
Parameters: a type i, b type i.
Data: c type i.

a = 10. b = 5.
6 Click on ‘Pattern’ ctrl+F6to generate function code
Select radio-button ‘Call function:’ and enter function name ZmyFunc [see RFC function
creation step-8]
7 Continue
8 Call function ‘Zmyfunc’ destination ‘NONE’
Exporting
X = a
Y = b
Importing
Z = c.
Write: / c.

NOTE: add statement destination ‘NONE’ to test the remote function call in local system. In
real life use the remote computer name. e.g destination ‘HONGKONG’
9 Save , check, activate, execute

IDOC (Intermediate DOCument)

- IDOCs are data containers


- IDOCs are text fields in a specific format as specified by ANSI or ‘EDIFACT’
- IDOCs are exchanged between 2 business systems that can understand and
process IDOCs
- IDOCs are used in ALE and EDI integration
- IDOC types are: a) designed components or, b) templates
- IDOCs are runtime components available only during execution
- IDOCs are used to exchange data for ALE
- IDOCs are used to exchange data for EDI
- IDOCs are runtime objects instantiated from the IDOC TYPEs

IDOC-TYPE (class)
|
IDOC (object)

Basic IDOC-TYPE (basic Base class)


|
Extended IDOC-TYPE (derived class - inheritance)

Note: each field structure should not exceed 100 bytes. An IDOC can have any number of SEGMENTs,
but atleast one SEGMENT should be mandatory

IDOC-TYPE
|------ SEGMENT
|------ segment definition (segment name)
|------ segment fields (defined with data elements e.g. KUNNR, …. )

SASIDHAR 9963855143
-61-
ABAP Lab-Guide

|------ segment documentation (document available with data element)

Process to define IDOC:

Step1: define ‘SEGMENT’ (transaction code WE31)


Step2: create ‘IDOC TYPE’ and attach ‘SEGMENT’ (transaction code WE30)
Step3: release ‘SEGMENT’ (transaction code WE31)
Step4: release ‘IDOC TYPE’ (transaction code WE30)
Step5: define a ‘LOGICAL MESSAGE’ (transaction code WE81)
Step6: attach ‘IDOC TYPE’ to ‘LOGICAL MESSAGE’ (transaction code WE82)
Step7: view ‘IDOC TYPE’ documentation (transaction code WE60)

Steps Action
1 WE31
2 Segment type: ZmySEG (give any name)
3 Click on ‘Create’ icon (F5)
4 Short description: (enter any text)
5 Field name data element
CustNo kunnr
CustName name1
OrderNo vbeln-va
OrderValue netwer
6 Press ‘Enter’ key
7 Right most column gets filled with Field-lengths
8 Save , continue(tick mark) , ‘Local object’ , Back , back
9 WE30
10 Object name: ZmyOBJ (give any name)
11 Click on ‘Create’ icon (F5)
12 Select radi-button ‘Create new’ (default)
Short description:
13 Click on ‘continue’ (tick mark)
14 Select ‘ZmyOBJ’ from the list
15 Click on ‘Create’ icon (shift+F6)
16 A pop-up window appears
17 Segment type: ZmySEG
Select check-box ‘Mandatory Seg’
Minimum number: 10
Maximum number: 100
18 Continue(tick mark) , Save , ‘Local object’ , Back , Back
19 WE31
20 On menu-bar, select: EDIT  Set Release
21 Click on ‘Check’ (it will display segment consistency message)
22 Back , Back
23 WE30
24 On menu-bar, select: EDIT  Set Release
25 Click ‘Yes’ in the pop-up box
26 Click on ‘Check’ (it will display message: ZmyOBJ is released)
27 Back , Back
28 WE81
29 Screen appears with list of Messages
30 Click on ‘Change’ icon (ctrl+F1)
31 Click on ‘continue’ (tick mark) in the pop-up box
32 Click on ‘New Entries’ (F5) on tool-bar

SASIDHAR 9963855143
-62-
ABAP Lab-Guide

33 Message type short text


ZmyMSG (enter any name) santanu’s message (enter any text)
34 Click on ‘Create Request’ (F8) in the pop-up box
35 Short description: ZmyREQUEST (give any text)
36 Save , continue (tick mark) , Back , Back
37 WE82
38 Screen appears with list of Messages
39 Click on ‘Change’ icon (ctrl+F1)
40 Click on ‘continue’ (tick mark) in the pop-up box
41 Click on ‘New Entries’ (F5) on tool-bar
42 Message type basic type release
ZmyMSG [see step-33] ZmyOBJ [see step-10] 46c (for 4.6c, 47e for 4.7e)
43 Save
44 Click on ‘Continue’ in the pop-up box
45 Back , Back
46 WE60
47 Click on ‘Display Tree’ icon (F8)
Click on ‘Expand SubTree’ icon (optional)
Click on ‘Collapse SubTree’ icon (optional)
To have total tree view
48 Back
49 Click on ‘HTML’ (optional) to save data in HTML file.
Click on ‘Transport Data’ (F5) to Transport Data (Warning: DON’t try in local system)
Click on ‘C-header’ (optional) to save data as C-header file (visual .NET)
Click on ‘Parser’ (F9)(optional) to display documentation of IDOC record types, click on
‘DisplayErrorLog’ to show errors(if any)

IDOC: (sending/receiving)

Steps System1 (sending system) System2 (receiving system)


1 Select the data Receive the IDOC and store it
2 Extract selected data Extract data from IDOC
3 Instantiate IDOC-TYPE into IDOC object Transfer/use extracted data into respective
application
4 Fill the IDOC with extracted data
5 Provide partner information to IDOC
6 Push IDOC into communition network
7 =OUTBOUND PROCESS= =INBOUND PROCESS=

IDOC: in runtime

Steps Action
1 IDOC-TYPE is instantiated into IDOC
2 One unique 16 character number is attached to IDOC within the client
3 One ‘control record’ is attached
4 SEGMENTs are translated into ‘data records’
5 ‘status records’ are attached on crossing each mile-stone of IDOC processing
6 Syntax rules are checked
7 ‘control record’ is just like address-envelope

SASIDHAR 9963855143
-63-
ABAP Lab-Guide

ALE: (Application Linking Enabling)

- to distribute data, we have to replicate data


- 100% uptime should be assured
ALE configuration:

Steps Action
1 On ‘source system’
goto an application e.g. SALE
2 Under ‘sending system’ and ‘receiving system’ define the logical system by entering the
DESTINATION system name & SOURCE system name. These names must be saved in a
‘development class’ e.g. ZmyDEV’
3 Assign clients to ‘Logical client’
4 Select the clients that are going to act as source and destination system and change their names
accordingly. (client: 800, 810)
5 ‘Logical client’ assignment – completed--
6 Set the RFC destination and configure it
7 Use the RFC destination, if it exists.
8 Create a new destination, if it doesn’t exist.
9 Modelling and implementing business process:
10 Under this, maintain distributed model & distributed views by creating MODEL –VIEW and
MESSAGE-TYPE
11 Transport the MODEL-VIEW that is developed into a MODEL-VIEW class
12 Generate ‘partner profile’ by giving the ‘Logical system name’
13 NOTE: carry out the same procedure for the other ‘client system’

Reference Book: ‘configuring ALE and EDI’ – by Arvind Nagpal

EDI: (Electronic Data Interchange) - configuration

Steps Action
1 WE21 (transaction code: to create a port)
2 Name:
Desc:
Function module:
Outbound file name:
RFC destination name:
Command file name: CONVERTER_SRART
3 WE41 (transaction code: for OUTBOUND process)
4 Process code: ZmyOUTPROCESS
Description: santanu’s outbound process

Or use..

SASIDHAR 9963855143
-64-
ABAP Lab-Guide

WE42 (transaction code: for INBOUND process)


Process code: ZmyINPROCESS
Description: santanu’s inbound process
5 WE20 (transaction code: to create ‘partner profile’)
6 Partner number:
User:
Type:
Language:
Port:
7 Transfer IDOC
8 NACE (transaction code)
9 Select APPLICATION
10 Select TYPE
11 Click on ‘Execute’

BAPI : Business API (Application Program Interface)

Protocol:
SAP’s application model is ‘transaction’ model, where as Java/VB follows ‘object oriented’ model

Steps Action
1 BAPI (transaction code)
2 1. Cross application components
2. Accounting - general
3. Financial accounting
4. Treasury
5. Controlling
6. Investment management
7. Enterprise controlling
8. Real estate management
9. Logistics – general
10. Sales & Distribution (SD) – basic functions, sales, billing, sales support
11. Materials management (MM)
12. Logistics execution
13. Quality management (QM)
14. Plant maintenance (PM)
15. Customer service
16. Production planning & Control
17. Project system
18. Environment, Health & Safety
19. Personnel management (HR)
20. Personal Time management (HR)
21. Pay roll (HR)
22. Training (HR)
23. Basic component service
3 NOTE: SPRO (transaction code) for entering into MM, FICO, etc.
IMG (transaction code) for implementation guide
4 SW01 (transaction code) to create an object

SASIDHAR 9963855143

S-ar putea să vă placă și