You are on page 1of 232

SAP-ADV ABAP 1

Database Outbound Program


Read data from IDOC status 51 Messagestatus Type 53
Posting Program Master IDOC application IDOC application
MASTER_IDOC_DISTRIBUTED
Not posted posted
IDOC Receivers
Syntax Checks Master IDOC
EDI RFC
Sub
Network Sender
Receiver
System
IDOC
IDOC MM Vendor Number:
SDConversion
IDOC filtering Changes
Version Change
Vendor
are made
Number:Field PO Number:
Item noItem description
PO Number: Outbound
Inbound
User: Page
User: Vendor
Number
PO
User:PODriver
External
Heading
Quantity
Logo
Name:
Database
Program
Devices
Total Amo
Item noItem IDOC
Snodescription
Sno Sno
matnr filtering
matnrRemote
matnr
movement
movement
Vendor
UOM Function
movement
Heading
Page:
type
Logo
POversion
Name:
Heading
Page:
type
Logo
3Total
Quantity
Heading
of
Page:
type Call
External
Logo
360
Heading
of
Amount:
Logo Date:
change
3quantity
60
Database Smart
ofNumbers
quantity
Devices
60
UPrice
quantity Form
field
Tprice
amoun c
am
PO
Carry
Date:
Carry 1-49
50-99
forward
Date: Status
forward
Date: Status
(Unique
Address:
amount:
Date:
Driver Numbers
amount:
Form Function
Program Modu
Basic Integrity Checks Address: communication comm
Communication
IDOCs IDOC
Partner Profile Created SyntaxPOGrand
IDOC
Page
Checks
SAP-
Total:
Total:
PagePO
IDOC
Total:
Quantity:
Quantity: Pending Quantity:

ADV ABAP Ports are created IDOC Pending


Port created
INBOUND_IDOC_SYNCHRONOUS
PartnerDelivery
Profile
Quantity: Delivery Quantity:
Quantity:
table created
ARFC_DEST_SHIP
NAME : B V Ashok kumar
TOPICS : BDC
SCRIPTS
SMART FORMS
ENHANCEMENTS
ALE
BAPI
Ashok
SAP-ADV ABAP 2

Ashok
SAP-ADV ABAP 3

INDEX
1 BDC 5
2 Data Transfer Techniques (Inbound & Outbound) 5
3 Steps in BDC Data Transfer Technique 6
4 Methods in BDC (Session, Call Transaction, LSMW & Direct Input methods) 7
5 1. Session Method 8
6 Upload bank data from Notepad using session method 10
7 Uploading data from XL Sheet using Session Method 15
8 2. Call Transaction Method 21
9 Upload pricing data using Call Transaction Method 23
10 3. LSMW 29
11 SKIP Functionality 35
12 . Upload material master data with MM01 using flat file with headings & logo 35
13 BDC with Table Control 36
14 Upload vendor master data using XK01 using Table Control 37
15 File Handling 38
16 Opening a File in Application Server in Output Mode (Write Mode) 38
17 Opening a File in Input Mode (Read Mode) 40
18 Upload asset master data with AS02 using Call Transaction Method 43
(Assignment)
19 Upload employee payroll for info type 14 with PA30 using Call Transaction 44
Method (Assignment)
20 SAP Scripts 45
21 Flow of Creating Form (Steps) 47
22 Goods receipt form using Scripts 48
23 Function Modules for Print Program 56
24 PO Form using Scripts(Assignment) 57
25 Standard Forms 58
26 Smart Forms 61
27 Steps in Working of Smart Forms 63
28 PO Form using Smart Forms 64
29 SAP Enhancements (User exits, Customer exits, BADI, Enhancement Frame 81
Work & BTE)
30 1. User exits 81
31 Validate sales order application using User exits 81
32 2. Customer exits (Function Exits, Menu Exits, Screen Exits & Field Exits) 83
33 a) Function Exits 83
34 Validate vendor master application for postal code 83
35 b) Menu Exits 86
36 c) Screen Exits 88
37 d) Fieldexits 92
Ashok
SAP-ADV ABAP 4

38 3. BADI(Standard, Custom &Filter BADIs) 93


39 i) Standard BADI 94
40 Watch Point 96
41 Navigation for Finding BADI (3 Methods) 97
42 Validate BOM application (CS01) for alternate Bom using Standard BADI 98
43 Add a menu in FBL5N application using Standard BADI 100
44 . Add a screen in XD01, XD02 with field Sales Manager using Standard BADI 102
45 ii) Custom BADI 107
46 iii) Filter BADI 107
47 Determine tax code for sales organization using Filter BADI 107
48 4. Enhancement Framework 111
49 Provide Profit center as obligatory in F-28 application 113
50 In MB31 provide Document date & Posting date as previous date 114
51 Add fields in FB03 application ( Dmbtr, Hlcont ) 115
52 Add screen in VF01, VF02, VF03 with ZZBOXNO, ZZSIZE, ZZTEXT 117
53 5. BTE 120
54 Add indicator field in FBL5N application 120
55 Cross Applications (ALE & IDOC) 125
56 Records (Control, Data & Status) 126
57 ALE Architecture 128
58 Message Type 130
59 Types of IDOCs (Standard IDOC, Custom IDOC &Extended IDOC) 131
60 a) Standard IDOC 131
61 Distributing material master data 131
62 Sending Changes to Inbound System 137
63 IDOC Filtering(Segment Filtering, IDOC Filtering &Reduced IDOC Filtering) 139
64 1. Segment Filtering 139
65 2. IDOC Filtering 140
66 3. Reduced IDOC Type 146
67 Distributing Transactional Data 148
68 b) Custom IDOC 154
69 c) Extended IDOC 160
70 Trouble Shooting & Recovery 167
71 Debugging IDOCs 168
72 EDI 169
73 Steps in EDI Process Flow 171
74 BAPI 174
75 BOR 176
76 Types of BAPIs (Standard BAPI, Custom BAPI & Extended BAPI) 177
77 1. Standard BAPI 177
78 2. Custom BAPI 181
79 Adobe Forms 186
Ashok
SAP-ADV ABAP 5

80 Debugging Techniques 189


81 Table Level Debugging 189
82 Modifying Data during Debugging 190
83 Debugging Background Jobs 191
84 Lock Object 192
85 Search Help Exit 195
86 Questions & Answers 197
87 BDC 197
88 SCRIPTS & SMART FORMS 217

Ashok
SAP-ADV ABAP 6

BDC:
Batch Data Communication
BDC is a data transfer technique from one system to another system

*** Real time need for BDC:


1. Assume client wants to enter (or) process 1000 materials using MM01 T-code. Manually
it will take lot of time for the same. In this case we have to use BDC
2. In real time every company have to update their prices quarterly (or) half yearly using
VK11 T-code. Again manually, it will take lot of time. In this case also we have to use
BDC
3. In HR module ESI Numbers have to be modified yearly for workers. This is again time-
consuming process. In this case also we have to use BDC

 In all above examples manually clients have to process application data & there is no
guaranty that data is 100% consistent
 SAP is providing a technique called BDC for data transfer

Data Transfer Techniques:


There are two types of data transfer techniques
1. Outbound
2. Inbound

Outbound:

SAP
SAP
(source system) Non-SAP

Inbound:

SAP
SAP (target system)

Non-SAP

Note:
BDC is an Inbound data transfer technique

Ashok
SAP-ADV ABAP 7

Steps in BDC Data Transfer Technique:


Step-1:
In real time Flat File (XL Sheet (or) Note pad) is provided by end user (client)

Step-2:
 Functional Consultant will analyses Flat File & there only he will converts Non-SAP data
into SAP format
 Functional Consultant will prepare Functional Document & provide it to Technical
Consultant

Step-3:
Technical Consultant will write an interface program (BDC program) in SAP system & he will
upload the data from Flat File to Internal table (created based on Flat File)

Step-4:
 In real time some data might be in SAP format (or) Non-SAP format
 All Non-SAP format data is converted into SAP format using validations in application

Step-5:
 Before validation we have to perform mapping logic
 **For that we have to create mapping logic internal table based on BDC Data Structure

Step-6:
 From mapping logic internal table (it_bdcdata) data will goes to respective application
where LUW is performed
 With LUW data is finally transferred to database tables

Note:
BDC is a part of conversion technique

Flat File:
In real time Flat File (mainly XL Sheet) is provided by end user

Ashok
SAP-ADV ABAP 8

Mapping Logic:
BDC Data (structure)

Program (module pool program)

Dynpro (screen number)

Dynbegin (start screen)


Fnam (field name)
Fval (field value)

Methods in BDC:
1. ** Session method
2. ** Call Transaction method
3. LSMW (this job is done by Functional Consultant)
4. Direct Input method (it is out dated)

Ashok
SAP-ADV ABAP 9

Session Method:
Features:
1. Use session method for uploading large amount of data (more than 10000 records)
2. Data can be processed in Foreground as well as Background
3. *** In BDC in session method error records are captured using Log File
4. In session method respective Log File is already given by SAP
5. *** Multiple applications can be processed at one time
6. Asynchronous processing
7. Synchronous updating
8. It is a slower method but consistent

Function Modules in Session Method:


1. BDC_OPEN_GROUP
2. BDC_INSERT
3. BDC_CLOSE_GROUP

BDC_OPEN_GROUP:
It will open a session in SM35

BDC_INSERT:
It transfers mapped data from mapping logic internal table to session

BDC_CLOSE_GROUP:
It closes a session which is already opened.
Flow of Data in Session Method:
Flat File
(using function module)
It_data
(using LOOP………ENDLOOP)
Wa_data
(using APPEND keyword)
It_bdcdata
(using BDC_INSERT function module)
Session

Session processed (SM 35)

Screens

LUW
Database Tables
Processing:
Ashok
SAP-ADV ABAP 10

 Transferring the data from Flat File (Presentation Server) ultimately to Session
(Application Server) is called processing
 In session method processing is asynchronous (all records from Flat File are ultimately
broad to session)

Updating:
 Transferring the data from Application Server to Database Server is called updating
 In session method updating is synchronous
 In session method if a record is correctly committed to database then only next record is
updated (next transaction can be processed only when the previous record is correctly
written to the database)

** Recording:
 Using recording you can map Program name, Screen number, Field names………….etc
 You can map Screen Sequences
 You can map FCT values for different function codes (BACK, SAVE, ENTER………etc)

Note:
T Code for recording is SHDB

Ashok
SAP-ADV ABAP 11

Requirement:
Upload bank data from Notepad using session method

Solution:
Step-1:
 Go to SHDB
 New Recording
 Recording: ZBANK_RECO
 Transaction Code: FI01
 Start Recording
 Bank Country: IN
 Bank Key: SR Nagar
 Enter
 Bank Name: state bank on Hyderabad
 Street: SR nagar
 City: Hyderabad
 Bank Branch: SR nagar branch
 Save
 Save
 Back

Note:
In real time, Functional Consultants perform recording. As a Technical Consultant based on
recording we have to create a program

Step-2:
 Go to SHDB
 Select your recording name (ZBANK_RECO)
 Program
 Program Name: ZFI_BANK_UPLOAD
 Transaction For Recording
 Enter
 Title: BDC for FI01
 Type: Executable Program
 Source Code
 Local Object
 You will find a program
 Remove starting 3 lines
i.e. INCLUDE BDCRECXL
START-OF-SELECTION
……………………….

Ashok
SAP-ADV ABAP 12

 From bottom remove last 2 lines


i.e. PERFORM BDC_TRANSACTION USING
………………….

Step-3:
Write your program from begging of given program

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.


PARAMETER p_file TYPE rlgrap-filename.
SELECTION-SCREEN: END OF BLOCK b1.

TYPES: BEGIN OF ty_fi01,


banks TYPE banks,
bankl TYPE bankl,
banka TYPE banka,
stras TYPE stras,
brnch TYPE brnch,
END OF ty_fi01.

DATA: wa_fi01 TYPE ty_fi01,


it_01 TYPE TABLE OF ty_fi01.

* mapping objects
DATA: wa_bdcdata TYPE BDCDATA,
it_bdcdata TYPE TABLE OF BDCDATA.

DATA: fnam TYPE STRING.

* F4 functionality
AT SELECTION-SCREEN ON VALUE_REQUEST FOR p_file.

PERFORM open_file.

START-OF-SELECTION.

PERFORM upload.
PERFORM open_session.
PERFORM process_data.
PERFORM close_session.

Ashok
SAP-ADV ABAP 13

FORM open_file.

CALL FUNCTION ‘F4_FILENAME’


EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ‘p_file’
IMPORTING
FILE_NAME = p_file.

ENDFORM.

FORM upload.

fnam = p_file.

CALL FUNCTION ‘GUI_UPLOAD’


EXPORTING
FILENAME = fnam
HAS_FIELD_SEPARATOR = ‘X’
TABLES
DATA_TAB = it_fi01.

ENDFORM.

FORM open_session.

CALL FUNCTION ‘BDC_OPEN_GROUP’


EXPORTING
CLIENT = SY-MANDT
GROUP = ‘Ashok’
USER = SY-UNAME
KEEP = ‘X’.
ENDFORM.

FORM process_data.
LOOP AT it_fi01 INTO wa_fi01.
REFRESH it_bdcdata.

Remove dummy values & provide work area


wa_fi01-banks.
wa_fi01-bankl.
Ashok
SAP-ADV ABAP 14

wa_fi01-banka.
wa_fi01-stras.
wa_fi01-ort01.
wa_fi01-brnch.

* transfer mapped data to session


CALL FUNCTION ‘BDC_INSERT’
EXPORTING
TCODE = ‘FI01’
TABLES
DYNPROTAB = it_bdcdata.

ENDLOOP.

ENDFORM.

FORM close_session.
CALL FUNCTION ‘BDC_CLOSE_GROUP’.
ENDFORM.

* screen mapping
FORM BDC_DYNPRO USING PROG SCREEN.

CLEAR wa_bdcdata.

wa_bdcdata-program = prog.
wa_bdcdata-dynpro = screen.
wa_bdcdata-dynbegin = ‘X’.

APPEND wa_bdcdata TO it_bdcdata.

ENDFORM.

* field mapping
FORM BDC_FIELD USING FIELD VALUE.

CLEAR wa_bdcdata.

wa_bdcdata-fnam = field.
wa_bdcdata-fval = value.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM.
Ashok
SAP-ADV ABAP 15

Step-4:
Create a Flat File with Note pad
IN SBI009 STATEBANKOFINDIA LBNAGAR HYDERABAD
IN SBH008 STATEBANKOFHYD AMEERPET HYDERABAD

Step-5:
 Go to SE38
 Execute
 Apply F4
 Select your Flat File
 Open
 Execute

 Go to SM35
 Select your Session name
 Process
 Background
 Process

07-11-2014
Question-1:
Assume my Session has been processed & after processing, I want my Session to be displayed
in SM35 for status check. How you can achieve this task?
Answer:
By providing exporting parameter KEEP = ‘X’ you can get your processed session back in
SM35

Question-2:
How you can maintain Logs (or) Error records in Session method?
Answer:
In Session method SAP is providing a Log file by default
No need to create a Log file for handling error records
You can find Log file by using SM35
 Go to SM35
 Select your session
 Select Log option (F7)
 Select your session
 Select Display button

Ashok
SAP-ADV ABAP 16

Uploading data from XL Sheet using Session Method:


Using TEXT_CONVERT_XLS_TO_SAP you can upload the data from XL Sheet to internal
table

Requirement:
Upload bank data from XL Sheet using session method

Solution:
Step-1:
 Go to SHDB
 New Recording
 Recording: ZBANK_RECO
 Transaction Code: FI01
 Start Recording
 Bank Country: IN
 Bank Key: SR Nagar
 Enter
 Bank Name: state bank on Hyderabad
 Street: SR nagar
 City: Hyderabad
 Bank Branch: SR nagar branch
 Save
 Save
 Back

Note:
In real time, Functional Consultants perform recording. As a Technical Consultant based on
recording we have to create a program

Step-2:
 Go to SHDB
 Select your recording name (ZBANK_RECO)
 Program
 Program Name: ZFI_BANK_UPLOAD
 Transaction For Recording
 Enter
 Title: BDC for FI01
 Type: Executable Program
 Source Code
 Local Object
 You will find a program
 Remove starting 3 lines
Ashok
SAP-ADV ABAP 17

i.e. INCLUDE BDCRECXL


START-OF-SELECTION
……………………….

 From bottom remove last 2 lines


i.e. PERFORM BDC_TRANSACTION USING
………………….

Step-3:
Write your program from begging of given program

** TYPE-POOLS TRUXS.

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.


PARAMETER p_file TYPE rlgrap-filename.
SELECTION-SCREEN: END OF BLOCK b1.

TYPES: BEGIN OF ty_fi01,


banks TYPE banks,
bankl TYPE bankl,
banka TYPE banka,
stras TYPE stras,
brnch TYPE brnch,
END OF ty_fi01.

DATA: wa_fi01 TYPE ty_fi01,


it_01 TYPE TABLE OF ty_fi01.

* mapping objects
DATA: wa_bdcdata TYPE BDCDATA,
it_bdcdata TYPE BDCDATA.

DATA: t_raw TYPE TRUXS_T_TEXT_DATA.

* F4 functionality
AT SELECTION-SCREEN ON VALUE_REQUEST FOR p_file.

PERFORM open_file.

START-OF-SELECTION.

PERFORM upload.
Ashok
SAP-ADV ABAP 18

PERFORM open_session.
PERFORM process_data.
PERFORM close_session.

FORM open_file.

CALL FUNCTION ‘F4_FILENAME’


EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ‘p_file’
IMPORTING
FILE_NAME = p_file.

ENDFORM.

FORM upload.

CALL FUNCTION ‘TEXT_CONVERT_XLS_TO_SAP’


EXPORTING
I_TAB_RAW_DATA = t_raw
I_FILENAME = p_file
TABLES
I_TAB_CONVERTED_DATA = it_fi01.

ENDFORM.

FORM open_session.

CALL FUNCTION ‘BDC_OPEN_GROUP’


EXPORTING
CLIENT = SY-MANDT
GROUP = ‘rgs’
USER = SY-UNAME.

ENDFORM.

** FORM process_data.
LOOP AT it_fi01 INTO wa_fi01.
REFRESH it_bdcdata.

Ashok
SAP-ADV ABAP 19

Remove dummy values & provide work area


wa_fi01-banks.
wa_fi01-bankl.
wa_fi01-banka.
wa_fi01-stras.
wa_fi01-ort01.
wa_fi01-brnch.

* transfer mapped data to session


CALL FUNCTION ‘BDC_INSERT’
EXPORTING
TCODE = ‘FI01’
TABLES
DYNPROTAB = it_bdcdata.

ENDLOOP.

ENDFORM.

FORM close_session.
CALL FUNCTION ‘BDC_CLOSE_GROUP’.
ENDFORM.

* screen mapping
FORM BDC_DYNPRO USING PROG SCREEN.

CLEAR wa_bdcdata.

wa_bdcdata-program = prog.
wa_bdcdata-dynpro = screen.
wa_bdcdata-dynbegin = ‘X’.

APPEND wa_bdcdata TO it_bdcdata.

ENDFORM.

* field mapping
FORM BDC_FIELD USING FIELD VALUE.

CLEAR wa_bdcdata.

wa_bdcdata-fnam = field.
Ashok
SAP-ADV ABAP 20

wa_bdcdata-fval = value.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM.

Step-4:
Create a Flat File MS-XL
IN SBI009 STATEBANKOFINDIA LBNAGAR HYDERABAD
IN SBH008 STATEBANKOFHYD AMEERPET HYDERABAD

Step-5:
 Go to SE38
 Execute
 Apply F4
 Select your Flat File
 Open
 Execute

 Go to SM35
 Select your Session name
 Process
 Background
 Process

Question-1:
How you can perform background processing in Session method?
Answer:
Using program RSBDCSUB you can execute session in background

Example:
In above program modify subroutine PERFORM close_session.

FORM close_session.

CALL FUNCTION ‘BDC_CLOSE_GROUP’.

SUBMIT RSBDCSUB VIA SELECTION-SCREEN.

ENDFORM.

 Execute
 F4
 Select your Flat File
Ashok
SAP-ADV ABAP 21

 Execute
 You will find a selection screen
 Session: RGS
 Execute

Question-2:
Suppose I’m having a Flat File with 50000 records. It happened that the system crashed while
uploading data. How I know the number of records exactly uploaded?
Answer:
I will go to respective database table & copy the key values to the table & execute it

Question-3:
Assume there are 1000 records out of which I uploaded 500 records & remaining I want to
upload next day. How you will, you perform this job.
Answer:
I will check the status of the records uploaded & I will delete the records from Flat File which
are correctly uploaded & remaining I will execute once again on next day

Question-4:
I’m having 2 Flat Files with 500 records & 50000 records. Which method will you prefer for
both Flat Files?
Answer:
 For 500 records Call Transaction Method
 For 50000 records Session Method

Ashok
SAP-ADV ABAP 22

Call Transaction Method:


Features of Call Transaction Method:
1. Use Call Transaction Method for uploading small amount of data (master data)
2. Data can be uploaded foreground & as well as background
3. ** Only single application can be processed at one time with one BDC program
4. ** In Call Transaction Method we have to create Log file explicitly using structure
BDCMSGCOLL
5. Synchronous processing (record by record)
6. Asynchronous updating by default (even you can switch updating mode to synchronous)
7. Faster than Session method. Because in Call Transaction Method control will not wait for
updating process to be happened. It simply transfers the control to Message Service (or)
Update Service to perform the same. That’s why this method is faster than Session
method

Note:
In Call Transaction Method session function modules are not required

** Syntax for Call Transaction Method:


CALL TRANSACTION <T code> USING <it_bdcdata>
MODE <mode>
UPDATE <update>
MESSAGE INTO <it_bdcmsgcoll>
OPTIONS FROM <ctu_param>

Parameters & Modes in Call Transaction Method:


Parameter Mode
1. MODE A ----------- Foreground
E ----------- Error
N ----------- Background
2. UPDATE A ----------- Asynchronous
S ------------ Synchronous
3. MESSAGE M

Append Mode (A):


It is foreground processing

Error Mode (E):


If error occurs then only it will display screen & remaining processing is background

No Display Mode (N):


It is background processing

Ashok
SAP-ADV ABAP 23

Update Parameter:
Using this parameter, you can switch the control from asynchronous to synchronous

Message Parameter:
It is for error handling in Call Transaction Method

Flow of Data in Call Transaction Method:


Flat File
(using function module)
It_data
(using LOOP………ENDLOOP)
Wa_data
(using APPEND keyword)
It_bdcdata
(using function module CALL TRANSACTION)
Screens

LUW

Database Tables

Ashok
SAP-ADV ABAP 24

Requirement:
Upload pricing data using Call Transaction Method

Every company will increases the prices of their finished products using VK11 application

Solution:
Step-1:
 Go to SHDB
 New Recording
 Recording: ZVK11_RECO
 Transaction Code: VK11
 Start Recording
 Condition Type: ZZ01
 Enter
 Sales Organization: 1000
 Distribution Channel: 10
 Material: 100-100
 Amount: 500
 Unit: INR
 Valid From: 01.07.2014
 Valid To: 31.12.2014
 Save
 Save
 Back

Step-2:
 Go to SHDB
 Select your recording name (ZVK11_RECO)
 Program
 Program Name: ZMM_VK11_UPLOAD
 Transaction For Recording
 Enter
 Title: BDC for VK11
 Type: Executable Program
 Source Code
 Local Object
 You will find a program
 Remove starting 3 lines
i.e. INCLUDE BDCRECXL
START-OF-SELECTION
……………………….

Ashok
SAP-ADV ABAP 25

 From bottom remove last 2 lines


i.e. PERFORM BDC_TRANSACTION USING
………………….

Step-3:
Write your program from begging of given program

** TYPE-POOLS TRUXS.

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.


PARAMETER p_file TYPE rlgrap-filename.
SELECTION-SCREEN: END OF BLOCK b1.

TYPES: BEGIN OF ty_fi01,


banks TYPE banks,
bankl TYPE bankl,
banka TYPE banka,
stras TYPE stras,
brnch TYPE brnch,
END OF ty_fi01.

DATA: wa_vk01 TYPE ty_fi01,


vk_01 TYPE TABLE OF ty_fi01.

* mapping objects
DATA: wa_bdcdata TYPE BDCDATA,
it_bdcdata TYPE BDCDATA.

DATA: t_raw TYPE TRUXS_T_TEXT_DATA.

* F4 functionality
AT SELECTION-SCREEN ON VALUE_REQUEST FOR p_file.

PERFORM open_file.

START-OF-SELECTION.

PERFORM upload.
PERFORM process_data.
PERFORM fill_cat.
PERFORM display_data.

Ashok
SAP-ADV ABAP 26

FORM open_file.

CALL FUNCTION ‘F4_FILENAME’


EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ‘p_file’
IMPORTING
FILE_NAME = p_file.

ENDFORM.

FORM upload.

CALL FUNCTION ‘TEXT_CONVERT_XLS_TO_SAP’


EXPORTING
I_TAB_RAW_DATA = t_raw
I_FILENAME = p_file
TABLES
I_TAB_CONVERTED_DATA = it_fi01.

ENDFORM.

** FORM process_data.
LOOP AT it_fi01 INTO wa_fi01.
REFRESH it_bdcdata.

Remove dummy values & provide work area


wa_fi01-banks.
wa_fi01-bankl.
wa_fi01-banka.
wa_fi01-stras.
wa_fi01-ort01.
wa_fi01-brnch.

* transfer mapped data to session


CALL FUNCTION ‘BDC_INSERT’
EXPORTING
TCODE = ‘FI01’
TABLES
DYNPROTAB = it_bdcdata.

Ashok
SAP-ADV ABAP 27

ENDLOOP.

ENDFORM.

* screen mapping
FORM BDC_DYNPRO USING PROG SCREEN.

CLEAR wa_bdcdata.

wa_bdcdata-program = prog.
wa_bdcdata-dynpro = screen.
wa_bdcdata-dynbegin = ‘X’.

APPEND wa_bdcdata TO it_bdcdata.

ENDFORM.

* field mapping
FORM BDC_FIELD USING FIELD VALUE.

CLEAR wa_bdcdata.

wa_bdcdata-fnam = field.
wa_bdcdata-fval = value.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM.

Step-4:
Create a Flat File MS-XL
IN SBI009 STATEBANKOFINDIA LBNAGAR HYDERABAD
IN SBH008 STATEBANKOFHYD AMEERPET HYDERABAD

