2.11.4 Auto-Generated Forms

Auto-Generated Forms

Forms can be configured so that instances of the Form can be generated automatically based on some programmed logic. For example, all open work-items of a particular type can be scanned for and an auto-generated Form created and sent to particular users, based on data associated with the work-item.

This can be achieved in FAB by

  1. configuring which Forms should be auto-generated,
  2. scheduling a job to process the Forms
  3. implement logic for selecting the basis for each Form (ie each instance of Form based on what?)
  4. implement logic for selecting data for each instance (Form contents for each instance)

Configure any Forms to be generated automatically via /IQX/CONFIG - >Auto-Generated Forms


Create a variant for the Form and schedule it as desired, or execute immediately.



Via the Implementation Class of the Form/App, implement methods:




In this method, write the logic for selecting the data that is the basis of the auto-generated forms.

Fill the exporting parameter ET_KEYS with a unique key and value pair (ZKEY, ZVALUE) for each record identified for automatic generation.

For example, it could be open work-items of a particular type:

*   Example 2 - retrieve open workflows of a particular type
    DATA: lt_work_items TYPE STANDARD TABLE OF swwwihead,
          ls_work_items LIKE LINE OF lt_work_items,
          lt_wi_agent TYPE STANDARD TABLE OF swwuserwi.

    SELECT * FROM swwwihead INTO TABLE lt_work_items
      WHERE wi_rh_task = 'TS98100231'                   "example demo workflow WS98100290, task TS98100231
        AND wi_stat = 'READY'.

*   keep only those with agents
    IF lt_work_items IS NOT INITIAL.

      SELECT *
        FROM  swwuserwi
        INTO TABLE lt_wi_agent
        FOR ALL ENTRIES IN lt_work_items
        WHERE wi_id     = lt_work_items-wi_id
           AND no_sel    = space.

      SORT lt_wi_agent BY wi_id.

      LOOP AT lt_work_items INTO ls_work_items.
        READ TABLE lt_wi_agent WITH KEY wi_id = ls_work_items-wi_id BINARY SEARCH TRANSPORTING NO FIELDS.
        IF sy-subrc = 0.

          ls_keys-zkey 'WorkitemId'.
-zvalue ls_work_items-wi_id.
APPEND ls_keys TO et_keys.



In this method, we

  1. write the logic for selecting the actual data for each Form that will be generated (based on the key,value pairs generated via AUTO_GENERATED_FORM_SELECT )
  2. Set a starting Action in EV_ACTION (such as GENERATE or SAVE).

This simulates a user filling out the form with some data and pressing a button that invokes the configured action.

It is then up to the Form logic and workflow as usual to carry on processing the Form.

Example: for each work item id, retrieve the associated Notification and set some attributes of the Form.

FIELD-SYMBOLS <fs_form_data> LIKE LINE OF ct_form_data.

    DEFINE set_field.
      READ TABLE ct_form_data ASSIGNING <fs_form_data> WITH KEY zfield_name = &1.
      IF sy-subrc = 0.
        <fs_form_data>-zfield_value = &2.

    CASE iv_key.

     WHEN 'WorkitemId'.

        " given key - WorkitemId        "get Notification from workflow container
        DATA: lv_wi_id TYPE sww_wiid,
              ls_object TYPE swr_obj_2.

        lv_wi_id = iv_key_value.

            workitem_id      = lv_wi_id
*           LANGUAGE         = SY-LANGU
*           USER             = SY-UNAME
*           BUFFERED_ACCESS  = 'X'
*           LEADING_OBJECT   =
*           RETURN_CODE      =
            leading_object_2 = ls_object
*           TABLES
*           OBJECTS          =
*           MESSAGE_LINES    =
*           MESSAGE_STRUCT   =
*           OBJECTS_2        =

        lv_qmnum = ls_object-instid.

        IF lv_qmnum IS NOT INITIAL.

              number             = lv_qmnum
              notifheader_export = ls_notifheader_export
              notifhdtext        = ls_notifhdtext.


 "      set workitem id into Form
        set_field 'WorkitemId' iv_key_value.


    "set fields from Notification into Form

    set_field 'NotificationNumber' lv_qmnum.
    set_field 'Description' ls_notifheader_export-short_text.
    set_field 'NotificationNumber' lv_qmnum.
    set_field 'LocationDescription' ls_notifhdtext-funcldescr.
    set_field 'EquipmentDescription' ls_notifhdtext-equidescr.
    set_field 'StartDate' ls_notifheader_export-notif_date.

    ev_action = 'GENERATE'.