You are on page 1of 8

GENERATING

AN

SAP

DATA

STRUCTURE:

You can use the ABAP/4 Dictionary to generate data structures for SAP tables in any of the following programming languages: Cobol PL/1 C You can then incorporate these data structures in your data conversion program. For most of the standard SAP batch input programs, SAP has also provided special data structure identifiers. With such an identifier, you can generate a listing of all of the table fields that are required by the corresponding batch input program. You do not need to find out which tables are required for the batch input program and generate their structures individually. If you are creating your own batch input procedure, you may be able to use the standard field listings as well. The names of the special data structure identifiers are documented in the SAP Customizing system. For information on finding the relevant documentation, please see Batch Input Concepts(1). Data Transfer Programs in ABAP/4

If your data transfer program is written in ABAP/4, you can include data structures of tables in your program with the TABLES instruction. The structure is then read directly from the ABAP/4 Dictionary. In this case, you cannot use the special data structure identifiers provided by the SAP applications. The identifier names are not recognized by the TABLES instruction. Instead, you can find the required table names by checking the transactions that your batch input procedure will be using to enter data. Or you can find the table names in the listings generated by the special identifiers. The diagram below shows the structures of transfer programs in ABAP/4 and as external programs written in other languages.

Including Table Procedure To generate

Structures

in

Transfer

Programs:

ABAP/4

and

Other

Languages

data

structure,

do

the

following:

1. Choose Tools --> ABAP/4 Workbench and then ABAP/4 Dictionary. 2. In the ABAP/4 Dictionary, select Environment --> Generate table description.

With this function, you can generate the structures of one or a group of SAP tables in programming code. You can then add this code to your data transfer program. 3. Specify the programming language in which the structure should be generated and identify the tables to be included. If you wish to use a special structure identifier for a standard SAP batch input report,then enter the identifier in the Key in TSRCG field. Example: The identifier AM-ANLA generates the data structure required for data transfers for the asset management application. 4. The system displays the data structure in list form, as in this example in PL/1 from the asset management application (AM-ANLA): ****************************************************************** * MEMBER GENERATED FROM SAP DATA DICTIONARY * * T A B L E BALTD * * DATE: 08.12.1995 TIME: 17:47:16 * * PLEASE DO NOT CHANGE MANUALLY * ****************************************************************** * 01 BALTD. * * Client (Old Assets Data Takeover AM) 05 MANDT PIC X(3) VALUE SPACE. * Company code 05 BUKRS PIC X(4) VALUE SPACE. * Asset class 05 ANLKL PIC X(8) VALUE SPACE. Choose System --> List --> Save --> File to download the data structure to your workstation or PC.

6)

DATA

CONVERSIONS:

Use the field descriptions that you obtained in Analyzing SAP Transactions(4) or Generating an SAP Data Structure(5) to determine the following: which fields can be taken over directly from your existing data. That is, there is a direct match between an existing data field and the corresponding SAP data field.

for which fields a conversion procedure is necessary for mapping your existing data to the requirements of the SAP System. CoNverting Data from Old Format to SAP Format

Your program must format batch input values just as an on-line user would when typing them in. In particular: The data must be character format. No piece of data may be longer than its target SAP field. If the data is shorter than the target field, you must left-justify it within the SAP field (pad it with blanks at the right end). (7) INITIALIZING AN SAP DATA STRUCTURE:

Standard SAP batch input programs require that every field in a data structure contains either: a value; or a special NODATA marker, which indicates that the no batch input data is required for the field. If you are writing your own data transfer program, you should therefore initialize all of the fields in your batch input data structure with the NODATA character. The NODATA character must occupy the first position in the field, as shown in the figure below. By default, the NODATA character is the forward slash. To initialize a field to NODATA, you must write this character as the first character in the field value.

If a batch input program finds NODATA in a field, then the program allows the field to default to its standard value in the SAP transaction that contains the field. Setting the NODATA marker: You can freely select another character as the NODATA marker. Define the new character in the batch input program that reads the data in the BGR00-NODATA field: Data: -NODATA GENERATING A like = SEQUENTIAL bgr00. ''. FILE:

If you are transferring data from a non-SAP System, then you will probably need to use a file as the transfer medium for the data. (For data transfer between SAP Systems, you may be able to use RFC or CPI-C to process data directly in the target SAP System.) The file that you generate should have the following characteristics:

All data should be in character format. This is required by the standard SAP batch input programs. Data must have the logical structure expected by the batch input program.

For a standard SAP batch input program, this requirement means that you have generated the data structure defined for the batch input program. For more information, see Generating an SAP Data Structure(5). You'll find sample code for reading from and writing to a sequential file in Sample Program: Data Transfer(9) .

(9)

SAMPLE

PROGRAM:

DATA

TRANSFER:

The following ABAP/4 program demonstrates the data transfer process. The program does the following: reads customer address data from a sequential file checks the data for unacceptable records performs conversions on the data writes the data back out to a sequential file using the format required by the SAP standard batch input program Batch Input Interface for Customers (ABAP/4 program RFBIDE00).

EXAMPLE: REPORT * SAP TABLES: * Structure DATA: TELE1(10) CUSTNR(8) TITLE(2) NAME1(30) END * Auxiliary DATA: INCLUDE DATA: structures BGR00, of for batch BKN00, data OF TYPE TYPE TYPE TYPE OF structure for BEGIN STRUCTURE END initializing OF OF to input BITFER. processing: BKNA1. transferred: OLDREC, C, C, C, C, OLDREC. fields: AUXREC. BKNA1. AUXREC.

existing BEGIN

be

* DATA: NAME1 TELE1

SAP

fields CUSTNR LIKE LIKE For N

for LIKE

converted

