Problem solve Get help with specific problems with your technologies, process and projects.

How to add database retrieval logic for use in a Smart Form

Wondering how to add database retrieval logic for use in a Smart Form? SAP expert Mark Smithson will tell you how.

How can I retrieve data in form logic from a database table, if the data from that table is not getting supplied by a print program into a Smart Form?
Thanks for the excellent question!

From a high-level perspective, there are two places to add database retrieval logic for use in a Smart Form:
(1) The print program
(2) The form itself

If you add this logic to the print program, there are two rules:

  • Don't modify standard SAP code (e.g. use a Z-version instead)
  • Make sure the import/export parameters between the form and print program are in sync
  • If you add this logic to the form itself, you can put it either at the top of the form under Global definitions (in 'Initialization' or 'Form routines') or in a 'Program lines' node within the body of the form itself. However, if you go with the second option, there are other rules:

  • Don't put the logic in the MAIN window
  • Don't put the logic in a secondary window which can be hit more than once during form output
  • The reason is that the form will generate an ABAP function module. All of its program logic will become part of this code. So basic ABAP programming standards should apply, including efficient database access (e.g. no SELECT statements in nested loops, no retrieval of irrelevant table columns or rows).

    To put it another way, avoid accessing the database more than necessary. Program nodes which can be hit multiple times as the form is output should only pull from pre-populated tables passed from the top of the form or from the print program -- not from the database.

    Dig Deeper on SAPscript and Smart Forms

    Start the conversation

    Send me notifications when other members comment.

    Please create a username to comment.