SAP

Excel OLE color conversion

Denise 2022. 10. 4. 10:30

FUNCTION zdk_rgb_to_ole_color.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IV_RGB) TYPE  CSEQUENCE
*"  EXPORTING
*"     REFERENCE(EV_COLOR) TYPE  CSEQUENCE
*"  EXCEPTIONS
*"      INVALID_COLOR
*"----------------------------------------------------------------------

  CONSTANTSlc_rgb TYPE VALUE 256.

  DATAlv_color  TYPE LENGTH 6.
  DATAlv_int    TYPE i.
  DATAlv_ole    TYPE int4.
  DATAlv_hex    TYPE xstring.

  IF iv_rgb+0(1'#'.
    lv_color iv_rgb+1(*).
  ELSE.
    lv_color iv_rgb+0(*).
  ENDIF.

  IF strlenlv_color <> 6.
    RAISE invalid_color.
  ENDIF.

  lv_hex lv_color+0(2).
  lv_int lv_hex.

  lv_ole lv_ole + lv_int.

  lv_hex lv_color+2(2).
  lv_int lv_hex.

  lv_ole lv_ole + lv_int * lc_rgb ).

  lv_hex lv_color+4(2).
  lv_int lv_hex.

  lv_ole lv_ole + lv_int * lc_rgb * lc_rgb ).

  ev_color lv_ole.
  CONDENSE ev_color.

ENDFUNCTION.

 

FUNCTION zdk_ole_to_rgb_color.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IV_COLOR) TYPE  CSEQUENCE
*"  EXPORTING
*"     REFERENCE(EV_RGB) TYPE  CSEQUENCE
*"  EXCEPTIONS
*"      INVALID_COLOR
*"----------------------------------------------------------------------
  CONSTANTS lc_rgb TYPE VALUE 256.

  DATAlv_color  TYPE int4.
  DATAlv_red    TYPE i.
  DATAlv_gre    TYPE i.
  DATAlv_blue   TYPE i.
  DATAlv_ole    TYPE int4.
  DATAlv_temp   TYPE DECIMALS 1.
  DATAlv_hex    TYPE xstring.
  DATAlv_chars  TYPE char02.

  lv_ole iv_color.

  lv_red  lv_ole MOD lc_rgb.
  lv_hex  lv_red.
  lv_chars lv_hex.
  ev_rgb lv_chars.

  lv_temp trunclv_ole / lc_rgb ).
  lv_gre lv_temp MOD lc_rgb.
  lv_hex lv_gre.
  lv_chars lv_hex.
  CONCATENATE ev_rgb lv_chars
         INTO ev_rgb.

  lv_temp trunclv_ole / lc_rgb / lc_rgb ).
  lv_blue lv_temp MOD lc_rgb.
  lv_hex  lv_blue.
  lv_chars lv_hex.
  CONCATENATE ev_rgb lv_chars
         INTO ev_rgb.

  CONDENSE ev_rgb.

ENDFUNCTION.

'SAP' 카테고리의 다른 글

How to find WebDynpro includes  (0) 2024.08.27