"List elements that take up more than one line are not permitted" 复杂 IF 语句错误
"List elements that take up more than one line are not permitted" error with complex IF statement
我不熟悉 APD 中的 ABAP 编码。我如何在 ABAP 代码中编写这样的语句?
if ((ls_source-VHMODEL == 'M1' OR ls_source-VHMODEL == 'M2') AND (ls_source-CREATE_DATE <= '2016-01-01' AND ls_source-CREATE_DATE >= '2014-01-01'))
{
// do stuff
}
else if ((ls_source-VHMODEL == 'H1' OR ls_source-VHMODEL == 'C3') AND (ls_source-CREATE_DATE <= '2015-01-01' AND ls_source-CREATE_DATE >= '2014-02-01'))
{
// do stuff
}
我试过这个:
if ( ( ls_source-VHMODEL EQ 'M1' OR ls_source-VHMODEL EQ 'M2') AND
(ls_source-CREATE_DATE > '20120122' AND ls_source-CREATE_DATE < '20120922')).
MOVE 'Segment 2' TO ls_target-SEGMENT.
else.
MOVE 'Other' TO ls_target-SEGMENT.
endif.
但这给了我错误
Syntax error: List elements that take up more than one line are not permitted.
试试这个:
if ( ( ls_source-vhmodel eq 'M1' or ls_source-vhmodel eq 'M2' ) and
( ls_source-create_date le '20160101' and ls_source-create_date ge '20140101' )
).
* Do something
elseif (
( ls_source-vhmodel eq 'H1' or ls_source-vhmodel eq 'C3' ) and
( ls_source-create_date le '20150101' and ls_source-create_date ge '20140201' )
).
*Do something
endif.
注意括号在代码中的分隔方式。
希望对您有所帮助。
你能检查一下括号前后是否有 space 吗?。
众所周知,ABAP 编译器对这些事情很敏感,因为括号可能意味着其他事情(即数据中的偏移量)。
您的问题是 (
和 )
.
前后的括号和间距
此代码编译:
if ( ls_source-vhmodel eq 'M1' or ls_source-vhmodel eq 'M2' ) and
( ls_source-create_date > '20120122' and ls_source-create_date < '20120922' ).
move 'Segment 2' to ls_target-segment.
else.
move 'Other' to ls_target-segment.
endif.
问题是您没有在括号之间留下 space。与其他语言不同,ABAP 需要在括号和语句的其余部分之间使用 space。
(ls_source-CREATE_DATE > '20120122' AND ls_source-CREATE_DATE < '20120922')).
^^^ ^^^
我不熟悉 APD 中的 ABAP 编码。我如何在 ABAP 代码中编写这样的语句?
if ((ls_source-VHMODEL == 'M1' OR ls_source-VHMODEL == 'M2') AND (ls_source-CREATE_DATE <= '2016-01-01' AND ls_source-CREATE_DATE >= '2014-01-01'))
{
// do stuff
}
else if ((ls_source-VHMODEL == 'H1' OR ls_source-VHMODEL == 'C3') AND (ls_source-CREATE_DATE <= '2015-01-01' AND ls_source-CREATE_DATE >= '2014-02-01'))
{
// do stuff
}
我试过这个:
if ( ( ls_source-VHMODEL EQ 'M1' OR ls_source-VHMODEL EQ 'M2') AND
(ls_source-CREATE_DATE > '20120122' AND ls_source-CREATE_DATE < '20120922')).
MOVE 'Segment 2' TO ls_target-SEGMENT.
else.
MOVE 'Other' TO ls_target-SEGMENT.
endif.
但这给了我错误
Syntax error: List elements that take up more than one line are not permitted.
试试这个:
if ( ( ls_source-vhmodel eq 'M1' or ls_source-vhmodel eq 'M2' ) and
( ls_source-create_date le '20160101' and ls_source-create_date ge '20140101' )
).
* Do something
elseif (
( ls_source-vhmodel eq 'H1' or ls_source-vhmodel eq 'C3' ) and
( ls_source-create_date le '20150101' and ls_source-create_date ge '20140201' )
).
*Do something
endif.
注意括号在代码中的分隔方式。
希望对您有所帮助。
你能检查一下括号前后是否有 space 吗?。
众所周知,ABAP 编译器对这些事情很敏感,因为括号可能意味着其他事情(即数据中的偏移量)。
您的问题是 (
和 )
.
此代码编译:
if ( ls_source-vhmodel eq 'M1' or ls_source-vhmodel eq 'M2' ) and
( ls_source-create_date > '20120122' and ls_source-create_date < '20120922' ).
move 'Segment 2' to ls_target-segment.
else.
move 'Other' to ls_target-segment.
endif.
问题是您没有在括号之间留下 space。与其他语言不同,ABAP 需要在括号和语句的其余部分之间使用 space。
(ls_source-CREATE_DATE > '20120122' AND ls_source-CREATE_DATE < '20120922')).
^^^ ^^^