0% found this document useful (0 votes)
46 views17 pages

BDC SheetalShama

The BDC process involves 3 main steps: 1. Recording a data entry transaction to automate it 2. Preparing external data for upload by converting it to SAP's format 3. Uploading the data using a batch input session, which processes the data in the background and updates the SAP database.

Uploaded by

Eugene
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views17 pages

BDC SheetalShama

The BDC process involves 3 main steps: 1. Recording a data entry transaction to automate it 2. Preparing external data for upload by converting it to SAP's format 3. Uploading the data using a batch input session, which processes the data in the background and updates the SAP database.

Uploaded by

Eugene
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Batch Data Communication (BDC)

Contributed by
Sheetal Sharma
Under the guidance of TagSkills.
SAP BDC stands for batch data communica
communication
tion and it is a automation of
existing transaction with legacy data code. Each transaction can create only
one record at a time. If you want to create the thousands of records, one way
is execute the same transaction thousands of time. Another way is develop a
BDC program to automate the existing transaction.
transact For example, company
decides to adapt its systems and procedures to SAP, and installs SAP, it will
have to upload a huge volume of data that are a part of its legacy systems or
old systems into the SAP system. This process is done through SAP BDC (Bat(Batch
Data Communication).

Batch input
Batch input is typically used to transfer data from non
non-R/3
R/3 systems to R/3
systems or to transfer data between R/3 systems.

It is a data transfer technique that allows you to transfer datasets


automatically to screens belonging
longing to transactions, and thus to an SAP system.
Batch input is controlled by a batch input session.

Batch input session

Groups a series of transaction calls together with input data and user actions.
A batch input session can be used to execute a dialog transaction in batch
input, where some or all the screens are processed by the session. Batch input
sessions are stored in the database as database tables and can be used within
a program as internal tables when accessing transactions.

Points to note

 BDI works by carrying out normal SAP transactions just as a user would
but it execute the transaction automatically. All the screen validations
and business logic validation will be done while using Batch Data Input.
 It is suitable for entering large amo
amount of data.
 No manual interaction is required

www.tagskills.com
 - We can perform the data base table operation either through DML
commands or through Transaction codes. DML commands are used
to update only one data base table at a time, whereas transaction code
is used to update their relevant data base tables at a time.

Methods of Batch Input


SAP provides two basic methods for transferring legacy data in to the R/3
System.

1. Session method.
2. Call Transaction Method.

Session Input method

In this method an ABAP/4 program reads the external data to the SAP System
and stores in a batch input session.

After creating the session, you can run the session to execute the SAP
transaction in it.

This method uses the function modules BDC_ OPEN, BDC_INSERT and
an
BDC_CLOSE

Batch Input Session can be process in 3 ways

1. In the foreground
2. In the background
3. During processing, with error display

You should process batch input sessions in the foreground or using the error
display if you want to test the data transfer.

If you want to execute the data transfer or test its performance, you should
process the sessions in the background.

Points to note about Session method

 Asynchronous
ynchronous processing
 Session method can process any number of transaction at a time.
time
 Synchronous database
abase update.

www.tagskills.com
 A batch input process log is generated for each session.
 Session cannot be generated in parallel.

You will typically observe the following sequence of steps to develop Batch
Input for your organization

1. Analysis of the legacy data. Determine h how


ow the data to be transferred is
to be mapped in to the SAP Structure. Also take note of necessary data
type or data length conversions.
2. Generate SAP data structures for using in export programs.
3. Export the data in to a sequential file. Note that character format is
required by predefined SAP batch input programs.
4. If the SAP supplied BDC programs are not used, code your own batch
input program. Choose an appropriate batch input method according to
the situation.
5. Process the data and add it to SAP SYSTEM.
6. Analyze the process log. For the CALL TRANSACTION method, where no
proper log is created, use the messages collected by your program.
7. From the results of the process analysis, correct and reprocess the
erroneous data.

The BDC process can be divided into three steps:

www.tagskills.com
Recording the Data Entry Transaction

The first step in creating a batch input session is to record the transaction
to be automated. This involves manually entering data into SAP and recording
the steps using transaction code SHDB. The system rrecords
ecords all keystrokes and
data entered throughout the transaction and generates an ABAP program that
may be used to automate it.

Preparing the Data for Upload

Once the transaction has been recorded, the data must be prepared for
upload. This includes conve
converting
rting the data to be uploaded into a format that
SAP can process. This can be accomplished using a data conversion tool or by
manually creating a file containing the data in a format that can be uploaded
using the batch input session.

Uploading the Data

Thee data is uploaded into SAP using the batch input session as the final step in
the BDC process. The batch input session is created using transaction code
SM35, which allows you to choose the ABAP program developed during the
recording process as well as th
the
e file holding the data to be uploaded. The data
is subsequently processed in the background through the system, which
updates the SAP database.

Writing BDC program


You may observe the following process to write your BDC program

1. Analyze the transaction(s) to process batch input data.


2. Decide on the batch input method to use.
3. Read data from a sequential file
4. Perform data conversion or error checking.
5. Storing the data in the batch input structure,BDCDATA.
6. Generate a batch input session for session method,or process the data
directly with CALL TRANSACTION USING statement.

Steps to upload data in SAP system using BDC —>

Step 1 – Do the recording and prepare the flat file and upload the data from
flat file to internal table.

www.tagskills.com
Step 2 - We need to record the session using tcode “SHDB” to get the
dummy BDC structure for FI01 screen.

Step 3 - After recording the session we need to write the BDC code to pass the
internal table data to the internal table of BDC structure according to the
recording.

Step 4 - Then data in the BDC internal table need to be updated in the
database table using any BDC method via FI01 screen.

Step 5- Create the session by using „BDC_OPEN_GROUP


„BDC_OPEN_GROUP‟‟ function module. The
input for the above function module is :
1. GROUP: Name of the session, which is used to process the session.
2. KEEP: Remaintain
maintain the session. After processing the session (Activate
(Activate= „X‟).
3. HOLDDATE :The session is locked, until it reaches the hold date.
4. USER: Valid user.
5. Loop at < Data internal table>.

Call the transaction by using’’BDC_INSERT


using’’BDC_INSERT‟ function module.
The input for the above function module is :
(1). <TCODE>
(2). <BDC DATA INTERNAL TABLE>

6. Close the session by using „BDC_CLOSE_GROUP


„BDC_CLOSE_GROUP‟‟ function module

Session method — >


There are 3 Function Modules for bulk update of the data -
1. BDC_OPEN_GROUP
2. BDC_INSERT
3. BDC_CLOSE_GROUP
Coding screen:
report ZBDC_TASK
no standard page heading line-size 255.

PARAMETERS: P_FILE TYPE LOCALFILE.

TYPES: BEGIN OF TY_T,


MATNR TYPE MARA-MATNR,
MBRSH TYPE MARA-MBRSH,
MTART TYPE MARA-MTART,
MAKTX TYPE MAKTX,
MEINS TYPE MARA-MEINS,
END OF TY_T.

www.tagskills.com
DATA: LT_DATA TYPE TABLE OF TY_T,
WA_D TYPE TY_T.
DATA: lt_BDCDATA type table of BDCDATA ,
wa_BDCDATA type bdcdata.
DATA: LT_MESSTAB TYPE TABLE OF BDCMSGCOLL ,
WA_MESSTAB TYPE BDCMSGCOLL.
DATA: V_FILE TYPE STRING ,
LV_MESSAGE TYPE STRING.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'F4_FILENAME'


EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME =''
IMPORTING
FILE_NAME = P_FILE.
START-OF-SELECTION.
V_FILE = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'


EXPORTING
FILENAME = V_FILE
* FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = LT_DATA
* CHANGING
* ISSCANPERFORMED =''
EXCEPTIONS
FILE_OPEN_ERROR =1
FILE_READ_ERROR =2
NO_BATCH =3
GUI_REFUSE_FILETRANSFER =4
INVALID_TYPE =5
NO_AUTHORITY =6
UNKNOWN_ERROR =7
BAD_DATA_FORMAT =8
HEADER_NOT_ALLOWED =9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION 'BDC_OPEN_GROUP'


EXPORTING
CLIENT = SY-MANDT
* DEST = FILLER8
GROUP = 'MM01_GRP'
* HOLDDATE = FILLER8
KEEP = 'X'
USER = SY-UNAME
EXCEPTIONS
CLIENT_INVALID =1
DESTINATION_INVALID =2
GROUP_INVALID =3
GROUP_IS_LOCKED =4

www.tagskills.com
HOLDDATE_INVALID =5
INTERNAL_ERROR =6
QUEUE_ERROR =7
RUNNING =8
SYSTEM_LOCK_ERROR =9
USER_INVALID = 10
OTHERS = 11
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

*perform open_group.
loop at lt_data into wa_d.
perform bdc_dynpro using 'SAPLMGMM' '0060' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-MATNR'
WA_D-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
WA_D-MBRSH.
perform bdc_field using 'RMMG1-MTART'
WA_D-MTART.
perform bdc_dynpro using 'SAPLMGMM' '0070' 0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
WA_D-MAKTX.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
WA_D-MEINS.

CALL FUNCTION 'BDC_INSERT'


EXPORTING
TCODE = 'MM01'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH =''
* CTUPARAMS =''
TABLES
DYNPROTAB = LT_BDCDATA
EXCEPTIONS
INTERNAL_ERROR =1
NOT_OPEN =2
QUEUE_ERROR =3
TCODE_INVALID =4
PRINTING_INVALID =5
POSTING_INVALID =6
OTHERS =7
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

REFRESH LT_BDCDATA.
ENDLOOP.

www.tagskills.com
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN =1
QUEUE_ERROR =2
OTHERS =3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

*----------------------------------------------------------------------
----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------
----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO..
CLEAR wa_BDCDATA.
wa_BDCDATA-PROGRAM = PROGRAM.
wa_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO LT_BDCDATA.
ENDFORM.

*----------------------------------------------------------------------
----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------
----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.

CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO LT_BDCDATA.

ENDFORM.

After executing the program will run in session. To access session screen we
have to go to transaction code “SM35”.

On SM35 screen select the session and then click on process. After clicking on
process a new window will appear having multiple options.
Process/foreground meansns we have do the task manually.

www.tagskills.com
Display only error means only the error in the execution will be shown
Background means it will be done automatically in the background.

After clicking on the process radio button on the new window the data will get
uploaded
oaded to the data base table. This green tick will tell that the execution is
successful without any error.

www.tagskills.com
www.tagskills.com
Call Transaction

Call Transaction is an SAP technique for automating the process of running


transaction codes in SAP systems. Call Transaction can help you automate data
entry tasks and reduce manual errors. The call transaction process begins with
the development of an ABAP program that calls the transaction code, which is
then performed in the foreground.

The Call Transaction processs can be divided into three steps:

Creating the ABAP Program

The first step in using Call Transaction is to create an ABAP program that calls
the transaction code. Transaction codes SE38 or SE80 can be used to generate
this program. The program contains th the
e transaction code as well as additional
logic to validate the data being entered or conduct other tasks.

Preparing the Data for Entry

After the ABAP program has been created, the data must be prepared for
entry. This involves converting the data to be ent
entered
ered into a format that SAP
can process. This can be done with the help of a data conversion tool or by
manually creating a file containing the data in a format that can be uploaded
using the ABAP program.

Executing the Transaction Code:


Code

The Call Transaction procedure continues with the execution of the ABAP
program, which calls the transaction code and enters the data into SAP. The
program can be run using transaction codes SE38 or SE80, and depending on
the outcomes of the transaction code execut
execution,
ion, it may prompt the user for
further input or show messages.

www.tagskills.com
Points to Note:

 Faster processing of data


 Asynchronous processing
 Transfer data for a single transaction.
 No batch input processing log is generated.
 Call transaction method — >
 Syntax —
CALL TRANSACTION <‘TCODE’> USING <BDCDATADATA INTERNAL TABLE>
MODE_’A’/’N’/’E’ messages into <BDCMSGCOLL internal table> update
‘A/S’.

After execution you will see records passing one by one.

Data after successfully passed in database table

Modes in Call Transaction — —>


There are 3 types of Modes -
1. A - All screens - it is the default mode, we have to pass data one by one.
2. N - No screen - in this mode data is passed in the background.
3. E - Error Screen - it is used to show if there is any error in the execution.

UPLOAD: - Upload is the function module which is used to browse the file as
well as upload the data from file to internal table. The input for the above
function module is
1. File type

www.tagskills.com
2. Data internal table which is similar as file

Update in Call Transaction —>



There are 2 types of Update
1. A - Asynchronous - in this the processing of next job will not wait for the
completion of the previous job.
2. S - Synchronous - in this the processing of next job will wait for the
completion of previous job.

In Update we will not get any message if the code execution is done
successfully or not. So we use a predefined structure BDCMSGCOLL and a
predefined function module FORMAT_MESSAGE in order to select required
message.

Coding Screen —
REPORT ZBDCTASK1.

PARAMETERS: P_FILE LIKE IBIPPARMS-PATH.


DATA: V_FILE TYPE STRING.
TYPES: BEGIN OF TY_LIFNR,
LIFNR TYPE LFA1-LIFNR,
KTOKK TYPE LFA1-KTOKK,
MCOD1 TYPE LFA1-MCOD1,
SORTL TYPE LFA1-SORTL,
LAND1 TYPE LFA1-LAND1,
END OF TY_LIFNR.

DATA: LT_LIFNR TYPE TABLE OF TY_LIFNR,


WA_LIFNR TYPE TY_LIFNR.

DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.


DATA: CTUMODE LIKE CTU_PARAMS-DISMODE
DISMODE VALUE 'A',
NODATA VALUE '/'.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


CALL FUNCTION 'F4_FILENAME'
* EXPORTING
* PROGRAM_NAME = SYST-CPROG
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME =''
IMPORTING
FILE_NAME = P_FILE
.

V_FILE = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'


EXPORTING
FILENAME = V_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
* HEADER_LENGTH =0
* READ_BY_LINE = 'X'

www.tagskills.com
* DAT_MODE =''
* CODEPAGE =''
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM =''
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK =''
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = LT_LIFNR
* CHANGING
* ISSCANPERFORMED =''
* EXCEPTIONS
* FILE_OPEN_ERROR =1
* FILE_READ_ERROR =2
* NO_BATCH =3
* GUI_REFUSE_FILETRANSFER =4
* INVALID_TYPE =5
* NO_AUTHORITY =6
* UNKNOWN_ERROR =7
* BAD_DATA_FORMAT =8
* HEADER_NOT_ALLOWED =9
* SEPARATOR_NOT_ALLOWED = 10
* HEADER_TOO_LONG = 11
* UNKNOWN_DP_ERROR = 12
* ACCESS_DENIED = 13
* DP_OUT_OF_MEMORY = 14
* DISK_FULL = 15
* DP_TIMEOUT = 16
* OTHERS = 17
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

*include bdcrecx1.

LOOP AT LT_LIFNR INTO WA_LIFNR.


perform bdc_dynpro using 'SAPMF02K' '0100' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-KTOKK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
* record-LIFNR_001.
WA_LIFNR-LIFNR.
perform bdc_field using 'RF02K-KTOKK'
* record-KTOKK_002.
WA_LIFNR-KTOKK.
perform bdc_dynpro using 'SAPMF02K' '0110' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-LAND1'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'LFA1-NAME1'
* record-NAME1_003.
WA_LIFNR-MCOD1.
perform bdc_field using 'LFA1-SORTL'
* record-SORTL_004.
WA_LIFNR-SORTL.
perform bdc_field using 'LFA1-LAND1'
* record-LAND1_005.
WA_LIFNR-LAND1.

www.tagskills.com
*perform bdc_transaction using 'XK01'.
CALL TRANSACTION 'XK01' USING BDCDATA
MODE CTUMODE.

ENDLOOP.

FORM BDC_DYNPRO USING PROGRAM DYNPRO..


CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.

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

Output—>

Database Table—>

www.tagskills.com
Difference between Call Transaction method and session method:

The following table highlights the major differences between Call Transaction
and session method−

Call Transaction Session Method


In call transaction method we In this method an error log will be
manually handle the errors. generated that will be handle the
errors.
This method is fast. This method is slower.
This is immediate data base updation. In this method after processing the
session through SM35 only database
is updated.
This is suitable if the flat file contai
contaisn This is suitable if the flat file contains
less amount of data. huge amount of data.
Background scheduling is not possible. Background scheduling is possible.
It returns SY-SUBRC value. It can’t return SY-SUBRC
SUBRC value.
Call Transaction method can process Session method can process any
only one transaction at a time. number of transactions at a time.
Synchronous process. Asynchronous Process.

www.tagskills.com
TagSkills:

Disclaimer –

© Copyright TagSkills. The copyright in this work is vested in


TagSkills. Please note and abide bbyy copyright laws. This presentation
is for educational purposes only, all logos, photos, and information,
etc used in this Presentation is the property of TagSkills. SAP is a
registered trademark of SAP AG in Germany and many other
countries. We are NOT AS ASSOCIATED
SOCIATED www.tagskills.com © Copyright
TagSkills. The copyright in this work is vested in TagSkills. Please note
and abide by copyright laws. This presentation is for educational
purposes only, all logos, photos, and information, etc used in this
Presentation
ion is the property of TagSkills. SAP is a registered
trademark of SAP AG in Germany and many other countries. We are
NOT ASSOCIATED with SAP.

www.tagskills.com

You might also like