This blog has been discontinued (See latest posts)
Thursday, November 25, 2010 Integrating Safety Symbols in the PI Sheet
VN:F [1.9.22_1171]
Rating: 4.5/5 (4 votes cast)

In my 4th session I presented a weighing demo which included also material dependent safety symbols. In this article I would like to show how to accomplish this.

The Look

Let me first show how the symbols look like in my setup. Picture 1 shows the list of components with the column ‘Safety’ containing small safety symbols. There are some materials that have symbols and some that don’t. So the content of this column depend on the material. in picture 2 you see the detailed weighing instruction with larger safety symbols to remind the operator again what to look out for.

PI Sheet: Component Overview

Picture 1: Component Overview

PI Sheet: Component Detail

Picture 2: Component Detail

The XStep Setup

In the further discussion I will concentrate on the list overview (Picture 1). In Picture 3 you see the structure of the XStep. For every component an XStep with an instruction (‘Line’) is generated (using a special custom generation scope, but you can just as well use one of the standard generation scopes for material components as well). The first element is a placeholder for dynamic status icons which I will not explain in this article.

XStep: Component Overview Section

Picture 3: The XStep

The important element here is a long text output element using PPPI_FRAGMENT_HTML. Here I have included placeholders for 3 image elements. This setup assumes that you have already created your safety symbol images in the web repository (TA SMW0). The naming convention I used here for the file names is Z_ICON_EHS_<SpecificName>.gif where ‘<SpecificName>’ is to be replaced by some meaningful string for each different symbol.

XStep: Long text for symbol output

Picture 4: The Long Text

As you can see I am including a parameter replacement (&…&) for each of my potential safety symbols. In my case I have restricted the scenario to max. 3 symbols per material. So if you need more you need to extend this of course. You might already have noticed that I have always 3 images here so you would expect always 3 images to be shown in the PI Sheet. Of course if the specific parameter is not evaluated (because there is no such symbol for the specific material) the image source would read ‘Z_ICON_EHS_.gif’. This of course would lead to nasty little broken link images in your PI Sheet. Therefore make sure that you also create a special image in the web repository with exactly that name (Z_ICON_EHS_.gif) which displays nothing (1×1 pixel with full transparency). When you do this an image is only shown where there should be one.

Now of course the real work begins when we come to the valuation of these parameters. The basic setup is shown in Picture 5 where 3 different parameters (those used in the long text parameter replacement) are valuated with 3 different valuation symbols.

XStep: Parameter Valuation

Picture 5: The Parameter Symbol Valuation

Linking the Symbols with the Material

Of course there are many ways to define safety information in an SAP environment. If you are using EHS you will probably find the information there. To make it simple for my demo scenario I have chosen to use the material classification. I created a material class (TA CL01, class type 001) which includes 3 characteristics PH_SYM_01, PH_SYM_02, and PH_SYM_03 with some meaningful description. The I classified those of my component materials where I want to see safety symbols in the PI Sheet (TA MM02). In my example for material MX_RAW_AI_01 I only valuated the first 2 characteristics:

  • PH_SYM_01 = GS_X
  • PH_SYM_02 = R_GLOVES

Of course the correspondent images (amongst others) must exist in the web repository (TA SMW0):

  • Z_ICON_EHS_GS_X.GIF
  • Z_ICON_EHS_R_GLOVES.GIF

Symbol Valuation

Helper Function

To get the actual characteristic value of the classified material I first created a small helper function:

FUNCTION Z_PH_GET_EHS_SYMBOL.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(MATNR) LIKE  RESB-MATNR
*"     REFERENCE(ATNAM) LIKE  CABN-ATNAM
*"  EXPORTING
*"     REFERENCE(SYMBOL) LIKE  AUSP-ATWRT
*"----------------------------------------------------------------------

TABLES: cabn, ausp.

SELECT SINGLE * FROM cabn
  WHERE atnam = atnam.

SELECT SINGLE * FROM ausp
  WHERE objek = matnr
  AND   atinn = cabn-atinn.

IF sy-subrc = 0.
  symbol = ausp-atwrt.
ENDIF.

ENDFUNCTION.

BAdI Implementation

In this article I will not describe how to set up and implement the valuation symbols. If you want to know how to get started with these valuation BAdIs please refer to my article ‘Using BAdIs for Custom Valuation and Generation in XSteps‘.

Here is the code you need to include for valuating the safety symbol parameters:

method IF_CMX_XS_SERVICE_SYMBOL~GET_DATA.

*====================================================================
* This is a very basic method for valuation of XStep symbols:
* - It contains a lot of hardcoded elements!
* - There is no exception handling!
*
*====================================================================

