10-25-2016 7:43 AM
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
10-25-2016 11: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.
10-25-2016 8: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)
10-25-2016 11:08 AM
You are right, I believe - the ALIGN and PAD positions should take only data objects (of course, it even says so in the documentation...). This, however, compiles and even seems to work:
r_bez_wrwo =
|{ i_pattern(12) WIDTH = 12 ALIGN = LEFT }| &&
|{ condense( val = l_stiege )
WIDTH = 3
* ALIGN = (l_align_stiege)
align = me->align_alphanumeric( l_stiege )
* ALIGN = ( COND i(
* WHEN l_stiege CO '0123456789 ' THEN cl_abap_format=>a_right
* ELSE cl_abap_format=>a_left
* ))
PAD = l_pad_stiege
} | && "Leerzeichen braucht man hier...
|{ condense( val = i_roomnumber )
WIDTH = 3
ALIGN = (l_align_room)
PAD = l_pad_room
}|.
And the COND without parentheses compiles and works as well! 🙂 Syntax highlighting gets confused, however.
10-25-2016 11:32 AM
Ok, I'm not good at reading documentation "diagonally" today 🙂 PAD, unlike ALIGN, can not take dynamic values - so says the documentation.
10-25-2016 1:18 PM
Great! My fault, I had looked at the 7.02 documentation. It works well in 7.40.
10-25-2016 11: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.
10-25-2016 11:44 AM