*&---------------------------------------------------------------------*
*& Report ZFIFB107
*& Description 薪酬计提批导开发
*&---------------------------------------------------------------------*
*& 开发人员 时间 更改类型 描述
*& CR信息
*&---------------------------------------------------------------------*
*& WuLiang 20140904 ECDK901469 FI-FI107-薪酬计提批导开发
*&---------------------------------------------------------------------* REPORT ZFIB107. TYPE-POOLS: SLIS. TABLES: SSCRFIELDS. DATA: T_FILE TYPE STRING,
T_PATH TYPE STRING,
T_FULLPATH TYPE STRING,
T_USER_ACTION TYPE I,
T_FILE_ENCODING TYPE ABAP_ENCOD. DATA: IT_FCODE TYPE TABLE OF SY-UCOMM,
FALG TYPE C,
SCREEN_VALUE TYPE SY-DYNNR VALUE '',
GS_OBJDATA LIKE WWWDATATAB. TYPES: BEGIN OF TY_OUTPUT_LINE,
KOSTL TYPE CSKS-KOSTL,
DMBTR1 TYPE BSEG-DMBTR,
DMBTR2 TYPE BSEG-DMBTR,
DMBTR3 TYPE BSEG-DMBTR,
DMBTR4 TYPE BSEG-DMBTR,
DMBTR5 TYPE BSEG-DMBTR,
DMBTR6 TYPE BSEG-DMBTR,
DMBTR7 TYPE BSEG-DMBTR,
DMBTR8 TYPE BSEG-DMBTR,
* dmbtr9 type bseg-dmbtr,
END OF TY_OUTPUT_LINE.
DATA: WA_OUTPUT_LINE TYPE TY_OUTPUT_LINE,
IT_OUTPUT_ITAB TYPE TABLE OF TY_OUTPUT_LINE WITH HEADER LINE,
IT_TOTAL_ITAB TYPE TABLE OF TY_OUTPUT_LINE WITH HEADER LINE. DATA: L_OREF TYPE REF TO CX_ROOT,
EXCEPTION_MSG(),
MSG(). DATA: UPLOAD_FALG TYPE C. DATA: G_EXCEL_ITAB TYPE ALSMEX_TABLINE OCCURS WITH HEADER LINE.
FIELD-SYMBOLS : <FS>.
DATA: G_INDEX TYPE I,
ERROR_TXT TYPE STRING,
ROW_INDEX TYPE STRING. DATA: DOCUMENTHEADER TYPE BAPIACHE09,
OBJ_TYPE TYPE BAPIACHE02-OBJ_TYPE,
OBJ_KEY TYPE BAPIACHE02-OBJ_KEY,
OBJ_SYS TYPE BAPIACHE02-OBJ_SYS,
ACCOUNTRECEIVABLE TYPE TABLE OF BAPIACAR09 WITH HEADER LINE,
ACCOUNTGL TYPE TABLE OF BAPIACGL09 WITH HEADER LINE,
CURRENCYAMOUNT TYPE TABLE OF BAPIACCR09 WITH HEADER LINE,
ACCOUNTPAYABLE TYPE TABLE OF BAPIACAP09 WITH HEADER LINE,
RETURN TYPE TABLE OF BAPIRET2 WITH HEADER LINE,
WA_RETURN TYPE BAPIRET2,
EXTENSION2 TYPE TABLE OF BAPIPAREX WITH HEADER LINE,
ZACC_DOCUMENT TYPE ZACC_DOCUMENT. SELECTION-SCREEN BEGIN OF SCREEN AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME,
P_BUKRS TYPE T001-BUKRS,
P_BLDAT TYPE BKPF-BLDAT,
P_BUDAT TYPE BKPF-BUDAT,
P_SAKNR TYPE SKB1-SAKNR.
PARAMETERS: P_R1 RADIOBUTTON GROUP G1 DEFAULT 'X',
P_R2 RADIOBUTTON GROUP G1.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN END OF SCREEN . SELECTION-SCREEN BEGIN OF SCREEN AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-T02.
PARAMETERS: P_DOWN LIKE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN END OF SCREEN . SELECTION-SCREEN: FUNCTION KEY ,
FUNCTION KEY . SELECTION-SCREEN: BEGIN OF TABBED BLOCK SUB FOR LINES,
END OF BLOCK SUB. INITIALIZATION.
SSCRFIELDS-FUNCTXT_01 = '执行批导'.
SSCRFIELDS-FUNCTXT_02 = '模板下载'.
SUB-PROG = SY-REPID.
SUB-DYNNR = . AT SELECTION-SCREEN.
IF SSCRFIELDS-UCOMM = 'FC02'.
SUB-DYNNR = .
ENDIF.
IF SSCRFIELDS-UCOMM = 'FC01'.
SUB-DYNNR = .
ENDIF.
PERFORM FRM_CHECK_DATA. AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM SUB_FRM_GET_FILEPATH. AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_DOWN.
PERFORM SUB_FRM_GET_DOWN. START-OF-SELECTION.
IF SUB-DYNNR EQ ''.
PERFORM FRM_GET_DATA.
IF IT_OUTPUT_ITAB[] IS INITIAL.
MESSAGE S888(SABAPDOCU) WITH '上载文件无数据' DISPLAY LIKE 'E'.
RETURN.
ENDIF.
IF NOT P_R1 IS INITIAL.
*创建类型为AB的会计凭证
PERFORM FRM_CREATE_JT_BELNR.
ELSE.
*创建类型为SK的会计凭证
PERFORM FRM_CREATE_FF_BELNR.
ENDIF.
*创建会计凭证信息输出
PERFORM FRM_OUTPUT_MESSAGE.
ELSE.
PERFORM FRM_DOWN_FILE.
ENDIF. *&---------------------------------------------------------------------*
*& Form SUB_FRM_GET_FILEPATH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SUB_FRM_GET_FILEPATH .
*上传文件F4帮助
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = P_FILE
DEF_PATH = 'C:\'
MASK = ',*.dat.'
MODE = 'O'
TITLE = 'Select Upload File'
IMPORTING
FILENAME = P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
ENDFORM. " SUB_FRM_GET_FILEPATH
*&---------------------------------------------------------------------*
*& Form SUB_FRM_GET_DOWN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SUB_FRM_GET_DOWN .
*模板下载位置选择
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
FILE_FILTER = '.XLS'
DEFAULT_EXTENSION = 'XLS'
DEFAULT_FILE_NAME = '薪酬计提批导开发导入模板'
INITIAL_DIRECTORY = 'C:\'
CHANGING
FILENAME = T_FILE
PATH = T_PATH
FULLPATH = T_FULLPATH
USER_ACTION = T_USER_ACTION
FILE_ENCODING = T_FILE_ENCODING
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
OTHERS = 3. P_DOWN = T_FULLPATH.
ENDFORM. " SUB_FRM_GET_DOWN
*&---------------------------------------------------------------------*
*& Form FRM_CHECK_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CHECK_DATA .
*根据功能选择不同,判断不同的字段是否必输
CASE SY-DYNNR.
WHEN ''.
CASE SSCRFIELDS-UCOMM.
WHEN 'F02'.
SUB-DYNNR = 200.
WHEN 'ONLI'.
IF SUB-DYNNR EQ '' AND P_FILE IS INITIAL.
SUB-DYNNR = 100.
MESSAGE '请输入上载文件' TYPE 'E'.
ENDIF. IF SUB-DYNNR EQ '' AND P_BUKRS IS INITIAL.
SUB-DYNNR = 100.
MESSAGE '请输入公司代码' TYPE 'E'.
ENDIF. IF SUB-DYNNR EQ '' AND P_BLDAT IS INITIAL.
SUB-DYNNR = 100.
MESSAGE '请输入凭证日期' TYPE 'E'.
ENDIF. IF SUB-DYNNR EQ '' AND P_BUDAT IS INITIAL.
SUB-DYNNR = 100.
MESSAGE '请输入过帐日期' TYPE 'E'.
ENDIF. IF SUB-DYNNR EQ '' AND P_SAKNR IS INITIAL AND NOT P_R2 IS INITIAL.
SUB-DYNNR = 100.
MESSAGE '请输入银行科目' TYPE 'E'.
ENDIF.
ENDCASE. WHEN ''.
CASE SSCRFIELDS-UCOMM.
WHEN 'F01'.
SUB-DYNNR = 100. WHEN 'ONLI'.
PERFORM FRM_CHECK_DOWN.
IF SUB-DYNNR EQ '' AND P_DOWN IS INITIAL.
SUB-DYNNR = 200.
MESSAGE '请输入下载目录' TYPE 'E'.
ENDIF.
ENDCASE.
ENDCASE.
ENDFORM. " FRM_CHECK_DATA
*&---------------------------------------------------------------------*
*& Form FRM_CHECK_DOWN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CHECK_DOWN .
*模板下载
DATA:L_OBJID TYPE WWWDATATAB-OBJID.
DATA: L_ERRTXT TYPE STRING. L_OBJID = 'ZFIB107'.
SELECT SINGLE RELID OBJID FROM WWWDATA INTO CORRESPONDING FIELDS OF GS_OBJDATA
WHERE SRTF2 = 0 AND RELID = 'MI' AND OBJID = L_OBJID.
IF SY-SUBRC NE 0 OR GS_OBJDATA-OBJID EQ SPACE.
CONCATENATE '模板文件' L_OBJID '不存在' INTO L_ERRTXT.
MESSAGE L_ERRTXT TYPE 'E'.
ENDIF.
ENDFORM. " FRM_CHECK_DOWN
*&---------------------------------------------------------------------*
*& Form FRM_DOWN_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_DOWN_FILE .
*模板下载
DATA:LS_DESTINATION LIKE RLGRAP-FILENAME.
DATA:L_RC LIKE SY-SUBRC,
L_ERRTXT TYPE STRING.
CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
EXPORTING
KEY = GS_OBJDATA
DESTINATION = P_DOWN
IMPORTING
RC = L_RC.
IF L_RC NE 0.
CONCATENATE '模板文件:' GS_OBJDATA-OBJID '下载失败' INTO L_ERRTXT.
MESSAGE L_ERRTXT TYPE 'E'.
ELSE.
MESSAGE '模板下载成功' TYPE 'S'.
ENDIF.
ENDFORM. " FRM_DOWN_FILE
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA .
*取得EXCEL数据
CLEAR: MSG, UPLOAD_FALG.
CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.
CONSTANTS: C_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
CLEAR MSG.
TRY.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 3
I_END_COL = 9
I_END_ROW = 65535
TABLES
INTERN = G_EXCEL_ITAB
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
LOOP AT G_EXCEL_ITAB.
MOVE: G_EXCEL_ITAB-COL TO G_INDEX.
ASSIGN COMPONENT G_INDEX OF STRUCTURE IT_OUTPUT_ITAB TO <FS>.
MOVE: G_EXCEL_ITAB-VALUE TO <FS>.
AT END OF ROW.
APPEND IT_OUTPUT_ITAB.
IF NOT P_R1 IS INITIAL.
CLEAR IT_OUTPUT_ITAB-KOSTL."Changed By LY 20150305
ENDIF.
COLLECT IT_OUTPUT_ITAB INTO IT_TOTAL_ITAB.
CLEAR IT_OUTPUT_ITAB.
ENDAT.
ENDLOOP.
CATCH CX_ROOT INTO L_OREF.
UPLOAD_FALG = 'X'.
MSG = L_OREF->GET_TEXT( ).
IF NOT MSG IS INITIAL.
WRITE:/ 'upladload file exception:', MSG.
ENDIF.
ENDTRY.
ENDFORM. " FRM_GET_DATA
*&---------------------------------------------------------------------*
*& Form FRM_CREATE_JT_BELNR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CREATE_JT_BELNR .
DATA: L_INDEX TYPE I,
L_DMBTR1 TYPE BSEG-DMBTR,
L_DMBTR2 TYPE BSEG-DMBTR,
L_DMBTR3 TYPE BSEG-DMBTR,
L_DMBTR4 TYPE BSEG-DMBTR. CLEAR L_INDEX. *调用BAPI生成类型为AB的会计凭证
DOCUMENTHEADER-DOC_TYPE = 'AB'.
DOCUMENTHEADER-DOC_DATE = P_BLDAT.
DOCUMENTHEADER-PSTNG_DATE = P_BUDAT.
DOCUMENTHEADER-FIS_PERIOD = P_BUDAT+4(2).
DOCUMENTHEADER-COMP_CODE = P_BUKRS.
DOCUMENTHEADER-USERNAME = SY-UNAME.
DOCUMENTHEADER-BUS_ACT = 'RFBU'.
DOCUMENTHEADER-HEADER_TXT = '珠宝工资分配'. SORT IT_OUTPUT_ITAB BY KOSTL. LOOP AT IT_OUTPUT_ITAB.
MOVE IT_OUTPUT_ITAB TO WA_OUTPUT_LINE.
AT NEW KOSTL.
CLEAR: L_DMBTR1, L_DMBTR2.
ENDAT. L_DMBTR1 = L_DMBTR1 + WA_OUTPUT_LINE-DMBTR1.
* l_dmbtr2 = l_dmbtr1 + wa_output_line-dmbtr9.
L_DMBTR2 = L_DMBTR2 + WA_OUTPUT_LINE-DMBTR2 + WA_OUTPUT_LINE-DMBTR3 + WA_OUTPUT_LINE-DMBTR4 + WA_OUTPUT_LINE-DMBTR5
+ WA_OUTPUT_LINE-DMBTR6 + WA_OUTPUT_LINE-DMBTR7 + WA_OUTPUT_LINE-DMBTR8. AT END OF KOSTL.
ADD 1 TO L_INDEX.
ACCOUNTGL-ITEMNO_ACC = L_INDEX.
IF WA_OUTPUT_LINE-KOSTL EQ 'C2I000012I'."Change By Ly 20150323
* IF wa_output_line-kostl EQ 'C202000006'.
ACCOUNTGL-GL_ACCOUNT = ''.
* ELSEif wa_output_line-kostl eq 'C202000005'.“DELETE BY LY 20150304
* accountgl-gl_account = ''.
ELSE.
ACCOUNTGL-GL_ACCOUNT = ''.
ENDIF.
ACCOUNTGL-COSTCENTER = WA_OUTPUT_LINE-KOSTL.
ACCOUNTGL-ITEM_TEXT = '珠宝工资分配'.
APPEND ACCOUNTGL.
CLEAR ACCOUNTGL. CURRENCYAMOUNT-ITEMNO_ACC = L_INDEX.
CURRENCYAMOUNT-AMT_DOCCUR = L_DMBTR1.
CURRENCYAMOUNT-CURRENCY = 'CNY'.
APPEND CURRENCYAMOUNT.
CLEAR CURRENCYAMOUNT. CLEAR: ZACC_DOCUMENT.
ZACC_DOCUMENT-POSNR = L_INDEX.
* zacc_document-bschl = ''.Changed By Ly 20150323
IF L_DMBTR1 < 0. "更改 shirumeng 20150506
ZACC_DOCUMENT-BSCHL = ''.
ZACC_DOCUMENT-XNEGP = 'X'.
ELSE.
ZACC_DOCUMENT-BSCHL = ''.
ENDIF.
EXTENSION2-STRUCTURE = 'ZACC_DOCUMENT'.
EXTENSION2-VALUEPART1 = ZACC_DOCUMENT.
APPEND EXTENSION2.
CLEAR EXTENSION2. ADD 1 TO L_INDEX.
ACCOUNTGL-ITEMNO_ACC = L_INDEX.
ACCOUNTGL-GL_ACCOUNT = ''. "更改 shiruemng 20150429
ACCOUNTGL-COSTCENTER = WA_OUTPUT_LINE-KOSTL.
ACCOUNTGL-ITEM_TEXT = '珠宝工资分配'.
APPEND ACCOUNTGL.
CLEAR ACCOUNTGL. CURRENCYAMOUNT-ITEMNO_ACC = L_INDEX.
CURRENCYAMOUNT-AMT_DOCCUR = L_DMBTR2.
CURRENCYAMOUNT-CURRENCY = 'CNY'.
APPEND CURRENCYAMOUNT.
CLEAR CURRENCYAMOUNT. CLEAR: ZACC_DOCUMENT.
ZACC_DOCUMENT-POSNR = L_INDEX.
* zacc_document-bschl = ''.
IF L_DMBTR2 < 0.
ZACC_DOCUMENT-BSCHL = ''.
ZACC_DOCUMENT-XNEGP = 'X'.
ELSE.
ZACC_DOCUMENT-BSCHL = ''.
ENDIF.
EXTENSION2-STRUCTURE = 'ZACC_DOCUMENT'.
EXTENSION2-VALUEPART1 = ZACC_DOCUMENT.
APPEND EXTENSION2.
CLEAR EXTENSION2. ADD 1 TO L_INDEX.
ACCOUNTGL-ITEMNO_ACC = L_INDEX.
ACCOUNTGL-GL_ACCOUNT = ''. "更改 shiruemng 20150429
ACCOUNTGL-COSTCENTER = WA_OUTPUT_LINE-KOSTL.
ACCOUNTGL-ITEM_TEXT = '珠宝工资分配'.
APPEND ACCOUNTGL.
CLEAR ACCOUNTGL. CURRENCYAMOUNT-ITEMNO_ACC = L_INDEX.
CURRENCYAMOUNT-AMT_DOCCUR = L_DMBTR1 * -1.
CURRENCYAMOUNT-CURRENCY = 'CNY'.
APPEND CURRENCYAMOUNT.
CLEAR CURRENCYAMOUNT. CLEAR: ZACC_DOCUMENT.
ZACC_DOCUMENT-POSNR = L_INDEX.
* 和 6601010000 效果相反。
IF L_DMBTR1 < 0.
ZACC_DOCUMENT-BSCHL = ''.
ZACC_DOCUMENT-XNEGP = 'X'.
ELSE.
ZACC_DOCUMENT-BSCHL = ''.
ENDIF.
" ZACC_DOCUMENT-BSCHL = ''.
EXTENSION2-STRUCTURE = 'ZACC_DOCUMENT'.
EXTENSION2-VALUEPART1 = ZACC_DOCUMENT.
APPEND EXTENSION2.
CLEAR EXTENSION2.
ENDAT.
ENDLOOP. READ TABLE IT_TOTAL_ITAB INDEX 1.
ADD 1 TO L_INDEX.
PERFORM FRM_FILL_ITEM USING L_INDEX '' IT_TOTAL_ITAB-DMBTR2.
ADD 1 TO L_INDEX.
PERFORM FRM_FILL_ITEM USING L_INDEX '' IT_TOTAL_ITAB-DMBTR3.
ADD 1 TO L_INDEX.
PERFORM FRM_FILL_ITEM USING L_INDEX '' IT_TOTAL_ITAB-DMBTR4.
ADD 1 TO L_INDEX.
PERFORM FRM_FILL_ITEM USING L_INDEX '' IT_TOTAL_ITAB-DMBTR5.
ADD 1 TO L_INDEX.
PERFORM FRM_FILL_ITEM USING L_INDEX '' IT_TOTAL_ITAB-DMBTR7.
ADD 1 TO L_INDEX.
PERFORM FRM_FILL_ITEM USING L_INDEX '' IT_TOTAL_ITAB-DMBTR8. "更改 shiruemng 20150429
ADD 1 TO L_INDEX.
PERFORM FRM_FILL_ITEM USING L_INDEX '' IT_TOTAL_ITAB-DMBTR6. CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = DOCUMENTHEADER
TABLES
ACCOUNTRECEIVABLE = ACCOUNTRECEIVABLE
ACCOUNTPAYABLE = ACCOUNTPAYABLE
ACCOUNTGL = ACCOUNTGL
CURRENCYAMOUNT = CURRENCYAMOUNT
EXTENSION2 = EXTENSION2
RETURN = RETURN.
ENDFORM. " FRM_CREATE_JT_BELNR
*&---------------------------------------------------------------------*
*& Form FRM_CREATE_FF_BELNR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CREATE_FF_BELNR .
DATA: L_INDEX TYPE I,
L_DMBTR1 TYPE BSEG-DMBTR,
L_DMBTR2 TYPE BSEG-DMBTR,
L_DMBTR3 TYPE BSEG-DMBTR,
L_DMBTR4 TYPE BSEG-DMBTR.
DATA:LV_DMBTR5 TYPE BSEG-DMBTR. CLEAR L_INDEX.
*调用BAPI生成类型为SK会计凭证
DOCUMENTHEADER-DOC_TYPE = 'SK'.
DOCUMENTHEADER-DOC_DATE = P_BLDAT.
DOCUMENTHEADER-PSTNG_DATE = P_BUDAT.
DOCUMENTHEADER-FIS_PERIOD = P_BUDAT+4(2).
DOCUMENTHEADER-COMP_CODE = P_BUKRS.
DOCUMENTHEADER-USERNAME = SY-UNAME.
DOCUMENTHEADER-BUS_ACT = 'RFBU'.
DOCUMENTHEADER-HEADER_TXT = '珠宝工资发放'. CHECK IT_TOTAL_ITAB[] IS NOT INITIAL. SORT IT_TOTAL_ITAB[] BY KOSTL.
LOOP AT IT_TOTAL_ITAB.
ADD 1 TO L_INDEX.
* read table it_total_itab index 1. ACCOUNTGL-ITEMNO_ACC = L_INDEX."1.
ACCOUNTGL-GL_ACCOUNT = ''. "更改 shiruemng 20150429
ACCOUNTGL-COSTCENTER = IT_TOTAL_ITAB-KOSTL.
ACCOUNTGL-ITEM_TEXT = '珠宝工资发放'.
APPEND ACCOUNTGL.
CLEAR ACCOUNTGL. CURRENCYAMOUNT-ITEMNO_ACC = L_INDEX."1.
CURRENCYAMOUNT-AMT_DOCCUR = IT_TOTAL_ITAB-DMBTR1 - IT_TOTAL_ITAB-DMBTR2 - IT_TOTAL_ITAB-DMBTR3 - IT_TOTAL_ITAB-DMBTR4
- IT_TOTAL_ITAB-DMBTR5 - IT_TOTAL_ITAB-DMBTR6 - IT_TOTAL_ITAB-DMBTR7 - IT_TOTAL_ITAB-DMBTR8.
CURRENCYAMOUNT-CURRENCY = 'CNY'.
APPEND CURRENCYAMOUNT. CLEAR: ZACC_DOCUMENT.
ZACC_DOCUMENT-POSNR = L_INDEX."1.
IF CURRENCYAMOUNT-AMT_DOCCUR < 0.
ZACC_DOCUMENT-BSCHL = ''.
ZACC_DOCUMENT-XNEGP = 'X'.
ELSE.
ZACC_DOCUMENT-BSCHL = ''.
ENDIF.
* zacc_document-bschl = ''.
ZACC_DOCUMENT-RSTGR = '-'.
EXTENSION2-STRUCTURE = 'ZACC_DOCUMENT'.
EXTENSION2-VALUEPART1 = ZACC_DOCUMENT.
APPEND EXTENSION2.
CLEAR EXTENSION2.
CLEAR CURRENCYAMOUNT. "20150506
* add 1 to l_index.
* accountgl-itemno_acc = l_index.
* accountgl-gl_account = p_saknr.
* accountgl-item_text = '珠宝工资发放'.
* append accountgl.
* clear accountgl.
*
* currencyamount-itemno_acc = l_index.
** currencyamount-amt_doccur = it_total_itab-dmbtr1 * -1.
* currencyamount-amt_doccur = ( it_total_itab-dmbtr1 - it_total_itab-dmbtr2 - it_total_itab-dmbtr3 - it_total_itab-dmbtr4
* - it_total_itab-dmbtr5 - it_total_itab-dmbtr6 - it_total_itab-dmbtr7 - it_total_itab-dmbtr8 ) * -1.
LV_DMBTR5 = IT_TOTAL_ITAB-DMBTR1 - IT_TOTAL_ITAB-DMBTR2 - IT_TOTAL_ITAB-DMBTR3 - IT_TOTAL_ITAB-DMBTR4
- IT_TOTAL_ITAB-DMBTR5 - IT_TOTAL_ITAB-DMBTR6 - IT_TOTAL_ITAB-DMBTR7 - IT_TOTAL_ITAB-DMBTR8 + LV_DMBTR5.
* currencyamount-currency = 'CNY'.
* append currencyamount.
* clear currencyamount.
*
* clear: zacc_document.
* zacc_document-posnr = l_index.
* zacc_document-bschl = ''.
* extension2-structure = 'ZACC_DOCUMENT'.
* extension2-valuepart1 = zacc_document.
* append extension2.
* clear extension2.
* clear it_total_itab.
ENDLOOP. "Changed by ly 20150311
ADD 1 TO L_INDEX.
ACCOUNTGL-ITEMNO_ACC = L_INDEX.
ACCOUNTGL-GL_ACCOUNT = P_SAKNR.
ACCOUNTGL-ITEM_TEXT = '珠宝工资发放'.
APPEND ACCOUNTGL.
CLEAR ACCOUNTGL. CURRENCYAMOUNT-ITEMNO_ACC = L_INDEX.
CURRENCYAMOUNT-AMT_DOCCUR = LV_DMBTR5 * -1.
* currencyamount-amt_doccur = ( it_total_itab-dmbtr1 - it_total_itab-dmbtr2 - it_total_itab-dmbtr3 - it_total_itab-dmbtr4
* - it_total_itab-dmbtr5 - it_total_itab-dmbtr6 - it_total_itab-dmbtr7 - it_total_itab-dmbtr8 ) * -1.
CURRENCYAMOUNT-CURRENCY = 'CNY'.
APPEND CURRENCYAMOUNT. CLEAR: ZACC_DOCUMENT.
ZACC_DOCUMENT-POSNR = L_INDEX.
IF LV_DMBTR5 < 0.
ZACC_DOCUMENT-BSCHL = ''.
" ZACC_DOCUMENT-XNEGP = 'X'.
ELSE.
ZACC_DOCUMENT-BSCHL = ''.
ENDIF.
" ZACC_DOCUMENT-BSCHL = ''.
EXTENSION2-STRUCTURE = 'ZACC_DOCUMENT'.
EXTENSION2-VALUEPART1 = ZACC_DOCUMENT.
APPEND EXTENSION2.
CLEAR EXTENSION2.
CLEAR IT_TOTAL_ITAB.
CLEAR CURRENCYAMOUNT. "20150506
"Changed by ly 20150311 CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = DOCUMENTHEADER
TABLES
ACCOUNTRECEIVABLE = ACCOUNTRECEIVABLE
ACCOUNTPAYABLE = ACCOUNTPAYABLE
ACCOUNTGL = ACCOUNTGL
CURRENCYAMOUNT = CURRENCYAMOUNT
EXTENSION2 = EXTENSION2
RETURN = RETURN.
ENDFORM. " FRM_CREATE_FF_BELNR
*&---------------------------------------------------------------------*
*& Form FRM_FILL_ITEM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_L_INDEX text
* -->P_1149 text
* -->P_IT_TOTAL_ITAB_DMBTR4 text
*----------------------------------------------------------------------*
FORM FRM_FILL_ITEM USING P_L_INDEX
VALUE(P_1149)
P_IT_TOTAL_ITAB_DMBTR4.
ACCOUNTGL-ITEMNO_ACC = P_L_INDEX.
ACCOUNTGL-GL_ACCOUNT = P_1149.
ACCOUNTGL-ITEM_TEXT = '珠宝工资分配'.
APPEND ACCOUNTGL.
CLEAR ACCOUNTGL. CURRENCYAMOUNT-ITEMNO_ACC = P_L_INDEX.
CURRENCYAMOUNT-AMT_DOCCUR = P_IT_TOTAL_ITAB_DMBTR4 * -1.
CURRENCYAMOUNT-CURRENCY = 'CNY'.
APPEND CURRENCYAMOUNT.
CLEAR CURRENCYAMOUNT. CLEAR: ZACC_DOCUMENT.
ZACC_DOCUMENT-POSNR = P_L_INDEX.
IF P_IT_TOTAL_ITAB_DMBTR4 < 0.
ZACC_DOCUMENT-BSCHL = ''.
ZACC_DOCUMENT-XNEGP = 'X'.
ELSE.
ZACC_DOCUMENT-BSCHL = ''.
ENDIF.
EXTENSION2-STRUCTURE = 'ZACC_DOCUMENT'.
EXTENSION2-VALUEPART1 = ZACC_DOCUMENT.
APPEND EXTENSION2.
CLEAR EXTENSION2.
ENDFORM. " FRM_FILL_ITEM
*&---------------------------------------------------------------------*
*& Form FRM_OUTPUT_MESSAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_OUTPUT_MESSAGE .
DATA:LT_MESSAGE TYPE FUCN_T_MESSAGE,
LS_MESSAGE TYPE FUCN_S_MESSAGE,
LV_SAVE_NECESSARY TYPE FUCN_REP_FLG VALUE ' '. LOOP AT RETURN.
CLEAR LS_MESSAGE.
LS_MESSAGE-MSGID = RETURN-ID .
LS_MESSAGE-MSGTY = RETURN-TYPE .
LS_MESSAGE-MSGNO = RETURN-NUMBER.
LS_MESSAGE-MSGV1 = RETURN-MESSAGE_V1.
LS_MESSAGE-MSGV2 = RETURN-MESSAGE_V2.
APPEND LS_MESSAGE TO LT_MESSAGE.
ENDLOOP. CALL FUNCTION 'FUCN_MESSAGE_POPUP'
EXPORTING
IT_MESSAGE = LT_MESSAGE
IF_SAVE_NECESSARY = LV_SAVE_NECESSARY. READ TABLE RETURN WITH KEY TYPE = 'S'.
IF SY-SUBRC EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
ENDFORM. " FRM_OUTPUT_MESSAGE

