CODE FOR THE INCLUDE
*&---------------------------------------------------------------------*
*&
Include
ZRAJ_TOP_OF_PAGE1
*&---------------------------------------------------------------------*
DATA: WA_BDCDATA TYPE BDCDATA,
IT_BDCDATA TYPE TABLE OF BDCDATA.
TYPES: BEGIN OF TY_FI01,
BANKS TYPE BANKS,
BANKL TYPE BANKK,
BANKA TYPE BANKA,
END OF TY_FI01.
DATA: WA_FI01 TYPE TY_FI01,
IT_FI01 TYPE TABLE OF TY_FI01.
************************************
**UP LOAD THE FILE DATA TO IT_FI01**
************************************
*call function 'GUI_UPLOAD'
*
exporting
*
FILENAME =
'C:\FI01.TXT'
**
FILETYPE =
'ASC'
*
HAS_FIELD_SEPARATOR =
'X'
**
HEADER_LENGTH = 0
**
READ_BY_LINE =
'X'
**
DAT_MODE = '
'
**
CODEPAGE = '
'
**
IGNORE_CERR =
ABAP_TRUE
**
REPLACEMENT =
'#'
**
CHECK_BOM = ' '
** IMPORTING
**
FILELENGTH =
**
HEADER =
*
TABLES
*
DATA_TAB =
IT_FI01
** 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.
*
WRITE:/ 'FILE UPLOAD SUCESSFULLY'.
*endif.
MAIN PROGRAM
- IN THIS PROGRAM CREATE ONE CLASS AND
- THE OPEN, INSERT AND APPEND SESSION ARE IN THE SAME PROGRAM.
- IN THAT CLASS CALL TRANSACTION IS IMPLEMENTD BUT I AM NOT USE IT.( IN THE LAST I GIVE THE SNAP SHOT’S
report ZGDEMO_BDC_FI01
no standard page heading line-size 255.
include ZRAJ_TOP_OF_PAGE1.
data O_BDC type ref to ZGDEMO_INSERT_BDC_RAJ.
start-of-selection.
*perform open_group.
create object O_BDC.
call method O_BDC->UPLOAD_FILE
exporting
IM_FILE_NAME = 'C:\FI01.TXT'
IM_SEP = 'X'
IMPORTING
IT_DATA = IT_FI01
.
call function 'BDC_OPEN_GROUP'
EXPORTING
CLIENT =
SY-MANDT
*
DEST =
FILLER8
GROUP =
'ZRAJSESSION'
*
HOLDDATE =
FILLER8
KEEP = 'X'
USER = SY-UNAME
*
RECORD =
FILLER1
*
PROG =
SY-CPROG
* IMPORTING
*
QID =
* 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.
WRITE:/ 'SESSION OPEN SUCESSFULLY'.
endif.
loop at IT_FI01 into WA_FI01.
refresh IT_BDCDATA.
call method O_BDC->FILL_DYNPRO
exporting
IM_PROGRAM = 'SAPMF02B'
IM_DYNPRO = '0100'
IM_DYNBEGIN = 'X'
IMPORTING
IT_PROCEDURE = IT_BDCDATA
.
call method O_BDC->FILL_FIELDS
exporting
IM_FNAM = 'BDC_OKCODE'
IM_FVAL = '/00'
IMPORTING
IT_PROCEDURE = IT_BDCDATA
.
call method O_BDC->FILL_FIELDS
exporting
IM_FNAM = 'BNKA-BANKS'
IM_FVAL = WA_FI01-BANKS
IMPORTING
IT_PROCEDURE = IT_BDCDATA.
call method O_BDC->FILL_FIELDS
exporting
IM_FNAM = 'BNKA-BANKL'
IM_FVAL = WA_FI01-BANKL
IMPORTING
IT_PROCEDURE = IT_BDCDATA.
call method O_BDC->FILL_DYNPRO
exporting
IM_PROGRAM = 'SAPMF02B'
IM_DYNPRO = '0110'
IM_DYNBEGIN = 'X'
IMPORTING
IT_PROCEDURE = IT_BDCDATA.
call method O_BDC->FILL_FIELDS
exporting
IM_FNAM = 'BDC_OKCODE'
IM_FVAL = '=UPDA'
IMPORTING
IT_PROCEDURE = IT_BDCDATA.
call method O_BDC->FILL_FIELDS
exporting
IM_FNAM = 'BNKA-BANKA'
IM_FVAL = WA_FI01-BANKA
IMPORTING
IT_PROCEDURE = IT_BDCDATA.
*
call transaction 'FI01' using IT_BDCDATA mode 'A'.
*call method O_BDC->CALL_TRANSACTION
*
exporting
*
IM_TCODE = 'FI01'
*
IM_DMODE = 'A'
*
IMPORTING
*
IM_PROCEDURE = IT_BDCDATA
*
.
*
call function 'BDC_INSERT'
EXPORTING
TCODE = 'FI01'
*
POST_LOCAL = NOVBLOCAL
*
PRINTING = NOPRINT
*
SIMUBATCH = ' '
*
CTUPARAMS = ' '
tables
DYNPROTAB =
IT_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.
WRITE:/ 'SESSION INSERT SUCESSFULLY'.
endif.
endloop.
call function 'BDC_CLOSE_GROUP'
*
EXCEPTIONS
*
NOT_OPEN = 1
*
QUEUE_ERROR = 2
*
OTHERS = 3
.
if SY-SUBRC = 0.
WRITE:/ 'SESSION CLOSE SUCESSFULLY'.
endif.
SNAP SHOTS
IN THE ABOVE I AM USING THE INHEARTED CONSCAPT.
THE SUPER CLASS NAME IS : ZGDEMO_COMMON_BDC_RAJ
AND SUB CLASS NAME IS
: ZGDEMO_INSERT_BDC_RAJ
THE CODE OF METHOD ‘UPLOAD_FILE’ FROM ‘SUPER CLASS’
method UPLOAD_FILE.
call function 'GUI_UPLOAD'
exporting
FILENAME =
'c:\fi01.txt'
*
FILETYPE =
'ASC'
HAS_FIELD_SEPARATOR =
'X'
*
HEADER_LENGTH = 0
*
READ_BY_LINE =
'X'
*
DAT_MODE = '
'
*
CODEPAGE = '
'
*
IGNORE_CERR = ABAP_TRUE
*
REPLACEMENT =
'#'
*
CHECK_BOM = '
'
*
IMPORTING
*
FILELENGTH =
*
HEADER =
TABLES
DATA_TAB =
IT_DATA
*
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.
WRITE:/ 'UPLOAD THE FILE SUCESSFULLY'.
endif.
endmethod.
METHOD FILL_DYNPRO
METHOD FILL_FIELDS
THESE ALL METHODE FROM SUPER CLASS.
IN SUB CLASS
METHOD CALL_TRANSACTION
THEN I WANT TO CREATE ANOTHER SUB CLASS FOR IMPLEMENTATION
FOR SESSION METHOD.
THE CLASS NAME IS ‘ZGDEMO_SESSION_BDC_RAJ’
FOR SESSION METHODE
THE SUPER CLASS IS : ZGDEMO_COMMON_BDC_RAJ