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

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

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?

    Requires Free Membership to View

    When you register, you will start receiving targeted emails from my award-winning team of editorial writers. Our goal is to keep you informed on the hottest topics and biggest challenges faced by SAP professionals today.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSAP.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSAP.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

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.

    This was first published in November 2005