BDC
BDC
Outbound:
SAP
SAP
(source system) Non-SAP
Inbound:
SAP
SAP (target system)
Non-SAP
Note:
BDC is an Inbound data transfer technique
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
Mapping Logic:
BDC Data (structure)
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)
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
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
Screens
LUW
Database Tables
Processing:
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
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: BM NAGAR
Enter
Bank Name: state bank on VASHI
Street: BM NAGAR
City: VASHI
Bank Branch: VASHI 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
Transfer from 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
……………………….
Step-3:
Write your program from begging of given program
* mapping objects
DATA: wa_bdcdata TYPE BDCDATA,
it_bdcdata TYPE BDCDATA.
* 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.
FORM open_file.
ENDFORM.
FORM upload.
fnam = p_file.
ENDFORM.
FORM open_session.
** FORM process_data.
LOOP AT it_fi01 INTO wa_fi01.
REFRESH 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’.
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 with Note pad
IN SBI009 STATEBANKOFINDIA LBSROAD
MUMBAI
IN SBH008 STATEBANKOFHYD MINABAIROAD
MUMBAI
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:
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
Note:
In Call Transaction Method session function modules are not required
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
LUW
Database Tables
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.2019
Valid To: 31.12.2019
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
……………………….
From bottom remove last 2 lines
i.e. PERFORM BDC_TRANSACTION USING
………………….
Step-3:
Write your program from begging of given program
report ZVK11_PRICING_UPL
no standard page heading line-size 255.
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_vk11,
KSCHL TYPE konv-KSCHL,
VKORG TYPE vbak-VKORG,
VTWEG TYPE vbak-VTWEG,
MATNR TYPE vbap-MATNR,
KBETR TYPE konv-KBETR,
KONWA TYPE KONWa,
DATAB TYPE DATAB,
DATBI TYPE DATBI,
END OF ty_vk11.
DATA:wa_vk11 TYPE ty_vk11,
it_vk11 TYPE TABLE OF ty_vk11.
DATA:lv_date TYPE char8.
* mapping objects
DATA: wa_bdcdata TYPE BDCDATA,
it_bdcdata TYPE TABLE OF BDCDATA.
DATA: t_raw TYPE TRUXS_T_TEXT_DATA.
DATA:it_bdcmsgcoll TYPE TABLE OF BDCMSGCOLL,
wa_bdcmsgcoll TYPE BDCMSGCOLL.
* 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.
*&---------------------------------------------------------------------*
*& Form OPEN_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
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. " OPEN_FILE
*&---------------------------------------------------------------------*
*& Form UPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD .
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
I_TAB_RAW_DATA = t_raw
I_FILENAME = p_file
TABLES
I_TAB_CONVERTED_DATA = it_vk11
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " UPLOAD
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PROCESS_DATA .
LOOP AT it_vk11 INTO wa_vk11.
REFRESH :it_bdcdata.
perform bdc_dynpro using 'SAPMV13A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RV13A-KSCHL'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RV13A-KSCHL'
wa_vk11-KSCHL.
perform bdc_dynpro using 'SAPMV13A' '1004'.
perform bdc_field using 'BDC_CURSOR'
'RV13A-DATBI(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KOMG-VKORG'
wa_vk11-VKORG.
perform bdc_field using 'KOMG-VTWEG'
wa_vk11-VTWEG.
perform bdc_field using 'KOMG-MATNR(01)'
wa_vk11-MATNR.
perform bdc_field using 'KONP-KBETR(01)'
wa_vk11-KBETR.
perform bdc_field using 'KONP-KONWA(01)'
wa_vk11-KONWA.
CONCATENATE WA_VK11-DATBI+6(2) WA_VK11-DATBI+4(2) WA_VK11-DATBI+0(4) INTO l
v_date.
perform bdc_field using 'RV13A-DATAB(01)'
lv_date.
CLEAR:lv_date.
CONCATENATE WA_VK11-DATBI+6(2) WA_VK11-DATBI+4(2) WA_VK11-DATBI+0(4) INTO l
v_date.
perform bdc_field using 'RV13A-DATBI(01)'
* wa_vk11-DATBI.
lv_date.
CLEAR:lv_date.
perform bdc_dynpro using 'SAPMV13A' '1004'.
perform bdc_field using 'BDC_CURSOR'
'KONP-KONWA(01)'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
CALL TRANSACTION 'VK11' USING IT_BDCDATA
MODE 'A'
UPDATE 'A'
MESSAGES INTO it_bdcmsgcoll.
ENDLOOP.
ENDFORM. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0167 text
* -->P_0168 text
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING Program
screen.
wa_bdcdata-PROGRAM = program.
wa_bdcdata-DYNPRO = screen.
wa_bdcdata-DYNBEGIN = 'X'.
append wa_bdcdata to it_bdcdata.
CLEAR:wa_bdcdata.
ENDFORM. " BDC_DYNPRO
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0172 text
* -->P_0173 text
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAME
FVAL.
wa_bdcdata-FNAM = fname.
wa_bdcdata-FVAL = fval.
APPEND wa_bdcdata to it_bdcdata.
CLEAR:wa_bdcdata.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_DATA .
BREAK-POINT.
ENDFORM. " DISPLAY_DATA
Step-4:
Create a Flat File MS-XL
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:
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