BDC & File Handling
-
Upload
srikanth-sarguneswaran -
Category
Documents
-
view
226 -
download
0
Transcript of BDC & File Handling
-
8/10/2019 BDC & File Handling
1/83
Batch Data Communication
-
8/10/2019 BDC & File Handling
2/83
Batch Data Communication
Objective:
Batch Data Communication
Types of BDC and differences between them
File Handling in !" both on application
server and presentation server#
-
8/10/2019 BDC & File Handling
3/83
Batch Data Communication
Definition :
Batch Data Communication $BDC% is the process of
transferring data from one !" ystem to another !"
system or from a non&!" system to !" ystem#
-
8/10/2019 BDC & File Handling
4/83
Batch Data Communication
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 !"
system and when transferring data from a legacy
system $e'ternal system%#
BDC uses normal transaction codes to transfer data#
-
8/10/2019 BDC & File Handling
5/83
Batch Data Communication
Types of BDC :
C(!)C!( B!TCH )*"+T $ession ,ethod%
C!(( T-!*!CT)O*
-
8/10/2019 BDC & File Handling
6/83
Batch Data Communication
B!TCH )*"+T ,.THOD:
This method is also called as /C(!)C!( ,.THOD0#
Features:
!synchronous processing#
ynchronous "rocessing in database update#
Transfer data for more than one transaction#
Batch input processing log will be generated# During processing1 no transaction is started until the
previous transaction has been written to the database#
-
8/10/2019 BDC & File Handling
7/83
Batch Data Communication
Batch )nput "rocessing
2ueue file2ueue file
e3uentialfile
Batch input programBatch input program
Batch input functionBatch input function
!" -45!" -45!" -45
CustomerCustomerdatadata
FlightFlightconnectionsconnections -eservation-eservation
datadata
-
8/10/2019 BDC & File Handling
8/83
-
8/10/2019 BDC & File Handling
9/83
Uses of batch input Transferring data from another system when you install
your !" ystem
-egularly transferring data that is captured by a non&!"
system in your company into the !" ystem#
-
8/10/2019 BDC & File Handling
10/83
Classical Batch Input "rogram reads the e'ternal data that is to be entered in the
!" ystem and stores the data in a 6batch&input
session#6#
essions then can be run either in Foreground or in
Bac7ground mode#
Function modules BDC8O".*1 BDC8)*.-T1 and
BDC8C(O. are used to generate sessions#
-
8/10/2019 BDC & File Handling
11/83
-
8/10/2019 BDC & File Handling
12/83
How to create session Open the batch input session using function module
BDC8O".*89-O+" #
For each transaction in the session:
Fill the BDCDATA structure with values for allscreens and fields that must be processed.
Transfer the transaction to the session with
BDCI!"#$T .
Close the session with BDC8C(O.89-O+"#
-
8/10/2019 BDC & File Handling
13/83
Call Transaction "rogram uses the !B!"4 C!(( T-!*!CT)O* +)*9
statement to run an !" transaction# Batch&input data
does not have to be deposited in a session for later
processing# )nstead1 the entire batch&input process ta7esplace inline in your program#
-
8/10/2019 BDC & File Handling
14/83
-
8/10/2019 BDC & File Handling
15/83
Call Transaction contd C!(( T-!*!CT)O* ;
-
8/10/2019 BDC & File Handling
16/83
"teps Involved !naly=e the data that is to be transferred to the !"
ystem#
Code data transfer program# >ou can write the program in
!B!"4 or as an e'ternal program# .'port the data that is to be transferred to a se3uential file#
-
8/10/2019 BDC & File Handling
17/83
-
8/10/2019 BDC & File Handling
18/83
-
8/10/2019 BDC & File Handling
19/83
"teps Involved contd.
)f necessary1 code the !B!"4 batch input program that will
read in the data to be transferred from your file $!" supplies
ready&to&run batch&input programs for most of the !" applications#%
"rocess the data and add it to the !" ystem either by a
batch&input session or directly using C!((
T-!*!CT)O*
-
8/10/2019 BDC & File Handling
20/83
"teps Involved contd. Chec7 that all data has been successfully processed#
Correct and re&process erroneous data
*ou can use the batch+input mana,ement
function to process erroneous transactions
interactivel-. *ou can correct data durin, this
interactive processin,.
-
8/10/2019 BDC & File Handling
21/83
ritin, a Transfer )ro,ram !naly=e the structure of your e'isting data and specify the
conversions that are re3uired to fill the !" data
structures#
9enerate the !" data structure in code form and insert it
into your program#
)f the program is written in !B!"41 you need only include
the re3uired tables in your program with the T!B(.
statement#
-
8/10/2019 BDC & File Handling
22/83
ritin, a Transfer )ro,ram
contd. )nitiali=e the !" data structure#
Fill the structure with data1 performing any conversions
and error&chec7ing that are re3uired#
?rite the se3uential file that is typically re3uired for ma7ingthe data available to the batch input program in the !"
ystem#
-
8/10/2019 BDC & File Handling
23/83
Direct )nput
To enhance the batch input procedure, the system offers thedirect input technique, especially for transferring large
amounts of data.
No sessions are created
Stores the data directly into SAP tables
It does not process screens.
The system calls a number of function modules for
necessary data checks.
In case of errors, restart mechanism is aailable
-
8/10/2019 BDC & File Handling
24/83
!"amples for direct input programs are#
Program Application
$%&I&'(( %I
$)*ATIN* ))
$+A%SS(( S*
$AA'T* A)
$-!+!T( /01PA
-
8/10/2019 BDC & File Handling
25/83
Batch Data Communication
-ecording $Transaction code HDB%
-ecording is a process that is provided by the !" system
to generate the !" data structure for batch data
communication#
! sample recording for the transaction ,@A is e'plained
below#
-
8/10/2019 BDC & File Handling
26/83
Batch Data Communication
-ecording tep :
tarting screen of the recording $Transaction code HDB%
/lick 2Ne3 $ecording4 button to ne3 recording.
-
8/10/2019 BDC & File Handling
27/83
Batch Data Communication
-ecording tep : .nter the recording name and thetransaction
for which you want the recording and clic7 tart
-ecordingE Button#
-
8/10/2019 BDC & File Handling
28/83
Batch Data Communication
-ecording tep 5: .nter sample data for the transaction#
.very 7ey stro7e will be recorded#
-
8/10/2019 BDC & File Handling
29/83
Batch Data Communication
-ecording tep : !fter entering all data for the transaction
$here ,@A%1 the recording overview screen will be
displayed# Then save the recording# !nd clic7 the "rogramEbutton#
-
8/10/2019 BDC & File Handling
30/83
Batch Data Communication
-ecording tep : .nter the program name #
-
8/10/2019 BDC & File Handling
31/83
Batch Data Communication
-ecording tep G: .nter the program attributes#
Clic7 ource CodeE Button#
-
8/10/2019 BDC & File Handling
32/83
Batch Data Communication
!nd the code generated was as below# ".-FO-, BDC8D>*"-O +)*9 ;!",FA@; ;AA;#
".-FO-, BDC8F).(D +)*9 ;BDC8C+-O-; ;-FA@&@TO@@;# ".-FO-, BDC8F).(D +)*9 ;[email protected] ;4AA;#
".-FO-, BDC8F).(D +)*9 ;-FA@&()F*-0 -.CO-D&()F*-8AA#
".-FO-, BDC8F).(D +)*9 ;-FA@&@TO@@0 -.CO-D&@TO@@8AA#
".-FO-, BDC8D>*"-O +)*9 ;!",FA@; ;AA;#
".-FO-, BDC8F).(D +)*9 ;BDC8C+-O-0 ;(F!&O-T(;#
".-FO-, BDC8F).(D +)*9 ;[email protected] ;4AA;#
".-FO-, BDC8F).(D +)*9 ;(F!&*!,.0 -.CO-D&*!,.8AA5# ".-FO-, BDC8F).(D +)*9 ;(F!&O-T(0 -.CO-D&O-T(8AA#
".-FO-, BDC8F).(D +)*9 ;(F!&(!*D; -.CO-D&(!*D8AA#
".-FO-, BDC8F).(D +)*9 ;(F!&"-!; -.CO-D&"-!8AAG#
".-FO-, BDC8D>*"-O +)*9 ;!",FA@; ;AA;#
".-FO-, BDC8F).(D +)*9 ;BDC8C+-O- ;(F!&@+**-;#
".-FO-, BDC8F).(D +)*9 ;[email protected] ;4AA;# ".-FO-, BDC8D>*"-O +)*9 ;!",FA@; ;A5A;#
".-FO-, BDC8F).(D +)*9 ;BDC8C+-O-0 ;(FB@&B!*@$A%;#
".-FO-, BDC8F).(D +)*9 ;[email protected] ;I.*T-;#
".-FO-, BDC8D>*"-O +)*9 ;!"("O; ;A5AA;#
".-FO-, BDC8F).(D +)*9 ;[email protected] ;I>.;#
".-FO-, BDC8T-!*!CT)O* +)*9 ;,@A;#
-
8/10/2019 BDC & File Handling
33/83
Batch Data Communication
ample BDC "rogram $ession ,ethod%:
-."O-T Jreport#D!T!: )8BDCD!T! ()@. BDCD!T! OCC+- A ?)TH H.!D.- ()*.#
D!T!: B.9)* OF -.CO-D OCC+- A1 Declaration of the data that is to be uploaded fromthe file
()F*-8AA$AG%1
@TO@@8AA$AA%1
*!,.8AA5$A5%1
O-T(8AA$AA%1
(!*D8AA$AA5%1
"-!8AAG$AA%1 .*D OF -.CO-D#
T!-T&OF&.(.CT)O*#
".-FO-, O".*89-O+"#
K+ploading data from the local file C:LMendor#t't
C!(( F+*CT)O* ;?8+"(O!D;
.&+B-C N A#
?-)T. ;.--O- )* +"(O!D;#
.*D)F#
-
8/10/2019 BDC & File Handling
34/83
Batch Data Communication
ample BDC "rogram $Continues%:(OO" !T -.CO-D# Filling the BDC table with data
".-FO-, BDC8D>*"-O +)*9 ;!",FA@; ;AA;#
".-FO-, BDC8F).(D +)*9 ;BDC8C+-O-;
;-FA@&@TO@@;#
".-FO-, BDC8F).(D +)*9 ;BDC8O@COD.;
;4AA;#
".-FO-, BDC8F).(D +)*9 ;-FA@&()F*-;
-.CO-D&()F*-8AA#
".-FO-, BDC8F).(D +)*9 ;-FA@&@TO@@; -.CO-D&@TO@@8AA#
".-FO-, BDC8D>*"-O +)*9 ;!",FA@; ;AA;#
".-FO-, BDC8F).(D +)*9 ;BDC8C+-O-;
;(F!&O-T(;#
".-FO-, BDC8F).(D +)*9 ;BDC8O@COD.;
;4AA;#
".-FO-, BDC8F).(D +)*9 ;(F!&*!,.; -.CO-D&*!,.8AA5#
".-FO-, BDC8F).(D +)*9 ;(F!&O-T(;
-.CO-D&O-T(8AA#
".-FO-, BDC8F).(D +)*9 ;(F!&(!*D;
-.CO-D&(!*D8AA#
-
8/10/2019 BDC & File Handling
35/83
Batch Data Communication
ample BDC "rogram $Continues%:
".-FO-, BDC8F).(D +)*9 ;(F!&"-!;
-.CO-D&"-!8AAG#
".-FO-, BDC8D>*"-O +)*9 ;!",FA@; ;AA;#
".-FO-, BDC8F).(D +)*9 ;BDC8C+-O-;
;(F!&@+**-;#
".-FO-, BDC8F).(D +)*9 ;BDC8O@COD.;
;4AA;#
".-FO-, BDC8D>*"-O +)*9 ;!",FA@; ;A5A;#
".-FO-, BDC8F).(D +)*9 ;BDC8C+-O-; ;(FB@&B!*@$A%;#
".-FO-, BDC8F).(D +)*9 ;BDC8O@COD.;
;I.*T-;#
".-FO-, BDC8D>*"-O +)*9 ;!"("O; ;A5AA;#
".-FO-, BDC8F).(D +)*9 ;BDC8O@COD.;
;I>.;#
".-FO-, BDC8T-!*!CT)O* +)*9 ;,@A;#
.*D(OO"#
".-FO-, C(O.89-O+"# Closing the BDC session
C
-
8/10/2019 BDC & File Handling
36/83
Batch Data Communication
ample BDC "rogram $Continues%:
FO-, O".*89-O+"#
C!(( F+*CT)O* ;BDC8O".*89-O+";
.&+*!,.
@.." I ;&+B-C N A#
?-)T. ;.--O- )* O".*89-O+";#.*D)F#
.*DFO-,#
FO-, BDC8D>*"-O +)*9 "-O9-!, D>*"-O#
C(.!- )8BDCD!T!#
)8BDCD!T!&"-O9-!, I "-O9-!,#
)8BDCD!T!&D>*"-O I D>*"-O# )8BDCD!T!&D>*B.9)* I ;
-
8/10/2019 BDC & File Handling
37/83
Batch Data Communication
ample BDC "rogram $Continues%:
FO-, BDC8F).(D +)*9 F*!, FM!(# C(.!- )8BDCD!T!#
)8BDCD!T!&F*!, I F*!,#
)8BDCD!T!&FM!( I FM!(#
!"".*D )8BDCD!T!#
.*DFO-,#
FO-, BDC8T-!*!CT)O* +)*9 TCOD.#C!(( F+*CT)O* ;BDC8)*.-T;
.
-
8/10/2019 BDC & File Handling
38/83
Batch Data Communication
ession Overview creen $Transaction Code : ,5%
.'ample transaction is ,@A$Mendor Creation%
Clic7 "rocessE Button
B t h D t C i ti
-
8/10/2019 BDC & File Handling
39/83
Batch Data Communication
.nter the processing options $li7e Foreground4 Bac7ground
etc##%
B t h D t C i ti
-
8/10/2019 BDC & File Handling
40/83
Batch Data Communication
Foreground "rocessing:
First screen of the transaction ,@A$Mendor Creation%
B t h D t C i ti
-
8/10/2019 BDC & File Handling
41/83
Batch Data Communication
econd screen of the Transaction ,@A $Mendor Creation%
Batch Data Comm nication
-
8/10/2019 BDC & File Handling
42/83
Batch Data Communication
(ast creen of the Transaction ,@A $Mendor Creation%:
Batch Data Communication
-
8/10/2019 BDC & File Handling
43/83
Batch Data Communication
"rompt for aving the record:Here O@8COD. I >.
Batch Data Communication
-
8/10/2019 BDC & File Handling
44/83
Batch Data Communication
!fter processing the session1 the status of the session is
"rocessedE
Batch Data Communication
-
8/10/2019 BDC & File Handling
45/83
Batch Data Communication
C!(( T-!*!CT)O* ,.THOD :
This is another method to transfer data from the legacysystem#
Features:
ynchronous processing# The system performs a database
commit immediately before and after the C!((
T-!*!CT)O* +)*9 statement#
+pdating the database can be either synchronous or
asynchronous# The program specifies the update type#
Transfer data for a single transaction#
Transfers data for a se3uence of dialog screens#
*o batch input processing log is generated#
Batch Data Communication
-
8/10/2019 BDC & File Handling
46/83
Batch Data Communication
The C!(( T-!*!CT)O* tatement
C!(( T-!*!CT)O* Ntransaction code
+)*9 NBDC table
,OD. Ndisplay mode
+"D!T. Nupdate mode
,.!9. )*TO Nmesstab
C!(( T-!*!CT)O* Ntransaction code
+)*9 NBDC table ,OD. Ndisplay mode +"D!T. Nupdate mode ,.!9. )*TO Nmesstab
! Display all
. Display only if there are errors
* Display nothing
! Display all
. Display only if there are errors
* Display nothing
Do not continue processing until
update has finished $synchronous%
! Continue processing immediately
Do not continue processing untilupdate has finished $synchronous%
! Continue processing immediately
Ndisplay mode:Ndisplay mode:Ndisplay mode:
Nupdate mode:Nupdate mode:Nupdate mode:
Batch Data Communication
-
8/10/2019 BDC & File Handling
47/83
Batch Data Communication
ample "rogram $C!(( T-!*!CT)O*%:-."O-T J-."O-T#
D!T!: )8BDCD!T! ()@. BDCD!T! OCC+- A ?)TH H.!D.- ()*.#D!T!: B.9)* OF -.CO-D OCC+- A1
()F*-8AA$AG%1
@TO@@8AA$AA%1
*!,.8AA5$A5%1
O-T(8AA$AA%1
(!*D8AA$AA5%1
"-!8AAG$AA%1 .*D OF -.CO-D#
T!-T&OF&.(.CT)O*#
K+ploading data from the local file C:LMendor#t't
C!(( F+*CT)O* ;?8+"(O!D;
.&+B-C N A#
?-)T. ;.--O- )* +"(O!D;#
.*D)F#
Batch Data Communication
-
8/10/2019 BDC & File Handling
48/83
Batch Data Communication
ample "rogram $C!(( T-!*!CT)O*%:(OO" !T -.CO-D#
".-FO-, BDC8D>*"-O +)*9 ;!",FA@; ;AA;#
".-FO-, BDC8F).(D +)*9 ;BDC8C+-O-; ;-FA@&@TO@@;#
".-FO-, BDC8F).(D +)*9 ;[email protected] ;4AA;#
".-FO-, BDC8F).(D +)*9 ;-FA@&()F*-0 -.CO-D&()F*-8AA#
".-FO-, BDC8F).(D +)*9 ;-FA@&@TO@@0 -.CO-D&@TO@@8AA#
".-FO-, BDC8D>*"-O +)*9 ;!",FA@; ;AA;#
".-FO-, BDC8F).(D +)*9 ;BDC8C+-O-0 ;(F!&O-T(;#
".-FO-, BDC8F).(D +)*9 ;[email protected] ;4AA;#
".-FO-, BDC8F).(D +)*9 ;(F!&*!,.0 -.CO-D&*!,.8AA5# ".-FO-, BDC8F).(D +)*9 ;(F!&O-T(0 -.CO-D&O-T(8AA#
".-FO-, BDC8F).(D +)*9 ;(F!&(!*D; -.CO-D&(!*D8AA#
".-FO-, BDC8F).(D +)*9 ;(F!&"-!; -.CO-D&"-!8AAG#
".-FO-, BDC8D>*"-O +)*9 ;!",FA@; ;AA;#
".-FO-, BDC8F).(D +)*9 ;BDC8C+-O- ;(F!&@+**-;#
".-FO-, BDC8F).(D +)*9 ;[email protected] ;4AA;#
".-FO-, BDC8D>*"-O +)*9 ;!",FA@; ;A5A;# ".-FO-, BDC8F).(D +)*9 ;BDC8C+-O-0 ;(FB@&B!*@$A%;#
".-FO-, BDC8F).(D +)*9 ;[email protected] ;I.*T-;#
".-FO-, BDC8D>*"-O +)*9 ;!"("O; ;A5AA;#
".-FO-, BDC8F).(D +)*9 ;[email protected] ;I>.;#
".-FO-, BDC8T-!*!CT)O* +)*9 ;,@A;#
.*D(OO"#
Batch Data Communication
-
8/10/2019 BDC & File Handling
49/83
Batch Data Communication
ample "rogram $C!(( T-!*!CT)O*%:
FO-, BDC8D>*"-O +)*9 "-O9-!, D>*"-O#
C(.!- )8BDCD!T!#
)8BDCD!T!&"-O9-!, I "-O9-!,# )8BDCD!T!&D>*"-O I D>*"-O#
)8BDCD!T!&D>*B.9)* I ;
-
8/10/2019 BDC & File Handling
50/83
Batch Data Communication
Batch )nput 4 C!(( T-!*!CT)O* & Comparision
Batch input C!(( T-!*!CT)O*
-eturn code *o >es
.rror logging >es *o
"rocessing Time&delayed )mmediately
ession C!(( T-!*!CT)O*
-eturn code *o >es
Database +pdate ynchronous !synchronous4ynchronous
"rocessing Time&delayed )mmediately
Transactions ,ore than one Only One
.rror (og ?ill be created?ill not becreated
File Handling in !"
-
8/10/2019 BDC & File Handling
51/83
File Handling in !"
!B!"4 allows us to wor7 with se3uential files
on the !pplication server
on the "resentation server
-
8/10/2019 BDC & File Handling
52/83
or/in, with files on
Application server )nternal Table
A S
READ DATASET
TRANSFER
-
8/10/2019 BDC & File Handling
53/83
or/in, with files on
)resentation server )nternal Table
P S
UPLOAD
DOWNLOAD
File Handling in !"
-
8/10/2019 BDC & File Handling
54/83
File Handling in !"
?O-@)*9 ?)TH F)(. O* TH. !""()C!T)O* .-M.-:
!B!"4 provides three statements for handling files:
O".* D!T!.T
C(O. D!T!.T
D.(.T. D!T!.T
-.!D D!T!.T
T-!*F.-
File Handling in !"
-
8/10/2019 BDC & File Handling
55/83
File Handling in !"
O".* D!T!.T
Opens the specified file# )f you do not use any additions1the file is opened for reading in binary mode# )t returns
>&+B-C I A if the file is opened successfully#
Otherwise >&+B-C I P#
File Handling in !"
-
8/10/2019 BDC & File Handling
56/83
File Handling in !"
ynta'
O".* D!T!.T Ndsn Q!dditionsR#
!dditions:
# FO- )*"+T $ Default %
# FO- O+T"+T
5# FO- !"".*D)*9
# )* B)*!-> ,OD.
# )* T.
-
8/10/2019 BDC & File Handling
57/83
File Handling in !"
# O".* D!T!.T Ndsn FO- )*"+T#
This statement tries to open the field in ;read4update; mode
$as long as the user has write authori=ation%#)f the user does
not have write authori=ation1 the system opens the file in
;read; mode# )f this fails1 an error occurs#
# O".* D!T!.T Ndsn FO- O+T"+T#
This statement tries to open the file in ;write4update; mode
as long as the user has read authori=ation# )f the
authori=ation is missing1 the system opens the file in ;write;mode# )f the file already e'ists1 its e'isting content is
deleted# )f the file does not e'ist1 the system creates it#
File Handling in !"
-
8/10/2019 BDC & File Handling
58/83
File Handling in !"
5# O".* D!T!.T Ndsn FO- !"".*D)*9#
This statement tries to open the file in ;append; mode# )f the
file is already open1 the system moves to the end of the file#
?hen you open a file using FO- !"".*D)*91 attempting to
read the file sets >&+B-C to # The system display the
end of the file#
*ote :
>ou can only use one of the additions to 5 in a singlestatement
File Handling in !"
-
8/10/2019 BDC & File Handling
59/83
g
# O".* D!T!.T Ndsn )* B)*!-> ,OD.#
The contents of the file are not structured in lines in the-.!D D!T!.T or T-!*F.- operations# )nstead1 they are
input or output as a stream# >ou do not have to specify the
)* B)*!-> ,OD. addition e'plicitly#
# O".* D!T!.T Ndsn )* T.ou can only use one of additions and in a single
statement#
File Handling in !"
-
8/10/2019 BDC & File Handling
60/83
g
G# O".* D!T!.T Ndsn !T "O)T)O* p#
+se this addition to specify the e'plicit starting position p inthe file $calculated in bytes from the start of the file%# The
ne't read or write operation will start at this position# >ou
cannot position before the beginning of the file# Do not use
this addition with the )* T.
-
8/10/2019 BDC & File Handling
61/83
g
# O".* D!T!.T Ndsn T>". ctrl #
>ou can use the ctrl field to specify further file attributes#
The contents of this field are passed unchanged and
unchec7ed to the operating system# The synta' for the
attributes is dependent on the operating system#
P# O".* D!T!.T Ndsn ,.!9. msg#
)f an error occurs while the file is being opened1 thecorresponding operating system message is placed in field
msg#
.'ample
D!T!: dsn$A% M!(+. ;4usr4test#dat;1
msg$AA%#O".* D!T!.T dsn FO- )*"+T ,.!9. msg#
)F sy&subrc N A#
?-)T. 4 msg#
.*D)F#
File Handling in !"
-
8/10/2019 BDC & File Handling
62/83
g
S# O".* D!T!.T NdsnFILTER f.
)f you are wor7ing under +*)< or ?indows *T1 you can
specify an operating system command in the field f#
.'ample
+nder +*)
-
8/10/2019 BDC & File Handling
63/83
g
C(O. D!T!.T
Closes the specified file#
ynta'
C(O. D!T!.T Ndsn#
D.(.T. D!T!.T
Deletes the file specified file# )f it deletes the file
successfully it returns >&+B-C I A# Otherwise returns >&
+B-C I # The possible reasons for failing are:
The file does not e'ist# The file is a directory# The file is a program that is currently running#
File Handling in !"
-
8/10/2019 BDC & File Handling
64/83
g
-.!D D!T!.T
+sed to read a record from a file#
ynta'
-.!D D!T!.T dsn )*TO f#
!ddition : (.*9TH len#
The actual length of the data objet read is placed in the field
len after the read access# len must be defined as a variable#
! synta' error will occur if you define it as a constant# The
following e'ample displays S#.'ample
D!T!: len T>". i1
te't$5A% T>". c M!(+. ;Beethoven;1
dir$5A% T>". c M!(+. ;4usr4test#dat;#
O".* D!T!.T dir )* T.
-
8/10/2019 BDC & File Handling
65/83
T-!*F.- statement
+sed to write a record into a file#
ynta'
T-!*F.- f TO dsn#
Transfers the data object f to a se3uential file whose nameis specified in dsn# dsn can be a field or a literal# >ou must
already have opened the file# # )f the specified file is not
already open1 T-!*F.- attempts to open the file FO-
O+T"+T )* B)*!-> ,OD.# )f this is not possible1 a runtime
error occurs#f can be a field1 a string1 or a structure#
File Handling in !"
-
8/10/2019 BDC & File Handling
66/83
!ddition : (.*9TH len#
The length of the data object to be written is defined by len1
where len can be either a constant or a variable# )f len is
smaller than the length of the data object f1 the systemtruncates character fields $C1 *1 D1 T1
-
8/10/2019 BDC & File Handling
67/83
?O-@)*9 ?)TH F)(. O* TH. "-..*T!T)O* .-M.-:
To wor7 with files on the presentation server 1 !"provides some special function modules ?8+"(O!D1
for reading from a file1 and ?8DO?*(O!D1 for writing
into the file# !n internal table must be used as an
interface between the program and the function module#
File Handling in !"
-
8/10/2019 BDC & File Handling
68/83
?riting data to a file on the presentation server:
To write data from an internal table to a file on the
presentation server1 use function module ?8DO?*(O!D#
The most important parameters that are e'ported are as
follows:
B)*8F)(.)J.
File (ength for binary files# ! length of =ero or the length
which is larger than the number of bytes in the internal table
$width K number of lines% causes an e'ception#
File Handling in !"
-
8/10/2019 BDC & File Handling
69/83
COD."!9.
Only for download in DO
F)(.*!,.
The name of the file that is to be generated on thepresentation server$ if necessary with predefined path
name%# )f the path doesn0t e'ist or the file cannot be opened1
an e'ception will be raised#
File Handling in !"
-
8/10/2019 BDC & File Handling
70/83
F)(.T>".
The target format of the file# Malid values are:
/!C0 : !C)) format1 the table is stored with rows#/D!T0: !C)) format as in ;!C;1 additional column
separation with T!Bs#
/B)*0 : Binary format $specification of B)*8F)(.)J.
re3uired%
/DBF0 : tored as Dbase file $always with DO codepage%#
/)B,0 : !C)) format as in ;!C; with )B, code page
conversion $DO%
,OD.
?riting mode $ /!0 I !ppend 1 empty I Overwrite%
F)(.(.*9TH
The length of the generated file is returned#
File Handling in !"
-
8/10/2019 BDC & File Handling
71/83
T!B(. "!-!,.T.-
D!T!8T!B
The source internal table whose contents aredownloaded into a file#
.
-
8/10/2019 BDC & File Handling
72/83
-eading data from a file on the presentation server:
To read data from the presentation server into an internal tablewe use the function module ?8+"(O!D# The most important
parameters that are e'ported are as follows:
COD."!9.
Only for download in DO#
File Handling in !"
-
8/10/2019 BDC & File Handling
73/83
F)(.*!,.
*ame of the file
F)(.T>".The source file type# Malid values are:
/B)*0 : Binary files#
/!C0: !C)) files1 te't files with end&of&line mar7ers#
/D!T0: The file is loaded line by line into the transferred
table# Tabs in the file mean a change of field#
File Handling in !"
-
8/10/2019 BDC & File Handling
74/83
.'port "arameters for ?8+"(O!D:
F)(.(.*9TH & *umber of bytes transferred#
Table parameters for ?8+"(O!D:
D!T!8T!B & )nternal target table1 to which the data is
loaded#
.'ceptions for ?8+"(O!D:
CO*M.-)O*8.--O- & .rrors in the data conversion#
F)(.8O".*8.--O- & ystem cannot open file#
F)(.&-.!D8.--O- & ystem cannot read from file)*M!()D8T!B(.8?)DTH & )nvalid table structure
)*M!()D8T>". & )nvalid value for parameter
F)(.T>".
File Handling in !"
-
8/10/2019 BDC & File Handling
75/83
ummary
Batch Data Communication $BDC% is the process of
transferring data from one !" ystem to another !"
system or from a non&!" system to !" ystem#
Two methods of BDCs are there# ession method and C!((
T-!*!CT)O* method#
File Handling in !"
-
8/10/2019 BDC & File Handling
76/83
?or7ing with files on application server and presentation
server#
!B!"4 statements O".* D!T!.T1 -.!D D!T!.T1
D.(.T. D!T!.T1 C(O. D!T!.T1 T-!*F.-#
!nd special function modules for reading and writing data
files on presentation server1 ?8+"(O!D and
?8DO?*(O!D#
Batch Data Communication
-
8/10/2019 BDC & File Handling
77/83
.'ercise:
?rite a batch input program for transaction ,,A using
following data from a local file#(ength of the each field is
also given#
,aterial ,aterial Basic Data Basic Data Description +nit
Of
type 9roup
,easure
$% $% $% $% $A%
$5%
, BOH < < ,aterial@9
Batch Data Communication
-
8/10/2019 BDC & File Handling
78/83
olution :
-."O-T J-."O-T#D!T!: )8BDCD!T! ()@. BDCD!T! OCC+- A ?)TH H.!D.- ()*.#
D!T!: B.9)* OF -.CO-D OCC+- A1,B-H8AA$AA%1
,T!-T8AA$AA%1
@J.(8A8AA5$AA%1
@J.(8A8AA$AA%1
,!@T
-
8/10/2019 BDC & File Handling
79/83
olution $Continues%:
)F >&+B-C N A# ?-)T. ;.--O- )* +"(O!D;#
.*D)F#".-FO-, O".*89-O+"#
(OO" !T -.CO-D# ".-FO-, BDC8D>*"-O +)*9 ;!"(,9,,; ;AAGA;# ".-FO-, BDC8F).(D +)*9 ;BDC8C+-O-; ;-,,9&,T!-T;#
".-FO-, BDC8F).(D +)*9 ;BDC8O@COD.; ;4AA;# ".-FO-, BDC8F).(D +)*9 ;-,,9&,B-H; -.CO-D&,B-H8AA# ".-FO-, BDC8F).(D +)*9 ;-,,9&,T!-T; -.CO-D&,T!-T8AA#
".-FO-, BDC8D>*"-O +)*9 ;!"(,9,,; ;AAA;# ".-FO-, BDC8F).(D +)*9 ;BDC8C+-O-; ;,)CHT!+?&D>T
-
8/10/2019 BDC & File Handling
80/83
olution $Continues%:
".-FO-, BDC8F).(D +)*9 ;,)CHT!+?&@J.($A%;
-.CO-D&@J.(8A8AA5#
".-FO-, BDC8F).(D +)*9 ;,)CHT!+?&@J.($A%; -.CO-D&@J.(8A8AA#
".-FO-, BDC8D>*"-O +)*9 ;!"(,9,,; ;AA;#
".-FO-, BDC8F).(D +)*9 ;BDC8O@COD.;
;4AA;#
".-FO-, BDC8F).(D +)*9 ;,!@T&,!@T
-
8/10/2019 BDC & File Handling
81/83
olution $Continues%:
".-FO-, BDC8F).(D +)*9 ;,!@T&,!@T&,!*DT 9-O+" I ;.)O*;
+.- I >&+*!,. @.." I ;&+B-C N A#?-)T. ;.--O- )* O".*89-O+";#.*D)F#.*DFO-,#
Batch Data Communication
l i $C i %
-
8/10/2019 BDC & File Handling
82/83
olution $Continues%:FO-, BDC8D>*"-O +)*9 "-O9-!, D>*"-O# C(.!- )8BDCD!T!# )8BDCD!T!&"-O9-!, I "-O9-!,#
)8BDCD!T!&D>*"-O I D>*"-O# )8BDCD!T!&D>*B.9)* I ;
-
8/10/2019 BDC & File Handling
83/83
Thank You