Вы находитесь на странице: 1из 9

BDC call transaction method

BDC (Batch Data Communication):


It Transfers or upload the datas(records) from Legacy(Non SAP)
system to SAP system.
Batch input means bulk amount of data.
It is a programming method. So technical consultants are use this method and
others using LSMW.
Types: It has two types
1. CALL TRANSACTION METHOD.
2. SESSION METHOD (C L A S S I C A L ) .

Call Transaction method:


1. synchronous Processing. (Data or record)
2. Synchronous and Asynchronous database updates.
3. Transfer of data for individual transaction.
4. This is more faster than session method.
5. Not suited for bulk transfer.
6. No automatic error handling.
7. Error logs are not created.
8. The value of sy-subrc returned to 0 if successful.
9. The system won't store data for later processing. This is online
processing.
10. It can handle small amount of data.
11. Function modules :
F4_FILENAME ( Open the legacy file [.txt or .xls]) .
TEXT_CONVERT_XSL_TO_SAP ( Convert the .xls file to sap
format) : Using for only .xls files.
GUI_UPLOAD : Using for only .txt files.
Step-by-Step creation:
Create the recording :
Using T-code SHDB.
Click new recording then put the recoding name
and transaction code (xd01 customer, xk01- vender, mm01
material master creation) then click continue or press enter.

Thereafter put all the required datas into


the transaction screen. Note:Must provide the mandatory fields
datas.
After finished recording to save and come back.
Select your record then click program button.
Transfer the recording to ABAP Editor (SE38).
Put the program name in the pop up window then click continue or
press enter.
Automatically open the report in se38.
Define the type-pools and call the function modules.
Example 1: (call transaction to upload .xls file data) customer master
creation
REPORT ZVAIGUNDARAJABDC2
NO STANDARD PAGE HEADING LINE-SIZE 255.
INCLUDE BDCRECX1.

TYPE-POOLS TRUXS. This is use to data conversion in


TEXT_CONVERT_XLS_TO_SAP.

***************internal table**************************************
DATA: BEGIN OF RECORD OCCURS 0,
* data element: BUKRS
BUKRS_001(004),
* data element: KTOKD
KTOKD_002(004),
* data element: NAME1_GP
NAME1_003(035),
* data element: LAND1_GP
LAND1_004(003),
* data element: REGIO
REGIO_005(003),
* data element: SPRAS
SPRAS_006(002),
* data element: CIVVE
CIVVE_007(001),
* data element: AKONT
AKONT_008(010),
END OF RECORD.
*** End generated data section ***

DATA IT_RAW TYPE TRUXS_T_TEXT_DATA.


PARAMETERS PATH TYPE RLGRAP-FILENAME OBLIGATORY.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR PATH.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME
= SYST-CPROG
DYNPRO_NUMBER
= SYST-DYNNR
FIELD_NAME
= 'PATH'
IMPORTING
FILE_NAME
= PATH
.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR
=
* I_LINE_HEADER
=
I_TAB_RAW_DATA
= IT_RAW
I_FILENAME
= PATH
TABLES
I_TAB_CONVERTED_DATA
= RECORD
* EXCEPTIONS
* CONVERSION_FAILED
=1
* OTHERS
=2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
START-OF-SELECTION.
LOOP AT RECORD.
PERFORM OPEN_GROUP.
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_FIELD

USING 'SAPMF02D' '0100'.


USING 'BDC_CURSOR'
'RF02D-KTOKD'.
USING 'BDC_OKCODE'
'/00'.
USING 'RF02D-BUKRS'
RECORD-BUKRS_001.
USING 'RF02D-KTOKD'
RECORD-KTOKD_002.
USING 'SAPMF02D' '0110'.
USING 'BDC_CURSOR'
'KNA1-REGIO'.
USING 'BDC_OKCODE'
'/00'.
USING 'KNA1-NAME1'

PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_FIELD
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD

RECORD-NAME1_003.
USING 'KNA1-LAND1'
RECORD-LAND1_004.
USING 'KNA1-REGIO'
RECORD-REGIO_005.
USING 'KNA1-SPRAS'
RECORD-SPRAS_006.
USING 'SAPMF02D' '0120'.
USING 'BDC_CURSOR'
'KNA1-LIFNR'.
USING 'BDC_OKCODE'
'/00'.
USING 'SAPMF02D' '0125'.
USING 'BDC_CURSOR'
'KNA1-NIELS'.
USING 'BDC_OKCODE'
'/00'.
USING 'SAPMF02D' '0130'.
USING 'BDC_CURSOR'
'KNBK-BANKS(01)'.
USING 'BDC_OKCODE'
'=ENTR'.
USING 'SAPMF02D' '0340'.
USING 'BDC_CURSOR'
'RF02D-KUNNR'.
USING 'BDC_OKCODE'
'=ENTR'.
USING 'SAPMF02D' '0370'.
USING 'BDC_CURSOR'
'RF02D-KUNNR'.
USING 'BDC_OKCODE'
'=ENTR'.
USING 'KNA1-CIVVE'
RECORD-CIVVE_007.
USING 'SAPMF02D' '0360'.
USING 'BDC_CURSOR'
'KNVK-NAMEV(01)'.
USING 'BDC_OKCODE'
'=ENTR'.
USING 'SAPMF02D' '0210'.
USING 'BDC_CURSOR'
'KNB1-AKONT'.
USING 'BDC_OKCODE'
'/00'.
USING 'KNB1-AKONT'
RECORD-AKONT_008.
USING 'SAPMF02D' '0215'.
USING 'BDC_CURSOR'

