Thursday, October 24, 2013

Batch Input with Objects

Some times, we get such a requirement that forces us to use batch input for creation/changing of some SAP object/document. Usually, the resulting code isn't that elegant. In this post, I'll show how to use a ABAP Class to process call transaction and allow to future improvements that afects every program that uses it, without the need to change those same programs.
Those improvements could be:
  • Create Batch input in DB for latter processing
  • Create Enhanced Logs
  • Start Workflows
  • Etc

1 - Create an ABAP Class in transaction SE24, select an apropriate package:

















2 - Create the following attributes:

3 - Create these methods:









4 - Pick the relevant code for the each method:


5 - Save and activate the class.

6 - To help generate the code, the following program can be used:



The input for this program is the SHDB record and the program variable name.

7 - Example:
  • SHDB Record:


8 - Program Input

9 - Generated Code:


Final remarks:
As you can see, the code is more understable and simplier to use.
The SHDB record name, must be unique, since it is selected by name.
With the generated code, you must add the coding for variable selection and remove unecessary inputs. The program only creates code for the relevant batch input lines.