SAP REPORT – SAP USER EXIT





What is a SAP USER EXIT?

A SAP User Exit is a user defined FORM routine that is used to calculate and/or replace values within a validation, substitution, or rule.

User exits have the following format:

  • U (for a user-defined user exit) or S (for a standard user exit)
  • The user exit number (three digits)

For example, U123 is a user-defined user exit.

You can configure the form pool name of the sap user exit and must store it in the table for client-dependent user exits (T80D) in Customizing. Table T80D contains the form pool names for the user exits used in validations, substitutions, and rules. Each validation/substitution form pool is client-dependent. (For more information, refer to the Maintain Client-Dependent User Exits activity in the Implementation Guide (IMG) for Special Purpose Ledger.)

Example form pools RGGBS000 and RGGBR000 for client 000 are delivered with the SAP R/3 System. You must copy these form pools and configure them in T80D. The new form pool name should conform to the customer naming convention (beginning with the letter Z ) so that is not overwritten when the next SAP upgrade is installed (for example, ZGGBR000).

Example FORM routine for substitution exit 001 (U001).

TABLES: COBL.

FORM U001.
COBL-KOSTL = COBL-BUKRS.

ENDFORM.

Tables and structures should not be declared in the FORM routines so that the contents can be used together with the calling transaction.

SAP exits are FORM routines that have been programmed by SAP. The name of the form pool for SAP exits is SAPFGBEB.

If you still store your rules in table T890 (interpreted rules), you cannot use user exits in your rule definition. It is highly recommended that you use report program RGUGBR10 to convert interpreted rules into generated rules so that you can use the Customizing function for maintaining rules. For more information, see Using the Rule Manager Reports .

The following table shows the types of user exits that can be used in validations, substitutions, and rules.

User exit   type Description Application Example
1 No parameters are defined for the user exit. Rules, validations, and substitutions   (prerequisite) See form pool RGGBR000, parameter type   C_EXIT_PARAM_NONE
2 Same as user exit type 1, except one parameter   (the field to be substituted) is defined in the user exit. For example, you   can create a substitution routine that analyzes the cost center irrespective   of the used field. Substitutions See form pool RGGBS000, parameter type   C_EXIT_PARAM_FIELD
3 All data is passed as one parameter; this exit   type can only be used in matrix validations and substitutions. Rules, validations, and substitutions   (prerequisite) See form pool RGGBR000, parameter type C_EXIT_PARAM_CLASS

Validations and rules use exit numbers 1 and 3 from the above table.

Substitutions use all of the exit numbers from the above table.

For substitutions, you can also create user exits that accept a field as one parameter and then return the changed value in this parameter. This allows you to create a user exit that can be used independently of the field and table name. This type of user exit cannot be used as an entry in the Exit only field in the list of values to be substituted; you can only use this exit type in conjunction with a field name. An example of this user exit type is in form pool RGGBS000.

If you want to define a parameter for your user exit that is different from the result of a validation (B_RESULT), you must make an entry for your user exit in the FORM routine GET_EXIT_TITLES in the form pool you defined. It is recommended that you copy the SAP example form pool RGGBR000 for validation exits or RGGBS000 for substitution exits. These example

 

You can implement company-specific enhancements (user exits) that will provide additional functions. Customer-specific user exits may encompass such activities as:

  • Specifying the conditions for dispatching      certificates (FORM routines as user exits)
  • Defining additional data origins for inspection      specifications, results, and short texts for characteristics in the      certificate profile (self-defined function modules as table entries)
  • Defining and evaluating additional limitations      for the selection of inspection lots and partial lots (SAP user exit with      menu function in the certificate profile and function modules)
  • The automatic entry of the characteristic detail      data in the certificate profile (SAP user exit)
  • Defining the layout (text elements from a      SAPscript® layout set, SAPscript® standard texts, SAPscript® layout sets)
  • Defining the layout and the output data for      characteristics (special text elements in the SAPscript® layout set for      the characteristic output format, inspection method and supplementary      text, if the result is outside of the tolerance; SAPscript® standard      texts)
  • Adding new objects to which certificate profiles      can be assigned (enhancement of a structure in the dictionary and an SAP      user exit with a function module)
  • Using your own program to select the data and      print the certificates (as a table entry)

To obtain information about additional enhancement possibilities, you can create a list as follows:

  1. Choose Tools ® ABAP Workbench.

The system displays the initial screen for the ABAP Workbench.

  1. Choose Utilities ® Enhancement ® Definition.