'KNB1-ZTERM'.
PERFORM BDC_FIELD
USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_DYNPRO
USING 'SAPMF02D' '0220'.
PERFORM BDC_FIELD
USING 'BDC_CURSOR'
'KNB5-MAHNA'.
PERFORM BDC_FIELD
USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_DYNPRO
USING 'SAPMF02D' '0230'.
PERFORM BDC_FIELD
USING 'BDC_CURSOR'
'KNB1-VRSNR'.
PERFORM BDC_FIELD
USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_DYNPRO
USING 'SAPMF02D' '0610'.
PERFORM BDC_FIELD
USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD
USING 'BDC_CURSOR'
'RF02D-KUNNR'.
PERFORM BDC_TRANSACTION USING 'XD01'.
PERFORM CLOSE_GROUP.
ENDLOOP.

Excel sheet data: ( .xls file)


1000 ZMUM
RAJ1 IN 20
EN x
16443100
1000 ZMUM
RAJ2 IN 20
EN x
16443100
Example 2: (call transaction to upload .txt file data) customer master
creation:
report ZVAIGUNDARAJABDC3
no standard page heading line-size 255.
include bdcrecx1.
data: begin of record OCCURS 0,
* data element: BUKRS
BUKRS_001(004),
* data element: KTOKD
KTOKD_002(004),
* data element: ANRED
ANRED_003(015),
* data element: NAME1_GP
NAME1_004(035),
* data element: LAND1_GP
LAND1_005(003),
* data element: SPRAS
SPRAS_006(002),
* data element: CIVVE
CIVVE_007(001),

* data element: AKONT


AKONT_008(010),
end of record.
*** End generated data section ***
data: file1 TYPE string.
PARAMETERS: file TYPE rlgrap-filename OBLIGATORY.
AT SELECTION-SCREEN on VALUE-REQUEST FOR file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME
= SYST-CPROG
DYNPRO_NUMBER
= SYST-DYNNR
FIELD_NAME
= 'file'
IMPORTING
FILE_NAME
= file
.
file1 = file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME
= file1
FILETYPE
= 'ASC'
HAS_FIELD_SEPARATOR
= 'x'
* HEADER_LENGTH
=0
* READ_BY_LINE
= 'X'
* DAT_MODE
=''
* CODEPAGE
=''
* IGNORE_CERR
= ABAP_TRUE
* REPLACEMENT
= '#'
* CHECK_BOM
=''
* VIRUS_SCAN_PROFILE
=
* NO_AUTH_CHECK
=''
* IMPORTING
* FILELENGTH
=
* HEADER
=
TABLES
DATA_TAB
= record
* 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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
start-of-selection.
loop at record.
perform open_group.
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field

using 'SAPMF02D' '0100'.


using 'BDC_CURSOR'
'RF02D-KTOKD'.
using 'BDC_OKCODE'
'/00'.
using 'RF02D-BUKRS'
record-BUKRS_001.
using 'RF02D-KTOKD'
record-KTOKD_002.
using 'SAPMF02D' '0110'.
using 'BDC_CURSOR'
'KNA1-SPRAS'.
using 'BDC_OKCODE'
'/00'.
using 'KNA1-ANRED'
record-ANRED_003.
using 'KNA1-NAME1'
record-NAME1_004.
using 'KNA1-LAND1'
record-LAND1_005.
using 'KNA1-SPRAS'
record-SPRAS_006.
using 'SAPMF02D' '0120'.
using 'BDC_CURSOR'
'KNA1-LIFNR'.

perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field

using 'BDC_OKCODE'
'/00'.
using 'SAPMF02D' '0125'.
using 'BDC_CURSOR'
'KNA1-NIELS'.
using 'BDC_OKCODE'
'/00'.
using 'SAPMF02D' '0130'.
using 'BDC_CURSOR'
'KNBK-BANKS(01)'.
using 'BDC_OKCODE'
'=ENTR'.
using 'SAPMF02D' '0340'.
using 'BDC_CURSOR'
'RF02D-KUNNR'.
using 'BDC_OKCODE'
'=ENTR'.
using 'SAPMF02D' '0370'.
using 'BDC_CURSOR'
'RF02D-KUNNR'.
using 'BDC_OKCODE'
'=ENTR'.
using 'KNA1-CIVVE'
record-CIVVE_007.
using 'SAPMF02D' '0360'.
using 'BDC_CURSOR'
'KNVK-NAMEV(01)'.
using 'BDC_OKCODE'
'=ENTR'.
using 'SAPMF02D' '0210'.
using 'BDC_CURSOR'
'KNB1-AKONT'.
using 'BDC_OKCODE'
'/00'.
using 'KNB1-AKONT'
record-AKONT_008.
using 'SAPMF02D' '0215'.
using 'BDC_CURSOR'
'KNB1-ZTERM'.
using 'BDC_OKCODE'
'/00'.
using 'SAPMF02D' '0220'.
using 'BDC_CURSOR'
'KNB5-MAHNA'.
using 'BDC_OKCODE'
'/00'.
using 'SAPMF02D' '0230'.
using 'BDC_CURSOR'

'KNB1-VRSNR'.
perform bdc_field
using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro
using 'SAPMF02D' '0610'.
perform bdc_field
using 'BDC_OKCODE'
'/00'.
perform bdc_field
using 'BDC_CURSOR'
'RF02D-KUNNR'.
perform bdc_transaction using 'XD01'.
perform close_group.
ENDLOOP.

Record: ( .txt file)


1000 ZMUM
mr
1000 ZMUM
mr
Contribute!

RAJ1 IN
RAJ2 IN

EN
EN

x
x

16443100
16443100