data: BKN00-KUNNR, BKNA1-NAME1, BKNA1-TELF1. fields: I. . character: CASE, CASE, CASE, CASE, CASE.

* DATA: FIELD-SYMBOLS * File PARAMETERS: OLDFILE(20) SAPFILE(20) ERRFILE(20) SESSION(20) NODATA

initializing TYPE

and

session

names, '/tmp/oldfile' '/tmp/sapfile' '/tmp/errfile' 'ADDRDAT' '/'

NODATA LOWER LOWER LOWER LOWER LOWER

DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT

START-OF-SELECTION. OPEN DATASET: SAPFILE FOR ERRFILE FOR * Open * MOVE: SESSION SY-MANDT SY-UNAME NODATA TRANSFER * DO. ADD ASSIGN IF MOVE ENDDO. MOVE * DO. " READ IF batch

OLDFILE FOR OUTPUT OUTPUT input 'O' TO TO TO TO BGR00 session

INPUT IN IN as TO first

IN

TEXT TEXT TEXT SAPFILE

MODE, MODE, MODE.

TO fields TO STRUCTURE 0. with

entry: program: BGR00-STYPE, BGR00-GROUP, BGR00-MANDT, BGR00-USNAM, BGR00-NODATA. SAPFILE. NODATA: N. TO . ENDIF. . BKNA1.

Initialize

data

1 COMPONENT N OF SY-SUBRC NE BGR00-NODATA AUXREC Read Read DATASET SY-SUBRC and

AUXREC EXIT. TO

TO convert data OLDFILE existing

data: record: OLDREC. ENDIF.

NE

0.

INTO EXIT.

" Check data and transfer only certain records: IF OLDREC-CUSTNR(5) NE 'AABBC' OR OLDREC-CUSTNR(6) EQ 'AABBCD' OR OLDREC-TELE1 EQ SPACE. TRANSFER OLDREC TO ERRFILE. * TEXT-001: 'Data not transferred for customer:' WRITE: / TEXT-001, OLDREC-CUSTNR. ELSE. " Convert the customer number to SAP convention: IF OLDREC-CUSTNR+5(1) = 'C'. IF OLDREC-CUSTNR+5(1) = 'D'. ENDIF. " Convert abbreviations to full words: CASE OLDREC-TITLE. WHEN 'Co'. BKNA1-TITLE = 'Company'. WHEN 'Corp'. BKNA1-TITLE = 'Corporation'. WHEN OTHERS. BKNA1-TITLE = NODATA. ENDCASE. " Convert records from old format to SAP format: MOVE: OLDREC-CUSTNR TO CUSTNR, OLDREC-NAME1 TO NAME1, OLDREC-TELE1 TO TELE1. " Fill SAP structures: MOVE: '1' TO BKNOO-STYPE, 'XD02' TO BKNOO-TCODE, CUSTNR TO BKNOO-CKUNNR. MOVE: '2' TO BKNA1-STYPE, 'BKNA1' TO BKNA1-TBNAM, 'TELE1 TO BKNA1-TELF1, NODATA TO BNKA1-SENDE. " Transfer data to SAPFILE: TRANSFER: BKNOO TO SAPFILE, BKNA1 TO SAPFILE. * TEXT-02: 'Data was transferred for customer:' WRITE: / TEXT-002, OLDREC-CUSTNR, BKNOO-CUSTNR. ENDIF. ENDDO. CLOSE DATASET: OLDFILE, SAPFILE, ERRFILE.

(10)

WRITING

BATCH

INPUT

PROGRAM:

PROCEDURE

IN

OVERVIEW:

In general, you can transfer data from an existing system into the SAP System with pre-defined

batch

input

programs,

delivered

with

the

SAP

System.

In some cases, however, you will need to write your own batch input program. For example, the standard SAP batch input programs in an application may not have foreseen the data transfer requirement you have, or you may wish to customize the standard data transfer procedure. To write your own batch input program, you'll need to do the following:

1. Analyze the transaction(s) that you will use to process your batch input data. You may have already done this when you wrote your data transfer program. Please see Writing a Data Transfer Program(3) and Analyzing SAP Transactions(4) for more information. 2. Decide on the batch-input method that you wish to use.

"Classical" batch input -- by way of a batch input session -- is more comfortable. Restartcapability and detailed logging are supported by the batch input management transaction for batch input sessions. Batch input by way of CALL TRANSACTION USING offers faster processing if you need it to get your batch input done in the time slot that is available for it. CALL TRANSACTION USING offers, however, less support for error recovery and management of batch input. For 3. Your detailed information, Write program will please the need see Selecting batch to do a Batch-Input input the Method(11) .

program. following:

read data in, often from a sequential file that has been exported from another system or prepared by a data transfer program if necessary, perform data conversions or error-checking prepare the data for batch input processing by storing the data in the batch input data structure, BDCDATA. generate a batch input session for classical batch input, or process the data directly with CALL TRANSACTION USING. RELATED BDC BDC BDC BDC MySAP SAP PART METHOD CODE TABLE and form,over POSTS FIVE CODE MASTER CONTROL strategies introduction

SESSION SAMPLE

SAMPLE CUSTOMER

sales definition,full

distribution veiw and

SAP SAP What What

Full form of planning and distribution of goods full form for mrp,sales and materiel planning is SAP and Why do we are in need of It is SAP Full form and its definition part one

SAP Full form and introduction part two SAP architecture,its full form of working and enjoy sap products SAP journey from R/3 towards MySAP.com MySAP technology RFC,BAPI,ALE and IDOC overveiw MySAP new generation technologies overview EnjoySAP introduction and Business Process of SAP XML with ALE,IDOC and BAPI Support this blog with Your Google Vote here @ Labels: ABAP BDC COMPLETE

You might also like