Step-5:
 Go to SE38
 Execute
 Apply F4
 Select your Flat File
 Open
 Execute

 Go to SM35
 Select your Session name
Ashok
SAP-ADV ABAP 28

 Process
 Background
 Process

Ashok
SAP-ADV ABAP 29

08-11-2014
Question:
What is the difference between Session Method & Call Transaction Method?
Answer:
Session Method Call Transaciton Method
1. It for uploading large amount of data 1. It for uploading small amount of data
2. Multiple applications can be processed 2. Only single application can be processed
at one time with one BDC program at one time with one BDC program
3. In this method respective Log File is 3. In this method we have to create Log file
already given by SAP explicitly using structure BDCMSGCOLL
4. Asynchronous processing 4. Synchronous processing
5. Synchronous updating 5. Asynchronous updating
6. It is a slower method but consistent 6. Faster than Session method

Question:
How will you handle error records BDC?
Answer:
 In real time client will ask error records during BDC upload
 For that we have to provide him Logs in the form of error file
 In Session Method Log file you can find directly in SM35
 In Call Transaction Method as processing synchronous we have to create a Log file
internal table based on structure BDCMSGCOLL which holds log details during
processing of application
 The error records are looped to respective work area which further exported to Funtion
Module FORMAT_MESSAGE
 It returns a Message ID which I will capture by using a dummy internal table

Ashok
SAP-ADV ABAP 30

LSMW:
 Legacy System Migration Work bench
 It is convenient tool for migrating Non-SAP (or) Legacy data from one system to another
system

Difference between BDC & LSMW:


BDC LSMW
1. Same Flat file can be uploaded 1. Use this method for uploading data at one time
Number of times
2. Here recording you have to do 2. Recording is in-built
Separately using SHDB
3. Mapping is maintained manually 3. Mapping is done by system itself
Using program

Method in LSMW:
1. Batch Input Recording (Session Method)
2. IDOC Method
3. BAPI Method
4. Direct Input Method

Note:
 The T code for working with LSMW is LSMW
 In real time LSMW is mostly performed by Functional Consultant

Example:
 Go to LSMW
 Project: ZFI_LSMW
 Sub Project: ZFI_SUBPRO
 Project: ZFI_SESSION
 Create Entry
 Description: LWMW Project
 Enter
 Description: Sub Project
 Enter
 Name: Session name
 F8
 If Numbering Off is selected get it into Numbering On
 If Double Click = Display get it into Double Click = Change

Ashok
SAP-ADV ABAP 31

****
Step-1: Maintain object attributes
With this step you can maintain attributes for your method
i.e. Method name, Recording details……………etc
 Select F8
 Option
 Recording Overview
 Create Recording (Ctrl + F1)
 Recording: FILSMW
 Description: Recording
 Enter
 Transaction Code: FI01
 Enter
 Bank Country: IN
 Bank Key: B0001
 Enter
 Bank Name: SBH
 Street: LBNagar
 City: Hyderabad
 Bank Branch: LBNagarBranch
 Save
 Double click on BNKA-BANKS
 Name: BANKS
 Name: Bank Country
 Default Value: ____________
 Enter
 Double click on BNKA-BANKL
 Name: BANKL
 Name: Bank Key
 Default Value: ____________
 Enter
 Repeat the same procedure with BNKA-STRAS, BNKA-ORT01, BNKA-BRNCH
 Save
 Back
 Back
 Batch Input Recording
 Recording: FILSMW
 Enter
 Save
 Back

Ashok
SAP-ADV ABAP 32

Step-2: Maintain source structure


With this step source structure is created based on flat file
 F8
 Create
 Source Structure: ITBANK
 Description: Bank internal table
 Enter
 Save
 Back

Step-3: Maintaing source fields


With this step fields are created
 F8
 Select ITBANK
 Table Maintaince (Ctrl + F9)
Field name Type Length Description
BANKS C 3 Country
BANKL C 10 Key
BANKA C 40 Name
STRAS C 40 Street
ORT01 C 40 City
BRNCH C 40 Branch

 Save
 Back
 Save
 Back

Step-4: Maintain structure relations


With this step recording is linked with source structure ITBANK
 F8
 Save
 Back

Step-5: Maintain field mapping & conversion groups


With this step field mapping is done
 F8
 Select BANKS
 Source Field (Ctrl + F2)
 You will find a pop-up, Double click on BANKS
 Select BANKL
 Source Field (Ctrl + F2)
Ashok
SAP-ADV ABAP 33

 You will find a pop-up, Double click on BANKL


 Repeat the same procedure for BANKA, STRAS, ORT01, BRNCH
 Save
 Back

Step-6: Maintain fixed values and translating user defined routines


With this step routing are linked with LSMW

Note:
This step is not required ignore it

 Select Step-7

Step-7: Specify fields


With this step flat file is maintained
Create a flat file (XL (or) Notepad) in the following manner
IN B0001 SBH LBNagar Hyderabad LBNagarBranch

 F8
 Double click Legacy Data On The PC (Frontend)
 Apply F4 on File
 Select your flat file from required path
 Name: Flat file
 Delimitor
 Tablator

Note:
If headings are maintained in Flat file it is mandatory to select check Fields Names At Start Of
File

 Enter
 Save

Note:
Sometimes you may find an error ‘Field names at start of File………….up to 45
charectors…..remaing data saved’. If you get this error
 Doublce click on Convert Data
 File: your flat file path
 Save

 Back

Ashok
SAP-ADV ABAP 34

Step-8: Assign fields


 With this step flat file is linked with source structure FIBANK
 F8
 Save
 Back

Step-9: Read data


 With this step data is uploaded from flat file to source structure
 Execute
 Execute
 Back
 Back

Step-10: Display read data


 With this step data in source structure can be viewed
 Execute
 Enter
 Back

Step-11: Convert data


 With this step screen mapping is done. This step is directly linked with Step-1
 Execute
 Execute
 Back
 Back

Step-12: Display converted data


 With this step converted data is displayed
 Execute
 Enter
 Back

Step-13: Create batch input session


 With this step session is created
 Execute
 Execute
 You will find a message ‘1 batch input folder with 1 transaction created’, Enter

Step-14: Run batch input session


 With this step session is processed
 Execute
 Select your session
Ashok
SAP-ADV ABAP 35

 Process
 Enter
 Enter
 Enter

Ashok
SAP-ADV ABAP 36

09-11-2014
SKIP Functionality:
Requirement:
Upload material master data with MM01 using flat file with headings & logo

Flat File:
A-922 M ROH Sodaash Kg R1111 1000 Kg 800
A-923 M ROH Sodaash Kg R1111 1000 Kg 800

Solution:
ZMM_MM01_BDC1

Ashok
SAP-ADV ABAP 37

BDC with Table Control:


Requirement:
Upload vendor master data using XK01 using Table Control

Flat File:
9444 1000 1000 0001 MR Satya Google
LBNagar Hyderabad IN, IN, IN, IN, IN, IN SBI001,SBH001, ICICI001,
HDFC001, CANARA001, AXIS001 30941209294, 30941209295, 30941209296,
30941209297, 30941209298, 30941209299 31000 A1 INR

Solution:
 Go to SHDB
 New Recording
 Transaction Code: XK01
 Start Recording
 Vendor: 8733
 Company Code: 1000
 Purchase Org: 1000
 Account Group: 0001
 Title: MR
 Name: Satya
 Search Term: Google
 Postal Code: 500074
 City: Hyderabad
 Country: IN
 Enter
 No data in this screen
 Enter
 Country: IN
 Bank Key: SBH001
 Bank Account: 30941209294
 Enter
 Enter
 Recoun. Amount: 31000
 Cash Mng Group: A1
 Enter
 No data in this screen
 Enter
 No data in this screen
 Enter
 Order Currency: INR
 Enter
Ashok
SAP-ADV ABAP 38

 Save
 Save
 Back
 Select your recording
 Program
 Program Name: ZVENDOR_UPLOAD
 Transfer For Recording
 Enter
 Title: BDC for recording
 Type: Executable Program
 Source Code
 Remove starting 3 lines
 Remove last 3 lines
 Write your program
ZXK01_UPLOAD

Ashok
SAP-ADV ABAP 39

File Handling:
 If flat file is maintaining in presentation server then any-body can manipulated it
 Even flat files can be maintained in application server also where data is more secure as it
is managed by administrator
 If the flat file is maintained in presentation server then it is a part of Physical File
Handling
 If the flat file is maintained in application server then it is a part of Logical File Handling

Opening a File in Application Server in Output Mode (Write Mode):


Syntax:
OPEN DATASET <file> FOR OUTPUT IN BINARY MODE.
-------------
-------------
CLOSE DATASET <file>.

Example:
 Go to SE38
 Program: ZSD_OPEN_DATASET
 Create
 Title: Opening dataset
 Type: Executable Program
 Enter
 Local Object

PARAMETERS p_file(100) TYPE C.

INCLUDE ZCUSTOM.

OPEN DATASET p_file FOR OUTPUT IN BINARY MODE.


SELECT kunnr land1 name1 ort01 pstlz stras FROM KNA1 INTO TABLE
it_kna1 UPTO 10 ROWS.

LOOP AT it_kna1 INTO wa_kna1 FROM 1 TO 4.


TRANSFER wa_kna1 TO p_file.
ENDLOOP.

CLOSE DATASET p_file.

 Double click on ZCUSTOM


 Yes
 Enter

Ashok
SAP-ADV ABAP 40

 Local Object

TYPES: BEGIN OF ty_kna1,


kunnr TYPE kunnr,
land1 TYPE land1,
name1 TYPE name1,
ort01 TYPE ort01,
pstlz TYPE pstlz,
stras TYPE stras,
END OF ty_kna1.

DATA: wa_kna1 TYPE ty_kna1,


it_kna1 TYPE TABLE OF ty_kna1.

 Activate
 Back
 Activate
 Execute
 P_file: D:\opendataset.txt
 Execute

Ashok
SAP-ADV ABAP 41

Opening a File in Input Mode (Read Mode):


Syntax:
OPEN DATASET <file> FOR INPUT IN BINARY MODE.
-------------
-------------
CLOSE DATASET <file>.

Example:
 Go to SE38
 Program: ZSD_CUSTOMER
 Create
 Title: BDC for customer master data
 Type: Module Pool
 Save
 Local Object

 Go to SE51
 Program: ZSD_CUSTOMER
 Screen: 100
 Create
 F6
 Table: KNA1
 Enter
 Select required fields (kunnr, land1, name1, ort01, pstlz, stras)
 Enter
 Place the fields on the screen
 Place two buttons (INSERT, EXIT) on the screen
 Provide Text & FCT code of buttons
 Flow Logic
 Remove comment for MODULE USER_COMMAND_100
 Double click on USER_COMMAND_100
 Yes
 Main Program
 Enter

TABLES KNA1.

 Place cursor between MODULE…………ENDMODULE of USER_COMMAND_100

CASE SY-UCOMM.
WHEN ‘INSERT’.
INSERT KNA1.
Ashok
SAP-ADV ABAP 42

IF SY-SUBRC EQ 0.
MESSAGE ‘Record inserted’ TYPE ‘I’.
ELSE.
MESSAGE ‘Inserting failed’ TYPE ‘E’.
ENDIF.

WHEN ‘EXIT’.
LEAVE TO SCREEN 0.
ENDCASE.

 Activate
 Back
 Activate

 Go to SE93
 Transaction Code: ZCUST
 Screen: 100
 Save

 Go to SE38
 Program: ZSD_CUSTOMER_BDC
 Create
 Title: BDC for customer data
 Type: Executable Program
 Enter
 Enter

PARAMETERS p_file(100) TYPE C.

INCLUDE ZCUSTOM.

DATA: wa_bdcdata TYPE BDCDATA,


it_bdcdata TYPE BDCDATA.

OPEN DATASET p_file FOR INPUT IN BINARY MODE.


DO.
READ DATASET p_file INTO wa_kna1.
IF SY-SUBRC NE 0.
EXIT.
ELSE.
REFRESH it_bdcdata.
Ashok
SAP-ADV ABAP 43

PERFORM bdc_dynpro USING ‘zsd_customer_bdc’ ‘100’.


PERFORM bdc_field USING: ‘kna1-kunnr’ wa_kna1-kunnr,
‘kna1-land1’ wa_kna1-land1,
‘kna1-name1’ wa_kna1-name1,
‘kna1-ort01’ wa_kna1-ort01,
‘kna1-pstlz’ wa_kna1-pstlz,
‘kna1-stras’ wa_kna1-stras,
‘bdc-okcode’ ‘/00’.

CALL TRANSACTION ‘ZCUSTOM’ USING it_bdcdata MODE ‘A’.

ENDIF.
ENDDO.

CLOSE DATASET p_file.

FORM bdc_dynpro USING prog screen.


CLOSE wa_bdcdata.
wa_bdcdata-program = prog.
wa_bdcdata-dynpor = screen.
wa_bdcdata-dynbegin = ‘X’.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM.
FORM bdc_field USING field value.
CLOSE wa_bdcdata.
wa_bdcdata-fname = field.
wa_bdcdata-fval = value.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM.

 Execute
 P_file: D:\opendataset.txt

Ashok
SAP-ADV ABAP 44

Assignment-1:
Upload asset master data with AS02 using Call Transaction Method

Flat File:
Asset number Sub asset number Company code Qunatity
3000006 0 0005 300

Recording:
 Go to SHDB
 New Recording
 Recording: ZREC_AS02
 Transaction Code: AS02
 Start Recording
 Asset: 3000003
 Sub Number: 0
 Company Code: 0005
 Enter
 Quantity: 200
 Save
 Back
 Save

Solution:
 Go to SHDB
 Select your recording
 Program
 Title: BDC for AS02
 Type: Executable Program
 Source Code
 Remove first 3 lines
 Remove last 2 lines & write your program

Ashok
SAP-ADV ABAP 45

Assignment-2:
Upload employee payroll for infotype 14 with PA30 using Call Transaction Method

Flat File:
Employee number Amount
1000 3000
1001 5000
1002 7000

Recording:
 Go to SHDB
 New Recording
 Recording: ZREC_PA30
 Transaction Code: Pa30
 Start Recording
 Employee number: 1000
 Infotype: 14
 Sty: M110
 F6
 Start: 01.04.2013
 To: 31.03.2014
 Wage Type: M110
 Amount: 3000
 Save
 Back
 Save

Solution:
 Go to SHDB
 Select your recording
 Program
 Title: BDC for PA30
 Type: Executable Program
 Source Code
 Remove first 3 lines
 Remove last 2 lines & write your program

Ashok
SAP-ADV ABAP 46

SAP Scripts:
Using Scripts you can design Forms & send the data for print outs

Components of Scripts:
1. Form
2. Page
3. Window
4. Page Window
5. Layout
6. Paragraph Formats
7. Character Formats
8. Header

Form:
It is a collection of pages

Page:
It is a collection of windows

Window:
It is the smallest element of a form, which holds actual data

Page Window:
Using this option windows are maintained in a page in SAP Scripts

Layout:
All windows are adjusted in a page using layout

Paragraph Formats:
With this option you can maintain Font size, Style, Color, Underline……….etc for text on a
form

Character Formats:
Using this option you can maintain Font size, Style, Color…….etc for text (for special
characters in a form)

Header:
Using header administrative data (client number, date of creation, date of change, user
id……..etch) is maintained

Ashok
SAP-ADV ABAP 47

*** Types of Windows:


1. Main Window
2. Constant Window
3. Variable Window

Main Window:
 It is a default window in forms
 Use this window for maintaining dynamic length data (transactional data)
 In one page you can maintain 99 Main Windows (Main 00 to Main 98)

Note:
Without Main Window you cannot work with Scripts

Constant Window:
It is reflected to all the pages of a form

Note:
Maintain Logos, Headers, Footers……….etc using this window

Variable Window:
It is restricted to a specific page

Flow of Data in Scripts:


(Printer, Fax…….etc)

SAPLD SE38

Ashok
SAP-ADV ABAP 48

Note:
SAPLD provides interface between Form Painter & External Devices

Note:
T code for working with Scripts is SE71

Flow of Creating Form (Steps):


1. Page
2. Paragraph Formats
3. Character Formats
4. Assign paragraph formats to header
5. Create windows
6. Assign all windows to page using page window
7. Write logic for each window
8. Adjust all windows in layout
9. Activate form
10.Create driver program (print program)

Ashok
SAP-ADV ABAP 49

Requirement:
Goods receipt form

Solution:
Step-1: Form
 Go to SE71
 Form: ZFORM_GRN
 Create
Ashok
SAP-ADV ABAP 50

 You will find a message, Enter


 Meaning: GRN Form

Step-2:
 Select Pages
 Page: PAGE1
 Next Page: PAGE1
 Enter
 Meaning: page1

Step-3:
 Select Paragraph Formats
 Paragraph: P1
 Enter
 Meaning: p1
 Font
 Family: COURIER
 Font Size: 12
 BOLD ON

Step-4:
 Select Character Formats
 Char. Format: C1
 Enter
 Meaning: c1
 Family: HELVE
 Size: 10
 BOLD ON

Step-5:
 Select Header (F5)
 Basic Settings
 First Page: PAGE1
 Default Paragraph: P1

Step-6:
 Select Windows
 Edit ------ Create Element
 Window: LOGO
 Meaning: window
 Enter
 Window Type: CONST
Ashok
SAP-ADV ABAP 51

 Edit ------- Create Element


 Window: PAGE
 Meaning: window
 Enter
 Repeat the same procedure for USER, HEADER, HEADER1

Step-7:
 Select Page Windows
 Edit ----- Create Element
 You will find a pop-up, Double click on HEADER
 Window Width: 5
 Window Height: 5
 Edit ----- Create Element
 Double click on HEADER1
 Window Width: 5
 Window Height: 5
 Edit ----- Create Element
 Repeat the same procedure for USER, PAGE, MAIN, CONST, LOGO windows

Note:
When you maintain MAIN window using Page Windows you will get MAIN window again in
the pop-up (as we can maintain 99 MAIN windows in a Page). So next time you don’t select it

Step-8:
 Double click on MAIN window
 Edit ----- Text Elements
 Goto ----- Change Editor

/: SUMMING &wa_msg-dmbtr& INTO &wa_sum&


/E ELEL
/: TOP
/: IF &page& NE 1
* ,,,,,,,,,,<C1>Carry forward amount: &wa_sum&</>
/: ENDIF
/: ENDTOP
*
* &sno&,,&wa_mseg-matnr&,,&wa_mseg-bwart&,,&wa_mseg-menge&
= &wa_mseg-dmbtr&
/E PAGE_TOTAL
* &uline(60)&
* ,,,,,,,,,,<C1>Page total: &wa_sum&</>
*
Ashok
SAP-ADV ABAP 52

/E GRAND_TOTAL
* &uline(60)&
* ,,,,,,,,,,<C1>Grand total: &wa_sum&</>
 Back

Step-9:
 Double click HEADER window
 Edit ----- Text Elements
 Goto ----- Change Editor

/: BOX WIDTH 7 CM HEIGHT 4 LN FRAME 4 TW INTENSITY 8


* ,,Reddy labs
* An Anji Reddy Group
* Ameerpet-500074
 Back
 Next Page

Step-10:
 Double click on HEADER1 window
 Edit ----- Text Elements
 Goto ----- Change Editor

* &uline(60)&
*
* Sno,,,,Material,,,,Material Type,,,,Quantity,,,,Amount
* &uline(60)&
 Back

Step-11:
 Double click on LOGO window
 Edit ----- Text Elements
 Goto ----- Change Editor

/: BITMAP enjoy OBJECT GRAPHICS ID BMAP TYPE BCOL


 Back
 Next Page

Step-12:
 Double click on PAGE window
 Edit ----- Text Elements
 Goto ----- Change Editor
/: BOX WIDTH 5 CM HEIGHT 1 LN FRAME 4 TW
Ashok
SAP-ADV ABAP 53

* PAGE &page& OF &sapscript_jobpages&


 Back

Step-13:
 Double click on USER window
 Edit ----- Text Elements
 Goto ----- Change Editor

/: BOX WIDTH 5 CM HEIGHT 2 LN FRAME 4 TW


* USERNAME: &sy-uname&
* DATE: &sy-datum&
 Back

Step-14:
 Select Settings
 Form Painter
 By default graphical pc editor selected, Deselect it
 Select Graphical Form Painter
 Enter
 Adjust all the windows according to the size of data
 Select Minimize
 Settings ------ Form Painter
 Deselect Graphical Form Painter check box
 Select Graphical PC Editor check box
 Select Utilities -------- Printing Text
 You will find a pop-up
 Output Device: LP01
 Print Preview
 Form
 Activate
 Local Object

Step-15:
 Go to SE38
 Program: ZGRN_FORM
 Create
 Title: Forms for GRN details
 Type: Executable Program
 Enter
 Local Object
 Write driver program
ZGRN_COL_FORM
Ashok
SAP-ADV ABAP 54

TYPES: MKPF, MSEG.

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.


SELECT-OPTIONS: s_mblnr FOR mkpf-mblnr,
s_werks FOR mseg-werks,
s_bukrs FOR mseg-bukrs,
s_budat FOR mkpf-budat.
SELECTION-SCREEN: END OF BLOCK b1.

TYPES: BEGIN OF ty_mseg,


matnr TYPE matnr,
bwart TYPE bwart,
menge TYPE menge_D,
dmbtr TYPE dmbtr,
END OF ty_mseg.

DATA: wa_mseg TYPE ty_mseg,


it_mseg TYPE TABLE OF ty_mseg.

DATA: sno TYPE I,


wa_sum TYPE DMBTR.

PERFORM get_mseg.
PERFORM open_form.
PERFORM start_form.
PERFORM process_form.
PERFORM end_form.
PERFORM close_form.

FORM get_mseg.
SELECT mseg~matnr mseg~bwart mseg~menge mseg~dmbtr INTO TABLE it_mseg
FROM MKPF INNER JOIN MSEG
ON mkpf~mblnr = mseg~mblnr
WHERE mkpf~mblnr IN s_mblnr
AND mseg~werks IN s_werks
AND mseg~bukrs IN s_bukrs
AND mseg~budat IN s_budat.
ENDFORM.

FORM open_form.
CALL FUNCTION ‘OPEN_FORM’.
Ashok
SAP-ADV ABAP 55

EXPORTING
LANGUAGE = SY-LANGU
FORM = ‘ZFORM_GRN’.
ENDFORM.

FORM start_form.
CALL FUNCTION ‘START_FORM’
EXPORTING
STARTPAGE = ‘PAGE1’
LANGUAGE = SY-LANGU
FORM = ‘ZFORM_GRN’.
ENDFORM.

FORM process_form.
LOOP AT it_mseg INTO wa_mseg.
sno = sno + 1.
CALL FUNCTION ‘WRITE_FORM’
EXPORTING
ELEMENT = ‘ELE1’
WINDOW = ‘MAIN’.

IF sno = 8.
CALL FUNCTION ‘WRITE_FORM’
EXPORTING
ELEMENT = ‘PAGE_TOTAL’
WINDOW = ‘MAIN’.

CALL FUNCTION ‘CONTROL_FORM’


EXPORTING
COMMAND = ‘NEW-PAGE’.

sno = 0.
ENDIF.

AT LAST.
CALL FUNCTION ‘WRITE_FORM’
EXPORTING
ELEMENT = ‘GRAND_TOTAL’
WINDOW = ‘MAIN’.
ENDAT.

ENDLOOP.
Ashok
SAP-ADV ABAP 56

ENDFORM.

FORM end_form.
CALL FUNCTION ‘END_FORM’.
ENDFORM.

FORM close_form.
CALL FUNCTION ‘CLOSE_FORM’.
ENDFORM.

 Execute driver program


 Material Doc: 49000000 to 49000100
 Execute
 You will find a pop-up,
 Output Device: LP01
 Print Preview

Ashok
SAP-ADV ABAP 57

Function Modules for Print Program:


1. OPEN_FORM:
Activates a form in SAP Scripts (pass Form name & Language)

2. STRAT_FORM:
It opens a form from a specific page (pass Form name & Page name)

3. WRITE_FORM:
It is for calling text elements in SAP Scripts (pass Text element name & Window name)

4. END_FORM:
It is for closing START_FORM

5. CLOSE_FORM:
It is for closing OPEN_FORM

