Writing Data Conversion Programs

SAP ABAP Interview QuestionsQuestion 13: How do you write a conversion program?

Don’t confuse about the conversion program. When using the standard batch input program, they require a specified file format. But probably your file that is to be transferred is not as required. Therefore you need to write a conversion program that will convert your file to SAP’s file format.You must generate the data structure from the SAP standard data structure. Then you can use the standard batch input program by using this converted SAP file format.

A conversion may be necessary for data type and length. The data type required by all standard SAP batch input programs is C, character. You can find the required field length either in your analysis of the data declaration structure of the generated batch input program or in the data structures that you generate.

The data is exported in SAP format to a sequential file. The batch input program in R/3 System reads the data in from this file.

The tasks involved in writing a data transfer program are shown in the diagram and list below.

Process Flow for the Conversion Program

  1. Analyze the structure of existing data and specify the conversions are required to fill the SAP data structures.
  2. If necessary, generate the SAP data structure in code form and insert it into your program. This is only possible if the SAP data structure is an ABAP Dictionary object (structure, table)
  3. Fill the structure with data. If you don’t want to assign a value to a field in structure, use the NODATA character. Execute any conversions and error checks that may be required.
  4. Write the sequential file that is typically required for making the data available to the data transfer program in the R/3 System.

Once you have determined the SAP data structure, you should:

  • Determine which fields can be transferred directly from your existing data. There is a direct match between an existing data field and the corresponding SAP data field.
  • Check which fields must be converted to adapt existing data to the requirements of the R/3 System.

Data Conversion

Your program must format legacy data just as an online user would when typing them in.

  • The data must be character format.
  • The data itself must be not 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.
  • If the transaction for a field is to keep its initial value, use the NODATA character.

Standard SAP data transfer programs require that every field in 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 conversion 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 forward slash. To initialize a field to NODATA, you must write this character as the first character in the field value.

NODATA Character

If a batch input program finds NODATA in a field, then the program allows the field to its standard value in the SAP transaction that contains the field.

Setting the NODATA character: You can freely select another character as the NODATA character by:

  • Specifying this in the selection screen for a generated data transfer program.
  • Defining the new character in the data transfer program that reads the data in the BGR00-NODATA field:

Data: <Name> like bgr00.
<Name>-NODATA = ‘<Character>’.

References:

Leave a Reply