Park1
Park1
Park1
FORM UPLOAD_FILE .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = P_FILE.
ENDFORM.
FORM FILL_TABLE .
MOVE P_FILE TO FILENAME_EXL.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = FILENAME_EXL
I_BEGIN_COL = '1'
I_BEGIN_ROW = '2'
I_END_COL = '256'
I_END_ROW = '10000'
TABLES
INTERN = L_INTERN
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC NE 0.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE : / 'FILE ERROR'.
EXIT.
ELSE.
SORT L_INTERN BY ROW COL.
LOOP AT L_INTERN.
MOVE L_INTERN-COL TO L_INDEX.
ASSIGN COMPONENT L_INDEX OF STRUCTURE WA_ITAB TO <FS>.
MOVE L_INTERN-VALUE TO <FS>.
AT END OF ROW.
APPEND WA_ITAB TO IT_ITAB.
CLEAR WA_ITAB.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM. " FILL_TABLE
FORM GET_DATA_KR.
DATA: IT_BKPF TYPE TABLE OF BKPF,
WA_BKPF TYPE BKPF,
IT_BSEG TYPE TABLE OF BSEG,
WA_BSEG TYPE BSEG,
LV_CNT TYPE NUMC3,
LV_AKONT TYPE AKONT,
IT_BSEC TYPE TABLE OF BSEC,
IT_BSET TYPE TABLE OF BSET,
IT_BSEZ TYPE TABLE OF BSEZ,
IT_BKORM TYPE TABLE OF BKORM,
IT_THEAD TYPE TABLE OF THEAD,
IT_SPLTTAB TYPE TABLE OF ACSPLT,
IT_SPLTWT TYPE TABLE OF WITH_ITEMX,
IT_MANDATE TYPE TABLE OF SEPA_MANDATE,
LV_NEWKO TYPE NUMC10,
LV_HKONT TYPE SAKNR.
* FS006_FB01 TYPE FS006.
TABLES: WITH_ITEM.
DATA : H_LFBW TYPE LFBW OCCURS 0 WITH HEADER LINE,
H_T001WT TYPE T001WT OCCURS 0 WITH HEADER LINE,
T_BSEZ TYPE BSEZ OCCURS 0 WITH HEADER LINE,
FS006_FB01 TYPE FS006,
T_BKPF TYPE BKPF OCCURS 0 WITH HEADER LINE,
T_BSEG TYPE BSEG OCCURS 0 WITH HEADER LINE,
I_WITH_ITEM TYPE WITH_ITEMX OCCURS 0 WITH HEADER LINE,
T_BSEC TYPE TABLE OF BSEC,
T_BSET TYPE TABLE OF BSET,
LV_BELNR TYPE VBKPF-BELNR,
* LV_BUKRS TYPE VBKPF-BUKRS VALUE '1001',
* LV_GJAHR TYPE VBKPF-GJAHR,
* LV_LIFNR TYPE BSEG-LIFNR VALUE 'MAS1022',
* XMSG LIKE FIMSG1 OCCURS 0 WITH HEADER LINE,
* XVBKPF TYPE VBKPF OCCURS 0 WITH HEADER LINE,
* LV_BUDAT TYPE BKPF-BUDAT,
LV_SLNO TYPE NUMC4.
* WA_BKPF-BLDAT = SY-DATUM.
* WA_BKPF-BUDAT = SY-DATUM.
WA_BKPF-MONAT = FISCAL_PERIOD.
WA_BKPF-WWERT = SY-DATUM.
WA_BKPF-USNAM = SY-UNAME.
WA_BKPF-TCODE = 'FB01'.
WA_BKPF-XBLNR = WA_ITAB-XBLNR.
WA_BKPF-WAERS = WA_ITAB-WAERS.
WA_BKPF-GLVOR = 'RFBU'.
WA_BKPF-HWAER = 'INR'.
WA_BKPF-XMWST = 'X'.
WA_BKPF-KUTY2 = 'M'.
APPEND WA_BKPF TO IT_BKPF.
CLEAR WA_BKPF.
ENDIF.
IF WA_ITAB-NEWBS = '31' OR WA_ITAB-NEWBS = '40'.
WA_BSEG-BUKRS = WA_ITAB-BUKRS.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
EXPORTING
COMPANYCODEID = 'SAFF'
POSTING_DATE = POSTING_DATE
IMPORTING
FISCAL_YEAR = FISCAL_YEAR
FISCAL_PERIOD = FISCAL_PERIOD
* RETURN =
.
WA_BSEG-GJAHR = FISCAL_YEAR.
* WA_BSEG-GJAHR = SY-DATUM+0(4).
WA_BSEG-BUZEI = LV_CNT.
WA_BSEG-BSCHL = WA_ITAB-NEWBS.
IF WA_ITAB-NEWBS = '31'.
WA_BSEG-KOART = 'K'.
WA_BSEG-SHKZG = 'H'.
WA_BSEG-GSBER = WA_ITAB-GSBER.
WA_BSEG-PRCTR = WA_ITAB-PRCTR.
WA_BSEG-MWSKZ = WA_ITAB-MWSKZ.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-ZUONR.
WA_BSEG-ZUONR = WA_ITAB-NEWKO.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-XUMSW = 'X'.
WA_BSEG-XHRES = 'X'.
WA_BSEG-XKRES = 'X'.
WA_BSEG-XOPVW = 'X'.
CLEAR:LV_AKONT,LV_NEWKO.
LV_NEWKO = WA_ITAB-NEWKO.
SELECT SINGLE AKONT INTO LV_AKONT FROM LFB1 WHERE LIFNR = LV_NEWKO AND B
UKRS = WA_ITAB-BUKRS.
WA_BSEG-SAKNR = LV_AKONT.
WA_BSEG-HKONT = LV_AKONT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-LIFNR. "wa_bseg-hkont
* wa_bseg-lifnr = wa_itab-newko.
WA_BSEG-ZFBDT = SY-DATUM.
ENDIF.
IF WA_ITAB-NEWBS = '40'.
WA_BSEG-KOART = 'S'.
WA_BSEG-SHKZG = 'S'.
WA_BSEG-GSBER = WA_ITAB-GSBER.
WA_BSEG-PRCTR = WA_ITAB-PRCTR.
WA_BSEG-MWSKZ = WA_ITAB-MWSKZ.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
* wa_bseg-zuonr = wa_itab-NEWKO.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-KOSTL = WA_ITAB-KOSTL.
* wa_bseg-XUMSW = 'X'.
WA_BSEG-XHRES = 'X'.
* wa_bseg-XKRES = 'X'.
* wa_bseg-XOPVW = 'X'.
* CLEAR:lv_hkont.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-HKONT.
LV_HKONT = WA_ITAB-NEWKO.
* SELECT SINGLE akont INTO lv_akont FROM lfb1 WHERE lifnr = wa_itab-NEWKO A
ND bukrs = wa_itab-bukrs.
* wa_mseg-saknr = lv_akont.
* wa_bseg-hkont = lv_hkont.
* wa_mseg-lifnr = wa_itab-newko.
WA_BSEG-ZFBDT = SY-DATUM.
ENDIF.
APPEND WA_BSEG TO IT_BSEG.
ENDIF.
CLEAR:WA_BSEG.
ENDLOOP.
*
* CALL FUNCTION 'FI_WT_READ_T001WT'
* EXPORTING
* I_BUKRS = 'SAFF'
** I_TYPE =
* TABLES
* T_T001WT = H_T001WT
* EXCEPTIONS
* NOT_FOUND = 1
* OTHERS = 2.
*
*
* CALL FUNCTION 'FI_WT_READ_LFBW'
* EXPORTING
* I_LIFNR = '0001000003'
* I_BUKRS = 'SAFF'
** I_TYPE =
* TABLES
* T_LFBW = H_LFBW
* EXCEPTIONS
* NOT_FOUND = 1
* OTHERS = 2.
*
*
* LOOP AT H_LFBW.
**--- vendor subjected to wt type
* IF H_LFBW-WT_SUBJCT = 'X'.
*
* READ TABLE H_T001WT WITH KEY
* WITHT = H_LFBW-WITHT.
*
* IF SY-SUBRC EQ 0.
* IF H_T001WT-WT_AGENT = 'X' AND
* H_T001WT-WT_AGTDF LE lv_BUDAT AND
* H_T001WT-WT_AGTDT GE lv_BUDAT.
*
* MOVE-CORRESPONDING H_LFBW TO I_WITH_ITEM.
* I_WITH_ITEM-WT_WTEXMN = H_LFBW-WT_EXNR.
* I_WITH_ITEM-BUZEI = '1'. " <---- Vendor Item No
* I_WITH_ITEM-WT_QSSHH = '2000'. "<--- Line item 2 amount
* APPEND I_WITH_ITEM.
* ENDIF.
* ENDIF.
* ENDIF.
*ENDLOOP.
*
*CALL FUNCTION 'FI_WT_PUT_X_WITH_ITEM'
* TABLES
* T_WITH_ITEM = I_WITH_ITEM.
ELSE.
* Error message capturing
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
INTO LV_TEXT
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
wa_msg-sno = LV_SLNO.
wa_msg-msgtyp = SY-MSGTY.
wa_msg-text = LV_TEXT.
* WA_RETURN-TYPE = SY-MSGTY. "Message type: S Success, E Error, W Warning,
I Info, A Abort
* WA_RETURN-ID = SY-MSGID. "Message Class
* WA_RETURN-NUMBER = SY-MSGNO. "Message Number
* WA_RETURN-MESSAGE = LV_TEXT. "Message Text
* APPEND WA_RETURN TO ET_RETURN.
APPEND wa_msg to it_msg.
CLEAR wa_msg.
*Return error messages back to Mulesoft
* T_RETURN[] = ET_RETURN[].
ENDIF.
ENDFORM.
FORM GET_DATA_KZ.
DATA: IT_BKPF TYPE TABLE OF BKPF,
WA_BKPF TYPE BKPF,
IT_BSEG TYPE TABLE OF BSEG,
WA_BSEG TYPE BSEG,
LV_CNT TYPE NUMC3,
LV_AKONT TYPE AKONT,
IT_BSEC TYPE TABLE OF BSEC,
IT_BSET TYPE TABLE OF BSET,
IT_BSEZ TYPE TABLE OF BSEZ,
IT_BKORM TYPE TABLE OF BKORM,
IT_THEAD TYPE TABLE OF THEAD,
IT_SPLTTAB TYPE TABLE OF ACSPLT,
IT_SPLTWT TYPE TABLE OF WITH_ITEMX,
IT_MANDATE TYPE TABLE OF SEPA_MANDATE,
LV_NEWKO TYPE NUMC10,
LV_HKONT TYPE SAKNR.
DATA : LV_BELNR TYPE VBKPF-BELNR,
LV_SLNO TYPE NUMC4,
FISCAL_YEAR TYPE BAPI0002_4-FISCAL_YEAR,
FISCAL_PERIOD TYPE BAPI0002_4-FISCAL_PERIOD.
WA_BKPF-BUKRS = 'SAFF'. "WA_ITAB-BUKRS.
WA_BKPF-GJAHR = SY-DATUM+0(4).
WA_BKPF-BLART = 'KZ'."WA_ITAB-BLART.
WA_BKPF-BLDAT = SY-DATUM.
WA_BKPF-BUDAT = SY-DATUM.
WA_BKPF-MONAT = '05' ."FISCAL_PERIOD ."'04'.
WA_BKPF-WWERT = SY-DATUM.
WA_BKPF-USNAM = SY-UNAME.
WA_BKPF-TCODE = 'FB01'.
WA_BKPF-XBLNR = 'Test'. "WA_ITAB-XBLNR.
WA_BKPF-WAERS = 'INR'."WA_ITAB-WAERS.
WA_BKPF-GLVOR = 'RFBV'.
WA_BKPF-HWAER = 'INR'.
* WA_BKPF-XMWST = 'X'.
WA_BKPF-KUTY2 = 'M'.
APPEND WA_BKPF TO IT_BKPF.
CLEAR WA_BKPF.
FORM GET_DATA_KZ_ITAB.
DATA: IT_BKPF TYPE TABLE OF BKPF,
WA_BKPF TYPE BKPF,
IT_BSEG TYPE TABLE OF BSEG,
WA_BSEG TYPE BSEG,
LV_CNT TYPE NUMC3,
LV_AKONT TYPE AKONT,
IT_BSEC TYPE TABLE OF BSEC,
IT_BSET TYPE TABLE OF BSET,
IT_BSEZ TYPE TABLE OF BSEZ,
IT_BKORM TYPE TABLE OF BKORM,
IT_THEAD TYPE TABLE OF THEAD,
IT_SPLTTAB TYPE TABLE OF ACSPLT,
IT_SPLTWT TYPE TABLE OF WITH_ITEMX,
IT_MANDATE TYPE TABLE OF SEPA_MANDATE,
LV_NEWKO TYPE NUMC10,
LV_HKONT TYPE SAKNR.
DATA : LV_BELNR TYPE VBKPF-BELNR,
LV_SLNO TYPE NUMC4,
FISCAL_YEAR TYPE BAPI0002_4-FISCAL_YEAR,
FISCAL_PERIOD TYPE BAPI0002_4-FISCAL_PERIOD,
E_BELNR TYPE CHAR10,
POSTING_DATE TYPE BAPI0002_4-POSTING_DATE,
LV_TEXT TYPE BAPI_MSG.
* WA_BKPF-BLDAT = WA_ITAB-BLDAT.
* WA_BKPF-BUDAT = WA_ITAB-BUDAT.
* CLEAR:POSTING_DATE.
* CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
*
*
* CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
* EXPORTING
* COMPANYCODEID = 'SAFF'
* POSTING_DATE = POSTING_DATE "WA_ITAB-BUDAT
* IMPORTING
* FISCAL_YEAR = FISCAL_YEAR
* FISCAL_PERIOD = FISCAL_PERIOD
** RETURN =
* .
WA_BKPF-MONAT = FISCAL_PERIOD."FISCAL_PERIOD ."'04'.
WA_BKPF-GJAHR = FISCAL_YEAR.
WA_BKPF-WWERT = SY-DATUM.
WA_BKPF-USNAM = SY-UNAME.
WA_BKPF-CPUDT = SY-DATUM.
WA_BKPF-TCODE = 'FB01'.
WA_BKPF-XBLNR = WA_ITAB-XBLNR.
WA_BKPF-WAERS = WA_ITAB-WAERS.
WA_BKPF-GLVOR = 'RFBV'.
WA_BKPF-HWAER = WA_ITAB-WAERS.
WA_BKPF-KUTY2 = 'M'.
APPEND WA_BKPF TO IT_BKPF.
CLEAR WA_BKPF.
ENDIF.
IF WA_ITAB-NEWBS = '50'.
WA_BSEG-BUKRS = WA_ITAB-BUKRS.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
EXPORTING
COMPANYCODEID = 'SAFF'
POSTING_DATE = POSTING_DATE
IMPORTING
FISCAL_YEAR = FISCAL_YEAR
FISCAL_PERIOD = FISCAL_PERIOD
* RETURN =
.
WA_BSEG-GJAHR = FISCAL_YEAR.
WA_BSEG-BUZEI = LV_CNT.
WA_BSEG-BSCHL = WA_ITAB-NEWBS.
WA_BSEG-KOART = 'S'.
WA_BSEG-SHKZG = 'H'.
WA_BSEG-GSBER = WA_ITAB-GSBER.
CLEAR:LV_NEWKO.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = LV_NEWKO.
WA_BSEG-HKONT = LV_NEWKO.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-KOSTL = WA_ITAB-KOSTL.
WA_BSEG-ZFBDT = SY-DATUM.
APPEND WA_BSEG TO IT_BSEG.
CLEAR:WA_BSEG.
ENDIF.
IF WA_ITAB-NEWBS = '40'.
WA_BSEG-BUKRS = WA_ITAB-BUKRS.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
EXPORTING
COMPANYCODEID = 'SAFF'
POSTING_DATE = POSTING_DATE
IMPORTING
FISCAL_YEAR = FISCAL_YEAR
FISCAL_PERIOD = FISCAL_PERIOD
* RETURN =
.
WA_BSEG-GJAHR = FISCAL_YEAR.
WA_BSEG-BUZEI = LV_CNT.
WA_BSEG-BSCHL = WA_ITAB-NEWBS.
WA_BSEG-KOART = 'S'.
WA_BSEG-SHKZG = 'S'.
WA_BSEG-GSBER = WA_ITAB-GSBER.
CLEAR:LV_NEWKO.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = LV_NEWKO.
WA_BSEG-HKONT = LV_NEWKO.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-KOSTL = WA_ITAB-KOSTL.
WA_BSEG-ZFBDT = SY-DATUM.
APPEND WA_BSEG TO IT_BSEG.
CLEAR:WA_BSEG.
ENDIF.
IF WA_ITAB-NEWBS = '25'.
WA_BSEG-BUKRS = WA_ITAB-BUKRS.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
ENDIF.
ENDFORM.
FORM GET_DATA_KG.
DATA: IT_BKPF TYPE TABLE OF BKPF,
WA_BKPF TYPE BKPF,
IT_BSEG TYPE TABLE OF BSEG,
WA_BSEG TYPE BSEG,
LV_CNT TYPE NUMC3,
LV_AKONT TYPE AKONT,
IT_BSEC TYPE TABLE OF BSEC,
IT_BSET TYPE TABLE OF BSET,
IT_BSEZ TYPE TABLE OF BSEZ,
IT_BKORM TYPE TABLE OF BKORM,
IT_THEAD TYPE TABLE OF THEAD,
IT_SPLTTAB TYPE TABLE OF ACSPLT,
IT_SPLTWT TYPE TABLE OF WITH_ITEMX,
IT_MANDATE TYPE TABLE OF SEPA_MANDATE,
LV_NEWKO TYPE NUMC10,
LV_HKONT TYPE SAKNR.
DATA : LV_BELNR TYPE VBKPF-BELNR,
LV_SLNO TYPE NUMC4,
FISCAL_YEAR TYPE BAPI0002_4-FISCAL_YEAR,
FISCAL_PERIOD TYPE BAPI0002_4-FISCAL_PERIOD.
WA_BKPF-BUKRS = 'SAFF'. "WA_ITAB-BUKRS.
WA_BKPF-GJAHR = SY-DATUM+0(4).
WA_BKPF-BLART = 'KG'."WA_ITAB-BLART.
WA_BKPF-BLDAT = SY-DATUM.
WA_BKPF-BUDAT = SY-DATUM.
WA_BKPF-MONAT = '05' ."FISCAL_PERIOD ."'04'.
WA_BKPF-WWERT = SY-DATUM.
WA_BKPF-USNAM = SY-UNAME.
WA_BKPF-TCODE = 'FB01'.
WA_BKPF-XBLNR = 'Test'. "WA_ITAB-XBLNR.
WA_BKPF-WAERS = 'INR'."WA_ITAB-WAERS.
WA_BKPF-GLVOR = 'RFBV'.
WA_BKPF-HWAER = 'INR'.
* WA_BKPF-XMWST = 'X'.
WA_BKPF-KUTY2 = 'M'.
APPEND WA_BKPF TO IT_BKPF.
CLEAR WA_BKPF.
WA_BSEG-BUKRS = 'SAFF'. "WA_ITAB-BUKRS.
WA_BSEG-GJAHR = SY-DATUM+0(4).
WA_BSEG-BUZEI = '001'.
WA_BSEG-BSCHL = '21'."WA_ITAB-NEWBS.
WA_BSEG-KOART = 'K'.
WA_BSEG-SHKZG = 'S'.
WA_BSEG-GSBER = 'ADTD'."WA_I41200001TAB-GSBER.
WA_BSEG-DMBTR = '1000.00'."WA_ITAB-WRBTR.
WA_BSEG-WRBTR = '1000.00'."WA_ITAB-WRBTR.
WA_BSEG-PSWBT = '1000.00'."WA_ITAB-WRBTR.
WA_BSEG-PSWSL = 'INR'."WA_ITAB-WAERS.
WA_BSEG-SGTXT = 'Test2'."WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
CLEAR:LV_AKONT,LV_NEWKO.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = LV_NEWKO.
SELECT SINGLE AKONT INTO LV_AKONT FROM LFB1 WHERE LIFNR = LV_NEWKO AND BUKRS =
WA_ITAB-BUKRS.
WA_BSEG-SAKNR = LV_AKONT.
WA_BSEG-HKONT = LV_AKONT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-LIFNR. "wa_bseg-hkont
WA_BSEG-SAKNR = '0020110001'.
WA_BSEG-HKONT = '0020110001'.
WA_BSEG-LIFNR = '0001000002'.
WA_BSEG-XKRES = 'X'.
WA_BSEG-XOPVW = 'X'.
WA_BSEG-XZAHL = 'X'.
WA_BSEG-XBILK = 'X'.
WA_BSEG-KOSTL = 'CFATCTOS'.
WA_BSEG-ZFBDT = SY-DATUM.
APPEND WA_BSEG TO IT_BSEG.
CLEAR:WA_BSEG.
* WA_BKPF-BLDAT = SY-DATUM.
* WA_BKPF-BUDAT = SY-DATUM.
* WA_BKPF-MONAT = FISCAL_PERIOD.
* WA_BKPF-BLDAT = WA_ITAB-BLDAT.
* WA_BKPF-BUDAT = WA_ITAB-BUDAT.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
FORM GET_DATA_KA_ITAB.
DATA: IT_BKPF TYPE TABLE OF BKPF,
WA_BKPF TYPE BKPF,
IT_BSEG TYPE TABLE OF BSEG,
WA_BSEG TYPE BSEG,
LV_CNT TYPE NUMC3,
LV_AKONT TYPE AKONT,
IT_BSEC TYPE TABLE OF BSEC,
IT_BSET TYPE TABLE OF BSET,
IT_BSEZ TYPE TABLE OF BSEZ,
IT_BKORM TYPE TABLE OF BKORM,
IT_THEAD TYPE TABLE OF THEAD,
IT_SPLTTAB TYPE TABLE OF ACSPLT,
IT_SPLTWT TYPE TABLE OF WITH_ITEMX,
IT_MANDATE TYPE TABLE OF SEPA_MANDATE,
LV_NEWKO TYPE NUMC10,
LV_HKONT TYPE SAKNR.
DATA : LV_BELNR TYPE VBKPF-BELNR,
LV_SLNO TYPE NUMC4,
FISCAL_YEAR TYPE BAPI0002_4-FISCAL_YEAR,
FISCAL_PERIOD TYPE BAPI0002_4-FISCAL_PERIOD,
E_BELNR TYPE CHAR10,
POSTING_DATE TYPE BAPI0002_4-POSTING_DATE,
LV_TEXT TYPE BAPI_MSG.
WA_BKPF-BLDAT = POSTING_DATE.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
WA_BKPF-BUDAT = POSTING_DATE.
CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
EXPORTING
COMPANYCODEID = 'SAFF'
POSTING_DATE = POSTING_DATE "WA_ITAB-BUDAT
IMPORTING
FISCAL_YEAR = FISCAL_YEAR
FISCAL_PERIOD = FISCAL_PERIOD
* RETURN =
.
WA_BKPF-MONAT = FISCAL_PERIOD."FISCAL_PERIOD ."'04'.
WA_BKPF-GJAHR = FISCAL_YEAR.
WA_BKPF-WWERT = SY-DATUM.
WA_BKPF-USNAM = SY-UNAME.
WA_BKPF-CPUDT = SY-DATUM.
WA_BKPF-TCODE = 'FB01'.
WA_BKPF-XBLNR = WA_ITAB-XBLNR.
WA_BKPF-WAERS = WA_ITAB-WAERS.
WA_BKPF-GLVOR = 'RFBU'.
WA_BKPF-HWAER = WA_ITAB-WAERS.
WA_BKPF-KUTY2 = 'M'.
APPEND WA_BKPF TO IT_BKPF.
CLEAR WA_BKPF.
ENDIF.
IF WA_ITAB-NEWBS = '21' OR WA_ITAB-NEWBS = '31'.
WA_BSEG-BUKRS = WA_ITAB-BUKRS.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
WA_BSEG-GSBER = WA_ITAB-GSBER.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
CLEAR:LV_AKONT,LV_NEWKO.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = LV_NEWKO.
WA_BSEG-LIFNR = LV_NEWKO.
CLEAR:LV_AKONT.
SELECT SINGLE AKONT INTO LV_AKONT FROM LFB1 WHERE LIFNR = LV_NEWKO AND BUK
RS = WA_ITAB-BUKRS.
WA_BSEG-SAKNR = LV_AKONT.
WA_BSEG-HKONT = LV_AKONT.
WA_BSEG-KOSTL = WA_ITAB-KOSTL.
WA_BSEG-ZFBDT = SY-DATUM.
APPEND WA_BSEG TO IT_BSEG.
CLEAR:WA_BSEG.
ENDIF.
IF WA_ITAB-NEWBS = '50' OR WA_ITAB-NEWBS = '40'.
WA_BSEG-BUKRS = WA_ITAB-BUKRS.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
EXPORTING
COMPANYCODEID = 'SAFF'
POSTING_DATE = POSTING_DATE
IMPORTING
FISCAL_YEAR = FISCAL_YEAR
FISCAL_PERIOD = FISCAL_PERIOD
* RETURN =
.
WA_BSEG-GJAHR = FISCAL_YEAR.
WA_BSEG-BUZEI = LV_CNT.
WA_BSEG-BSCHL = WA_ITAB-NEWBS.
IF WA_BSEG-BSCHL = '40'.
WA_BSEG-KOART = 'S'.
WA_BSEG-SHKZG = 'S'.
ENDIF.
IF WA_BSEG-BSCHL = '50'.
WA_BSEG-KOART = 'S'.
WA_BSEG-SHKZG = 'H'.
ENDIF.
WA_BSEG-GSBER = WA_ITAB-GSBER.
CLEAR:LV_NEWKO.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = LV_NEWKO.
WA_BSEG-HKONT = LV_NEWKO.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-KOSTL = WA_ITAB-KOSTL.
WA_BSEG-ZFBDT = SY-DATUM.
APPEND WA_BSEG TO IT_BSEG.
CLEAR:WA_BSEG.
ENDIF.
CLEAR:WA_ITAB.
ENDLOOP.
CALL FUNCTION 'PRELIMINARY_POSTING_FB01'
EXPORTING
TEXT_UPDATE = 'X'
* TEXT_ITEM_UPDATE = ' '
* I_UF05A =
I_XCMPL = 'X'
* FS006_FB01 =
I_TCODE = 'FB01'
* I_PARGB =
* I_TCODE_INT =
* IMPORTING
* XEPBBP =
TABLES
T_BKPF = IT_BKPF
T_BSEG = IT_BSEG
T_BSEC = IT_BSEC
T_BSET = IT_BSET
T_BSEZ = IT_BSEZ
* T_BKORM =
* T_THEAD =
* T_SPLTTAB =
* T_SPLTWT =
* T_MANDATE =
EXCEPTIONS
ERROR_MESSAGE = 1
.
IF SY-SUBRC = 0.
WA_MSG-SNO = LV_SLNO.
WA_MSG-MSGTYP = 'S'.
CLEAR: LV_BELNR.
GET PARAMETER ID 'BLP' FIELD LV_BELNR.
E_BELNR = LV_BELNR.
CONCATENATE 'Document' E_BELNR 'Parked successfully' INTO WA_MSG-TEXT.
APPEND WA_MSG TO IT_MSG.
CLEAR:WA_MSG.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
INTO LV_TEXT
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
wa_msg-sno = LV_SLNO.
wa_msg-msgtyp = SY-MSGTY.
wa_msg-text = LV_TEXT.
* WA_RETURN-TYPE = SY-MSGTY. "Message type: S Success, E Error, W Warning,
I Info, A Abort
* WA_RETURN-ID = SY-MSGID. "Message Class
* WA_RETURN-NUMBER = SY-MSGNO. "Message Number
* WA_RETURN-MESSAGE = LV_TEXT. "Message Text
* APPEND WA_RETURN TO ET_RETURN.
APPEND wa_msg to it_msg.
CLEAR wa_msg.
ENDIF.
ENDFORM.
FORM GET_DATA_SA_ITAB.
DATA: IT_BKPF TYPE TABLE OF BKPF,
WA_BKPF TYPE BKPF,
IT_BSEG TYPE TABLE OF BSEG,
WA_BSEG TYPE BSEG,
LV_CNT TYPE NUMC3,
LV_AKONT TYPE AKONT,
IT_BSEC TYPE TABLE OF BSEC,
IT_BSET TYPE TABLE OF BSET,
IT_BSEZ TYPE TABLE OF BSEZ,
IT_BKORM TYPE TABLE OF BKORM,
IT_THEAD TYPE TABLE OF THEAD,
IT_SPLTTAB TYPE TABLE OF ACSPLT,
IT_SPLTWT TYPE TABLE OF WITH_ITEMX,
IT_MANDATE TYPE TABLE OF SEPA_MANDATE,
LV_NEWKO TYPE NUMC10,
LV_HKONT TYPE SAKNR.
DATA : LV_BELNR TYPE VBKPF-BELNR,
LV_SLNO TYPE NUMC4,
FISCAL_YEAR TYPE BAPI0002_4-FISCAL_YEAR,
FISCAL_PERIOD TYPE BAPI0002_4-FISCAL_PERIOD,
E_BELNR TYPE CHAR10,
POSTING_DATE TYPE BAPI0002_4-POSTING_DATE,
LV_TEXT TYPE BAPI_MSG.
WA_BSEG-ZUONR = WA_ITAB-NEWKO.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-XUMSW = 'X'.
WA_BSEG-XHRES = 'X'.
WA_BSEG-XKRES = 'X'.
WA_BSEG-XOPVW = 'X'.
CLEAR:LV_AKONT,LV_NEWKO.
LV_NEWKO = WA_ITAB-NEWKO.
SELECT SINGLE AKONT INTO LV_AKONT FROM LFB1 WHERE LIFNR = LV_NEWKO AND B
UKRS = WA_ITAB-BUKRS.
WA_BSEG-SAKNR = LV_AKONT.
WA_BSEG-HKONT = LV_AKONT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-LIFNR. "wa_bseg-hkont
* wa_bseg-lifnr = wa_itab-newko.
WA_BSEG-ZFBDT = SY-DATUM.
ENDIF.
* IF WA_ITAB-NEWBS = '40'.
* WA_BSEG-KOART = 'S'.
* WA_BSEG-SHKZG = 'S'.
* WA_BSEG-GSBER = WA_ITAB-GSBER.
* WA_BSEG-PRCTR = WA_ITAB-PRCTR.
* WA_BSEG-MWSKZ = WA_ITAB-MWSKZ.
* WA_BSEG-DMBTR = WA_ITAB-WRBTR.
* WA_BSEG-WRBTR = WA_ITAB-WRBTR.
* WA_BSEG-PSWBT = WA_ITAB-WRBTR.
* WA_BSEG-PSWSL = WA_ITAB-WAERS.
** wa_bseg-zuonr = wa_itab-NEWKO.
* WA_BSEG-SGTXT = WA_ITAB-SGTXT.
* WA_BSEG-VORGN = 'RFBU'.
* WA_BSEG-KOSTL = WA_ITAB-KOSTL.
** wa_bseg-XUMSW = 'X'.
* WA_BSEG-XHRES = 'X'.
** wa_bseg-XKRES = 'X'.
** wa_bseg-XOPVW = 'X'.
** CLEAR:lv_hkont.
* CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
* EXPORTING
* INPUT = WA_ITAB-NEWKO
* IMPORTING
* OUTPUT = WA_BSEG-HKONT.
*
*
* LV_HKONT = WA_ITAB-NEWKO.
** SELECT SINGLE akont INTO lv_akont FROM lfb1 WHERE lifnr = wa_itab-NEWKO
AND bukrs = wa_itab-bukrs.
** wa_mseg-saknr = lv_akont.
** wa_bseg-hkont = lv_hkont.
** wa_mseg-lifnr = wa_itab-newko.
* WA_BSEG-ZFBDT = SY-DATUM.
* ENDIF.
APPEND WA_BSEG TO IT_BSEG.
ENDIF.
IF WA_ITAB-NEWBS = '01'.
WA_BSEG-BUKRS = WA_ITAB-BUKRS.
WA_BSEG-GJAHR = SY-DATUM+0(4).
WA_BSEG-BUZEI = LV_CNT.
WA_BSEG-BSCHL = WA_ITAB-NEWBS.
IF WA_ITAB-NEWBS = '01'.
WA_BSEG-KOART = 'D'.
WA_BSEG-SHKZG = 'S'.
WA_BSEG-GSBER = WA_ITAB-GSBER.
WA_BSEG-PRCTR = WA_ITAB-PRCTR.
WA_BSEG-MWSKZ = WA_ITAB-MWSKZ.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
WA_BSEG-ZUONR = WA_ITAB-NEWKO.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-XUMSW = 'X'.
WA_BSEG-XHRES = 'X'.
WA_BSEG-XKRES = 'X'.
WA_BSEG-XOPVW = 'X'.
CLEAR:LV_AKONT,LV_NEWKO.
LV_NEWKO = WA_ITAB-NEWKO.
SELECT SINGLE AKONT INTO LV_AKONT FROM knb1 WHERE kunnr = LV_NEWKO AND B
UKRS = WA_ITAB-BUKRS.
WA_BSEG-SAKNR = LV_AKONT.
WA_BSEG-HKONT = LV_AKONT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-kunnr. "wa_bseg-hkont
* wa_bseg-lifnr = wa_itab-newko.
WA_BSEG-ZFBDT = SY-DATUM.
ENDIF.
* IF WA_ITAB-NEWBS = '50'.
* WA_BSEG-KOART = 'S'.
* WA_BSEG-SHKZG = 'H'.
* WA_BSEG-GSBER = WA_ITAB-GSBER.
* WA_BSEG-PRCTR = WA_ITAB-PRCTR.
* WA_BSEG-MWSKZ = WA_ITAB-MWSKZ.
* WA_BSEG-DMBTR = WA_ITAB-WRBTR.
* WA_BSEG-WRBTR = WA_ITAB-WRBTR.
* WA_BSEG-PSWBT = WA_ITAB-WRBTR.
* WA_BSEG-PSWSL = WA_ITAB-WAERS.
* WA_BSEG-SGTXT = WA_ITAB-SGTXT.
* WA_BSEG-VORGN = 'RFBU'.
* WA_BSEG-KOSTL = WA_ITAB-KOSTL.
* WA_BSEG-XHRES = 'X'.
* CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
* EXPORTING
* INPUT = WA_ITAB-NEWKO
* IMPORTING
* OUTPUT = WA_BSEG-HKONT.
* WA_BSEG-ZFBDT = SY-DATUM.
* ENDIF.
APPEND WA_BSEG TO IT_BSEG.
ENDIF.
CLEAR:WA_ITAB,WA_BSEG.
ENDLOOP.
CALL FUNCTION 'PRELIMINARY_POSTING_FB01'
EXPORTING
TEXT_UPDATE = 'X'
* TEXT_ITEM_UPDATE = ' '
* I_UF05A =
I_XCMPL = 'X'
* FS006_FB01 =
I_TCODE = 'FB01'
* I_PARGB =
* I_TCODE_INT =
* IMPORTING
* XEPBBP =
TABLES
T_BKPF = IT_BKPF
T_BSEG = IT_BSEG
T_BSEC = IT_BSEC
T_BSET = IT_BSET
T_BSEZ = IT_BSEZ
* T_BKORM =
* T_THEAD =
* T_SPLTTAB =
* T_SPLTWT =
* T_MANDATE =
EXCEPTIONS
ERROR_MESSAGE = 1
.
IF SY-SUBRC = 0.
WA_MSG-SNO = LV_SLNO.
WA_MSG-MSGTYP = 'S'.
CLEAR: LV_BELNR.
GET PARAMETER ID 'BLP' FIELD LV_BELNR.
E_BELNR = LV_BELNR.
CONCATENATE 'Document' E_BELNR 'Parked successfully' INTO WA_MSG-TEXT.
APPEND WA_MSG TO IT_MSG.
CLEAR:WA_MSG.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
INTO LV_TEXT
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
wa_msg-sno = LV_SLNO.
wa_msg-msgtyp = SY-MSGTY.
wa_msg-text = LV_TEXT.
* WA_RETURN-TYPE = SY-MSGTY. "Message type: S Success, E Error, W Warning,
I Info, A Abort
* WA_RETURN-ID = SY-MSGID. "Message Class
* WA_RETURN-NUMBER = SY-MSGNO. "Message Number
* WA_RETURN-MESSAGE = LV_TEXT. "Message Text
* APPEND WA_RETURN TO ET_RETURN.
APPEND wa_msg to it_msg.
CLEAR wa_msg.
ENDIF.
ENDFORM.
FORM GET_DATA_AB_ITAB.
DATA: IT_BKPF TYPE TABLE OF BKPF,
WA_BKPF TYPE BKPF,
IT_BSEG TYPE TABLE OF BSEG,
WA_BSEG TYPE BSEG,
LV_CNT TYPE NUMC3,
LV_AKONT TYPE AKONT,
IT_BSEC TYPE TABLE OF BSEC,
IT_BSET TYPE TABLE OF BSET,
IT_BSEZ TYPE TABLE OF BSEZ,
IT_BKORM TYPE TABLE OF BKORM,
IT_THEAD TYPE TABLE OF THEAD,
IT_SPLTTAB TYPE TABLE OF ACSPLT,
IT_SPLTWT TYPE TABLE OF WITH_ITEMX,
IT_MANDATE TYPE TABLE OF SEPA_MANDATE,
LV_NEWKO TYPE NUMC10,
LV_HKONT TYPE SAKNR.
DATA : LV_BELNR TYPE VBKPF-BELNR,
LV_SLNO TYPE NUMC4,
FISCAL_YEAR TYPE BAPI0002_4-FISCAL_YEAR,
FISCAL_PERIOD TYPE BAPI0002_4-FISCAL_PERIOD,
E_BELNR TYPE CHAR10,
POSTING_DATE TYPE BAPI0002_4-POSTING_DATE,
LV_TEXT TYPE BAPI_MSG.
SORT IT_ITAB BY NEWBS.
CLEAR:LV_CNT.
REFRESH: IT_BKPF,IT_BSEG.
LOOP AT IT_ITAB INTO WA_ITAB.
LV_SLNO = WA_ITAB-SNO.
LV_CNT = LV_CNT + 1.
IF LV_CNT = 1.
WA_BKPF-BUKRS = WA_ITAB-BUKRS."SAFF
WA_BKPF-BLART = 'AB'."WA_ITAB-BLART.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BLDAT+6(4) WA_ITAB-BLDAT+3(2) WA_ITAB-BLDAT+0(2) INTO
POSTING_DATE.
WA_BKPF-BLDAT = POSTING_DATE." WA_ITAB-BLDAT.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
WA_BKPF-BUDAT = POSTING_DATE." WA_ITAB-BUDAT.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
FORM GET_DATA_DG_ITAB.
DATA: IT_BKPF TYPE TABLE OF BKPF,
WA_BKPF TYPE BKPF,
IT_BSEG TYPE TABLE OF BSEG,
WA_BSEG TYPE BSEG,
LV_CNT TYPE NUMC3,
LV_AKONT TYPE AKONT,
IT_BSEC TYPE TABLE OF BSEC,
IT_BSET TYPE TABLE OF BSET,
IT_BSEZ TYPE TABLE OF BSEZ,
IT_BKORM TYPE TABLE OF BKORM,
IT_THEAD TYPE TABLE OF THEAD,
IT_SPLTTAB TYPE TABLE OF ACSPLT,
IT_SPLTWT TYPE TABLE OF WITH_ITEMX,
IT_MANDATE TYPE TABLE OF SEPA_MANDATE,
LV_NEWKO TYPE NUMC10,
LV_HKONT TYPE SAKNR,
LV_BELNR TYPE VBKPF-BELNR,
LV_SLNO TYPE NUMC4,
E_BELNR TYPE BELNR_D,
FISCAL_YEAR TYPE BAPI0002_4-FISCAL_YEAR,
FISCAL_PERIOD TYPE BAPI0002_4-FISCAL_PERIOD,
POSTING_DATE TYPE BAPI0002_4-POSTING_DATE,
LV_TEXT TYPE BAPI_MSG.
WA_BKPF-GJAHR = FISCAL_YEAR.
WA_BKPF-MONAT = FISCAL_PERIOD.
WA_BKPF-BLART = 'DG'.
WA_BKPF-WWERT = SY-DATUM.
WA_BKPF-USNAM = SY-UNAME.
WA_BKPF-TCODE = 'FB01'.
WA_BKPF-XBLNR = WA_ITAB-XBLNR.
WA_BKPF-WAERS = WA_ITAB-WAERS.
WA_BKPF-GLVOR = 'RFBU'.
WA_BKPF-HWAER = 'INR'.
* WA_BKPF-XMWST = 'X'.
WA_BKPF-KUTY2 = 'M'.
APPEND WA_BKPF TO IT_BKPF.
CLEAR WA_BKPF.
ENDIF.
IF WA_ITAB-NEWBS = '11' OR WA_ITAB-NEWBS = '40'.
WA_BSEG-BUKRS = WA_ITAB-BUKRS.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
WA_BSEG-GJAHR = FISCAL_YEAR.
WA_BSEG-BUZEI = LV_CNT.
WA_BSEG-BSCHL = WA_ITAB-NEWBS.
IF WA_ITAB-NEWBS = '11'.
WA_BSEG-KOART = 'D'.
WA_BSEG-SHKZG = 'H'.
* WA_BSEG-GSBER = WA_ITAB-GSBER.
WA_BSEG-PRCTR = WA_ITAB-PRCTR.
WA_BSEG-MWSKZ = WA_ITAB-MWSKZ.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-ZUONR. "wa_
* WA_BSEG-ZUONR = WA_ITAB-NEWKO.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-XUMSW = 'X'.
WA_BSEG-XHRES = 'X'.
WA_BSEG-XKRES = 'X'.
WA_BSEG-XOPVW = 'X'.
CLEAR:LV_AKONT,LV_NEWKO.
LV_NEWKO = WA_ITAB-NEWKO.
SELECT SINGLE AKONT INTO LV_AKONT FROM knb1 WHERE kunnr = LV_NEWKO AND B
UKRS = WA_ITAB-BUKRS.
WA_BSEG-SAKNR = LV_AKONT.
WA_BSEG-HKONT = LV_AKONT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-kunnr. "wa_bseg-hkont
* wa_bseg-lifnr = wa_itab-newko.
WA_BSEG-ZFBDT = SY-DATUM.
ENDIF.
IF WA_ITAB-NEWBS = '40'.
WA_BSEG-KOART = 'S'.
WA_BSEG-SHKZG = 'S'.
WA_BSEG-GSBER = WA_ITAB-GSBER.
WA_BSEG-PRCTR = WA_ITAB-PRCTR.
WA_BSEG-MWSKZ = WA_ITAB-MWSKZ.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-KOSTL = WA_ITAB-KOSTL.
WA_BSEG-XHRES = 'X'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-HKONT.
WA_BSEG-ZFBDT = SY-DATUM.
ENDIF.
APPEND WA_BSEG TO IT_BSEG.
ENDIF.
CLEAR:WA_BSEG.
ENDLOOP.
WA_BKPF-GJAHR = FISCAL_YEAR.
WA_BKPF-MONAT = FISCAL_PERIOD.
WA_BKPF-BLART = 'DA'.
WA_BKPF-WWERT = SY-DATUM.
WA_BKPF-USNAM = SY-UNAME.
WA_BKPF-TCODE = 'FB01'.
WA_BKPF-XBLNR = WA_ITAB-XBLNR.
WA_BKPF-WAERS = WA_ITAB-WAERS.
WA_BKPF-GLVOR = 'RFBU'.
WA_BKPF-HWAER = 'INR'.
* WA_BKPF-XMWST = 'X'.
WA_BKPF-KUTY2 = 'M'.
APPEND WA_BKPF TO IT_BKPF.
CLEAR WA_BKPF.
ENDIF.
IF WA_ITAB-NEWBS = '04' OR WA_ITAB-NEWBS = '50' or WA_ITAB-NEWBS = '01' or W
A_ITAB-NEWBS = '11'.
WA_BSEG-BUKRS = WA_ITAB-BUKRS.
WA_BSEG-GJAHR = SY-DATUM+0(4).
WA_BSEG-BUZEI = LV_CNT.
WA_BSEG-BSCHL = WA_ITAB-NEWBS.
IF WA_ITAB-NEWBS = '04' or WA_ITAB-NEWBS = '01'.
WA_BSEG-KOART = 'D'.
WA_BSEG-SHKZG = 'S'.
WA_BSEG-GSBER = WA_ITAB-GSBER.
WA_BSEG-PRCTR = WA_ITAB-PRCTR.
WA_BSEG-MWSKZ = WA_ITAB-MWSKZ.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
WA_BSEG-ZUONR = WA_ITAB-NEWKO.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-XUMSW = 'X'.
WA_BSEG-XHRES = 'X'.
WA_BSEG-XKRES = 'X'.
WA_BSEG-XOPVW = 'X'.
CLEAR:LV_AKONT,LV_NEWKO.
LV_NEWKO = WA_ITAB-NEWKO.
SELECT SINGLE AKONT INTO LV_AKONT FROM knb1 WHERE kunnr = LV_NEWKO AND B
UKRS = WA_ITAB-BUKRS.
WA_BSEG-SAKNR = LV_AKONT.
WA_BSEG-HKONT = LV_AKONT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-kunnr. "wa_bseg-hkont
* wa_bseg-lifnr = wa_itab-newko.
WA_BSEG-ZFBDT = SY-DATUM.
ENDIF.
WA_BKPF-GJAHR = FISCAL_YEAR.
WA_BKPF-MONAT = FISCAL_PERIOD.
WA_BKPF-BLART = 'DZ'.
WA_BKPF-WWERT = SY-DATUM.
WA_BKPF-USNAM = SY-UNAME.
WA_BKPF-TCODE = 'FB01'.
WA_BKPF-XBLNR = WA_ITAB-XBLNR.
WA_BKPF-WAERS = WA_ITAB-WAERS.
WA_BKPF-GLVOR = 'RFBU'.
WA_BKPF-HWAER = 'INR'.
* WA_BKPF-XMWST = 'X'.
WA_BKPF-KUTY2 = 'M'.
APPEND WA_BKPF TO IT_BKPF.
CLEAR WA_BKPF.
ENDIF.
IF WA_ITAB-NEWBS = '40' OR WA_ITAB-NEWBS = '15'.
WA_BSEG-BUKRS = WA_ITAB-BUKRS.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
EXPORTING
COMPANYCODEID = 'SAFF'
POSTING_DATE = POSTING_DATE
IMPORTING
FISCAL_YEAR = FISCAL_YEAR
FISCAL_PERIOD = FISCAL_PERIOD
* RETURN =
.
WA_BSEG-GJAHR = FISCAL_YEAR.
WA_BSEG-BUZEI = LV_CNT.
WA_BSEG-BSCHL = WA_ITAB-NEWBS.
IF WA_ITAB-NEWBS = '40'.
WA_BSEG-KOART = 'S'.
WA_BSEG-SHKZG = 'S'.
WA_BSEG-GSBER = WA_ITAB-GSBER.
WA_BSEG-PRCTR = WA_ITAB-PRCTR.
WA_BSEG-MWSKZ = WA_ITAB-MWSKZ.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-KOSTL = WA_ITAB-KOSTL.
WA_BSEG-XHRES = 'X'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-HKONT.
WA_BSEG-ZFBDT = SY-DATUM.
ENDIF.
IF WA_ITAB-NEWBS = '15'.
WA_BSEG-KOART = 'D'.
WA_BSEG-SHKZG = 'H'.
* WA_BSEG-GSBER = WA_ITAB-GSBER.
WA_BSEG-PRCTR = WA_ITAB-PRCTR.
WA_BSEG-MWSKZ = WA_ITAB-MWSKZ.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
WA_BSEG-ZUONR = WA_ITAB-NEWKO.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-XUMSW = 'X'.
WA_BSEG-XHRES = 'X'.
WA_BSEG-XKRES = 'X'.
WA_BSEG-XOPVW = 'X'.
CLEAR:LV_AKONT,LV_NEWKO.
LV_NEWKO = WA_ITAB-NEWKO.
SELECT SINGLE AKONT INTO LV_AKONT FROM knb1 WHERE kunnr = LV_NEWKO AND B
UKRS = WA_ITAB-BUKRS.
WA_BSEG-SAKNR = LV_AKONT.
WA_BSEG-HKONT = LV_AKONT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-kunnr. "wa_bseg-hkont
* wa_bseg-lifnr = wa_itab-newko.
WA_BSEG-ZFBDT = SY-DATUM.
ENDIF.
APPEND WA_BSEG TO IT_BSEG.
ENDIF.
CLEAR:WA_BSEG.
ENDLOOP.
WA_BKPF-GJAHR = FISCAL_YEAR.
WA_BKPF-MONAT = FISCAL_PERIOD.
WA_BKPF-BLART = 'DR'.
WA_BKPF-WWERT = SY-DATUM.
WA_BKPF-USNAM = SY-UNAME.
WA_BKPF-TCODE = 'FB01'.
WA_BKPF-XBLNR = WA_ITAB-XBLNR.
WA_BKPF-WAERS = WA_ITAB-WAERS.
WA_BKPF-GLVOR = 'RFBU'.
WA_BKPF-HWAER = 'INR'.
* WA_BKPF-XMWST = 'X'.
WA_BKPF-KUTY2 = 'M'.
APPEND WA_BKPF TO IT_BKPF.
CLEAR WA_BKPF.
ENDIF.
IF WA_ITAB-NEWBS = '01' OR WA_ITAB-NEWBS = '50'.
WA_BSEG-BUKRS = WA_ITAB-BUKRS.
CLEAR:POSTING_DATE.
CONCATENATE WA_ITAB-BUDAT+6(4) WA_ITAB-BUDAT+3(2) WA_ITAB-BUDAT+0(2) INTO
POSTING_DATE.
CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
EXPORTING
COMPANYCODEID = 'SAFF'
POSTING_DATE = POSTING_DATE
IMPORTING
FISCAL_YEAR = FISCAL_YEAR
FISCAL_PERIOD = FISCAL_PERIOD
* RETURN =
.
WA_BSEG-GJAHR = FISCAL_YEAR.
WA_BSEG-BUZEI = LV_CNT.
WA_BSEG-BSCHL = WA_ITAB-NEWBS.
IF WA_ITAB-NEWBS = '01'.
WA_BSEG-KOART = 'D'.
WA_BSEG-SHKZG = 'S'.
WA_BSEG-GSBER = WA_ITAB-GSBER.
WA_BSEG-PRCTR = WA_ITAB-PRCTR.
WA_BSEG-MWSKZ = WA_ITAB-MWSKZ.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
WA_BSEG-ZUONR = WA_ITAB-NEWKO.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-ZUONR. "
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-XUMSW = 'X'.
WA_BSEG-XHRES = 'X'.
WA_BSEG-XKRES = 'X'.
WA_BSEG-XOPVW = 'X'.
CLEAR:LV_AKONT,LV_NEWKO.
LV_NEWKO = WA_ITAB-NEWKO.
SELECT SINGLE AKONT INTO LV_AKONT FROM knb1 WHERE kunnr = LV_NEWKO AND B
UKRS = WA_ITAB-BUKRS.
WA_BSEG-SAKNR = LV_AKONT.
WA_BSEG-HKONT = LV_AKONT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-kunnr. "wa_bseg-hkont
* wa_bseg-lifnr = wa_itab-newko.
WA_BSEG-ZFBDT = SY-DATUM.
ENDIF.
IF WA_ITAB-NEWBS = '50'.
WA_BSEG-KOART = 'S'.
WA_BSEG-SHKZG = 'H'.
WA_BSEG-GSBER = WA_ITAB-GSBER.
WA_BSEG-PRCTR = WA_ITAB-PRCTR.
WA_BSEG-MWSKZ = WA_ITAB-MWSKZ.
WA_BSEG-DMBTR = WA_ITAB-WRBTR.
WA_BSEG-WRBTR = WA_ITAB-WRBTR.
WA_BSEG-PSWBT = WA_ITAB-WRBTR.
WA_BSEG-PSWSL = WA_ITAB-WAERS.
WA_BSEG-SGTXT = WA_ITAB-SGTXT.
WA_BSEG-VORGN = 'RFBU'.
WA_BSEG-KOSTL = WA_ITAB-KOSTL.
WA_BSEG-XHRES = 'X'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ITAB-NEWKO
IMPORTING
OUTPUT = WA_BSEG-HKONT.
WA_BSEG-ZFBDT = SY-DATUM.
ENDIF.
APPEND WA_BSEG TO IT_BSEG.
ENDIF.
CLEAR:WA_BSEG.
ENDLOOP.