Anda di halaman 1dari 51

BDC This section reviews batch input programming concepts and explains how to program data transfer and

batch input processing programs. 1) Batch Input Concepts 2) Transferring Data: Batch Input Procedure in Overview DATA TRA !"#R PRO$RA%! &) 'riting a Data Transfer Progra( )) Ana*+,ing !AP Transactions -) $enerating an !AP Data !tructure .) Data Conversions /) Initia*i,ing an !AP Data !tructure 0) $enerating a !e1uentia* "i*e 2) !a(p*e Progra(: Data Transfer BATC3 I P4T PRO$RA%! 15) 'riting a Batch Input Progra(: Procedure in Overview 11) !e*ecting a Batch6Input %ethod 12) 4sing the Batch Input Data !tructure 1&) Progra((ing Techni1ues: #ntering Data and #7ecuting "unctions CR#ATI $ !#!!IO ! 1)) Creating Batch Input !essions 1-) Creating a !ession with BDC8OP# 8$RO4P 1.) Adding Data to a !ession: BDC8I !#RT 1/) C*osing a !ession: BDC8C9O!#8$RO4P 10) Processing Batch Input !essions CA99 TRA !ACTIO 4!I $ 12) 4sing CA99 TRA !ACTIO 4!I $ for Batch Input 25) 4sing CA99 DIA9O$ with Batch Input $# #RA9 I "OR%ATIO A D !A%P9# PRO$RA% 21) Direct Input 22) !a(p*e Batch Input Progra( 2&) Batch Input recording for transaction runs 2)) Batch Input Authori,ations

ABAP Training

Page 1 of 51

BDC :1) BATC3 I P4T CO C#PT!: The AP !stem offers two primar! methods for transferring data into the !stem from other AP !stems and non" AP !stems. These two methods are collectivel! called #batch input# or #batch data communication.# Basic techni1ue for data transfer with ;atch input Both batch input methods wor$ b! carr!ing out normal AP transactions% &ust as a user would. 'owever% batch"input can execute the transactions automaticall! and is therefore suitable for entering large amounts of data that are alread! available in electronic form. The batch input techni(ue offers these advantages for transferring data) *o manual interaction is re(uired during data transfer. +f the data to be transferred is alread! available in electronic form ,on a tape% for example-% then !ou can enter the data automaticall! into the AP !stem using batch input. Batch input ensures data integrit!. Batch input enters data into the AP !stem using the same transactions that interactive users do. Batch input data is therefore submitted to all of the chec$s and controls that appl! to data entered b! normal interactive means. The ;atch input (ethods There are several wa!s to process batch input data in the AP !stem. Batch input processing (ethods< The first processing method could be called #classical batch input.# +n it% an ABAP./ program reads the external data that is to be entered in the AP !stem and stores the data in a #batch"input session.# A session stores the actions that are re(uired to enter !our data using normal AP transactions. 0hen the program has finished generating the session% !ou can run the session to execute the AP transactions in it. 1ou can either explicitl! start and monitor a session with the batch"input management function , !stem ""2 ervices ""2 Batch input- or have the session run in the bac$ground processing s!stem. This method uses the function modules BDC34P5*% BDC3+* 56T% and BDC3C74 5 to generate sessions. +n the second method% !our program uses the ABAP./ CA77 T6A* ACT+4* 8 +*9 statement to run an AP transaction. Batch"input data does not have to be deposited in a session for later processing. +nstead% the entire batch"input process ta$es place inline in !our program. There is a third batch"input method using the ABAP./ CA77 D+A749 statement. 'owever% AP recommends against using this method unless necessar!. The CA77

ABAP Training

Page : of 51

BDC D+A749 method is now outdated and is more complex and less comfortable to use than the other techni(ues. All three batch"input methods use a common data structure for holding the instructions and data for AP transactions. This structure is defined as structure BDCDATA in the ABAP./ Dictionar!. ;or help in selecting the method to use% please see !#9#CTI $ A BATC36I P4T %#T3O! :11)< T+pica* uses of ;atch input< 8ses of batch input include the following) Transferring data from another s!stem when !ou install !our AP !stem 6egularl! transferring data that is captured b! a non" AP s!stem in !our compan! into the AP !stem. Assume% for example% that data collection in some areas of !our compan! is still performed b! a non" AP s!stem. 1ou can still consolidate all of !our data in the AP !stem b! exporting the data from the other s!stem and reading it into the AP !stem with batch input. 1ou can also use batch input to transfer data between two 6.< !stems. 'owever% there are more direct methods for doing this% such as 6;C ,remote function calls-. App*ication support for ;atch6input< The AP applications provide pre"programmed support for batch input transfers for man! of AP=s business ob&ects. To implement one of the supported data transfers% !ou must often write the program that exports the data from !our non" AP !stem. This program% $nown as a #data transfer# program must map the data from the external s!stem into the data structure re(uired b! the AP batch input program. hould !ou wish to write a transfer program that executes outside the AP !stem% then the AP applications provide definitions of the re(uired data formats for the exports. ;rom these definitions% !ou can generate code for the data structures to include in !our export program. 1ou can also write such programs in ABAP./% which lets !ou ta$e advantage of the comfort and conveniences of the AP Development 0or$bench. 4nce !ou have exported the data% !ou can then use a standard% pre"programmed AP report to import the data. This program uses one of the batch input methods to process the data and add it to the AP !stem. 1ou can find information on pre"defined batch"input programs in the AP Customi>ing !stem. Choose Tools ""2 Customi>ing. Then displa! either !our 5nterprise +?9 ,+mplementation 9uide- pro&ects or the AP standard +?9. +n the pro&ect displa!% use the 5xpand function to displa! all nodes in the pro&ect. 1ou can then search for relevant topics with the $e!words ;atch input and transfer<

ABAP Training

Page < of 51

BDC :2) TRA !"#RI $ DATA : BATC3 I P4T PROC#D4R# I O=#R=I#'< Transferring data with batch input re(uires the steps shown in the illustration and list below. *ote that AP standard batch"input programs ta$e care of several of these steps for !ou. ;or more information% please see BATC3 I P4T CO C#PT! :1)< The procedure) 1. Anal!>e the data that is to be transferred to the AP !stem. 9oal) Determine how !our existing data should be mapped to the AP data structure. ?ethod) 1ou=ll need to determine the structure of the data that is to be transferred into the s!stem. 8sing the AP data structure that !ou generate in step :% !ou=ll need to determine how the data to be transferred must be mapped to the AP structure. 1ou=ll also need to determine whether an! data t!pe or data length conversions are re(uired. ;or more information see DATA CO =#R!IO ! :.)< :. 9enerate AP data structures for incorporation into !our data export program. ?ethod) 8se the data structure generation function of the ABAP./ dictionar! to generate data structures for AP tables in an! of several programming languages. +f !ou are using one of AP=s standard batch input programs% then use of this function is re(uired. The standard batch input programs generall! re(uire that !ou use a special pre" defined data structure. ;or more information% please see $# #RATI $ A !AP DATA !TR4CT4R# :-)< +f !ou=re writing !our own batch input procedure% then !ou will need to determine the data structure on !our own. 1ou=ll need to anal!>e the AP transactions to find the names of the fields that the transaction re(uires. ;or more information% please see A A9>!I $ !AP TRA !ACTIO ! :))< <. Code !our data transfer program. 1ou can write the program in ABAP./ or as an external program. 1ou=ll find more information in 'RITI $ A DATA TRA !"#R PRO$RA% :&)< /. 5xport the data that is to be transferred to a se(uential file.

6e(uirements) The file must use the logical format re(uired b! the batch"input program that will import the file ,step @-.

ABAP Training

Page / of 51

BDC 6eading and interpreting the file is much easier if !ou write it in A C++ or 5BCD+C ,character- format rather than% for example% writing numeric data in hexadecimal format. Character format is re(uired b! the pre"defined AP batch input programs. 5. +f necessar!% code the ABAP./ batch input program that will read in the data to be transferred from !our file. AP supplies read!"to"run batch"input programs for most of the AP applications. ;or more information on writing !our own program% see 'RITI $ A BATC3 I P4T PRO$RA% : PROC#D4R# I O=#R=I#':15)< @. " Process the data and add it to the AP !stem. 1ou can do this either b!)

$# #RATI $ A BATC36I P4T !#!!IO :A) A or b! processing data directl! in !our batch"input program with the ABAP./ statement CA99 TRA !ACTIO 4!I $ :12)< B. Chec$ that all data has been successfull! processed.

?ethod) Anal!>e the batch input processing log. +f !ou are using CA77 T6A* ACT+4* 8 +*9% then !ou will need to anal!>e the processing messages collected b! !our program. 1ou=ll find more information on running and anal!>ing sessions and logs in %A A$I $ BATC36I P4T !#!!IO ! :B)< C. Correct and re"process erroneous data.

?ethod) 1ou can use the batch"input management function to process erroneous transactions interactivel!. 1ou can correct data during this interactive processing.

ABAP Training

Page 5 of 51

BDC A< $# #RATI $ A BATC36I P4T !#!!IO 4ne of the two recommended wa!s to process batch input data is to store the data in a batch input session. This session can then be run in the AP !stem to enter the batch input data into the s!stem. +n general% preparing a session is the best and most comfortable wa! to process batch input data. 'owever% !ou ma! wish to use the alternate method% CA77 T6A* ACT+4* 8 +*9% if !our batch input sessions cannot be run (uic$l! enough. ;or more information on choosing the best batch input method% see !#9#CTI $ A BATC36 I P4T %#T3OD :11)< Creating? "i**ing? and C*osing a Batch Input !ession To create a session% program the following procedure using the following BDC3 function modules) 1. :. a. 4pen the batch input session using function module BDC8OP# 8$RO4P :1-) . ;or each transaction in the session)

;ill the BDCDATA structure with values for all screens and fields that must be processed in the transaction. ;or more information% please see 4!I $ T3# BATC36I P4T DATA !TR4CT4R# :12) b. Transfer the transaction to the session with BDC8I !#RT :1.). <. Close the batch input session with BDC8C9O!#8$RO4P :1/)<

The following topics describe these function modules. ee !A%P9# BATC3 I P4T PRO$RA% :22) for an example of how the function modules are used.

ABAP Training

Page @ of 51

