居然无法将文字颜色全部改成红色。。。
*&---------------------------------------------------------------------*
*& Report ZTEST_PS_RPT_0003
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST_PS_RPT_0003.
tables:AUFK,AFKO,AFVC,PRPS,AFVV,AFRU.
type-pools:slis.
data:begin of itab occurs 0,
aufnr like aufk-aufnr, "网络号
ktext like aufk-ktext, "网络名称
gstrp like afko-gstrp, "网络开始日期
gltrp like afko-gltrp, "网络完成日期
vornr like afvc-vornr, "作业号
ltxa1 like afvc-ltxa1, "作业描述
posid like prps-posid, "WBS元素
post1 like prps-post1, "WBS描述
dauno like afvv-dauno, "工作时长(天)
fsavd like afvv-fsavd, "计划开始日期
fsedd like afvv-fsedd, "计划完成日期
isdd like afvv-isdd, "实际开始日期
iedd like afvv-iedd, "实际完成日期
abarb like afru-abarb, "作业报工量
budat like afru-budat, "报工日期
fidat type i, "距离完工天数
state type string, "作业系统状态
coltab type slis_t_specialcol_alv,"单元格颜色
end of itab.
data:begin of itab_aufk occurs 0,
aufnr like aufk-aufnr,
ktext like aufk-ktext,
pspel like aufk-pspel,
end of itab_aufk.
data:BEGIN OF itab_afko occurs 0,
aufnr like afko-aufnr,
aufpl like afko-aufpl,
gstrp like afko-gstrp, "网络开始日期
gltrp like afko-gltrp, "网络完成日期
end of itab_afko.
data:BEGIN OF itab_afvc occurs 0,
vornr like afvc-vornr, "作业号
ltxa1 like afvc-ltxa1, "作业描述
aufpl like afvc-aufpl, "订单中工序的工艺路线号
projn like afvc-projn,
aplzl like afvc-aplzl,
end of itab_afvc.
data:BEGIN OF itab_prps occurs 0,
posid like prps-posid, "WBS元素
post1 like prps-post1, "WBS描述
pspnr like prps-pspnr,
end of itab_prps.
data:BEGIN OF itab_afvv occurs 0,
aufpl like afvv-aufpl,
aplzl like afvv-aplzl,
dauno like afvv-dauno, "工作时长(天)
fsavd like afvv-fsavd, "计划开始日期
fsedd like afvv-fsedd, "计划完成日期
end of itab_afvv.
data:BEGIN OF itab_afru occurs 0,
aufnr like afru-aufnr,
aufpl like afru-aufpl,
vornr like afru-vornr,
abarb like afru-abarb, "作业报工量
budat like afru-budat, "报工日期
isdd like afru-isdd, "实际开始日期
iedd like afru-iedd, "实际完成日期
end of itab_afru.
*--------------ALV显示变量----------------------------*
DATA:COL_POS TYPE I.
DATA:GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
FIELDCATALOG LIKE GT_FIELDCAT,
G_REPID LIKE SY-REPID.
*DATA: GREF_ALV TYPE REF TO CL_GUI_ALV_GRID.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
s_aufnr for aufk-aufnr OBLIGATORY,"网络号
s_fsavd for afvv-fsavd,"作业计划开始日期
s_fsedd for afvv-fsedd,"作业计划完成日期
s_posid for prps-posid."WBS元素
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
perform FRM_GET_DATA.
perform frm_process.
perform FRM_DIS_DATA.
END-OF-SELECTION.
form FRM_GET_DATA.
select aufk~aufnr aufk~ktext aufk~pspel
into CORRESPONDING FIELDS OF TABLE itab_aufk
from aufk
where aufk~aufnr in s_aufnr.
select afko~gstrp afko~gltrp afko~aufnr afko~aufpl
into CORRESPONDING FIELDS OF TABLE itab_afko
from afko
where afko~aufnr in s_aufnr.
if lines( itab_afko ) > 0.
select afvc~vornr afvc~ltxa1 afvc~aufpl afvc~projn afvc~aplzl
into CORRESPONDING FIELDS OF TABLE itab_afvc
from afvc
FOR ALL ENTRIES IN itab_afko
where afvc~aufpl = itab_afko-aufpl.
if lines( itab_afvc ) > 0.
select prps~posid prps~post1 prps~pspnr
into CORRESPONDING FIELDS OF TABLE itab_prps
from prps
FOR ALL ENTRIES IN itab_afvc
where prps~pspnr = itab_afvc-projn
and prps~posid in s_posid.
select afvv~aufpl afvv~aplzl afvv~dauno afvv~fsavd afvv~fsedd
into CORRESPONDING FIELDS OF TABLE itab_afvv
from afvv
FOR ALL ENTRIES IN itab_afvc
where afvv~aufpl = itab_afvc-aufpl
and afvv~aplzl = itab_afvc-aplzl
and afvv~fsavd in s_fsavd
and afvv~fsedd in s_fsedd.
select afru~aufnr afru~aufpl afru~vornr afru~abarb afru~budat afru~isdd afru~iedd
into CORRESPONDING FIELDS OF TABLE itab_afru
from afru
FOR ALL ENTRIES IN itab_afvc
where afru~aufpl = itab_afvc-aufpl
and afru~vornr = itab_afvc-vornr.
endif.
endif.
endform.
form frm_process.
loop at itab_afru.
itab-aufnr = itab_afru-aufnr.
itab-vornr = itab_afru-vornr.
itab-abarb = itab_afru-abarb.
itab-isdd = itab_afru-isdd.
itab-iedd = itab_afru-iedd.
itab-budat = itab_afru-budat.
READ TABLE itab_aufk with key aufnr = itab_afru-aufnr.
if sy-subrc eq 0.
itab-ktext = itab_aufk-ktext.
endif.
READ TABLE itab_afko with key aufnr = itab_afru-aufnr.
if sy-subrc eq 0.
itab-gstrp = itab_afko-gstrp.
itab-gltrp = itab_afko-gltrp.
endif.
READ TABLE itab_afvc with key aufpl = itab_afru-aufpl vornr = itab_afru-vornr.
if sy-subrc eq 0.
itab-ltxa1 = itab_afvc-ltxa1.
endif.
READ TABLE itab_afvv with key aufpl = itab_afvc-aufpl aplzl = itab_afvc-aplzl.
if sy-subrc eq 0.
itab-dauno = itab_afvv-dauno.
itab-fsavd = itab_afvv-fsavd.
itab-fsedd = itab_afvv-fsedd.
endif.
READ TABLE itab_prps with key pspnr = itab_afvc-projn.
if sy-subrc eq 0.
itab-posid = itab_prps-posid.
itab-post1 = itab_prps-post1.
endif.
itab-fidat = sy-datlo - itab-fsedd.
append itab.
ENDLOOP.
loop at itab.
DATA l_alvcolor TYPE slis_specialcol_alv.
clear gs_layout.
l_alvcolor-fieldname = 'FIDAT'.
if itab-fidat < 30.
l_alvcolor-color-col = 6.
elseif itab-fidat >= 30 and itab-fidat < 80.
l_alvcolor-color-col = 3.
endif.
l_alvcolor-color-int = 0.
l_alvcolor-nokeycol = 'X'.
append l_alvcolor to itab-coltab.
modify itab.
ENDLOOP.
endform.
FORM FRM_DIS_DATA.
PERFORM FRM_BUILD_FIELD.
* GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GS_LAYOUT-INFO_FIELDNAME = 'LINE_COL'.
GS_LAYOUT-ZEBRA = 'X'.
GS_LAYOUT-HEADER_TEXT = 'ALV TEST'.
gs_layout-coltab_fieldname = 'COLTAB'.
G_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = GT_FIELDCAT[]
I_SAVE = 'A'
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM FRM_BUILD_FIELD.
PERFORM E01_FIELDCAT_INIT USING:
'AUFNR' '网络号' 12 '' '' 'X' '' '' ' ' '' '' '' '',
'KTEXT' '网络名称' 10 '' '' 'X' '' '' ' ' '' '' '' '',
'GSTRP' '网络开始日期' 12 '' '' 'X' '' '' ' ' '' '' '' '',
'GLTRP' '网络完成日期' 12 '' '' 'X' '' '' ' ' '' '' '' '',
'VORNR' '作业号' 10 '' '' 'X' '' '' ' ' '' '' '' '',
'LTXA1' '作业描述' 10 '' '' 'X' '' '' ' ' '' '' '' '',
'POSID' 'WBS元素' 10 '' '' 'X' '' '' ' ' '' '' '' '',
'POST1' 'WBS描述' 10 '' '' 'X' '' '' ' ' '' '' '' '',
'DAUNO' '工作时长(天)' 5 '' '' 'X' '' '' ' ' '' '' '' '',
'FSAVD' '计划开始日期' 12 '' '' 'X' '' '' ' ' '' '' '' '',
'FSEDD' '计划完成日期' 12 '' '' 'X' '' '' ' ' '' '' '' '',
'ABARB' '作业报工量' 5 '' '' 'X' '' '' ' ' '' '' '' '',
'ISDD' '实际开始日期' 12 '' '' 'X' '' '' ' ' '' '' '' '',
'IEDD' '实际完成日期' 12 '' '' 'X' '' '' ' ' '' '' '' '',
'BUDAT' '报工日期' 10 '' '' 'X' '' '' ' ' '' '' '' '',
'FIDAT' '距离完工天数' 12 '' '' 'X' '' '' ' ' '' '' '' '',
'STATE' '作业系统状态' 12 '' '' 'X' '' '' ' ' '' '' '' ''.
ENDFORM.
FORM E01_FIELDCAT_INIT USING
FIELD_NAME TYPE C
FIELD_TEXT TYPE C
FIELD_LENTH TYPE I
FIELD_EDIT TYPE C
FIELD_TYPE TYPE C
FIELD_KEY TYPE C
FIELD_HOTSPOT TYPE C
FIELD_CHECKBOX TYPE C
FIELD_NO_ZERO TYPE C
FIELD_REF_TABNAME TYPE C
FIELD_EMPHASIZE TYPE C
FIELD_INPUT TYPE C
FIELD_SUM TYPE C .
COL_POS = COL_POS + 1.
FIELDCATALOG-COL_POS = COL_POS.
FIELDCATALOG-FIELDNAME = FIELD_NAME.
FIELDCATALOG-SELTEXT_L = FIELD_TEXT.
FIELDCATALOG-SELTEXT_M = FIELD_TEXT.
FIELDCATALOG-SELTEXT_S = FIELD_TEXT.
FIELDCATALOG-CHECKBOX = FIELD_CHECKBOX.
FIELDCATALOG-INPUT = FIELD_INPUT.
FIELDCATALOG-EDIT = FIELD_EDIT.
IF FIELD_TYPE = 'Q'.
FIELDCATALOG-JUST = 'R'.
ELSE.
FIELDCATALOG-JUST = 'L'.
ENDIF.
FIELDCATALOG-KEY = FIELD_KEY.
FIELDCATALOG-HOTSPOT = FIELD_HOTSPOT .
FIELDCATALOG-OUTPUTLEN = FIELD_LENTH.
FIELDCATALOG-NO_ZERO = FIELD_NO_ZERO.
FIELDCATALOG-EMPHASIZE = FIELD_EMPHASIZE .
FIELDCATALOG-REF_FIELDNAME = FIELD_REF_TABNAME.
FIELDCATALOG-REF_TABNAME = FIELD_REF_TABNAME.
FIELDCATALOG-DO_SUM = FIELD_SUM.
APPEND FIELDCATALOG TO GT_FIELDCAT.
ENDFORM.