点击此处---> 群内免费提供SAP练习系统(在群公告中)
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
嗨,
在这里,我尝试根据使用过程订购的数量给予折扣。 但是我不知道如何在过程中将column的值分配给变量。
这是我的代码:
创建列表" KABIL_PRACTICE"。" SALES_IF_ELSE" ( " SALES_ID"整数, " PRODUCT_ID"整数, " QTY"整数, " DISCOUNT"整数, " SALES_AMOUNT"双 ); " SALES_IF_ELSE"(" SALES_ID"," PRODUCT_ID"," QTY"," SALES_AMOUNT")值(1,101,15,1500)插入到" KABIL_PRACTICE"中; " SALES_IF_ELSE"(" SALES_ID"," PRODUCT_ID"," QTY"," SALES_AMOUNT")值(2,102,25,2500);将其插入" KABIL_PRACTICE"。 值" 3,103,35,3500";" SALES_IF_ELSE"(" SALES_ID"," PRODUCT_ID"," QTY"," SALES_AMOUNT")值插入到" KABIL_PRACTICE"中; 值" 4,104,40,4000"中的" SALES_IF_ELSE"(" SALES_ID"," PRODUCT_ID"," QTY"," SALES_AMOUNT")插入到" KABIL_PRACTICE"中; " SALES_IF_ELSE"(" SALES_ID"," PRODUCT_ID"," QTY"," SALES_AMOUNT")值(5,105,27,2700);将其插入" KABIL_PRACTICE"。 " SALES_IF_ELSE"(" SALES_ID"," PRODUCT_ID"," QTY"," SALES_AMOUNT")值(6,106,32,3200)插入;并插入" KABIL_PRACTICE"中。 值(7,107,19,1900);" SALES_IF_ELSE"(" SALES_ID"," PRODUCT_ID"," QTY"," SALES_AMOUNT")值插入到" KABIL_PRACTICE"中; 创建过程" KABIL_PRACTICE"。" IF_ELSE_DISC" 语言sqlscript 一开始 声明QTY整数; " SALES_IF_ELSE":=数量;从" KABIL_PRACTICE"中选择"数量"。 如果(数量> 25) 然后 更新" KABIL_PRACTICE"。" SALES_IF_ELSE"设置为" DISCOUNT" = 5; 否则,如果 更新" KABIL_PRACTICE"。" SALES_IF_ELSE"设置为" DISCOUNT" = 1; 万一; 万一; 结束;
有人帮助我。...
我已经为您提供了答案( https://stackoverflow.com/questions/45832931/how-to-assign-a-variable-in-procedure-in-sap-hana ):
这是没有充分使用SQL而是试图在SQL数据库上强制使用命令式编程风格的经典情况。
您要做的就是根据条件更新表,不是吗?
在这种情况下,根本不需要过程逻辑(对于任何SQL数据库都是如此)。
这将在单个命令中将计算出的
" DISCOUNT"
值存储在表中,而不会循环。如果这不是您想要执行的操作,请细化问题描述。
能否请您多解释一下您想要达到的目标? 您是要计算单个条目的折扣(如果是,限制条件在哪里),还是要更新所有条目的折扣?
在您当前的示例中,尝试读取单个" QTY"值没有太大意义,因为结果将始终是数组而不是单个值。
关于,
弗洛里安
嗨弗洛里安,
我只想知道如何将列值分配给在此声明为" QTY"的变量...
一周热门 更多>