REPORT ZHR_GSCLJGJ1.
INCLUDE ZHR_GSCLJGJ_TOP1.
*INCLUDE ZHR_GSCLJGJ_TOP. "全局定义
INCLUDE ZHR_GSCLJGJ_SEL1.
*INCLUDE ZHR_GSCLJGJ_SEL. "选择屏幕
INCLUDE ZHR_GSCLJGJ_MAIN1.
*INCLUDE ZHR_GSCLJGJ_MAIN."主逻辑
INCLUDE ZHR_GSCLJGJ_FRM1.
*INCLUDE ZHR_GSCLJGJ_FRM. "子过程
*&---------------------------------------------------------------------*
*& 包含 ZHR_GSCLJGJ_TOP
*&---------------------------------------------------------------------*
NODES: PERNR.
INFOTYPES:0001,0002,0041,0531,0000,0185,0015,0003.
DATA: G_CURR_BEGDA TYPE DATUM. " 当月第一天
DATA: G_CURR_ENDDA TYPE DATUM. " 当月最后一天
DATA: G_LAST_BEGDA TYPE DATUM. " 上月第一天
DATA: G_LAST_ENDDA TYPE DATUM. " 上月最后一天
TYPES:BEGIN OF STR_PERNR,
PERNR TYPE PERNR-PERNR,
END OF STR_PERNR.
DATA:GT_PERNR TYPE STANDARD TABLE OF STR_PERNR,
GS_PERNR TYPE STR_PERNR.
TYPES:BEGIN OF GTY_ALV,
PERNR TYPE PERNR-PERNR, "工号
NAME TYPE P0182-ALNAM, "姓名
PERSG TYPE P0001-PERSG, "员工组
TAXGPT TYPE T7CN36T-TAXGPT, "最新纳税主体
TAXID TYPE P0531-TAXID, "最新证件号码
BYSFSX TYPE CHAR6, "本月是否算薪
SYSFSX TYPE CHAR6, "上月是否算薪
HDAT TYPE P0000-BEGDA, "入职日
REHDAT TYPE DATUM, "最近一次再入职日
TERMDAT TYPE DATUM, "最近一次离职日期
GZZLW TYPE DATUM, "最近一次工资薪资转劳务(同一纳税主体)日期
LWZGZ TYPE DATUM, "最近一次劳务转工资薪资(同一纳税主体)日期
LXLWZ TYPE DATUM, "最近一次连续劳务转非连续劳务(同一纳税主体)日期
FLXLWZ TYPE DATUM, "最近一次非连续劳务转连续劳务(同一纳税主体)日期
NSBGDAT TYPE DATUM, "最近一次纳税主体变更日期
ZJBGDAT TYPE DATUM, "最近一次证件编号变更日期
SRECLJ TYPE DATUM, "收入额重新累计日期 免税额起算日期
MSEQSR TYPE DATUM, "免税额起算日期
MSEZZR TYPE DATUM, "免税额终止日期
BEGDA TYPE T549Q-BEGDA, "薪资期间第一天
ENDDA TYPE T549Q-ENDDA, "薪资期间最后一天
BEGDA_N TYPE DATUM, "下个薪资周期开始日期
RESULT TYPE ICON_D, "导入结果
MESSAGE TYPE BAPI_MSG, "报错消息
END OF GTY_ALV.
DATA:GT_ALV TYPE GTY_ALV OCCURS 0,
GS_ALV TYPE GTY_ALV.
*更新0531 预存表
TYPES:BEGIN OF GTY_0531,
PERNR TYPE PERNR-PERNR, "工号
BEGDA TYPE P0531-BEGDA,
ENDDA TYPE P0531-ENDDA,
TXERD TYPE P0531-TXERD,
CURST TYPE P0531-CURST,
TXARE TYPE P0531-TXARE,
TAXGP TYPE P0531-TAXGP,
END OF GTY_0531.
DATA: GT_P0531 TYPE TABLE OF P0531,
GS_P0531 TYPE P0531.
DATA: GT_P0531_BDC TYPE TABLE OF GTY_0531,
GS_P0531_BDC TYPE GTY_0531.
DATA:GT_T549A TYPE T549A OCCURS 0 WITH HEADER LINE, "薪资发放范围
GT_T549Q TYPE T549Q OCCURS 0 WITH HEADER LINE. "工资发放期间
"ALV
DATA: GT_ALV_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA:G_COL_POS LIKE SY-CUCOL.
DATA: GT_RGDIR TYPE STANDARD TABLE OF PC261 WITH HEADER LINE.
* BDC
DATA: GT_BDC_DATA LIKE STANDARD TABLE OF BDCDATA WITH HEADER LINE.
DATA: GT_BDC_MSG TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE.
DATA: GV_BDC_MODE VALUE 'N'.
DATA: GT_RETURN TYPE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE.
*&---------------------------------------------------------------------*
*& 包含 ZHR_GSCLJGJ_SEL
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK block01 WITH FRAME TITLE text-b01.
PARAMETERS: p_mont TYPE isellist-month OBLIGATORY.
SELECTION-SCREEN END OF BLOCK block01.
*&---------------------------------------------------------------------*
*& 包含 ZHR_GSCLJGJ_MAIN
*&---------------------------------------------------------------------*
INITIALIZATION.
PERFORM FRM_INIT."初始化
AT SELECTION-SCREEN OUTPUT.
* PERFORM xxx. "屏幕输出控制
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MONT.
"月份搜索帮助
PERFORM FRM_MONTH_F4 CHANGING P_MONT.
AT SELECTION-SCREEN.
* PERFORM xxx."屏幕选择控制
START-OF-SELECTION.
PERFORM FRM_MONTH_LAST_DAY_PRO. "屏幕月份最后一天
PERFORM FRM_GET_CONFIGURATION. " 获取相关配置表
PERFORM FRM_SET_PNP_SEL_PERIOD. "设置逻辑数据库时间变量
GET PERNR.
PERFORM FRM_GET_PERNR."取满足条件的员工数据
END-OF-SELECTION.
IF SY-BATCH = 'X'.
PERFORM FRM_DATA_PROCESS .
ELSE.
PERFORM FRM_DISPALY."数据显示
ENDIF.
*&---------------------------------------------------------------------*
*& 包含 ZHR_GSCLJGJ_FRM
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form FRM_INIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_INIT .
CLEAR: GT_T549A[],
GT_T549A,
GT_T549Q[],
GT_T549Q,
GT_ALV[],
GT_ALV,
G_CURR_BEGDA,
G_CURR_ENDDA,
G_LAST_ENDDA,
GT_P0531[],
GT_P0531.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_MONTH_F4
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_P_MONT text
*----------------------------------------------------------------------*
FORM FRM_MONTH_F4 CHANGING EV_MONT.
CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
EXPORTING
ACTUAL_MONTH = SY-DATUM(6)
LANGUAGE = SY-LANGU
START_COLUMN = 8
START_ROW = 5
IMPORTING
SELECTED_MONTH = EV_MONT
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 1
HOLIDAY_CALENDAR_NOT_FOUND = 2
MONTH_NOT_FOUND = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_MONTH_LAST_DAY_PRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_MONTH_LAST_DAY_PRO .
CONCATENATE P_MONT '01' INTO G_CURR_BEGDA.
"屏幕月份最后一天
PERFORM FRM_LAST_DAY_OF_MONTH USING G_CURR_BEGDA
CHANGING G_CURR_ENDDA.
"上个月最后一天
G_LAST_ENDDA = G_CURR_BEGDA - 1.
"上月第一天
CONCATENATE G_LAST_ENDDA+0(6) '01' INTO G_LAST_BEGDA.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_LAST_DAY_OF_MONTH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_G_CURR_BEGDA text
* <--P_G_CURR_ENDDA text
*----------------------------------------------------------------------*
FORM FRM_LAST_DAY_OF_MONTH USING IV_BEGDA
CHANGING EV_ENDDA.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = IV_BEGDA
IMPORTING
LAST_DAY_OF_MONTH = EV_ENDDA.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SET_PNP_SEL_PERIOD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SET_PNP_SEL_PERIOD .
PN-BEGPS = G_CURR_BEGDA."当月第一天
PN-ENDPS = G_CURR_ENDDA."当月最后一天
"查询条件默认值:国家分组为‘28’人员
* "1. 人员预筛选:上月和当月都在职过的人
* CLEAR GT_PERNR[].
* SELECT PERNR INTO TABLE GT_PERNR
* FROM PA0000
* WHERE STAT2 = '3'
* AND BEGDA <= G_CURR_ENDDA
* AND ENDDA >= G_LAST_BEGDA
* AND PERNR IN PNPPERNR.
* SORT GT_PERNR ASCENDING BY PERNR.
* DELETE ADJACENT DUPLICATES FROM GT_PERNR.
*
* "2. 人员预筛选:上月和当月0015有值的人
* SELECT A~PERNR APPENDING CORRESPONDING FIELDS OF TABLE GT_PERNR
* FROM PA0000 AS A
* INNER JOIN PA0015 AS B
* ON A~PERNR = B~PERNR
* AND A~BEGDA <= B~BEGDA
* AND A~ENDDA >= B~ENDDA
* WHERE STAT2 = '0'
* AND A~PERNR IN PNPPERNR
* AND A~BEGDA <= G_CURR_ENDDA
* AND A~ENDDA >= G_LAST_BEGDA
* AND B~BEGDA <= G_CURR_ENDDA
* AND B~ENDDA >= G_LAST_BEGDA.
* SORT GT_PERNR ASCENDING BY PERNR.
* DELETE ADJACENT DUPLICATES FROM GT_PERNR.
*
* "构造逻辑数据库选择条件字段 PNPPERNR
* IF GT_PERNR[] IS NOT INITIAL.
* CLEAR PNPPERNR[].
* LOOP AT GT_PERNR INTO GS_PERNR.
* PNPPERNR-SIGN = 'I'.
* PNPPERNR-OPTION = 'EQ'.
* PNPPERNR-LOW = GS_PERNR-PERNR.
* APPEND PNPPERNR.
* ENDLOOP.
* ENDIF.
* CLEAR GT_PERNR[].
"国家分组为28的人
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_PERNR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_PERNR .
DATA:LV_BEGDA TYPE T549Q-BEGDA, "薪资期间第一天
LV_ENDDA TYPE T549Q-ENDDA, "薪资期间最后一天
LS_0531 TYPE P0531,
LV_TAXGP_LAST TYPE P0531-TAXGP,
LV_EETYP_LAST TYPE P0531-EETYP,
LV_EMTYP_LAST TYPE P0531-EMTYP,
LV_TAXID_LAST TYPE P0531-TAXID,
LV_DIFF TYPE C, "税组变更标识
LV_PERSG TYPE PERSG, "员工组
LS_P0002 TYPE P0002,
LS_P0001 TYPE P0001,
LS_P0000 TYPE P0000,
LS_P0185 TYPE P0185,
LS_P0531 TYPE P0531,
LV_CURST TYPE P0531-CURST.
DATA:LV_XZ_01F TYPE DATUM, "薪资期间第一天-1
LV_RHDAT TYPE DATUM. "最近一次再入职日-1
DATA:LV_LAST_SUBTY TYPE SUBTY,
LV_CURR_SUBTY TYPE SUBTY,
LV_LZRQ TYPE DATUM.
DATA:LS_LOG TYPE ZTGSCLJ_LOG.
DATA: LV_DIS TYPE C."为X的需要在alv显示
DATA: LV_LSHT TYPE DATUM. "最近一次入职日
DATA: LT_P0041 TYPE TABLE OF P0041,
LS_P0041 TYPE P0041,
LV_DATAR TYPE DATAR,
LV_DATE TYPE DATUM.
DATA : LO_MSGHD TYPE REF TO IF_HRPA_MESSAGE_HANDLER,
LV_MOLGA TYPE MOLGA.
CREATE OBJECT LO_MSGHD TYPE CL_HRPA_DUMMY_MESSAGE_HANDLER.
CLEAR LV_MOLGA.
"获取国家分组
CALL FUNCTION 'HR_ECM_GET_EE_MOLGA'
EXPORTING
PERNR = PERNR-PERNR
MESSAGE_HANDLER = LO_MSGHD
IMPORTING
MOLGA = LV_MOLGA.
CHECK LV_MOLGA = '28'.
"计算薪资周期
RP_PROVIDE_FROM_LAST P0001 SPACE G_CURR_ENDDA G_CURR_ENDDA ."当月最后一天
CLEAR: GT_T549A,
GT_T549Q.
READ TABLE GT_T549A WITH KEY ABKRS = P0001-ABKRS.
IF SY-SUBRC = 0.
READ TABLE GT_T549Q WITH KEY PERMO = GT_T549A-PERMO.
IF SY-SUBRC = 0.
LV_BEGDA = GT_T549Q-BEGDA.
LV_ENDDA = GT_T549Q-ENDDA.
ENDIF.
ENDIF.
"工号
GS_ALV-PERNR = PERNR-PERNR.
GS_ALV-BEGDA = LV_BEGDA. "薪资期间第一天
GS_ALV-ENDDA = LV_ENDDA. "薪资期间最后一天
GS_ALV-BEGDA_N = LV_ENDDA + 1."下个薪资周期第一天
"姓名
GS_ALV-NAME = P0001-ENAME.
"员工组
GS_ALV-PERSG = P0001-PERSG.
SORT P0531 BY BEGDA DESCENDING.
LOOP AT P0531 WHERE TAXGP <> '' AND BEGDA <= LV_ENDDA AND BEGDA >= LV_BEGDA.
"最新纳税主体
SELECT SINGLE TAXGPT
INTO GS_ALV-TAXGPT
FROM T7CN36T
WHERE TAXGP = P0531-TAXGP.
EXIT.
ENDLOOP.
LOOP AT P0531 WHERE TAXID <> ''AND BEGDA <= LV_ENDDA AND BEGDA >= LV_BEGDA.
"最新证件号码
GS_ALV-TAXID = P0531-TAXID.
EXIT.
ENDLOOP.
*上月是否算薪
LV_XZ_01F = LV_BEGDA - 1."薪资期间第一天 - 1
CLEAR:GT_RGDIR[],
GT_RGDIR.
"工资结果
CALL FUNCTION 'CU_READ_RGDIR_NEW'
EXPORTING
PERSNR = PERNR-PERNR
TABLES
IN_RGDIR = GT_RGDIR
EXCEPTIONS
NO_RECORD_FOUND = 1
IMPORT_MISMATCH_ERROR = 2
NO_READ_AUTHORITY = 3
INCONSISTENT_DATA = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
ENDIF.
*上月薪资结果
READ TABLE GT_RGDIR WITH KEY FPPER = LV_XZ_01F+0(6)
INPER = LV_XZ_01F+0(6).
IF SY-SUBRC = 0.
GS_ALV-SYSFSX = '是'.
ELSE.
GS_ALV-SYSFSX = '否'.
ENDIF.
RP_PROVIDE_FROM_LAST P0041 SPACE G_CURR_ENDDA G_CURR_ENDDA ."当月最后一天
*本月是否算薪
* READ TABLE GT_RGDIR WITH KEY FPPER = LV_BEGDA+0(6)
* INPER = LV_BEGDA+0(6).
* IF SY-SUBRC = 0.
* GS_ALV-BYSFSX = '是'.
* ELSE.
* GS_ALV-BYSFSX = '否'.
* ENDIF.
"离职日期
DO IF_HRPA_CONSTANTS=>GC_NUMBER_OF_DATE_TYPES_IT0041 TIMES
VARYING LV_DATAR FROM P0041-DAR01 NEXT P0041-DAR02
VARYING LV_DATE FROM P0041-DAT01 NEXT P0041-DAT02.
"离职日期
IF LV_DATAR = 'U6'.
LV_LZRQ = LV_DATE.
CLEAR LV_DATE.
EXIT.
ENDIF.
ENDDO.
IF LV_LZRQ IS NOT INITIAL AND LV_LZRQ <= G_CURR_BEGDA.
LOOP AT P0000 WHERE STAT2 = 0 AND BEGDA < G_CURR_BEGDA.
LOOP AT P0003 WHERE ABWD1 IS NOT INITIAL AND ABWD1 > G_CURR_ENDDA.
GS_ALV-BYSFSX = '是'.
EXIT.
ENDLOOP.
ENDLOOP.
ENDIF.
IF GS_ALV-BYSFSX IS INITIAL .
GS_ALV-BYSFSX = '否'.
ENDIF.
LT_P0041 = P0041[].
SORT LT_P0041 BY BEGDA .
READ TABLE LT_P0041 INTO LS_P0041 INDEX 1.
"入职日期
DO IF_HRPA_CONSTANTS=>GC_NUMBER_OF_DATE_TYPES_IT0041 TIMES
VARYING LV_DATAR FROM LS_P0041-DAR01 NEXT LS_P0041-DAR02
VARYING LV_DATE FROM LS_P0041-DAT01 NEXT LS_P0041-DAT02.
"入职日期
IF LV_DATAR = 'U3'.
GS_ALV-HDAT = LV_DATE.
CLEAR LV_DATE.
EXIT.
ENDIF.
ENDDO.
"最近一次再入职日
DO IF_HRPA_CONSTANTS=>GC_NUMBER_OF_DATE_TYPES_IT0041 TIMES
VARYING LV_DATAR FROM P0041-DAR01 NEXT P0041-DAR02
VARYING LV_DATE FROM P0041-DAT01 NEXT P0041-DAT02.
"最近一次再入职日
IF LV_DATAR = 'U3' AND LV_DATE <> GS_ALV-HDAT.
GS_ALV-REHDAT = LV_DATE.
CLEAR LV_DATE.
EXIT.
ENDIF.
ENDDO .
"最近一次离职日期
RP_PROVIDE_FROM_LAST P0041 SPACE G_CURR_ENDDA G_CURR_ENDDA ."当月最后一天
DO IF_HRPA_CONSTANTS=>GC_NUMBER_OF_DATE_TYPES_IT0041 TIMES
VARYING LV_DATAR FROM P0041-DAR01 NEXT P0041-DAR02
VARYING LV_DATE FROM P0041-DAT01 NEXT P0041-DAT02.
"最近一次离职日期
IF LV_DATAR = 'U6' .
GS_ALV-TERMDAT = LV_DATE.
CLEAR LV_DATE.
EXIT.
ENDIF.
ENDDO .
"最近一次入职日
IF GS_ALV-HDAT IS NOT INITIAL .
LV_LSHT = GS_ALV-HDAT.
ENDIF.
IF GS_ALV-REHDAT IS NOT INITIAL .
LV_LSHT = GS_ALV-REHDAT.
ENDIF.
"最近一次纳税主体变更日期
CLEAR LV_DIFF.
SORT P0531[] BY BEGDA .
LOOP AT P0531 WHERE BEGDA(6) <= P_MONT.
IF SY-TABIX > 1.
IF LV_TAXGP_LAST NE P0531-TAXGP."比较前一个税组和当前税组
"判断从最近一次入职日到当前薪资周期结束日期前
* IF P0531-BEGDA >= LV_LSHT AND P0531-BEGDA <= LV_ENDDA.
* LV_DIFF = 'X'.
* ENDIF.
* IF P0531-BEGDA <= LV_ENDDA.
GS_ALV-NSBGDAT = P0531-BEGDA(6) && '01'."最近一次纳税主体变更日期
* ENDIF.
ENDIF.
IF LV_EETYP_LAST = '4' AND LV_EMTYP_LAST = '1' AND P0531-EETYP = '4' AND P0531-EMTYP <> '1'.
* IF P0531-BEGDA <= LV_ENDDA.
GS_ALV-LXLWZ = P0531-BEGDA(6) && '01'."最近一次连续劳务转连续劳务(同一纳税主体)日期
* ENDIF.
ENDIF.
IF LV_EETYP_LAST = '4' AND LV_EMTYP_LAST <> '1' AND P0531-EETYP = '4' AND P0531-EMTYP = '1'.
* IF P0531-BEGDA <= LV_ENDDA.
GS_ALV-FLXLWZ = P0531-BEGDA(6) && '01'."最近一次非连续劳务转连续劳务(同一纳税主体)日期
* ENDIF.
ENDIF.
IF LV_TAXID_LAST NE P0531-TAXID.
* IF P0531-BEGDA <= LV_ENDDA.
GS_ALV-ZJBGDAT = P0531-BEGDA(6) && '01'. "最近一次证件编号变更日期
* ENDIF.
ENDIF.
ENDIF.
LV_TAXGP_LAST = P0531-TAXGP.
LV_EETYP_LAST = P0531-EETYP.
LV_EMTYP_LAST = P0531-EMTYP.
LV_TAXID_LAST = P0531-TAXID.
ENDLOOP.
"最近一次劳务转工资薪资(同一纳税主体)日期
"最近一次工资薪资转劳务(同一纳税主体)日期
LOOP AT P0001 INTO LS_P0001 WHERE BEGDA(6) =< P_MONT.
IF SY-TABIX > 1."从第二条开始
IF LV_PERSG <> 'B' AND LS_P0001-PERSG = 'B'.
GS_ALV-GZZLW = LS_P0001-BEGDA(6) && '01'."最近一次工资薪资转劳务(同一纳税主体)日期
ELSEIF LV_PERSG = 'B'AND LS_P0001-PERSG <> 'B'.
GS_ALV-LWZGZ = LS_P0001-BEGDA(6) && '01'."最近一次劳务转工资薪资(同一纳税主体)日期
ENDIF.
ENDIF.
LV_PERSG = LS_P0001-PERSG.
CLEAR LS_P0001.
ENDLOOP.
"收入额重累计日期
*1.最近一次再入职日”在当月且“上月是否算薪”=“否”
*2.最近一次离职日期”<当月第1天且“上月是否算薪”=否且“本月是否算薪”=是
*3.最近一次证件编号变更日期“在当月
*4.最近一次纳税主体变更日期“在当月
*5.最近一次工资薪金转劳务(同一纳税主体)日期”在当月
*6.最近一次劳务转工资薪金(同一纳税主体)日期” 在当月
*7.最近一次连续劳务转非连续劳务(同一纳税主体)日期”在当月
*8.最近一次非连续劳务转连续劳务 (同一纳税主体)日期”在当月
*上述判断条件序号越大优先级越高时,满足条件时此日期显示为当月第一天
IF GS_ALV-REHDAT(6) = P_MONT AND GS_ALV-SYSFSX = '否'.
GS_ALV-SRECLJ = G_CURR_BEGDA.
ELSE.
IF GS_ALV-TERMDAT < G_CURR_BEGDA AND GS_ALV-SYSFSX = '否' AND GS_ALV-BYSFSX = '是'.
GS_ALV-SRECLJ = G_CURR_BEGDA.
ELSE.
IF GS_ALV-ZJBGDAT(6) = P_MONT.
GS_ALV-SRECLJ = G_CURR_BEGDA.
ELSE.
IF GS_ALV-NSBGDAT(6) = P_MONT.
GS_ALV-SRECLJ = G_CURR_BEGDA.
ELSE.
IF GS_ALV-GZZLW(6) = P_MONT.
GS_ALV-SRECLJ = G_CURR_BEGDA.
ELSE.
IF GS_ALV-LWZGZ(6) = P_MONT.
GS_ALV-SRECLJ = G_CURR_BEGDA.
ELSE.
IF GS_ALV-LXLWZ(6) = P_MONT.
GS_ALV-SRECLJ = G_CURR_BEGDA.
ELSE.
IF GS_ALV-FLXLWZ(6) = P_MONT..
GS_ALV-SRECLJ = G_CURR_BEGDA.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
"免税额起算日期
*1.“入职日”在当月,取“入职日”
*2.有“最近一次再入职日”的话,找到其所在月的上个月是否有薪资结果,如没有则刷新,否则不刷新
*3.“最近一次纳税主体变更日期“>当前531记录中的纳税入职日期,取“最近一次纳税主体变更日期“
*4. “最近一次工资薪金转劳务(同一纳税主体)日期” >当前531记录中的纳税入职日期,取“最近一次工资薪金转劳务(同一纳税主体)日期”
*5.“最近一次劳务转工资薪金(同一纳税主体)日期” >当前531记录中的纳税入职日期,取“最近一次劳务转工资薪金(同一纳税主体)日期”
*6.“最近一次连续劳务转非连续劳务(同一纳税主体)日期” >当前531记录中的纳税入职日期,取“最近一次连续劳务转非连续劳务(同一纳税主体)日期”
*7. “最近一次非连续劳务转连续劳务 (同一纳税主体)日期” >当前531记录中的纳税入职日期,取“最近一次非连续劳务转连续劳务 (同一纳税主体)日期”
*8. “最近一次离职日期”<当月第1天,且“当月是否算薪“=是 且”上月是否算薪“=否,取“最近一次离职日期”
*满足上述任一条件,则显示为上述日期的当月1日
IF GS_ALV-HDAT(6) = P_MONT.
GS_ALV-MSEQSR = GS_ALV-HDAT(6) && '01'.
ELSE.
IF GS_ALV-REHDAT IS NOT INITIAL .
LV_RHDAT = GS_ALV-REHDAT - 1.
READ TABLE GT_RGDIR WITH KEY FPPER = LV_RHDAT+0(6)
INPER = LV_RHDAT+0(6).
IF SY-SUBRC = 0.
GS_ALV-MSEQSR = GS_ALV-REHDAT(6) && '01'.
ENDIF.
ELSE.
"取当前531记录中的纳税入职日期
LOOP AT P0531 WHERE BEGDA <= G_CURR_ENDDA AND BEGDA >= G_CURR_BEGDA.
EXIT.
ENDLOOP.
"3.“最近一次纳税主体变更日期“>当前531记录中的纳税入职日期,取“最近一次纳税主体变更日期“
IF GS_ALV-NSBGDAT IS NOT INITIAL AND P0531-TXERD IS NOT INITIAL AND GS_ALV-NSBGDAT > P0531-TXERD.
GS_ALV-MSEQSR = GS_ALV-NSBGDAT(6) && '01'.
ELSE.
"4. “最近一次工资薪金转劳务(同一纳税主体)日期” >当前531记录中的纳税入职日期,取“最近一次工资薪金转劳务(同一纳税主体)日期”
IF GS_ALV-GZZLW IS NOT INITIAL AND P0531-TXERD IS NOT INITIAL AND GS_ALV-GZZLW > P0531-TXERD.
GS_ALV-MSEQSR = GS_ALV-GZZLW(6) && '01'.
ELSE.
"5.“最近一次劳务转工资薪金(同一纳税主体)日期” >当前531记录中的纳税入职日期,取“最近一次劳务转工资薪金(同一纳税主体)日期”
IF GS_ALV-LWZGZ IS NOT INITIAL AND P0531-TXERD IS NOT INITIAL AND GS_ALV-LWZGZ > P0531-TXERD.
GS_ALV-MSEQSR = GS_ALV-LWZGZ(6) && '01'.
ELSE.
"6.“最近一次连续劳务转非连续劳务(同一纳税主体)日期” >当前531记录中的纳税入职日期,取“最近一次连续劳务转非连续劳务(同一纳税主体)日期”
IF GS_ALV-LXLWZ IS NOT INITIAL AND P0531-TXERD IS NOT INITIAL AND GS_ALV-LXLWZ > P0531-TXERD.
GS_ALV-MSEQSR = GS_ALV-LXLWZ(6) && '01'.
ELSE.
"7. “最近一次非连续劳务转连续劳务 (同一纳税主体)日期” >当前531记录中的纳税入职日期,取“最近一次非连续劳务转连续劳务 (同一纳税主体)日期”
IF GS_ALV-FLXLWZ IS NOT INITIAL AND P0531-TXERD IS NOT INITIAL AND GS_ALV-FLXLWZ > P0531-TXERD.
GS_ALV-MSEQSR = GS_ALV-FLXLWZ(6) && '01'.
ELSE.
"8. “最近一次离职日期”<当月第1天,且“当月是否算薪“=是 且”上月是否算薪“=否,取“最近一次离职日期”
IF GS_ALV-TERMDAT IS NOT INITIAL AND GS_ALV-TERMDAT < G_CURR_BEGDA AND GS_ALV-BYSFSX = '是' AND GS_ALV-SYSFSX = '否'.
GS_ALV-MSEQSR = GS_ALV-TERMDAT(6) && '01' .
* ELSE.
* "不满足上述任一条件,则显示为IT0041-U3
* GS_ALV-MSEQSR = GS_ALV-HDAT .
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
"免税额终止日期
*1.“最近一次离职日期“在当月
*2. “最近一次离职日期”<当月第1天,且“当月是否算薪“=是
*满足上述任一条件,则显示为IT0041-U6
IF GS_ALV-TERMDAT(6) = P_MONT OR ( GS_ALV-TERMDAT < G_CURR_BEGDA AND GS_ALV-BYSFSX = '是' AND GS_ALV-TERMDAT IS NOT INITIAL ).
GS_ALV-MSEZZR = GS_ALV-TERMDAT.
ENDIF.
*1.若收入额重新累计日期存在,取收入额重新累计日期当天的0531数据。
* 判断P0531-CURST不等于’X’且收入额重新累计日期大于等于当前薪资周期开始日或P0531-TXERD<>免税额重新累计日期,则该条数据放入最后输出显示结果。
*并将P0531中所有与收入额重新累计日期和当前薪资周期结束日有交集的数据加入0531预取数据。
IF GS_ALV-SRECLJ IS NOT INITIAL.
RP_PROVIDE_FROM_LAST P0531 SPACE GS_ALV-SRECLJ GS_ALV-SRECLJ.
IF ( P0531-CURST NE 'X' AND GS_ALV-SRECLJ >= LV_BEGDA ) OR P0531-TXERD <> GS_ALV-MSEQSR.
LV_DIS = 'X'.
CLEAR LS_P0531.
LOOP AT P0531 INTO LS_P0531 WHERE BEGDA <= LV_ENDDA
AND ENDDA >= GS_ALV-SRECLJ.
APPEND LS_P0531 TO GT_P0531.
CLEAR LS_P0531.
ENDLOOP.
ENDIF.
ELSE.
*2. 若收入额重新累计日期不存在,且免税额重新累计日期存在。
IF GS_ALV-MSEQSR IS NOT INITIAL.
* 当免税额重新累计日期早于当前薪资周期开始日时,读取P0531中所有与当前薪资周期有交集的数据,若存在P0531-TXERD<>免税额重新累计日期或P0531-CURST=‘X’,
* 则该条数据放入最后输出显示结果,且将所有满足条件的P0531数据加入0531预取数据
IF GS_ALV-MSEQSR < LV_BEGDA.
CLEAR LS_P0531.
LOOP AT P0531 INTO LS_P0531 WHERE ENDDA >= LV_BEGDA
AND BEGDA <= LV_ENDDA.
IF P0531-TXERD <> GS_ALV-MSEQSR OR P0531-CURST = 'X'.
LV_DIS = 'X'.
APPEND LS_P0531 TO GT_P0531.
EXIT.
ENDIF.
CLEAR LS_P0531.
ENDLOOP.
ELSE.
* 当免税额重新累计日期大于等于当前薪资周期开始日时,读取P0531中所有与免税额重新累计日期和当前薪资周期结束日有交集的数据,若存在P0531-TXERD<>免税额重新累计日期或P0531-CURST=‘X’,
* 则该条数据放入最后输出显示结果,且将所有满足条件的P0531数据加入0531预取数据。
CLEAR LS_P0531.
LOOP AT P0531 INTO LS_P0531 WHERE ENDDA >= GS_ALV-MSEQSR
AND BEGDA <= LV_ENDDA.
IF P0531-TXERD <> GS_ALV-MSEQSR OR P0531-CURST = 'X'.
LV_DIS = 'X'.
EXIT.
APPEND LS_P0531 TO GT_P0531.
ENDIF.
CLEAR LS_P0531.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
SELECT SINGLE *
FROM ZTGSCLJ_LOG
INTO LS_LOG
WHERE PERNR = GS_ALV-PERNR AND MSEQSR = GS_ALV-MSEQSR AND MSEZZR = GS_ALV-MSEZZR AND ZSTATUS = '成功'.
* IF LV_DIS = 'X' AND SY-SUBRC <> 0 .
IF SY-SUBRC <> 0 .
APPEND GS_ALV TO GT_ALV.
APPEND LINES OF P0531[] TO GT_P0531.
ENDIF.
CLEAR GS_ALV.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_DISPALY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_DISPALY .
CLEAR:G_COL_POS ,
GT_ALV_FIELDCAT[],
GT_ALV_FIELDCAT.
PERFORM FRM_SET_FIELDCAT USING: 'PERNR' '工号',
'NAME' '姓名',
'PERSG' '员工组',
'TAXGPT' '最新纳税主体',
'TAXID' '最新证件号码',
'SYSFSX' '上月是否算薪',
'BYSFSX' '已离职当月是否算薪',
'HDAT' '入职日',
'REHDAT ' '最近一次再入职日',
'TERMDAT' '最近一次离职日期',
'GZZLW' '最近一次工资薪资转劳务(同一纳税主体)日期',
'LWZGZ' '最近一次劳务转工资薪资(同一纳税主体)日期',
'LXLWZ' '最近一次连续劳务转非连续劳务(同一纳税主体)日期',
'FLXLWZ' '最近一次非连续劳务转连续劳务(同一纳税主体)日期' ,
'NSBGDAT' '最近一次纳税主体变更日期',
'ZJBGDAT' '最近一次证件编号变更日期',
'SRECLJ' '收入额重新累计日期',
'MSEQSR' '免税额起算日期',
* 'MSEQSR' '免税额重累计日期',
'MSEZZR' '免税额终止日期',
'RESULT' '状态',
'MESSAGE' '报错消息'.
GS_LAYOUT-ZEBRA = 'X'.
GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PF_STATUS_SET = 'FRM_STATUS_SET'
I_CALLBACK_USER_COMMAND = 'FRM_USER_COMMAND'
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = GT_ALV_FIELDCAT
IS_LAYOUT = GS_LAYOUT
I_SAVE = 'A'
TABLES
T_OUTTAB = GT_ALV
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SET_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_1 text
* -->P_0097 text
* -->P_0098 text
*----------------------------------------------------------------------*
FORM FRM_SET_FIELDCAT USING IV_FIELDNAME
IV_SELTEXT_L.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
G_COL_POS = G_COL_POS + 1.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-COL_POS = :G_COL_POS .
LS_FIELDCAT-FIELDNAME = IV_FIELDNAME.
LS_FIELDCAT-SELTEXT_L = IV_SELTEXT_L.
LS_FIELDCAT-DDICTXT = IV_SELTEXT_L.
APPEND LS_FIELDCAT TO GT_ALV_FIELDCAT.
ENDFORM.
*&---------------------------------------------------------------------*
*& form frm_status_set
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->extab text
*----------------------------------------------------------------------*
FORM FRM_STATUS_SET USING IT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD' EXCLUDING IT_EXTAB.
ENDFORM. "FRM_STATUS_SET
*&---------------------------------------------------------------------*
*& form frm_user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->r_ucomm text
* -->rs_selfield text
*----------------------------------------------------------------------*
FORM FRM_USER_COMMAND USING IV_UCOMM LIKE SY-UCOMM
IV_RS_SELFIELD TYPE SLIS_SELFIELD.
CASE IV_UCOMM.
WHEN 'EXET'.
PERFORM FRM_DATA_PROCESS.
ENDCASE.
IV_RS_SELFIELD-REFRESH = 'X'.
ENDFORM. "FRM_USER_COMMAND
*&---------------------------------------------------------------------*
*& Form FRM_GET_CONFIGURATION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_CONFIGURATION .
"薪资发放范围
SELECT * FROM T549A INTO TABLE GT_T549A.
"工资发放期间
SELECT * FROM T549Q INTO TABLE GT_T549Q
WHERE PABRJ = P_MONT+0(4)
AND PABRP = P_MONT+4(2).
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATE_OF_DATE_TYPE_SYS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->iv_0041 TYPE p0041
* --> iv_datar TYPE datar
* <--ev_date TYPE datum
*----------------------------------------------------------------------*
FORM FRM_GET_DATE_OF_DATE_TYPE_SYS USING IV_0041 TYPE P0041
IV_DATAR TYPE DATAR
CHANGING EV_DATE TYPE DATUM.
DATA: LV_DAR TYPE PA0041-DAR01,
LV_DAT TYPE PA0041-DAT01.
CLEAR: LV_DAR,
LV_DAT.
IF IV_0041 IS INITIAL.
EXIT.
ENDIF.
DO 12 TIMES VARYING LV_DAR FROM IV_0041-DAR01 NEXT IV_0041-DAR02
VARYING LV_DAT FROM IV_0041-DAT01 NEXT IV_0041-DAT02.
CASE LV_DAR.
WHEN IV_DATAR.
EV_DATE = LV_DAT.
EXIT.
ENDCASE.
ENDDO.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_NATIO_OF_CODE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_P0002 text
* <--P_LV_LAST_NATIO text
*----------------------------------------------------------------------*
FORM FRM_GET_NATIO_OF_CODE USING IV_P0002 TYPE P0002
CHANGING EV_SUBTY.
*主要证件类型确定逻辑如下:
*CN->取证件类型为01的居民身份证
*HK/MO->取证件类型为07的港澳居民来往内地通行证
*TW ->取证件类型为08的台湾居民来往大陆通行证
*其他->取证件类型为02的护照证件
CASE IV_P0002-NATIO.
WHEN 'CN'.
EV_SUBTY = '01'.
WHEN 'HK' OR 'MO'.
EV_SUBTY = '07'.
WHEN 'TW'.
EV_SUBTY = '08'.
WHEN OTHERS.
EV_SUBTY = '02'.
ENDCASE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_DATA_PROCESS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_DATA_PROCESS .
DATA: LS_RETURN TYPE BAPIRETURN1,
LV_BDC_MSG_STRING TYPE STRING,
LV_FDDT TYPE DATUM,
LS_P0531 TYPE P0531,
LT_P0531 TYPE TABLE OF P0531,
LT_LOG TYPE TABLE OF ZTGSCLJ_LOG,
LS_LOG TYPE ZTGSCLJ_LOG.
SORT GT_P0531 BY PERNR BEGDA ASCENDING.
LOOP AT GT_ALV INTO GS_ALV.
CLEAR LT_P0531.
IF GS_ALV-SRECLJ IS INITIAL."收入额重新累计日期不存在
"分段日期:取免税额重累计日期和薪资周期开始日两者中晚的日期。
IF GS_ALV-MSEQSR >= GS_ALV-BEGDA.
LV_FDDT = GS_ALV-MSEQSR.
ELSE.
LV_FDDT = GS_ALV-BEGDA.
ENDIF.
"取0531中与分段日期和当前薪资结束日有交集所有数据
LOOP AT GT_P0531 INTO LS_P0531 WHERE PERNR = GS_ALV-PERNR
AND BEGDA <= GS_ALV-ENDDA
AND ENDDA >= LV_FDDT.
"若P0531-BEGDA早于分段日期,则更新P0531-BEGDA为分段日期
IF LS_P0531-BEGDA < LV_FDDT.
LS_P0531-BEGDA = LV_FDDT.
ENDIF.
"若P0531-TXERD不等于免税额重累计日期或收入额重累计标识不等于空。
"则更新P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’’。
CHECK LS_P0531-TXERD <> GS_ALV-MSEQSR OR LS_P0531-CURST <> ''.
IF GS_ALV-MSEQSR IS INITIAL .
PERFORM FRM_COLLECT_0531_DATA TABLES LT_P0531
USING LS_P0531 LS_P0531-BEGDA LS_P0531-TXERD GS_ALV-MSEZZR ''.
ELSE.
PERFORM FRM_COLLECT_0531_DATA TABLES LT_P0531
USING LS_P0531 LS_P0531-BEGDA GS_ALV-MSEQSR GS_ALV-MSEZZR ''.
ENDIF.
ENDLOOP.
ELSE."收入额重累计日期存在
"新增P0531-BEGDA=下个薪资周期开始日,P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’’。
LOOP AT GT_P0531 INTO LS_P0531 WHERE PERNR = GS_ALV-PERNR
AND BEGDA <= GS_ALV-BEGDA_N
AND ENDDA >= GS_ALV-BEGDA_N.
EXIT.
ENDLOOP.
PERFORM FRM_COLLECT_0531_DATA TABLES LT_P0531
USING LS_P0531 GS_ALV-BEGDA_N GS_ALV-MSEQSR GS_ALV-MSEZZR ''.
********************免税额重累计日期在薪资周期前
IF GS_ALV-MSEQSR < GS_ALV-BEGDA.
"取0531中与当前薪资周期有交集的所有数据
LOOP AT GT_P0531 INTO LS_P0531 WHERE PERNR = GS_ALV-PERNR
AND BEGDA <= GS_ALV-ENDDA
AND ENDDA >= GS_ALV-BEGDA.
"若P0531-BEGDA早于薪资周期开始日期,则更新P0531-BEGDA=薪资周期开始日。
IF LS_P0531-BEGDA < GS_ALV-BEGDA.
LS_P0531-BEGDA = GS_ALV-BEGDA.
ENDIF.
"若P0531-ENDDA早于收入额重累计日期,且P0531-TXERD不等于免税额重累计日期或收入额重累计标识不等于空,
"则更新P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’’
IF LS_P0531-ENDDA < GS_ALV-SRECLJ.
CHECK LS_P0531-TXERD <> GS_ALV-MSEQSR OR LS_P0531-CURST <> ''.
PERFORM FRM_COLLECT_0531_DATA TABLES LT_P0531
USING LS_P0531 LS_P0531-BEGDA GS_ALV-MSEQSR GS_ALV-MSEZZR ''.
"若收入额重累计日期在P0531-BEGDA和P0531-ENDDA之间,且P0531-TXERD不等于免税额重累计日期或收入额重累计标识不等于‘X’,
"则更新P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’’
ELSEIF GS_ALV-SRECLJ BETWEEN LS_P0531-BEGDA AND LS_P0531-ENDDA.
PERFORM FRM_COLLECT_0531_DATA TABLES LT_P0531
USING LS_P0531 LS_P0531-BEGDA GS_ALV-MSEQSR GS_ALV-MSEZZR ''.
"同时新增P0531-BEGDA=收入额重累计日期,P0531-TXERD=免税额重新累计日期,入额累计标识P0531-CURST=’X’
PERFORM FRM_COLLECT_0531_DATA TABLES LT_P0531
USING LS_P0531 GS_ALV-SRECLJ GS_ALV-MSEQSR GS_ALV-MSEZZR 'X'.
"若P0531-BEGDA晚于收入额重累计日期,且P0531-TXERD不等于免税额重累计日期或收入额重累计标识不等于’X’,
"则更新P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’X’
ELSEIF LS_P0531-BEGDA > GS_ALV-SRECLJ.
CHECK LS_P0531-TXERD <> GS_ALV-MSEQSR OR LS_P0531-CURST <> 'X'.
PERFORM FRM_COLLECT_0531_DATA TABLES LT_P0531
USING LS_P0531 LS_P0531-BEGDA GS_ALV-MSEQSR GS_ALV-MSEZZR 'X'.
ENDIF.
ENDLOOP.
"免税额重累计日期在薪资周期之间
"取0531中与收入额重累计日期和薪资周期结束日有交集的所有数据
ELSEIF GS_ALV-MSEQSR BETWEEN GS_ALV-BEGDA AND GS_ALV-ENDDA.
LOOP AT GT_P0531 INTO LS_P0531 WHERE PERNR = GS_ALV-PERNR
AND BEGDA <= GS_ALV-ENDDA
AND ENDDA >= GS_ALV-SRECLJ.
"若P0531-BEGDA早于收入额重累计日期,则更新P0531-BEGDA=收入额重累计日期
IF LS_P0531-BEGDA < GS_ALV-SRECLJ.
LS_P0531-BEGDA = GS_ALV-SRECLJ.
ENDIF.
"若P0531-ENDDA在免税额重累计日期前,且收入额重累计标识不等于’X’,则更新收入额累计标识P0531-CURST=’X’
IF LS_P0531-ENDDA < GS_ALV-MSEQSR.
CHECK LS_P0531-CURST <> 'X'.
PERFORM FRM_COLLECT_0531_DATA TABLES LT_P0531
USING LS_P0531 LS_P0531-BEGDA LS_P0531-TXERD GS_ALV-MSEZZR 'X'.
"若免税额重累计日期在P0531-BEGDA和P0531-ENNDA之间
ELSEIF GS_ALV-MSEQSR BETWEEN LS_P0531-BEGDA AND LS_P0531-ENDDA.
"P0531-TXERD不等于免税额重累计日期或收入额重累计标识不等于’X’
CHECK LS_P0531-TXERD <> GS_ALV-MSEQSR OR LS_P0531-CURST <> 'X'.
PERFORM FRM_COLLECT_0531_DATA TABLES LT_P0531
USING LS_P0531 LS_P0531-BEGDA LS_P0531-TXERD GS_ALV-MSEZZR 'X'.
"同时新增P0531-BEGDA=免税额重累计日期,P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’X’。
PERFORM FRM_COLLECT_0531_DATA TABLES LT_P0531
USING LS_P0531 GS_ALV-MSEQSR GS_ALV-MSEQSR GS_ALV-MSEZZR 'X'.
"若P0531-BEGDA在免税额重累计日期之后
ELSEIF LS_P0531-BEGDA > GS_ALV-MSEQSR.
"且P0531-TXERD不等于免税额重累计日期或收入额重累计标识不等于’X’
CHECK LS_P0531-TXERD <> GS_ALV-MSEQSR OR LS_P0531-CURST <> 'X'.
"更新P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’X’。
PERFORM FRM_COLLECT_0531_DATA TABLES LT_P0531
USING LS_P0531 LS_P0531-BEGDA GS_ALV-MSEQSR GS_ALV-MSEZZR 'X'.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
SORT LT_P0531 BY BEGDA ASCENDING.
LOOP AT LT_P0531 INTO LS_P0531.
CLEAR LS_RETURN.
REFRESH: GT_BDC_DATA.
REFRESH: GT_BDC_MSG.
PERFORM FRM_BDC_DYNPRO USING 'SAPMP50A' '1000'.
PERFORM FRM_BDC_FIELD USING 'BDC_OKCODE' '=COP'.
PERFORM FRM_BDC_FIELD USING 'RP50G-PERNR' GS_ALV-PERNR.
PERFORM FRM_BDC_FIELD USING 'BDC_SUBSCR' 'SAPMP50A 0800SUBSCR_HEADER'.
PERFORM FRM_BDC_FIELD USING 'BDC_SUBSCR' 'SAPMP50A 0320SUBSCR_ITMENU'.
PERFORM FRM_BDC_FIELD USING 'BDC_SUBSCR' 'SAPMP50A 0330SUBSCR_TIME'.
PERFORM FRM_BDC_FIELD USING 'RP50G-TIMR6' 'X'.
PERFORM FRM_BDC_FIELD USING 'RP50G-BEGDA' LS_P0531-BEGDA.
PERFORM FRM_BDC_FIELD USING 'RP50G-ENDDA' LS_P0531-BEGDA.
PERFORM FRM_BDC_FIELD USING 'BDC_SUBSCR' 'SAPMP50A 0350SUBSCR_ITKEYS'.
PERFORM FRM_BDC_FIELD USING 'RP50G-CHOIC' '531'.
PERFORM FRM_BDC_DYNPRO USING 'MP053100' '2000'.
PERFORM FRM_BDC_FIELD USING 'BDC_OKCODE' '=UPD'.
PERFORM FRM_BDC_FIELD USING 'P0531-BEGDA' LS_P0531-BEGDA.
PERFORM FRM_BDC_FIELD USING 'P0531-ENDDA' LS_P0531-ENDDA.
* PERFORM frm_bdc_field USING 'P0531-TXARE' gt_p0531_bdc-txare .“目前系统配置这个字段不可修改
PERFORM FRM_BDC_FIELD USING 'P0531-TAXGP' LS_P0531-TAXGP .
IF LS_P0531-TAXGP IS NOT INITIAL .
PERFORM FRM_BDC_FIELD USING 'P0531-TXERD' LS_P0531-TXERD .
ENDIF.
IF LS_P0531-TXTMD IS NOT INITIAL .
PERFORM FRM_BDC_FIELD USING 'P0531-TXTMD' LS_P0531-TXTMD .
ENDIF.
PERFORM FRM_BDC_FIELD USING 'P0531-CURST' LS_P0531-CURST.
PERFORM FRM_BDC_FIELD USING 'BDC_SUBSCR' 'SAPMP50A 0090SUBSCREEN_T582C'.
CALL TRANSACTION 'PA30' USING GT_BDC_DATA
MODE GV_BDC_MODE
UPDATE 'A'
MESSAGES INTO GT_BDC_MSG.
LOOP AT GT_BDC_MSG WHERE MSGTYP = 'E'.
CLEAR: LV_BDC_MSG_STRING.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
MSGID = GT_BDC_MSG-MSGID
MSGNR = GT_BDC_MSG-MSGNR
MSGV1 = GT_BDC_MSG-MSGV1
MSGV2 = GT_BDC_MSG-MSGV2
MSGV3 = GT_BDC_MSG-MSGV3
MSGV4 = GT_BDC_MSG-MSGV4
IMPORTING
MESSAGE_TEXT_OUTPUT = LV_BDC_MSG_STRING.
CONCATENATE LV_BDC_MSG_STRING ';' LS_RETURN-MESSAGE INTO LS_RETURN-MESSAGE.
CLEAR GT_BDC_MSG.
ENDLOOP.
IF LS_RETURN-MESSAGE IS NOT INITIAL.
GS_ALV-RESULT = LS_RETURN-MESSAGE.
ELSE.
GS_ALV-RESULT = '成功'.
ENDIF.
MODIFY GT_ALV FROM GS_ALV TRANSPORTING RESULT MESSAGE.
ENDLOOP.
CLEAR LS_LOG .
MOVE-CORRESPONDING GS_ALV TO LS_LOG.
LS_LOG-ZDATUM = SY-DATUM.
LS_LOG-ZUZEIT = SY-UZEIT.
IF GS_ALV-RESULT = '成功'.
LS_LOG-ZSTATUS = '成功'.
ELSE .
LS_LOG-ZSTATUS = '失败'.
LS_LOG-ZMESSAGE = GS_ALV-RESULT.
ENDIF.
APPEND LS_LOG TO LT_LOG.
ENDLOOP.
MODIFY ZTGSCLJ_LOG FROM TABLE LT_LOG.
IF SY-SUBRC = 0.
COMMIT WORK AND WAIT .
ELSE.
ROLLBACK WORK.
ENDIF.
* LOOP AT GT_ALV INTO GS_ALV.
*
* CLEAR: GT_P0531_BDC.
*
* IF GS_ALV-SRECLJ IS NOT INITIAL. "收入累计日期不为空
* IF GS_ALV-MSEQSR < GS_ALV-BEGDA. "免税额重新累计日期在薪资周期前
* LOOP AT GT_P0531 INTO GS_P0531 WHERE PERNR = GS_ALV-PERNR
* AND BEGDA <= GS_ALV-ENDDA
* AND ENDDA >= GS_ALV-BEGDA.
*
* IF GS_P0531-BEGDA < GS_ALV-BEGDA."若P0531-BEGDA在薪资周期前
*
**1.如果收入额重新累计日期在P0531-ENDDA之后
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’’。则按如下逻辑新增0531记录:
**P0531-BEGDA=薪资周期开始日期
**P0531-TXERD=免税额重新累计日期
**收入额累计标识P0531-CURST=’’
* IF GS_ALV-SRECLJ > GS_P0531-ENDDA.
* IF GS_ALV-MSEQSR NE GS_P0531-TXERD OR GS_P0531-CURST = 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-BEGDA
* GS_ALV-MSEQSR
* ''
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ELSE.
**2.如果收入额重新累计日期在P0531-endda之前
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’X’。则按如下逻辑新增0531记录:
**P0531-BEGDA=薪资周期开始日期
**P0531-TXERD=免税额重新累计日期
**收入额累计标识P0531-CURST=’X’
* IF GS_ALV-MSEQSR NE GS_P0531-TXERD OR GS_P0531-CURST NE 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-BEGDA
* GS_ALV-MSEQSR
* 'X'
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
* ENDIF.
*
* IF GS_P0531-BEGDA >= GS_ALV-BEGDA AND GS_P0531-ENDDA <= GS_ALV-ENDDA."若P0531-BEGDA和P0531-ENDDA都在薪资周期内
**1.如果收入额重新累计日期在P0531-BEGDA之前,
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’X’.则按如下逻辑新增0531记录:
**P0531-TXERD=免税额重新累计日期,
**收入额累计标识P0531-CURST=’X’
* IF GS_ALV-SRECLJ < GS_P0531-BEGDA.
* IF GS_ALV-MSEQSR NE GS_P0531-TXERD OR GS_P0531-CURST NE 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_P0531-BEGDA
* GS_ALV-MSEQSR
* 'X'
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
*
**2.如果收入额重新累计日期在P0531-BEGDA和P0531-ENDDA之间,
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’X’。 则按如下逻辑新增0531记录:
**P0531-BEGDA=收入额重新累计日期,
**P0531-TXERD=免税额重新累计日期,
**收入额累计标识P0531-CURST=’X’
* IF GS_ALV-SRECLJ >= GS_P0531-BEGDA AND GS_ALV-SRECLJ <= GS_P0531-ENDDA.
* IF GS_ALV-MSEQSR NE GS_P0531-TXERD OR GS_P0531-CURST NE 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-SRECLJ
* GS_ALV-MSEQSR
* 'X'
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
*
**3.如果收入额重新累计日期在P0531-ENDDA之后,
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’’。则按如下逻辑新增0531记录:
**P0531-TXERD=免税额重新累计日期,
**收入额累计标识P0531-CURST=’’
* IF GS_ALV-SRECLJ > GS_P0531-ENDDA.
* IF GS_ALV-MSEQSR <> GS_P0531-TXERD OR GS_P0531-CURST = 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_P0531-BEGDA
* GS_ALV-MSEQSR
* ''
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
* ENDIF.
*
* IF GS_P0531-ENDDA > GS_ALV-ENDDA."若P0531-ENDDA在薪资周期后
**1.如果收入额重新累计日期在P0531-BEGDA之前,
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’X’。则按如下逻辑新增0531记录:
**(1)p0531-txerd=免税额重新累计日期,收入额累计标识p0531-curst=’x’。
**(2)p0531-begda=下个薪资周期开始日,p0531-txerd=免税额重新累计日期,收入额累计标识p0531-curst=’’
*
* IF GS_ALV-SRECLJ < GS_P0531-BEGDA.
* IF GS_ALV-MSEQSR NE GS_P0531-TXERD OR GS_P0531-CURST NE 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_P0531-BEGDA
* GS_ALV-MSEQSR
* 'X'
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
*
*
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-BEGDA_N
* GS_ALV-MSEQSR
* ''
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ELSE.
**2.如果收入额重新累计日期在P0531-BEGDA之后,
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’X’。同时按如下逻辑新增0531记录:
**(1)P0531-BEGDA=收入额重新累计日期,P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’X’。
**(2)P0531-BEGDA=下个薪资周期开始日,P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’’
* IF GS_ALV-MSEQSR NE GS_P0531-TXERD OR GS_P0531-CURST NE 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-SRECLJ
* GS_ALV-MSEQSR
* 'X'
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
*
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-BEGDA_N
* GS_ALV-MSEQSR
* ''
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
* ENDIF.
* CLEAR GS_P0531.
* ENDLOOP.
* ELSE. "Tax Entry Date在薪资期间内
*
* LOOP AT GT_P0531 INTO GS_P0531 WHERE PERNR = GS_ALV-PERNR
* AND BEGDA <= GS_ALV-ENDDA
* AND ENDDA >= GS_ALV-MSEQSR.
* IF GS_P0531-BEGDA < GS_ALV-MSEQSR."若P0531-BEGDA在免税额重新累计日期前
**1.如果收入额重新累计日期在P0531-ENDDA后,
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’’。则按如下逻辑新增0531记录:
**P0531-BEGDA=免税额重新累计日期,P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’’。
* IF GS_ALV-SRECLJ > GS_P0531-ENDDA.
* IF GS_ALV-MSEQSR <> GS_P0531-TXERD OR GS_P0531-CURST = 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-MSEQSR
* GS_ALV-MSEQSR
* ''
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ELSE.
**2.如果收入额重新累计日期在P0531-ENDDA前(包含等于),
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’X’。则按如下逻辑新增0531记录:
**P0531-BEGDA=收入额重新累计日期,P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’X’
* IF GS_ALV-MSEQSR <> GS_P0531-TXERD OR GS_P0531-CURST NE 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-SRECLJ
* GS_ALV-MSEQSR
* 'X'
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
* ENDIF.
* "若P0531-BEGDA和P0531-ENDDA在免税额重新累计日期和薪资周期结束日期之间
* IF GS_P0531-BEGDA >= GS_ALV-MSEQSR AND GS_P0531-ENDDA <= GS_ALV-ENDDA.
**1.如果收入额重新累计日期在P0531-BEGDA之前,
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’X’。 则按如下逻辑更新0531记录:
**P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’X’。
* IF GS_ALV-SRECLJ < GS_P0531-BEGDA.
* IF GS_ALV-MSEQSR <> GS_P0531-TXERD OR GS_P0531-CURST NE 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_P0531-BEGDA
* GS_ALV-MSEQSR
* 'X'
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
*
**2.如果收入额重新累计日期P0531-BEGDA和P0531-ENDDA之间(包含等于),
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’X’。 则按如下逻辑新增0531记录:
**P0531-BEGDA=收入额重新累计日期,P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’X’
* IF GS_ALV-SRECLJ >= GS_P0531-BEGDA AND GS_ALV-SRECLJ <= GS_P0531-ENDDA.
* IF GS_ALV-MSEQSR <> GS_P0531-TXERD OR GS_P0531-CURST = ''.
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-SRECLJ
* GS_ALV-MSEQSR
* 'X'
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
*
**3. 如果收入额重新累计日期在P0531-ENDDA之后,
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’’。 则按如下逻辑更新0531记录:
**P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’’
* IF GS_ALV-SRECLJ > GS_P0531-ENDDA.
* IF GS_ALV-MSEQSR <> GS_P0531-TXERD OR GS_P0531-CURST = 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_P0531-BEGDA
* GS_ALV-MSEQSR
* ''
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
* ENDIF.
*
**若P0531-ENDDA在薪资周期结束日期之后
* IF GS_P0531-ENDDA > GS_ALV-ENDDA.
**1.如果收入额重新累计日期在P0531-BEGDA之前,
**且P0531-TXERD<>免税额重新累计日期或收入额累计标识P0531-CURST<>’X’。 则按如下逻辑更新0531记录:
**(1)P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’X’。
**(2)P0531-BEGDA=下个薪资周期开始日,P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’’。
*
* IF GS_ALV-SRECLJ < GS_P0531-BEGDA.
* IF GS_ALV-MSEQSR <> GS_P0531-TXERD OR GS_P0531-CURST <> 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_P0531-BEGDA
* GS_ALV-MSEQSR
* 'X'
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
*
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-BEGDA_N
* GS_ALV-MSEQSR
* ''
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ELSE.
**2.如果收入额重新累计日期在P0531-BEGDA之后(包含等于),
**且P0531-TXERD<>免税额重新累计日期或收入额重新累计标识P0531-CURST<>’X’。 则按如下逻辑新增0531记录:
**(1)P0531-BEGDA=收入额重新累计日期,P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’X’。
**(2)P0531-BEGDA=下个薪资周期开始日,P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’’。
* IF GS_ALV-MSEQSR NE GS_P0531-TXERD OR GS_P0531-CURST NE 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-SRECLJ
* GS_ALV-MSEQSR
* 'X'
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
*
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-BEGDA_N
* GS_ALV-MSEQSR
* ''
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
* ENDIF.
* CLEAR GS_P0531.
* ENDLOOP.
* ENDIF.
* ELSE. "收入累计日期为空
*
**1.若P0531-BEGDA小于薪资周期开始日,P0531-ENDDA大于等于薪资周期开始日,
**且P0531-TXERD<>免税额重新累计日期或收入额重新累计标识P0531-CURST<>’’。则按如下记录新增0531记录:
**P0531-BEGDA=薪资周期开始日,
**P0531-TXERD=免税额重新累计日期,
**收入额累计标识P0531-CURST=’’
* IF GS_ALV-MSEQSR < GS_ALV-BEGDA. "Tax Entry Date在薪资期间前
* LOOP AT GT_P0531 INTO GS_P0531 WHERE PERNR = GS_ALV-PERNR AND BEGDA <= GS_ALV-ENDDA AND ENDDA >= GS_ALV-BEGDA.
* IF GS_P0531-BEGDA < GS_ALV-BEGDA AND GS_P0531-ENDDA >= GS_ALV-BEGDA.
* IF GS_ALV-MSEQSR <> GS_P0531-TXERD OR GS_P0531-CURST = 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-BEGDA
* GS_ALV-MSEQSR
* ''
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
**2.若P0531-BEGDA在薪资周期开始日之后(包含等于),
**且P0531-TXERD<>免税额重新累计日期或收入额重新累计标识P0531-CURST<>’’。 则按如下记录更新0531记录:
**P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’’
*
* IF GS_P0531-BEGDA >= GS_ALV-BEGDA.
* IF GS_ALV-MSEQSR <> GS_P0531-TXERD OR GS_P0531-CURST = 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_P0531-BEGDA
* GS_ALV-MSEQSR
* ''
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
* CLEAR GS_P0531.
* ENDLOOP.
* ELSE. "Tax Entry Date在薪资期间内
* LOOP AT GT_P0531 INTO GS_P0531 WHERE PERNR = GS_ALV-PERNR
* AND BEGDA <= GS_ALV-ENDDA
* AND ENDDA >= GS_ALV-MSEQSR.
**1.若P0531-BEGDA小于免税额重新累计日期,P0531-ENDDA大于等于免税额重新累计日期,
**且P0531-TXERD<>免税额重新累计日期或收入额重新累计标识P0531-CURST<>’’。 则按如下记录新增0531记录:
**P0531-BEGDA=免税额重新累计日期,P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’’。
* IF GS_P0531-BEGDA < GS_ALV-MSEQSR AND GS_P0531-ENDDA >= GS_ALV-MSEQSR.
* IF GS_ALV-MSEQSR <> GS_P0531-TXERD OR GS_P0531-CURST = 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_ALV-MSEQSR
* GS_ALV-MSEQSR
* ''
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
*
**2.若P0531-BEGDA在免税额重新累计日期之后(包含等于),
**且P0531-TXERD<>免税额重新累计日期或收入额重新累计标识P0531-CURST<>’’。 则按如下记录更新0531记录:
**P0531-TXERD=免税额重新累计日期,收入额累计标识P0531-CURST=’’
* IF GS_P0531-BEGDA >= GS_ALV-MSEQSR.
* IF GS_ALV-MSEQSR <> GS_P0531-TXERD OR GS_P0531-CURST = 'X'.
* PERFORM FRM_COLLECT_0531_DATA USING GS_P0531-BEGDA
* GS_ALV-MSEQSR
* ''
* GS_P0531-TXARE
* GS_P0531-TAXGP
* GS_P0531-ENDDA.
* ENDIF.
* ENDIF.
* CLEAR GS_P0531.
* ENDLOOP.
* ENDIF.
* ENDIF.
*
*
* LOOP AT GT_P0531_BDC INTO GS_P0531.
* CLEAR LS_RETURN.
* REFRESH: GT_BDC_DATA.
* REFRESH: GT_BDC_MSG.
*
* PERFORM FRM_BDC_DYNPRO USING 'SAPMP50A' '1000'.
* PERFORM FRM_BDC_FIELD USING 'BDC_OKCODE' '=COP'.
* PERFORM FRM_BDC_FIELD USING 'RP50G-PERNR' GS_ALV-PERNR.
* PERFORM FRM_BDC_FIELD USING 'BDC_SUBSCR' 'SAPMP50A 0800SUBSCR_HEADER'.
* PERFORM FRM_BDC_FIELD USING 'BDC_SUBSCR' 'SAPMP50A 0320SUBSCR_ITMENU'.
* PERFORM FRM_BDC_FIELD USING 'BDC_SUBSCR' 'SAPMP50A 0330SUBSCR_TIME'.
* PERFORM FRM_BDC_FIELD USING 'RP50G-TIMR6' 'X'.
* PERFORM FRM_BDC_FIELD USING 'RP50G-BEGDA' GS_P0531-BEGDA.
* PERFORM FRM_BDC_FIELD USING 'RP50G-ENDDA' GS_P0531-BEGDA.
* PERFORM FRM_BDC_FIELD USING 'BDC_SUBSCR' 'SAPMP50A 0350SUBSCR_ITKEYS'.
* PERFORM FRM_BDC_FIELD USING 'RP50G-CHOIC' '531'.
* PERFORM FRM_BDC_DYNPRO USING 'MP053100' '2000'.
* PERFORM FRM_BDC_FIELD USING 'BDC_OKCODE' '=UPD'.
* PERFORM FRM_BDC_FIELD USING 'P0531-BEGDA' GS_P0531-BEGDA.
* PERFORM FRM_BDC_FIELD USING 'P0531-ENDDA' GS_P0531-ENDDA.
** PERFORM frm_bdc_field USING 'P0531-TXARE' gt_p0531_bdc-txare .“目前系统配置这个字段不可修改
* PERFORM FRM_BDC_FIELD USING 'P0531-TAXGP' GS_P0531-TAXGP .
* PERFORM FRM_BDC_FIELD USING 'P0531-TXERD' GS_P0531-TXERD .
* PERFORM FRM_BDC_FIELD USING 'P0531-CURST' GS_P0531-CURST.
* PERFORM FRM_BDC_FIELD USING 'BDC_SUBSCR' 'SAPMP50A 0090SUBSCREEN_T582C'.
*
* CALL TRANSACTION 'PA30' USING GT_BDC_DATA
* MODE GV_BDC_MODE
* UPDATE 'A'
* MESSAGES INTO GT_BDC_MSG.
*
* LOOP AT GT_BDC_MSG WHERE MSGTYP = 'E'.
*
* CLEAR: LV_BDC_MSG_STRING.
*
* CALL FUNCTION 'MESSAGE_TEXT_BUILD'
* EXPORTING
* MSGID = GT_BDC_MSG-MSGID
* MSGNR = GT_BDC_MSG-MSGNR
* MSGV1 = GT_BDC_MSG-MSGV1
* MSGV2 = GT_BDC_MSG-MSGV2
* MSGV3 = GT_BDC_MSG-MSGV3
* MSGV4 = GT_BDC_MSG-MSGV4
* IMPORTING
* MESSAGE_TEXT_OUTPUT = LV_BDC_MSG_STRING.
*
* CONCATENATE LV_BDC_MSG_STRING ';' LS_RETURN-MESSAGE INTO LS_RETURN-MESSAGE.
* CLEAR GT_BDC_MSG.
* ENDLOOP.
*
* IF LS_RETURN-MESSAGE IS NOT INITIAL.
* GS_ALV-RESULT = LS_RETURN-MESSAGE.
* ELSE.
* GS_ALV-RESULT = '成功'.
* ENDIF.
*
* MODIFY GT_ALV FROM GS_ALV TRANSPORTING RESULT MESSAGE.
* CLEAR GS_P0531.
* ENDLOOP.
*
* CLEAR GS_ALV.
* ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_bdc_dynpro
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 iv_program
* --> p2 iv_dynpro
*----------------------------------------------------------------------*
FORM FRM_BDC_DYNPRO USING IV_PROGRAM
IV_DYNPRO.
CLEAR GT_BDC_DATA.
GT_BDC_DATA-PROGRAM = IV_PROGRAM.
GT_BDC_DATA-DYNPRO = IV_DYNPRO.
GT_BDC_DATA-DYNBEGIN = 'X'.
APPEND GT_BDC_DATA.
ENDFORM.
*&---------------------------------------------------------------------*
*& frm_bdc_field
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 iv_fnam
* --> p2 iv_fval
*----------------------------------------------------------------------*
FORM FRM_BDC_FIELD USING IV_FNAM
IV_FVAL.
CLEAR GT_BDC_DATA.
GT_BDC_DATA-FNAM = IV_FNAM.
WRITE IV_FVAL TO GT_BDC_DATA-FVAL LEFT-JUSTIFIED.
APPEND GT_BDC_DATA.
ENDFORM. "frm_bdc_field
*&---------------------------------------------------------------------*
*& Form FRM_COLLECT_0531_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GS_ALV_BEGDA text
* -->P_GS_ALV_MSEQSR text
* -->P_1202 text
* -->P_GS_P0531_TXARE text
* -->P_GS_P0531_TAXGP text
* -->P_GS_P0531_ENDDA text
*----------------------------------------------------------------------*
FORM FRM_COLLECT_0531_DATA TABLES IT_0531 STRUCTURE P0531
USING IS_P0531 TYPE P0531
IV_BEGDA TYPE DATUM
IV_MSEQSR TYPE DATUM
IV_MSEZZR TYPE DATUM
IV_CURST TYPE C.
IS_P0531-BEGDA = IV_BEGDA.
IS_P0531-TXERD = IV_MSEQSR.
IS_P0531-TXTMD = IV_MSEZZR.
IS_P0531-CURST = IV_CURST.
APPEND IS_P0531 TO IT_0531.
ENDFORM.
标签:逻辑,GS,BDC,HR,BEGDA,P0531,纳税,ALV,LS
From: https://www.cnblogs.com/Hao9933/p/16966438.html