batch data conversion

Upload: ronvallanda

Post on 06-Apr-2018

245 views

Category:

Documents


1 download

TRANSCRIPT

  • 8/3/2019 Batch Data Conversion

    1/25

    BATCH DATA COMMUNICATION

    www.1000projects.com

    www.chetanasprojects.com

    www.campusmiles.com

  • 8/3/2019 Batch Data Conversion

    2/25

    Presentation Overview

    Duration 90 minutes

    Objectives Getting the clear concept of BDC

    How to use BDC effectively?

    To know the significance of BDC

    Pre-Requisites Knowledge of Dialog Programming

    Little Functional overview

    Contents Introduction to BDC.

    Method of Batch Input.

    Batch Data Procedures.

    Writing BDC programs.

    Creating Batch input Session.

    Batch Input Recording.

    File Transfer and File Handling

    Demo 30 minutes

  • 8/3/2019 Batch Data Conversion

    3/25

    Introduction

    Method of transferring data into the System from other SAP andnon-SAP Systems.

    Work by carrying out normal SAP transactions just as a user would.

    Execute the transaction automatically.

    Suitable for entering large amount of data.

    No manual interaction .

  • 8/3/2019 Batch Data Conversion

    4/25

    Methods of Batch Input

    SAP provide two basic methods for transferring legacy data in to the

    R/3 System. Classical Batch Input method.

    Call Transaction Method.

    1. Classical Batch Input method

    An ABAP/4 program reads the external data to the SAP System

    and stores in a batch input session.

    After creating the session, you can run the session to execute the

    SAP transaction in it. You can either monitor the session or run it in

    the background.

    This method uses the function modules BDC_ OPEN,

    BDC_INSERT and BDC_CLOSE

  • 8/3/2019 Batch Data Conversion

    5/25

    Classical Batch Input method

    Batch input sessions can be processed in various ways:

    In the foreground In the background

    During processing, with error display

    You should process batch input sessions in the foreground

    or using the error display if you want to test the data transfer.

    If you want to execute the data transfer or test its

    performance, you should process the sessions in the

    background.

  • 8/3/2019 Batch Data Conversion

    6/25

    Classical Batch Input Method

    Asynchronous processing

    Transfer data for multiple transactions.

    Synchronous database update.

    A batch input process log is generated for each session.

    Session cannot be generated in parallel.

  • 8/3/2019 Batch Data Conversion

    7/25

    Methods of Batch Input

    2. Call Transaction Method.

    ABAP/4 program uses CALL

    TRANSACTION USING

    statement to run an SAP

    transaction.

    Entire batch input process takes

    place online in the program

  • 8/3/2019 Batch Data Conversion

    8/25

    CALL TRANSACTION Method

    Using CALL TRANSACTION USING statement

    Faster processing of data

    Synchronous processing

    Transfer data for a single transaction.

    No batch input processing log is generated.

  • 8/3/2019 Batch Data Conversion

    9/25

    Batch input procedures

    1 Analysis of the legacy data.

    Determine how the data to betransferred is to be mapped in

    to the SAP Structure. Also take

    note of necessary data type or

    data length conversions.

    2 Generate SAP data structures

    for using in export programs.

  • 8/3/2019 Batch Data Conversion

    10/25

    Batch input procedures

    4 Export the data in to a sequential file. Note that character format isrequired by predefined SAP batch input programs.

    5 If the SAP supplied BDC programs are not used, code your ownbatch input program. Choose an appropriate batch input methodaccording to the situation.

    6 Process the data and add it to the SAP System.

    7 Analyze the process log. For the CALL TRANSACTION method,where no proper log is created, use the messages collected by your

    program.

    8 From the results of the process analysis, correct and reprocess theerroneous data.

  • 8/3/2019 Batch Data Conversion

    11/25

    Writing BDC program

    Analyze the transaction(s) to process batch input data.

    Decide on the batch input method to use.

    Read data from a sequential file

    Perform data conversion or error checking.

    Storing the data in the batch input structure,BDCDATA.

    Generate a batch input session for classical batch input,orprocess the data directly with CALL TRANSACTION USING

    statement.

  • 8/3/2019 Batch Data Conversion

    12/25

    Batch input data structure

    Declaration of batch input data structure

    DATA : BEGIN OF < bdc table>

    OCCURS .

    INCLUDE STRUCTURE BDCDATA.

    DATA:END OF .

    BDCDATA structureField name Type Length Description

    PROGRAM CHAR 8 Module pool

    DYNPRO NUMC 4 Dynpro number

    DYNBEGIN CHAR 1 Starting a dynpro

    FNAM CHAR 35 Field nameFVAL CHAR 80 Field value

  • 8/3/2019 Batch Data Conversion

    13/25

    Creating Batch input session

    Open the batch input session session using function moduleBDC_OPEN_GROUP.

    For each transaction in the session:

    a. Fill the BDCDATA with values for all screens and fields

    processed in the transaction.b. Transfer the transaction to the session with

    BDC_INSERT.

    Close the batch input session with BDC_CLOSE_GROUP.

  • 8/3/2019 Batch Data Conversion

    14/25

    Format of BDC_OPEN_GROUP

    CALL FUNCTION BDC_OPEN_GROUP

    EXPORTINGCLIENT =

    GROUP =

    HOLDATA =

    KEEP =

    USER =

    EXCEPTIONS RUNNING

    QUEUE_ERROR = 1

    CLIENT_INVALID = 2

    GROUP_INVALID = 3.

  • 8/3/2019 Batch Data Conversion

    15/25

    Format for BDC_INSERT and BDC_CLOSE_GROUP

    CALL FUNCTION BDC_INSERT

    EXPORTING TCODE =

    TABLES DYNPROTAB =

    EXCEPTIONS

    INTERNAL_ERROR = 1

    NOT_OPEN = 2

    QUEUE_ERROR = 3TCODE_INVALID = 4

    CALL FUNCTION BDC_CLOSE_GROUP

    EXCEPTIONS

    NOT_OPEN = 1QUEUE_ERROR = 2

    Note : Close the session after opening it

  • 8/3/2019 Batch Data Conversion

    16/25

    Using CALL TRANSACTION USING for batch input

    CALL TRANSACTION

    USING

    MODE

    UPDATE

    MESSAGES INTO messtab

    DISPLAY MODE:

    A :display all(default setting)

    E :Display only error

    N :No display

    Update mode

    S : continue processing when update is completed(synchronous)

    A : continue processing immediately.

    Note: messtab,an internal table must have a structure

    BDCMSGCOLL.

  • 8/3/2019 Batch Data Conversion

    17/25

    Batch Input Recorder

    SAPAG

    R

    The Batch Input Recorder (1)

    Customer Edit Goto Extras Environment System Help

    Create Customer: F.I. Initial ScreenCreate Customer: F.I. Initial Screen

    Recording NameCustomer

    Company code

    Account group

    Z-Intern

    0001

    Customer

    Company code

    BI-Re

    corder

    Field name Field contents

    RF02D-KUNNR Z-InternRF02D-BUKRSRF02D-KTOKD

    0001KUNA

    Template

  • 8/3/2019 Batch Data Conversion

    18/25

    Batch Input Recorder

    Batch input recorder records transactions which are manually entered and

    create a batch input session which can be executed later using SM35.

    Begin the batch input recorder by selecting the Recording pushbutton fromthe batch input initial screen.

    The recording name is a user defined name and can match the batch input

    session name which can be created from the recording.

    Enter a SAP transaction and begin posting the transaction.

    After you have completed posting a SAP transaction you either choose Get

    Transaction and Save to end the recording or Next Transaction and postanother transaction.

    Once you have saved the recording you can create a batch input session

    from the recording and/or generate a batch input program from the

    recording.

    The batch input session you created can now be analyzed just like any

    other batch input session. The program which is generated by the function of the batch input recorder

    is a powerful tool for the data interface programmer. It provides an solid

    base which can then be altered according to customer requirements.

  • 8/3/2019 Batch Data Conversion

    19/25

    BDC Program

    report zbdc05 .

    tables: ztrg_em05.

    data: begin of itab occurs 0,

    emplno(6),

    empl_name like ztrg_em05-empl_name,

    deptno(3),

    end of itab.

    data: bdctab like bdcdata occurs 0 with header line.

    call function 'WS_UPLOAD'

    exporting

    filename = 'C:\DEMO.TXT'

    filetype = 'DAT'

    tables

    data_tab = itab

    exceptions

    ----

    call function 'BDC_OPEN_GROUP'

    exportingclient = sy-mandt

    group = 'TEST'

    user = sy-uname

    exceptions

  • 8/3/2019 Batch Data Conversion

    20/25

    BDC Program

    loop at itab.

    refresh bdctab.

    clear bdctab.

    perform bdcfill using : 'X' '9000' 'SAPMZ705',' ' 'BDC_OKCODE' '/5',

    'X' '9000' 'SAPMZ705',

    ' ' 'ZTRG_EM05-EMPLNO' itab-emplno,

    ' ' 'ZTRG_EM05-EMPL_NAME' itab-empl_

    ' ' 'ZTRG_EM05-DEPTNO' itab-deptno,

    'X' '9000' 'SAPMZ705',

    ' ' 'BDC_OKCODE' '/11'.

    call function 'BDC_INSERT'

    exporting

    tcode = 'Z705'

    tables

    dynprotab = bdctab

    exceptions

    ----

    write 'BDC inserted'.

    endloop.

    call function 'BDC_CLOSE_GROUP'

    exceptions

    ----

  • 8/3/2019 Batch Data Conversion

    21/25

    FILE TRANSFER & FILE HANDLING

    OPEN DATASET dsn.

    Additions:1. ... FOR OUTPUT

    2. ... FOR INPUT

    3. ... FOR APPENDING

    4. ... IN BINARY MODE

    5. ... IN TEXT MODE

    6. ... AT POSITION pos

    7. ... TYPE ctrl

    8. ... MESSAGE mess

    9. ... FILTER

  • 8/3/2019 Batch Data Conversion

    22/25

    FILE TRANSFER & FILE HANDLING

    Opens the specified file. If no addition is specified, the file is

    opened for reading and in binary mode .

    The return code is set as follows:

    SY-SUBRC = 0: The file was opened.

    SY-SUBRC = 8: The file could not be opened.

  • 8/3/2019 Batch Data Conversion

    23/25

    FILE TRANSFER & FILE HANDLING

    Example

    DATA: DSN(20) VALUE '/usr/test',RECORD(80).

    OPEN DATASET DSN.

    DO.

    READ DATASET DSN INTO RECORD.IF SY-SUBRC NE 0.

    EXIT.

    ELSE.

    WRITE: / RECORD.

    ENDIF.ENDDO.

    CLOSE DATASET DSN.

  • 8/3/2019 Batch Data Conversion

    24/25

    FILE TRANSFER & FILE HANDLING

    TRANSFER f TO dsn.

    Transfers the field f (usually a field string) to the

    sequential file specified in dsn (this may be a literal or a

    field).

    Example DATA REC(80).

    TRANSFER REC TO '/usr/test'.

  • 8/3/2019 Batch Data Conversion

    25/25