Tip

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.

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

    Requires Free Membership to View

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.