Making dynamic patterns in SAP

Here is an example of making a dynamic pattern in SAP. This is quite useful for standard headers in your code.

Here is an example of making a dynamic pattern in SAP. This is quite useful for standard headers in your code.

First you have to create a pattern which contains only one line:
*$&$MUSTER

Then create a function module with the name of the pattern followed by '_editor_exit'
Then add a tables parameter.
parameter name: BUFFER
type spec.: LIKE
reference type: ABAPSOURCE

In the source you can add anything you like tot the buffer table, upon executing the pattern in your ABAP, it copies everything you put in it.

This is the result of the pattern I use:
*#######################################################################
* Report   :
* Version  : 1.00
* Author   : IPS107  - Rob Dielemans
* Function : Developer   Department :ABAP
* Date     : 05.05.2003
*-----------------------------------------------------------------------
* Title    :
* Purpose  :
* Details  :
*=======================================================================
* Change History
*-----------------------------------------------------------------------
* Correction on version : 1.00
* New version : 1.01
* Author      :
* Date        :
* Reason      :
* Change      :
*#######################################################################
The code was written in R/3 4.6D.
FUNCTION zips_model_header_editor_exit .
*"----------------------------------------------------------------------
*"*"Lokale interface:
*"  TABLES
*"      BUFFER STRUCTURE  ABAPSOURCE
*"----------------------------------------------------------------------

*      <DATA>
  DATA: l_commentline1 LIKE LINE OF buffer,
        l_commentline2 LIKE LINE OF buffer,
        l_commentline3 LIKE LINE OF buffer,
        l_firstname LIKE adrp-name_first,
        l_lastname LIKE adrp-name_last,
        l_function LIKE adcp-function,
        l_department LIKE adcp-department,
        l_datum(10).

*      <TABLES>
  TABLES: usr21,    "Assign user name address key
          adrp,     "Persons (central address administration)
          adcp.     "Person/Address assignment (central address administration)

*additional:, although using the comment charater '"', the system 
* converts it to '*' 
  CONCATENATE '"##############################'
        '#########################################' INTO l_commentline1.

  CONCATENATE '"------------------------------------'
              '-----------------------------------' INTO l_commentline2.
  CONCATENATE '"=================================='
            '=====================================' INTO l_commentline3.

  buffer = l_commentline1.
  APPEND buffer.

  buffer = '* Report   : '.
  APPEND buffer.

  buffer = '* Version  : 1.00'.
  APPEND buffer.

* initialize first and last name, if not found in database
  l_firstname = 'first name'.
  l_lastname = 'last name'.

* retrieval of first and last name in database
  SELECT SINGLE * FROM usr21 WHERE bname = sy-uname.
  IF sy-subrc = 0.

    SELECT SINGLE * FROM adrp WHERE persnumber = usr21-persnumber.
    IF sy-subrc = 0.
      l_firstname = adrp-name_first.
      l_lastname = adrp-name_last.

* retrtieval of function and department of user
      SELECT SINGLE * FROM adcp WHERE persnumber = usr21-persnumber.
      IF sy-subrc = 0.
        l_function = adcp-function.
        l_department = adcp-department.

      ENDIF.
    ENDIF.
  ENDIF.

  CONCATENATE '* Author   :' sy-uname' -' l_firstname l_lastname INTO
  buffer SEPARATED BY space.
  APPEND buffer.

  CONCATENATE '* Function :' l_function
              '  Department :' l_department
  INTO buffer SEPARATED BY space.
  APPEND buffer.

  WRITE sy-datum DD/MM/YYYY TO l_datum.
  CONCATENATE '* Date     : ' l_datum INTO buffer SEPARATED BY space.
  APPEND buffer.

  buffer = l_commentline2.
  APPEND buffer.

  buffer = '* Title    : '.
  APPEND buffer.

  buffer = '* Purpose  : '.
  APPEND buffer.

  buffer = '* Details  : '.
  APPEND buffer.

  buffer = l_commentline3.
  APPEND buffer.

  buffer = '* Change History'.
  APPEND buffer.

  buffer = l_commentline2.
  APPEND buffer.

  buffer = '* Correction on version : 1.00'.
  APPEND buffer.

  buffer = '* New version : 1.01'.
  APPEND buffer.

  buffer = '* Author      :'.
  APPEND buffer.

  buffer = '* Date        :'.
  APPEND buffer.

  buffer = '* Reason      :'.
  APPEND buffer.

  buffer = '* Change      :'.
  APPEND buffer.

  buffer = l_commentline1.
  APPEND buffer.

ENDFUNCTION.
This was first published in May 2003

Dig deeper on SAP ABAP

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close