BW裏轉換簡單常用ABAP
阿新 • • 發佈:2018-03-05
月份 tab datum 裏的 讀取 物料 字段 -s 工作
用戶查看的是當時的物料折讓,那你必然要給物料加個時間,才好區分。總是以現在最新的物料狀態查看歷史數據會出現問題。當時這個物料是折讓的,現在不折讓了。數據會有問題。加個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.
BW裏轉換簡單常用ABAP