嵌套的Ifs问题

2020-08-23 12:15发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


人们好,

我收到一条错误消息,说"其余文本似乎不是公式的一部分"。 然后突出显示最后一个Else语句之后的所有文本。 但我看不出问题出在哪里。 我认为我的分号位于正确的位置。

有什么想法吗?

这是我的代码。...

本地字符串变量mth;
 本地stringvar yr;
 局部stringvar dy;


 mth:="";
 yr:="";
 dy:="";


 yr = RIGHT(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4);


 如果{usp_invoicecredit1.doCustomerID} =" POM0485",则
     如果1 = 2则
         mth:=" kl"
     否则,如果2 = 3,则
         mth:=" ui";


     如果3 = 2
         mth:=" kj"
     其他
         mth:=" jkj";


     如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 01"然后
         mth:=" 02"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 02"然后
         mth:=" 03"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 03"然后
         mth:=" 04"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 04"然后
         mth:=" 05"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 05"然后
         mth:=" 06"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 06"然后
         mth:=" 07"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 07"然后
         mth:=" 08"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 08"然后
         mth:=" 09"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 09"然后
         mth:=" 10"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 10"然后
         mth:=" 11"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 11"然后
         mth:=" 12"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 12"然后
         mth:=" 01";


     如果为左(Totext({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),2)<=" 10"然后
         dy =" 10"
     否则,如果为LEFT(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),2)<=" 20"然后
         dy =" 20"
     否则,如果mth =" 01",则
         dy =" 28"
     否则,如果mth =" 01"或mth =" 03"或mth =" 05"或mth =" 06"或mth =" 07"或mth =" 10"或mth =" 12",则
         dy =" 31"
     否则,如果mth =" 04"或mth =" 06"或mth =" 09"或mth =" 11",则
         dy =" 30"
     否则,如果1 = 1
         dy =" 28";


     ToText(dy +"/" + mth +"/" + yr)//显示字符串


 else//这是问题所在
    ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"); //显示字串
    
 


 

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


人们好,

我收到一条错误消息,说"其余文本似乎不是公式的一部分"。 然后突出显示最后一个Else语句之后的所有文本。 但我看不出问题出在哪里。 我认为我的分号位于正确的位置。

有什么想法吗?

这是我的代码。...

本地字符串变量mth;
 本地stringvar yr;
 局部stringvar dy;


 mth:="";
 yr:="";
 dy:="";


 yr = RIGHT(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4);


 如果{usp_invoicecredit1.doCustomerID} =" POM0485",则
     如果1 = 2则
         mth:=" kl"
     否则,如果2 = 3,则
         mth:=" ui";


     如果3 = 2
         mth:=" kj"
     其他
         mth:=" jkj";


     如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 01"然后
         mth:=" 02"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 02"然后
         mth:=" 03"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 03"然后
         mth:=" 04"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 04"然后
         mth:=" 05"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 05"然后
         mth:=" 06"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 06"然后
         mth:=" 07"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 07"然后
         mth:=" 08"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 08"然后
         mth:=" 09"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 09"然后
         mth:=" 10"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 10"然后
         mth:=" 11"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 11"然后
         mth:=" 12"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 12"然后
         mth:=" 01";


     如果为左(Totext({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),2)<=" 10"然后
         dy =" 10"
     否则,如果为LEFT(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),2)<=" 20"然后
         dy =" 20"
     否则,如果mth =" 01",则
         dy =" 28"
     否则,如果mth =" 01"或mth =" 03"或mth =" 05"或mth =" 06"或mth =" 07"或mth =" 10"或mth =" 12",则
         dy =" 31"
     否则,如果mth =" 04"或mth =" 06"或mth =" 09"或mth =" 11",则
         dy =" 30"
     否则,如果1 = 1
         dy =" 28";


     ToText(dy +"/" + mth +"/" + yr)//显示字符串


 else//这是问题所在
    ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"); //显示字串
    
 


 
付费偷看设置
发送
2条回答
打个大熊猫
1楼-- · 2020-08-23 12:22

当您需要在If中运行多个语句时,需要用括号将它们括起来。 因此,您的公式将如下所示:

 local stringvar mth;
 本地stringvar yr;
 局部stringvar dy;

 mth:="";
 yr:="";
 dy:="";
 yr = RIGHT(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4);

 如果{usp_invoicecredit1.doCustomerID} =" POM0485",则(
     如果1 = 2则
         mth:=" kl"
     否则,如果2 = 3,则
         mth:=" ui";

     如果3 = 2
         mth:=" kj"
     其他
         mth:=" jkj";

     如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 01"然后
         mth:=" 02"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 02"然后
         mth:=" 03"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 03"然后
         mth:=" 04"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 04"然后
         mth:=" 05"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 05"然后
         mth:=" 06"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 06"然后
         mth:=" 07"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 07"然后
         mth:=" 08"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 08"然后
         mth:=" 09"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 09"然后
         mth:=" 10"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 10"然后
         mth:=" 11"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 11"然后
         mth:=" 12"
     否则,如果MID(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),4,2)=" 12"然后
         mth:=" 01";

     如果为左(Totext({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),2)<=" 10"然后
         dy =" 10"
     否则,如果为LEFT(ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"),2)<=" 20"然后
         dy =" 20"
     否则,如果mth =" 01",则
         dy =" 28"
     否则,如果mth =" 01"或mth =" 03"或mth =" 05"或mth =" 06"或mth =" 07"或mth =" 10"或mth =" 12",则
         dy =" 31"
     否则,如果mth =" 04"或mth =" 06"或mth =" 09"或mth =" 11",则
         dy =" 30"
     否则,如果1 = 1
         dy =" 28";

     ToText(dy +"/" + mth +"/" + yr)//显示字符串
 )
 else//这是问题所在
    ToText({usp_Invoicecredit1.dueDate}," dd/MM/yyyy"); //显示字符串

在右括号后可能需要用分号。

-Dell

SAP砖家
2楼-- · 2020-08-23 12:30

您好,Dell,

做到了这一点(没有半冒号)。

非常感谢

J

一周热门 更多>