BDC B<%A A$I $ BATC36I P4T !#!!IO Batch input sessions enter data non"interactivel! into an 6.< !stem. Batch input is t!picall! used to transfer data from non"6.< !stems to 6.< !stems or to transfer data between 6.< !stems. This section describes how to manage batch input sessions. To reach the main menu of the batch input s!stem% select !stem ""2 ervices ""2 Batch input. Overview and Concepts a) Tas@ Overview: Batch Input ;) Batch Input: Concepts 'or@ing with Batch Input !essions c) Processing !essions Auto(atica**+ d) !e*ecting !essions e) Running !essions f) Correcting a !ession g) De*eting !essions h) 9oc@ing and 4n*oc@ing !essions i) Re*easing and Restarting an Interrupted !ession Infor(ation and Ana*+sis A) Disp*a+ing Bueue %anage(ent Infor(ation @) Disp*a+ing !ession 9ogs *) Reorgani,ing the 9og "i*e () Ana*+,ing !essions

a) Tas@ Overview: Batch Input< 0ith the functions of the batch input management s!stem% !ou can do the following) D tart batch input sessions to enter data into an 6.< !stem. ;or debugging sessions that contain errors% the batch input s!stem offers two modes for running sessions interactivel!. chedule the bac$ground program that automaticall! submits sessions for processing in the bac$ground. D 7oc$ a session until a specified date. 7oc$ing a session prevents it from being run. D Delete batch input sessions.

ABAP Training

Page B of 51

BDC D 6elease a session for re"execution if it has been aborted b! a s!stem failure or shutdown while being created or executed. D Anal!>e a batch input session before or after it has run. The anal!sis function lets !ou displa! data entered in the transactions in a session. 1ou can) " Displa! the screens called b! the session with the session data filled in. " Displa! listings of input fields b! field name% with the session data for each field. D Displa! the log produced b! a batch input session.

;unctionall!) ;or help in generating sessions% please see the Basis Programming Interfaces manual. ;) Batch Input: Concepts: Processing !essions A batch input session is a set of one or more calls to transactions along with the data to be processed b! the transactions. The s!stem normall! executes the transactions in a session non"interactivel!% allowing rapid entr! of bul$ data into an 6.< !stem. A session simulates on"line entr! of transactions and data. +t calls transactions and enters data using most of the facilities that are available to interactive users. ;or example% the data that a session enters into transaction screens is sub&ect to the same consistenc! chec$ing as in normal interactive operation. ;urther% batch input sessions are sub&ect to the user"based authori>ation chec$ing that is performed b! the s!stem. $enerating !essions To transfer data with batch"input% the s!stem that is sending the data uses a data transfer interface provided b! an 6.< application program in the receiving s!stem. The interface program in the application then produces a batch input session. The interface program in an application is an ABAP./ program that sets up the transaction calls and data that ma$e up a session. +f the batch input session contains data from an external source% the program also reformats the data to meet the re(uirements of the input fields in which the data is to be entered. 8suall!% such programs are provided b! the 6.< applications. ;or more information% please see the documentation of the 6.< applications. Authori,ations 0hen a session is generated% a client and user are associated with it. +f the session is run in bac$ground"processing mode% the s!stem uses this user for authori>ation chec$ing as

ABAP Training

Page C of 51

BDC the session runs. This authori>ation testing applies whether !ou sent the &ob for batch execution or the session was started b! a bac$ground &ob. essions that !ou process in one of the interactive modes are run with !our authori>ations. The interactive modes are described later in this section. c) Processing !essions Auto(atica**+: +n most s!stems% sessions are started non"interactivel! with a bac$ground &ob that periodicall! chec$s for and starts an! sessions that have not !et been run. 6unning sessions interactivel! is usuall! reserved for testing sessions or correcting sessions. To start batch input sessions automaticall!% schedule the ABAP./ program 6 BDC 8B for repeated execution. The program schedules sessions for immediate execution in the bac$ground processing s!stem. 0ith 6 BDC 8B% !ou can use all of the selection criteria offered on the batch input main menu to select sessions to run) D D D session name date and time of generation status) read! to run or held in the (ueue because of errors

d) !e*ecting !essions: To reach the main menu for managing batch input sessions% select !stem ""2 ervice ""2 Batch input. 4n the main menu% !ou can select sessions using an! or all of the following criteria) D D D session name date on which the session was generated ,entered into the session (ueuesession status

1ou can also select from one of two actions) D D To displa! the session (ueue% select ession ""2 4verview. 1ou can start% anal!>e% or delete sessions in the (ueue. To displa! session log files% select ession ""2 7ogs.

All sessions generate a log when the! are run. ;rom the list of session logs% !ou can ta$e further actions% such as anal!>ing a session. The !ession Bueue The information in the session (ueue includes the following)

ABAP Training

Page E of 51

BDC D Date and Time) The date and time when a session was generated ,entered in the session (ueue-. D 7oc$ed) +f a session is loc$ed% this column shows the date upon which the s!stem releases the session. A loc$ed session cannot be started. D Created b!) The user who generated the session. D Tran. and creen) The number of transactions and screens% respectivel!% that remain to be processed in a session. D Auth. user) The user under whose authori>ations the session will be run if it is submitted for batch execution. 1ou can displa! statistics on the transactions in an! session b! mar$ing the session and using the tatistics function. !ession !orting and !tatus essions in the session (ueue are sorted b! date and time of generation and are grouped in different lists according to their status.

Possible statuses are as follows) D not !et processed

The Tran. and creen fields in the displa! show how man! transactions and screens% respectivel!% the session contains. D held in the session (ueue because of errors in transactions ,5rrors in sessions-

Transactions that contained errors are abortedA all correct transactions are processed. The Tran. and creen fields in the session displa! show how man! incorrect transactions were found in the session. 1ou can restart a session and correct the erroneous transactions with one of the interactive execution modes offered b! the batch input s!stem. ;or more information% please see Correcting a !ession:f)< D processed

;or further information on a session that has been successfull! run% !ou can displa! the log generated b! the session. All completed sessions generate a log. 1ou cannot run a completed session a second time.

ABAP Training

Page 1F of 51

