22
IBM Global Business Services © IBM Corporation 2013 Data Interfaces | Dec-2008 Batch Input Session

Chapter 05_ Batch Input Session

Embed Size (px)

DESCRIPTION

Chapter 05_ Batch Input Session

Citation preview

Page 1: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 2013Data Interfaces | Dec-2008

Batch Input Session

Page 2: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 20132 Dec-2008Data Interfaces |

Objectives

The participants will be able to: Create the Batch Input part of an Inbound Interface.

Describe the Batch Input Session Method for Batch Input.

Page 3: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 20133 Dec-2008Data Interfaces |

Overview

SAPSAPDatabaseDatabase

TableTable

BatchInput

Session

BDCProgram

ExternalData

The first batch input method is to create a batch input session. It is the processing of this batch input

session that updates the database, not the execution of the batch input program.

Page 4: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 20134 Dec-2008Data Interfaces |

Creating Batch Input Sessions

“BDC_INSERT” is called for each

transaction entered into the

batch input session.

Open Batch Input SessionOpen Batch Input Session

Close Batch Input SessionClose Batch Input Session

Insert Transaction Data into Session

BDC_OPEN_GROUP

BDC_INSERT

BDC_CLOSE_GROUP

Page 5: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 20135 Dec-2008Data Interfaces |

BDC_OPEN_GROUP

CALL FUNCTION ‘BDC_OPEN_GROUP’

EXPORTING

CLIENT = <client>

GROUP = <session name>

HOLDDATE = <lock session until date>

KEEP= <keep or delete session>

USER= <user name>

EXCEPTIONS

CLIENT_INVALID = 1

. . .

OTHERS = 11.

SY-SUBRCCHECK

Page 6: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 20136 Dec-2008Data Interfaces |

BDC_INSERT

CALL FUNCTION ‘BDC_INSERT’

EXPORTING

TCODE = <transaction code>

POST_LOCAL = <local update>

TABLES

DYNPROTAB = <bdc internal table>

EXCEPTIONS

INTERNAL_ERROR = 1

. . .

OTHERS = 5.

SY-SUBRCCHECK

Page 7: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 20137 Dec-2008Data Interfaces |

BDC_INSERT (Contd.)

CALL FUNCTION ‘BDC_INSERT’

EXPORTING

TCODE = <transaction code>

POST_LOCAL = <local update>

TABLES

DYNPROTAB = <bdc internal table>

EXCEPTIONS

INTERNAL_ERROR = 1

. . .

OTHERS = 5.

SY-SUBRCCHECK

Page 8: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 20138 Dec-2008Data Interfaces |

BDC_CLOSE_GROUP

CALL FUNCTION ‘BDC_CLOSE_GROUP’

EXCEPTIONS

NOT_OPEN = 1

QUEUE_ERROR = 2

OTHERS = 3.SY-SUBRC

CHECK

Page 9: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 20139 Dec-2008Data Interfaces |

Batch Input Session - Structure

BatchInput

Session

Data Section

Transaction Data

Header Section

Creator

Client

Session Name

Authorization User

Hold Date

Keep or Delete

Page 10: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201310 Dec-2008Data Interfaces |

Example #1 - Change Vendor

Vendor

Company Code

ABAPXX-002

AddressX

Name

Street

Computers, Inc.

Buyer, Inc.1

City Philadelphia

In this example, we will create a batch input session to add a street

address to an already existing vendor (TEST1).

The “Change Vendor” transaction is “FK02”.

Page 11: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201311 Dec-2008Data Interfaces |

Example #1 - Declaration Section

REPORT YDIXX5_2.

DATA: BDC_TAB TYPE STANDARD TABLE OF BDCDATA INITIAL SIZE 6 WITH HEADER LINE,

WA_BDC_TAB TYPE BDCDATA,

SESSION TYPE APQ_GRPNVALUE 'DEMO#8'.

Step #1

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

Page 12: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201312 Dec-2008Data Interfaces |

Example #1 - Main Program

START-OF-SELECTION.CALL FUNCTION ‘BDC_OPEN_GROUP’

EXPORTINGCLIENT = SY-MANDTGROUP = SESSIONUSER = SY-UNAME

EXCEPTIONS. . . .PERFORM FILL_BDC_TAB.CALL FUNCTION ‘BDC_INSERT’

EXPORTINGTCODE = ‘FK02’

TABLESDYNPROTAB = BDC_TAB

EXCEPTIONS. . . .CALL FUNCTION ‘BDC_CLOSE_GROUP’

EXCEPTIONS. . . .

Step #2

Step #3

Step #4

Step #5

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

Page 13: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201313 Dec-2008Data Interfaces |

Example #1 - Subroutines

FORM FILL_BDC_TAB.

REFRESH BDC_TAB.

PERFORM POPULATE_BDC_TABUSING:

‘1’‘SAPMF02K’ ‘0106’,‘ ’‘RF02K-LIFNR’ ‘ABAPXX-002’,‘ ’‘RF02K-D0110’ ‘X’,

‘1’‘SAPMF02K’ ‘0110’,‘ ’‘LFA1-STRAS’ ‘Buyer, Inc.1’,‘ ’‘BDC_OKCODE’ ‘=UPDA’.

