INCLUDE zfir_0010top.
TYPE-POOLS:slis.
TABLES:bsid,kna1,t001.
DATA: g_itab_fieldcat_lvc TYPE lvc_t_fcat,
g_itab_sort_lvc TYPE lvc_t_sort.
*定义显示结果集
DATA:BEGIN OF gt_result OCCURS 0,
name1 LIKE kna1-name1,"客户名称
kunnr LIKE bsid-kunnr,"客户代码
bukrs LIKE bsid-bukrs,"公司代码
butxt LIKE t001-butxt,"公司代码描述
prctr LIKE bsid-prctr,"利润中心
ktext LIKE cepct-ktext,"利润中心描述
hkont LIKE bsid-hkont,"总账科目
txt20 LIKE skat-txt20,"总账科目描述
dmbtr LIKE bsid-dmbtr,"合计金额
dmbtr1 LIKE bsid-dmbtr, "账龄期间1
dmbtr2 LIKE bsid-dmbtr, "账龄期间2
dmbtr3 LIKE bsid-dmbtr, "账龄期间3
dmbtr4 LIKE bsid-dmbtr, "账龄期间4
dmbtr5 LIKE bsid-dmbtr, "账龄期间5
dmbtr6 LIKE bsid-dmbtr, "账龄期间7 "账龄期间5
dmbtr7 LIKE bsid-dmbtr,
END OF gt_result.
DATA:BEGIN OF gt_bsid OCCURS 0,
bukrs LIKE bsid-bukrs,
kunnr LIKE bsid-kunnr,
gjahr LIKE bsid-gjahr,
belnr LIKE bsid-belnr,
buzei LIKE bsid-buzei,
prctr LIKE bsid-prctr,
hkont LIKE bsid-hkont,
shkzg LIKE bsid-shkzg,
budat LIKE bsid-budat,
xblnr LIKE bkpf-xblnr,
dmbtr LIKE bsid-dmbtr,
END OF gt_bsid.
DATA:lt_bsid LIKE gt_bsid OCCURS 0 WITH HEADER LINE."临时存储SHKZG为H的BSID行项目
DATA:wa_bsid LIKE gt_bsid OCCURS 0 WITH HEADER LINE."储存处理完成的BSID数据
DATA: l_bukrs LIKE bsid-bukrs,
l_kunnr LIKE bsid-kunnr,
l_dmbtr LIKE bsid-dmbtr,
l_dmbtr1 LIKE bsid-dmbtr,
l_dmbtr2 LIKE bsid-dmbtr,
l_dmbtr3 LIKE bsid-dmbtr,
l_dmbtr4 LIKE bsid-dmbtr,
l_dmbtr5 LIKE bsid-dmbtr,
l_dmbtr6 LIKE bsid-dmbtr.
DATA: l_days TYPE i."日期差
INCLUDE zfir_0010s01.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE t1.
SELECT-OPTIONS:s_bukrs FOR bsid-bukrs DEFAULT '1000' OBLIGATORY,
s_ktokd FOR kna1-ktokd,
s_kunnr FOR bsid-kunnr,
s_hkont FOR bsid-hkont,
s_prctr FOR bsid-prctr.
PARAMETER:p_budat LIKE bsid-budat DEFAULT sy-datum OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE t2.
PARAMETERS:p_date1(3) TYPE n DEFAULT 30 OBLIGATORY,
p_date2(3) TYPE n,
p_date3(3) TYPE n,
p_date4(3) TYPE n,
p_date5(3) TYPE n,
p_date6(3) TYPE n.
SELECTION-SCREEN END OF BLOCK blk2.
SELECTION-SCREEN BEGIN OF BLOCK blk3 WITH FRAME TITLE t3.
PARAMETERS:p_start LIKE bsid-budat MODIF ID mid OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk3.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_bukrs-low.
PERFORM frm_onf4_bukrs USING 'S_BUKRS-LOW'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_bukrs-high.
PERFORM frm_onf4_bukrs USING 'S_BUKRS-HIGH'.
INCLUDE zfir_0010e01.
INITIALIZATION.
t1 = '数据库选择'.
t2 = '显示选择'.
t3 = '测试选择'.
AT SELECTION-SCREEN OUTPUT.
*modify screen
DATA:hidid(5) TYPE c.
IF sy-tcode = 'ZFI0010'.
hidid = 'MID'.
ENDIF.
IF sy-tcode = 'ZFI0010A' OR sy-tcode = 'SEU_INT'."OR sy-tcode = 'SE38'.
hidid = 'NONE'.
ENDIF.
LOOP AT SCREEN.
IF screen-group1 = hidid.
screen-active = '0'.
screen-invisible = '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
AT SELECTION-SCREEN.
PERFORM frm_auth_check.
*定义宏
DATA:message(40) TYPE c.
DEFINE check_screen.
IF p_date&1 IS NOT INITIAL.
IF p_date&2 <= p_date&3.
CONCATENATE '账龄期间' &4 '必须比账龄期间' &5 '大' INTO message.
MESSAGE e000(zfi_001) WITH message.
ENDIF.
ELSE.
IF p_date&6 IS NOT INITIAL.
CONCATENATE '请输入账龄期间' &7 INTO message.
MESSAGE e000(zfi_001) WITH message.
ENDIF.
ENDIF.
END-OF-DEFINITION.
*check screen
check_screen 2 2 1 '2' '1' 3 '2'.
check_screen 3 3 2 '3' '2' 4 '3'.
check_screen 4 4 3 '4' '3' 5 '4'.
check_screen 5 5 4 '5' '4' 6 '5'.
check_screen 6 6 5 '6' '5' 6 '6'.
START-OF-SELECTION.
PERFORM frm_select_data.
PERFORM frm_output_data.
INCLUDE zfir_0010f01.
FORM frm_select_data.
*设置期初导入日期 初定20120430
DATA:budat LIKE bsid-budat VALUE '20120430'.
IF sy-datum > budat.
p_start = budat.
ENDIF.
*期初导入数据处理
SELECT
b~bukrs
b~kunnr
b~gjahr
b~belnr
b~buzei
b~prctr
b~hkont
b~shkzg
b~budat
f~xblnr
b~dmbtr
INTO CORRESPONDING FIELDS OF TABLE gt_bsid
FROM bsid AS b INNER JOIN kna1 AS k ON b~kunnr = k~kunnr
INNER JOIN bkpf AS f ON b~belnr = f~belnr AND b~gjahr = f~gjahr AND b~bukrs = f~bukrs
WHERE b~bukrs IN s_bukrs AND
k~ktokd IN s_ktokd AND
b~kunnr IN s_kunnr AND
b~hkont IN s_hkont AND
b~prctr IN s_prctr AND
b~budat = p_start.
*对于期初导入数据将参照内的日期作为基准日期
LOOP AT gt_bsid WHERE xblnr IS NOT INITIAL.
*Changed By Ryan Liu In 02.05.2012 14:04:31.
DATA:str1(4) TYPE c,
str2(2) TYPE c,
str3(2) TYPE c,
l_xblnr LIKE bsid-budat.
SPLIT gt_bsid-xblnr AT '/' INTO str1 str2 str3.
CONCATENATE str1 str2 str3 INTO l_xblnr.
CONDENSE l_xblnr NO-GAPS.
*End Of Change.
gt_bsid-budat = l_xblnr.
MODIFY gt_bsid TRANSPORTING budat.
ENDLOOP.
*正常数据处理
SELECT
b~bukrs
b~kunnr
b~gjahr
b~belnr
b~buzei
b~prctr
b~hkont
b~shkzg
b~budat
b~dmbtr
APPENDING CORRESPONDING FIELDS OF TABLE gt_bsid
FROM bsid AS b INNER JOIN kna1 AS k ON b~kunnr = k~kunnr
WHERE b~bukrs IN s_bukrs AND
k~ktokd IN s_ktokd AND
b~kunnr IN s_kunnr AND
b~hkont IN s_hkont AND
b~prctr IN s_prctr AND
b~budat > p_start AND
b~budat <= p_budat.
*INSERTED BY PYM 20120917
*IF SY-TCODE = 'ZFI0010'.
SELECT
b~bukrs
b~kunnr
b~gjahr
b~belnr
b~buzei
b~prctr
b~hkont
b~shkzg
b~budat
b~dmbtr
APPENDING CORRESPONDING FIELDS OF TABLE GT_BSID
FROM BSAD AS B INNER JOIN KNA1 AS K ON B~KUNNR = K~KUNNR
WHERE b~bukrs IN s_bukrs AND
k~ktokd IN s_ktokd AND
b~kunnr IN s_kunnr AND
b~hkont IN s_hkont AND
b~prctr IN s_prctr AND
b~AUGDT > p_budat AND
b~budat <= p_budat.
*ENDIF.
*ENDOFINSERTED
DELETE gt_bsid WHERE hkont = '1121020000' OR hkont = '1121010000'."应收票据-商业承兑汇票 应收票据-银行承兑汇票
IF gt_bsid[] IS INITIAL.
MESSAGE '未找到相关数据' TYPE 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
*处理部分清帐
PERFORM frm_deal_data.
*分配到各个账龄期间
PERFORM frm_save_data.
ENDFORM. "frm_select_date
FORM frm_deal_data.
IF gt_bsid[] IS NOT INITIAL.
LOOP AT gt_bsid.
IF gt_bsid-shkzg = 'H'.
MOVE gt_bsid TO lt_bsid.
APPEND lt_bsid.
CLEAR lt_bsid.
DELETE gt_bsid.
ENDIF.
ENDLOOP.
SORT gt_bsid BY bukrs kunnr hkont budat.
SORT lt_bsid BY bukrs kunnr hkont budat.
DATA:dmbtr LIKE bsid-dmbtr VALUE 0,
L_V_DMBTR_1 LIKE BSID-DMBTR,
L_V_DMBTR_2 LIKE BSID-DMBTR.
*inserted by pym 20121114
DATA:BEGIN OF lt_bsid_1 OCCURS 0,
bukrs LIKE bsid-bukrs,
kunnr LIKE bsid-kunnr,
hkont LIKE bsid-hkont,
shkzg LIKE bsid-shkzg,
dmbtr LIKE bsid-dmbtr,
dmbtr1 LIKE bsid-dmbtr,
END OF lt_bsid_1.
loop at gt_bsid.
lt_bsid_1-bukrs = gt_bsid-bukrs.
lt_bsid_1-kunnr = gt_bsid-kunnr.
lt_bsid_1-hkont = gt_bsid-hkont.
* lt_bsid_1-shkzg = gt_bsid-shkzg.
lt_bsid_1-dmbtr = gt_bsid-dmbtr.
COLLECT lt_bsid_1.
clear lt_bsid_1.
ENDLOOP.
loop at lt_bsid.
lt_bsid_1-bukrs = lt_bsid-bukrs.
lt_bsid_1-kunnr = lt_bsid-kunnr.
lt_bsid_1-hkont = lt_bsid-hkont.
* lt_bsid_1-shkzg = lt_bsid-shkzg.
lt_bsid_1-dmbtr1 = lt_bsid-dmbtr.
COLLECT lt_bsid_1.
clear lt_bsid_1.
ENDLOOP.
SORT lt_bsid_1 BY bukrs kunnr hkont.
LOOP AT lt_bsid_1.
IF lt_bsid_1-dmbtr = lt_bsid_1-dmbtr1.
DELETE gt_bsid WHERE bukrs = lt_bsid_1-bukrs AND kunnr = lt_bsid_1-kunnr AND hkont = lt_bsid_1-hkont.
DELETE lt_bsid WHERE bukrs = lt_bsid_1-bukrs AND kunnr = lt_bsid_1-kunnr AND hkont = lt_bsid_1-hkont.
ELSEIF lt_bsid_1-dmbtr > lt_bsid_1-dmbtr1.
dmbtr = lt_bsid_1-dmbtr1.
DELETE lt_bsid WHERE bukrs = lt_bsid_1-bukrs AND kunnr = lt_bsid_1-kunnr AND hkont = lt_bsid_1-hkont.
LOOP AT gt_bsid WHERE bukrs = lt_bsid_1-bukrs AND kunnr = lt_bsid_1-kunnr AND hkont = lt_bsid_1-hkont.
IF gt_bsid-dmbtr <= dmbtr.
dmbtr = dmbtr - gt_bsid-dmbtr.
DELETE gt_bsid.
ELSEIF gt_bsid-dmbtr > dmbtr.
gt_bsid-dmbtr = gt_bsid-dmbtr - dmbtr.
MODIFY gt_bsid TRANSPORTING dmbtr.
EXIT.
ENDIF.
ENDLOOP.
ELSEIF lt_bsid_1-dmbtr < lt_bsid_1-dmbtr1.
* dmbtr = lt_bsid_1-dmbtr1 - lt_bsid_1-dmbtr.
dmbtr = lt_bsid_1-dmbtr.
DELETE gt_bsid WHERE bukrs = lt_bsid_1-bukrs AND kunnr = lt_bsid_1-kunnr AND hkont = lt_bsid_1-hkont.
LOOP AT lt_bsid WHERE bukrs = lt_bsid_1-bukrs AND kunnr = lt_bsid_1-kunnr AND hkont = lt_bsid_1-hkont.
IF lt_bsid-dmbtr <= dmbtr.
dmbtr = dmbtr - lt_bsid-dmbtr.
DELETE lt_bsid.
ELSEIF lt_bsid-dmbtr > dmbtr.
lt_bsid-dmbtr = lt_bsid-dmbtr - dmbtr.
MODIFY lt_bsid TRANSPORTING dmbtr.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
loop at lt_bsid.
MOVE-CORRESPONDING lt_bsid to gt_bsid.
gt_bsid-dmbtr = 0 - gt_bsid-dmbtr.
append gt_bsid.
endloop.
*endofinsert
* LOOP AT lt_bsid.
* dmbtr = lt_bsid-dmbtr.
* LOOP AT gt_bsid WHERE bukrs = lt_bsid-bukrs AND kunnr = lt_bsid-kunnr AND hkont = lt_bsid-hkont.
** IF sy-subrc = 0.
* dmbtr = dmbtr - gt_bsid-dmbtr.
* IF dmbtr > 0.
** DELETE gt_bsid.
* gt_bsid-dmbtr = 0 - dmbtr.
* MODIFY gt_bsid.
* CLEAR gt_bsid.
* EXIT.
* ELSEIF dmbtr = 0.
* DELETE gt_bsid.
* EXIT.
* ELSE.
* gt_bsid-dmbtr = 0 - dmbtr.
* MODIFY gt_bsid.
* CLEAR gt_bsid.
* EXIT.
* ENDIF.
** ENDIF.
* ENDLOOP.
** CLEAR sy-subrc.
* IF sy-subrc = 4.
* gt_bsid-bukrs = lt_bsid-bukrs.
* gt_bsid-kunnr = lt_bsid-kunnr.
* gt_bsid-hkont = lt_bsid-hkont.
* gt_bsid-budat = lt_bsid-budat.
* gt_bsid-dmbtr = 0 - lt_bsid-dmbtr.
* APPEND gt_bsid.
* CLEAR gt_bsid.
* ENDIF.
* ENDLOOP.
ENDIF.
ENDFORM. "frm_deal_data
FORM frm_save_data.
LOOP AT gt_bsid.
l_days = p_budat - gt_bsid-budat.
gt_result-kunnr = gt_bsid-kunnr.
gt_result-bukrs = gt_bsid-bukrs.
gt_result-prctr = gt_bsid-prctr.
gt_result-hkont = gt_bsid-hkont.
IF l_days >= 0 AND l_days <= p_date1.
gt_result-dmbtr1 = gt_bsid-dmbtr.
ELSEIF p_date2 IS NOT INITIAL.
IF l_days > p_date1 AND l_days <= p_date2.
gt_result-dmbtr2 = gt_bsid-dmbtr.
ELSEIF p_date3 IS NOT INITIAL.
IF l_days > p_date2 AND l_days <= p_date3.
gt_result-dmbtr3 = gt_bsid-dmbtr.
ELSEIF p_date4 IS NOT INITIAL.
IF l_days > p_date3 AND l_days <= p_date4.
gt_result-dmbtr4 = gt_bsid-dmbtr.
ELSEIF p_date5 IS NOT INITIAL.
IF l_days > p_date4 AND l_days <= p_date5.
gt_result-dmbtr5 = gt_bsid-dmbtr.
ELSEIF p_date6 IS NOT INITIAL.
IF l_days > p_date5 AND l_days <= p_date6.
gt_result-dmbtr6 = gt_bsid-dmbtr.
ELSE.
gt_result-dmbtr7 = gt_bsid-dmbtr.
ENDIF.
ELSE.
gt_result-dmbtr6 = gt_bsid-dmbtr.
ENDIF.
ELSE.
gt_result-dmbtr5 = gt_bsid-dmbtr.
ENDIF.
ELSE.
gt_result-dmbtr4 = gt_bsid-dmbtr.
ENDIF.
ELSE.
gt_result-dmbtr3 = gt_bsid-dmbtr.
ENDIF.
ELSE.
gt_result-dmbtr2 = gt_bsid-dmbtr.
ENDIF.
* APPEND gt_result.
COLLECT gt_result.
CLEAR gt_result.
ENDLOOP.
LOOP AT gt_result.
SELECT SINGLE name1 INTO gt_result-name1 FROM kna1 WHERE kunnr = gt_result-kunnr.
SELECT SINGLE butxt INTO gt_result-butxt FROM t001 WHERE bukrs = gt_result-bukrs.
SELECT SINGLE ktext INTO gt_result-ktext FROM cepct WHERE spras = '1' AND prctr = gt_result-prctr.
SELECT SINGLE txt20 INTO gt_result-txt20 FROM skat WHERE spras = '1' AND saknr = gt_result-hkont.
gt_result-dmbtr = gt_result-dmbtr1 + gt_result-dmbtr2 + gt_result-dmbtr3 + gt_result-dmbtr4 + gt_result-dmbtr5 + gt_result-dmbtr6 + gt_result-dmbtr7.
MODIFY gt_result.
CLEAR gt_result.
ENDLOOP.
SORT gt_result BY kunnr bukrs hkont.
DATA WT_TEMP LIKE ZZT_FI_005.
WT_TEMP-DATUM = SY-DATUM.
WT_TEMP-UZEIT = SY-UZEIT.
WT_TEMP-UNAME = SY-UNAME.
WT_TEMP-TCODE = SY-TCODE.
WT_TEMP-CPROG = SY-CPROG.
WT_TEMP-BATCH = SY-BATCH.
WT_TEMP-CALLD = SY-CALLD.
CONCATENATE 'bukrs:' s_bukrs-LOW ',' s_bukrs-HIGH ';ktokd:' s_ktokd-LOW ',' s_ktokd-HIGH
';kunnr:' s_kunnr-LOW ',' s_kunnr-HIGH ';hkont:' s_hkont-LOW ',' s_hkont-HIGH ';prctr:' s_prctr-LOW ',' s_prctr-HIGH
';budat:' p_budat ';date1:' p_date1 ';date2:' p_date2 ';date3:' p_date3
';date4:' p_date4 ';date5:' p_date5 ';date6:' p_date6 ';start:' p_start INTO WT_TEMP-TITLE.
MODIFY ZZT_FI_005 FROM WT_TEMP.
IF SY-SUBRC = 0.
* IF sy-subrc <> 0.
* ROLLBACK WORK.
* ELSE.
COMMIT WORK.
ENDIF.
ENDFORM. "frm_save_data
FORM frm_output_data.
DATA: l_layout TYPE lvc_s_layo,
l_repid LIKE sy-repid,
l_events TYPE slis_t_event WITH HEADER LINE.
l_repid = sy-repid.
DATA:title1 LIKE dd03p-reptext,
title2 LIKE dd03p-reptext,
title3 LIKE dd03p-reptext,
title4 LIKE dd03p-reptext,
title5 LIKE dd03p-reptext,
title6 LIKE dd03p-reptext,
title7 LIKE dd03p-reptext.
* 填充fieldcat.
PERFORM sub_fill_alv_fieldcat USING 'NAME1'
'往来客户'.
PERFORM sub_fill_alv_fieldcat USING 'KUNNR'
'客户编码'.
PERFORM sub_fill_alv_fieldcat USING 'BUKRS'
'公司代码'.
PERFORM sub_fill_alv_fieldcat USING 'BUTXT'
'公司代码描述'.
PERFORM sub_fill_alv_fieldcat USING 'PRCTR'
'利润中心'.
PERFORM sub_fill_alv_fieldcat USING 'KTEXT'
'利润中心描述'.
PERFORM sub_fill_alv_fieldcat USING 'HKONT'
'总账科目'.
PERFORM sub_fill_alv_fieldcat USING 'TXT20'
'总账科目描述'.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR'
'合计金额'.
PERFORM frm_creat_title1 USING 0 p_date1 title1.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR1'
title1.
IF p_date2 IS NOT INITIAL.
PERFORM frm_creat_title1 USING p_date1 p_date2 title2.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR2'
title2.
IF p_date3 IS NOT INITIAL.
PERFORM frm_creat_title1 USING p_date2 p_date3 title3.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR3'
title3.
IF p_date4 IS NOT INITIAL.
PERFORM frm_creat_title1 USING p_date3 p_date4 title4.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR4'
title4.
IF p_date5 IS NOT INITIAL.
PERFORM frm_creat_title1 USING p_date4 p_date5 title5.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR5'
title5.
IF p_date6 IS NOT INITIAL.
PERFORM frm_creat_title1 USING p_date5 p_date6 title6.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR6'
title6.
PERFORM frm_creat_title2 USING p_date6 title7.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR7'
title7.
ELSE.
PERFORM frm_creat_title2 USING p_date5 title6.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR6'
title6.
ENDIF.
ELSE.
PERFORM frm_creat_title2 USING p_date4 title5.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR5'
title5.
ENDIF.
ELSE.
PERFORM frm_creat_title2 USING p_date3 title4.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR4'
title4.
ENDIF.
ELSE.
PERFORM frm_creat_title2 USING p_date2 title3.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR3'
title3.
ENDIF.
ELSE.
PERFORM frm_creat_title2 USING p_date1 title2.
PERFORM sub_fill_alv_fieldcat USING 'DMBTR2'
title2.
ENDIF.
l_layout-cwidth_opt = 'X'.
l_layout-col_opt = 'X'.
l_layout-zebra = 'X'.
l_layout-sel_mode = 'B'.
l_layout-no_rowmark = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = l_repid
is_layout_lvc = l_layout
it_fieldcat_lvc = g_itab_fieldcat_lvc
it_sort_lvc = g_itab_sort_lvc
i_grid_title = '应收账款账龄分析报表'
TABLES
t_outtab = gt_result
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. "frm_output_data
FORM sub_fill_alv_fieldcat USING p_fieldname TYPE slis_fieldname
p_reptext_ddic LIKE dd03p-reptext.
DATA: l_fieldcat_lvc TYPE lvc_s_fcat.
l_fieldcat_lvc-fieldname = p_fieldname.
l_fieldcat_lvc-reptext = p_reptext_ddic.
IF p_fieldname = 'KUNNR'.
l_fieldcat_lvc-no_zero = 'X'.
ENDIF.
IF p_fieldname = 'BUKRS'.
l_fieldcat_lvc-no_zero = 'X'.
ENDIF.
IF p_fieldname = 'PRCTR'.
l_fieldcat_lvc-no_zero = 'X'.
ENDIF.
APPEND l_fieldcat_lvc TO g_itab_fieldcat_lvc.
CLEAR l_fieldcat_lvc.
ENDFORM. "sub_fill_alv_fieldcat
FORM frm_creat_title1 USING date1 date2 title.
DATA:l_title1(20) TYPE c,
l_title2(20) TYPE c.
IF date1 <> 0.
WRITE date1 TO l_title1 NO-ZERO.
ELSE.
WRITE date1 TO l_title1.
ENDIF.
WRITE date2 TO l_title2 NO-ZERO.
CONCATENATE l_title1 '~' l_title2 '天' INTO title.
CONDENSE title NO-GAPS.
ENDFORM. "frm_creat_title1
FORM frm_creat_title2 USING date1 title.
DATA:l_title1(20) TYPE c.
WRITE date1 TO l_title1 NO-ZERO.
CONCATENATE l_title1 '天以上' INTO title.
CONDENSE title NO-GAPS.
ENDFORM. "frm_creat_title2
*&---------------------------------------------------------------------*
*& Form frm_onf4_bukrs
*&---------------------------------------------------------------------*
* 公司代码输入帮助
*----------------------------------------------------------------------*
* -->P_FIELD 字段
*----------------------------------------------------------------------*
FORM frm_onf4_bukrs USING p_field.
TYPES:BEGIN OF ty_t001,
bukrs TYPE t001-bukrs,
butxt TYPE t001-butxt,
END OF ty_t001.
DATA:
lt_t001 TYPE TABLE OF ty_t001 WITH HEADER LINE.
SELECT bukrs
butxt
FROM t001
INTO TABLE lt_t001
WHERE bukrs LIKE '1%'
AND spras = sy-langu.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
retfield = 'BUKRS' "预选值要填入的字段名
* PVALKEY = ' '
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = p_field " 此屏幕字段参数
value_org = 'S'
* multiple_choice = 'X'
callback_program = sy-repid
TABLES
value_tab = lt_t001[] " 存放预选值清单的内表
* FIELD_TAB =
* DYNPFLD_MAPPING =
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
ENDFORM. " frm_onf4_bukrs
INCLUDE zfc_check1.
FORM frm_auth_check.
DATA lt_t001 LIKE TABLE OF t001 WITH HEADER LINE.
SELECT
bukrs
INTO CORRESPONDING FIELDS OF TABLE lt_t001
FROM t001
WHERE bukrs IN s_bukrs.
LOOP AT lt_t001.
CALL FUNCTION'ZZ_CHECK_REPAUTH'
EXPORTING
i_module = 'FC'
i_bukrs = lt_t001-bukrs
* I_WERKS =
EXCEPTIONS
not_authorized = 1
no_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
ENDFORM." FRM_CHECK_INPUT