BDC 4nl! sessions that were generated with the G55P option are held in the (ueue after processing. 4ther sessions are deleted after the! are successfull! completed. D in generation

1ou will usuall! see this status onl! if !ou happen to displa! the (ueue while a session is being generated ,entered into the session (ueue-. 1ou can also encounter this status if a s!stem failure has interrupted the generation of a session. +f !ou suspect that a session has been interrupted% please see Re*easing and Restarting an Interrupted !ession:i) for more information. D in process

1ou will usuall! see this status onl! if !ou happen to displa! the (ueue while a session is being run. 1ou can also encounter this status if a s!stem failure has interrupted the execution of a session. +f !ou suspect that a session has been interrupted% please see Re*easing and Restarting an Interrupted !ession:i) for more information. e) Running !essions: 6unning a batch input session executes the transactions in the session and enters data into an 6.< !stem. To start a session% select ession H 4verview from the main batch input screen. Then mar$ the session,s- that !ou wish to start and select ession H Process or H Process in batch. 1ou can start an! session in the not !et processed list that is not loc$ed. 0ith Process.foreground or mode% !ou can also re"start transactions that have the status +ncorrect. essions with the status Processed cannot be run again. 6un ?odes There are three wa!s to run a session)

ABAP Training

Page 11 of 51

BDC DProcessCforeground: 1ou can interactivel! correct transactions that contained errors and step through transactions that have not !et been executed. DDisp*a+ errors on*+: This mode is li$e Process.foreground except that transactions that have not !et been run and which do not contain errors are run non"interactivel!. +f an error occurs% processing stops and the screen upon which the error occurred is displa!ed. DProcess in Batch: 8se batch mode to schedule a session for immediate processing in the batch facilit!. 1ou receive control of !our terminal again as soon as the session has been passed to the batch s!stem. *ote that !our session is automaticall! released for processing in the bac$ground processing s!stem. 1ou need not explicitl! release the session for processing. A completed session is handled in one of three wa!s) " The s!stem deletes a session from the (ueue when it has been successfull! completed. 1ou can chec$ on the outcome of the session b! displa!ing the session log file. " +f the G55P option was set when the session was generated% then the s!stem leaves a session in the (ueue% even if it was run successfull!. The status is changed to Processed. 1ou cannot run the session a second time. 1ou must manuall! delete it when !ou no longer need it. " +f a transaction in the session contained an error% the incorrect transaction is aborted. All other transactions are completed. The session remains in the (ueue and is held in the 5rrors section of the list. 1ou can correct the session in one of the interactive modes and run it to completion. A transaction contains an error if it issues a message of t!pe 5 ,error- or t!pe A ,abnormal termination-. 4ther messages are ignored and do not affect the execution of a session.. A session also is held in the (ueue in the 5rrors list if the session was ended with the .bend 4G code. Please see Correcting a !ession:f)< ;or more information on correcting sessions with the displa!"all or error"displa! mode% please see Correcting a !ession:f)< """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" f) Correcting a !ession:

ABAP Training

Page 1: of 51

BDC 0hen a session is run in bac$ground"processing mode% the s!stem mar$s transactions that contain errors as incorrect. All other transactions in the session are completed. The session itself is $ept in the session (ueue in the 5rrors section of the list. A transaction contains an error if it generates an error message of t!pe 5 ,error- or t!pe A ,abnormal termination-. ?essages of other t!pes are ignored and do not affect the execution of a session. 1ou can correct and re"execute the incorrect transactions in an #5rrors# session. There are two wa!s to do so) 1. 6e"run the session in displa!"all or error"displa! mode. These modes offer the following advantages) " The s!stem s$ips transactions that were successfull! completed. 4nl! incorrect transactions or transactions that have not been executed are run. " 1ou can change inputs and add missing screens interactivel! as incorrect transactions run. The following topic provides more information on using displa!"all mode or error" displa! mode to correct a transaction. :. As an alternative% !ou can anal!>e the session to determine what the error was. 0ith the anal!sis displa!s% !ou can chec$ the screen that contained the error and the values that were entered in it. 1ou can then correct the program that generated the session and regenerate the session. 1ou must ensure that the new session does not include transactions that were successfull! completed. 4therwise% the updates made b! the transactions will be performed again. 4sing Disp*a+6A** %ode 0hen !ou use displa!"all mode to re"start a session that contains an incorrect transaction% the s!stem s$ips to the first screen of the incorrect transaction. Completed transactions are not re"executed. options when +ou run a session interactive*+<

To correct a transaction% !ou can) D use the 5*T56 $e! to step through the screens recorded in the session

As in normal operation% pressing the 5*T56 $e! starts a dialog step. As long as !ou simpl! press 5*T56% the s!stem processes the screens and data recorded in the session. D change or add values in an! screen

ABAP Training

Page 1< of 51

BDC 0hen !ou press 5*T56% the s!stem processes the data as altered b! !ou. D branch off from the transaction flow recorded in the session

1ou can use an! function that !ou wish within the transaction that is currentl! running. 1ou can% for example% branch off to enter data on a screen that was omitted from the session. To resume executing the session% return to the screen that was expected b! the session. +t holds the data for the screen recorded in the session until !ou have returned to that screen. +t then resumes normal execution of the session. Interrupting a !ession 1ou can interrupt the interactive execution of a session b! entering the .bend 4G code on an! screen. .bend terminates the transaction currentl! being executed in the session and mar$s the transaction with the status +ncorrect. The session is $ept in the (ueue and is displa!ed in the 5rrors in sessions section of the list. 1ou can use .bend when testing sessions. ;or example% !ou ma! wish to run the first two transactions of a large session in displa!"all mode to ma$e sure that the session has been generated correctl!. +f the transactions are correct% !ou can then terminate the run with .bend and then submit the session for bac$ground execution. The transactions that have alread! been run will not be run again. De*eting a Transaction 1ou can delete a transaction from a session during interactive execution b! entering the .bdel 4G code. The transaction is removed from the session. The deleted transaction cannot be run even if !ou restart the session% and !ou cannot ta$e bac$ the deletion. The transaction is% however% available for anal!sis if the session was generated with the G55P option set. The transaction is mar$ed with the status Deleted in the anal!sis displa!. The deletion also is recorded in the log generated b! the session. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" g) De*eting !essions: 1ou can delete an! session from the session (ueue. Deleting a session discards the session. +f the session has alread! been run% !ou also delete the session log. *ormall!% sessions are deleted from the session (ueue automaticall! when the! are completed. 'owever% if a session was generated with the G55P option% it is $ept in the session (ueue. 1ou must explicitl! delete the session when !ou no longer need it.

ABAP Training

Page 1/ of 51

BDC A session is also $ept in the (ueue if it contained an error or was bro$en off with the .bend 4G code. uch a session is deleted when !ou finish processing it% unless it was generated with the G55P option. To delete a session from the session (ueue% mar$ the sessions to be deleted and select 5dit ""2 Delete. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" h) 9oc@ing and 4n*oc@ing !essions: 1ou can loc$ sessions in the session (ueue b! mar$ing the sessions and selecting 5dit H 7oc$. 7oc$ing a session prevents a session from being started until after the date recorded in the loc$. ;or example% a session loc$ed until the eleventh of *ovember can be started onl! after that date. 1ou ma! wish to loc$ a session for such reasons as D holding a session until a specified date D preventing a session that contains errors from being re"started D preventing a session that re(uires a special resource% such as printer forms or a specific tape% from being started unintentionall!. 1ou can unloc$ a session b! changing the loc$ date to the present date or b! entering a space as the loc$ date. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" i) Re*easing and Restarting an Interrupted !ession: +f a s!stem problem occurs while a session is being generated or is being run% the session is terminated abnormall!. T!pical causes of an abnormal termination might include shutdown of the 6.< !stem while a session is running or termination of a AP98+ presentation process while a session is being run interactivel!. +n the session (ueue% a session that was terminated while it was being generated remains in the Being generated section of the list. A session that was terminated while it was running remains in the Active list. 1ou can recogni>e that a session has terminated abnormall! because the status of the session does not change. +f% for example% !ou find a session that was run the previous night still in the Active list% then it is li$el! that the session was interrupted. +f a session was to run in the bac$ground% !ou can chec$ the status of the session=s &ob in the bac$ground processing s!stem. +f the session was aborted% then the bac$ground &ob log contains the reason for the abnormal termination.

ABAP Training

Page 15 of 51

BDC Before !ou can restart ,or start- a session that terminated abnormall!% !ou must release it. 6eleasing the aborted session sets its status to Being processed. 6eset the status b! mar$ing the session or sessions and selecting 5dit ""2 6elease. 1ou can safel! restart a session that was interrupted while it was being run. 0hen !ou restart the session% all transactions that were successfull! completed before the problem occurred will be s$ipped. The transaction that was executing when the problem occurred will be re"executed. caution 6elease an active session onl! if !ou are sure that it has been interrupted and is no longer running.. essions also have the status Active while the! are running. caution 6estarting after abnormal termination during generation) 1ou can start a session that was interrupted while it was being generated. The session is guaranteed to contain onl! complete transactions and to be runnable. 'owever% there is no guarantee that the session contains all of the transactions that were to be included in it. 1ou ma! therefore wish to delete and regenerate such a session. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" A) Disp*a+ing Bueue %anage(ent Infor(ation: hould !ou ever need to review the internal (ueue"management information on a particular entr!% !ou can displa! this information b! mar$ing an entr! and selecting Anal!sis ""2 Iueue. *ot all of the (ueue management fields displa!ed are used b! the batch input s!stemA the (ueue management functions are used b! other (ueues in the s!stem as well. The fields that are used b! the batch input s!stem are as follows) D D D Client) The client in which a session is to run. 9roupid) The session name. I+D) The internal +D of a session. The +D is used for (ueue management with !stem ""2 ervices ""2 Iueue. D I TAT5) A character indicating the status of the batch input session. D I56A 5) +f mar$ed% indicates that the G55P option is set. +f G55P is set% the s!stem does not delete the session after it is successfull! run. D 8 56+D) 8ser to be used for authori>ation testing if a session is submitted for bac$ground execution. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @) Disp*a+ing !ession 9ogs:

ABAP Training

Page 1@ of 51

BDC 5ver! batch input session generates a log when it runs. To displa! a log% !ou can either) D D select ession ""2 7ogs from the batch input main menuA or put the cursor on a particular session in the session (ueue and select 9oto ""2 7og.

A session log contains an! error messages issued b! transactions in the session. +t also includes batch input error messages reporting an! problems in running transactions% together with the transaction and screen at which the problem occurred. ;inall!% a log contains a set of summar! statistics. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" *) Reorgani,ing the 9og "i*e: 1ou should periodicall! use the ABAP./ program 6 BDC654 to reorgani>e the batch input log file. 1ou can run 6 BDC654 in the bac$ground or interactivel!. 6unning the program reduces the si>e of the log file% B+J6.< !stem name2J+nstance name2% in the shared 6.< director! #global# in the host s!stem to the minimum possible si>e. Deleting a session mar$s a session log for deletion% but the storage held for the log is returned to the host onl! b! a reorgani>ation. The program will delete a log onl! if the session to which the log belongs has been deleted. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" () Ana*+,ing !essions: 8se the anal!sis functions to chec$ on the actions performed b! a batch input session. The anal!sis functions allow !ou to displa! the transactions% screens% and data in a session. 1ou can use these functions before or after a session has been run. note Anal!sis of sessions that have been run is available onl! for sessions that contained an error or which were generated with the G55P option. The G55P option prevents the s!stem from deleting a session that has been successfull! run. 1ou can anal!>e a session b! mar$ing the session in the session (ueue and selecting 9oto ""2 Anal!sis ""2 ession or b! selecting Anal!sis from the session log screen. Ana*+sis B*oc@s 6eading ver! long sessions from the database can cause time"outs to occur. ;or this reason% the s!stem reads sessions for anal!sis in bloc$s.

ABAP Training

Page 1B of 51

BDC Bloc$s do not restrict !our abilit! to displa! a long session. 1ou can switch forward and bac$ward from bloc$ to bloc$ with function $e!s. A bloc$ alwa!s contains onl! complete transactions. A bloc$ boundar! cannot fall in the middle of a transaction. !ession !u((ar+ The first anal!sis screen lists the transactions and screens recorded in the session. creens are identified b! the name of the program and the number of the screen. tatuses are identical to those of the session (ueue% except that transactions that were deleted with the .bdel 4G code have the status Deleted. !ession Data 1ou can displa! the data entered on each screen of a session b! selecting Anal!sis H Data from the first anal!sis screen. 1ou can have the data presented to !ou in two formats) D The first data displa! presents data in list format b! field name. D Alternativel!% !ou can switch to the screen called b! the session with the session data shown on it. 1ou can switch bac$ and forth from one form of displa! to the other. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :&) 'RITI $ A DATA TRA !"#R PRO$RA%: The data transfer program is responsible for doing the following) D Converting the data that is to be transferred into the AP !stem as re(uired b! the AP data structure or transactions that !ou are using. The data structure ma! be generated from the standard AP data structures ,see $enerating an !AP Data !tructure:-) -. This is re(uired if !ou are wor$ing with a standard AP batch input program. 4r% if !ou are creating !our own batch input procedure% !ou ma! have developed the data structure !ourself b! anal!>ing the AP transactions with which the data is to be entered. A conversion ma! be necessar! for data t!pe and length. The data t!pe re(uired b! all standard AP batch input programs is C% character data. 1ou can find the re(uired field lengths either in !our anal!sis of the AP data entr! transactions or in the data structures that !ou generate in the ABAP./ Dictionar!.

ABAP Training

Page 1C of 51

BDC D 5xporting the data in AP format to a se(uential file. The batch input program in the AP !stem reads the data in from this file. Tas@ Overview The tas$s involved in writing a data transfer program are shown in the diagram and list below.

'riting a Transfer Progra( The procedure) 1. Anal!>e the structure of !our existing data and specif! the conversions that are re(uired to fill the AP data structures. :. 9enerate the AP data structure in code form and insert it into !our program. !our <. /. are 5. the +f the program is written in ABAP./% !ou need onl! include the re(uired tables in program with the TAB75 statement. +nitiali>e the AP data structure. ;ill the structure with data% performing an! conversions and error"chec$ing that re(uired. 0rite the se(uential file that is t!picall! re(uired for ma$ing the data available to batch input program in the AP !stem.

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :)) A A9>EI $ !AP TRA !ACTIO !: +f !ou are creating !our own batch input procedure% then !ou will need to anal!>e the AP transaction,s- with which the batch input data is to be entered into the AP !stem. The purpose of the anal!sis is to gather the following information) D the transaction code% if !ou do not alread! $now it D which fields re(uire input D which fields !ou can allow to default to standard values D the names% t!pes% and lengths of the fields that are used b! a transaction D the identifiers of the functions that !ou will need to call to have the transaction process the batch input data.

ABAP Training

Page 1E of 51

BDC Co**ecting Transaction Data To anal!>e a transaction% do the following) 1. field. tart the transaction b! menu or b! entering the transaction code in the command 1ou can determine the transaction name b! choosing !stem ""2 tatus. :. tep through the transaction% entering the data and performing the functions that will be re(uired for processing !our batch input data. <. 4n each screen% note the program name and screen ,d!npro- number. Displa! these b! choosing !stem ""2 tatus. The relevant fields are Program and D!npro number.

,d!npro-

+f pop"up windows occur during execution% !ou can get the program name and screen number b! pressing ;1 on an! field or button on the screen. The Technical info pop"up shows not onl! the field information but also the program and screen. /. then ;or each field% chec$ box% and radio button on each screen% press ;1 ,help- and choose Technical info.

*ote the following information) " The field name for batch input% which !ou=ll find in its own box. " The length and data t!pe of the field. 1ou can displa! this information b! double" clic$ing on the Data element field. 5. ;ind out the identification code for each function ,button or menu- that !ou must execute to process the batch input data. Put the cursor on the button or menu entr! while holding down the left mouse button. Then press ;1. +n the pop"up window that follows% choose Technical info and note the code that is shown in the ;unction field. 1ou can also run an! function that is assigned to a function $e! b! wa! of the function $e! number. To displa! the list of available function $e!s% clic$ on the right mouse button. *ote the $e! number that is assigned to the functions !ou want to run.

$etting !creen and "ie*d Infor(ation in the Transaction Interface

ABAP Training

Page :F of 51

BDC 4sing the !creen Painter and %enu Painter to $et "ie*d and "unction Info 1ou can also obtain field and function information from the screen and menu definitions in the ABAP./ screen painter and menu painter. ;or example% !ou can (uic$l! displa! field information in the screen painter b! displa!ing the screen in the ;ullscreen editor and using the Attribs. for 1 field button for each field. The illustration below shows an example. $etting "ie*d Infor(ation in the !creen Painter imilarl!% !ou can get function and menu codes from the C8A definition of a screen in the menu painter. ee the ABAP./ Development 0or$bench documentation for more information on using these tools. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :-) $# #RATI $ A !AP DATA !TR4CT4R#: 1ou can use the ABAP./ Dictionar! to generate data structures for AP tables in an! of the following programming languages) D D D Cobol P7.1 C

1ou can then incorporate these data structures in !our data conversion program. ;or most of the standard AP batch input programs% AP has also provided special data structure identifiers. 0ith such an identifier% !ou can generate a listing of all of the table fields that are re(uired b! the corresponding batch input program. 1ou do not need to find out which tables are re(uired for the batch input program and generate their structures individuall!. +f !ou are creating !our own batch input procedure% !ou ma! be able to use the standard field listings as well. The names of the special data structure identifiers are documented in the AP Customi>ing s!stem. ;or information on finding the relevant documentation% please see Batch Input Concepts:1)< Data Transfer Progra(s in ABAPC) +f !our data transfer program is written in ABAP./% !ou can include data structures of tables in !our program with the TAB75 instruction. The structure is then read directl! from the ABAP./ Dictionar!.

ABAP Training

Page :1 of 51

BDC +n this case% !ou cannot use the special data structure identifiers provided b! the AP applications. The identifier names are not recogni>ed b! the TAB75 instruction. +nstead% !ou can find the re(uired table names b! chec$ing the transactions that !our batch input procedure will be using to enter data. 4r !ou can find the table names in the listings generated b! the special identifiers. The diagram below shows the structures of transfer programs in ABAP./ and as external programs written in other languages. Inc*uding Ta;*e !tructures in Transfer Progra(s: ABAPC) and Other 9anguages Procedure To generate a data structure% do the following) 1. :. Choose Tools ""2 ABAP./ 0or$bench and then ABAP./ Dictionar!. +n the ABAP./ Dictionar!% select 5nvironment ""2 9enerate table description.

0ith this function% !ou can generate the structures of one or a group of AP tables in programming code. 1ou can then add this code to !our data transfer program. <. pecif! the programming language in which the structure should be generated and identif! the tables to be included. +f !ou wish to use a special structure identifier for a standard AP batch input report% then enter the identifier in the Ge! in T 6C9 field. 5xample) The identifier A?"A*7A generates the data structure re(uired for data transfers for the asset management application. /. The s!stem displa!s the data structure in list form% as in this example in P7.1 from the asset management application ,A?"A*7A-) KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK K ?5?B56 95*56AT5D ;64? AP DATA D+CT+4*A61 K K T A B 7 5 BA7TD K K DAT5) FC.1:.1EE5 T+?5) 1B)/B)1@ K K P75A 5 D4 *4T C'A*95 ?A*8A771 K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK K F1 BA7TD. K K Client ,4ld Assets Data Ta$eover A?F5 ?A*DT P+C L,<MA785 PAC5. K Compan! code

ABAP Training

Page :: of 51

BDC F5 B8G6 K Asset class F5 A*7G7 P+C L,/MA785 PAC5. P+C L,CMA785 PAC5. ave ""2 ;ile to download the data structure to !our

Choose !stem ""2 7ist ""2 wor$station or PC.

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :.) DATA CO =#R!IO !: 8se the field descriptions that !ou obtained in Ana*+,ing !AP Transactions:)) or $enerating an !AP Data !tructure:-) to determine the following) D which fields can be ta$en over directl! from !our existing data. That is% there is a direct match between an existing data field and the corresponding AP data field. D for which fields a conversion procedure is necessar! for mapping !our existing data to the re(uirements of the AP !stem.

Converting Data fro( O*d "or(at to !AP "or(at 1our program must format batch input values &ust as an on"line user would when t!ping them in. +n particular) D The data must be character format. D *o piece of data ma! be longer than its target AP field. D +f the data is shorter than the target field% !ou must left"&ustif! it within the AP field ,pad it with blan$s at the right end-. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :/) I ITIA9IEI $ A !AP DATA !TR4CT4R#: tandard AP batch input programs re(uire that ever! field in a data structure contains either) D a valueA or D a special *4DATA mar$er% which indicates that the no batch input data is re(uired for the field. +f !ou are writing !our own data transfer program% !ou should therefore initiali>e all of the fields in !our batch input data structure with the *4DATA character. The *4DATA character must occup! the first position in the field% as shown in the figure below.

ABAP Training

Page :< of 51

BDC B! default% the *4DATA character is the forward slash. To initiali>e a field to *4DATA% !ou must write this character as the first character in the field value.

+f a batch input program finds *4DATA in a field% then the program allows the field to default to its standard value in the AP transaction that contains the field. etting the *4DATA mar$er) 1ou can freel! select another character as the *4DATA mar$er. Define the new character in the batch input program that reads the data in the B96FF"*4DATA field) Data) J*ame2 li$e bgrFF. J*ame2"*4DATA N =JCharacter2=. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :0) $# #RATI $ A !#B4# TIA9 "I9#: +f !ou are transferring data from a non" AP !stem% then !ou will probabl! need to use a file as the transfer medium for the data. ,;or data transfer between AP !stems% !ou ma! be able to use 6;C or CP+"C to process data directl! in the target AP !stem.The file that !ou generate should have the following characteristics) D All data should be in character format. This is re(uired b! the standard AP batch input programs. D Data must have the logical structure expected b! the batch input program. ;or a standard AP batch input program% this re(uirement means that !ou have generated the data structure defined for the batch input program. ;or more information% see $enerating an !AP Data !tructure:-)< 1ou=ll find sample code for reading from and writing to a se(uential file in !a(p*e Progra(: Data Transfer:2) < """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :2) !A%P9# PRO$RA%: DATA TRA !"#R: The following ABAP./ program demonstrates the data transfer process. The program does the following) D D D reads customer address data from a se(uential file chec$s the data for unacceptable records performs conversions on the data

ABAP Training

Page :/ of 51

BDC D writes the data bac$ out to a se(uential file using the format re(uired b! the AP standard batch input program Batch +nput +nterface for Customers ,ABAP./ program 6;B+D5FF-. #FA%P9#: 65P46T B+T;56. K AP structures for batch input processing) TAB75 ) B96FF% BG*FF% BG*A1. K tructure of existing data to be transferred) DATA) B59+* 4; 47D65C% T5751,1F- T1P5 C% C8 T*6,C- T1P5 C% T+T75,:- T1P5 C% *A?51,<F- T1P5 C% 5*D 4; 47D65C. K Auxiliar! structure for initiali>ing fields) DATA) B59+* 4; A8L65C. +*C78D5 T68CT865 BG*A1. DATA) 5*D 4; A8L65C. K AP fields for converted data) DATA) C8 T*6 7+G5 BG*FF"G8**6% *A?51 7+G5 BG*A1"*A?51% T5751 7+G5 BG*A1"T57;1. K ;or initiali>ing fields) DATA) * T1P5 +. ;+57D" 1?B47 J;2. K ;ile and session names% *4DATA character) PA6A?5T56 ) 47D;+75,:F- D5;A87T =.tmp.oldfile= 74056 CA 5% AP;+75,:F- D5;A87T =.tmp.sapfile= 74056 CA 5% 566;+75,:F- D5;A87T =.tmp.errfile= 74056 CA 5% 5 +4*,:F- D5;A87T =ADD6DAT= 74056 CA 5% *4DATA D5;A87T =.= 74056 CA 5. TA6T"4;" 575CT+4*. 4P5* DATA 5T) 47D;+75 ;46 +*P8T +* T5LT ?4D5% AP;+75 ;46 48TP8T +* T5LT ?4D5% 566;+75 ;46 48TP8T +* T5LT ?4D5.

ABAP Training

Page :5 of 51

BDC K 4pen batch input session as first AP;+75 entr!) K program) ?4M5) =4= T4 B96FF" T1P5% 5 +4* T4 B96FF"9648P% 1"?A*DT T4 B96FF"?A*DT% 1"8*A?5 T4 B96FF"8 *A?% *4DATA T4 B96FF"*4DATA. T6A* ;56 B96FF T4 AP;+75. K +nitiali>e data fields with *4DATA) D4. ADD 1 T4 *. A +9* C4?P4*5*T * 4; T68CT865 A8L65C T4 J;2. +; 1" 8B6C *5 F. 5L+T. 5*D+;. ?4M5 B96FF"*4DATA T4 J;2. 5*DD4. ?4M5 A8L65C T4 BG*A1. K 6ead and convert existing data) D4. # 6ead data record) 65AD DATA 5T 47D;+75 +*T4 47D65C. +; 1" 8B6C *5 F. 5L+T. 5*D+;. # Chec$ data and transfer onl! certain records) +; 47D65C"C8 T*6,5- *5 =AABBC= 46 47D65C"C8 T*6,@- 5I =AABBCD= 46 47D65C"T5751 5I PAC5. T6A* ;56 47D65C T4 566;+75. K T5LT"FF1) =Data not transferred for customer)= 06+T5) . T5LT"FF1% 47D65C"C8 T*6. 57 5. # Convert the customer number to AP convention) +; 47D65C"C8 T*6O5,1- N =C=. +; 47D65C"C8 T*6O5,1- N =D=. 5*D+;. # Convert abbreviations to full words) CA 5 47D65C"T+T75. 0'5* =Co=. BG*A1"T+T75 N =Compan!=. 0'5* =Corp=. BG*A1"T+T75 N =Corporation=. 0'5* 4T'56 . BG*A1"T+T75 N *4DATA. 5*DCA 5. # Convert records from old format to AP format) ?4M5) 47D65C"C8 T*6 T4 C8 T*6% 47D65C"*A?51 T4 *A?51% 47D65C"T5751 T4 T5751.

