Copyright 2024 - BV TallVision IT

An order, delivery or an invoice, SAP supplies them all and the (customer) company wants to change their appearance to match company requirements. As the system is set up to suit company requirements, these are very likely to have an effect on the actual output as well. This article describes a step-by-step approach that achieves goals: stay with Standard SAP where possible, get the look and feel that is specific to the company, translation into all relevant languages, work with a flexible Master document, control specifics using customizing settings.

 A master document

Using a master document for e.g. the delivery means that all business units, plants, sales organisations, etc will be using the same Smartform for "The delivery". This has a great disadvantage, as changes to this form have an effect on everybody. But this disadvantage is also the greatest advantage, from a development viewpoint. There is only one so a fix does not need to be applied to several deliveries.

To start with the master document, we first check what Standard SAP has prepared for us. We have absolutely no reason to ignore that. The delivery is a Customer Facing Document in the form of a smartform with (e.g.) driver program RLE_DELNOTE and smartform LE_SHP_DELNOTE (this information can be found on the TNAPR table). If you take a closer look at this Smartform, you will notice it has an interface with a parameter IS_DLV_DELNOTE of type LEDLV_DELNOTE. This interface parameter contains 95% of the information you are ever likely to require on the delivery note. It's SAP's present to the developer and it should be used and utilized as such. The IS_DLV_DELNOTE parameter is a complex structure with tables and substructures and it's packed with data. If what you are looking for is not there: it is not standard SAP and you have probably added it tot the system yourselves.

Create your master document by copying the standard SAP smartform (including it's interface). The layout matters can now be adjusted to company requirements. Note that the standard SAP driver program is not copied to a local version, this is only needed if additional information is needed for the Smartform, which can not be selected from the smartform itself. This is a choice: up to the developer. My personal preference is to leave the driver program as standard and use the Smartform Initialization block for additional data selection.

Minimum Master document requirements

The Master customer facing document should have a few points of interest covered: 

  • It should translatable - so make sure where texts are picked up from programmed logic or database, the language should be involved;
  • Documents have a first page and follow-up pages. Page n of nn is a must on every page and preferrably information that is only required on the first page will only show on the first page;
  • When the document is output on a non-productive system, it should clearly state that it is a test document (preferrably with the system/client it originated from). 
  • Customer facing means it is likely to go into an envelope. These have windows which should show the address. Pre-printed paper means the Smartform should ommit te logo. 

Master document enhancements

The master document is a template for all to use, but to make it usable, everyone will have something to say. Hence the master document should be composed as such: it should have areas where customizable components can be handled. A few examples: 

  • Reserve an area in the document header, which looks fine if nothing is filled in, but also allows information to be displayed;
  • Use: "labeled fields" in the document MAIN window. A Labeled field is effectively a single field value that is displayed on it's own line with it's own field label. If such information is available/applicable it will be shown (reserving a line);
  • The labeled field approach can be used on header data (either at the start or end of item data) as well as on the actual items. It can be repeated for as many bits of information applicable;
  • Reserve an area in the document footer;
  • Work with longtexts: E.g. set up the company address and phone information in a longtext and use it if no other text name is determined. This allows a local branch to set the contact details for the company-wide master document to their own office. 

Customizable components

When all layout matters are in place, the specific requests will come into play. Information should only be added if it is available (which is applicable to the whole Master document) or it should only be shown for a given sales organisation. Since we are working on a master document approach, the additional requirements need to be captured/recognised in organized and uniform way. And since we are assuming this is not the only document we want to handle as a master document (the delivery is one, but there are orders, an invoice and many many more) we take a step out of the Smartform.

A class is created called ZCL_SMARTFORM_CONTROLLER which holds an attribute with a name that corresponds with the name of the smartform. So once you have copied the LE_SHP_DELNOTE smartform into Z_SHP_DELNOTE, an instance attribute with the same name is added to the class. The attribute will have it's own type definition like TY_Z_SHP_DELNOTE. The first field on this type is called SETTINGS_LOADED (type boolean). All other fields on this type definition correspond to customizable components. E.g. a field is called SHOW_OLD_MATERIAL or SHOW_LOGO.

Back on the Smartform, define a variabele on the smartform with a type reference to the actual components structure, like so: GW_CONTROL type ZCL_SMARTFORM_CONTROLLER=>TY_Z_SHP_DELNOTE.  A local variabele is then instantiated in the Smartform Initialization block as follows:

      GW_CONTROL type 

    smartform     = 'Z_SHP_DELNOTE'
    company_code  = ''
    document_type = '' 
    billing_type  = ''
    purchase_org  = ''
    sales_org     = ''
    freekey       = ''.


When the class is instantiated (CREATE OBJECT is executed) the components on the LO_COMPONENT-Z_SHP_DELNOTE attribute are filled in. These component values can be boolean or other type (singular) values. The parameters are used to select the most suitable values, when values are specified they will be checked against available table entries. If e.g. the company code that was specified is not specified on the settings table, it will look for an entry with a blank company code.

The customizable components table

The actual table for customizable objects will contain the following fields: Table: Z_SMARTFORM_COMPONENTS(SMARTFORM, BUKRS, DOCTP, FKART, EKORG, VKORG, FREEKEY, COMPONENT, VALUE);

Z_SHP_DELNOTE       ZNL                             SHOW_LOGO          X 
Z_SHP_DELNOTE 1200  ZNL                             SHOW_OLD_MATERIAL  X
Z_SHP_DELNOTE 1900  9LF                             2ND_PGI_APPLICABLE X
Z_SHP_DELNOTE 1900  9LF                             ADDRESS_TEXT_EXT   _1900

Implementing in the Smartform

So where does all of this lead to ? A master document for the delivery, which can handle very specific alterations. All Smartform components have conditions, which can determine whether the component is to be added or ignored. The above setup can now be used in Smartform condition. E.g. if the "Old material number" should be shown only in some cases, the variabele GW_CONTROL-SHOW_OLD_MATERIAL will be set where the customizing table dictates.