0% found this document useful (0 votes)
79 views4 pages

BDC

The document describes how to upload bank data from a file into SAP using transaction code FI01. It defines internal tables to store the bank and BDC data, calls the GUI_UPLOAD function to import the file, then uses a loop to populate the BDC table by calling subroutines to add dynamic screen and field entries and submit the transaction.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views4 pages

BDC

The document describes how to upload bank data from a file into SAP using transaction code FI01. It defines internal tables to store the bank and BDC data, calls the GUI_UPLOAD function to import the file, then uses a loop to populate the BDC table by calling subroutines to add dynamic screen and field entries and submit the transaction.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

report ZBDC

no standard page heading line-size 255.


*include bdcrecx1.

TYPES : BEGIN OF TY_BANK,


BANKS TYPE BANKS,
BANKL TYPE BANKL,
BANKA TYPE BANKA,
STRAS TYPE STRAS,
ORT01 TYPE ORT01,
BRNCH TYPE BRNCH,
END OF TY_BANK.

DATA : IT_BANK TYPE TABLE OF TY_BANK,


Wa_BANK TYPE TY_BANK.

DATA : IT_BDCDATA TYPE TABLE OF BDCDATA, "BDC DATA IS MANDATORY."


WA_BDCDATA TYPE BDCDATA. "FOR BDC DATA WE DECLARE INTERNAL TABLE
AND WPk AREA."

***parameters: dataset(132) lower case.


*** DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
*
* If it is nessesary to change the data section use the rules:
* 1.) Each definition of a field exists of two lines
* 2.) The first line shows exactly the comment
* '* data element: ' followed with the data element
* which describes the field.
* If you don't have a data element use the
* comment without a data element name
* 3.) The second line shows the fieldname of the
* structure, the fieldname must consist of
* a fieldname and optional the character '_' and
* three numbers and the field length in brackets
* 4.) Each field must be type C.
*
* Generated data section with specific formatting - DO NOT CHANGE ***
*data: begin of record,
*data element: BANKS
* BANKS_001(003),
* data element: BANKK
* BANKL_002(015),
* data element: BANKA
* BANKA_003(060),
* data element: REGIO
* PROVZ_004(003),
* data element: STRAS_GP
* STRAS_005(035),
* data element: ORT01_GP
* ORT01_006(035),
* data element: BRNCH
* BRNCH_007(040),
* end of record."'

*** End generated data section ***

start-of-selection.
*DATA FILENAME TYPE STRING.
*DATA FILETYPE TYPE CHAR10.
*DATA HAS_FIELD_SEPARATOR TYPE CHAR01.
*DATA HEADER_LENGTH TYPE I.
*DATA READ_BY_LINE TYPE CHAR01.
*DATA DAT_MODE TYPE CHAR01.
*DATA CODEPAGE TYPE ABAP_ENCODING.
*DATA IGNORE_CERR TYPE ABAP_BOOL.
*DATA REPLACEMENT TYPE ABAP_REPL.
*DATA CHECK_BOM TYPE CHAR01.
*DATA VIRUS_SCAN_PROFILE TYPE VSCAN_PROFILE.
*DATA NO_AUTH_CHECK TYPE CHAR01.
*DATA FILELENGTH TYPE I.
*DATA HEADER TYPE XSTRING.
*DATA ISSCANPERFORMED TYPE CHAR01.

CALL FUNCTION 'GUI_UPLOAD'


EXPORTING
filename = 'D:\sskk\sample.txt'
* 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 = VIRUS_SCAN_PROFILE
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH = FILELENGTH
* HEADER = HEADER
TABLES
data_tab = IT_BANK
* 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
.

if sy-subrc = 0 .
message 'data uploaded successfully' TYPE 'I'.
endif.
"perform open_dataset using dataset.
*perform open_group.

"do.

"read dataset dataset into record.


"if sy-subrc <> 0. exit. endif.

LOOP AT IT_BANK INTO WA_BANK.

perform bdc_dynpro using 'SAPMF02B' '0100'.


perform bdc_field using 'BDC_CURSOR'
'BNKA-BANKL'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BNKA-BANKS'
WA_BANK-BANKS.
perform bdc_field using 'BNKA-BANKL'
WA_BANK-BANKL.
perform bdc_dynpro using 'SAPMF02B' '0110'.
perform bdc_field using 'BDC_CURSOR'
'BNKA-BRNCH'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'BNKA-BANKA'
WA_BANK-BANKA.
"perform bdc_field using 'BNKA-PROVZ'
" WA_BANK-PROVZ.
perform bdc_field using 'BNKA-STRAS'
WA_BANK-STRAS.
perform bdc_field using 'BNKA-ORT01'
WA_BANK-ORT01.
perform bdc_field using 'BNKA-BRNCH'
WA_BANK-BRNCH.

"perform bdc_transaction using 'FI01'.

"perform bdc_dynpro using 'SAPMF02B' '0100'.


"perform bdc_field using 'BDC_OKCODE'
" '/EF03'.
"perform bdc_field using 'BDC_CURSOR'
" 'BNKA-BANKS'.

CALL TRANSACTION 'FI01' using IT_BDCDATA MODE 'A' UPDATE 'S'.


REFRESH IT_BDCDATA.
*perform close_group.
"enddo.
ENDLOOP.

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.

"perform close_dataset using dataset.

You might also like