ABAP Training

Page :@ of 51

BDC # ;ill AP structures) ?4M5) =1= T4 BG*44" T1P5% =LDF:= T4 BG*44"TC4D5% C8 T*6 T4 BG*44"CG8**6. ?4M5) =:= T4 BG*A1" T1P5% =BG*A1= T4 BG*A1"TB*A?% =T5751 T4 BG*A1"T57;1% *4DATA T4 B*GA1" 5*D5. # Transfer data to AP;+75) T6A* ;56) BG*44 T4 AP;+75% BG*A1 T4 AP;+75. K T5LT"F:) =Data was transferred for customer)= 06+T5) . T5LT"FF:% 47D65C"C8 T*6% BG*44"C8 T*6. 5*D+;. 5*DD4. C74 5 DATA 5T) 47D;+75% AP;+75% 566;+75. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :15) 'RITI $ A BATC3 I P4T PRO$RA%: PROC#D4R# I O=#R=I#': +n general% !ou can transfer data from an existing s!stem into the AP !stem with pre" defined batch input programs% delivered with the AP !stem. +n some cases% however% !ou will need to write !our own batch input program. ;or example% the standard AP batch input programs in an application ma! not have foreseen the data transfer re(uirement !ou have% or !ou ma! wish to customi>e the standard data transfer procedure. To write !our own batch input program% !ou=ll need to do the following) 1. Anal!>e the transaction,s- that !ou will use to process !our batch input data.

