BDC Call Transaction Method Program in SAP ABAP
BDC Call Transaction Method Program in SAP ABAP
BDC is Bach data communication program which is used to migrate data from legacy(Non-SAP) system to SAP ABAP System.Call Transaction Method is one of the Techniques of BDC.
In call Transaction Method ,we have to record the Transaction using SHDB Transaction code to get the screen fields and related Program that is include bdcrecx1.
Go to SHDB Transaction Code and Click on New Recording.
Go to SHDB Transaction Code and Click on New Recording.
Give the Record name and Transaction code and click on Start New Recording Button.
Now enter the Bank country and Key
Now enter the Bank name ,City ,country and street.
Now Save the Recording .
Now select the created record and click on Program.
Now give the program title and select radio button transfer from recording.
Now give the program title and click on source code button.
Now save it as Local object.
Now BDC program will be created automatically and you can find the structures and dynpro and dynfield subroutines in Include BDCRECX1 main program.Copy them and paste in your source code.
Now ,you can see the whole code in the below.
report ZBDC_CALLTRNS_PRO4
no standard page heading line-size 255.
*include bdcrecx1.
types : begin of ty_bnka,
banks type bnka-banks,
bankl type bnka-bankl,
banka type bnka-banka,
stras type bnka-stras,
ort01 type bnka-ort01,
end of ty_bnka.
data : it_bnka type table of ty_bnka,
wa_bnka type ty_bnka.
data : it_bdcdata type table of bdcdata,
wa_bdcdata type bdcdata.
data : bdcmsg type table of bdcmsgcoll.
data : file type string.
parameters : p_file type rlgrap-filename.
start-of-selection.
if p_file is not initial.
file = p_file.
ENDIF.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = file
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 = it_bnkA
* 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.
*perform open_group.
LOOP AT IT_BNKA INTO WA_BNKA.
perform bdc_dynpro using 'SAPMF02B' '0100'.
perform bdc_field using 'BDC_CURSOR'
'BNKA-BANKL'.
perform bdc_field using 'BDC_OKCODE'
'ENTER'.
perform bdc_field using 'BNKA-BANKS'
WA_BNKA-BANKS.
perform bdc_field using 'BNKA-BANKL'
WA_BNKA-BANKL.
perform bdc_dynpro using 'SAPMF02B' '0110'.
perform bdc_field using 'BDC_CURSOR'
'BNKA-ORT01'.
perform bdc_field using 'BDC_OKCODE'
'ENTER'.
perform bdc_field using 'BNKA-BANKA'
WA_BNKA-BANKA.
perform bdc_field using 'BNKA-STRAS'
WA_BNKA-STRAS.
perform bdc_field using 'BNKA-ORT01'
WA_BNKA-ORT01.
CALL TRANSACTION 'FI01' USING IT_BDCDATA MODE 'A' UPDATE 'A' MESSAGES INTO BDCMSG.
*perform close_group.
ENDLOOP.
DATA : WA_BDCMSG LIKE LINE OF BDCMSG.
IF BDCMSG IS NOT INITIAL.
LOOP AT BDCMSG INTO WA_BDCMSG.
WRITE: WA_BDCMSG-TCODE,WA_BDCMSG-MSGTYP,WA_BDCMSG-MSGV1,WA_BDCMSG-FLDNAME.
CLEAR WA_BDCMSG.
ENDLOOP.
ENDIF.
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 IT_BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
* IF FVAL <> NODATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO IT_BDCDATA.
* ENDIF.
ENDFORM.
no standard page heading line-size 255.
*include bdcrecx1.
types : begin of ty_bnka,
banks type bnka-banks,
bankl type bnka-bankl,
banka type bnka-banka,
stras type bnka-stras,
ort01 type bnka-ort01,
end of ty_bnka.
data : it_bnka type table of ty_bnka,
wa_bnka type ty_bnka.
data : it_bdcdata type table of bdcdata,
wa_bdcdata type bdcdata.
data : bdcmsg type table of bdcmsgcoll.
data : file type string.
parameters : p_file type rlgrap-filename.
start-of-selection.
if p_file is not initial.
file = p_file.
ENDIF.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = file
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 = it_bnkA
* 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.
*perform open_group.
LOOP AT IT_BNKA INTO WA_BNKA.
perform bdc_dynpro using 'SAPMF02B' '0100'.
perform bdc_field using 'BDC_CURSOR'
'BNKA-BANKL'.
perform bdc_field using 'BDC_OKCODE'
'ENTER'.
perform bdc_field using 'BNKA-BANKS'
WA_BNKA-BANKS.
perform bdc_field using 'BNKA-BANKL'
WA_BNKA-BANKL.
perform bdc_dynpro using 'SAPMF02B' '0110'.
perform bdc_field using 'BDC_CURSOR'
'BNKA-ORT01'.
perform bdc_field using 'BDC_OKCODE'
'ENTER'.
perform bdc_field using 'BNKA-BANKA'
WA_BNKA-BANKA.
perform bdc_field using 'BNKA-STRAS'
WA_BNKA-STRAS.
perform bdc_field using 'BNKA-ORT01'
WA_BNKA-ORT01.
CALL TRANSACTION 'FI01' USING IT_BDCDATA MODE 'A' UPDATE 'A' MESSAGES INTO BDCMSG.
*perform close_group.
ENDLOOP.
DATA : WA_BDCMSG LIKE LINE OF BDCMSG.
IF BDCMSG IS NOT INITIAL.
LOOP AT BDCMSG INTO WA_BDCMSG.
WRITE: WA_BDCMSG-TCODE,WA_BDCMSG-MSGTYP,WA_BDCMSG-MSGV1,WA_BDCMSG-FLDNAME.
CLEAR WA_BDCMSG.
ENDLOOP.
ENDIF.
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 IT_BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
* IF FVAL <> NODATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO IT_BDCDATA.
* ENDIF.
ENDFORM.
Now save and activate the Program and execute.before all ,save your external data in note pad with tab space.
After executing BDC program ,it will ask note pad file path ,then give file path in input field.
Execute the BDC call transaction program.
Now system will process the transaction screens to upload the data into SAP data base.
Now program successfully transferred the data through two recorded screens of FI01 transaction code .
we have successfully created the Call transaction method program as SAP ABAP Developer.
SAP ABAP
BDC and LSMW
BDC Call Transaction Method Program in SAP ABAP
BDC Session Method Program Tutorial in SAP ABAP
BDC Interview Questions
SAP LSMW Tutorial Step by Step
Difference Between Call Transaction and Session Methods in SAP ABAP
Comments
Post a Comment