Skip to Content

COND Operator at string template formatting option summary functional operand position..?

Hi,

I'm probably missing obvious explanation as to why or not reading carefully enough, but I can't get the commented code below to compile (NW 740 SP12) and don't understand why:

* <SIGNATURE>---------------------------------------------------------------
* | Instance Public Method /FWW/CL_GL_BEZ_WRWO_HELPER->BUILD_BEZ_WRWO
* +-------------------------------------------------------------------------
* | [--->] I_PATTERN                      TYPE        /FWW/WRW_PATTERN (default =/FWW/CL_GL_BEZ_WRWO_HELPER=>C_DEFAULT_PATTERN)
* | [--->] I_STIEGE                       TYPE        AD_HSNM2(optional)
* | [--->] I_ROOMNUMBER                   TYPE        AD_ROOMNUM
* | [<-()] R_BEZ_WRWO                     TYPE        /FWW/WRW_MOBJ50
* | [!CX!] /FWW/CX_GL_BEZ_WRWO_HELPER
* +-------------------------------------------------------------</SIGNATURE>
METHOD build_bez_wrwo.
  me->check_pattern( i_pattern ).
  "Stiege aus Vorlage, falls leer
  DATA(l_stiege) = COND #(
    WHEN i_stiege IS INITIAL THEN i_pattern+12(3)
    ELSE i_stiege
  ).
  "Stiege Ausrichtung und Auffüllzeichen bestimmen
  DATA(l_align_stiege) = COND i(
    WHEN l_stiege CO '0123456789 ' THEN cl_abap_format=>a_right
    ELSE cl_abap_format=>a_left
  ).
  DATA(l_pad_stiege) = COND string(
    WHEN l_stiege CO '0123456798 ' THEN '0'
    ELSE space
  ).
  "Raumnummer Ausrichting und Auffüllzeichen bestimmen
  DATA(l_align_room) = COND i(
    WHEN i_roomnumber CO '0123456789 ' THEN cl_abap_format=>a_right
    ELSE cl_abap_format=>a_left
  ).
  DATA(l_pad_room) = COND string(
    WHEN i_roomnumber CO '0123456798 ' THEN '0'
    ELSE space
  ).

  r_bez_wrwo =
      |{ i_pattern(12) WIDTH = 12 ALIGN = LEFT }| &&
      |{ condense( val = l_stiege )
           WIDTH = 3
           ALIGN = (l_align_stiege)
*This does not compile...************************************************
*           ALIGN = ( COND i(
*             WHEN l_stiege CO '0123456789 ' THEN cl_abap_format=>a_right
*             ELSE cl_abap_format=>a_left
*           ) )
*************************************************************************
           PAD = l_pad_stiege
      } | &&
      |{ condense( val = i_roomnumber )
           WIDTH = 3
           ALIGN = (l_align_room)
           PAD = l_pad_room
      }|.

ENDMETHOD.

I tried with or without space between the COND and opening parenthesis of summary functional operand position - the compiler error message does change (I can't understand either of the messages...). Is the operator simply not meant to go at that position (I have to refactor that condition out to a functional method)?

Thank you,
Jānis

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 25, 2016 at 10:25 AM

    No such luck with padding though :) And autocomplete is screwed up as well.

    I ended up with the following:

    METHOD build_bez_wrwo.
      me->check_pattern( i_pattern ).
    
      "Stiege aus Vorlage, falls leer
      DATA(l_stiege) = COND #(
        WHEN i_stiege IS INITIAL THEN i_pattern+12(3)
        ELSE i_stiege
      ).
    
      DATA(l_pad_stiege) = me->pad_alphanumeric( CONV #( l_stiege ) ).
      DATA(l_pad_roomnumber) = me->pad_alphanumeric( CONV #( i_roomnumber ) ).
    
      r_bez_wrwo =
          |{ i_pattern(12) WIDTH = 12 ALIGN = LEFT }| &&
          |{ condense( val = l_stiege )
               WIDTH = 3
               ALIGN = ME->align_alphanumeric( CONV #( l_stiege ) )
               PAD = l_pad_stiege
          } | && "Leerzeichen braucht man hier...
          |{ condense( val = i_roomnumber )
               WIDTH = 3
               ALIGN = me->align_alphanumeric( CONV #( i_roomnumber ) )
               PAD = l_pad_roomnumber
          }|.
    
    ENDMETHOD.
    Add comment
    10|10000 characters needed characters exceeded

  • Oct 25, 2016 at 07:28 AM

    It seems that the nature of the arguments may vary according to the option. For LEN, it may be a "numeric expression position" (you may indicate a function) ; for ALIGN, it may be a "data object" only (source: format_options)

    Add comment
    10|10000 characters needed characters exceeded