Script Symbols:
1. * ----- default paragraph
2. ----- continous text
3. = ------- extended line
4. / ------- line field (one line gap)
5. /= ------ line field & extended line
6. /: ------ command line (it is for script commands i.e. BOX, BITMAP)
7. /* ------ comment line
8. /E ------ text element
9. TW ---- twip

1 TW = 1/20 PT (points)
1 PT = 1/72 inches

Debugging SAP Scripts:


 Go to SE71
 Form: ZFORM_GRN
 Utilities ------ Activate Debugger

 Go to SE38
 Program: ZGRN_COL_FORM
 Debugging

Ashok
SAP-ADV ABAP 58

Assignment:
PO Form

Logic:
* Item number &space(5)&Item description &space(30)& Unit of measurement &space(5)&
PO Quantity &space(5)& Unit price &space(5)& Total price &space(5)&
/ BOX FORM 4 TW
/ BOX HIEGHT 2 LN FRAME 4 TW INTENSIVILY 8
/ BOX WIDTH ‘15’ CH HIEGHT ‘15’ LN FRAME 4 TW
/ BOX WIDTH ‘30’ CH HIEGHT ‘15’ LN FRAME 4 TW

Solution:
ZGRN_FORM

Ashok
SAP-ADV ABAP 59

10-11-2014
Standard Forms:
 SAP is providing standard forms which are stored in a table TNAPR
 In these standard forms we have to make our own modifications based on requirement &
customize the same in NACE T-code

Example:
Step-1: coping a standard form into user defined form
 Go to SE71
 Utilities ----- Copy From Client
 Form Name: MEDRUCK
 Source Client: 800
 Target Form: ZPO_MEDO
 Execute
 Package: YABAP
 Enter
 Create Request

Step-2: adding a logo in a form


 Go to Paint
 Design a logo
 Save it on desktop

 Go to SE78
 Expand Graphics-General Graphics
 Double click on BMAP-Bit Map Images
 Graphics ---- Input
 Apply F4 on File Name
 Select your logo
 Name: SCRIPTLOGO
 Description: script logo
 Color Bit Map Image
 Enter
 Graphic
 Transport
 Enter

 Go to SE71
 Form: ZPO_MEDD
 Change
 Page Windows
 Try to find HEADER window by selecting Next Page option
Ashok
SAP-ADV ABAP 60

 Double click on HEADER window


 Edit ---- Text Elements
 Goto ---- Change Editor
 Place cursor on INCLUDE
 Apply End by keyboard
 Enter
/: BITMAP SCRIPTLOGO OBJECT GRAPHICS ID BMAP TYPE BCOL
 Back
 Form ---- Activate
 Utilities ----- Printing Test
 Print Preview

Step-3: adding a field lable based on logic


 Go to SE71
 Form: ZPO_MEDO
 Change
 Page Windows
 Double click on INFO1 window
 Edit ---- Text Elements
 Goto ---- Change Editor
 Place cursor starting of 1st line
 Apply 4 times Enter & see that existing code should not be deleted
AS <S>Modifing Layout </>
/: IF ekko-lifnr > 1001
/ Plant ID is 1001
/: ENDIF

 Back
 Form ----- Activate

Step-4: customizing a form in NACE T-code


Note:
This job is done by MM Functional Consultant

 Go to NACE
 Application EF
 Output Types
 Position
 Output Type: NEU
 Enter
 Select NEU
 On left side double click on processing Routines
Ashok
SAP-ADV ABAP 61

 Display / Change
 Form: ZPO_MEDD
 Save
 Enter

Step-5: testing the application with ME9F


 Go to ME9F
 Vendor: 1000 to 3000
 Execute
 Select any one check box
 Display Message

Step-6: transporting a form from one client to another client


Note:
We know that SAP Script is client dependant
Using program RSTXR3TR we can transport a form from one client to another client

 Go to SE10
 Display
 Expand Main request number
 Select sub request number
 Select Truck symbol Relase
 Select main request number
 Select Truck symbol Relase

 Go to SE38
 Program: RSTXR3TR
 Execute
 Transport Request: LID0001
 Export
 File Name: ‘ZPO_MEDD’
 Execute

 Log on to 810 client


 Go to SE38
 Program: RSTXR3TR
 Execute
 Transport Request: LID0001
 Import
 File Name: ZPO_MEDD
 Execute
 Go to SE71-------- Form: ZPO_MEDO---------- Change
Ashok
SAP-ADV ABAP 62

**Smart Forms:
It is a smartest way of working with forms

** Difference between Scripts & Smart Forms:


Script Smart Forms
1. It is client dependent 1. It is client independent
2. Table is created manually using BOX 2. Table can be created automatically
through navigation
3. Data transfer between Print Program & 3. Data transfer between Print Program &
Form is record by record (window by window) Form at one time using a unique Function
Module
4. Paragraph formats & character formats 4. Paragraph formats & character formats
Cannot be reuse can be reuse
5. Back ground pictures cannot be created 5. Can be created
6. With out MAIN window you cannot work 6. You can work without MAIN
window
With Scripts also
7. You cannot work with Scripts without 7. You can work
Print Program
8. ** Templates cannot be created 8. Can be created

Components of Smart Forms:


1. Form
2. Style
3. Text Module

Form:
It is a collection of Pages

Style:
It is for Paragraph Formats & Character Formats

Text Module:
Maintains conditional data

Types of Windows:
1. Main Window
2. Secondary Window
3. Final Window
4. Copies Window

Main Window:
Ashok
SAP-ADV ABAP 63

Use this for holding dynamic length data (transactional data)


Note:
Without Main window also you can work with Smart Forms

Secondary Window:
Use this for holding fixed length data (master data)

Final Window:
Use this for holding final data (totals, grand totals)

Copies Window:
Use this for copy (or) original format data

**Components of Window:
1. Text (maintains logic)
2. Template (static tables can be created)
3. Folder (holds different components together)
4. Address (maintains address)
5. ** Program Lines (create program)
6. Command (maintains page breaks)
7. Alternate (flip flop logic (if condition))
8. Loop (maintains loops)
9. Table Line (different cells logic)
10.Table (holds data dynamically)
11.Graphic (maintains logo)

Flow of Data in Smart Forms:


(Printer, Fax…….etc)

Ashok
SAP-ADV ABAP 64

Steps in Working of Smart Forms:


1. Create style (paragraph formats & character formats)
2. Create form
3. Form
1. Form interface (import & table parameters)
2. Form attributes (maintain styles)
4. Global definitions (create global variables)
5. Create page
1. Background picture
2. ** Print mode for duplex
6. Create windows
1. Graphics window
2. Text window
3. Alternate window
4. Table window
5. Template window
6. Main window……………..etc
7. Adjust windows in a layout (form painter)
8. Activate form
9. Create print program

Note:
T code for working with Smart Forms is SMARTFORMS

Ashok
SAP-ADV ABAP 65

Requirement:
PO Form

Solution:
Step-0: creating structure
 Go to SE11
 Data Type: ZPO_STRUC
 Create
 Structure
 Enter
 Short Description: structure for PO details
Component Compenent type
EBELP EBELP
MAKTX MAKTX
MENGE MENGE
NETPR NETPR
NETWR NETWR

 Currency / Quantity

Ashok
SAP-ADV ABAP 66

Reference table Reference field


EKPO MEINS
T001 WAERS
T001 WAERS
 Activate

Step-1: (creating Paragraph Format & Character Format)


 Go to SMARTFORMS
 Style: ZPO_STYLE
 Create

P1 -Paragraph Format:
 Right click on Paragraph Formats
 Create Node
 Paragraph Formats: P1
 Enter
 Description: p1
 Font
 Font Family: COURIER
 Font Size: 12
 Font Style: BOLD

P2 -Paragraph Format:
 Right click on Paragraph Formats
 Create Node
 Paragraph Formats: P2
 Enter
 Description: p2
 Indents and Spacing
 Alignment: CENTER
 Font
 Font Family: HELVE
 Font Size: 15
 Font Style: BOLD

P3- Paragraph Format:


 Right click on Paragraph Formats
 Create Node
 Paragraph Formats: P3
 Enter
 Description: p3
 Indents and Spacing
Ashok
SAP-ADV ABAP 67

 Alignment: CENTER
 Font
 Font Family: HELVE
 Font Size: 12
 Font Style: BOLD

C1- Character Format:


 Right click on Charector Formats
 Create Node
 Charector Formats: C1
 Enter
 Font
 Font Family: HELVE
 Font Size: 10
 Font Style: BOLD
 Doble click on Header Data
 Standard Paragraph: P1
 Style----- Activate
 Enter
 Back

Step-2: creating Form (Import & Table parameters)


 Form: ZPO_FORM
 Create
 You will find a form, the left part is called Navigation Tree, the right part is called
Maintain Screen. Using Form Painter you can design layout
 By default Form Attributes is selected, on Maintaince Screen select Output Options tab
 Style: ZPO_STYLE

Import parameters:
 Double click on Form Interface
 By default Import tab is selected, provide
Parameter name Type assignment Associated type
EBELN TYPE EBELN
BEDAT TYPE BEDAT
LIFNR TYPE LIFNR

Table parameters:
 Tables
Parameter name Type assignment Associated type
IT_EKPO LIKE ZPO_STRUC

Ashok
SAP-ADV ABAP 68

Step-3: creating Global variables


 Double click on Global Definaitions
Variable name Type assignment Associated type
TOTAL TYPE DMBTR
WA_EKPO TYPE ZPO_STRUC

 Types

TYPES: BEGIN OF ty_lfa1,


lifnr TYPE lifnr,
name1 TYPE name1,
adrnr TYPE adrnr,
END OF ty_lfa1.

TYPES: BEGIN OF ty_adrc,


city1 TYPE ort01,
street TYPE stras,
END OF ty_adrc.

 Global Data
Variable name Type assignment Associated type
WA_LFA1 TYPE TY_LFA1
WA_ADRC TYPE TY_ADRC

 Form Routines
 Currency / Quantity Fields
Field name Reference table Data type
Wa_ekpo-menge wa_ekpo-menge quan
Wa_ekpo-netpr wa_ekpo-netpr curr
Wa_ekpo-netwr wa_ekpo-netwr curr

Step-4: creating windows (LOGO, PO, PAGE, HEADER, VENDOR)


Logo window:
 Right click on PAGE1
 Create------- Window
 Window: LOGO
 Meaning: window for logo
 Enter
 Right click on LOGO window
 Create ------ Graphic
 Apply F4 on Name field

Ashok
SAP-ADV ABAP 69

 You will find a pop-up Color Bit Map Image check box & Deselect Block and White
Image check box
 Execute
 Select any one Logo based on your requirement

Note:
1. In real time logo is provided by client
2. While creating logo you can adjust the size of the logo using Resolution option
3. Double click on PAGE1 on maintaince screen you will find Background Picture option
with this you can maintain background pictures in Smart Forms
4. Select Output Options tab under that you will find Print Mode. If Print Mode is D you
can provide double side printing
5. By default Page Format is Potrate Format which is for form with less fields. If form
contains more fields (say 15, 20,…….etc) use Landscape Format

PO window:
 Right click on LOGO window
 Create ------- Window
 Window: PO
 Meaning: template for po
 Enter
 Right click on PO window
 Create ------ Template
 To increase the Width & Height of a template, double click on PO window
 On maintaince screen select Output Options tab
 Width: 10
 Height: 10

Note:
Only upto 25 only we can provide for Height & Width

 Enter
 Double click on Template 1
 Select Template tab
 Increase the width of a template based on your requirement
 Right click on C1
 Split ------ Line
 Right click on C1
 Split ------ Cell
 Right click on C2
 Split ------ Cell
 Under Template tab, select Pattern option (1st button)
Ashok
SAP-ADV ABAP 70

 By default all the patterns are deselected, select Display Framed Patterns option
 Double click on 2nd pattern
 Right click on Template 1
 Create ----- Folder 1
 Right click on Folder 1
 Create ------ Text
 Right click on Text 1
 Create ------ Text
 Similarly create 3 more texts (Text2, Text3, Text4)
 Double click on Text1
 On maintaince screen, select Output Options tab
 Scroll down to bottom
 Line: 1
 Coloumn: 1
 Double click on Text2
 On maintaince screen, select Output Options tab
 Scroll down to bottom
 Line: 1
 Coloumn: 2
 Double click on Text3
 On maintaince screen, select Output Options tab
 Scroll down to bottom
 Line: 2
 Coloumn: 1
 Double click on Text4
 On maintaince screen, select Output Options tab
 Scroll down to bottom
 Line: 2
 Coloumn: 2
 Double click on Text1
 Select Conditions
 Output Options
 Web Properties
 General Attributes
 Select Edit option
 PO Number
(or)
 Goto ----- Change Editor
* PO Number
 Back

 Double click on Text2


Ashok
SAP-ADV ABAP 71

 Select Edit option


 Goto ---- Change Editor
 P1 &EBELN&
 Back
(or)
 Select Field List ON/ OFF option
 At bottom expand Import interface
 Drag & drop EBELN on Editor

 Double click on Text3


 Select Edit option
 PO Date

 Double click on Text4


 At bottom expand Import interface
 Drag & drop BEDAT on Editor

PAGE window:
 Right click on PO window
 Create ------ Window
 Window: PAGE
 Meaning: page number
 Enter
 Right click on PAGE window
 Create ---- Text
 At bottom expand System Fields
 Drag & drop PAGE on Editor (&SFSYT-PAGE&)

Note:
SFSY-is a standard structure for Smart Forms sytem fields

HEADER window:
 Right click on PAGE window
 Create ----- Window
 Window: HEADER
 Meaning: widow for header text
 Enter
 Right click on HEADER window
 Create ----- Text
 Double click on Text5
 Select Editor option
 Goto ------ Change Editor
Ashok
SAP-ADV ABAP 72

P2 REDDY LABS
P2 <C1>,,,,,,An Anji Reddy group </>
P2 <C1>,,,,,, Ameerpet-10 </>
 Back

VENDOR window:
 Right click on HEADER window
 Create ------ Window
 Window: VENDOR
 Meaning: window for vendor details
 Enter
 Right click on VENDOR window
 Create ----Flow Logic -----Program Lines
Input parameters Output parameters
LIFNR WA_LFA1
WA_ADRC
SELECT SINGLE name1 FROM LFA1 INTO wa_lfa1 WHERE lifnr = lifnr.
IF NOT wa_lfa1 IS INITIAL.
SELECT SINGLE city1 street FROM ADRC INTO wa_adrc
WHERE addrnumber = wa_lfa1-kunnr.
 Execute
 Right click on CODE1
 Create ----- Text
 Expand Global Data option
 Expand WA_LFA1
 Editor option
 Goto ---- Change Editor
* Vendor Number: &WA_LFA1-LIFNR&
* Vendor Name: &WA_LFA1-NAME1&
* City: &WA_LFA1-CITY1&
* Street: &WA_LFA1-STREET&

MAIN window:
 Right click on MAIN window
 Create ----- Table
 On maintaince screen you will find %LTYPE1
 Split %LTYPE1 into 5 equal parts
 Right click on %LTYPE1
 Insert ------ Empty Line Underneath
 Split %LTYPE2 into 2 parts

 Under Table tab


Ashok
SAP-ADV ABAP 73

 Select Pattern option


 Select Display Framed Patterns
 Double click on 2nd pattern
 Select Data tab
 Internal Table: IT_EKPO
 Into; WA_EKPO
 Select Calculations tab
Operation Field name Target field Time
SUM total wa_ekpo-netwr total after loop

 Expand HEADER option under Tables


 Right click on HEADER
 Create ----- Table Line
 Line Type: %LTYPE1
 Right click on %CELL1
 Create --- Text
 Conditions
 Output Options
 Web Properties
 General Attributes
 Edit
 Goto ----- Change Editor
P3 Item Number

 Right click on %CELL2


 Create --- Text
 Editor
 Goto --- Change Editor
P3 Item Text

 Right click on %CELL3


 Create --- Text
 Editor
 Goto --- Change Editor
P3 PO Quantity

 Right click on %CELL4


 Create --- Text
 Editor
 Goto --- Change Editor
P3 Unit Price

Ashok
SAP-ADV ABAP 74

 Right click on %CELL5


 Create --- Text
 Editor
 Goto --- Change Editor
P3 Total Price

 Right click on MAIN window


 Create ----- Table Line
 Line Type: LTYPE1

 Right click on %CELL6


 Create --- Text
 Conditions
 Output Options
 Web Properties
 General Attributes
 Editor
 Goto --- Change Editor
P3 &WA_EKPO-EBELP&

 Right click on %CELL7


 Create --- Text
 Editor
 Goto --- Change Editor
P3 &WA_EKPO-ARKTX&

 Right click on %CELL8


 Create --- Text
 Editor
 Goto --- Change Editor
P3 &WA_EKPO-MENGE&

 Right click on %CELL9


 Create --- Text
 Editor
 Goto --- Change Editor
P3 &WA_EKPO-NETPR&

 Right click on %CELL10


 Create --- Text
 Editor
Ashok
SAP-ADV ABAP 75

Goto --- Change Editor


P3 &WA_EKPO-NETWR&

 Right click on Footer option


 Create ----- Table Line
 Line Type: LTYPE2
 Right click on CELL11
 Create ---- Text
 Conditions
 Output Options
 Web Properties
 General Attributes
P3 Total Amount

 Back
 Right click on CELL12
 Create ----- Text
 Editor
 Goto ---- Change Editor
P3 &TOTAL&
 Back

Step-5: adjust windows in a layout


 Select Form Painter option
 Adjust all the windows in layout as per client requirement (based on data size)
 The MAIN widow size should be large as it holds item data
 Form Painter

Step-6: activating form


 Select Activate

Step-7: creating driver program


 Go to SE38
 Program: ZMM_CALL_SMART_FORM
 Create
 Title: Driver program for smart form
 Type: Executable Program
 Enter
 Enter
 Write your driver program

Ashok
SAP-ADV ABAP 76

12-11-2014
Note:
SSF_FUNCTION_MODULE_NAME:
This function module returns a smart form function module generated on activation of smart
form

Ques-1:
Why we should call SSF_FUNCTION_MODULE_NAME instead of hard coding the function
module name itself?
Answer:
 We know that in real time we have to transport the objects from one client to another
client
 If the form is in Quality Server the system may assign a different version of function
module name to respective form & the same happen in Production Server also
 So therefore it always advisable to call SSF_FUNCTION_MODULE_NAME which
returns the function module currently which system you are working

Ques-2:
What are the common errors you are facing while working with smart forms?
Answer:
1. Incorrect parameter with call function
This exception you will get if you not pass all the parameters which you maintained in smart
form

2. Type conflict when calling a function module


This exception you will find when data type of smart form parameters will not match with
attributes of print program

3. Reference field …………unknown in form


This error you will find if you are not maintaining Currency / Quantity fields in smart form

4. *** sometimes your print program will not be executed at all


This will happen when your Window (specially Templates) are not maintained properly

5. Template does not fit into window


This will happen when template height is more than window height

6. Form generation error


This error you will find if form is having internal errors in Production Server thow it is perfectly
tested in Development Server

Ashok
SAP-ADV ABAP 77

7. *** Table is wider than window


This error you will find if your Table (or) Template is wider than your window based on which
is created

8. Graphic cannot be displayed


This error you will find if graphic is not maintained properly

Ques-3:
How do you work with Alternate option in smart form?
Answer:
 Righ click on any one Window (say LOGO)
 Create ----- Window Alternate
 Right click on Alternate Window
 Create ----- Flow Logic ------- Alternate
 Conditions option
Field name Relational Operator
LIFNR double click

 Select =/= (NE) option


Comparision Values
‘ ’
 Right click on True option
 Create ------ Text
 Editor
 PO Created

 Right click on Flase option


 Create ----- Text
 Editor
 PO not created

 Form Painter
 Adjust Alternate window
 Activate form

Ques-4:
How you can work with more than one Page in smart form?
Answer:
 Right click on PAGE1
 Create ------ Page
Ashok
SAP-ADV ABAP 78

 Right click on PAGE2


 Create ---- Window
 Window: LETTER
 Meaning: Window for letter description
 Save
 Right click on LETTER window
 Create ----- Text
 Editor
 Goto ------ Change Editor
* ,,,,,,,,,,Dear Satya,
* ,,,,,,,,,,Yor are shortlisted in Google as a Technical Consultant
* ,,,,,,,,,,Thanking you,

 Back
 Double click on MAIN window
 Window Type: Secondary Window
 Double click on PAGE1
 Next Page: PAGE2
 Double click on PAGE2
 Next Page:______
 Activate form

*** Ques-5:
How you can convert a smart form into PDF format?
Answer:
 Run your print program
 Provide input
 Execute
 Select Print option (Ctrl + P)
 At bottom you will find a print request number note down it (say 11,5716)
 Go to SE38
 Program: RSTXPDFT4
 Execute
 Spool Request: 11,5716
 Execute
 Save

Ques-6:
How you can debug a smart form?
Answer:
 Go to SMARTFORMS
 Form: ZPO_FORM
Ashok
SAP-ADV ABAP 79

 Change
 Expand VENDOR window
 Double click on CODE1
 Provide BREAK-POINT
 Activate form
 Go to SE38
 Program: ZMM_CALL_SMART_FORM (print program)
 Execute

Note:
In smart forms you can set only Static Break Point. You cannot set Dynamic Break Point

Ques-7:
How you can work with Excel Sheet in smart forms?
Answer:
DATA fnam TYPE STRING.

CALL FUNCTION ‘GUI_DOWNLOAD’

Ques-8:
How you can print multiple records in smart forms?
Answer:
ZMM_CALL_SMART_FORMN

TABLES: EKPO, EKKO, LFA1, ADRC.

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.


SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
SELECTION-SCREEN: END OF BLOCK b1.

DATA: fname TYPE RS38L_FNAM,


control TYPE SSFCTRLOP.

DATA: BEGIN OF wa_ekko,


ebeln TYPE ebeln,
bedat TYPE bedat,
lifnr TYPE lifnr,
END OF wa_ekko.

DATA: wa_ekpo TYPE zpo_strucc,


it_ekpo TYPE TABLE OF zpo_strucc.

Ashok
SAP-ADV ABAP 80

DATA: fnam TYPE STRING.


CONTROL-NO_OPEN = ‘X’.
CONTROL-PREVIEW = ‘X’.
CONTROL-NO_DIALOG = ‘X’.
CONTROL-NO_CLOSE = ‘X’.

START-OF-SELECTION.

CALL FUNCTION ‘SSF_OPEN’


EXPORTING
USER_SETTINGS = ‘X’.
CONTROL_PARAMETERS = control.

CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME’


EXPORTING
FORMNAME = ‘ZPO_FORM’
IMPORTING
FM_NAME = FNAME.

LOOP AT S_EBELN.
PERFORM get_data USING s_ebeln-low.

CALL FUNCTION FNAME


EXPORTING
CONTROL_PARAMETERS = control
EBELN = s_ebeln-low
BEDAT = wa_ekko-bedat
LIFNR = wa_ekko-lifnr
TABLES
IT_EKPO = it_ekpo.
ENDLOOP.

CALL FUNCTION ‘SSF_CLOSE’.

FORM get_data USING ORDER.


SELECT SINGLE ebeln bedat lifnr FROM EKKO INTO wa_ekko
WHERE ebeln EQ ORDER.

IF NOT wa_ekko IS INITIAL.


SELECT ebelp txz01 menge netpr netwr FROM EKPO INTO TABLE it_ekpo
WHERE ebeln = wa_ekko-ebeln.
ENDIF.
Ashok
SAP-ADV ABAP 81

ENDLOOP.
Ques-9:
How you can migrate SAP Script to smart form?
Answer:
 Go to SMARTFORMS
 Utilities ---- Migration ----- Import SAP Script Form
 Form: ZPO_MEDD
 Name: ZPO_MEDD
 Enter

Ques-10:
How you can generate smart form into PDF format during runtime of print program?
Answer:

Ques-11:
How you can send of a form in the form of mail?
Answer:

Ques-12:
How you can write code in smart forms?
Answer:

Ques-13:
How you can maintain Page Breaks in smart forms?
Answer:

Ashok
SAP-ADV ABAP 82

13-11-2014
SAP Enhancements:
 SAP is highly customizable
 Using SAP Enhancements you can add additional functionalitites in existing once without
disturbing the same

Types of SAP Enhancements:


1. Userexits
2. Customerexits
3. BADI
4. Enhancement Frame Work
5. BTE

Userexits:
Userexits are empty code blocks within subroutines

Object:
Validate sales order application using Userexits

Business Requirements:
 In real time using VA01 application sales order is created which is again modified by
using VA02
 Write an enhancement to validate VA02 such that one user created sales order is allowed
to modify is by same user only

Solution:
 Go to SE38
 Program: MV45AFZB
 Display
 Select Enhance option
 Edit ---- Enhancement Operations ----- Show Implicit Enhancement Options
 Try to search for USEREXIT_CHECK_VBAK subroutine
 Right click on spot under form USEREXIT_CHECK_VBAK
 Enhancement Implementation ----Create Implementation
 You will find a message, select Code option
 You will find a pop-up, select Create option
 Again you will find a pop-up, provide
 Enhancement Implementation: ZENC_VA02
 Short Text: enhancement for VA02 implementation
 Enter
 Enter

Ashok
SAP-ADV ABAP 83

 Enter
 Again you will find that pop-up, select your Enhancement name i.e. ZENC_VA02
 Enter
IF SY-TCODE EQ ‘VA02’.
IF VBAK-ERNAM NE SY-UNAME.
MESSAGE ‘Access denied’ TYPE ‘E’.
ENDIF.
ENDIF.

 Activate

Testing the Application:


 Go to VA02
 Order: 4969
 Enter
 You will find a pop-up, Enter

Navigation for Deleting Enhancement:


 Go to SE38
 Program: MV45AFZB
 Display
 Enhance
 Place cursor on your enhancement name i.e. ZENC_VA02
 Right click on it
 Enhancement Implementation ----- Undo Implementation
 Activate

Note:
 MV45AFZB & MV45AFZZ are the very important Userexits for VA01, VA02
application which we are working in real time
 Currently Userexits are outdated except above

Ashok
SAP-ADV ABAP 84

Customerexits:
 Customerexits are advanced to Userexits
 Instead of adding customization in existing code it is always better to provide your own
customization using a T code which is done by Customerexits

Note:
Customerexits is based on Fucntional Consultant

Types of Customerexits:
1. Function Exits
2. Menu Exits
3. Screen Exits
4. Field Exits

Function Exits:
Object:
Validate vendor master application for postal code

Business Requirement:
 Some times users will not enter Postal code, City, Tax code……..etc in an application
which are optional but important for clients
 Provide validation such that without entering Postal code the transaction should not be
created

Note:
** The T code for working Customerexits is CMOD
** The T code for identifying Customerexits for an application is SMOD

Solution:
Step-1: identifying Package name of an application
 Go to XK01
 System -----Status
 Double click on Program Name
 Goto ---- Attributes
 Note down package name (FBK)

Step-2: identifying Customerexits for an application


 Go to SMOD
 Apply F4 on Enhancement field
 You will find a pop-up, at bottom select Information System button
 Package: FBK

Ashok
SAP-ADV ABAP 85

 Enter
 Note down Customerexits (SAPMF02K)

Note:
In real time Customerexits for an application is provided by Functional Consultant

Step-3: writing enhancement


 Go to CMOD
 Project: ZENC_XK01
 Create
 Short Text: customerexits for xk01
 Save
 Enhancement Assignments button
 Select your enhancement SAPMF02K
 Enter

 You may find an error message ‘SAP enhancement……….SAPMF02K already belongs


to project……….’
 If you are getting such error you have to delete the old enhancement

Deleting Customerexits Enhancement:


 Note down old enhancement name (ZH1XK01)
 Go to /OCMOD
 Project: ZH1XK01
 Deactivate
 Delete option
 Yes
 Enter

Note:
** In Customerexits you cannot reuse the same exit in more than one project

 Select Components option


 Yes
 Double click on function module EXIT_SAPMF02K_001
 Scroll down to bottom
 Double click on INCLUDE
IF I_LFA1-PSTLZ IS INITIAL.
MESSAGE ‘Enter postal code’ TYPE ‘E’.
ENDIF.
 Activate
 Back
Ashok
SAP-ADV ABAP 86

 Back
 Back
 Activate project

Testing the Application:


 Go to XK01
 Vendor: 4275
 Create

Ashok
SAP-ADV ABAP 87

Menu Exits:
Add a menu in MC94 application

Solution:
Step-1: identifying Package name of an application
 Go to MC94
 System -----Status
 Double click on Program Name
 Goto ---- Attributes
 Note down package name (MCP2)

Step-2: identifying Customerexits for an application


 Go to SMOD
 Apply F4 on Enhancement field
 You will find a pop-up, at bottom select Information System button
 Package: MCP2
 Enter
 Note down Customerexits (MCP20003)

Step-3: writing enhancement


 Go to CMOD
 Project: ZENC_MC94
 Create
 Short Text: customerexits for mc94
 Save
 Enhancement Assignments button
 Select your enhancement MCP20003
 Enter

 You may find an error message ‘SAP enhancement……….MCP20003 already belongs to


project……….’
 If you are getting such error you have to delete the old enhancement

Deleting Customerexits Enhancement:


 Note down old enhancement name (ZHMC94)
 Go to /OCMOD
 Project: ZHMC94
 Deactivate
 Delete option
 Yes
 Enter
 Close
Ashok
SAP-ADV ABAP 88

 Select Components option


 Yes
 Display / Change option
 Display / Chane option
 Double click on +CU1
 Function Text: Call FAGLL03
 Enter
 Double click on +CU2
 Function Text: Call FBL5N
 Enter
 Double click on EXIT_SAPMMCP6_003
 Scroll down to bottom
 Double click on INCLUDE ZXSOPU03
 Display / Change option
CASE I_FCODE.
WHEN ‘+CU1’.
CALL TRANSACTION ‘FAGLL03’.
WHEN ‘+CU2’.
CALL TRANSACTION ‘FBL5N’.
ENDCASE.

 Activate
 Back
 Back
 Back
 Activate project

Testing the Application:


 Go to MC94
 Planning Type: apply F4 select any one
 Enter
 Active Version
 Extras ---- Customer Functions ---- Call FAGLL03
 ------ Call FBL5N

Ashok
SAP-ADV ABAP 89

Screen Exits:
Object:
Add a screen with following fields in CS01, CS02, CS03 applications
ZZORDER PO number
ZZDATE PO date
ZZVENDOR vendor number

Solution:
Step-1: adding fields to table
 Go to SE11
 Database Table: STKO
 Display
 Append Structure
 You will find a message, Enter
 Append Name: ZSTKO_APP
 Enter
 Short Description: Additional fields for stko table
Component Component Type
ZZORDER EBELN
ZZDATE BEDAT
ZZVENDOR LIFNR

 Activate

Step-2: identifying Package name of an application


 Go to CS01
 System -----Status
 Double click on Program Name (screen)
 Goto ---- Attributes
 Note down package name (CS)

Step-3: identifying Customerexits for an application


 Go to SMOD
 Apply F4 on Enhancement field
 You will find a pop-up, at bottom select Information System button
 Package: CS
 Enter
 Note down Customerexits (PCSP0003)

Step-4: writing enhancement


 Go to CMOD
 Project: ZENC_CS01
Ashok
SAP-ADV ABAP 90

 Create
 Short Text: customerexits for cs01
 Save
 Enhancement Assignments button
 Select your enhancement PCSP0003
 Enter
 Select Components option
 Yes
 Double click on 0114
 You find a message, select Maintain in Original Language option
 You should find a message ‘for program SAPLXCSA is been created’, Enter

 If you are not getting such message you have to delete the old enhancement

Deleting Customerexits Enhancement:


 Go to /OSE51
 Project: SAPLXCSA
 Screen Number: 1100
 Delete option
 Yes
 Enter
 Close

 Short Description: Sub Screen 1100


 Sub Screen
 Layout
 F6
 Table Name: STKO
 Enter
 Scroll down to bottom
 Select your fields (ZZORDER, ZZDATE, ZZLIFNR), Enter
 Place the fields on the screen
 Activate
 Back

 Double click on EXIT_SAPLCSDI_004


 Double click on CSCI_STKO
 Append Structure
 Enter
 Append Name: ZCSCI_APP
 Enter
 Short Description: additional fields
Ashok
SAP-ADV ABAP 91

Component Component Type


ZZORDER EBELN
ZZDATE BEDAT
ZZVENDOR LIFNR

 Activate
 Back
 Back
 Scroll down to bottom
 Double click on INCLUDE ZXCSAU04
 Display / Change option
TABLES STKO.

STKO-ZZEBELN = USERDATA-ZZORDER.
STKO-ZZDATE = USERDATA-ZZDATE.
STKO-LIFNR = USERDATA-ZZLIFNR.
 Activate
 Back
 Back
 Double click EXIT_SAPLSOI_005
 Double click on INCLUDE
 Display / Change option
USERDATA-ZZORDER = STKO-ZZEBELN.
USERDATA-ZZDATE = STKO-ZZBEDAT.
USERDATA-ZZLIFNR = STKO-ZZLIFNR.
 Activate
 Back
 Back
 Back
 Activate project

Testing the Application:


 Go to CA01
 Material: 100-101
 Bom: 1
 Header (cap symbol)
 Customer Fields
 Purchase Document: 30005
 Po Date: 11.11.2014
 Vendor: satya
 Save

Ashok
SAP-ADV ABAP 92

14-11-2014
Assignment:
Add following fields in ME21N, ME22N, ME23N
ZZDEL Delivery priority
Customerexit: MM06C005

Solution:

Ashok
SAP-ADV ABAP 93

Fieldexits:
Using fieldexits you can modify field labels of data elements in data dictionary

Example:
 Go to CMOD
 Goto ----- Text Enhancements ------Keywords ----Change
 Data Element: REGIO
 Enter
 Shot Field Lable: State
 Medium Field Lable: State
 Long Field Lable: State
 Heading: State
 Short Description: State
 Save

Note:
SAP is not recommending Fieldexits in real time

Ashok
SAP-ADV ABAP 94

BADI:
 Bussines Addins
 It is based on object oriented programming
 In Userexits (Customerexits) the same exit cannot be reuse in other projects
 In BADIs the same BADI definition can be implemented in N number of
implementations
 BADI concept is purly designed based on object oriented programming
 For implementing BADI, SAP will provide you an interactive & respective
implementation class
 Here interface is a collection of methods where you have to implement the additional
code

Note:
T codes for working with BADIs are
1. SE18 -------- for BADI definition
2. SE19 -------- for BADI implementation

Types of BADI:
1. Standard BADI
2. Custom BADI
3. Filter BADI

Ashok
SAP-ADV ABAP 95

***Standard BADI:
 In Standard BADI, BADI definitions are predefined (given by SAP)
 In Standard BADI we have to provide only implementation section

Object-1:
Validate customer master application for postal code

Solution:
 Go to SE19
 Classic BADI
 BADI Name: CUSTOMER_ADD_DATA
 Create Impl
 Enter
 Implementation Name: ZXD01_IMPL
 Enter
 Short Text: implementation for xd01 application
 Interface tab
 Double click on CHECK_ALL_DATA
 Yes
 Enter
 You may find a message ‘implementation ZXD01_IMPL migrated’, Enter
 You will find a pop-up, Select Create option
 Again you will find a pop-up, provide
 Enhancement Implementation: ZCUSTOMER_IMPL
 Short Text: implementation for xd01 application
 Enter
 Select your implementation (ZXD01_IMPL)
 Enter
 You may find a wrong method
 Back
 Again double click on CHECK_ALL_DATA
 Place cursor between METHOD………..ENDMETHOD

IF S_KNA1-PSTLZ IS INITIAL.
MESSAGE ‘Enter postal code’ TYPE ‘E’.
ENDIF.

 Activate
 Back
 Activate

Ashok
SAP-ADV ABAP 96

Testing the Application:


 Go to XD01
 Account Group: 004 bill to party
 Customer number: 5869
 Enter
 Title: Mr
 Name: satya
 City: Hyderabad
 Country: IN
 Save
 You will find an error message ‘Enter postal code’

Ashok
SAP-ADV ABAP 97

Watch Point:
 Watch point is a cleaver break point
 Use watch point for watching the errors in standard applications
 The another purpose of watch point is to watch a specific record in an internal table
during debugging

Note:
You can keep maximum 5 wach points in ABAP for a specific report

Example:
 Go to XD01
 Provide required input
 Save
 Apply /H in Command prompt (/H is a T code for debugging)
 Enter
 Enter
 Watch point button
 You will find a pop-up, provide
 ***Variable: SY-MSGTY (system field for capturing messages)
 Enter
 You will find a message ‘watch point created’
 F7

Ashok
SAP-ADV ABAP 98

Navigation for Finding BADI:


1st Method:
 Go to SE90
 Expand Enhancements option
 Expand Bussiness Add-ins
 Double click on Definitions
 Execute

2nd Method:
 Go to SE80
 Select Package
 Provide CS
 Enter
 Expand Enhancements
 Expand Classic BADIs Def

*** 3rd Method:


 Go to SE24
 Object Type: CL_EXITHANDLER
 Display
 Double click on method GET_INSTANCE
 Place cursor at call method CL_EXITHANDLER
 GET_CLASS_NAME_BY_INTERFACE
 Select Dynamic Break Point, stop

 Go to CS01
 Variable: EXIT_NAME
 F7………….
 Material: 100-101
 Plant: 1000
 Bom: 1
 Enter

Ashok
SAP-ADV ABAP 99

Object-2:
Validate BOM application (CS01) for alternate Bom

Business Requirement:
 In real time every material is having an alternate Bom
 But some materials alternate Bom not possible
 Provide to control on such materials such that user try to create alternate Bom system
through an error

Solution:
 Go to SE19
 Classic BADI
 BADI Name: BOM_UPDATE
 Create Impl
 Enter
 Implementation Name: ZBOM_IMPL
 Enter
 Short Text: implementation for BOM application
 Interface tab
 Double click on CHANGE_AT_SAVE
 Yes
 Enter
 You may find a wrong method
 Back
 Again double click on CHANCE_AT_SAVE
 Place cursor between METHOD………..ENDMETHOD

DATA: WA TYPE STPOB.

LOOP AT DELTA_STPOB INTO WA.


IF WA_IDNRK EQ ‘100-101’.
IF I_STLAL > 1.
MESSAGE ‘Alternate Bom not allowed’ TYPE ‘E’.
ENDIF.
ENDIF.
ENDLOOP.

 Activate

Ashok
SAP-ADV ABAP 100

Testing the Application:


 Go to CS01
 Material: 100-101
 Plant: 1000
 Bom: 1
 Save
 You will find an error message ‘Alternate Bom not allowed’

***Assignment:
 In MIRO (or) MIGO you will find posting date & document date
 Posting date never be less than document date
 Provide control such that if user provides document date greather than posting date gives
error

BADI Definition: INVOICE_UPDATE

Solution:

Ashok
SAP-ADV ABAP 101

Object-3:
Add a menu in FBL5N application

Solution:
 Go to SE90
 Expand Enhancements
 Expand Bussiness Addins
 Double click on Definitions
 Package: FREP
 Execute
 Note down BADI name

 Go to SE19
 Classic BADI
 BADI Name: F5_ITEMS_MENUE01
 Create Impl
 Enter
 Implementation Name: ZFI_ITEM
 Enter
 Short Text: implementation for FBL5N application
 Interface tab
 Double click on LIST_ITEMS01
 You may find a wrong method
 Back
 Again double click on LIST_ITEMS01
 Place cursor between METHOD………..ENDMETHOD

CALL TRANSACTION ‘FAGLL03’

 Activate
 Back
 Double click on LIST_ITEMS02
 Place cursor between METHOD………..ENDMETHOD

CALL TRANSACTION ‘FBL5N’

 Activate
 Back
 Activate

Ashok
SAP-ADV ABAP 102

Testing the Application:


 Go to FBL5N
 Customer Account: 1000
 Execute
 Extras ------Call FBL5N
o ----- Call FAGLL03

Ashok
SAP-ADV ABAP 103

Object-4:
Add a screen in XD01, XD02 with following field
Sales Manager

Solution:
 Go to SE11
 Database Table: KNA1
 Display
 Append Structure
 Create Append
 Append Name: ZKNA1_APP
 Enter
 Short Text: Additional fields
Component Component Type
ZZSM ZSM

 Activate

 Go to SPRO
 Select SAP Reference Img option
 Expand Logistic General
 Expand Bussiness Partner
 Expand Customers
 Expand Control
 Expand Adaption of Customers Own Master Data Fields
 Select Prepare Modification- Free Enhancement of Customer Master Record
 You will find a message, Enter
 New Entries
Screen Grp Description
Z5 Sales manager

 Save
 On left side double click on Label Tab Pages by selecting Screen Grp Z5
 You will find another screen
 Select New Entries button
Number Function Code Description
5000 TAB1 Sales manager
 Save
 Back
 Back
 Back
 Back
Ashok
SAP-ADV ABAP 104

 Select 2nd option Bussiness Addin Processing of Master data Enhancements


 You will find a pop-up, at bottom select Create option
 Implementation Name: ZCUST_ADD_SM
 Enter
 Implementation Short Text: Badi implementation
 Save
 You may find a message ‘implementation ZCUST_ADD_SM migrated’, Enter
 At bottom select Create option
 Enhancement Implementation: ZSM_IMPL
 Short Text: Addition of extra field
 Select your implementation name (ZSM_IMPL)
 Enter
 Interface tab
 Scroll down to bottom, Double click on last method CHECK_ADD_ON_ACTIVE
 Place cursor between METHOD………..ENDMETHOD

IF I_SCREEN_GROUP EQ Z5.
E_ADD_ON_ACTIVE = ‘X’.
ENDIF.

 Activate
 Back
 Activate
 Back
 Select 3rd option Bussiness Addin Customer Sub screen
 You will find a pop-up, at bottom select Create option
 You will find a pop-up, provide
 Implementation Name: ZCUST_CS_DATA
 Enter
 Implementation Short Text: Badi implementation
 Attributes tab
 Scroll down to bottom
 Select ‘+’ Insert Row
Screen Grp
Z5

 Save
 You may find a message, Enter
 You will find pop-up, at bottom select Create option
 Enhancement Implementation: ZSM_IMPL_SM
 Short Text: Badi implementation
 Enter
Ashok
SAP-ADV ABAP 105

 You will find a pop-up, select your implementation name ZSM_IMPL_SM


 Enter
 Interface tab
 Scroll vertical scroll bar up
 Double click on GET_TAXI_SCREEN
 Place cursor between METHOD………..ENDMETHOD

CASE I_TAXI_FCODE.
WHEN ‘TAB1’.
E_SCREEN = ‘5000’.
E_PROGRAM = ‘ZBADI_SM’.
ENDCASE.

 Activate
 Back
 Activate

 Go to SE38
 Program: ZBADI_SM
 Create
 Title: Sales manager
 Type: Module Pool
 Enter

 Go to SE51
 Program: ZBADI_SM
 Screen Number: 5000
 Create
 Short Description: Sub Screen 5000
 Sub Screen
 Layout
 F6
 Table Name: KNA1
 Enter
 Scroll down to bottom, select your field name ZZSM
 Enter
 Place the field on the screen
 Flow Logic
 Remove comment for MODULE STATUS_5000
 Double click on STATUS_5000
 Yes
 Main Program
Ashok
SAP-ADV ABAP 106

 Enter
 Yes

TABLES KNA1.

 Place cursor between MODULE……….ENDMODULE of STATUS_5000

IF SY-TCODE EQ ‘XD03’.
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘KNA1-ZZSM’.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.

 Activate
 Back
 Activate

Testing the Application:


 Go to XD01
 Account Group: bill to party
 Customer: 500025
 Enter
 Title: Mr
 Name: Satya
 Search Term: 1
 Street: LB Nagar
 Postal code: 500074
 City: Hyderabad
 Country: IN
 Enter
 You will find your screen with Sales manager field

Ashok
SAP-ADV ABAP 107

***Assignment:
Add following fields in VL01N, VL02N
Order number
Order date
Delivery challana number
Delivery challana date
Driver
Hint:
Add fields in LIKP table
BADI name is LE_SHP_TAB_CUST_HEAD

Solution:

Ashok
SAP-ADV ABAP 108

Custom BADI:
In Custom BADI, BADI definition is custom defined

Filter BADI:
 It is a part of Custom BADI
 In Filter BADI, the same definition can be called in different implementations

Object:
Determine tax code for sales organization

Solution:
 Go to SE18
 Utilities --- Create Classic BADI
 Definition Name: ZBADI_CUST_FILTER
 Enter
 Scroll down to bottom, select Filter Depend check box
 Filter Type: VKORG
 Save
 Interface tab

Note:
Based on your definition name system will create an interface ZIF_EX_BADI_CUST_FILTER

 Double click on interface name ZIF_EX_BADI_CUST_FILTER

Method Level Description


GET_TAX INSATANCE getting tax details

 Select method GET_TAX


 Parameters

Parameter Type Associated Type


P_TAX CHANGING I

 Activate
 During activation you will find a message, Enter
 Once your interface is activated system will add additional parameter FLT_VAL based on
your filter type VKORG

 Go to SE19
 Classic BADI
 BADI Name: ZBADI_CUST_FILTER
Ashok
SAP-ADV ABAP 109

 Create Impl
 Enter
 Implementation Name: ZBADI_FIL
 Enter
 Short Text: implementation for filter badi
 Scroll down to bottom
 Select ‘+’ Insert Row

Sales org
1000

 Save
 Interface tab
 Double click on GET_TAX
 Place cursor between METHOD………..ENDMETHOD

IF FLT_VAL = ‘1000’.
P_TAX = 10.
ENDIF.

 Activate
 Back
 Activate
 Back

 Classic BADI
 BADI Name: ZBADI_CUST_FILTER
 Create Impl
 Enter
 Implementation Name: ZBADI_FIL
 Enter
 Short Text: implementation for filter badi
 Attributes
 Scroll down to bottom
 Select ‘+’ Insert Row

Sales org
1020

 Save
 Interface tab
 Double click on GET_TAX
Ashok
SAP-ADV ABAP 110

 Place cursor between METHOD………..ENDMETHOD

IF FLT_VAL = ‘1020’.
P_TAX = 12.
ENDIF.

 Activate
 Back
 Activate
 Back

 Classic BADI
 BADI Name: ZBADI_CUST_FILTER
 Create Impl
 Enter
 Implementation Name: ZBADI_FIL
 Enter
 Short Text: implementation for filter badi
 Scroll down to bottom
 Select ‘+’ Insert Row

Sales org
1030

 Save
 Interface tab
 Double click on GET_TAX
 Place cursor between METHOD………..ENDMETHOD

IF FLT_VAL = ‘1030’.
P_TAX = 8.
ENDIF.

 Activate
 Back
 Activate

 Go to SE38
 Program: ZCAL_CUSTOM_FILTER_BADI
 Create
 Title: Method of filter badi
 Type: Executable Program
Ashok
SAP-ADV ABAP 111

 Save

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.


PARAMETERS v_vkorg TYPE vkorg.
SELECTION-SCREEN: END OF BLOCK b1.

DATA v_tax TYPE I.

DATA obj TYPE REF TO ZFI_EX_BADI_CUST_FILTER.

* get reference of the class implemented


CALL METHOD CL_EXITHANDLER=>GET_INSTANCE
CHANGING
INSTANCE = obj.

IF SY-SUBRC NE 0.
MESSAGE ‘Error in calling BADI’ TYPE ‘E’.
ELSE.
CALL METHOD obj->get_tax
EXPORTING
FLT_VAL = V_VKORG
CHANGING
P_TAX = V_TAX.

IF NOT V_TAX IS INITIAL.


WRITE:/ ‘The tax code for sales organization’, V_VKORG ‘is’, V_TAX.

ENDIF.
ENDIF.

Ashok
SAP-ADV ABAP 112

Enhancement Framework:
 BADIs are based on object oriented programming
 But SAP is not providing BADIs for all requirements
 Restricted to specific applications & only for specific requirements
 Using Framework you can enhance all types of SAP objects

Object-1:
 In VA01 you will find a field called Sales office, which is meant for sales office data
 Generally clients are instructed not to enter Sales office data as it pickup automatically
from master data (KNVV table)
 Some times clients will enter wrong data into Sales office, which is wrongly updated to
transactional tables
 Provide an enhancement to deselect Sales office field

Solution:
 Go to VA01
 Apply F1 on Sales office
 You will find a pop-up, select 4th option Technical Information
 Double click on Screen 101
 Double click on FELDAUSWAHL-101
 Double click on subroutine FELDAUSWAHL-101
 Enhance
 Edit ---- Enhancement Operations ----Show Implicit Enhancement Options
 Right click under spot under FORM FELDAUSWAHL-101
 Enhancement Implementation ----Create Implementation
 Code
 Create
 Enhancement Implementation: ZVA01_IMPL
 Enter
 Select your implementation name ZVA01_IMPL
 Enter

IF SY-TCODE EQ ‘VA01’.

LOOP AT SCREEN.

IF SCREEN-NAME EQ ‘VBAK-VKBUR’.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.

Ashok
SAP-ADV ABAP 113

ENDLOOP.
ENDIF.

 Activate

Testing the Application:


 Go to VA01
 Sales office is in display mode

Ashok
SAP-ADV ABAP 114

Object-2:
Provide Profit center as obligatory in F-28 application

Solution:
 Go to F-28
 Apply F1 on Profit Center
 Technical Information
 Double click on Screen 103
 Double click on DYNPRO_KOPF_MODIF
 Double click on subroutine DYNPRO_KOPF_MODIF
 Enhance
 Edit ---- Enhancement Operations ----Show Implicit Enhancement Options
 Right click under spot under FORM DYNPRO_KOPF_MODIF
 Enhancement Implementation ----Create Implementation
 Code

LOOP AT SCREEN.

IF SCREEN-NAME EQ ‘BSEG-PRCTR’.
SCREEN-REQUIRED = 1.
MODIFY SCREEN.
ENDIF.

 Activate

Testing the Application:


 Go to F-28
 There you will find Profit center became mandatory

Ashok
SAP-ADV ABAP 115

Object-3:
 In MB31 you will find Document date & Posting date as current date
 Provide an enhancement such that I want both the dates by default as previous dates

Solution;
 Go to MB31
 Apply F1 on Document date
 Technical Information
 Double click on Screen 300
 Double click on MODULE BELEGKOPF_VORGSCHLOG
 You will find a subroutine, Double click on it
 Enhance
 Edit ---- Enhancement Operations ----Show Implicit Enhancement Options
 Right click on spot above ENDFORM
 Enhancement Implementation ----Create Implementation
 Code
 Create
 Enhancement Implementation: ZMB_MB31
 Short Text: Implementation for MB51 application
 Enter
 Select your implementation ZMB_MB31
 Enter

MKPF-BUDAT = SY-DATLO - 1.
MKPF-BLDAT = SY-DATLO - 1.

 Activate

Testing the Application:


 Go to MB31
 There you will find previous date

Ashok
SAP-ADV ABAP 116

*** Object-4:
Add following fields in FB03 application
Dmbtr, Hlcont

Solution:
 Go to SE11
 Data Type: BKPF_ALV
 Display
 Append Structure
 Enter
 Append Name: ZBKPF_APP
 Enter
 Short Description: Additional fields
Component Component Type
HKONT HKONT
DMBTR DMBTR

 Currency / Quantity Fields


Reference Table Reference Field
T001 WAERS

 Activate

 Go to FB03
 Document List
 Apply F1 on Document number
 Technical Information
 Double click on Program name
 Go to REUSE_ALV_GRID_DISPLAY
 Find internal table
 Enhance
 Edit ---- Enhancement Operations ----Show Implicit Enhancement Options
 Right click on spot under FORM GRID_DISPLAY
 Enhancement Implementation ----Create Implementation
 Code
 Create
 Enhancement Implementation: ZENC_FB03
 Short Text: Implementation for FB03 application
 Enter
 Select your implementation ZENC_FB03
 Enter

Ashok
SAP-ADV ABAP 117

DATA: wa_s1 TYPE BKPF_ALV,


It_i1 TYPE TABLE OF BKPF_ALV.

TYPES: BEGIN OF ty_bseg1,


Belnr TYPE belnr_D,
Hkont TYPE hkont,
Dmbtr TYPE dmbtr,
Gjahr TYPE gjahr,
END OF ty_bseg1.

DATA: wa_bseg1 TYPE ty_bseg1,


It_bseg1 TYPE TABLE OF ty_bseg1.

APPEND LINES OF GT_YBKPF_ALV TO IT_I1.

REFRESH GT_YBKPF_ALV.

SELECT belnr hkont dmbtr FROM BSEG INTO TABLE it_bseg1


WHERE belnr = wa_s1-belnr.

Testing the Application:


 Go to FB03
 Document List
 Company code: 1000
 Document number: 100000000
 Execute
 Change Layout
 Scroll down to bottom
 Double click on G / L Account
 Double click on Amount_In_LC
 You will find your fields

Ashok
SAP-ADV ABAP 118

Object-5:
Add screen in VF01, VF02, VF03 with ZZBOXNO, ZZSIZE, ZZTEXT

Solution;
 Go to SE11
 Database Table: VBRK
 Display
 Append Structure
 Create Append
 Append Name: ZVBRK_APP
 Enter
 Short Description: Additional fields
Component Component Type
ZZBOXNO ZBOXNO
ZZSIZE ZSIZE
ZZTEXT ZTEXT

 Activate

 Go to SE80
 Program: SAPMV60A
 At bottom, expand Screens option
 Find 6001 screen & double click on it
 Double click on MODULE CUST_HEAD_ACTIVATE
 You will find a subroutine, double click on it
 Enhance
 Right click under FORM CUST_HEAD_ACTIVATE

LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘TABSTRIP_TAB06’.
GS_CUST_TAB_HEAD_OPTION = ‘invocice’.
GS_CUST_TAB_HEAD_PROGRAM = ‘ZSD_INVV’.
GS_CUST_TAB_HEAD_DYNPRO = ‘100’.

IF SCREEN-ACTIVE = 1.
SCREEN-INVISIBLE = 0.
MODIFY SCREEN.
ENDIF.

TABSTRIP_TAB06 = GS_CUST_TAB_HEAD_CAPTION.
ENDIF.

Ashok
SAP-ADV ABAP 119

ENDLOOP.

 Activate

 Go to SE38
 Program: ZSD_INVV
 Create
 Title: Invoice details
 Type: Modulpe Pool
 Save

 Go to SE51
 Program: ZSD_INVV
 Screen: 100
 Create
 Short Description: Sub screen 100
 Sub Screen
 Layout
 F6
 Table Name: VBRK
 Enter
 Scroll down to bottom, select your fields
 Enter
 Place the fields on screen
 Flow Logic
 Remove comment for MODULE STATUS_100
 Double click on STATUS_100
 Yes
 Main Program
 Enter
 Yes

IF SY-TCODE EQ ‘VF03’.
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘VBRK-ZZBOXNO’
OR SCREEN-NAME EQ ‘VBRK-ZZSIZE’
OR SCREEN-NAME EQ ‘VBRK-ZZTEXT’.
SCREEN-INPUT = 0.
ENDIF.
ENDLOOP.
ENDIF.

Ashok
SAP-ADV ABAP 120

 Activate
 Back
 Activate

Testing the Application:


 Go to VF02
 Bill number: 90030506
 Enter
 Goto ---Header ---Header
 Invoice tab
 Your fields will be displayed
 Fill data
 Save

Assignment-1:
Add fields Purchase requisition number & Requisitioner name in MB51 application
EBAN-BOMFN,
EBAN-AFNAM

Solution:

Assignment-2:
Add fields storage bin (MARD-LGPBE) in MB5B

Solution:

***Assignment-3:
 Validate Sales order quantity (VBAP-KWMENG) with PO quantity (EKPO-MENGE)
 If Sales order quantity is > PO quantity provide a control on VA01 application

Solution:

Ashok
SAP-ADV ABAP 121

BTE:
 Business Framework
 Business Transaction Events
 For standard applications SAP is providing BTE
 For BTE a specific function module is attached
 When BTE triggers respective function module is called

Note:
BTE is mostly for finance transactions
T code for BTE is FIBF

*** Identifing Event Associated with an Application:


 Go to SE93
 Transaction Code: FBL5N
 Display
 Double click on Program name
 Select Find option
 Find: OPEN
 Enter
 Double click on 1650

Ashok
SAP-ADV ABAP 122

Object:
Add indicator field in FBL5N application

Solution:
 Go to SE11
 Database Table: RFPOS
 Display
 Append Structure
 Create Append
 Append Name: ZFI_FBL5N
 Enter
 Short Text: indicator field
Component Component Type
ZZIND ZIND

 Extras ---- Enhancement Category


 Enter
 Can be Enhanced option
 Enter
 Activate

 Go to SE11
 Database Table: RFPOSX
 Display
 Append Structure
 Create Append
 Append Name: ZFI_FBL5N1
 Enter
 Short Text: indicator field
Component Component Type
ZZIND ZIND

 Extras ---- Enhancement Category


 Enter
 Can be Enhanced option
 Enter
 Activate

 Go to BERE
 Execute
 Select Event 1650
 Sample Function Module option
Ashok
SAP-ADV ABAP 123

 Copy button
 To: ZSAMPLE_INTERFACE_0001650
 Function Group: F4
 Enter
 Enter
 Function Module: ZSAMPLE_INTERFACE_0001650
 Change
 Remove comment for E_POSTAB = I_POSTAB

IF I_POSTAB-SHKZG = ‘H’.
I_POSTAB-ZZIND = ‘Credit’.
ELSE.
E_POSTAB-ZZIND = ‘Debit’.
ENDIF.

 Activate

 Go to FIBF
 Settings ----- Products ---- Of a Customer
 New Entries
Products A
ZFBL5N _/

 Save
 Back
 Back
 Settings ---- PS Modules ---- Of a Customer
 New Entries
Event Product Function Module
1650 ZFBL5N ZSAMPLE_INTERFACE_0001650

 Save

 Go to SE38
 Program: RFPOSXEXTEND
 Activate
 Yes
 Enter

Testing Application:
 Go to FBL5N
 Customer Account: 1000
Ashok
SAP-ADV ABAP 124

 Company code: 1000


 Execute
 Change Layout
 Double click on Indicator
 Enter

Ashok
SAP-ADV ABAP 125

Ques-1: What are the different ways of idntifing Customerexits (Functionexits)?


Answer:
 Go to SE93
 Transaction Code: XK01
 Display
 Double click on Program name
 Find option
 Find: CALL CUSTOMER_FUNCTION
 Enter
 Double click on 001

Ques-2: What is the difference between Implicit & Explicit Enhancement?


Answer:
 Under implicit enhancement you can write your own code
 Adding Z-enhancement in already existing one is called Explicit enhancement

Example:
 Go to SE93
 Transaction Code: VA01
 Display
 Double click on Program Name
 You will find a spot given by SAP
 Enhance
 Right click ES_SAPMV45A
 Enhancement Implementation ----Create Implementation

Ques-3: What is the difference between Enhancement spot (point) & Enhancement section?
Answer:
 In enhancement spot both customized & standard code will be executed
 In enhancement section only customized code will be executed

Ques-4: What is Transaction Variant in enhancements?


Answer:
 Using transaction variant you can provide enhancements
 You can make fields as Required, Output only, Invisible mode……etc using SHDO
(Transaction Variant)
 With above concept you have to create a Z-T code & the same you should provide it to
end user (standard applications should not be effected)

Ashok
SAP-ADV ABAP 126

Cross Applications: (ABAP / CA)


 It is a part of distributed environment in which various business applications are running
in different system
 Such that they can integrate at one point (or) another to stay synchronize

ALE:
 Application Linking Enabling
 ALE is SAP’s distributed technology for distributing (or) exchanging business process
between two systems (SAP (or) Non-SAP)
 In real time if two companies are having same SAP systems (Servers) & if they want to
exchange their business data
 Similarly, if two (or) more than two systems are working with different systems (other
than SAP) & they want to interact with SAP system we have to work with tool called
ALE

IDOC:
 Intermediate Document
 IDOC is a container with which business data can be exchanged between two systems

Components of IDOC:
1. IDOC Type
2. Segment Type
3. Records

IDOC Type:
 It specifies the structure & format of an IDOC
 It is simply collection of Segments
 Standard IDOC Types have a suffix with 01, 02, 03…………. Which is known as Version
Number

Segment Type:
 It is a collection of fields
 Standard starts with prefix ‘E1’

Example:
E1KNA1M
E1MARA1M

Ashok
SAP-ADV ABAP 127

Records:
Records are classified into
1. Control Record
2. Data Record
3. Status Record

Control Record:
 It holds control level information (IP address of both Sender & Receiver, Message Type
information, Segment Type information…………..etc)
 Only one Control Record exists in an IDOC
 The structure & format of Control Record is same for all IDOCs
 Control Record information is finally updated to a table EDIDC

Data Record:
 It holds actual data

It is again having 2 sections


1. Admin Section (holds segment type information)
2. Data Section (holds actual data in 1000 bytes)

 Data Record information is finally updated to a table EDIDU (the structure related to it is
EDIDD)

Status Record:
 IDOC have to travel through different layers (Application layer, ALE Service layer,
Communication layer)
 At each layer the status information of an IDOC can be gathered from Status Record
 Status Record information is updated to EDIDS

Note:
1. There exists only one Control Record in an IDOC
2. Status Records & Data Records can be many
3. In real time as an ALE Consultant we have to work with only IDOCs

Ashok
SAP-ADV ABAP 128

Run Time Components of IDOC:


 During run time a unique IDOC Number is attached to an IDOC
 All the Segments are translated into Data Records
 A unique Control Record is attached
 A unique Status Record is attached based on an IDOC status

Ashok
SAP-ADV ABAP 129

ALE Architecture:

Application Layer
CDM (Receivers)
Database

ALE Service Layer

Database Layer

Communication Layer

Outbound System

Integration Layer

Ashok
SAP-ADV ABAP 130

Inbound System

Ashok
SAP-ADV ABAP 131

Message Type:
These are unique application identities
SAP is providing an unique identity for all application data to identify the same

Note:
T code for Message Type is WE81 & WE82

Message Type Description


1. MATMAS material master
2. CREMAS vendor master
3. DEBMAS customer master
4. ORDERS purchase order
5. ORDRSP sales order
6. COSMAS cost center

Model View Functionality:


 It is also called Customer Distribution Model
 It acts as bag of information for Sender
 The information is that Receiver & the type of data that he want to send (Message Type)
 T code is BD64

Model View
Sender
Receiver
Message Type

Partner Profile:
 Using Partner Profiles Ports can be created
 T codes are WE21 & BD64

Process Flow:
Master Data Material MATMAS MATMAS05 Master IDOC Process codes Communication IDOC
(WE81) (WE30) (WE41)
(WE021 & WE03)

ALE Testing Tool (WE19) RFC (SM59)

Transactional data PO orders ORDERS ORDERS05 Master IDOC Process codes Communication IDOC

Ashok
SAP-ADV ABAP 132

Types of IDOCs:
1. Standard IDOC
2. Custom IDOC
3. Extended IDOC

Standard IDOC:
In this all IDOC options (Message Type, IDOC Type, Segment Type…………etc) are already
provided by SAP

Object:
Distributing material master data
Message Type: MATMAS
IDOC Type: MATMAS05

Logical Systems:
 These are unique client identities
 In real time for each client Logical Systems needs to be created

Solution:
Steps:
Client 800 Client 810
1. Work with SALE
Create Logical Systems
Assign Logical Systems to Clients

2. Work with SM59 2. Work with SM59


Create RFC destinations Create RFC destinations

3. Work with BD64


Create Model View

4. Work with BD64


Create Partner Profiles

5. Work with BD64 5. Work with BD64


Distribute Model View Create Ports

6. Work with MM01 6. Work with WE20


Create Material Create Process Codes

7. Work with BD10


Run Outbound program
Ashok
SAP-ADV ABAP 133

8. Work with WE05 8. Work with WE05


IDOC List Check status of IDOC

9. Work with MM03


Step-1:
Creating logical systems:
 Go to SALE
 Expand Basic Settings
 Expand Logical Systems
 Select Define Logical System option
 Enter

Note:
Logical systems are client independent

 New Entries
Logical System Name
MATT800 SENDER
MATT810 RECEIVER

 Save
 Back
 Back

Assigning Logical Systems to Clients:


 Select Assign Logical System to Client option
 Enter
 Double click on 800 client
 Logical System: MATT800
 Save
 Enter
 Back
 Double click on 810 client
 Logical System: MATT810
 Save
 Enter

Step-2:
Creating RFC destinations in 800 client:
 Go to SM59
 Select ABAP Connections
Ashok
SAP-ADV ABAP 134

 Create
 RFC Destination: MATT810
 Description: RFC for Client 810
 Target Host: SAPLID
 Logon & Security tab
 Scroll down to bottom
 Language: EN
 Client: 810
 User: user1
 PW Status: rgsabap
 Enter
 Enter
 Save
 Enter
 Remote Logon button
 Working under client 810

Creating RFC destinations in 810 client:


 Go to SM59
 ABAP Connections
 Create
 RFC Destination: MATT800
 Description: RFC for Client 800
 Target Host: SAPLID
 Logon & Security tab
 Scroll down to bottom
 Language: EN
 Client: 800
 User: user1
 PW Status: Rgsabap
 Enter
 Enter
 Save

Note:
In real time the above 2 steps are done by Basis Consultant

Step-3: Creating Model View


 Select client 800 session
 Go to BD64
 By default Create Model View button is deselected
 Select F9
Ashok
SAP-ADV ABAP 135

 Select Create Model View button


 Short Text: Model view for material details
 Technical Name: MATERIALM
 Enter
 Scroll down to bottom
 Select short description of your model view
 Select Add Message Type
 Sender: MATT810
 Receiver: MATT800
 Message Type: MATMAS
 Enter
 Again, select Add Message Type
 Sender: MATT800
 Receiver: MATT810
 Message Type: MATMAS
 Enter
 Save

Step-4: Creating Partner Profiles


 Environment ---- Generate Partner Profiles
 Partner System: MATT810
 Execute
 You will find a message ‘port 000000104 with RFC destination has been created’

Note:
Sometimes you may find an error message in red color. In such case
Go back
Again, execute

 Back

Step-5:
Distributing Model View:
 Edit --- Model View ---- Distribute
 Enter
 You should find a message ‘model view has been created’

Creating Ports:
 Select client 810 session
 Go to BD64
 Select your model view name
 Environment ---- Generate Partner Profiles
Ashok
SAP-ADV ABAP 136

 Partner System: MATT800


 Execute
 You will find a message ‘port has been created’

Step-6:
Creating process codes in 810 client:
 Go to WE20
 Expand Partner Type LS
 Select Sender logical system name (MATT800)
 Right side scroll down to bottom
 Under Inbound Parameters
 Double click on MATMAS
 By default you will find Process Code: AFSA which is wrong one, provide
 Process Code: MATN
 Save

Creating material in 800 client:


 Select client 800 session
 Go to MM01
 Material: u-883
 Industry Sector: mechanical grp
 Material Type: 1
 Enter
 Select Basic Data1 & Basic Data2
 Enter
 Material: sodaash
 Base unit of Measure: kg
 Material group: 001
 Gross wt: 1200
 Weight unit: kg
 Net weight: 1000
 Save

Note:
The above material is created by end user

Step-7:
Running Outbound program:
 Go to BD10
 Material: u-883
 Message Type: MATMAS
Ashok
SAP-ADV ABAP 137

 Logical System: MATT810


 Execute
 You will find a message ‘master IDOC is created for message type MATMAS’, Enter
 Again, you will find a message ‘communication IDOC created for message type
MATMAS’, Enter

Step-8:
Displaying IDOC List:
 Go to WE05
 Execute

Note:
In real time we should work with only outbound system. In outbound system you should always
get status as Green (or) Yellow

Checking status of IDOC in 810 client:


 Select client 810 session
 Go to WE05
 Execute

Step-9:
Working with MM03:
 Go to MM03
 Material: u-883
 Enter
 Enter

Ashok
SAP-ADV ABAP 138

Sending Changes to Inbound System:


Change Pointers Technique:
Steps:
1. Work with BD50
2. Work with BD52
3. Work with BD61
4. Work with SE38 (execute RBDM IDOC)
5. Work with WE05

Step-1:
 Go to BD50
 In real time sometimes all the Message Types may be selected, first you Deselect them &
then
 Select your Message Type MATMAS
 Save

Step-2:
 Go to BD52
 Message Type: MATMAS
 Enter
 Here we have to add additional tables & fields related to material

Step-3:
 Go to BD61
 Select Change Pointer Activated Generally check box
 Save

Step-4:
 Go to SE38
 Program: RBDMIDOC
 Execute
 Message Type: MATMAS
 Execute
 You will find a message, Enter
 Enter

 Go to MM02
 Material: u-883
 Enter
 Select Basic Data1, Basic Data2
 Enter
 Make some changes i.e. material: soda bottle, Gross wt: 800………etc
Ashok
SAP-ADV ABAP 139

 Save
 Go to SE38
 Program: RBDMIDOC
 Execute
 Message Type: MATMAS
 Execute
 You will find a message ‘1 master IDOC generated’, Enter
 Again, you will find a message ‘1 communication IDOC generated’, Enter

Step-5:
 Go to WE05
 Execute
 Scroll down to bottom, Double click on your IDOC Number

Ashok
SAP-ADV ABAP 140

IDOC Filtering:
1. Segment Filtering
2. IDOC Filtering
3. Reduced IDOC Filtering

Segment Filtering:
Unnecessary Segments can be filtered using Segment Filtering

Steps:
1. Work with BD56
2. Work with BD10
3. Work with BE05

Step-1:
 Go to BD56
 Message Type: MATMAS
 Enter
 New Entries
Ty Sender Ty Receiver Segment Type
LS MATT810 LS MATT800 E1MARMM

 Save

Step-2:
 Go to BD10
 Material: u-883
 Message Type: MATMAS
 Logical System: MATT800
 Execute

Step-3:
 Go to WE05
 Execute

Note:
Mandatory Segments cannot be deleted

Ashok
SAP-ADV ABAP 141

IDOC Filtering:
 Assume a company is having N number of Company Codes operating in different
countries
 Assume a customer is approaching to Company Code 1000 for business
 His customer master data will be available not only to 1000 Company Code but also to
other Company Code which is not required from 1000 Company Code perspective
 Whenever a customer is created for 1000 Company Code, it should be allowed by the
system
 It the same is done for other Company Codes it should be filtered out
 In customer distribution model you should create a Filter Set based on Company
Code…….etc
 Whenever Master IDOC is created then system will check whether the Company Code is
matching with Filter Set (or) not
 If not matching respective Segment is filtered out
Steps:
Client 800 Client 810
1. Work with SALE
Create Logical Systems
Assign Logical Systems to Clients

2. Work with SM59 2. Work with SM59


Create RFC destinations Create RFC destinations

3. Work with BD64


Create Model View
*** Create Filter Set

4. Work with BD64


Create Partner Profiles

5. Work with BD64 5. Work with BD64


Distribute Model View Create Ports

6. Work with XD01 6. Work with WE20


Create Material Create Process Codes

7. Work with BD12


Run Outbound program

8. Work with WE05 8. Work with WE05


IDOC List Check status of IDOC
Ashok
SAP-ADV ABAP 142

Step-1:
Creating logical systems:
 Go to SALE
 Expand Basic Settings
 Expand Logical Systems
 Select Define Logical System option
 Enter

Note:
Logical systems are client independent

 New Entries
Logical System Name
CUST800 SENDER
CUST810 RECEIVER

 Save
 Back
 Back

Assigning Logical Systems to Clients:


 Select Assign Logical System to Client option
 Enter
 Double click on 800 client
 Logical System: CUST800
 Save
 Enter
 Back
 Double click on 810 client
 Logical System: CUST810
 Save
 Enter

Step-2:
Creating RFC destinations in 800 client:
 Go to SM59
 Select ABAP Connections
 Create
 RFC Destination: CUST810
 Description: RFC for Client 810
 Target Host: SAPLID
 Logon & Security tab
Ashok
SAP-ADV ABAP 143

 Scroll down to bottom


 Language: EN
 Client: 810
 User: user1
 PW Status: rgsabap
 Enter
 Enter
 Save
 Enter
 Remote Logon button
 Working under client 810

Creating RFC destinations in 810 client:


 Go to SM59
 ABAP Connections
 Create
 RFC Destination: CUST800
 Description: RFC for Client 800
 Target Host: SAPLID
 Logon & Security tab
 Scroll down to bottom
 Language: EN
 Client: 800
 User: user1
 PW Status: Rgsabap
 Enter
 Enter
 Save

Note:
In real time the above 2 steps are done by Basis Consultant

Step-3:
Creating Model View:
 Select client 800 session
 Go to BD64
 By default Create Model View button is deselected
 Select F9
 Select Create Model View button
 Short Text: Model view for customer master
 Technical Name: CUSTOM ORDER
 Enter
Ashok
SAP-ADV ABAP 144

 Scroll down to bottom


 Select short description of your model view
 Select Add Message Type
 Sender: CUST810
 Receiver: CUST800
 Message Type: DEBMAS
 Enter
 Again, select Add Message Type
 Sender: CUST800
 Receiver: CUST810
 Message Type: DEBMAS
 Enter
 Save

Creating Filter Set:


 Expand Model View
 Expand Sender
 Expand Receiver
 Expand DEBMAS
 You will find No Filter Set, double click on it
 Create Filter Group
 Expand Data Filtering
 Expand Filter Group
 Double click on Global Co Cde
 ‘+’ Insert Row
Value List
GL_1000

 Enter
 Enter
 Save

Step-4: Creating Partner Profiles


 Environment ---- Generate Partner Profiles
 Partner System: CUST810
 Execute
 You will find a message ‘port 000000104 with RFC destination has been created’
Note:
Sometimes you may find an error message in red color. In such case
Go back
Again, execute
Back
Ashok
SAP-ADV ABAP 145

Step-5:
Distributing Model View:
 Edit --- Model View ---- Distribute
 Enter
 You should find a message ‘model view has been created’

Note:
On distributing Model View, model view will became client independent

Creating Ports:
 Select client 810 session
 Go to BD64
 Select your model view name
 Environment ---- Generate Partner Profiles
 Partner System: CUST800
 Execute
 You will find a message ‘port has been created’

Step-6:
Creating process codes in 810 client:
 Go to WE20
 Expand Partner Type LS
 Select Sender logical system name (CUST800)
 Right side scroll down to bottom
 Under Inbound Parameters
 Double click on DEBMAS
 By default you will find Process Code: DEB2 which is wrong one, provide
 Process Code: DEBM
 Save

Creating customer in 800 client:


 Select client 800 session
 Go to XD01
 Account Group: Bill to party
 Customer: 7856
 ***Company Code: 1000
 Enter
 Title: Mr
 Name: Satya
 Search Term: 1
 Street: LB Nagar
 Postal Code: 500074
Ashok
SAP-ADV ABAP 146

 City: Hyderabad
 Country: IN
 Save

Step-7:
Running Outbound program:
 Go to BD12
 Customer: 7856
 Output Type: DEBMAS
 Execute

Step-8:
Displaying IDOC List:
 Go to WE05
 Execute
 Select DEBMAS
 Execute
 Double click on IDOC Number
 Expand Data Records

 Go to XD01
 Customer: 7856
 Company Code: 3000
 Enter
 Title: Mr
 Name: Satya
 City: Hyderabad
 Country: IN
 Save

 Go to BD12
 Customer: 7856
 Output Type: DEBMAS
 Execute

Checking status of IDOC in 810 client:


 Select client 810 session
 Go to WE05
 Execute

Ashok
SAP-ADV ABAP 147

Reduced IDOC Type:


Unwanted fields can be filtered using Reduced IDOC Type

Steps:
1. Work with BD53
2. Work with BD64
3. Work with BD10
4. Work with WE05

Step-1:
 Go to BD53
 Reduced Message Type: ZRED_MATMAS
 Create
 Message Type Ref: MATMAS
 Enter
 Description: Reduced message type for material type
 Enter
 Place cursor on E1MARMM
 Select button
 You will find a white color change instead of red color to the segment
 Double click on that segment
 Select the fields which you want to filter
 Select button
 Enter
 Save

Step-2:
Creating Model View:
 Select client 800 session
 Go to BD64
 By default Create Model View button is deselected
 Select F9
 Select Create Model View button
 Short Text: Model view for customer master
 Technical Name: CUSTOM ORDER
 Enter
 Scroll down to bottom
 Select short description of your model view
 Select Add Message Type
 Sender: CUST810
 Receiver: CUST800
 Message Type: DEBMAS
Ashok
SAP-ADV ABAP 148

 Enter
 Again, select Add Message Type
 Sender: CUST800
 Receiver: CUST810
 Message Type: DEBMAS
 Enter
 Save

Step-3:
 Go to BD10
 Material: u-883
 Message Type: MATMAS
 Logical System: MATT800
 Execute

Step-4:
 Go to WE05
 Execute

Note:
In real time we are not working with Reduced IDOC Filtering

Ashok
SAP-ADV ABAP 149

Distributing Transactional Data:


Method: Message Control Technique
In Message Control Technique whenever application document is created, IDOC is created &
dispatched to Inbound system

***Object:
Distribute Purchase Order Data using Message Control Technique
Message Type: ORDERS
IDOC Type: ORDERS05

Steps:
Client 800 Client 810
1. Work with SALE
Create Logical Systems
Assign Logical Systems to Clients

2. Work with SM59 2. Work with SM59


Create RFC destinations Create RFC destinations

3. Work with BD64


Create Model View

4. Work with BD64


Create Partner Profiles

5. Work with BD64 5. Work with BD64


Distribute Model View Create Ports

6. Work with XK01


Create Vendor master

7. Work with WE20


Maintain Partner Profiles

8. Work with MN05


Maintain Conditional Records

Note:
Conditional Records are maintained by Functional Consultant

9. Work with ME21N


Create Purchase Order based on vendor
Ashok
SAP-ADV ABAP 150

Note:
Purchase Order creation is done by end user. Once ME21N is executed IDOC is created &
dispatched to Inbound system

10. Work with ME22


Check the status of IDOC

Solution:
Step-1:
Creating logical systems:
 Go to SALE
 Expand Basic Settings
 Expand Logical Systems
 Select Define Logical System option
 Enter

Note:
Logical systems are client independent

 New Entries
Logical System Name
MATT800 SENDER
MATT810 RECEIVER

 Save
 Back
 Back

Assigning Logical Systems to Clients:


 Select Assign Logical System to Client option
 Enter
 Double click on 800 client
 Logical System: MATT800
 Save
 Enter
 Back
 Double click on 810 client
 Logical System: MATT810
 Save
 Enter

Ashok
SAP-ADV ABAP 151

Step-2:
Creating RFC destinations in 800 client:
 Go to SM59
 Select ABAP Connections
 Create
 RFC Destination: MATT810
 Description: RFC for Client 810
 Target Host: SAPLID
 Logon & Security tab
 Scroll down to bottom
 Language: EN
 Client: 810
 User: user1
 PW Status: rgsabap
 Enter
 Enter
 Save
 Enter
 Remote Logon button
 Working under client 810

Creating RFC destinations in 810 client:


 Go to SM59
 ABAP Connections
 Create
 RFC Destination: MATT800
 Description: RFC for Client 800
 Target Host: SAPLID
 Logon & Security tab
 Scroll down to bottom
 Language: EN
 Client: 800
 User: user1
 PW Status: Rgsabap
 Enter
 Enter
 Save

Note:
In real time the above 2 steps are done by Basis Consultant

Ashok
SAP-ADV ABAP 152

Step-3: Creating Model View


 Select client 800 session
 Go to BD64
 By default Create Model View button is deselected
 Select F9
 Select Create Model View button
 Short Text: Model view for material details
 Technical Name: ORDDMOD
 Enter
 Scroll down to bottom
 Select short description of your model view
 Select Add Message Type
 Sender: MATT810
 Receiver: MATT800
 Message Type: ORDERS
 Enter
 Again, select Add Message Type
 Sender: MATT800
 Receiver: MATT810
 Message Type: ORDERS
 Enter
 Save

Step-4: Creating Partner Profiles


 Environment ---- Generate Partner Profiles
 Partner System: MATT810
 Execute
 You will find a message ‘port 000000104 with RFC destination has been created’

Note:
Sometimes you may find an error message in red color. In such case
Go back
Again, execute

 Back

Step-5:
Distributing Model View:
 Edit --- Model View ---- Distribute
 Enter
 You should find a message ‘model view has been created’

Ashok
SAP-ADV ABAP 153

Creating Ports:
 Select client 810 session
 Go to BD64
 Select your model view name
 Environment ---- Generate Partner Profiles
 Partner System: MATT800
 Execute
 You will find a message ‘port has been created’, Enter

Step-6: Creating vendor master


 Select client 800 session
 Go to XK01
 Create a Vendor with providing mandatory inputs (9343, 1000, 001…)
 Save

Step-7: Maintaining Partner Profiles


 Go to WE20
 Select Create option (F5)
 Partner: 9343
 Save
 Under Outbound Parameters
 Select ‘+’ Insert Row
 Create Outbound Parameters
 Partner Role: VN
 Message Type: ORDERS
 Receiver Port: A0000106
 Select Transfer IDOC Immediately option
 Basic Type: ORDERS05
 Save
 Select Message Control tab
 Scroll down to bottom
 Select ‘+’ Insert Row
Application Message Type Process Code
EF NEU ME10
 Save

Note:
With the above navigation we should provide
1. Whom to transfer (Receiver address)
2. What to transfer (Message Type & IDOC Type)
3. Mode of dispatch (Transfer Immediately & Collect IDOCs)
4. Medium of data transfer (Port)
Ashok
SAP-ADV ABAP 154

Step-8: Maintaining Conditional Records


 Go to MM05
 Output Type: NEU
 Key Combination button
 You will find a pop-up, Enter
 Execute
Vendor Function Partner Medium Date / Time Language
9343 VN 9343 A 4 EN

 Save

Step-9: Creating Purchase Order based onvendor


 Go to ME21N
 Vendor: 9343
 Enter
 Purchase Organization: 1000
 Purchase Group: 001
 Company Code: 1000
 Enter
 Currency: EUR
 Material: 100-101
 Quantity: 30
 Net Price: 3000
 Plant: 1000
 Save
 You will find a message ‘Standard PO record under the number 45000-17462 created’

Step-10: Checking status of IDOC


 Go to ME22
 You will find the Purchase Order: 45000-17462, Enter
 Header
 Messages
 Once PO is created accurately you will find an Output Type in green color
 Select that Output Type
 Select Processing Log option
 IDOC 00034355549 has been created & success

Ashok
SAP-ADV ABAP 155

Custom IDOC:
In Custom IDOC all IDOC options are customized

Steps:
Client 800 Client 810
1. Work with SALE
Create Logical Systems
Assign Logical Systems to Clients

2. Work with SM59 2. Work with SM59


Create RFC destinations Create RFC destinations

3. Work with WE31


Create Segment Type

4. Work with WE30


Create IDOC Type

5. Work with WE81


Create Message Type

6. Work with WE82


Link Message Type & IDOC Type

7. Work with BD64


Create Model View

8. Work with WE21


Create Port

9. Work with WE20


Maintain Partner Profiles

10. Work with SE38


Create Stand Alone program

11. Run Stand Alone program

Solution:
Step-1:
Creating logical systems:
 Go to SALE
Ashok
SAP-ADV ABAP 156

 Expand Basic Settings


 Expand Logical Systems
 Select Define Logical System option
 Enter

Note:
Logical systems are client independent

 New Entries
Logical System Name
MATT800 SENDER
MATT810 RECEIVER

 Save
 Back
 Back

Assigning Logical Systems to Clients:


 Select Assign Logical System to Client option
 Enter
 Double click on 800 client
 Logical System: MATT800
 Save
 Enter
 Back
 Double click on 810 client
 Logical System: MATT810
 Save
 Enter

Step-2:
Creating RFC destinations in 800 client:
 Go to SM59
 Select ABAP Connections
 Create
 RFC Destination: MATT810
 Description: RFC for Client 810
 Target Host: SAPLID
 Logon & Security tab
 Scroll down to bottom
 Language: EN
 Client: 810
Ashok
SAP-ADV ABAP 157

 User: user1
 PW Status: rgsabap
 Enter
 Enter
 Save
 Enter
 Remote Logon button
 Working under client 810

Creating RFC destinations in 810 client:


 Go to SM59
 ABAP Connections
 Create
 RFC Destination: MATT800
 Description: RFC for Client 800
 Target Host: SAPLID
 Logon & Security tab
 Scroll down to bottom
 Language: EN
 Client: 800
 User: user1
 PW Status: Rgsabap
 Enter
 Enter
 Save

Note:
In real time the above 2 steps are done by Basis Consultant

Step-3: Creating Segment Type


 Select client 800 session
 Go to WE31
 Segment Type: Z1SEG
 Create
 Short Description: custom segment type
Field Name Data element
KUNNR KUNNR
NAME1 NAME1
LAND1 LAND1
ORT01 ORT01
PSTLZ PSTLZ
STRAS STRAS
Ashok
SAP-ADV ABAP 158

 Save

Step-4: Creating IDOC Type


 Go to WE30
 Object Type: Z1CUST_01
 Create
 F5
 You will find a message ‘assignment line is longer than 800’, Enter
 Short Description: custom IDOC type
 Select your IDOC Type
 Create Segment
 You will find a pop-up, provide
 Segment Type: Z1SEG
 Select Mandatory Segment option
 Min: 1
 Max: 1
 Enter
 Save

Step-5: Creating Message Type


 Go to WE81
 Display / Change option
 You will find a message, Enter
 New Entries
Message Type Short Text
ZCUSTM for customer segment

 Save

Step-6: Linking Message Type & IDOC Type


 Go to WE82
 Display / Change option
 You will find a message, Enter
 New Entries
Message Type Basic Type (or) IDOC Type Release
ZCUSTM Z1CUST_01 620

 Save

Step-7: Creating Model View


 Go to BD64
 F9
Ashok
SAP-ADV ABAP 159

 Create Model View


 Short Text: model view for customer IDOC
 Technical Name: CUSTOMID
 Enter
 Scroll down to bottom
 Select your model view description
 Add Message Type option
 Sender: MATT800
 Receiver: MATT810
 Message Type: ZCUSTM
 Enter
 Save

Step-8: Creating Port


 Go to WE21
 Transactional RFC option
 Create
 You will find a pop-up, Enter
 Description: Port creation
 RFC Destination: MATT810
 Save

Step-9: Maintaining Partner Profiles


 Go to WE20
 Partner Type: LS
 Create
 Partner Number: MATT810
 Save
 Scroll down to bottom
 Under Outbound Parameters
 Select ‘+’ create Outbound Parameters
 Message Type: ZCUSTM
 Basic Type: Z1CUST_01
 Receiver Port: A0000127
 Select Transfer IDOC Immediately option
 Save

Step-10: Creating Standard alone program


 Go to SE38
 Program: ZSD_IDOC_PROGRAMMING
 Create
 Title: Standard alone program
Ashok
SAP-ADV ABAP 160

 Type: Executable Program


 Save
 Write your program

Step-11: Executing standard alone program


 Go to SE38
 Program: ZSD_IDOC_PROGRAMMING
 Execute
 Provide input
 Execute

Ashok
SAP-ADV ABAP 161

17-11-2014
Extended IDOC:
Extended IDOC = Predefined IDOC Type + Additional Segment

Steps:
Client 800 Client 810
1. Work with SALE
Create Logical Systems
Assign Logical Systems to Clients

2. Work with SM59 2. Work with SM59


Create RFC destinations Create RFC destinations

3. Work with WE31


Create Segment Type

4. Work with WE30


Create Extended IDOC Type

5. Work with WE82


Link Message Type & IDOC Type & Extended IDOC Type

6. Work with BD64


Create Model View

7. Work with WE21


Create Port

8. Work with WE20


Maintain Partner Profiles

9. Work with SMOD


Create Extended IDOC program

10. Work with CMOD


Link Extended IDOC program with CMOD

11. Work with XD01


Create customer master

12. Run BD12

Ashok
SAP-ADV ABAP 162

13. Work with WE05

Solution:
Step-1:
Creating logical systems:
 Go to SALE
 Expand Basic Settings
 Expand Logical Systems
 Select Define Logical System option
 Enter

Note:
Logical systems are client independent

 New Entries
Logical System Name
EXT1800 SENDER
EXT1810 RECEIVER

 Save
 Back
 Back

Assigning Logical Systems to Clients:


 Select Assign Logical System to Client option
 Enter
 Double click on 800 client
 Logical System: EXT1800
 Save
 Enter
 Back
 Double click on 810 client
 Logical System: EXT1810
 Save
 Enter

Step-2:
Creating RFC destinations in 800 client:
 Go to SM59
 Select ABAP Connections
 Create
 RFC Destination: EXT1810
Ashok
SAP-ADV ABAP 163

 Description: RFC for Client 810


 Target Host: SAPLID
 Logon & Security tab
 Scroll down to bottom
 Language: EN
 Client: 810
 User: user1
 PW Status: rgsabap
 Enter
 Enter
 Save
 Enter
 Remote Logon button
 Working under client 810

Creating RFC destinations in 810 client:


 Go to SM59
 ABAP Connections
 Create
 RFC Destination: EXT1800
 Description: RFC for Client 800
 Target Host: SAPLID
 Logon & Security tab
 Scroll down to bottom
 Language: EN
 Client: 800
 User: user1
 PW Status: Rgsabap
 Enter
 Enter
 Save

Note:
In real time the above 2 steps are done by Basis Consultant

Step-3: Creating Segment Type


 Select client 800 session
 Go to WE31
 Segment Type: Z1SEG
 Create
 Short Description: custom segment type
Field Name Data element
Ashok
SAP-ADV ABAP 164

KUNNR KUNNR
NAME1 NAME1
LAND1 LAND1
ORT01 ORT01
PSTLZ PSTLZ
STRAS STRAS

 Save

Step-4: Creating Extended IDOC Type


 Go to WE30
 Object Type: Z1CUST_02
 Extension radio button
 Create
 Enter
 Linked Basic Type: DEBMAS05
 Description: IDOC Extension
 Enter
 Select E1KNA1M
 Create
 Enter
 Segment Type: Z1SEG
 Select Mandatory Segment option
 Min: 1
 Max: 1
 Enter
 Save

Step-5: Linking Message Type & Extended IDOC Type


 Go to WE82
 Display / Change option
 New Entries
Message Type Basic Type Extension Release
DEBMAS DEBMAS05 Z1CUST_02 620

 Save

Step-6: Creating Model View


 Go to BD64
 Display / Change (F9)
 Create Model View
 Short Text: model view for Extended IDOC
Ashok
SAP-ADV ABAP 165

 Technical Name: EXTMOD


 Enter
 Scroll down to bottom
 Select your model view description
 Add Message Type option
 Sender: EXT1800
 Receiver: EXT1810
 Message Type: DEBMAS
 Enter
 Save

Step-7: Creating Port


 Go to WE21
 Transactional RFC option
 Create
 You will find a pop-up, Enter
 Description: Port creation
 RFC Destination: EXT1810
 Save

Step-8: Maintaining Partner Profiles


 Go to WE20
 Partner Type: LS
 Create
 Partner Number: EXT1810
 Save
 Scroll down to bottom
 Under Outbound Parameters
 Select ‘+’ create Outbound Parameters
 Message Type: DEBMAS
 Basic Type: DEBMAS05
 Extension: Z1CUST_02
 Receiver Port: A00000111
 Select Transfer IDOC Immediately option
 Save

Step-9: Creating Extended IDOC program


 Go to SMOD
 Enhancement: VSV00001
 Display
 Components
 Double click on EXIT_SAPLVV01_001
Ashok
SAP-ADV ABAP 166

 Double click on INCLUDE ZXVSVN01


 Display / Change option

DATA: WA_KNA1 TYPE Z1SEG,


WA_DATA TYPE EDIDD,
WA_MAPPING TYPE E1KNA1M.

CASE SEGMENT_NAME.
WHEN ‘E1KNA1M’.
READ TABLE IDOC_DATA INTO WA_DATA WITH KEY SEGNAM =
‘E1KNA1M’.
WA_MAPPING = WA_DATA + SDATA.

SELECT SINGLE KUNNR NAME1 ORT01 PSTLZ STRAS FROM KNA1 INTO
WA_KNA1 WHERE KUNNR = WA_MAPPING-KUNNR.
WA_DATA-SDATA = WA_KNA1.
WA_DATA-SEGNAM = ‘Z1SEG’.

APPEND WA_DATA TO IDOC_DATA.

ENDCASE.

Step-10: Linking Extended IDOC program with CMOD


 Go to CMOD
 Project: EXTIDOC
 Create
 Short Text: linking
 Enhancement Assignments
 Enhancement
 SAPVSV00001

 You may find an error note down that project name


 Project: ZIDOC
 Activate

Step-11: Creating customer master


 Go to XD01
 Account Group: bill to party
 Customer: 9634
 Enter
 Title: Mr
 Name: Satya
Ashok
SAP-ADV ABAP 167

 City: Hyderabad
 Country: In
 Save

Step-12: Running BD12


 Go to BD12
 Customer: 9634
 Output Type: DEBMAS
 Logical System: EXT1810
 Execute

Step-13: Checking IDOC status


 Go to WE05
 Execute
 Double click on your IDOC Number
 Expand Data Records
 Here you will find your IDOCs

Ashok
SAP-ADV ABAP 168

*** Trouble Shooting & Recovery:


1. Message ‘0 Master IDOC is created’
No data in databse

2. Message ‘0 Communication IDOC generated’


No Logical System defined in SALE

3. Status 29
Error in ALE Service Layer (or)
Error in Custom (or) Extended program

4. Status 26
Error in Syntax Check (or)
If Segment is wrong (or)
Mandatory Segments are deleted (or)
If Partner Profiles are not maintained in WE20

Important T codes for ALE:


1. WE19 (ALE Testing Tool)
It is for testing IDOCs

Example:
 Go to WE19
 IDOC Number: 8110 (it is wrong)
 Execute
 Double click on IDOC Number
 Standard Inbound option
 You will find a pop-up with error message

2. BD20
It is for processing partial IDOCs

3. WE09
It is for searching IDOCs which are being processed as on date

Ashok
SAP-ADV ABAP 169

Debugging IDOCs:
1st Method:
 Go to BD20
 IDOC Number: 801120
 Command Prompt: /H
 Enter
 Enter
 F6………………..

2nd Method:
 Go to SE37
 Function Module: IDOC_INPUT
 Display
 Place Dynamic Break Point at DESCRIBLE TABLE IDOC_DATA LINES

 Go to BD20
 IDOC Number: 801120
 Execute

***Question: How you can change the status of an IDOC?


Answer:
Using standard program RBDAPP01

Ashok
SAP-ADV ABAP 170

EDI:
 Electronic Data Interchange
 Paperless work
 EDI is computer to computer exchange of routine business data (Purchase Orders,
Invoices, Sales Orders………..etc) in standard format

Advantages of EDI:
 Availability of data in electronic forms
 Reduced data entry errors
 Paperless work
 Better competitive advantage
 Accuracy of data
 Speed
 Security

Difference between ALE & EDI:


 ALE is SAP’s distributed technology for transferring data between two systems
 In ALE data transfer is done between Logical Systems
 EDI is not SAP’s technology
 In EDI data transfer is done in standard format between Business Partners

EDI Architecture:

Ashok
SAP-ADV ABAP 171

EDI Architecture Involves:


1. EDI Enable Applications
For creating business processes such as Purchase Orders, Invoices, Sales Orders…….. etc

2. Carrier of Data (IDOC)


3. EDI Sub Systems
4. Middleware Technologies (networks).
These converts IDOC interfaces into EDI Enabled Message Types
Example:
Middleware Technologies, Web methods, EAI …………..etc

Middle Wares:
1. EAI
Enterprise Application Integration
1. MA Series
2. Web Methods

2. EDI Systems
1. Gentian
2. Mercator

3. SAP XI
Exchange infrastructure

4. SAP Net wavers

Ashok
SAP-ADV ABAP 172

Steps in EDI Process Flow:


1. Work with WE21
Create File Port

2. Work with XK01


Create vendor

3. Work with WE20


Maintain Partner Profiles

4. Work with MN05


Maintain Conditional Records

5. Work with ME21N


Create Purchase Order based on vendor

6. Work with ME22


Check status of IDOC

Solution:
Step-1: Creating File Port
 Go to WE21
 File
 Create
 Port: IDOCPORT
 Description: Port creation
 Scroll down to bottom
 Function Module: EDI_PATH_CREATE_USERNAME
 Inbound File tab
 Function Module: EDI_PATH_CREATE_USERNAME
 Save
 Outbound Trigger tab
 RFC Destination: SERVER_EXEC
 Save

Note:
SERVER_EXEC will transfer the IDOC file to Web methods

Step-2: Creating Vendor


 Go to XK01
 Create a vendor 9347 by providing mandatory fields
 Save
Ashok
SAP-ADV ABAP 173

Step-3: Maintaining Partner Profiles


 Go to WE20
 Partner Type: LI
 Create
 Partner Number: 9347
 Save
 Under Outbound Parameters
 Select ‘+’ Create Outbound Parameter
 Partner Role: VM
 Message Type: ORDERS
 Receiver Port: IDOCPORT
 Transfer IDOC Immediately option
 Start Sub System option
 Basic Type: ORDERS05
 Save
 Message Control
 ‘+’ Insert Row
Application Message Type Process Code
EF NEU ME10

 Save

Step-4: Maintaining Conditional Records


 Go to MN05
 Output Type: MEU
 Key Combination
 Enter
 Execute
Vendor Function Partner Medium Language
9347 VN 9347 6 EN

 Save

Step-5:
 Go to ME21N
 Vendor: 9347
 Enter
 Purchase Organization: 1000
 Purchase Group: 001
 Company Code: 1000
 Enter
Ashok
SAP-ADV ABAP 174

 Currency: INR
 Material: 100-101
 PO Quantity: 10
 Net Price: 3000
 Plant: 1000
 Save
 Once you save the application you will get a message ‘Purchase Order ……… created’

Step-6: Checking status of IDOC


 Go to ME22
 F6
 Header ------- Messages
 Here you will find a green color status
 Select that status, select Processing Log option
 You should find message ‘IDOC created & written to file’

Ashok
SAP-ADV ABAP 175

BAPI:
 Business Application Programming Interface
 It is an interface programming across business applications

Difference between BDC & BAPI:


BDC BAPI
1. In BDC we have to update the database 1. BAPI updates the database directly
Via Screens
2. Screen mapping is compulsory 2. No mapping required
3. BDC programs not effective for 3. BAPI ensures very good performance for
Large applications (poor performance) all SAP applications
4. In up gradation projects as there may be 4. Same BAPI programs can be reused
New screens with new fields therefore you
Have to rewrite your BDC program
5. BDC is not available for Enjoy transactions 5. Can upload data for Enjoy Transactions
Also

Features of BAPI:
1. BAPI is an interface programming
2. It is based on Object Oriented Programming
3. It supports all types of Languages (.Net, Java, VC++………etc)
4. It supports all type of Communication interfaces (RFC, COM, DCOM, CORBA,
TIBCO………….etc)
5. In BAPI, RFC function module converted to method & the same method is accessed by
3rd party communication interfaces
6. BAPI is synchronous

Business Object:
 The entire business objected oriented programming is designed based on business objects
 Every business object holds business data & does not allow it to access by outside world

Components of Business Object:


1. Kernel
2. Integration Layer
3. Interface Layer
4. Communication Layer

Kernel:
It holds inherent data

Ashok
SAP-ADV ABAP 176

Integration Layer:
In this layer methods are defined for accessing Kernel data

Interface Layer:
Here interfaces (BAPIs) are maintained for integrating with methods

Communication Layer:
All communication interfaces (RFC, CORBA……..etc) can access this layer

Other Components of Business Object:


1. Object Type
2. Key Fields
3. Methods
4. Attributes ………….etc

Object Type:
 Business Objects are created based on Object Type
 It acts as a blue print (or) template for creating business objects

Key Fields:
Using this option key fields are maintained (Customer Number, Sales Order………etc)

Methods:
The main logic for extracting business data is maintained using Methods

Attributes:
 These are the parameters which are passed & returns from Methods
 These are actually part of Methods

Ashok
SAP-ADV ABAP 177

BOR:
 Business Object Repository
 It is the central repository for all business object types & their BAPIs

Features of BOR:
1. It acts as central access point (or) repository for all Business Objects, Object Types, Their
Key Fields, Methods …………..etc
2. All 3rd party Communication interfaces can access Business Objects stored in BOR
3. Business Objects maintained in BOR remains stable for a long time

Note:
The T code for working with BOR is BAPI & SW01

Where BAPIs are used in Real Time:


1. In all modules (SD, MM, PP, HR ………etc)
2. In dimensional products (CRM, APO, SCM………etc)
3. In ALE directly

Ashok
SAP-ADV ABAP 178

***Types of BAPIs:
1. Standard BAPI
2. Custom BAPI
3. Extended BAPI

Standard BAPI:
In standard BAPI, all BAPI function modules are predefined

Object:
Create a bank in client database

Solution:
 Go to SE38
 Program: ZFI_BAPI_BANK
 Create
 Title: Uploading bank data using BAPI
 Type: Executable Program
 Save

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.


PARAMETERS: p_banks TYPE banks,
p_bankl TYPE bankl.
SELECTION-SCREEN: END OF BLOCK b1.

DATA: wa_bank_address TYPE BAPI1011_ADDRESS,


wa_return TYPE BAPIRET2.

wa_bank_address-bank_name = ‘Sbi’.
wa_bank_address-street = ‘Lbnagar’.
wa_bank_address-city = ‘Hyderabad’.
wa_bank_address-bank_brnch = ‘Lbnagarbranch’.

CALL FUNCTION ‘BAPI_BANK_CREATE’


EXPORTING
BANK_COUNTRY = p_banks
BANK_KEY = p_bankl
BANK_ADDRESS = wa_bank-address
IMPORTING
RETURN = wa_return.

IF SY-SUBRC EQ 0.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
Ashok
SAP-ADV ABAP 179

EXPORTING
WAIT = ‘X’.
ENDIF.

IF wa_return-message IS NOT INITIAL.


WRITE:/30 wa_return-message.
ELSE.
MESSAGE ‘Bank created successfully’ TYPE ‘I’.
ENDIF.

Ashok
SAP-ADV ABAP 180

Object-2:
Create interface program for update bank data

Solution:
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.
PARAMETERS: p_banks TYPE banks,
p_bankl TYPE bankl.
SELECTION-SCREEN: END OF BLOCK b1.

DATA: wa_bank_address TYPE BAPI1011_ADDRESS,


wa_return TYPE BAPIRET2.

wa_bank_address-bank_name = ‘Sbi’.
wa_bank_address-street = ‘Tnagar’.
wa_bank_address-city = ‘Chennai’.
wa_bank_address-bank_brnch = ‘Tnagarbranch’.

wa_bank_addressx-street = ‘X’.
wa_bank_addressx-city = ‘X’.
wa_bank_addressx-bank_brnch = ‘X’.

CALL FUNCTION ‘BAPI_BANK_CHANGE’


EXPORTING
BANK_COUNTRY = p_banks
BANK_ADDRESS = wa_bank-address
BANK_ADDRESSX = wa_bank-addressx
IMPORTING
RETURN = wa_return.

IF SY-SUBRC EQ 0.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
WAIT = ‘X’.
ENDIF.

IF wa_return-message IS NOT INITIAL.


WRITE:/30 wa_return-message.
ELSE.
MESSAGE ‘Bank updated successfully’ TYPE ‘I’.
ENDIF.

Ashok
SAP-ADV ABAP 181

*** Assignment:
Create BAPI interface program for creating sales order using
BAPI_SALEORDER_CRETEDAT2

Solution:

Ashok
SAP-ADV ABAP 182

23-11-2014
Custom BAPI:
In Custom BAPI, BAPI function modules are custom defined

Object:
Create customized BAPI for invoice object

Phases:
1. Analysis Phase
2. Design Phase
3. Implementation Phase
4. Test & Release Phase

Analysis Phase:
During this phase Project Managers will analyze which BAPI project should be implemented
for current project

Design Phase:
During this phase BAPI Structures & Tables are designed

Implementation Phase:
During this phase BAPI project will be implemented
It is further having following sub phases
1. Working with SE11 (DDIC)
2. Working with SE37 (Create RFC Form)
3. Working with SWo1 (create Business Object)
4. Working with SE38 (create Interface program)

Test & Release Phase:


In this phase BAPI is tested & released

Solution:
Step-1:
Creating Structure:
 Go to SE11
 Data Type: ZBAPI_INVSTR
 Create
 Structure
 Short Description: Invoice details
Component Component Type
VBELN VBELN_VF
FKDAT FKDAT
Ashok
SAP-ADV ABAP 183

MATNR MATNR
ARKTX ARKTX
FKIMG FKIMG
NETWR NETWR

 Currency / Quantity Fields tab


Reference Table Reference Field
EKPO MEINS
T001 WAERS

 Activate

Creating Table:
 Go to SE11
 Database Table: ZBAPI_INVTABLE
 Create
 Short Description: Invoice table
 Delivery Class: A
 Table View Maintenance: Display / Maintenance View Allowed
 Fields
Field Data Element
MANDT _/ MANDT
VBELN _/ VBELN_VF
FKDAT FKDAT
MATNR MATNR
ARKTX ARKTX
FKIMG FKIMG
NETWR NETWR

 Currency / Quantity Fields tab


Reference Table Reference Field
EKPO MEINS
T001 WAERS

 Technical Settings
 Data Class: APPL0
 Size Category: 0
 Save
 Back
 Activate
 Utilities ----- Table Contents ----- Create Entries
 Provide input & Save
Ashok
SAP-ADV ABAP 184

Step-2: Creating RFC Function Module


 Go to SE37
 Goto ---Function Groups ---- Create Group
 Function Group: ZBAPI_FGR
 Short Text: BAPI Group
 Enter
 Function Module: ZBAPI_BILL_FUNCTION
 Create
 Function Group: ZBAPI_FGR
 Short Text: BAPI module for invoice
 Enter
 Enter
 Attributes tab
 *** Remote Enabled Module
 Import tab
Parameter Name Typing Associated Type Pass Value
VBELN_LOW TYPE ZBAPI_INVSTR-VBELN _/
VBELN_HIGH TYPE ZBAPI_INVSTR-VBELN _/
DATE_LOW TYPE ZBAPI_INVSTR-FKDAT _/
DATE_HIGH TYPE ZBAPI_INVSTR-FKDAT _/

 Export tab
Parameter Name Typing Associated Type Pass Value
RETURN TYPE BAPIRET2 _/

 Tables tab
Parameter Name Typing Associated Type
IT_INV LIKE ZBAPI_INVTABLE

 Source Code tab


SELECT * FROM ZBAPI_INVTABLE INTO TABLE IT_INV
WHERE VBELN BETWEEN VBELN_LOW AND VBELN_HIGH
AND FKDAT BETWEEN DATE_LOW AND DATE_HIGH.

IF SY-SUBRC NE 0.
RAISE INVALID-INPUT.
ENDIF.

 Activate
 Back
 Function Module --- Release----- Release
Ashok
SAP-ADV ABAP 185

Step-3: creating Business Object


 Go to SWO1
 Object Type: ZCUS_BILL
 Create
 Object Type: ZCUS_BILL
 Object Name: BILLINGG
 Name: Invoice Details
 Description: Invoice Details
 Program: ZBILL_INV
 Application: V
 Enter
 Select Key Fields
 Create (F5)
 Yes
 Table: ZBAPI_INVTABLE
 Enter
 Select VBELN
 Enter
 You will find a pop-up, Enter
 Select Methods
 Utilities ---- API Methods --- Add Method
 Function Module: ZBAPI_BILL_FUNCTION
 Enter
 You will find a pop-up, select Next Step option
 Next Step option
 You will find a message ‘Do you want to generate a template automatically for missing
section’, Yes
 Save
 Back

Testing the Business Object:


 Object Type ---- Change Release Status To ------- Implemented
 Test button
 Execute
 Provide input
 Execute
 You should find entries in your internal table

Note:
In real time if your testing is not fine go to SE37 & solve the issue

Ashok
SAP-ADV ABAP 186

Creating Business Object in BOR:


 Go to SWO1
 Change Object Type: ZCUS_BILL
 Change
 Select ZCUS_BILL
 Edit ----- Change Release Status ----Object Type ---- To Released
 Enter
 Enter
 Expand Methods
 Select your method (ZBAPIFUNCTION)
 Edit ---- Change ---- Release Status ---- Object Type Component----- To
Released
 *** Generate (Ctrl + F3)\
 Go to BAPI
 Scroll down you will find your Business Object

Note:
In real time as a ABAP Consultant we should create business objects in BOR

Assignment-1:
Create standard BAPI for creation of material using BAPI_MATERIAL_SAVEDATA

Assignment-2:
Create standard BAPI for creating purchase order using BAPI_PO_CREATE

Ashok
SAP-ADV ABAP 187

Adobe Forms:
 Using Adobe Forms you can design interactive forms with various interactive actions
 In Smart Forms we can design only Paper Forms
 But using Adobe Forms you can design PDF (or) Online Forms

System Requirements for Installing Adobe Forms:


1. Adobe life cycle designer
2. Java stack
3. Version ECC 6.0 & above
4. QUI patch level should be greater than 5

Note:
 T code for working with Adobe Forms is SFP
 Adobe forms can be exploited using
ABAP knowledge
Web Dynpro
Java Script

Object:
Develop an invoice form using Adobe forms

Solution:
 Go to SFP
 Interface: ZBILL_INT
 Create
 Description: Invoice interface
 Enter
 By default Import option is selected
 On right side select Append Row option
VBELN TYPE VBELN_VF

 Double click on Types option


TYPES: BEGIN OF TY_VBRP,
VBELN TYPE VBELN_VF,
MATNR TYPE MATNR,
FKIMG TYPE FKIMG,
ARKTX TYPE ARKTX,
NETWR TYPE NETWR,
END OF TY_VBRP.

TYPES: T_VBRP TYPE TABLE OF TY_VBRP.


Ashok
SAP-ADV ABAP 188

 Double click on Global Data


 On right side select Append Row option
IT_VBRP TYPE T_VBRP

 Double click on Code Initialization


 Above Input Parameters, select Append Row
 Above Output Parameters, select Append Row
VBELN IT_VBRP

SELECT VBELN MATNR FKIMG ARKTX NETWR FROM VBRP INTO TABLE
IT_VBRP WHERE VBELN = VBELN.

 Activate
 Back
 Form: ZBILL_FORM
 Create
 Description: Invoice form
 Interface: ZBILL_INT
 Enter
 Expand Import
 Drag & drop VBELN under ZBILL_FORM
 Expand Global Data option
 Drag & drop IT_VBRP under ZBILL_FORM
 Expand System Fields
 Expand SFPSY
 Drag & drop DATE, USER NAME under ZBILL_FORM
 Layout
 Palettes ---- Library
 Place Text Icon on Design view
 Place Image Icon on design view
 Double click on Image
 Ok
 Select any Logo, Open
 Right click on image
 Palettes ----- Object
 Embed Image Data
 Close
 Place VBELN, DATE, USER NAME on design view
 Place IT_VBRP on design window
 Save
 Close
Ashok
SAP-ADV ABAP 189

 Activate
 Go to SE38
 Program: ZSD_ADOBE_FORM
 Create
 Title: Adobe form
 Type: Executable Program
 Save

PARAMETERS p_vbeln TYPE vbeln_vf.

DATA: fname TYPE RS38L_FNAM,


output TYPE SFPOUTPUTPARAMS.

PERFORM open_form.
PERFORM call_form.
PERFORM close_form.

FORM open_form.
CALL FUNCTION ‘FP_JOB_OPEN’
CHANGING
IE_OUTPUTPARAMS = output.
ENDFORM.

FORM call_form.
CALL FUNCTION ‘FP_FUNCTION_MODULE_NAME’
EXPORTING
I_NAME = ‘ZBILL_FORM’
IMPORTING
E_FUNCNAME = fname.

CALL FUNCTION FNAME


EXPORTING
VBLEN = p_vbeln.
ENDFORM.

FORM close_form.
CALL FUNCTION ‘FP_JOB_CLOSE’.
ENDFORM.
 Activate
 Execute
 Provide input
 Execute
Ashok
SAP-ADV ABAP 190

Debugging Techniques:
Table Level Debugging:
Using table level debugging you can manipulate data directly from table level

Example:
 Go to SE11
 Database Table: KNA1
 Display
 Contents
 Kunnr: 1000 to 1005
 Execute
 Select Select All option (F9)
 Display (F7)
 Command Prompt: /H
 Enter
 Enter
 Debugging ----Switch to New ABAP Debugger
Variable
CODE

 Enter
 Scroll horizontally
 Click on Change Field
 Remove SHOW & provide EDIT

Note:
For delete ------ DELE
For modify ---- EDIT
For insert ------ INSR

 Enter
 F6 ……………….
 F8
 Provide input (which you want to modify)
 Save
 Next Entry
 Provide input (which you want to modify)
 Save

Ashok
SAP-ADV ABAP 191

Modifying Data during Debugging:


 Go to SE38
 Program: any program name
 Debugging
 Provide input values
 Execute
 Tables
 Table: internal table name
 F6
 Double click on the record which you want to modify
 Click on Pen option
 Modify & Enter

Ashok
SAP-ADV ABAP 192

Debugging Background Jobs:


 Go to SM37
 Job Name: any job name
 Execute
 You will find a job name tick its check box
 ***Command Prompt: JDBG
 Enter
 Enter

Ashok
SAP-ADV ABAP 193

Lock Object:
Using lock object you can maintain data integrity between applications

Example:
 Go to SE11
 Database Table: YCUSTOM
 Create
 Short Description: custom table
 Delivery Class: A
 Table View Maintained: Display / view allowed
 Fields tab
Field name Data element
MANDT MANDT
KUNNR KUNNR
NAME1 NAME1

 Technical Settings
 Data Class: APPL0
 Size Category: 0
 Save
 Back
 Activate
 Utilities ---- Table Contents ---- Create Entries
 Kunnr: 1000
 Name1: satya
 Save

 Go to SE38
 Program: ZLOCK
 Create
 Title: lock object program
 Type: Executable Program
 Save

TABLES YCUSTOM.

PARAMETERS p_cust TYPE KUNNR.

START-OF-SELECTION.
CALL SCREEN 100.

 Double click on 100


Ashok
SAP-ADV ABAP 194

 Yes
 Short Description: main screen
 Layout
 F6
 Table: YCUTOM
 Enter
 Select all fields, Enter
 Place the fields on screen
 Flow Logic
 Remove comment for MODULE STATUS_100
 Double click on STATUS_100
 Yes
 Main Program
 Enter

SELECT SINGLE * FROM YCUSTOM WHERE KUNNR = p_cust.

 Go to /OSE11
 Lock Object: EZLCK1
 Create
 Short Description: lock object
 Tables
 Name: YCUSTOM
 Lock Mode: WRITE LOCK
 Activate

Note:
Once your lock object is activated system will create 2 function modules
One for applying lock &
Another for releasing lock

 Goto ---- Lock Modules


 Copy Request Lock function module (ENQUEUE_EZLCK1)
 Select your program session (SE38)
 Pattern
 Call Function: paste (ENQUEUE_EZLCK1)
 Enter

CALL FUNCTION ‘ENQUEUE_EZLCK1’


EXPORTING
MODE_YCUSTOM = ‘E’
MANDT = SY-MANDT
Ashok
SAP-ADV ABAP 195

KUNNR = p_cust.

 Activate

 Remove comment for MODULE USER_COMMAND_100


 Double click on USER_COMMAND_100
 Yes
 Main Program
 Enter
 Select DDIC (SE11) session
 Copy Release Lock function module (DEQUEUE_EZLCK1)
 Go to SE38 session
 Pattern
 Call Function: paste (DEQUEUE_EZLCK1)
 Enter

CALL FUNCTION ‘DEQUEUE_EZLCK1’


EXPORTING
MODE_YCUSTOM = ‘E’
MANDT = SY-MANDT
KUNNR = p_cust.

 Activate
 Back
 Activate

Testing:
 Go to SE38
 Execute your program
 Done

 Go to /OSE38
 Execute your program
 Not Done

Note:
In real time locks are released manually using T code SM12
o Go to SM12
o List
o Select locks
o Lock Entry ----- Delete All

Ashok
SAP-ADV ABAP 196

Ashok
SAP-ADV ABAP 197

Search Help Exit:


Example:
 Go to SE11
 Database Table: YCUST1
 Create
 Short Description: custom table
 Delivery Class: A
 Table View Maintained: Display / view allowed
 Fields tab
Field name Data element
MANDT MANDT
KUNNR KUNNR
NAME1 NAME1

 Technical Settings
 Data Class: APPL0
 Size Category: 0
 Save
 Back
 Activate
 Insert the following records into table
1000 satya
1001 satya
1002 satya
1003 pruthvi

 Go to SE37
 Function Module: F4IF_SHLP_EXIT_EXAMPLE
 Copy
 To: ZSEARCH_MOD
 Function Group: ZFGR
 Enter
 Enter
 Function Module: ZSEARCH_MOD
 Change
 Scroll down to bottom, before EXIT

SORT RECORD_TAB.

DELETE ADJACENT DUPLICATES FROM RECORD_TAB.

 Activate
Ashok
SAP-ADV ABAP 198

 Go to SE11
 Search Help: ZSEAR_HELP
 Create
 Enter
 Short Description: elementary search help
 Selection Method: ZCUST1
 Search Help Exit: ZSEAR_HELP
 Scroll down to bottom, provide
Search Help Parameter Export Import LPOS SPOS
NAME1 _/ _/ 1 1

 Activate

 Go to SE38
 Program: ZCALL_SEARCH
 Create
 Title: search help exit program
 Type: Executable Program
 Save

PARAMETERS p_search MATCHCODE OBJECT ZSEAR_HELP.

 Activate
 Execute
 Apply F4 on field
 You will find only sorted list
i.e. 1000 satya
1004 pruthvi

Ashok
SAP-ADV ABAP 199

Questions & Answers:


BDC:
Question-1:
Assume my Session has been processed & after processing I want my Session to be displayed in
SM35 for status check. How you can achieve this task?
Answer:
By providing exporting parameter KEEP = ‘X’ you can get your processed session back in
SM35

Question-2:
How you can maintain Logs (or) Error records in Session method?
Answer:
In Session method SAP is providing a Log file by default
No need to create a Log file for handling error records
You can find Log file by using SM35
 Go to SM35
 Select your session
 Select Log option (F7)
 Select your session
 Select Display button

Question-3:
How you can perform background processing in Session method?
Answer:
Using program RSBDCSUB you can execute session in background

Example:
In above program modify subroutine PERFORM close_session.

FORM close_session.

CALL FUNCTION ‘BDC_CLOSE_GROUP’.

SUBMIT RSBDCSUB VIA SELECTION-SCREEN.

ENDFORM.

 Execute
 F4
 Select your Flat File
 Execute
Ashok
SAP-ADV ABAP 200

 You will find a selection screen


 Session: RGS
 Execute

Question-4:
Suppose I’m having a Flat File with 50000 records. It happened that the system crashed while
uploading data. How I know the number of records exactly uploaded?
Answer:
I will go to respective database table & copy the key values to the table & execute it

Question-5:
Assume there are 1000 records out of which I uploaded 500 records & remaining I want to
upload next day. How you will you perform this job?
Answer:
I will check the status of the records uploaded & I will delete the records from Flat File which
are correctly uploaded & remaining I will execute once again on next day

Question-6:
I’m having 2 Flat Files with 500 records & 50000 records. Which method will you prefer for
both Flat Files?
Answer:
 For 500 records Call Transaction Method
 For 50000 records Session Method

Question-7:
What is the difference between Session Method & Call Transaction Method?
Answer:
Session Method Call Transaciton Method
7. It for uploading large amount of data 1. It for uploading small amount of data
8. Multiple applications can be processed 2. Only single application can be processed
at one time with one BDC program at one time with one BDC program
9. In this method respective Log File is 3. In this method we have to create Log file
already given by SAP explicitly using structure BDCMSGCOLL
10.Asynchronous processing 4. Synchronous processing
11.Synchronous updating 5. Asynchronous updating
12.It is a slower method but consistent 6. Faster than Session method

Question-8:
How will you handle error records BDC?
Answer:
 In real time client will ask error records during BDC upload

Ashok
SAP-ADV ABAP 201

 For that we have to provide him Logs in the form of error file
 In Session Method Log file you can find directly in SM35
 In Call Transaction Method as processing synchronous we have to create a Log file
internal tabld based on structure BDCMSGCOLL which holds log details during
processing of application
 The error records are looped to respective work area which further exported to Funtion
Module FORMAT_MESSAGE
 It returns a Message ID which I will capture by using a dummy internal table

1.) What is the full form of bdc?


Ans: Batch data communication

1.) What is alternate to batch input session?


Ans: Call transaction and call dialog.

3.) What are the steps in bdc session?


Ans:
 The first step is to identify screens of a transaction the program will process
 Next step is to write a bdc program to build a bdc table will be used to submit data in sap.
 The final step is to submit the bdc table to the system in the batch mode or through a
single call transaction method.

4.) What table stores on line messages?


Ans: T100

5.) What do u do if system crashes in middle of bdc?


Ans:
I will check the number of record updated and delete the same from flat file and upload again. (I
will check the log file in sm35)

6.) What do u do with errors in bdc session?


Ans: Analyze the input file format and entries in internal table bdc data.

7.) What are the commands for sequential file and their syntax?
Ans:
1. Read dataset file <file> into <wa>.
2. Open dataset file <filename> in binary mode
3. Close dataset <file>.
4. Transfer <file> to <wa>.
5. Delete dataset <file>.

Ashok
SAP-ADV ABAP 202

8.) Why batch input?


Ans: To upload large amount of information at peak times

9.) Can data be put directly in database in sap?


Ans: No, only when data has been entered into transaction.

10.) Explain at high levels, the batch input sessions?


Ans:
 Batch data is placed in queues called batch input sessions
 Then placed into Application programs for maintenance
 Then into the database

11.) What are the function modules for batch input?


Ans:
1. Bdc_open_group
2. Bdc_insert
3. Bdc_close_group

12.) What is the structure of bdc table?


Ans:
1. Program (program name)
2. Dynrpo (screen numbers)
3. Dynbegin (start screen)
4. Fnam (fieldnames)
5. Fval (field values)

13.) Write down the coding example of filling the data into bdc table ?
Ans:

14.)How do u find the transaction number, screen numbers and fieldnames?


Ans:
 System->status
 F1
 Technical attributes
 Functional
 Tech specs
 Recording

15.) What are the processing modes of batch input?


Ans:
1. Foreground

Ashok
SAP-ADV ABAP 203

2. Background
3. Display with errors

16.) What is the effect of bdc_cursor field in bdc table?


Ans:
U can set the cursor and enter the corresponding field value and corresponding
Fieldname on which the cursor to be positioned

17.) Why u choose session or call transaction method?


Ans:
 When u want to update database for a single transacton->ctm
 U can update the database in asynchronous mode.
 U can update huge database updating for more than one transaction.

18.) How u can trap error in ctm?


Ans:
 Errors can be trapped using a structure BDCMSGCOLL, whose field MSGTYP will
become ‘E’ whenever an error occurs.
 There errors are formatted using FORMAT_MESSAGE in the desired format and stored
in an internal table.

19.) What are the diff types of update modes?


Ans:
1. Synchronous
2. Asynchronous

20.) What is diff b/w session method and lsmw?


Ans:
 In session the method of updation is ‘BATCH INPUT’ we require a program to be coded.
 In lsmw the method of updation is BATCHINPUT, DIRECT INPUT, IDOC, BAPI.
 Here method is through navigation.

21.) How do u find the information in current screen?


Ans: Menu->system->status

22.) How do u save data in bdc tables?


Ans: By using field name BDC_OKCODE and value is ‘/11’.

23.) What is multiple line field?


Ans: It is special field, which allows user to enter multiple lines in it.

Ashok
SAP-ADV ABAP 204

24.) What is the last entry in bdc tables?


Ans: The last entry is to save data using BDC_OKCODE and the value is ‘/11’.

25.) An index is added to the fieldname to indicate which line is to be populated by bdc session?
Ans:

26.) What is batch input session?


Ans:
 Intermediate step between internal table and database table
 Data along with the action is stored in session
 i.e. Data for screen fields, to which screen the data should be passed, the program
behind the screen.

27.) A situation: an abap program creates a batch input session. We need to submit the Program
and batch input session in background. How will u do it?
Ans:
Go to SM36 and create a background job by giving job name, job class and job steps
(background scheduling steps).

28.) What are the problems in processing batch input sessions?


Ans: If user forgets to ‘keep’ session then session is automatically removed from session queue
and the log remains

29.) Which mode in call transaction allows background processing?


Ans: ‘n’

30.) What is the syntax of call transaction method?


Ans:

31.) Is it possible to use call transaction without bdc table?


Ans:
Yes, in such case the current program is suspended, the transaction specified is brought up and a
user must enter data into screens.

32.) How many sessions are opened with BDC_OPEN_GROUP?


Ans: One.

33.) What is batch input or bdc?


Ans:
The methods ctm and session are collectively called batch input for transferring data between
systems.

Ashok
SAP-ADV ABAP 205

34.) What are the advantages of batch input?


Ans:
 Ensures data integrity
 No manual interaction for data transfer

35.) What is synchronous database update?


Ans: No new transaction is started until previous transaction is written to database.

36.) Suppose there are 1000 records and there is an error at 66 record. How will u identify and
send it to end user?
Ans: Using BDCMSGCOLL u can capture error records and using T code SLG1 u can find it.

37.) I am uploading 1000 records using session method. I have an error at 950 record. What will
happen in both ctm and session method?
Ans:
 Up to 949 records are updated using session method.
 Except 950 remaining all records are update using ctm.

38.) What is the use of OK_CODE in bdc?


Ans:
 Bdc_okcode will hold all the ok codes in the bdc program,
 When u pass fields to a screen after filling the fields we need to click on a button to move
other screens,
 So here, button will have a ok_code internally to know this we are recording in a program
 After that, we will store this ok_code in bdc_okcode field to trigger next operation.

39.) How will generate and processing the session in the same program?
Ans: In ur program using SUBMIT RSBDCSUB VIA SELECTION-SCREEN

40.) How will run bdc program in background?


Ans: RSBDCSUB

41.) I want to upload 10 lakh records and each record is taking 1 minute for processing. How
will solve this issue?
Ans:
 Break the records into 100/1000 sessions and process ur session it will take same time as
it take for single sessions.
 We can go through lsmw direct input method.
 Use bapi run in background.

Ashok
SAP-ADV ABAP 206

42.) How does u know that updation is successful or not?


Ans:
 Using BDCMSGCOLL u can find the errors
 In session method go to SM35 see the status (the green shows successful & red with
errors)

43.) If I want to upload 5 lakh records. Which method do think is best?


Ans: Session as it provide log for each record processed

44.) What is ‘keep’ in bdc structure?


Ans:
 It is an indicator to check processed sessions
 If this flag is set then session is kept even after it is processed otherwise session is deleted
after its processing is over.

45.) After running a bdc program with session, I found few errors next morning. What will u
do?
Ans:
 Correct the error records (ur flat file) and run bdc program.
 If problem is not in session then I will check the bdc program.

46.) U are given FD for bdc, how will u decide which method to use?
Ans:
 It depends on client requirement
 If it is large data use session method.
 Small amount of data use ctm.

47.) How will run bdc program in background?


Ans: RSBDCSUB (or) SM36

48.) What is the utility of BDC_CURSOR?


Ans: Move cursor location to a specific screen field where data need to be inserted.

49.) What is the difference between batch input and direct input?
Ans:
Batch Input Direct Input
1. Validations are done based on predefined 1. Validations are done by applications
Function Module
2. We cannot send the fields according to 2. Fields can be send (our requirement)
Our requirement

Ashok
SAP-ADV ABAP 207

50.) How do u write a program in session such that it will run the program without going to
SM35 and creates a session?
Ans: SUBMIT RSBDCSUB VIA SELECTION-SCREEN AND RETURN.

51.) How will u handle Table Control in bdc?


Ans:

52.) What are the types of batch input?


Ans:
1. Classical batch input
2. Call transaction
3. Call dialog

53.) How u can execute a function code in bdc session?


Ans:
Bdcdata-fnam = ‘bdc_okcode’.
Bdcdata-fval = ‘=upda’.

54.) How we can position a cursor on a particular field?


Ans:
Bdcdata-fnam = ‘bdc_cursor’.
Bdcdata-fval = ‘fieldname’.

55.) What are dialog users and background users?


Ans:
 Dialog users are normal interactive users in sap system.
 Background users are user master records that are specially defined for providing
authorizations for background processing jobs.

56.) What are update modes in call transaction?


Ans:
1. Synchronous (s)
2. Asynchronous (a)
3. Local (l)

57.) What does message parameter indicate?


Ans:
It indicates that all system messages issues during call transaction are written into internal table
created based on <BDCMSGCOLL>

Ashok
SAP-ADV ABAP 208

58.) What is direct input?


Ans:
 To enhance batch input procedure, the system offers direct input technique especially for
transferring for large amount of data.
 It does not create sessions but stores data directly in database.
 The direct input programs are executed directly in background
 To maintain and start these programs use program RBMVSHOW (or) T code BMV0.

59.) What are the features of recording?


Ans: Generates a batch input program from recorded data.

60.) How do u set up batch input process?


Ans:
 Data analysis: analyze the data that is to be transferred to SAP system.
 Generate SAP structures: generate structures to incorporate for incorporation into data
export programs.
 Develop transfer programs: bdc program
 Create sequential file: export the data to be transferred to a sequential file.
 Create batch input program: read data to be transferred from the sequential file.
 Process batch input data: process data and add it to sap system(ctm and session method).
 Analyze errors: check all data is successfully processed.
 Analyze error session: correct and reprocess erroneous session.

61.) What is CTU_PARAMS?


Ans:
This is a structure defined in SE11 that must be used to declare the type of variable
After the options from keyword of call transaction….
DATA: WA_PARAMS TYPE CTU_PARAMS.
WA_PARAMS-DISMODE = ‘X’.
WA_PARAMS-UPDMODE = ‘X’.
CALL TRANSACTION ‘SM04’ USING IT_BDCDATA OPTIONS FROM WA_PARAMS.

62.) What are the commands available for controlling batch input session?
Ans:
1. /bbeg------- restart transaction
2. /bbdel------ delete transaction from from batch input session
3. /n ----------- terminate current transaction
4. /bda--------- foreground processing
5. /bde--------- display mode to error mode
6. /bend------- end current batch input session

Ashok
SAP-ADV ABAP 209

63.)Diff b/w session and call transaction method.


Session method
1.)Using call transaction syntax
2.)Only one transaction is called.
3.)The abap program must do the error handling itself
(call transaction return error messages into internal table)
4.)By default standard size is not used.
5.)Update mode can be chosen.(syn,asyn)
6.)U may use racommit of ctu_params
To not stop the bdc at the end of commit_work
7.)Sy-binpt is always set to space using nobinpt
Of ctu_params
8.)As sy-binpt is reset to ‘x’ after commit work it
Can be set to ‘x’ again by using nobiend of ctu_params
Option cattmode of ctu_params can be used.
9.)All display modes can be used including p and s.
10.)Recording(shdb).
Session method:
1.)It is saved to database using function modules
Bdc_open_group,bdc_insert,bdc_close_group and
Later run by sm35 or programs rsbdcsub,rsbdcbtc.
It does not run ctu but bdc_start_group.
2.)Several transaction can be processed with one session.
3.)There is built in error and recovery mechanism in sm35
To view error records and run the erroneous records again
(note:bdc data cannot be corrected)
4.)By default standard size is used(22 lines * 84 columes)
5.)Update mode is always synchronous.
6.)Transaction execution always stops at commit_work.
7.)Sy-binpt value is always ‘x’.
8.)Always stops after commit_work.
9.)Always display modes can be used except p & s.
10.)Extended log,expert mode,cancel if log occurs.

63.) How do I record a batch input session for later playback?


Ans: SHDB(recording)

64.) Why SHDB doesn’t record some screens?


Ans: There was probably a commit work. By default recording stops after commit_work

Ashok
SAP-ADV ABAP 210

65.) How will copy a recording?


Ans:
 Display the recording
 There is a button to export to a file on ur presentation server.
 Create a recording without T code and without starting the recorder,
 A but to input is displayed

66.) How does recording work?


Ans:
 It works similarly as ctm,
 It is surrounded by kernel SET_TRANS_VAR for activating and deactivating recording
using function module BDC_RECORD_TRANSACTION.
 SHDB records the bdc data into APQI and APQD tables.
 Lsmw uses same technique but records bdc data into tables SAPDMC (or) LSGBDC*
tables.

Ashok
SAP-ADV ABAP 211

BDC FAQS:
1Q: What should be the approach for writing a BDC program?
Ans:
 Analysis the Data
 Generate SAP structure
 Develop transfer program
 Create sequential file
 Create batch input program
 Process batch input data

2Q: What is the alternative to batch input session?


Ans: Call transaction & Call Dialog

3Q: What are the steps in a BDC session ?


Ans:
 The first step in a BDC session is to identify the screens of the transaction that the
program will process.
 Next step is to write a program to build the BDC table that will be used to submit the data
to SAP.
 The final step is to submit the BDC table to the system in the batch mode or as a single
transaction by the CALL TRANSACTION command.

4Q: What are the problems in processing batch input sessions? How is batch input process
different from processing on line?
Ans: Sessions cannot be run in parallel and not fast.

5Q: What do you do when the system crashes in the middle of a BDC batch session?
Ans:
 Check no. of records already updated and
 Delete them from input file and
 Run BDC again.

6Q: What do you do with errors in BDC batch session?


Ans: Analysis and correct input file format and entries in internal table BDCDATA.

7Q: What are the commands that allow you to process sequential file? What is their syntax?
Ans :-
1. READ DATASET (reading) and
2. TRANSFER (writing)
Syntax:

Ashok
SAP-ADV ABAP 212

OPEN DATASET for < appending=" " output=" "> in mode at POSITION
MESSAGE.
READ DATASET INTO.
CLOSE DATASET.
DELETE DATASET.
TRANSFER to

8Q: What is the process for transferring data from legacy system to SAP?
Ans:
 FTP file transfer,
 Manufacturer –specific field transfer NFS (network file system) (or) BDC.

9Q: How many types of tables exists and what are they in data dictionary?
Ans:

10Q: What is the step-by-step process to create a table in data dictionary?


Ans:
 Create Domain.
 Create Data Element.
 Create Actual Table.

11Q: Can a transparent table exist in data dictionary but not in the data base physically?
Ans: NO

12Q: What are the domains and data elements?


Ans:

13Q: Can you create a table with fields not referring to data elements?
Ans: NO.

14Q: What is the advantage of structures? How do you use them in the ABAP programs?
Ans:

15Q: What does an extract statement do in the ABAP program?


Ans:
 An extract dataset consists of a sequence of records.
 These records may have different structures.
 All records with the same structure form a record type.
 You must define each record type of an extract dataset as a field group, using the FIELD-
GROUPS statement.

Ashok
SAP-ADV ABAP 213

 When the first EXTRACT statement occurs in a program, the system creates the extract
dataset and adds the first extract record to it.
 In each subsequent EXTRACT statement, the new extract record is added to the dataset.

16Q: What is a collect statement? How is it different from append?


Ans:
COLLECT:
 When the line is inserted, the system checks whether there is already a table entry that
matches the key.
 If there is no corresponding entry already in the table, the COLLECT statement has the
same effect as inserting the new line.
 If an entry with the same key already exists, the COLLECT statement does not append a
new line, but adds the contents of the numeric fields in the work area to the contents of
the numeric fields in the existing entry.

17Q: What is Open SQL v/s Native SQL?


Ans:
 Open SQL allows you to access database tables declared in the ABAP Dictionary
regardless of the database platform that your R/3 System is using.
 Native SQL allows you to use database-specific SQL statements in an ABAP program.
 This means that you can use database tables that are not administered by the ABAP
Dictionary, and therefore integrate data that is not part of the R/3 System.

18 (a). What does an EXEC SQL stmt do in ABAP?


Ans:
To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow
it with the ENDEXEC statement as follows:

EXEC SQL.

ENDEXEC.

18(b). What is the disadvantage of using EXEC SQL stmt do in ABAP?


Ans:
Using inverted commas (") or an asterisk (*) at the beginning of a line in a native SQL
statement does not introduce a comment as it would in normal ABAP syntax

19Q: What is the meaning of ABAP editor integrated with ABAP data dictionary?
Ans: Area menu

Ashok
SAP-ADV ABAP 214

20Q: What is an interactive report? What is the obvious differences of such report compared
with classical type reports?
Ans:
 Interactive reporting allows the user to participate in retrieving and presenting data at
each level during the session.
 Gives a basic list form, which the user can call detailed information by positioning the
cursor and entering the commands
 Classical reports consists of one program the creates a single list which contains
clustered data requested, regardless of the details the user wants to see.

21Q: What is a drill down report?


Ans: A drilldown report is a report used for the interactive evaluation of data. (Interactive
reports)

22Q: How do you write a function module in SAP? Describe?.


Ans:
 Create function group.
 Create function module program in se37.
 Specify the parameters for passing data to and from the module and the exceptions.
 Write source code.
 Write executable program calling the functional program.

23Q: What are the exceptions in function module?


Ans:
 Exceptions are used to handle errors.
 The Function module checks for any type of error & raise exception & returns SY-
SUBRC to the calling program.
 Main program checks for SY-SUBRC for any errors and then takes action accordingly.

24Q: What is a function group?


Ans:
Function Modules that operate with same data can be grouped in one known as function group.

25Q: How are the date and time field values stored in SAP?
Ans: SY-DATUM & SY-UZEIT

26Q: What are the fields in a BDCTab Table?


Ans:
1. PROGRAM
2. DYNPRO
3. DYNBEGIN
Ashok
SAP-ADV ABAP 215

4. FNAM
5. FVAL

27Q: Name few data dictionary objects?


Ans:

28Q: Why batch input?


Ans :- To input a large amount of information at off peak times.

29Q: Can data be put directly into the database?


Ans:- No, only after the data has been entered via transaction.

30Q: Explain at high level, the batch input process?


Ans :-
 Batch data is placed into queues called batch input sessions
 Then placed into the application programs for maintenance into the database

31Q: What are the function modules associated with batch input?
Ans :-
1. BDC_OPEN_GROUP ,
2. BDC_CLOSE_GROUP ,
3. BDC_INSERT

32Q: What is the structure of the BDC table?


Ans :-
Program / Dynpro / Start / Field Name / Field Content

33Q: Write out a coding example for filling a BDC Table?


Ans :-
FORM
REFEESH
CLEAR
MOVE to -PROGRAM
TO -DYNPRO
‘X’ TO -DYNBEGIN
APPEND
CLEAR
MOVE: TO -FNAM
TO -FVAL
APPEND

Ashok
SAP-ADV ABAP 216

34Q: How do you find the transaction number, program number and field names?
Ans :-
 Transaction no., Program no –
 System -> status
 Field names - F1,
 Technical help

35Q: What are the processing modes for Batch Input?


Ans :-
1. Process on screen (foreground) ,
2. Display errors only and
3. Process in the background

36Q: What are the available OK Codes that can be utilized during batch input processing?
Ans :-
/n –-------- terminates current batch input transaction and marks as incorrect.
/bdel –---- delete current batch input transaction from session.
/bend –----- terminate batch input processing and mark session as incorrect.
/bda –------ change display mode to process the session on screen instead of displaying only
errors.
/bde –------ change display mode to display only errors instead of processing the session on the
screen.

37Q: What is the effect of the BDC_CURSOR field name in the BDC table?
Ans :-
You can set the cursor and enter as a corresponding field value the name of the field on which
the cursor is to be positioned

38Q: How many types of BDCs you have done?


Ans:

39Q: Why you choose Call transaction and/or session method?


Ans:
 Call transaction is mainly used when you want to update the database using a single
transaction
 You can also update the database in asynchronous mode,
 Whereas session is used to perform huge database updations using more than one
transaction and which will last for a long time.

40Q: What are different types of Update modes?


Ans: In BDC’s we have two types of updation modes – 1) Synchronous 2) Asynchronous

Ashok
SAP-ADV ABAP 217

41Q: What is main difference between session method and LSMW?


Ans:
 In the context of session method, the method of updating is “Batch Input” , we require a
program to be coded,
 But in the context of LSMW method, The methods of updating using “Batch
Input/Direction Input” from an IDOC, from a BAPI structure.
 No source code is required the complete operation is performed in 16 steps sequence

42Q: What is main difference between CATT and LSMW?


Ans:
 Using LSMW you can update any kind of data but no changes to database are allowed,
 Whereas CATT tool can update only master data, which also allows changes to the
master data and also a significant testing of data is possible

43Q: Give real time work done by u in BDC ? Transactions used ? parameters passed with
functions?
Ans:

44Q: Will ask u for screen no's and dynpro names for BDC that u say u have done?
Ans:

45Q: Which technical field in the BDCDATA table holds the last cursor position?
Ans:

46Q: How do you read a LOCAL sequential file?


Ans:

47Q: How do you write a sequential file?


Ans:

48Q: How do you send the BDCDATA table in a Call Transaction statement?
Ans:

49Q: What loop do you code for a READ DATASET statement?


Ans:

Ashok
SAP-ADV ABAP 218

50Q: What are the steps in a BDC session ?


Ans:
 The first step in a BDC session is to identify the screens of the transaction that the
program will process.
 Next step is to write a program to build the BDC table that will be used to submit the data
to SAP.
 The final step is to submit the BDC table to the system in the batch mode or as a single
transaction by the CALL TRANSACTION command.

Ashok
SAP-ADV ABAP 219

SCRIPTS & SMART FORMS:


Ques-1:
Why we should call SSF_FUNCTION_MODULE_NAME instead of hardcoding the function
module name itself?
Answer:
 We know that in real time we have to transport the objects from one client to another
client
 If the form is in Quality Server the system may assign a different version of function
module name to respective form & the same happen in Production Server also
 So therefore it always advaisable to call SSF_FUNCTION_MODULE_NAME which
returns the function module currently which system you are working

Ques-2:
What are the common errors you are facing while working with smart forms?
Answer:
9. Incorrect parameter with call function
This exception you will get if you not pass all the parameters which you maintained in smart
form

10.Type conflict when calling a function module


This exception you will find when data type of smart form parameters will not match with
attributes of print program

11.Reference field …………unknown in form


This error you will find if you are not maintaining Currency / Quantity fields in smart form

12.*** sometimes your print program will not be executed at all


This will happen when your Window (specially Templates) are not maintained properly

13.Template doesnot fit into window


This will happen when template height is more than window height

14.Form generation error


This error you will find if form is having internal errors in Production Server thow it is perfectly
tested in Development Server

15.*** Table is wider than window


This error you will find if your Table (or) Template is wider than your window based on which
is created
16.Graphic cannot be displayed
Ashok
SAP-ADV ABAP 220

This error you will find if graphic is not maintained properly

Ques-3:
How do you work with Alternate option in smart form?
Answer:
 Righ click on any one Window (say LOGO)
 Create ----- Window Alternate
 Right click on Alternate Window
 Create ----- Flow Logic ------- Alternate
 Conditions option
Field name Relational Operator
LIFNR double click

 Select =/= (NE) option


Comparision Values
‘ ’
 Right click on True option
 Create ------ Text
 Editor
 PO Created

 Right click on Flase option


 Create ----- Text
 Editor
 PO not created

 Form Painter
 Adjust Alternate window
 Activate form

Ques-4:
How you can work with more than one Page in smart form?
Answer:
 Right click on PAGE1
 Create ------ Page
 Right click on PAGE2
 Create ---- Window
 Window: LETTER
 Meaning: Window for letter description
 Save
 Right click on LETTER window
 Create ----- Text
Ashok
SAP-ADV ABAP 221

 Editor
 Goto ------ Change Editor
* ,,,,,,,,,,Dear Satya,
* ,,,,,,,,,,Yor are shortlisted in Google as a Technical Consultant
* ,,,,,,,,,,Thanking you,

 Back
 Double click on MAIN window
 Window Type: Secondary Window
 Double click on PAGE1
 Next Page: PAGE2
 Double click on PAGE2
 Next Page:______
 Activate form

*** Ques-5:
How you can convert a smart form into PDF format?
Answer:
 Run your print program
 Provide input
 Execute
 Select Print option (Ctrl + P)
 At bottom you will find a print request number note down it (say 11716)
 Go to SE38
 Program: RSTXPDFT4
 Execute
 Spool Request: 11716
 Execute
 Save

Ques-6:
How you can debug a smart form?
Answer:
 Go to SMARTFORMS
 Form: ZPO_FORM
 Change
 Expand VENDOR window
 Double click on CODE1
 Provide BREAK-POINT
 Activate form
 Go to SE38
 Program: ZMM_CALL_SMART_FORM (print program)
Ashok
SAP-ADV ABAP 222

 Execute

Note:
In smart forms you can set only Static Break Point. You cannot set Dynamic Break Point

Ques-7:
How you can work with Excel Sheet in smart forms?
Answer:
DATA fnam TYPE STRING.

CALL FUNCTION ‘GUI_DOWNLOAD’

Ques-8:
How you can print multiple records in smart forms?
Answer:
ZMM_CALL_SMART_FORMN

TABLES: EKPO, EKKO, LFA1, ADRC.

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.


SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
SELECTION-SCREEN: END OF BLOCK b1.

DATA: fname TYPE RS38L_FNAM,


control TYPE SSFCTRLOP.

DATA: BEGIN OF wa_ekko,


ebeln TYPE ebeln,
bedat TYPE bedat,
lifnr TYPE lifnr,
END OF wa_ekko.

DATA: wa_ekpo TYPE zpo_strucc,


it_ekpo TYPE TABLE OF zpo_strucc.

DATA: fnam TYPE STRING.


CONTROL-NO_OPEN = ‘X’.
CONTROL-PREVIEW = ‘X’.
CONTROL-NO_DIALOG = ‘X’.
CONTROL-NO_CLOSE = ‘X’.

START-OF-SELECTION.
Ashok
SAP-ADV ABAP 223

CALL FUNCTION ‘SSF_OPEN’


EXPORTING
USER_SETTINGS = ‘X’.
CONTROL_PARAMETERS = control.

CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME’


EXPORTING
FORMNAME = ‘ZPO_FORM’
IMPORTING
FM_NAME = FNAME.

LOOP AT S_EBELN.
PERFORM get_data USING s_ebeln-low.

CALL FUNCTION FNAME


EXPORTING
CONTROL_PARAMETERS = control
EBELN = s_ebeln-low
BEDAT = wa_ekko-bedat
LIFNR = wa_ekko-lifnr
TABLES
IT_EKPO = it_ekpo.
ENDLOOP.

CALL FUNCTION ‘SSF_CLOSE’.

FORM get_data USING ORDER.


SELECT SINGLE ebeln bedat lifnr FROM EKKO INTO wa_ekko
WHERE ebeln EQ ORDER.

IF NOT wa_ekko IS INITIAL.


SELECT ebelp txz01 menge netpr netwr FROM EKPO INTO TABLE it_ekpo
WHERE ebeln = wa_ekko-ebeln.
ENDIF.
ENDLOOP.

Ashok
SAP-ADV ABAP 224

Ques-9:
How you can migrate SAP Script to smart form?
Answer:
 Go to SMARTFORMS
 Utilities ---- Migration ----- Import SAP Script Form
 Form: ZPO_MEDD
 Name: ZPO_MEDD
 Enter

Ques-10:
How you can generate smart form into PDF format during runtime of print program?
Answer:

Ques-11:
How you can send of a form in the form of mail?
Answer:

Ques-12:
How you can write code in smart forms?
Answer:

Ques-13:
How you can maintain Page Breaks in smart forms?
Answer:

1. ) How to Force a page break within table loop ?


Ans:
 Create a loop around the table.
 Put a Command node before the table in the loop that forces a NEWPAGE on whatever
condition you want.
 Then only loop through a subset of the internal table (based on the conditions in the
Command node) of the elements in the Table node.

2.) Difference between 'form interface' and 'global definitions' in global settings of smart
forms?
Ans:
 Form Interface is where you declare what must be passed in and out of the smart form (in
from the print program to the smart form and out from the smart form to the print
program).
 Global definition is where you declare data to be used within the smart form on a global
scope.
Ashok
SAP-ADV ABAP 225

 ie: anything you declare here can be used in any other node in the form.

3.) How u can convert Smart Forms Output to PDF?


Ans:
There is a way to download smart form in PDF format.
Please do the following:
1. Print the smart form to the spool.
2. Note the spool number.
3. Download a PDF file (Acrobat Reader) version of the spool by running Program
RSTXPDFT4 and entering the noted spool number.

4.) How u print a Smart Form Double sided (Duplex printing)?


Ans:
 Your customer wants your PO Smart Form to be able to print "Terms and Conditions" on
the backside of each page.
 They do not want to purchase pre-printed forms with the company's logo on the front and
terms & conditions on the back.
 Easy - page FRONT lists page CONTACTS as next page and CONTACTS lists FRONT
as next page.
 Since CONTACTS does not contain a MAIN window, it will print the contacts info and
then continue on to FRONT for the rest of the main items.
 Additionally, set print mode on FRONT to D (duplex) and set CONTACTS to 'blank' (for
both resource name and print mode - this is the only way to get to the back of the page).

5.) How u can transport SMARTFORM? SE01?


Ans:

6.) How do you make sure that both, the SMARTFORM & it's function module gets
transported? (or) Does the FM with same name gets generated automatically in the transported
client?
Ans:
 A smart form is transported no differently than any other object.
 If it is assigned to a development class that is attached to a transport layer, it will be
transported.
 The definition is transported, and when called, the function module is regenerated.
 This leads to an interesting situation.
 On the new machine, it is very likely the function module name will be different than the
name on the source system.
 Make sure, before you call the function module, you resolve the external name to the
internal name using the 'SSF_FUNCTION_MODULE_NAME' function module.
 Typically, generate the SF, then use the pattern to being in the interface.
Ashok
SAP-ADV ABAP 226

 Then change the call function to use the name you get back from the above function
module.

7.)How to protect lines in the main window from splitting between pages?
Ans:
It was easy with SAP script, but how to do it with SFs
For 4.7 version if you are using tables there are two options for protection against line break
1. You can protect a line type against page break.
2. You can protect several table lines against page break for output in the main area.

Protection against page break for line types


 Double-click on your table node and choose the Table tab page.
 Switch to the detail view by choosing the Details pushbutton.
 Set the Protection against page break checkbox in the table for the relevant line type.
 Table lines that use this line type are output on one page.

Protection against page break for several table lines:


 Expand the main area of your table node in the navigation tree.
 Insert a file node for the table lines to be protected in the main area.
 If you have already created table lines in the main area, you can put the lines that you
want to protect again page break under the file using Drag &Drop.
 Otherwise, create the table lines as sub nodes of the file.
 Choose the Output Options tab page of the file node and set the Page Protection option.
 All table lines that are in the file with the Page Protection option set are output on one
page.
 In 4.6, Alternatively in a paragraph format use the Page protection attribute to determine
whether or not to display a paragraph completely on one page.
 Mark it if you want to avoid that a paragraph is split up by a page break.
 If on the current page (only in the main window) there is not enough space left for the
paragraph, the entire paragraph appears on the next page.

8.) What are the differences between SAP Scripts and Smart forms?
Ans:
 SAP Scripts are client dependent whereas Smart forms are client independent.
 SAP Scripts require a driver program to display the output whereas in smart forms the
form routines can be written so that it is standalone.
 An integrated Form Builder helps to design Smart forms more easily than SAP Scripts
 A Table Painter and Smart styles to assist in building up the smart forms
 On activation a function module is generated for Smart forms

Ashok
SAP-ADV ABAP 227

9.) Is multiple page formats possible in smart forms?


Ans: Multiple page formats is possible in smart forms

10.) How can I insert symbols in Smart forms?


Ans:
 Select the Text node.
 Change Editor (Click the button above Check near the Editor)
 Go to menu Include->Characters->SAP Symbols
 Choose the SAP symbol that you want to insert.

11.) I have a smart form which works fine in DEV. After transporting it to PROD, there is no
Function module generated for this smart form. As a result my program dumps in PROD?
Ans:
 The Smart form that is created in the Development may not have the same name in the
Production server.
 So it is always advised to use the Function Module
SSF_FUNCTION_MODULE_NAME

12.) How u write Function Module name by passing the Smart form name?
Ans:

13.) How can I make the Smart forms to choose a printer name by default?
Ans:

14.) How can I display the total number of pages in Smartforms?


Ans:
SFSY-FORMPAGES -----------to display the total number of pages in the Smart forms
SFSY-PAGE--------------------- Current page number
SFSY-FORMPAGE------------ Total number of pages in the currently formatted layout set
SFSY-JOBPAGE---------------Total number of pages in the currently formatted print request
SFSY-COPYCOUNT---------Original-1,1st copy-2
SFSY-DATE------------ Date
SFSY-TIME------------ Time
SFSY-USERNAME--- Username

15.) What are the various text formatting options in Smartforms?


Ans:
&symbol(Z)&----------- Omit Leading Zeros
&symbol(S)&----------- Omit Leading Sign
&symbol(<)&----------- Display Leading Sign to the Left
&symbol(>)& -----------Display Leading Sign to the Right

Ashok
SAP-ADV ABAP 228

&symbol(C)& ----------Compress Spaces


&symbol(.N)& ---------Display up to N decimal places
&symbol(T)& ----------Omit thousands separator
&symbol(R)& ----------Right justified
&symbol(I)& -----------Suppress output of the initial value

16.) Where can I provide the input parameters to the smart form?
Ans:
 The input parameters for the smart form can be defined in Global Settings->Form
Interface.
 The Associated Type must be defined in the ABAP Dictionary.

17.) Where can I define my own global types for the smart form?
Ans:
 The global types (within the smart form) can be defined in
 Global Settings->Global Definitions->Types
 The types defined here will be global through the entire smart form.
 Also the form routines can be defined Global Settings->Global Definitions->Form
Routines

18.)I have defined my own Program Lines, where I have used a global variable G_TEXT. I get
an error G_TEXT is not defined?
Ans:
 Whenever using the global variables in the Program Lines, enter the variable name in
Input Parameters if you are going to use (read) the variable.
 If you are going to both read/write the variable value enter the same in Output
Parameters.

19.) I have created a table node for display. Where can I check the condition which must satisfy
to display the table?
Ans:
 The conditions can be defined in the Conditions tab.
 In smart forms all the nodes have a condition tab where you can specify the condition to
be satisfied to access the node.
20.) How can I define Page Protect in Smart forms?
Ans:
To define Page Protect for a node go to the Output options and check the Page Protection
checkbox.

Ashok
SAP-ADV ABAP 229

21.) What is the difference between Template and Table in Smart forms?
Ans:
 The Template contains a fixed number of rows and columns, where the output is fixed.
 The Table can have variable number of rows

22.) Where can I define the paragraph and character format for the smart forms?
Ans:
The paragraph and character format for the smart forms can be defined in the transaction
SMARTSTYLES

22.) How will add watermark to smart form output?


Ans:
 Go to the properties of 'PAGE',
 Tab 'Background Picture'
 Add the graphic image name here

23.) How to add buttons and radio buttons etc in smart forms?
Ans:
 Buttons is not possible in smart forms (only in adobe forms it is possible).
 But you can insert checkboxes and radio buttons in smart forms.
 You can print a check box in different ways..
 By inserting symbols and making window as check box..
 Once go through the thread u will get to k now different ways

24.) How u can keep checkboxes in smart form?


Ans:
To use Check box in smart form do the following:
 Change the editor to 'PC Editor' and take the menu.
 In text editor of TEXT ELEMENTS..
 Insert -> Characters -> SAP Symbols
 In print preview u can't see these changes..

25.) How u can debug smart forms?


Ans:
By keeping a static breakpoint in program lines (BREAK <USERNAME>.

26.) How can I provide a background shading to the table?


Ans:
In the Table Painter, you can specify the color and shading for the table lines.

Ashok
SAP-ADV ABAP 230

Faqs in Smartforms:
1.) What is the difference b/w Scripts and Smartforms?
2.) What is the diff b/w Table and a Template? In which requirements do u prefer table and in
which cases u prefer template?
3.) How u can debug smartforms?
4.) How u can migrate scripts into smartforms?
5.) How u can convert scripts or smartforms into pdf format?
6.) How u can print signature in last page in smartforms?
7.) How u can apply control break functionality in smartforms?
8.) What is the functionality of :
a.)Loop
b.)Alternate
c.)Command
d.)Graphic
e.)Program lines
in smartforms. Given explanation with a real time example?

9.) Is main window is mandatory in smartforms?


10.) Is print program is mandatory in smartforms?
11.) How u can write a program in form in smartforms?(using program lines).
12.) How u can acheive page break in smartforms?
13.) What is page protection in smartforms?
14.) How is pre printed stationary done in smartforms?
15.) Is it possible to create a table in a normal window?Yes.
16.) Assume I hard coded a runtime function module in print program? If i am quality client
for tesing I am getting dump? Why?
17.) How u can print multiple records say invoices and employee numbers with one time print
program execution?
18.) What is the functionality of
a.)SSF_FUNCTION_MODULE_NAME
b.)SSF_OPEN
c.)SSF_CLOSE
19.) I am getting an error Table is wider than window? How will u rectify it?
20.) How u can run a form without getting print dialog?
21.) I want 3 page to be printed out of 5 pages? How will u achieve it?
22.) What are the eve

Ashok
SAP-ADV ABAP 231

Ques-1: What are the different ways of idntifing Customerexits (Functionexits)?


Answer:
 Go to SE93
 Transaction Code: XK01
 Display
 Double click on Program name
 Find option
 Find: CALL CUSTOMER_FUNCTION
 Enter
 Double click on 001

Ques-2: What is the difference between Implicit & Explicit Enhancement?


Answer:
 Under implicit enhancement you can write your own code
 Adding Z-enhancement in already existing one is called Explicit enhancement

Example:
 Go to SE93
 Transaction Code: VA01
 Display
 Double click on Program Name
 You will find a spot given by SAP
 Enhance
 Right click ES_SAPMV45A
 Enhancement Implementation ----Create Implementation

Ques-3: What is the difference between Enhancement spot (point) & Enhancement section?
Answer:
 In enhancement spot both customized & standard code will be executed
 In enhancement section only customized code will be executed

Ques-4: What is Transaction Variant in enhancements?


Answer:
 Using transaction variant you can provide enhancements
 You can make fields as Required, Output only, Invisible mode……etc using SHDO
(Transaction Variant)
 With above concept you have to create a Z-T code & the same you should provide it to
end user (standard applications should not be effected)

Ashok
SAP-ADV ABAP 232

***Question-5: How you can change the status of an IDOC?


Answer:
Using standard program RBDAPP01

Ashok

You might also like