ENDFORM.

FORM POPULATE_BDC_TAB USINGFLAG TYPE C

VAR1 TYPE C VAR2 TYPE C.

CLEAR WA_BDC_TAB.IF FLAG = ‘1’.

WA_BDC_TAB-PROGRAM = VAR1. WA_ BDC_TAB-DYNPRO= VAR2.

WA_BDC_TAB-DYNBEGIN= ‘X’.ELSE.

WA_BDC_TAB-FNAM = VAR1.WA_BDC_TAB-FVAL = VAR2.

ENDIF.

APPEND WA_BDC_TAB TO BDC_TAB.

ENDFORM.

Page 14: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201314 Dec-2008Data Interfaces |

Example #2 - Change Vendors

Vendor

Company Code

TEST1

AddressX

Name

Street

Computers, Inc.

123 Main St.

City Philadelphia

Vendor

Company Code

TEST2

AddressX

Name

Street

Computer Land

10 Walnut St.

CityBoston

In this example, we will read records from a sequential file on the application server to create a batch input session that

updates multiple vendors.

Page 15: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201315 Dec-2008Data Interfaces |

Example #2 - Sequential File

TEST1 123 Main St.

TEST2 10 Walnut St.

TEST3 32 Chestnut St.

TEST4 30 Market St.

TEST5 17 S. 30th St.

File name:

‘/tmp/bc180_file3’

The sequential file we will read is set up in records. Each record has two fields with

the following formats:

<Field1> LIKE LFA1-LIFNR

<Field2> LIKE LFA1-STRAS

Page 16: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201316 Dec-2008Data Interfaces |

Example #2 - Declaration Section

REPORT YDIXX5_02.

DATA: BDC_TAB TYPE STANDARD TABLE OF BDCDATA INITIAL SIZE 6 ,SESSION TYPE APQ_GRPN

VALUE 'DEMO#9',INFILE(20) VALUE '/tmp/bc180_file3'.

DATA: BEGIN OF INREC,VENDNUM TYPE LIFNR,STREET TYPE STRAS_GP,

END OF INREC.

Step #1

Step #2

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

Page 17: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201317 Dec-2008Data Interfaces |

Example #2 - Main Program

START-OF-SELECTION.OPEN DATASET INFILE

FOR INPUT IN TEXT MODE ENCODING DEFAULT.

CALL FUNCTION ‘BDC_OPEN_GROUP’. . . .DO.

READ DATASET INFILE INTO INREC.IF SY-SUBRC <> 0. EXIT. ENDIF.PERFORM FILL_BDC_TAB.CALL FUNCTION ‘BDC_INSERT’

EXPORTINGTCODE = ‘FK02’

TABLESDYNPROTAB = BDC_TAB. . . .

ENDDO.CALL FUNCTION ‘BDC_CLOSE_GROUP’. . . .CLOSE DATASET INFILE.

SY-SUBRCCHECKStep #3

Step #4

Step #5

Step #6

Step #7

Step #8

Step #9

Step #10

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

Page 18: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201318 Dec-2008Data Interfaces |

Example #2 - Subroutines

FORM FILL_BDC_TAB.

REFRESH BDC_TAB.

PERFORM POPULATE_BDC_TABUSING:

‘1’ ‘SAPMF02K’ ‘0106’,‘ ’ ‘RF02K-LIFNR’ INREC-VENDNUM,‘ ’ ‘RF02K-D0110’ ‘X’,

‘1’ ‘SAPMF02K’ ‘0110’,‘ ’ ‘LFA1-STRAS’ INREC-STREET,‘ ’ ‘BDC_OKCODE’ ‘=UPDA’.

ENDFORM.

FORM POPULATE_BDC_TAB USINGFLAG TYPE C

VAR1 TYPE C VAR2 TYPE C. CLEAR WA_BDC_TAB.

IF FLAG = ‘1’.WA_BDC_TAB-PROGRAM = VAR1.WA_BDC_TAB-DYNPRO = VAR2.WA_BDC_TAB-DYNBEGIN = ‘X’.ELSE.WA_BDC_TAB-FNAM = VAR1.WA_BDC_TAB-FVAL = VAR2.ENDIF.

APPEND WA_BDC_TAB TO BDC_TAB.

ENDFORM.

Notice that the vendor number and street values are coming from the file’s records read into the “INREC” structure.

Page 19: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201319 Dec-2008Data Interfaces |

Demonstration

Creation of a custom batch input session program for transaction XD02 (Change Customer).

Page 20: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201320 Dec-2008Data Interfaces |

Practice

Creation of a custom batch input session program for transaction XD02 (Change Customer).

Page 21: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201321 Dec-2008Data Interfaces |

Summary

Research Transaction

Code BDC Program

Execute BDC Program

Batch Input Session Created

Process Batch Input Session

SAP Database Updated

Page 22: Chapter 05_ Batch Input Session

IBM Global Business Services

© IBM Corporation 201322 Dec-2008Data Interfaces |

Questions

What are the function modules required to create a batch input session ?

In what sequence are they called ?