1ou ma! have alread! done this when !ou wrote !our data transfer program. Please see 'riting a Data Transfer Progra(:&) and Ana*+,ing !AP Transactions:)) for more information. :. Decide on the batch"input method that !ou wish to use.

#Classical# batch input "" b! wa! of a batch input session "" is more comfortable. 6estart"capabilit! and detailed logging are supported b! the batch input management transaction for batch input sessions. !ou Batch input b! wa! of CA77 T6A* ACT+4* 8 +*9 offers faster processing if need it to get !our batch input done in the time slot that is available for it.

ABAP Training

Page :B of 51

BDC CA77 and T6A* ACT+4* 8 +*9 offers% however% less support for error recover! management of batch input. ;or detailed information% please see !e*ecting a Batch6Input %ethod:11) . <. 0rite the batch input program. 1our program will need to do the following) " read data in% often from a se(uential file that has been exported from another s!stem or prepared b! a data transfer program " if necessar!% perform data conversions or error"chec$ing " prepare the data for batch input processing b! storing the data in the batch input data structure% BDCDATA. " generate a batch input session for classical batch input% or process the data directl! with CA77 T6A* ACT+4* 8 +*9. 1ou=ll find information on programming techni(ues for batch input programs in the following topics% as well as a sample program. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :11) !#9#CTI $ A BATC36I P4T %#T3OD: 0hen !ou generate batch input in ABAP./% !ou have three options for submitting the data to batch input processing. 4nl! the first two methods can be recommended without reservation. The third method% b! wa! of CA77 D+A749% is outmoded. CA77 D+A749 +s less comfortable than the other methods. 1ou should use it onl! if !ou must. D Create a session on the batch input (ueue.

ummar!) tandard method. 4ffers management of sessions% support for pla!ing bac$ and correcting sessions that contain errors% and detailed logging. 1our program prepares the data and stores it in a batch input session. A session is a collection of transaction data for one or more transactions. Batch input sessions are maintained b! the s!stem in the batch input (ueue. 1ou can process batch input sessions in the bac$ground processing s!stem. 1our program must open a session in the (ueue before transferring data to it% and must close it again afterwards. All of these operations are performed b! ma$ing function module calls from the ABAP./ program. The most important aspects of the session interface are) " " As!nchronous processing Transfers data for multiple transactions

ABAP Training

Page :C of 51

BDC " !nchronous database update

During processing% no transaction is started until the previous transaction has been written to the database. " " A batch input processing log is generated for each session essions cannot be generated in parallel

The batch input program must not open a session until it has closed the preceding session. D 8se the CA77 T6A* ACT+4* 8 +*9 statement

ummar!) 4ffers faster processing of data than batch input sessions. 6ecommended if !ou=re having problems getting data entered into !our AP !stem (uic$l! enough. The pla!bac$% interactive correction% and logging facilities offered for batch input sessions are not available for CA77 T6A* ACT+4* 8 +*9. 1our program prepares the data and calls the desired transaction for immediate processing. The most important aspects of the CA77 T6A* ACT+4* 8 +*9 interface are) " " " !nchronous processing Transfers data for a single transaction !nchronous and as!nchronous database updating both possible The program specifies which $ind of updating is desired. " eparate 780 for the transaction The s!stem performs a database commit immediatel! before and after the CA77 T6A* ACT+4* 8 +*9 statement. " *o batch input processing log is generated D 8se the CA77 D+A749 statement

ummar!) *ot recommended if !ou can enter data b! wa! of sessions or CA77 T6A* ACT+4* 8 +*9. 1our program prepares data for a se(uence of dialog screens% and calls a dialog module for immediate processing. The most important aspects of the CA77 D+A749 interface are) " " " !nchronous processing Transfers data for a se(uence of dialog screens *o separate database update for the dialog A database update occurs onl! when the calling program executes a commit operation. " hares 780 with calling program " *o batch input processing log is generated """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

ABAP Training

Page :E of 51

BDC

:12) 4!I $ T3# BATC3 I P4T DATA !TR4CT4R#: The batch input structure stores the data that is to be entered into AP !stem and the actions that are necessar! to process the data. 1ou can thin$ of the structure as storing the script that the AP !stem is to follow in processing batch input data. The batch input structure is used b! all of the batch input methods. 1ou can use the same structure for all t!pes of batch input% regardless of whether !ou are creating a session in the batch input (ueue or using CA77 T6A* ACT+4* 8 +*9 or CA77 D+A749. The diagram below shows how to declare the structure in !our ABAP./ program and the fields contained in the structure.

BDCDATA !tructure Infor(ation structure: A BDCDATA structure can contain the batch input data for onl! a single run of a transaction. The t!pical processing loop in a program is therefore as follows) D Create a BDCDATA structure D 0rite the structure out to a session or process it with CA77 T6A* ACT+4* 8 +*9A and then D Create a BDCDATA structure for the next transaction that is to be processed. 0ithin a BDCDATA structure% data is organi>ed b! the screens in a transaction. 5ach screen that is processed in the course of a transaction must be identified with a BDCDATA record. This record uses the Program% D!npro% and D!nbegin fields of the structure) The screen identifier record is followed b! a separate BDCDATA record for each value that is to be entered into a field. These records use the ;*A? and ;MA7 fields of the BDCDATA structure. Malues to be entered in a field can be an! of the following) D data that is entered into screen fields D function codes that are entered into the command field. execute functions in a transaction% such as ave. D cursor"positioning commands. uch function codes

The transaction to which a BDCDATA structure refers is identified separatel!. +f !our program writes data to a batch input session% then the transaction is specified in the call to the BDC3+* 56T function module. This function module writes a BDCDATA structure

ABAP Training

Page <F of 51

BDC out to the session. +f !our program processes data with CA77 T6A* ACT+4* 8 +*9% then the transaction is specified directl! in this statement. The following table shows what the contents of a BDCDATA structure might loo$ li$e. This BDCDATA structure would add a line to a report in transaction 5<C% the ABAP./ 5ditor) BDCDATA !tructure for Adding a 9ine to a Report :Transaction !#&0) PRO$RA% D> PRO 66666666666666666 6666666666666 AP? <C? F1FF D> B#$I " A% "=A9 66666666666666666 66666666666666666666666666 6666666666 L 6 <C?"P6496A?? J*ame2 6 <C?";8*C35D+T L BDC34GC4D5 NC'AP ,Change L 6 TLP"TD7+*5C4?,1AP? 5DT :<1F TD7+*5C4?,16 TLP"TD7+*5,1BDC34GC4D5 $e!AP? 5DT :<1F $e!AP? <C? F1FF $e!"ie*ds: The fields in the BDCDATA structure are as follows) D et this D screen. D D1*B59+* P6496A? *ame of the program. 7ength ,C-. The P6496A? field is not case"sensitive. field onl! in the first record for the screen. D1*P64 *umber of the screen. 7ength ,/-. et this field onl! in the first record for the L BDC34GC4D5 L BDC34GC4D5 .15 ,Iuit function .< ,Bac$ function BDC Test Text .11 , ave function L BDC3C86 46 6 TLP" B"

function codeAP? 5DT :<1F

ABAP Training

Page <1 of 51

BDC first D +ndicates the first record for the screen. 7ength ,1-. et this field to L onl! in the record for the screen. ,6eset to = = ,blan$- for all other records.;*A? *ame of a field in the screen. 7ength ,<5-. The ;*A? field is not case"sensitive. D ;MA7

