Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BDC

Former Member
0 Likes
811

Hi friends,

Can you please let me know the complete-flow , about how BDC works.

regards,

Ankush.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
757

Hi,

You have to follow below steps:

1. Go to SHDB.

2. NEW RECORDING

3. Give Transaction name where you want data to be populated and filled in database , say MM01 - Material.

4. Start recording (dummy) screen and put dummy but relevant data.

5. Once you finish, save recording.

6. See Program button in apps toolbar, or Function module...

7. Click and transfer this recording to further records updation.

8. Create Program.

9. Take all in newly created program , whic is nothing but your screen numbers, program names and field names you had recorded.

10. Upload data using FM

11. Loop data and screens as per you want.

12. Run it. Select method session or call transaction

13. Give legacy file name

14. Upload data.

Reward if useful!

5 REPLIES 5
Read only

Former Member
0 Likes
758

Hi,

You have to follow below steps:

1. Go to SHDB.

2. NEW RECORDING

3. Give Transaction name where you want data to be populated and filled in database , say MM01 - Material.

4. Start recording (dummy) screen and put dummy but relevant data.

5. Once you finish, save recording.

6. See Program button in apps toolbar, or Function module...

7. Click and transfer this recording to further records updation.

8. Create Program.

9. Take all in newly created program , whic is nothing but your screen numbers, program names and field names you had recorded.

10. Upload data using FM

11. Loop data and screens as per you want.

12. Run it. Select method session or call transaction

13. Give legacy file name

14. Upload data.

Reward if useful!

Read only

Former Member
0 Likes
757

HI,

BDC:

Batch Data Communication (BDC) is the process of transferring data from one SAP System to another SAP system or from a non-SAP system to SAP System.

Features :

BDC is an automatic procedure.

This method is used to transfer large amount of data that is available in electronic medium.

BDC can be used primarily when installing the SAP system and when transferring data from a legacy system (external system).

BDC uses normal transaction codes to transfer data.

Types of BDC :

CLASSICAL BATCH INPUT (Session Method)

CALL TRANSACTION

BATCH INPUT METHOD:

This method is also called as ‘CLASSICAL METHOD’.

Features:

Asynchronous processing.

Synchronous Processing in database update.

Transfer data for more than one transaction.

Batch input processing log will be generated.

During processing, no transaction is started until the previous transaction has been written to the database.

CALL TRANSACTION METHOD :

This is another method to transfer data from the legacy system.

Features:

Synchronous processing. The system performs a database commit immediately before and after the CALL TRANSACTION USING statement.

Updating the database can be either synchronous or asynchronous. The program specifies the update type.

Transfer data for a single transaction.

Transfers data for a sequence of dialog screens.

No batch input processing log is generated.

For BDC:

http://myweb.dal.ca/hchinni/sap/bdc_home.htm

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/bdc&;

http://www.sap-img.com/abap/learning-bdc-programming.htm

http://www.sapdevelopment.co.uk/bdc/bdchome.htm

http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm

http://help.sap.com/saphelp_47x200/helpdata/en/69/c250684ba111d189750000e8322d00/frameset.htm

http://www.sap-img.com/abap/learning-bdc-

http://www.sapbrain.com/TUTORIALS/TECHNICAL/BDC_tutorial.html

Regards,

Priyanka.

Read only

Former Member
0 Likes
757

Hi,

<b>BATCH DATA COMMUNICATION</b>

When a company decides to implement the SAP R/3 to manage business-critical data, it usually does not start from a no-data situation. Normally, a SAP R/3 project comes into replace or complement existing application.

In the process of replacing current applications and transferring application data, two situations might occur:

• The first is when application data to be replaced is transferred at once, and only once.

• The second situation is to transfer data periodically from external systems to SAP and vice versa.

• There is a period of time when information has to be transferred from existing application, to SAP R/3, and often this process will be repetitive.

The SAP system offers two primary methods for transferring data into SAP systems. From non-SAP systems or legacy system. These two methods are collectively called “batch input” or “batch data communication”.

1. SESSION METHOD

2. CALL TRANSACTION

3. DIRECT INPUT

Advantages offered by BATCH INPUT method:

1. Can process large data volumes in batch.

2. Can be planned and submitted in the background.

3. No manual interaction is required when data is transferred.

4. Data integrity is maintained as whatever data is transferred to the table is through transaction. Hence batch input data is submitted to all the checks and validations.

To implement one of the supported data transfers, you must often write the program that exports the data from your non-SAP system. This program, known as a “data transfer” program must map the data from the external system into the data structure required by the SAP batch input program.

The batch input program must build all of the input to execute the SAP transaction.

Two main steps are required:

• To build an internal table containing every screen and every field to be filled in during the execution of an SAP transaction.

• To pass the table to SAP for processing.

Prerequisite for Data Transfer Program