The system displays the initial screen for SAP enhancements.

  1. Choose the possible entries help for the Enhancement field.

The system displays the selection screen for locating SAP enhancements.

  1. Enter QC in the Enhancement field.
  2. Choose Execute.

As in SAP.COM

Tags: , ,



SAP REPORTS – ALV Grid (Function Modules)





REPORT alvtest.

TYPES:
BEGIN OF t_makt,
matnr LIKE makt-matnr,
maktx LIKE makt-maktx,
END OF t_makt.

DATA:
it_makt TYPE STANDARD TABLE OF t_makt,
wa_makt TYPE t_makt.

*****************************************************
* Data declarations for the ALV grid
*****************************************************
DATA: r_grid TYPE REF TO cl_gui_alv_grid.

DATA: alv_fieldcat TYPE slis_t_fieldcat_alv,
wa_alv_fieldcat TYPE slis_fieldcat_alv,
alv_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.

*****************************************************

START-OF-SELECTION.
PERFORM alv_setup.
PERFORM read_data.
END-OF-SELECTION.
PERFORM display_alv.

*&—————————————————————–*
*& Form read_data
*&—————————————————————–*

FORM read_data.
SELECT matnr maktx
FROM makt
INTO TABLE it_makt
WHERE spras = ‘E’.
ENDFORM. ” read_data

*&—————————————————————–*
*& Form alv_setup
*&—————————————————————–*
*
* Setup of the columns in the ALV grid
*
*——————————————————————*
FORM alv_setup.

CLEAR wa_alv_fieldcat.
REFRESH alv_fieldcat.

* Matnr field
wa_alv_fieldcat-key = ‘X’. “This is a key column
wa_alv_fieldcat-fieldname = ‘MATNR’. “Name of the table field
wa_alv_fieldcat-seltext_s = ‘Matnr’. “Short column heading
wa_alv_fieldcat-seltext_m = ‘Material nr.’. “Medium column heading
wa_alv_fieldcat-seltext_l = ‘Material number’. “Long column heading
APPEND wa_alv_fieldcat TO alv_fieldcat.

* Mat text field
wa_alv_fieldcat-key = ”. “This is not a key column
wa_alv_fieldcat-fieldname = ‘MAKTX’.
wa_alv_fieldcat-seltext_s = ‘Mat. txt’.
wa_alv_fieldcat-seltext_m = ‘Material txt’.
wa_alv_fieldcat-seltext_l = ‘Material text’.
APPEND wa_alv_fieldcat TO alv_fieldcat.
ENDFORM. ” alv_setup
*&—————————————————————–*
*& Form display_alv
*&—————————————————————–*
* Display data in the ALV grid
*
*——————————————————————*
FORM display_alv.

gd_repid = sy-repid.

* Configure layout of screen
alv_layout-colwidth_optimize = ‘X’.
alv_layout-zebra = ‘X’.
alv_layout-no_min_linesize = ‘X’.

* Now call display function
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = ‘TOP_OF_PAGE_SETUP’ “Ref to form
is_layout = alv_layout
it_fieldcat = alv_fieldcat
* i_grid_title = text-005
TABLES
t_outtab = it_makt
EXCEPTIONS
program_error = 1
OTHERS = 2.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. ” display_alv
*&—————————————————————–*
*& Form top_of_page_setup
*&—————————————————————–*
*
* Set-up what to display at the top of the ALV pages
* Note that the link to this form is in the
* CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ parameter
* i_callback_top_of_page = ‘TOP_OF_PAGE’ in form display_alv
*——————————————————————*
FORM top_of_page_setup.

DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader.

wa_header-typ = ‘H’.
wa_header-info = ‘This is a test of the ALV grid’.
APPEND wa_header TO t_header.

CLEAR wa_header.

CALL FUNCTION ‘REUSE_ALV_COMMENTARY_WRITE’
EXPORTING
it_list_commentary = t_header.
ENDFORM.

Tags: , , ,



SAP REPORTS





This is the page for sample reports! ALV´s, Batch Inputs, … Whatever are your needs, feel free to ask us … maybe we can help you.

ELSE AND ELSE IF
DATA RESULT TYPE I.

IF RESULT < 0.
WRITE / ‘Result less than zero’.
ELSEIF RESULT = 0.
WRITE / ‘Result equal zero’.
ELSE.
WRITE / ‘Result greater than zero’.
ENDIF.
Depending on the value of RESULT , the three different texts
are output.

