2011年5月4日 星期三

SAP Script Form

SAP Script Form 是by Client 與 語言作開發的。
在Form中加一段程式碼

PERFORM form IN PROGRAM prog
USING &INVAR1&
USING &INVAR2&
......
CHANGING &OUTVAR1&
CHANGING &OUTVAR2&
......
ENDPERFORM


在Program中的程式碼
重點要將資料append 或 modify回OUT_TAB的itab內

**-- 2011/05/03 add by ben (Check ZH partner)
*&--------------------------------------------------------------------*
*& Form Check ZH Partner
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->IN_TAB text
* -->OUT_TAB text
*---------------------------------------------------------------------*
FORM CHECK_ZH_PARTNER TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
DATA: L_LIFN2 TYPE EKPA-LIFN2.
DATA: L_ADRNR TYPE LFA1-ADRNR.
DATA: L_INDEX TYPE SY-TABIX.
READ TABLE IN_TAB WITH KEY 'EKKO-EBELN'.

SELECT SINGLE LIFN2 INTO L_LIFN2
FROM EKPA
WHERE EBELN = IN_TAB-VALUE
AND EBELP = '00000'
AND PARVW = 'ZH'.
IF SY-SUBRC = 0.
SELECT SINGLE ADRNR INTO L_ADRNR
FROM LFA1
WHERE LIFNR = L_LIFN2.
IF SY-SUBRC = 0.
READ TABLE OUT_TAB WITH KEY 'PEKKO-ADRNR'.
L_INDEX = SY-TABIX.
IF SY-SUBRC = 0.
OUT_TAB-VALUE = L_ADRNR.
ENDIF.
MODIFY OUT_TAB INDEX L_INDEX.
CLEAR OUT_TAB.
ENDIF.
ENDIF.
ENDFORM. "check_zh_partner

沒有留言:

張貼留言