Malue for the field named in ;*A?. 7ength ,1<:-. The ;MA7 field is case" sensitive. Malues assigned to this field are alwa!s padded on the right if the! are less than 1<: characters. Malues must be in character format. "inding function codes and progra( and fie*d na(es: Please see Ana*+,ing !AP Transactions:)) for more information. Data for(atting re1uire(ents: Please see Data Conversions:.) for more information. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :1&) PRO$RA%%I $ T#C3 IB4#! : # T#RI $ DATA A D #F#C4TI $ "4 CTIO !: a)!a(p*e Code: "i**ing the BDCDATA !tructure ;)Identif+ing a !creen c)#ntering a =a*ue in a "ie*d d)#7ecuting a "unction e)#ntering =a*ues in 9oop "ie*ds f)Positioning the Cursor g)#nding a Transaction """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" a) !a(p*e Code: "i**ing the BDCDATA !tructure: The following form routine shows how the BDCDATA structure should be filled. Build the structure line b! line using ?4M5 and APP5*D statements. Before building each line% reset the header line of the internal table with the C75A6 statement. pecial techni(ues% such as placing the cursor% are not shown in this example. #7a(p*e: Assume in this example that the BDCDATA structure has been declared as BDCDAT in the ABAP./ program)

ABAP Training

Page <: of 51

BDC ;46? ;ill"BDC"Table 65;65 ' BDCDAT # tart new D1*P64 C75A6 BDCDAT ?4M5) Jprogram name2 T4 BDCDAT"P6496A?. JD1*P64 number2 T4 BDCDAT"D1*P64. =L= T4 BDCDAT"D1*B59+*. APP5*D BDCDAT. # 5nter fields and values for D1*P64 C75A6 BDCDAT. ?4M5) J;ield name 12 T4 BDCDAT";*A?. J;ield value 12 T4 BDCDAT";MA7. APP5*D BDCDAT. C75A6 BDCDAT. ?4M5) J;ield name :2 T4 BDCDAT";*A?. J;ield value :2 T4 BDCDAT";MA7. APP5*D BDCDAT. ... ... # tart next D1*P64 C75A6 BDCDAT. ?4M5) Jprogram name2 T4 BDCDAT"P6496A?. JD1*P64 number2 T4 BDCDAT"D1*P64. =L= T4 BDCDAT"D1*B59+*. APP5*D BDCDAT. 5*D;46?. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" ;) Identif+ing a !creen: The first record for each screen must contain information that identifies the screen) program name% screen name and a start"of"screen indicator. 1ou record this information in the P6496A?% D1*P64% and D1*B59+* fields of the BDCDATA structure. This sample BDCDATA starts a screen. The record specifies the program and screen identifiers. 0ith BDCDATA"D1*B59+*% the record shows that batch input data for a new screen is starting) #7a(p*e: BDCDATA"P6496A? N =sapms<Cm=. BDCDATA"D1*P64 N =F1FF=. BDCDATA"D1*B59+* N =x=.

ABAP Training

Page << of 51

BDC APP5*D BDCDATA. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" c) #ntering a =a*ue in a "ie*d: After the d!npro"start record% !ou must add a record for each field that is to receive a value. 1ou need fill onl! the ;*A? and ;MA7 fields. This sample BDCDATA enters a value into a field. The ;*A? field identifies the target field b! its table and field names. ;MA7 specifies the value that is to be entered) #7a(p*e: BDCDATA";*A? N =6 <C?";8*C35D+T=. BDCDATA";MA7 N =x=. APP5*D BDCDATA. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" d)#7ecuting a "unction: 1ou can execute a function in a transaction b! entering the function code or function $e! number in the command field of an AP session. 1ou use the ;*A? and ;MA7 fields to enter this information% &ust as !ou would for normal screen fields. The command field is identified b! a special name in batch input% BDC34GC4D5. This name is constant and alwa!s identifies the command field. This sample record would execute the save function. +t uses the function $e! assignment of save% which is ;11. A function $e! number must be prefixed with the . ,slashcharacter) #7a(p*e: BDCDATA";*A? N =BDC34GC4D5=. BDCDATA";MA7 N =.11=. This sample record also executes save% but uses the function code instead of the function $e! assignment. All functions% whether the! are displa!ed in menus or as buttons% are identified b! function codes. A function code must be prefixed with the N character. #7a(p*e: BDCDATA";*A? N =BDC34GC4D5=. BDCDATA";MA7 N =N8PDA=.

ABAP Training

Page </ of 51

BDC """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" e)#ntering =a*ues in 9oop "ie*ds ome screen fields need multiple values% one on each line. To provide input to one of these loop fields% !ou must use an explicit line index ) #7a(p*e: BDCDATA";*A? N =fieldx,5-=. BDCDATA";MA7 N =value=. The line index ,in the example) ,5-% line 5- indicates in which loop line on the screen values are to appear. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" f)Positioning the Cursor: To position the cursor on a particular field% !ou must use the special cursor field) #7a(p*e: BDCDATA";*A? N =BDC3C86 46=. BDCDATA";MA7 N =fieldx=. To position the cursor on a loop field% !ou must use again an index) #7a(p*e: BDCDATA";*A? N =BDC3C86 46=. BDCDATA";MA7 N =field!,5-=. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" g)#nding a Transaction: 1ou can successfull! complete processing of a transaction in batch input in either of two wa!s) D D leave the transaction and return to the AP main menu. trigger an update of the database.

ABAP Training

Page <5 of 51

BDC #nding a Transaction #7a(p*e: Returning to the !AP (ain (enu: ;rom the text input screen in the ABAP./ editor% for example% the following BDCDATA records are necessar! to leave the transaction) BDCDATA"P6496A? N = AP? 5DT=. #7eave text input field BDCDATA"D1*P64 N =:<1F=. BDCDATA"D1*B59+* N =L=. BDCDATA";*A? N =BDC34GC4D5=. BDCDATA";MA7 N =.<=. #Bac$ function $e! BDCDATA"P6496A? N = AP? <C?=. #7eave ABAP./ editor BDCDATA"D1*P64 N =F1FF=. BDCDATA"D1*B59+* N =L=. BDCDATA";*A? N =BDC34GC4D5=. BDCDATA";MA7 N =.15=. #Iuit function $e! """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :1)) CR#ATI $ BATC3 I P4T !#!!IO !: 4ne of the two recommended wa!s to process batch input data is to store the data in a batch input session. This session can then be run in the AP !stem to enter the batch input data into the s!stem. +n general% preparing a session is the best and most comfortable wa! to process batch input data. 'owever% !ou ma! wish to use the alternate method% CA77 T6A* ACT+4* 8 +*9% if !our batch input sessions cannot be run (uic$l! enough. ;or more information on choosing the best batch input method% see !e*ecting a Batch6Input %ethod:11) <

Creating? "i**ing? and C*osing a Batch Input !ession To create a session% program the following procedure using the following BDC3 function modules) 1. :. 4pen the batch input session using function module BDC8OP# 8$RO4P:1-) < ;or each transaction in the session)

ABAP Training

Page <@ of 51

BDC a. ;ill the BDCDATA structure with values for all screens and fields that must be processed in the transaction. ;or more information% please see 4sing the Batch Input Data !tructure:12)< b. Transfer the transaction to the session with BDC8I !#RT:1.) < <. Close the batch input session with BDC8C9O!#8$RO4P:1/)<

The following topics describe these function modules. ee !a(p*e Batch Input Progra(:22) for an example of how the function modules are used. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :1-) CR#ATI $ A !#!!IO 'IT3 BDC8OP# 8$RO4P : 8se the BDC34P5*39648P function module to do the following create a new session. 4nce !ou have created a session% then !ou can insert batch input data into it with BDC3+* 56T. 1ou cannot re"open a session that alread! exists and has been closed. +f !ou call BDC34P5*39648P with the name of an existing session% then an additional session with the same name is created. A batch input program ma! have onl! one session open at a time. Before opening a session% ma$e sure that an! sessions that the program closes an! sessions that it previousl! had opened.

BDC34P5*39648P ta$es the following 5LP46T+*9 parameters) D C7+5*T Client in which the session is to be processed. Default) +f !ou don=t provide a value for this parameter% the default is the client which the batch input program runs when the session is created. 9648P *ame of the session that is to be created. ?a! be up to 1: characters long. Default) *one. 1ou must specif! a session name. D '47DDAT5 7oc$ date. The session is loc$ed and ma! not be processed until after the date specif!. 4nl! a s!stem administrator with the 74CG authori>ation for

under D

that !ou

ABAP Training

Page <B of 51

BDC the authori>ation ob&ect Batch +nput Authori>ations can unloc$ and run a session before this date. ;ormat) 1111??DD ,C digits-. Default) *o loc$ date% session can be processed immediatel!. A loc$ date is optional. D G55P

6etain session after successful processing. et this option to the value L to have a session $ept after it has been successfull! processed. A session that is $ept remains in the input.output (ueue until an administrator deletes it. essions that contain errors in transactions are $ept even if G55P is not set. Default) +f not set% then sessions that are successfull! processed are deleted. 4nl! the batch input log is $ept. D 8 56

Authori>ations user for bac$ground processing. This is the user name that is used for chec$ing authori>ations if a session is started in bac$ground processing. The user must be authori>ed for all of the transactions and functions that are to be executed in a session. 4therwise% transactions will be terminated with #no authori>ation# errors. The user can be of t!pe dialog or bac$ground. Dialog users are normal interactive users in the AP !stem. Bac$ground users are user master records that are speciall! defined for providing authori>ations for bac$ground processing &obs. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :1.) ADDI $ DATA TO A !#!!IO : BDC8I !#RT : 8se the BDC3+* 56T function module to add a transaction to a batch input session. 1ou specif! the transaction that is to be started in the call to BDC3+* 56T. 1ou must provide a BDCDATA structure that contains all of the data re(uired to process the transaction completel!.

BDC3+* 56T ta$es the following parameters) D TC4D5

The code of the transaction that is to be run. ;or help in finding the transaction code of a function% see Ana*+,ing !AP Transactions:)) < TC4D5 is an 5LP46T+*9 parameter in the function module.

ABAP Training

Page <C of 51

BDC D locall!. ,refer to the $e!word documentation of 5T 8PDAT5 TA G 74CA7 for more informationD D1*P64TAB P4 T374CA7 Parameter to update data locall!. +f P4 T374CA7 N =L=% data will be updated

