(5) 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.
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.
Including Table Structures in Transfer Programs: ABAP/4 and Other Languages
Procedure
To generate a 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.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: like bgr00.
-NODATA = ''.
GENERATING A SEQUENTIAL 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 BITFER.
* SAP structures for batch input processing:
TABLES: BGR00, BKN00, BKNA1.
* Structure of existing data to be transferred:
DATA: BEGIN OF OLDREC,
TELE1(10) TYPE C,
CUSTNR(8) TYPE C,
TITLE(2) TYPE C,
NAME1(30) TYPE C,
END OF OLDREC.
* Auxiliary structure for initializing fields:
DATA: BEGIN OF AUXREC.
INCLUDE STRUCTURE BKNA1.
DATA: END OF AUXREC.
* SAP fields for converted data:
DATA: CUSTNR LIKE BKN00-KUNNR,
NAME1 LIKE BKNA1-NAME1,
TELE1 LIKE BKNA1-TELF1.
* For initializing fields:
DATA: N TYPE I.
FIELD-SYMBOLS .
* File and session names, NODATA character:
PARAMETERS:
OLDFILE(20) DEFAULT '/tmp/oldfile' LOWER CASE,
SAPFILE(20) DEFAULT '/tmp/sapfile' LOWER CASE,
ERRFILE(20) DEFAULT '/tmp/errfile' LOWER CASE,
SESSION(20) DEFAULT 'ADDRDAT' LOWER CASE,
NODATA DEFAULT '/' LOWER CASE.
START-OF-SELECTION.
OPEN DATASET: OLDFILE FOR INPUT IN TEXT MODE,
SAPFILE FOR OUTPUT IN TEXT MODE,
ERRFILE FOR OUTPUT IN TEXT MODE.
* Open batch input session as first SAPFILE entry:
* program:
MOVE: 'O' TO BGR00-STYPE,
SESSION TO BGR00-GROUP,
SY-MANDT TO BGR00-MANDT,
SY-UNAME TO BGR00-USNAM,
NODATA TO BGR00-NODATA.
TRANSFER BGR00 TO SAPFILE.
* Initialize data fields with NODATA:
DO.
ADD 1 TO N.
ASSIGN COMPONENT N OF STRUCTURE AUXREC TO .
IF SY-SUBRC NE 0. EXIT. ENDIF.
MOVE BGR00-NODATA TO .
ENDDO.
MOVE AUXREC TO BKNA1.
* Read and convert existing data:
DO.
" Read data record:
READ DATASET OLDFILE INTO OLDREC.
IF SY-SUBRC NE 0. EXIT. ENDIF.
" 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 A 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. Restart-capability 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 detailed information, please see Selecting a Batch-Input Method(11) .
3. Write the batch input program.
Your program will need to do the 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 POSTS
BDC PART FIVE
BDC TABLE CONTROL
SAP architecture,its full form of working and enjoy sap products
SAP journey from R/3 towards MySAP.com
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.
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.
Including Table Structures in Transfer Programs: ABAP/4 and Other Languages
Procedure
To generate a 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.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:
BDC PART FIVE
SAP architecture,its full form of working and enjoy sap products
SAP journey from R/3 towards MySAP.com
No comments :
Post a Comment