Writing a Data Transfer Program involves following prerequisites:

<i>Analyzing data from local file

Analyzing transaction</i>

<b>BATINPUT/DIRECT INPUT</b>

A: Batch-inputs can not be used to fill the "delivery due list" screen because it is not a dynpro. This is a standard SAP report. A SAP report (check with "System -> Status") may be called using SUBMIT sentence with the appropriate options . It is preferred to call a report than create a Batch-input program.

<b>What is the difference between batch input and call transaction in BDC?</b>

Session method.

1) synchronous processing.

2) can tranfer large amount of data.

3) processing is slower.

4) error log is created

5) data is not updated until session is processed.

Call transaction.

1) asynchronous processing

2) can transfer small amount of data

3) processing is faster.

4) errors need to be handled explicitly

5) data is updated automatically

Chk these links for more info

http://help.sap.com/saphelp_erp2005/helpdata/en/fa/097119543b11d1898e0000e8322d00/frameset.htm

S<b>ample Program for BDC Session method</b>

INCLUDE yx30_dm_upload_listings_top. " Include for Variable Declarations and Section Secreens

INCLUDE yx30_dm_upload_listings_dat. " Include for File read & Authority Check,Session Overview

&----


*& At Selection Screen Output *

&----


AT SELECTION-SCREEN OUTPUT.

  • PERFORM fill_parameters. " Subroutine to fetch the file.

&----


*& Start Of Selection Event *

&----


START-OF-SELECTION.

  • PERFORM authority_check. "Subroutine for authority check

PERFORM file_read. "Subroutine for File read

PERFORM open_session USING 'MIG_LISTING'. "Subroutine to open the session

LOOP AT itab_listings INTO wa_listings.

v_mod = sy-tabix MOD k_sesssize.

IF v_mod EQ 0.

PERFORM populate_session. "Subroutine to populate the session

PERFORM close_bdc_session. "Sobroutine to close the session

v_count2 = v_count2 + 1.

v_count3 = v_count2 * k_sesssize.

IF v_count1 NE v_count3.

PERFORM open_session USING 'MIG_LISTING'.

ELSE.

EXIT.

ENDIF.

ELSE.

PERFORM populate_session.

ENDIF.

ENDLOOP.

CLEAR: v_mod,v_count1,v_count2,v_count3.

PERFORM close_bdc_session.

SUBMIT rsbdcsub

WITH mappe EQ 'MIG_LISTING' " Session Name

WITH von EQ sy-datum " Starting Interval date

WITH bis EQ sy-datum " Closing Interval Date

WITH z_verarb EQ 'X'

WITH logall EQ 'X' " Log Info

AND RETURN .

&----


*& Include YX30_DM_UPLOAD_LISTINGS_TOP

&----


  • Type Declaration

TABLES: kotg902,kotg903. " Tables for sold-to-party & ship-to-party

TYPES: BEGIN OF type_listings,

kschl TYPE c LENGTH 4, " Condition Type

tabname16 TYPE c LENGTH 16, " Condition table name

vkorg TYPE c LENGTH 4, " Sales Organisation

kunnr TYPE c LENGTH 10, " sold-to-party number or ship-to party number

matnr TYPE c LENGTH 18, " Material Number

kodatab(10) TYPE c , " valid-from date

kodatb1(10) TYPE c, " valid-to-date

END OF type_listings.

  • Internal Table Declaration

DATA: itab_listings TYPE STANDARD TABLE OF type_listings. "Internal table for LISTINGS.

DATA: itab_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE. "Internal Table for BDC data.

  • Variables & Constants Declaration

DATA : v_mod TYPE i, " Sessioning variable

v_count1 TYPE i, " Counter for No.of records in the upload File

v_count2 TYPE i, " Counter for No.of Sessions created

v_count3 TYPE i. " Counter for EOF indication

CONSTANTS: k_split(1) TYPE c VALUE ';', " File spliting indicator

k_sesssize TYPE i VALUE 1000, " Session size

k_sessname TYPE string VALUE 'MIG_LISTING'. " Session Name

  • Work Area Declaration

DATA: wa_listings TYPE type_listings. "Work Area for LISTINGS.

  • Variable Declaration

DATA: v_file_listings TYPE string, "Source File Name

v1 TYPE string, " Variables for File Fetching

v2 TYPE string,

v3 TYPE string.

*Selection Screen Declaration

----


  • selection-screen *

----


SELECTION-SCREEN BEGIN OF BLOCK blk1

WITH FRAME TITLE text-s01.

PARAMETER:

p_sysid(3) TYPE c OBLIGATORY , "Source System

p_bukrs(4) TYPE c OBLIGATORY , "Source CompCode

p_samshr TYPE char30 LOWER CASE OBLIGATORY DEFAULT '/sap_upload/' , "Samba Share Drive

