用户查看的是当时的物料折让,那你必然要给物料加个时间,才好区分。总是以现在最新的物料状态查看历史数据会出现问题。当时这个物料是折让的,现在不折让了。数据会有问题。加个DSO。做一个时间记录。读取系统时间,上数的时候做为判断。3月份上数就是取3月份。当时的物料状态
在结束例程里写。字段赋予常量方可生效。
*取物料上数的系统时间的月份判断季度
loop at RESULT_PACKAGE ASSIGNING <RESULT_FIELDS> . l_date = sy-datum+4(4).. l_date1 = sy-datum+4(2). year = sy-datum+0(4). if l_date = 12. l_year = year + 1. endif. IF ‘0321‘ <= l_date AND l_date <= ‘0620‘. CONCATENATE year ‘2‘ INTO <RESULT_FIELDS>-CALQUARTER. ELSEIF ‘0621‘ <= l_date AND l_date <= ‘0920‘. CONCATENATE year ‘3‘ INTO <RESULT_FIELDS>-CALQUARTER.. ELSEIF ‘0921‘ <= l_date AND l_date <= ‘1220‘. CONCATENATE year ‘4‘ INTO <RESULT_FIELDS>-CALQUARTER.. ELSEIF l_date <= ‘0320‘. CONCATENATE year ‘1‘ INTO <RESULT_FIELDS>-CALQUARTER.. ELSE. CONCATENATE l_year ‘1‘ INTO <RESULT_FIELDS>-CALQUARTER.. ENDIF. endloop.
销售上数, 判断销售季度。,取是否折让字段,
这ABAP写不太出来,需要多实践。
这个其实不难,没写过。还真写不出来。可笑了,眼高手低典型代表
*定义一个操作字段类型 data: l_date type String, year type String, l_year type string, l_date1 type String. *定义一个内表 IT_ZCZJTO26 ,工作区 WA_ZCZJTO26 DATA:IT_ZCZJTO26 TYPE STANDARD TABLE OF /BIC/AZCZJTO2600, WA_ZCZJTO26 TYPE /BIC/AZCZJTO2600. *循环这个RESULT_PACKAGE,分配<RESULT_FIELDS>,判断季度 loop at RESULT_PACKAGE ASSIGNING <RESULT_FIELDS> . l_date = <RESULT_FIELDS>-PSTNG_DATE+4(4). l_date1 = <RESULT_FIELDS>-PSTNG_DATE+4(2). year = <RESULT_FIELDS>-PSTNG_DATE+0(4). if l_date = 12. l_year = year + 1. endif. IF ‘0321‘ <= l_date AND l_date <= ‘0620‘. CONCATENATE year ‘2‘ INTO <RESULT_FIELDS>-CALQUARTER. ELSEIF ‘0621‘ <= l_date AND l_date <= ‘0920‘. CONCATENATE year ‘3‘ INTO <RESULT_FIELDS>-CALQUARTER. ELSEIF ‘0921‘ <= l_date AND l_date <= ‘1220‘. CONCATENATE year ‘4‘ INTO <RESULT_FIELDS>-CALQUARTER. ELSEIF l_date <= ‘0320‘. CONCATENATE year ‘1‘ INTO <RESULT_FIELDS>-CALQUARTER. ELSE. CONCATENATE l_year ‘1‘ INTO <RESULT_FIELDS>-CALQUARTER. *12,28=‘1228‘是不小于‘0320’的 ENDIF. endloop. *读取需要字段从表/BIC/AZCZJTO2600 。分配至内表 IT_ZCZJTO26 * INTO CORRESPONDING FIELDS OF TABLE 自动匹配相应的字段 SELECT MATERIAL CALQUARTER /BIC/ZSFZR FROM /BIC/AZCZJTO2600 INTO CORRESPONDING FIELDS OF TABLE IT_ZCZJTO26 FOR ALL ENTRIES IN RESULT_PACKAGE WHERE MATERIAL = RESULT_PACKAGE-/BIC/ZMATERIAL AND CALQUARTER = RESULT_PACKAGE-CALQUARTER. *循环将内表里IT_ZCZJTO26 分配给工作区 WA_ZCZJTO26 。做了分配 LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS> . READ TABLE IT_ZCZJTO26 INTO WA_ZCZJTO26 WITH KEY MATERIAL = <RESULT_FIELDS>-/BIC/ZMATERIAL CALQUARTER = <RESULT_FIELDS>-CALQUARTER. *执行成功 ,结果是否折让等于工作区 WA_ZCZJTO26-/BIC/ZSFZR.,是/BIC/AZCZJTO2600 里的字段。 IF sy-subrc = 0. <RESULT_FIELDS>-/BIC/ZSFZR = WA_ZCZJTO26-/BIC/ZSFZR. ENDIF. ENDLOOP.