ADD-CORRESPONDING – Adds subfields of structures.
ADD-CORRESPONDING TO.

APPEND – Appends a line or multiple lines to the end of an index table.
APPEND |LINES OF TO
[ASSIGNING | REFERENCE INTO].

ASSIGN – Assigns a field to a field symbol
ASSIGN [INCREMENT ] TO
[CASTING [TYPE|LIKE] [DECIMALS]] [RANGE].

Tags: ,



SAP REPORTS – Batch Input (Call Transaction)





This example shows how to use Call Transaction. If Call Transaction fails,

a batch input session is created.

DATA: BEGIN OF BDC_TAB OCCURS 0.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDC_TAB.

FORM Create_Transaction.
* Table for messages from call transaction. The table is automatically
* filled with messags from call transaction.
DATA BEGIN OF messtab OCCURS 10.

INCLUDE STRUCTURE bdcmsgcoll.
DATA END OF messtab.

REFRESH bdc_tab.

* Create new dynpro
PERFORM bdc_newdynpro USING ‘SAPML03T’ ’101′.
* Insert fields
PERFORM bdc_field USING ‘LTAK-BWLVS’ w_screen1000-io_bwls.
PERFORM bdc_field USING ‘LTAP-MATNR’ w_screen1000-io_matnr.
PERFORM bdc_field USING ‘RL03T-ANFME’ w_tmpstr.
PERFORM bdc_field USING ‘LTAP-CHARG’ w_screen1000-io_charg.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=TAM’.
…………….. And much more of the same ………………

**** Use this part if you want to use call transaction
* Call the transaction. Messages from Call Transaction are stored in the
* internal table messtab
CALL TRANSACTION ‘LT01′ USING bdc_tab MODE ‘N’ UPDATE ‘S’
MESSAGES INTO messtab.

IF sy-subrc = 0.
* Call transaction successfull, get the number of the Transfer Order that
* was created
LOOP AT messtab.
IF messtab-dynumb = ’0104′ AND messtab-msgnr = ’016′.
w_transportorderno = messtab-msgv1.
ENDIF.
ENDLOOP.
ELSE.
* Call transaction failed, create a batch input session instead.
PERFORM open_group.

PERFORM bdc_insert USING ‘LT01′.
PERFORM close_group.
ENDIF.

ENDFORM.

Here are the strandard forms used for call transaction and batch input

*****************************************************
* Starts a new screen
*****************************************************
FORM bdc_newdynpro USING program dynpro.
CLEAR bdc_tab.
bdc_tab-program = program.
bdc_tab-dynpro = dynpro.

bdc_tab-dynbegin = ‘X’.
APPEND bdc_tab.
ENDFORM.

*****************************************************
* Inserts a field in bdc_tab
*****************************************************
FORM bdc_field USING fnam fval.
CLEAR bdc_tab.
bdc_tab-fnam = fnam.
bdc_tab-fval = fval.
APPEND bdc_tab.
ENDFORM.

*****************************************************
* Opens group
*****************************************************

FORM open_group.
CALL FUNCTION ‘BDC_OPEN_GROUP’
EXPORTING
client = sy-mandt
* DEST = FILLER8
group = ‘ZSM02′
* HOLDDATE = FILLER8
keep = ‘X’
user = sy-uname
* RECORD = FILLER1
* IMPORTING
* QID =
EXCEPTIONS
client_invalid = 1
destination_invalid = 2
group_invalid = 3
group_is_locked = 4
holddate_invalid = 5
internal_error = 6
queue_error = 7
running = 8
system_lock_error = 9
user_invalid = 10
OTHERS = 11.
ENDFORM.

*****************************************************
* Closes group
*****************************************************

FORM close_group.
CALL FUNCTION ‘BDC_CLOSE_GROUP’
EXCEPTIONS
not_open = 1
queue_error = 2
OTHERS = 3.
ENDFORM.

*****************************************************
* BDC_INSERT
*****************************************************
FORM bdc_insert USING tcode.
CALL FUNCTION ‘BDC_INSERT’
EXPORTING
tcode = tcode
* POST_LOCAL = NOVBLOCAL

* PRINTING = NOPRINT
TABLES
dynprotab = bdc_tab

EXCEPTIONS
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
printing_invalid = 5
posting_invalid = 6
OTHERS = 7.
ENDFORM.

Tags: , ,

Copyright © 2010 ABOUT SAP. All rights reserved.