Data Interfaces - Chapter 07_V1

Embed Size (px)

Citation preview

  • 7/30/2019 Data Interfaces - Chapter 07_V1

    1/9

    IBM Global Services

    Copyright IBM Corporation 2003Data Interfaces | 5.07 | August 2003Slide 1

    PROGRAM DYNPRO DYNBEGIN FNAM FVAL

    SAPMF02K 0106 X

    RF02K-LIFNR TEST1

    RF02K-D0110 X

    SAPMF02K 0110 XLFA1-STRAS 123 Main St.

    BDC_OKCODE /11

    BDC Table

    Overview

    Create Batch Input

    Session

    (BDC Program)

    Use in CALL

    TRANSACTION

    statement

    Use in CALL

    DIALOG

    statement

  • 7/30/2019 Data Interfaces - Chapter 07_V1

    2/9

    IBM Global Services

    Copyright IBM Corporation 2003Data Interfaces | 5.07 | August 2003Slide 2

    When is the

    SAP database

    updated?

    How are errors

    handled?

    Create batch

    input session

    (BDC Program):

    During the processing

    of the batch input

    session

    Automatically by the

    system during the

    processing of the

    batch input session

    CALL TRANSACTION:

    CALL DIALOG:

    During the execution

    of the batch input

    program

    Must be handled in

    the batch input

    program

    Differences in Batch Input Methods

  • 7/30/2019 Data Interfaces - Chapter 07_V1

    3/9

    IBM Global Services

    Copyright IBM Corporation 2003Data Interfaces | 5.07 | August 2003Slide 3

    Name

    Street

    Computers, Inc.

    123 Main St.

    City Philadelphia

    VendorCompany Code

    TEST1

    AddressX

    VendorCompany Code

    TEST2

    AddressX

    Name

    Street

    Computer Land

    10 Walnut St.

    City Boston

    To illustrate the CALL TRANSACTION and CALL

    DIALOG methods, we will use the example to change

    vendors coming from a sequential file.

    Example - Change Vendors

  • 7/30/2019 Data Interfaces - Chapter 07_V1

    4/9

    IBM Global Services

    Copyright IBM Corporation 2003Data Interfaces | 5.07 | August 2003Slide 4

    CALL TRANSACTION

    USING

    MODE UPDATE

    MESSAGES INTO

    .

    A: display all

    E: display errors only

    N: no display

    S: synchronous

    A: asynchronous

    CALL TRANSACTION

    USING Statement

  • 7/30/2019 Data Interfaces - Chapter 07_V1

    5/9

    IBM Global Services

    Copyright IBM Corporation 2003Data Interfaces | 5.07 | August 2003Slide 5

    REPORT Y180DM10.

    DATA: BDC_TAB LIKE STANDARD TABLE OF

    BDCDATA INITIAL SIZE 6 WITH HEADER LINE,

    INFILE(20) VALUE /tmp/bc180_file4.

    DATA: BEGIN OF INREC,

    VENDNUM LIKE LFA1-LIFNR,

    STREET LIKE LFA1-STRAS,

    END OF INREC.

    PARAMETERS: DISPMODE DEFAULT A,

    UPDAMODE DEFAULT S.

    ** This program is continued on the next slide **

    Step #1

    Step #2

    Example #1 - Declaration Section

  • 7/30/2019 Data Interfaces - Chapter 07_V1

    6/9

    IBM Global Services

    Copyright IBM Corporation 2003Data Interfaces | 5.07 | August 2003Slide 6

    START-OF-SELECTION.

    OPEN DATASET INFILE

    FOR INPUT IN TEXT MODE.

    DO.

    READ DATASET INFILE INTO INREC.

    IF SY-SUBRC 0. EXIT. ENDIF.PERFORM FILL_BDC_TAB.

    CALL TRANSACTION FK02

    USING BDC_TAB

    MODE DISPMODE

    UPDATE UPDAMODE.

    IF SY-SUBRC 0.WRITE: / Error.

    ENDIF.

    ENDDO.

    CLOSE DATASET INFILE.

    Step #3

    Step #4

    Step #5Step #6

    ** This program is continued on the next slide **

    Step #7

    Step #8

    Step #9

    Example #1 - Main Program

  • 7/30/2019 Data Interfaces - Chapter 07_V1

    7/9

    IBM Global Services

    Copyright IBM Corporation 2003Data Interfaces | 5.07 | August 2003Slide 7

    FORM FILL_BDC_TAB.

    REFRESH BDC_TAB.

    PERFORM POPULATE_BDC_TAB

    USING:

    1 SAPMF02K 0106,

    RF02K-LIFNR INREC-VENDNUM,

    RF02K-D0110 X,

    1 SAPMF02K 0110,

    LFA1-STRAS INREC-STREET,

    BDC_OKCODE /11.

    ENDFORM.

    FORM POPULATE_BDC_TAB USING

    FLAG VAR1 VAR2.

    CLEAR BDC_TAB.

    IF FLAG = 1.

    BDC_TAB-PROGRAM = VAR1.

    BDC_TAB-DYNPRO = VAR2.

    BDC_TAB-DYNBEGIN = X.

    ELSE.

    BDC_TAB-FNAM = VAR1.

    BDC_TAB-FVAL = VAR2.

    ENDIF.

    APPEND BDC_TAB.

    ENDFORM.

    Notice that the vendor number and street values are coming

    from the files records read into the INREC structure.

    Example #1 - Subroutines

  • 7/30/2019 Data Interfaces - Chapter 07_V1

    8/9

    IBM Global Services

    Copyright IBM Corporation 2003Data Interfaces | 5.07 | August 2003Slide 8

    Write an error report.

    Send the record(s) in

    error to an error file.

    Create a batch input

    session with the

    record(s) in error.

    Error Handling

  • 7/30/2019 Data Interfaces - Chapter 07_V1

    9/9

    IBM Global Services

    Copyright IBM Corporation 2003Data Interfaces | 5.07 | August 2003Slide 9

    DO.

    . . .

    PERFORM FILL_BDC_TAB.

    CALL TRANSACTION FK02

    USING BDC_TAB

    MODE N

    UPDATE S.IF SY-SUBRC 0.

    WRITE: / Error.

    ENDIF.

    ENDDO.

    DO.

    . . .

    PERFORM FILL_BDC_TAB.

    CALL TRANSACTION FK02

    USING BDC_TAB

    MODE N

    UPDATE A.IF SY-SUBRC 0.

    WRITE: / Transaction error.

    ENDIF.

    ENDDO.

    With synchronous updating, we

    can check SY-SUBRC to

    determine the success of the

    transaction and the actual

    update to the database.

    With asynchronous updating,

    we can check SY-SUBRC to

    determine the success of the

    transaction only, no tthe actual

    update to the database.

    Synchronous versus Asynchronous