안녕하세요. 오늘 첨으로 글을 올려보는데요. 정말 답답해 죽겠습니다.아직 모르는게 천지인.. 초보인지라
저는 지금 해외법인 환율에 대해서 운영을 하고 있는 초보인데요.
지역금융에서 다른 법인의 RFC펑션을 타고 환율의 정보를 가져다가 지역금융에서 보여주게 되는데요.
그 펑션을 이용할때 각 법인의 코드와 REASON코드라는것이 들어가야하는데.
각 법인마다 사용하고 있는 REASON코드는 다 각자 다릅니다.
01,02,1,2,3,4,5,6이라는 REASON코드중에 각법인에서 사용하지 않는 코드는 나오지 않도록 만들어야 하는데
이 펑션을 다루고 있는 곳은
CALL FUNCTION 'Z_FI_REVERSE_FROM_FEMS'
DESTINATION GT_MAINCURR-ZDEST
EXPORTING
BUKRS = GT_MAINCURR-ZBUKRS
GJAHR = DEALYR "YEAR
STGRD = REASON "GT_MAINCURR-STGRD
IMPORTING
RG = RT_CD
MSG = MESSAGE
TABLES
BELNR = XBELNR
REVNR = REVENR
STGRD = GT_REASONC
EXCEPTIONS
COMMUNICATION_FAILURE = 9 MESSAGE MSG_TEXT
SYSTEM_FAILURE = 8 MESSAGE MSG_TEXT.
IF SY-SUBRC = 8 OR SY-SUBRC = 9.
MESSAGE E998 WITH GT_MAINCURR-ZCOMPTEXT
'failed connection !'.
ENDIF.
ENDLOOP.
이 펑션 모듈 안에서 이루어 지거든요
FUNCTION Z_FI_REVERSE_FROM_FEMS.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(BUKRS) LIKE BKPF-BUKRS
*" VALUE(GJAHR) LIKE BKPF-GJAHR
*" VALUE(STGRD) LIKE UF05A-STGRD
*" EXPORTING
*" VALUE(RG) LIKE ZFEMSSTRUC-RC
*" VALUE(MSG) LIKE ZFEMSSTRUC-MSG
*" TABLES
*" BELNR STRUCTURE ZFEMSSAPNOSTRC
*" REVNR STRUCTURE ZFEMSREVESTRC
*"----------------------------------------------------------------------
DATA : BEGIN OF SAPNO OCCURS 0,
BELNR LIKE BKPF-BELNR,
END OF SAPNO.
DATA BEGIN OF ITAB_MSG OCCURS 10.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA END OF ITAB_MSG.
DATA BEGIN OF GW_PERIOD . "zzum.kim. 2008.10.30.
INCLUDE STRUCTURE T001B .
DATA END OF GW_PERIOD .
DATA BEGIN OF GW_STGRD.
INCLUDE STRUCTURE UF05A.
DATA: END OF GW_STGRD.
DATA : PSDATE LIKE ZFEMSEVALUE-ZZEVALDATE . "posting date zzum.kim
DATA : MTDATE LIKE ZFEMSEVALUE-ZZEVALDATE . "closing date zzum.kim
* DATA : GW_TEMPD LIKE UF05A-TEMPD
DATA : BUDAT LIKE BKPF-BUDAT,
TMP_BELNR(10) TYPE N,
MODE,
RTCD LIKE SY-TABIX,
MONAT LIKE BKPF-MONAT.
SAPNO[] = BELNR[].
CLEAR : PSDATE , MTDATE , RG , REVNR , MSG. "zzum.kim. 2008.11.10.
LOOP AT SAPNO.
TMP_BELNR = SAPNO-BELNR.
* -- zzum.kim start 2008.10.16.
* ---- original source code - befor 2008.10.16.
* SELECT SINGLE budat INTO budat FROM bkpf WHERE gjahr = gjahr
* AND belnr = tmp_belnr.
SELECT SINGLE BUDAT INTO BUDAT
FROM BKPF
WHERE BUKRS EQ BUKRS
AND BELNR EQ TMP_BELNR
AND GJAHR EQ GJAHR.
* SELECT SINGLE GW_TEMPD INTO GW_TEMPD
* FROM GW_STGRD
* WHERE STGRD EQ STGRD
* AND TEMPD EQ TEMPD.
*if stgrd <> 0.
* -- zzum.kim end 2008.10.16.
IF SY-SUBRC NE 0.
RC = SY-SUBRC.
CONCATENATE 'There is not ' TMP_BELNR 'in Document Header'
INTO MSG.
EXIT.
ELSE.
PSDATE = BUDAT . "zzum.kim. 2008.10.30.
CLEAR BUDAT.
BUDAT = SY-DATUM.
ENDIF.
* -- zzum.kim : start 2008.10.30.
** -- check closing month - table t001b <= postiong key date
SELECT SINGLE BUKRS FRYE1 FRPE1
FROM T001B
INTO CORRESPONDING FIELDS OF GW_PERIOD
WHERE BUKRS = BUKRS
AND MKOAR = 'S' .
IF SY-SUBRC = 0 .
CONCATENATE GW_PERIOD-FRYE1 GW_PERIOD-FRPE1+1(2) INTO MTDATE .
IF MTDATE <= PSDATE+0(6) .
* -- zzum.kim : end 2008.10.30.
* monat = budat+4(2).
REFRESH : BDCDATA, ITAB_MSG.
PERFORM BDC_DATA_CREATE USING 'SAPMF05A' '0105' 'X' '' ''.
PERFORM BDC_DATA_CREATE USING '' '' '' 'RF05A-BELNS' SAPNO-BELNR .
PERFORM BDC_DATA_CREATE USING '' '' '' 'BKPF-BUKRS' BUKRS .
PERFORM BDC_DATA_CREATE USING '' '' '' 'RF05A-GJAHS' GJAHR .
PERFORM BDC_DATA_CREATE USING '' '' '' 'UF05A-STGRD' STGRD .
* PERFORM bdc_data_create USING '' '' '' 'BSIS-BUDAT' budat.
* PERFORM bdc_data_create USING '' '' '' 'BSIS-MONAT' monat.
* perform bdc_data_create using '' '' '' 'RF05A-VOIDR' voidr.
PERFORM BDC_DATA_CREATE USING '' '' '' 'BDC_OKCODE' '=BU'.
MODE = 'N' .
CALL TRANSACTION 'FB08' USING BDCDATA
MODE MODE"A or E or N
MESSAGES INTO ITAB_MSG.
RTCD = SY-SUBRC.
DATA : LIN TYPE I.
DESCRIBE TABLE ITAB_MSG LINES LIN.
READ TABLE ITAB_MSG INDEX LIN.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
MSGID = ITAB_MSG-MSGID
MSGNR = ITAB_MSG-MSGNR
MSGV1 = ITAB_MSG-MSGV1
MSGV2 = ITAB_MSG-MSGV2
MSGV3 = ITAB_MSG-MSGV3
MSGV4 = ITAB_MSG-MSGV4
IMPORTING
MESSAGE_TEXT_OUTPUT = MSG
EXCEPTIONS
OTHERS = 1.
* -- zzum.kim : start 2008.11.10.
REVNR-RV_BELNR = TMP_BELNR .
REVNR-RV_MSG = MSG .
APPEND REVNR . CLEAR : REVNR , MSG .
* -- zzum.kim : end 2008.11.10.
CONCATENATE ITAB_MSG-MSGTYP ITAB_MSG-MSGNR
'(' ITAB_MSG-MSGID ')' MSG INTO MSG.
IF MSG(8) = 'S312(F5)'. "Document&was posted in company code&
RC = 0.
ELSEIF MSG(8) = 'E361(F5)'. "Document was already reverse
RC = 0.
ELSE.
RC = RTCD.
ENDIF.
* -- zzum.kim : start 2008.11.03.
ELSE .
CLEAR : RC , RG .
RC = 10 .
RG = RC .
CONCATENATE ' Document ' TMP_BELNR ' is not allowed to reverse.'
INTO MSG.
REVNR-RV_BELNR = TMP_BELNR .
REVNR-RV_MSG = MSG .
APPEND REVNR . CLEAR REVNR .
ENDIF .
* -- zzum.kim : end 2008.11.03.
ENDIF .
ENDLOOP.
ENDFUNCTION.
*---------------------------------------------------------------------*
* FORM bdc_data_create *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> p_pgm *
* --> p_dynpro *
* --> p_begin *
* --> p_fld *
* --> p_val *
*---------------------------------------------------------------------*
FORM BDC_DATA_CREATE USING P_PGM P_DYNPRO P_BEGIN P_FLD P_VAL.
CLEAR BDCDATA.
IF P_BEGIN = 'X'.
BDCDATA-PROGRAM = P_PGM.
BDCDATA-DYNPRO = P_DYNPRO.
BDCDATA-DYNBEGIN = P_BEGIN.
ELSE.
BDCDATA-FNAM = P_FLD.
BDCDATA-FVAL = P_VAL.
ENDIF.
APPEND BDCDATA.
ENDFORM. " BDC_DATA
이곳이 펑션안에 정의 되어있는것들인데요
이중에 REASON코드에 해당하는 FIELD 는 STGRD라는 필드입니다.
어떻게방법이 없을까요.