p_object TYPE char10 OBLIGATORY DEFAULT 'PRC' . "Migration Data Object

SELECTION-SCREEN END OF BLOCK blk1.

SELECTION-SCREEN SKIP 3.

PARAMETER:

cb_pfill TYPE c AS CHECKBOX DEFAULT 'X' . "Prefill values

SELECTION-SCREEN COMMENT /1(79) text-s1a.

SELECTION-SCREEN BEGIN OF BLOCK blk3

WITH FRAME TITLE text-s03.

PARAMETER:

pa_filn1(500) TYPE c LOWER CASE

VISIBLE LENGTH 50 OBLIGATORY , "Filename AppServer

pa_dlimt TYPE c DEFAULT ';' , "Field Delimter

pa_test TYPE c DEFAULT 'X'. "'X' = TEST ,'' = UPLOAD

SELECTION-SCREEN END OF BLOCK blk3.

&----


*& Include YX30_DM_UPLOAD_LISTINGS_DAT

&----


&----


*& Form fill_parameters

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_parameters .

IF cb_pfill = 'X'. "Preparing Input File

CONCATENATE p_sysid '_forward' INTO v3.

CONCATENATE p_sysid '_listings_' p_bukrs '.CSV' INTO v2.

CONCATENATE p_samshr v3 '/' p_object '/' v2 INTO pa_filn1.

CLEAR v3.

CLEAR v2.

ENDIF.

ENDFORM. " fill_parameters

&----


*& Form authority_check

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM authority_check .

  • Authority Check For the Migration

AUTHORITY-CHECK OBJECT 'YX30_MIGR'

ID 'SYSTEM' FIELD p_sysid

ID 'BUKRS' FIELD p_bukrs

ID 'YX30_DMOBJ' FIELD p_object

ID 'ACTVT' FIELD '16'.

IF sy-subrc <> 0.

MESSAGE e010 WITH p_sysid p_bukrs p_object '16'.

ENDIF.

ENDFORM. " authority_check

&----


*& Form file_read

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM file_read .

DATA: single_line TYPE string .

v_file_listings = pa_filn1.

IF v_file_listings IS INITIAL .

MESSAGE e039 WITH v_file_listings.

ENDIF.

*-- read file, split lines into fields and put data into table

OPEN DATASET v_file_listings FOR INPUT IN TEXT MODE ENCODING NON-UNICODE. "Opening the files

IF sy-subrc EQ 0.

DO.

READ DATASET v_file_listings INTO single_line. "Reading the content of file into line

IF sy-subrc = 0.

IF sy-index > 1. "skip header-line

SPLIT "Split the content of line into work area

single_line

AT k_split

INTO

wa_listings-kschl " Condition type

wa_listings-tabname16 " Condition table name

wa_listings-vkorg " Sales organisation

wa_listings-kunnr " sold-to party numberor ship-to party number

wa_listings-matnr " Material Number

wa_listings-kodatab " Valid-from date

wa_listings-kodatb1. " Valid-to date

APPEND wa_listings TO itab_listings. "Appending Work Area to internal table

ENDIF.

ELSE.

EXIT.

ENDIF.

v_count1 = sy-tabix.

ENDDO.

CLOSE DATASET v_file_listings. "Closing the files

ENDIF.

ENDFORM. " file_read

&----


*& Form insert_bdc_session

&----


  • text

----


  • -->P_0045 text

----


FORM insert_bdc_session USING p_tcode.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = p_tcode

TABLES

dynprotab = itab_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.

ENDIF.

ENDFORM. " insert_bdc_session

&----


*& Form close_bdc_session

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM close_bdc_session .

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

not_open = 1

queue_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

ENDIF.

ENDFORM. " close_bdc_session

&----


*& Form bdc_dynpro

&----


  • text

----


  • -->P_0184 text

  • -->P_0185 text

----


FORM bdc_dynpro USING p_program p_dynpro.

CLEAR itab_bdcdata.

itab_bdcdata-program = p_program.

itab_bdcdata-dynpro = p_dynpro.

itab_bdcdata-dynbegin = 'X'.

APPEND itab_bdcdata.

ENDFORM. " bdc_dynpro

&----


*& Form bdc_field

&----


  • text

----


  • -->P_0179 text

  • -->P_WA_LISTINGS_TABNAME16 text

----


FORM bdc_field USING p_fnam p_fval.

CLEAR itab_bdcdata.

itab_bdcdata-fnam = p_fnam.

itab_bdcdata-fval = p_fval.

APPEND itab_bdcdata.

ENDFORM. " bdc_field

&----


*& Form open_session

&----


  • text

----


  • -->P_0069 text

----


FORM open_session USING p_sessname.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

group = p_sessname

keep = 'X'

user = sy-uname

EXCEPTIONS

client_invalid = 1