The BDCDATA structure that contains the data that is to be processed b! the transaction. D1*P64TAB is a tables parameter in the function module. ;or information on filling the structure% see Progra((ing Techni1ues: #ntering Data and #7ecuting "unctions:1&)< """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :1/) C9O!I $ A !#!!IO : BDC8C9O!#8$RO4P : 8se the BDC3C74 539648P function module to close a session after !ou have inserted all of !our batch input data into it. 4nce a session is closed% it can be processed.

BDC3C74 539648P needs no parameters. +t automaticall! closes the session that is currentl! open in !our program. 1ou must close a session before !ou can open another session from the same program. 1ou cannot re"open a session once it has been closed. A new call to BDC34P5*39648P with the same session name creates a new session with the same name. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :10) PROC#!!I $ BATC3 I P4T !#!!IO !: 0hen !ou create a batch input session% it remains in the batch input (ueue until it is explicitl! started. ession processing can be started in two wa!s) D An on"line user can start the session using the batch input menu options. ,To access the batch input options% choose !stem""2 ervices""2Batch +nput.D 1ou can submit the bac$ground &ob 6 BDC 8B to start a session in bac$ground processing. +f several sessions have the same name% 6 BDC 8B starts them all.

ABAP Training

Page <E of 51

BDC +t=s possible to coordinate the generation and execution of a session in the bac$ground processing s!stem. 1ou can% for example% schedule both the batch input program and 6 BDC 8B in the bac$ground. +f !ou designate the batch input &ob as the predecessor for 6 BDC 8B% then 6 BDC 8B will be started automaticall! when the batch input &ob successfull! completes. Alternativel!% !ou can schedule both the batch input program and 6 BDC 8B as &ob steps in a single bac$ground &ob. +n this case% however% 6 BDC 8B is started even if the batch input program should terminate abnormall!. ;or detailed information about processing batch input sessions% see %A A$I $ BATC3 I P4T !#!!IO !:B) in the !stem ervices guide. 1ou=ll find this guide in the Basis librar!% s!stem administration section% on the AP documentation CD"64?. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :12) 4!I $ CA99 TRA !ACTIO 4!I $ "OR BATC3 I P4T: Processing batch input data with CA77 T6A* ACT+4* 8 +*9 is the faster of the two recommended batch input methods. +n this method% batch input data is processed inline in !our batch input program. 5rror recover!% restarting% and management of batch input processing are all more comfortable if !ou use #classical# batch input processing b! wa! of batch input sessions. CA77 T6A* ACT+4* 8 +*9 is therefore recommended onl! if batch input sessions do not run fast enough to meet !our re(uirements. ;or more information on choosing a batch input method% please see !e*ecting a Batch6 Input %ethod:11) <

A program that uses CA77 T6A* ACT+4* 8 +*9 to submit batch input should perform the following steps) 1. Prepare a BDCDATA structure for the transaction that !ou wish to run. The re(uirements for filling the BDCDATA structure are the same as for #classical# batch input using sessions. ;or more information% please see 4sing the Batch Input Data !tructure:12)< :. the 0ith a CA77 T6A* ACT+4* 8 +*9 statement% call the transaction and pass BDCDATA structure to it as batch input. ;or example)

ABAP Training

Page /F of 51

BDC CA77 T6A* ACT+4* = 5<C= 8 +*9 BDCDATA ?4D5 =A= 8PDAT5 = =. ?5 A95 +*T4 ?5 TAB. The %ode Para(eter The ?4D5 parameter lets !ou specif! whether the batch input processing should be displa!ed to !ou as it happens. 1ou can choose between three modes) A Displa! ever!thing. All screens and the data that goes in them appear when !ou run !our program. This is the default setting for ?4D5 in CA77 T6A* ACT+4* 8 +*9. * Displa! nothing. All screens are processed invisibl!% regardless of whether there are errors or not. Control returns to !our program as soon as transaction processing is finished. ,Database updates however% ma! have ta$en place or ma! have not have ta$en place% depending on the value of the 8PDAT5 parameter.5 Displa! errors onl!. The transaction goes into displa! mode as soon as an error in one of the screens is detected. 1ou can then correct the error. The displa! modes are the same as those that are available for processing batch input sessions. The 4pdate Para(eter The 8PDAT5 parameter lets !ou specif! how updates produced b! a transaction should be processed. 1ou can select between these modes) A As!nchronous updating. +n this mode% the called transaction does not wait for an! updates it produces to be completed. +t simpl! passes the updates to the AP update service. As!nchronous processing therefore usuall! results in faster execution of !our batch input program. As!nchronous processing is *4T recommended for processing an! larger amount of data. This is because the called transaction receives no completion message from the update module in as!nchronous updating. The calling batch input program% in turn% cannot determine whether a called transaction ended with a successful update of the database or not. +f !ou use as!nchronous updating% then !ou will need to use the update management facilit! ,transaction ?1:- to chec$ whether updates have been terminated abnormall! during session processing. 5rror anal!sis and recover! is less convenient than with s!nchronous updating. that it !nchronous updating. +n this mode% the called transaction waits for an! updates produces to be completed. 5xecution is slower than with as!nchronous

ABAP Training

Page /1 of 51

BDC updating because called transactions wait for updating to be completed. 'owever% the called transaction is able to return an! update error message that occurs to !our program. +t=s much easier for !ou to anal!>e and recover from errors. 7 7ocal updating. +f !ou update data locall!% the update of the database will not be processed in a separate process% but in the process of the calling program. ,6efer to the $e!word documentation of 5T 8PDAT5 TA G 74CA7 for more information.The %essages Para(eter The ?5 A95 specification indicates that all s!stem messages issued during a CA77 T6A* ACT+4* 8 +*9 are written into the internal table J?5 TAB2. The internal table must have the structure BDC? 9C477. #7a(p*e 1ou can have s!stem messages issued b! transaction 5<C ,bottom of example- collected in table ?5 TAB with the following coding) DATA B59+* 4; BDCDATA 4CC86 1FF. +*C78D5 T68CT865 BDCDATA. DATA 5*D 4; BDCDATA. DATA B59+* 4; ?5 TAB 4CC86 1F. +*C78D5 T68CT865 BDC? 9C477. DATA 5*D 4; ?5 TAB. DATA 65P46T,C-. BDCDATA"P6496A? N = AP? <C?=. BDCDATA"D1*P64 N =F1FF=. BDCDATA"D1*B59+* N =L=. APP5*D BDCDATA. C75A6 BDCDATA. BDCDATA";*A? N =6 <C?"P6496A??=. BDCDATA";MA7 N 65P46T. APP5*D BDCDATA. ... CA77 T6A* ACT+4* = 5<C= 8 +*9 BDCDATA ?4D5 =*= ?5 A95 +*T4 ?5 TAB. The following figures show the return codes from CA77 T6A* ACT+4* 8 +*9 and the s!stem fields that contain message information from the called transaction. As the return code chart shows% return codes above 1FFF are reserved for batch input. +f !ou use the ?5 A95 +*T4 Jmessage table2 option% then !ou do not need to (uer! the s!stem fields shown belowA their contents are automaticall! written into the message

ABAP Training

Page /: of 51

BDC table. 1ou can loop over the message table to write out an! messages that were entered into it. #rror Ana*+sis and Restart Capa;i*it+ 8nli$e #classical# batch input processing using sessions% CA77 T6A* ACT+4* 8 +*9 processing does not provide an! special handling for incorrect transactions. There is no restart capabilit! for transactions that contain errors or produce update failures. 1ou can handle incorrect transactions b! using update mode ,s!nchronous updatingand chec$ing the return code from CA77 T6A* ACT+4* 8 +*9. +f the return code is an!thing other than F% then !ou should do the following) D write out or save the message table D use the BDCDATA table that !ou generated for the CA77 T6A* ACT+4* 8 +*9 to generate a batch input session for the fault! transaction. 1ou can then anal!>e the fault! transaction and correct the error using the tools provided in the batch input management facilit!. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :25) 4!I $ CA99 DIA9O$ 'IT3 BATC3 I P4T: A program that uses CA77 D+A749 to submit batch input should perform the following steps) 1. ;or the screens !ou want processed% fill all desired fields. :. 8se a CA77 D+A749 statement to call the dialog module and to pass it to the BDCDATA table.

The ?4D5 parameter in the CA77 statement is explained in 8sing CA99 TRA !ACTIO 4!I $ for Batch Input:12)< #7a(p*e CA77 D+A749 =D+A7491= 8 +*9 BDCDATA ?4D5 =5=. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :21) DIR#CT I P4T: To enhance the batch input procedure% the s!stem offers the direct input techni(ue% especiall! for transferring large amounts of data. +n contrast to batch input% this techni(ue

ABAP Training

Page /< of 51

BDC does not create sessions% but stores the data directl!. +t does not process screens. To enter the data into the corresponding database tables directl!% the s!stem calls a number of function modules that execute an! necessar! chec$s. +n case of errors% the direct input techni(ue provides a restart mechanism. 'owever% to be able to activate the restart mechnism% direct input programs must be executed in the bac$ground onl!. To maintain and start these programs% use program 6B?M '40 or the transaction B?MF. 5xamples for direct input programs are) Program Application """"""""""""" """""""""""" 6;B+B7FF ;+ 6?DAT+*D ?? 6MA; FF D 6AA7TD11 A? 6G5M5LTF C4"PA ;or more information% see the respective program documentation. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :22) !A%P9# BATC3 I P4T PRO$RA%: The following program demonstrates both the creation of sessions% and the use of CA77 T6A* ACT+4* 8 +*9. 65P46T 6PBDC:FF 7+*5" +Q5 1:F. K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K Add a line in a report K K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K PA6A?5T56 ) BDCT1P5 T1P5 C D5;A87T =?=% # ? N Create batch input session # T N Call transaction #"""""""""""""""""""""""""""""""""""""""""""""""""""K # 4nl! used for batch input sessions K #"""""""""""""""""""""""""""""""""""""""""""""""""""K 9648P,1:- T1P5 C D5;A87T =BDCT5 T=% # group name of session 8 56,1:- T1P5 C D5;A87T 1"8*A?5% # user name for starting the # session in bac$ground G55P,1- T1P5 C% # = = N delete session after processing # =L= N $eep session after successful # processing '47DDAT5 7+G5 1"DAT8?% #"""""""""""""""""""""""""""""""""""""""""""""""""""K # 4nl! used for call transaction K

ABAP Training

Page // of 51

BDC #"""""""""""""""""""""""""""""""""""""""""""""""""""K D?4D5 T1P5 C D5;A87T =A=. # Displa! mode # =A= N displa! all screens # =5= N displa! onl! errors # =*= N displa! nothing K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K Batch input data for a single transaction K K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K DATA) B59+* 4; BDCDATA 4CC86 F. +*C78D5 T68CT865 BDCDATA. DATA) 5*D 4; BDCDATA. DATA) B59+* 4; ?5 TAB 4CC86 F. +*C78D5 T68CT865 BDC? 9C477. DATA) 5*D 4; ?5 TAB. K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K 9enerate batch input K K K K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K CA 5 BDCT1P5. 0'5* =?=. P56;46? C65AT539648P. 5L+T. 0'5* =T=. P56;46? CA773T6A* ACT+4*. 5L+T. 5*DCA 5. K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K K K Create batch input session K K K K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K ;46? C65AT539648P. 06+T5) . =Create group=. #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K # 4pen batch input group K #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K CA77 ;8*CT+4* =BDC34P5*39648P= 5LP46T+*9 C7+5*T N 1"?A*DT 9648P N 9648P 8 56 N 8 56 G55P N G55P '47DDAT5 N '47DDAT5. 06+T5) . =BDC34P5*39648P rc N=,EEE-% 1" 8B6C. #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K

ABAP Training

Page /5 of 51

BDC # +nsert first transaction K #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K P56;46? 95*3BDC3DATA. CA77 ;8*CT+4* =BDC3+* 56T= 5LP46T+*9 TC4D5 N = 5<C= TAB75 D1*P64TAB N BDCDATA. 06+T5) . =BDC3+* 56T rc N=,EEE-% 1" 8B6C. #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K # +nsert second transaction K #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K P56;46? 95*3BDC3DATA. CA77 ;8*CT+4* =BDC3+* 56T= 5LP46T+*9 TC4D5 N = 5<C= TAB75 D1*P64TAB N BDCDATA. 06+T5) . =BDC3+* 56T rc N=,EEE-% 1" 8B6C. #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K # Close batch input group K #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K CA77 ;8*CT+4* =BDC3C74 539648P=. 06+T5) . =BDC3C74 539648P rc N=,EEE-% 1" 8B6C. 5*D;46?. # 5nd C65AT539648P K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K K K Call Transaction 8sing K K K K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K ;46? CA773T6A* ACT+4*. 06+T5) . =Call Transaction 6C N=,EEE-. P56;46? 95*3BDC3DATA. CA77 T6A* ACT+4* = 5<C= 8 +*9 BDCDATA ?4D5 D?4D5 ?5 +*T4 ?5 TAB. 06+T5) 1" 8B6C% 1"? 9T1% 1"? 9+D% 1"? 9*4% 1"? 9M1. 06+T5) . = =% 1"? 9M:. 06+T5) . = =% 1"? 9M<. 06+T5) . = =% 1"? 9M/. 5*D;46?. # 5nd CA773T6A* ACT+4* K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K K K Create batch input data for K K transaction 5<C K K K

A95

ABAP Training

Page /@ of 51

BDC K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K ;46? 95*3BDC3DATA. DATA) 7+*5 7+G5 BDCDATA";MA7. 65;65 ' BDCDATA. K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K ;irst screen of transaction K K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K P56;46? BDC3D1*P64 8 +*9 = AP? <C?= =F1FF=. P56;46? BDC3;+57D 8 +*9 =6 <C?"P6496A??= =6PBDCEEE=. P56;46? BDC3;+57D 8 +*9 =bdc3cursor= =chap=. P56;46? BDC3;+57D 8 +*9 =BDC34GC4D5= =.FF=. K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K +n editor% go to bottom of report K K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K P56;46? BDC3D1*P64 8 +*9 = AP? 5DT= =:<1F=. P56;46? BDC3;+57D 8 +*9 =6 TLP"TDC4??7+*5= =B4T=. K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K +nsert line into report K K""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""K P56;46? BDC3D1*P64 8 +*9 = AP? 5DT= =:<1F=. P56;46? BDC3;+57D 8 +*9 =6 TLP"TD7+*5C4?,1B-= =+=. K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K 9o to bottom of report again K K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K P56;46? BDC3D1*P64 8 +*9 = AP? 5DT= =:<1F=. P56;46? BDC3;+57D 8 +*9 =6 TLP"TDC4??7+*5= =B4T=. K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K ?odif! line in report and save report K K ,5nter f11 in o$"codeK K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K P56;46? BDC3D1*P64 8 +*9 = AP? 5DT= =:<1F=. 7+*5 N =Batchinput=. 7+*5O:F N 1"DAT8?. 7+*5O<F N 1"8Q5+T. P56;46? BDC3;+57D 8 +*9 =6 TLP"TD7+*5,1B-= 7+*5. P56;46? BDC3;+57D 8 +*9 =BDC34GC4D5= =.11=. K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K 7eave the editor ,enter f< in o$"codeK K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K P56;46? BDC3D1*P64 8 +*9 = AP? 5DT= =:<1F=. P56;46? BDC3;+57D 8 +*9 =BDC34GC4D5= =.<=. K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K 7eave transaction se<C ,enter f15 in K o$"codeK""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K K

