*&---------------------------------------------------------------------*
*& Report ZPPF006
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zppf007.
INCLUDE zppf006_top.
INCLUDE zppf006_scr.
INCLUDE zppf006_frm.
START-OF-SELECTION.
PERFORM:frm_get_data.
PERFORM:frm_process_data.
PERFORM:frm_display_data.
*&---------------------------------------------------------------------*
*& 包含 ZPPF006_TOP
*&---------------------------------------------------------------------*
TABLES:anla,csks,anlh,anlz,cskt,but000.
DATA:BEGIN OF gs_anla,
bukrs LIKE anla-bukrs, "公司代码
anln1 LIKE anla-anln1, "主资产号
txt50 LIKE anla-txt50, "资产品名
gdlgrp LIKE anla-gdlgrp, "评估组 5-购置日期
aktiv LIKE anla-aktiv, "资产资本化日期
lifnr LIKE anla-lifnr, "资产提供者名
txa50 LIKE anla-txa50,
sernr LIKE anla-sernr, "序列号
invnr LIKE anla-invnr,
END OF gs_anla.
DATA:BEGIN OF gs_but000,
partner LIKE but000-partner,
name_org1 LIKE but000-name_org1,
END OF gs_but000.
DATA:gt_but000 LIKE TABLE OF gs_but000.
DATA:BEGIN OF gs_anlz,
anln1 LIKE anlz-anln1,
kostl LIKE anlz-kostl, "成本中心
bdatu LIKE anlz-bdatu, "结束日
adatu LIKE anlz-adatu, "起始日
END OF gs_anlz.
DATA:BEGIN OF gs_cskt,
kostl LIKE cskt-kostl,
ltext LIKE cskt-ltext,
END OF gs_cskt.
DATA:BEGIN OF gs_csks,
kostl LIKE csks-kostl, "成本中心
* name1 LIKE csks-name1, "使用部门
verak LIKE csks-verak, "负责人
* datbi LIKE csks-datbi,
* datab LIKE csks-datab,
END OF gs_csks.
DATA:BEGIN OF gs_anlh,
anln1 LIKE anlh-anln1,
anlhtxt LIKE anlh-anlhtxt, "资产主号说明-规格型号
END OF gs_anlh.
DATA:BEGIN OF gs_out,
mark,
bukrs LIKE anla-bukrs,
anln1 LIKE anla-anln1,
txt50 LIKE anla-txt50,
gdlgrp LIKE anla-gdlgrp,
aktiv LIKE anla-aktiv,
name_org1 LIKE but000-name_org1,
kostl LIKE anlz-kostl,
ltext LIKE cskt-ltext,
verak LIKE csks-verak,
txa50 LIKE anla-txa50,
bdatu LIKE anlz-bdatu, "结束日
adatu LIKE anlz-adatu, "起始日
sernr LIKE anla-sernr, "序列号
invnr LIKE anla-invnr,
anlhtxt LIKE anlh-ANLHTXT,
END OF gs_out.
DATA:gt_anla LIKE TABLE OF gs_anla,
gt_anlz LIKE TABLE OF gs_anlz,
gt_csks LIKE TABLE OF gs_csks,
gt_anlh LIKE TABLE OF gs_anlh,
gt_cskt LIKE TABLE OF gs_cskt,
gt_out LIKE TABLE OF gs_out.
DATA: gs_fieldcat TYPE slis_fieldcat_alv,
gt_fieldcat LIKE TABLE OF gs_fieldcat.
DATA: gs_layout TYPE slis_layout_alv.
DATA: gw_options TYPE ssfcompop,
gw_control TYPE ssfctrlop.
DATA:gs_zpps008 TYPE zpps008,
gt_zpps008 LIKE TABLE OF gs_zpps008.
DATA:gs_zpps008s TYPE zpps008s,
gt_zpps008s LIKE TABLE OF gs_zpps008s.
*ZPPS008S
*&---------------------------------------------------------------------*
*& 包含 ZPPF006_SCR
*&---------------------------------------------------------------------*
SELECT-OPTIONS:s_bukrs FOR anla-bukrs.
SELECT-OPTIONS:s_anln1 FOR anla-anln1.
SELECT-OPTIONS:s_txt50 FOR anla-txt50.
SELECT-OPTIONS:s_gdlgrp FOR anla-gdlgrp.
SELECT-OPTIONS:s_aktiv FOR anla-aktiv.
SELECT-OPTIONS:s_kostl FOR csks-kostl.
SELECT-OPTIONS:s_sernr FOR anla-sernr.
*&---------------------------------------------------------------------*
*& 包含 ZPPF006_FRM
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_get_data .
CLEAR:gt_anla.
DATA:lv_tabix LIKE sy-tabix.
SELECT bukrs anln1 txt50 gdlgrp aktiv lifnr txa50 sernr invnr
INTO TABLE gt_anla
FROM anla
WHERE bukrs IN s_bukrs
AND anln1 IN s_anln1
AND txt50 IN s_txt50
AND gdlgrp IN s_gdlgrp
AND aktiv IN s_aktiv
AND sernr IN s_sernr.
SORT gt_anla BY anln1.
DELETE ADJACENT DUPLICATES FROM gt_anla COMPARING anln1.
IF gt_anlz[] IS NOT INITIAL.
SELECT kostl verak INTO TABLE gt_csks
FROM csks
FOR ALL ENTRIES IN gt_anlz
WHERE kostl = gt_anlz-kostl.
* AND datbi = '99991231'.
ENDIF.
IF gt_anla[] IS NOT INITIAL.
SELECT anln1 kostl bdatu adatu INTO TABLE gt_anlz FROM anlz FOR ALL ENTRIES IN gt_anla
WHERE anln1 = gt_anla-anln1
AND kostl IN s_kostl
AND bdatu = '99991231'.
ENDIF.
IF s_kostl[] IS NOT INITIAL.
LOOP AT gt_anla INTO gs_anla.
lv_tabix = sy-tabix.
READ TABLE gt_anlz WITH KEY anln1 = gs_anla-anln1
TRANSPORTING NO FIELDS.
IF sy-subrc <> 0.
DELETE gt_anla INDEX lv_tabix.
CONTINUE.
CLEAR:lv_tabix.
ENDIF.
ENDLOOP.
ENDIF.
IF gt_anla[] IS NOT INITIAL.
SELECT partner name_org1 INTO TABLE gt_but000 FROM but000
FOR ALL ENTRIES IN gt_anla
WHERE partner = gt_anla-lifnr.
ENDIF.
IF gt_anla[] IS NOT INITIAL.
SELECT kostl ltext INTO TABLE gt_cskt FROM cskt
FOR ALL ENTRIES IN gt_anlz
WHERE kostl = gt_anlz-kostl.
ENDIF.
IF gt_anlz[] IS NOT INITIAL.
SELECT kostl verak INTO TABLE gt_csks
FROM csks
FOR ALL ENTRIES IN gt_anlz
WHERE kostl = gt_anlz-kostl.
* AND datbi = '99991231'.
IF gt_anla[] IS NOT INITIAL.
SELECT anln1 anlhtxt INTO TABLE gt_anlh
FROM anlh
FOR ALL ENTRIES IN gt_anla
WHERE anln1 = gt_anla-anln1.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_PROCESS_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_process_data .
SORT gt_anla BY anln1.
SORT gt_anlz BY anln1.
SORT gt_csks BY kostl.
SORT gt_anlh BY anln1.
SORT gt_cskt BY kostl.
SORT gt_but000 BY partner.
CLEAR:gs_anla,gs_anlz, gs_csks,gs_anlh ,gs_cskt.
CLEAR:gs_but000.
LOOP AT gt_anla INTO gs_anla.
gs_out-bukrs = gs_anla-bukrs.
gs_out-anln1 = gs_anla-anln1.
gs_out-txt50 = gs_anla-txt50.
gs_out-gdlgrp = gs_anla-gdlgrp.
gs_out-aktiv = gs_anla-aktiv.
gs_out-txa50 = gs_anla-txa50.
gs_out-sernr = gs_anla-sernr.
gs_out-invnr = gs_anla-invnr.
* gs_out-liefe = gs_anla-liefe.
CLEAR:gs_but000.
READ TABLE gt_but000 INTO gs_but000
WITH KEY partner = gs_anla-lifnr
BINARY SEARCH.
IF sy-subrc EQ 0 .
gs_out-name_org1 = gs_but000-name_org1.
ENDIF.
READ TABLE gt_anlz INTO gs_anlz
WITH KEY anln1 = gs_anla-anln1
BINARY SEARCH.
IF sy-subrc EQ 0.
gs_out-kostl = gs_anlz-kostl.
gs_out-bdatu = gs_anlz-bdatu.
gs_out-adatu = gs_anlz-adatu.
READ TABLE gt_csks INTO gs_csks
WITH KEY kostl = gs_anlz-kostl
BINARY SEARCH.
IF sy-subrc EQ 0.
* gs_out-name1 = gs_csks-name1.
gs_out-verak = gs_csks-verak.
* gs_out-datbi = gs_csks-datbi.
* gs_out-datab = gs_csks-datab.
READ TABLE gt_cskt INTO gs_cskt
WITH KEY kostl = gs_anlz-kostl
BINARY SEARCH.
IF sy-subrc EQ 0.
gs_out-ltext = gs_cskt-ltext.
ENDIF.
ENDIF.
ENDIF.
READ TABLE gt_anlh INTO gs_anlh
WITH KEY anln1 = gs_anla-anln1
BINARY SEARCH.
IF sy-subrc EQ 0.
gs_out-anlhtxt = gs_anlh-anlhtxt.
ENDIF.
APPEND gs_out TO gt_out.
CLEAR:gs_out.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_DISPLAY_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_display_data .
CLEAR: gt_fieldcat.
DEFINE append_field.
gs_fieldcat-fieldname = &1.
gs_fieldcat-seltext_l = &2.
IF &1 EQ 'ANLN1'.
gs_fieldcat-ref_fieldname = &1.
gs_fieldcat-ref_tabname = 'ANLA'.
ENDIF.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR: gs_fieldcat.
END-OF-DEFINITION.
append_field:'BUKRS' '公司代码'.
append_field:'ANLN1' '主资产号'.
append_field:'TXT50' '资产品名'.
append_field:'SERNR' '序列号'.
append_field:'invnr' '存货号'.
append_field:'ADATU' '起始日期'.
append_field:'BDATU' '截止日期'.
append_field:'GDLGRP' '购置日期'.
append_field:'AKTIV' '资产资本化日期'.
append_field:'NAME_ORG1' '供应商'.
append_field:'KOSTL' '成本中心'.
append_field:'LTEXT' '使用部门'.
append_field:'VERAK' '负责人'.
append_field:'TXA50' '规格型号'.
gs_layout-box_fieldname = 'MARK'.
gs_layout-colwidth_optimize = 'X'.
gs_layout-zebra = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = gs_layout
it_fieldcat = gt_fieldcat
i_callback_pf_status_set = 'FRM_STATUS_SET'
i_callback_user_command = 'FRM_USER_COMMAND'
TABLES
t_outtab = gt_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
FORM frm_status_set
USING ut_extab TYPE slis_t_extab.
SET PF-STATUS 'STANDARD'.
ENDFORM.
FORM frm_user_command USING uv_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
IF uv_ucomm EQ 'PRINT3'.
PERFORM:frm_out_data .
ELSEIF uv_ucomm EQ 'PRINT2'.
PERFORM:frm_out2_data .
ELSE.
PERFORM:frm_out1_data.
ENDIF.
ENDFORM.
FORM frm_out_data .
DATA: lv_fname TYPE rs38l_fnam.
DATA:BEGIN OF gs_itab OCCURS 0,
anln1 TYPE anln1,
mark,
END OF gs_itab.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
* GS_OUTPUT_OPTIONS-TDDEST = 'FrontEnd Printer'.
* GS_OUTPUT_OPTIONS-TDDELETE = 'X'.
* GS_OUTPUT_OPTIONS-TDIMMED = 'X'.
* GS_CONTROL_PARAMETERS-PREVIEW = ''.
* GS_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
* EXPORTING
* CONTROL_PARAMETERS = GS_CONTROL_PARAMETERS
* OUTPUT_OPTIONS = GS_OUTPUT_OPTIONS
formname = 'ZPPF0008'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
fm_name = lv_fname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
* ENDIF.
* LOOP AT gt_out INTO gs_zpps008 WHERE mark = 'X' ."AND anln1 EQ gs_itab-anln1 .
* APPEND gs_zpps008 TO gt_zpps008.
** ENDLOOP.
* ENDLOOP.
* CALL FUNCTION lv_fname
* TABLES
* it_zpps008 = gt_zpps008
* EXCEPTIONS
* formatting_error = 1
* internal_error = 2
* send_error = 3
* user_canceled = 4
* OTHERS = 5.
*
* IF sy-subrc <> 0.
** Implement suitable error handling here
* ENDIF.
* CLEAR:gs_zpps008,gt_zpps008.
*ENDLOOP.
*
*ENDFORM.
ELSE.
gw_options-tdnewid = 'X'. "New Spool
gw_options-tdimmed = 'X'.
gw_options-tddelete = 'X'. "Delete Spool After Print
gw_options-tdfinal = 'X'.
gw_options-tdiexit = 'X'. "Exit after printing in print preview
gw_options-tddest = 'LP01'.
gw_control-no_dialog = 'X'.
gw_control-preview = 'X'.
gw_control-no_open = 'X'.
gw_control-no_close = 'X'.
CALL FUNCTION 'SSF_OPEN' "打开打印窗口
EXPORTING
control_parameters = gw_control
output_options = gw_options
user_settings = ''
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
* DATA: lt_bseg LIKE TABLE OF gs_bseg.
* LOOP AT gt_bkpf INTO gs_bkpf.
LOOP AT gt_out INTO gs_zpps008 WHERE mark = 'X'.
gs_itab-anln1 = gs_zpps008-anln1.
gs_itab-mark = gs_zpps008-mark.
APPEND gs_itab.
CLEAR gs_itab.
ENDLOOP.
SORT gs_itab.
DELETE ADJACENT DUPLICATES FROM gs_itab.
LOOP AT gs_itab.
LOOP AT gt_out INTO gs_zpps008 WHERE mark = 'X' AND anln1 EQ gs_itab-anln1." WHERE belnr = gs_bkpf-belnr.
APPEND gs_zpps008 TO gt_zpps008.
ENDLOOP.
CALL FUNCTION lv_fname
EXPORTING
control_parameters = gw_control
output_options = gw_options
* is_bkpf = gs_bkpf
* IMPORTING
* job_output_info = l_end
* job_output_options = l_start
TABLES
it_zpps008 = gt_zpps008
* it_bkpf = lt_bkpf
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
CLEAR: gt_zpps008.
* ENDLOOP.
ENDLOOP.
CALL FUNCTION 'SSF_CLOSE'
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
OTHERS = 4.
*CLEAR: gt_zpps008.
ENDIF.
ENDFORM.
FORM frm_out1_data .
DATA: lv_fname TYPE rs38l_fnam.
DATA:BEGIN OF gs_itab OCCURS 0,
anln1 TYPE anln1,
mark,
END OF gs_itab.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
* GS_OUTPUT_OPTIONS-TDDEST = 'FrontEnd Printer'.
* GS_OUTPUT_OPTIONS-TDDELETE = 'X'.
* GS_OUTPUT_OPTIONS-TDIMMED = 'X'.
* GS_CONTROL_PARAMETERS-PREVIEW = ''.
* GS_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
* EXPORTING
* CONTROL_PARAMETERS = GS_CONTROL_PARAMETERS
* OUTPUT_OPTIONS = GS_OUTPUT_OPTIONS
formname = 'ZPPF0008A'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
fm_name = lv_fname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
* ENDIF.
* LOOP AT gt_out INTO gs_zpps008 WHERE mark = 'X' ."AND anln1 EQ gs_itab-anln1 .
* APPEND gs_zpps008 TO gt_zpps008.
** ENDLOOP.
* ENDLOOP.
* CALL FUNCTION lv_fname
* TABLES
* it_zpps008 = gt_zpps008
* EXCEPTIONS
* formatting_error = 1
* internal_error = 2
* send_error = 3
* user_canceled = 4
* OTHERS = 5.
*
* IF sy-subrc <> 0.
** Implement suitable error handling here
* ENDIF.
* CLEAR:gs_zpps008,gt_zpps008.
*ENDLOOP.
*
*ENDFORM.
ELSE.
gw_options-tdnewid = 'X'. "New Spool
gw_options-tdimmed = 'X'.
gw_options-tddelete = 'X'. "Delete Spool After Print
gw_options-tdfinal = 'X'.
gw_options-tdiexit = 'X'. "Exit after printing in print preview
gw_options-tddest = 'LP01'.
gw_control-no_dialog = 'X'.
gw_control-preview = 'X'.
gw_control-no_open = 'X'.
gw_control-no_close = 'X'.
CALL FUNCTION 'SSF_OPEN' "打开打印窗口
EXPORTING
control_parameters = gw_control
output_options = gw_options
user_settings = ''
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
* DATA: lt_bseg LIKE TABLE OF gs_bseg.
* LOOP AT gt_bkpf INTO gs_bkpf.
LOOP AT gt_out INTO gs_zpps008 WHERE mark = 'X'.
gs_itab-anln1 = gs_zpps008-anln1.
gs_itab-mark = gs_zpps008-mark.
APPEND gs_itab.
CLEAR gs_itab.
ENDLOOP.
SORT gs_itab.
DELETE ADJACENT DUPLICATES FROM gs_itab.
LOOP AT gs_itab.
LOOP AT gt_out INTO gs_zpps008 WHERE mark = 'X' AND anln1 EQ gs_itab-anln1." WHERE belnr = gs_bkpf-belnr.
APPEND gs_zpps008 TO gt_zpps008.
ENDLOOP.
CALL FUNCTION lv_fname
EXPORTING
control_parameters = gw_control
output_options = gw_options
* is_bkpf = gs_bkpf
* IMPORTING
* job_output_info = l_end
* job_output_options = l_start
TABLES
it_zpps008 = gt_zpps008
* it_bkpf = lt_bkpf
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
CLEAR: gt_zpps008.
* ENDLOOP.
ENDLOOP.
CALL FUNCTION 'SSF_CLOSE'
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
OTHERS = 4.
*CLEAR: gt_zpps008.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_OUT2_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_out2_data .
DATA: lv_fname TYPE rs38l_fnam.
DATA: lv_i TYPE i .
DATA: lv_mod TYPE i .
lv_i = 0 .
CLEAR gt_zpps008s[] .
LOOP AT gt_out INTO gs_out WHERE MARK EQ 'X' .
lv_i = lv_i + 1 .
lv_mod = lv_i MOD 2 .
IF lv_mod EQ 1 .
gs_zpps008s-bukrs = gs_out-bukrs .
gs_zpps008s-anln1 = gs_out-anln1.
gs_zpps008s-txt50 = gs_out-txt50 .
gs_zpps008s-gdlgrp = gs_out-gdlgrp .
gs_zpps008s-ltext = gs_out-ltext .
gs_zpps008s-TXA50 = gs_out-TXA50 .
ELSE .
gs_zpps008s-bukrs1 = gs_out-bukrs .
gs_zpps008s-anln11 = gs_out-anln1.
gs_zpps008s-txt501 = gs_out-txt50 .
gs_zpps008s-gdlgrp1 = gs_out-gdlgrp .
gs_zpps008s-ltext1 = gs_out-ltext .
gs_zpps008s-TXA501 = gs_out-TXA50 .
APPEND gs_zpps008s TO gt_zpps008s .
ENDIF.
ENDLOOP .
data: lx type i .
lx = 1 .
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZMMF008D'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
fm_name = lv_fname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION lv_fname
* EXPORTING
* is_zmmt001_head = gs_zmmt001_head
TABLES
it_zpps008s = gt_zpps008s
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
ENDFORM.
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq_39510046/article/details/125796869