destination_invalid = 2

group_invalid = 3

group_is_locked = 4

holddate_invalid = 5

internal_error = 6

queue_error = 7

running = 8

system_lock_error = 9

user_invalid = 10

OTHERS = 11.

IF sy-subrc <> 0.

ENDIF.

ENDFORM. " open_session

&----


*& Form populate_session

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM populate_session .

PERFORM bdc_dynpro USING 'SAPMV13G' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'G000-KSCHL'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'G000-KSCHL'

wa_listings-kschl.

PERFORM bdc_dynpro USING 'SAPLV14A' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RV130-SELKZ(01)'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RV130-SELKZ(02)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=WEIT'.

IF wa_listings-tabname16 EQ 'KOTG902'.

PERFORM bdc_field USING 'RV130-SELKZ(01)' 'X'.

PERFORM bdc_dynpro USING 'SAPMV13G' '1902'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'KOMGG-VKORG'

wa_listings-vkorg.

PERFORM bdc_field USING 'KOMGG-KUNAG'

wa_listings-kunnr.

CONCATENATE wa_listings-kodatab6(2) '.' wa_listings-kodatab4(2) '.' wa_listings-kodatab+0(4) INTO wa_listings-kodatab.

PERFORM bdc_field USING 'G000-DATAB'

wa_listings-kodatab.

CONCATENATE wa_listings-kodatb16(2) '.' wa_listings-kodatb14(2) '.' wa_listings-kodatb1+0(4) INTO wa_listings-kodatb1.

PERFORM bdc_field USING 'G000-DATBI'

wa_listings-kodatb1.

PERFORM bdc_field USING 'KOMGG-MATNR(01)'

wa_listings-matnr.

PERFORM bdc_dynpro USING 'SAPMV13G' '1902'.

PERFORM bdc_field USING 'BDC_CURSOR'

'KOMGG-MATNR(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=SICH'.

ELSEIF wa_listings-tabname16 EQ 'KOTG903'.

PERFORM bdc_field USING 'RV130-SELKZ(02)' 'X'.

PERFORM bdc_dynpro USING 'SAPMV13G' '1903'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'KOMGG-VKORG'

wa_listings-vkorg.

PERFORM bdc_field USING 'KOMGG-KUNWE'

wa_listings-kunnr.

CONCATENATE wa_listings-kodatab6(2) '.' wa_listings-kodatab4(2) '.' wa_listings-kodatab+0(4) INTO wa_listings-kodatab.

PERFORM bdc_field USING 'G000-DATAB'

wa_listings-kodatab.

CONCATENATE wa_listings-kodatb16(2) '.' wa_listings-kodatb14(2) '.' wa_listings-kodatb1+0(4) INTO wa_listings-kodatb1.

PERFORM bdc_field USING 'G000-DATBI'

wa_listings-kodatb1.

PERFORM bdc_field USING 'KOMGG-MATNR(01)'

wa_listings-matnr.

PERFORM bdc_dynpro USING 'SAPMV13G' '1903'.

PERFORM bdc_field USING 'BDC_CURSOR'

'KOMGG-MATNR(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=SICH'.

ENDIF.

  • Insert the data into bdcdata table

PERFORM insert_bdc_session USING 'VB01'.

CLEAR itab_bdcdata.

REFRESH itab_bdcdata.

ENDFORM. " populate_session

<b>Reward Points if Useful</b>

Regards

Gokul

Read only

Former Member
0 Likes
757

Hi Ankush,

Here I specify over all idea how to write the code.

1...decalre ur internal table----in which fields should be similar to ur flat file structure.

2..declare BDCDATA internal table

3..by using UPLOAD or WS_UPLOAD or GUI_UPLOAD load that flat file data into the ur internal table.

Here passing parameters are...give the name of ur flatfile like C:\DOC\file.txt

and name of your internal table.

4.. loop at inernal_table.......

a..pass each screen field value, to the BDCDATA internal table

Ex. PERFORM BDCDATA USING 'screen program name'

' screen number'

' X' or 'space'

'field name'

'field value' .

in the subroutine add each row to the bdcdata internal table. write the code here

b... here u specifiy the CALL TRANSACTION syntax

endloop.

Below is for session method.

1,2,3 steps...same as above

4...call the BDC_ OPEN_GROUP function module, pass the session name.

5...

loop at inernal_table.......

a..pass each screen field value, to the BDCDATA internal table

Ex. PERFORM BDCDATA USING 'screen program name'

' screen number'

' X' or 'space'

'field name'

'field value' .

in the subroutine add each row to the bdcdata internal table. write the code here

b... here u specifiy the BDC_INSERT function module pass the tr code to which u r doing.

endloop.

6....call the BDC_CLOSE_GROUP function module. here there is no need to pass any parameters

endloop.

Regards,

Surya