Using Classification with SmartForms
Sometimes it is nice to make a SmartForm more dynamic, especially since they can be a pain to maintain for complicated labels. In cases like this my colleagues in Germany have developed this method to apply SAP classification to SmartForms.
The first step is to create the desired characteristics. Follow these steps for each characteristic that is required.
- CT04 "Characteristics Management"
- Create a new characteristic (ZLE_MYLABEL_FIELD1)
- Basic Data: Data Type (Character Format), No. of chars (1)
- Descriptions: EN (My field), DE (Meine feld)
- Values: Char Value (1, 2, 3, …) Description (This is my field)
- Restrictions: Class type ZLW
- Save
Continued after the break...
The next step is to create the class
- CL02 "Class"
- Create a new class (ZLE_MYLABEL), type (ZLW)
- Basic data: (My class)
- Char: (ZLE_MYLABLE_FIELD1), Origin (FIELD1)
- Save
Finally assign the classification to the message condition for the SmartForm.
- CL20N
- Usage (B)
- Application (V6)
- Condition type (ZL54)
- Class type (ZLW)
- (ENTER)
- Assignements: add ZLE_MYLABEL, (enter)
- Values for class ZLE_MYLABEL, enter the conditions you wish to make
- Save
In the SmartForm the following code is needed:
FORM read_classification USING inast TYPE nast
CHANGING cs_options TYPE ty_options.
DATA: lf_objek TYPE kssk-objek,
lt_ksml TYPE tt_ksml,
ls_ksml LIKE LINE OF lt_ksml,
lt_ausp TYPE tt_ausp,
ls_ausp LIKE LINE OF lt_ausp.
FIELD-SYMBOLS: TYPE ANY.
CLEAR: lf_objek, cs_options.
CONCATENATE 'B' inast-kappl inast-kschl
INTO lf_objek.
REFRESH: lt_ksml, lt_ausp.
CALL FUNCTION 'READ_CLASS_DATA'
EXPORTING
i_klart = 'ZLW'
i_objek = lf_objek
TABLES
t_ksml = lt_ksml
t_ausp = lt_ausp
EXCEPTIONS
OTHERS = 5.
LOOP AT lt_ksml INTO ls_ksml.
ASSIGN COMPONENT ls_ksml-herku
OF STRUCTURE cs_options
TO .
CHECK sy-subrc EQ 0.
LOOP AT lt_ausp INTO ls_ausp
WHERE atinn EQ ls_ksml-imerk.
= ls_ausp-atwrt.
ENDLOOP.
ENDLOOP.
ENDFORM.