ABAP Training

Page /B of 51

BDC P56;46? BDC3D1*P64 8 +*9 = AP? <C?= =F1FF=. P56;46? BDC3;+57D 8 +*9 =BDC34GC4D5= =.15=. 5*D;46?. #5nd 95*3BDC3DATA K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K K +n the batch input data% start a new screen K K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K ;46? BDC3D1*P64 8 +*9 P6496A? D1*P64. C75A6 BDCDATA. BDCDATA"P6496A? N P6496A?. BDCDATA"D1*P64 N D1*P64. BDCDATA"D1*B59+* N =L=. APP5*D BDCDATA. 5*D;46?. #5nd BDC3D1*P64 K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K K K +n the batch input data% insert a field K K""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""K ;46? BDC3;+57D 8 +*9 ;*A? ;MA7. C75A6 BDCDATA. BDCDATA";*A? N ;*A?. BDCDATA";MA7 N ;MA7. APP5*D BDCDATA. 5*D;46?.

K K K

K K K

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :2&) BATC3 I P4T R#CORDI $ "OR TRA !ACTIO R4 !: This section tells !ou how to use the recording functions of batch input. ;or more information% refer to these sections) a)Recording features ;)!a(p*e progra( c)!pecia* recording features """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" a)Recording features The recording function offers the following features) D D D recording transaction runs% creating batch input sessions from the recorded transaction run% generating a batch input program from the recorded data.

ABAP Training

Page /C of 51

BDC 6ecording transaction runs A batch input recording consists of a se(uence of transactions with the screens processed. A screen ,program name% screen name- contains the modified fields ,field name% field value-% the executed user command ,BDC34GC4D5- and the cursor position ,BDC3C86 46-. To start the recording function% go to the batch input initial screen and choose 6ecord or directl! call transaction 'DB. The s!stem stores each recording under a name of up to 1: characters that !ou can choose at will. 1ou must specif! this name when starting the recording. The following special characters are not allowed) . % , - = # N R S T U. The recording function offers an overview of all exising recordings. To displa! the overview% clic$ on 4verview. 1ou can limit the selection b! entering a date interval. To create a recording% specif! the recording name and choose Create. +n the subse(uent dialog box% enter the name of the transaction !ou want to record. Then execute the transaction and enter the re(uired values in the screen fields. After the end of the transaction% the s!stem displa!s the processed screens ,module pool% screen number-% the changed fields ,field name% field value-% the executed user commands ,BDC34GC4D5-. and the cursor position ,BDC3C86 46- in a hierarchical list. Choose Cop! transaction to cop! the executed transaction run into the recording. Choose *ext transaction if !ou want to record another transaction run with a different transaction. After recording all desired transactions% save the recording. Create ;atch input sessions fro( the recorded transaction run ;rom within the recording overview% choose Create session to create a batch input session with the data of the recorded transaction. 1ou can then process this session as usual. $enerate a ;atch input progra( fro( the recorded data Apart from creating a session% !ou can also generate an ABAP./ batch input program from within the recording overview. +n this case% select the desired recording and specif! the name of the program !ou want to generate. Then maintain the program attributes and the entr! in the ob&ect list. The generated program contains the entire coding re(uired to create a batch input session. Thus !ou can leave out the transaction execution and the determination of the module pool name% the screen numbers% the field names% and the function codes. 1ou ma! need to modif! this program onl! slightl!% if !ou want to use it% for example% to read the data to be transferred from a se(uential dataset.

ABAP Training

Page /E of 51

BDC """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" ;)sa(p*e progra( This example shows a program that was generated to transfer data using transaction T;CA. This program changes the plane t!pe , ;7+9'T"P7A*5T1P5- for the airline , ;7+9'T"CA66+D- =7'= and the connection +D , ;7+9'T"C4**+D- =:/F:=. report $htfcaF1. include bdcrecxx. start"of"selection. perform open3group. perform bdc3d!npro using = AP?T;CA= =F1FF=. perform bdc3field using =BDC34GC4D5= =8PDA=. perform bdc3field using =BDC3C86 46= = ;7+9'T"CA66+D=. perform bdc3field using = ;7+9'T"CA66+D= =7'=. perform bdc3field using = ;7+9'T"C4**+D= =:/F:=. perform bdc3d!npro using = AP?T;CA= =F:FF=. perform bdc3field using =BDC34GC4D5= = AM5=. perform bdc3field using =BDC3C86 46= = ;7+9'T"P7A*5T1P5,F:-=. perform bdc3field using = ;7+9'T"P7A*5T1P5,F:-= =A<:1=. perform bdc3transaction using =T;CA=. perform close3group. The subroutines called are part of the include program BDC65CLL. The! call the function modules re(uired for creating a batch input session and the! fill the BDC table. +n addition% this include parameter contains statements for the selection screen la!out. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" c)specia* recording features: The following data is not recorded) D D D D D ;1% ;/% and customer"related ;1 and ;/ functions% all functions of the menus !stem and 'elp% values of the standard variant% error dialogs and warning dialogs% scrolling via the scrollbar ,use ;:1 to ;:/ instead-.

C4??+T 046G indicates the successful end of the transaction and% thus% of the recording. 75AM5 T4 T6A* ACT+4* cannot be processed in batch input and% therefore% ends the recording.

ABAP Training

Page 5F of 51

BDC """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :2)) BATC3 I P4T A4T3ORIEATIO !: 1ou need no special authori>ation "" other than the ABAP./ run time authori>ation ,authori>ation ob&ect 3P6496A? "" to run a program that creates batch input. An! user can create batch input sessions. tarting processing for a session once it is in the (ueue is another matter% however. To start sessions% !ou need the authori>ations described in #?anaging Batch +nput essions# in the !stem ervices guide. 1ou=ll find this guide in the Basis librar!% s!stem administration section% on the AP documentation CD"64?.

ABAP Training

Page 51 of 51

Anda mungkin juga menyukai