簡單的RCF Function

qiujun發表於2007-07-18

作用:輸入SO和SO的日期得到SO的相關資料後,把資料轉入內表...

TABLES項IT_SODATA LIKE ZSDTEST_MAURICE 接資料到內表ZSDTEST_MAURICE為StructureS_VBELN like TVARVCS_ERDAT like TVARVC

EXCEPTIONS項
NODATAFOUND There are no data fount
NODATE Not date

程式程式碼:

[@more@]

FUNCTION zsdtest_maurcie.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" IT_SODATA STRUCTURE ZSDTEST_MAURICE
*" S_VBELN STRUCTURE TVARVC
*" S_ERDAT STRUCTURE TVARVC
*" EXCEPTIONS
*" NODATAFOUND
*" NODATE
*"----------------------------------------------------------------------
RANGES: r_vbeln FOR vbak-vbeln.
RANGES: r_erdat FOR vbak-erdat.

CLEAR: r_vbeln, r_vbeln[], r_erdat, r_erdat[].

IF s_erdat[] IS INITIAL.
RAISE nodate.
ELSE.
LOOP AT s_erdat.
r_erdat-sign = s_erdat-sign.
r_erdat-option = s_erdat-opti.
r_erdat-low = s_erdat-low .
r_erdat-high = s_erdat-high.
APPEND r_erdat.
CLEAR r_erdat.
ENDLOOP.
ENDIF.

IF s_vbeln[] IS NOT INITIAL.
LOOP AT s_vbeln.
r_vbeln-sign = s_vbeln-sign.
r_vbeln-option = s_vbeln-opti.
r_vbeln-low = s_vbeln-low .
r_vbeln-high = s_vbeln-high.
APPEND r_vbeln.
CLEAR r_vbeln.
ENDLOOP.
ENDIF.


SELECT
vbak~vbeln
vbak~erdat
vbak~auart
vbak~vkorg
vbak~vtweg
vbak~vkbur
vbak~bstnk
vbap~matnr
vbap~posnr
INTO CORRESPONDING FIELDS OF TABLE it_sodata
FROM vbak
INNER JOIN vbap
ON vbak~vbeln = vbap~vbeln
WHERE vbak~vbeln IN r_vbeln
AND vbak~erdat IN r_erdat.

IF it_sodata[] IS INITIAL.
RAISE nodatafound.
ENDIF.

ENDFUNCTION.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/90072/viewspace-926952/,如需轉載,請註明出處,否則將追究法律責任。

相關文章