*=== Data declaration ===============================================
  DATA: ls_tempsym       TYPE cmx_xs_w_symbol_name,
        ls_symbol        TYPE cmx_xs_w_symbol_name,
        l_ehs_symbol    TYPE        AUSP-ATWRT,
        l_rsnum          TYPE        resb-rsnum,
        l_rspos          TYPE        resb-rspos,
        l_rsart          TYPE        resb-rsart,
        l_posnr          type        resb-posnr,
        l_sortf          TYPE        resb-sortf,
        l_matnr          TYPE        resb-matnr,
        l_qty            TYPE        resb-bdmng,
        ls_resbd         TYPE        resbd.

*=== Preparation ====================================================

*--- Set namespace of the valuated symbols --------------------------
ls_tempsym-namespace = 'SAP'.

IF flt_val-application = 'MOR'.

*   get reservation number from generated step
    ls_tempsym-symbol = 'RESERVATION'.
    query->get_value_into_numc(
                   EXPORTING
                        symbol  = ls_tempsym
                   IMPORTING
                         data   = l_rsnum ).
*   get reservation item from generated step
    ls_tempsym-symbol = 'RESERVATION_ITEM'.
    query->get_value_into_numc(
                   EXPORTING
                        symbol  = ls_tempsym
                   IMPORTING
                         data   = l_rspos ).
*   get reservation item type from generated step
    ls_tempsym-symbol = 'RESERVATION_ITEM_TYPE'.
    query->get_value_into_string(
                   EXPORTING
                        symbol  = ls_tempsym
                   IMPORTING
                         data   = l_rsart ).
*   Read corresponding reservation data
    CALL FUNCTION 'CO_BT_RESB_READ_WITH_KEY'
      EXPORTING
        flg_resbd       = space
        no_read_from_db = 'X'
        rsart_imp       = l_rsart
        rsnum_imp       = l_rsnum
        rspos_imp       = l_rspos
      IMPORTING
        resbd_exp       = ls_resbd
      EXCEPTIONS
        not_found       = 1
        OTHERS          = 2.

      l_sortf = ls_resbd-sortf.
      l_matnr = ls_resbd-matnr.
      l_posnr = ls_resbd-posnr.

      IF ls_resbd-nomng IS initial.
        l_qty = ls_resbd-bdmng.
      ELSE.
        l_qty = ls_resbd-nomng.
      ENDIF.

ELSE.

    ls_tempsym-symbol = 'QUANTITY_REQUIRED'.
    query->get_value_into_packed(
                   EXPORTING
                        symbol  = ls_tempsym
                   IMPORTING
                         data   = l_qty ).

    ls_tempsym-symbol = 'MATERIAL'.
    query->get_value_into_string(
                   EXPORTING
                        symbol  = ls_tempsym
                   IMPORTING
                         data   = l_matnr ).

   l_sortf = ''.

ENDIF.

*=== Valuation depending on the filter symbol =======================
  ls_symbol-namespace = flt_val-namespace.
  ls_symbol-symbol    = flt_val-symbol.

  CASE flt_val-symbol.

*___ EH&S Symbol 1 from Material Classification _____________________
   WHEN 'EHS_SYMBOL_01'.
     l_ehs_symbol = ''.
     CALL FUNCTION 'Z_PH_GET_EHS_SYMBOL'
      EXPORTING
        matnr           = l_matnr
        atnam           = 'PH_SYM_01'
      IMPORTING
        symbol          = l_ehs_symbol.

       query->set_value_from_string( symbol = ls_symbol
                                     data   = l_ehs_symbol
                                     domain = 'DDIC/ATWRT' ).
*___ EH&S Symbol 2 from Material Classification _____________________
   WHEN 'EHS_SYMBOL_02'.
     l_ehs_symbol = ''.
     CALL FUNCTION 'Z_PH_GET_EHS_SYMBOL'
      EXPORTING
        matnr           = l_matnr
        atnam           = 'PH_SYM_02'
      IMPORTING
        symbol          = l_ehs_symbol.

       query->set_value_from_string( symbol = ls_symbol
                                     data   = l_ehs_symbol
                                     domain = 'DDIC/ATWRT' ).

*___ EH&S Symbol 3 from Material Classification _____________________
   WHEN 'EHS_SYMBOL_03'.
     l_ehs_symbol = ''.
     CALL FUNCTION 'Z_PH_GET_EHS_SYMBOL'
      EXPORTING
        matnr           = l_matnr
        atnam           = 'PH_SYM_03'
      IMPORTING
        symbol          = l_ehs_symbol.

       query->set_value_from_string( symbol = ls_symbol
                                     data   = l_ehs_symbol
                                     domain = 'DDIC/ATWRT' ).

  ENDCASE.

ENDMETHOD.

Please make sure that you use the same name of the characteristic in you material class and in the call of function Z_PH_GET_EHS_SYMBOL (atnam = …). Of course you can also include other symbol valuation code for material related valuation here as I described it in my guide.

Integrating Safety Symbols in the PI Sheet, 4.5 out of 5 based on 4 ratings
Please rate the article:
VN:F [1.9.22_1171]
Rating: 4.5/5 (4 votes cast)

News

This blog has been discontinued!

Archives

Calendar

November 2010
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930