增强字段要配合另外一篇使用:

https://www.cnblogs.com/sapSB/p/6065914.html

会计凭证BAPI_ACC_DOCUMENT_POST的更多相关文章

  1. 使用BAPI_ACC_DOCUMENT_POST,创建会计凭证,用BADI扩展字段(转)

    业务需求:和银行做一个接口,要通过银行流水产生会计凭证,会计凭证的事务码是F-02,查到了BAPI方法BAPI_ACC_DOCUMENT_POST.昨天测试发现,有一些参数在BAPI_ACC_DOCU ...

  2. 用BAPI_ACC_DOCUMENT_POST过账生成凭证

    根据前台需要输入参数,在bapi里面传值,不同业务所需参数不同. dome1: "bapi结构赋值     LOOP AT lt_item INTO lw_item.       wa_do ...

  3. 【ABAP系列】SAP ABAP 资产类BAPI过账 BAPI_ACC_DOCUMENT_POST

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 资产类BAPI ...

  4. 【FICO系列】SAP 创建会计凭证(FB01)的BAPI

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[FICO系列]SAP 创建会计凭证(FB01) ...

  5. 关于BAPI_ACC_DOCUMENT_POST解读

    BAPI_ACC_DOCUMENT_POST是SAP ERP提供生成会计凭证的标准BAPI,这个BAPI可以用到多种场景生成会计凭证,实际项目中一般情况下更多的是生成应收和应付的会计凭证,分别对应客户 ...

  6. OpenERP中的会计凭证

    OpenERP在采购和销售过程中会自动生成一些会计凭证,这些会计凭证反映了物流和资金流在财务上的处理方式. 仓库入库时 借:库存商品 贷:在途物资 收到供应商发票时 借:在途物资 借:进项税额 贷:应 ...

  7. BAPI_ACC_DOCUMENT_POST Enter rate / GBP rate type M for Error SG105

    Folks, I was wondering if I could get a bit of help here as I've been racking my brains on it for ag ...

  8. SAP中方会计凭证打印解决方案

    中方会计凭证由于 编码格式 以及 科目对照关系 是无法直接使用SAP自带的凭证打印功能的,如下为客户开发的一个解决方案,供各位参考 1).需要定制几个Table的结构 zc0000fit0009[科目 ...

  9. RE合同记账会计凭证

    *&---------------------------------------------------------------------* *& Title : 不动产转租合同自 ...

随机推荐

  1. Python—RabbitMQ

    RabbitMQ RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统 安装 因为RabbitMQ由erlang实现,先安装erlang #安装配置epel源 rpm -ivh http ...

  2. centos7 shell脚本实现随机数

    questions: 1.随机数如何获得 2.如何确定随机值的大小是我们所需要的 answers: 1.目前可以通过获取系统时间的毫秒数来得到,毕竟毫秒数还是变化比较快的 可以看到这个速度还是变化很快 ...

  3. oracle 删除用户时的坑

    ORACLE在使用 SELECT SID,SERIAL# FROM V$SESSION WHERE USERNAME='dt_zntg_trade' 删除会话时,一定要注意dt_zntg_trade的 ...

  4. 菜鸟学Android编程——简单计算器《一》

    菜鸟瞎搞,高手莫进 本人菜鸟一枚,最近在学Android编程,网上看了一些视频教程,于是想着平时手机上的计算器应该很简单,自己何不尝试着做一个呢? 于是就冒冒失失的开撸了. 简单计算器嘛,功能当然很少 ...

  5. Oculus中OVRPlayerController飞行视角的制作

    最近项目上的事,忙的不可开交.忙里偷闲,记录下Oculus飞行视角的制作 师兄给我的要求是,带上Oculus,通过remote和头盔操作,可以完成飞行我的解决办法:1.消除重力的影响,如同在真空中,就 ...

  6. java模式-工厂模式

    今天在学习工厂模式,从最简单的简单工厂模式开始. 我们现在需要通过工厂Factory生产A,B两款产品(都是产品,实现了接口Product). 产品A: public class A implemen ...

  7. LeetCode——Letter Combinations of a Phone Number

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  8. Latex图片显示问题(1)

    用latex编译后,若用dvipdf生成pdf文件,则其中有个eps图的左侧会显示不完全:若是用dvips--pspdf生成pdf文件,图像显示没问题. 这种情况的问题出在,加载 graphicx 宏 ...

  9. 基于ubuntu 14搭建nginx+php+mysql环境

    基于最新的Ubuntu 14.04(2014年9月)搭建nginx.php.mysql环境, 以下全部命令行操作: 1 由于需要大量的权限操作,方便起见临时提升权限,使用root账号 sudo su ...

  10. python 04

    面向对象 __init__ 方法在类的一个对象被建立时, 马上运行. 这个方法可以用来对你的对象做一些你希望的初始化. python中所有的类成员(包括数据成员)都是公共的, 所有的方法都是有效的. ...