*&---------------------------------------------------------------------*
*& Report ZMM009
*&---------------------------------------------------------------------*
*& 抬头 : 内向交货单打印 *
*& 模块 : MM *
*& 作者 : ZHANGS *
*& 创建日期 : 2019/02/19 *
*& 修改记录 : *
*& 日期 修改人 修改内容 *
*& YYYY/MM/DD 修改人员名 说明 *
*&---------------------------------------------------------------------*
REPORT zmm009.
TABLES:t001w,lfa1,ekko,likp,makt,t024,ekpo,lips,kona.
TYPES: BEGIN OF ty_itab,
werks TYPE lips-werks, "工厂
lifnr TYPE likp-lifnr, "供应商
name1 TYPE lfa1-name1, "供应商描述
matnr TYPE lips-matnr, "物料编码
maktx TYPE makt-maktx, "物料描述
vbeln TYPE lips-vbeln, "内向交货单 "重名
posnr TYPE lips-posnr, "行项目
lfimg TYPE lips-lfimg, "数量
meins TYPE lips-meins, "计量单位
lgort TYPE lips-lgort, "库位
lgobe TYPE t001l-lgobe, "库位描述
lfdat TYPE likp-lfdat, "交货日期
bldat TYPE likp-bldat, "凭证日期
lichn TYPE lips-lichn, "供应商批次
wbsta TYPE lips-wbsta, "是否已入库
ormng TYPE ekes-ormng, "已收货数量
vgbel TYPE lips-vgbel, "采购订单
vgpos TYPE lips-vgpos, "行项目
gvbeln TYPE ekkn-vbeln, "销售订单 "重名
vbelp TYPE ekkn-vbelp, "销售订单行项目
adrnr TYPE char50, "送货地址
ysum TYPE char50, "摘要
loekz TYPE ekpo-loekz,
elikz TYPE ekpo-elikz,
bednr TYPE ekpo-bednr, "需求跟踪号
submi TYPE ekko-submi, "bednr为空时需求跟踪号取submi
END OF ty_itab.
DATA:gt_itab TYPE TABLE OF ty_itab,
gs_itab TYPE ty_itab.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:s_werks FOR t001w-werks OBLIGATORY, "选择条件工厂
s_lifnr FOR lfa1-lifnr, "选择条件供应商
s_ebeln FOR ekko-ebeln, "选择条件采购订单
s_vbeln FOR likp-vbeln, "选择条件内向交货单
s_matnr FOR makt-matnr, "选择条件物料编码
s_eknam FOR kona-ekgrp, "选择条件采购组
s_bednr FOR ekpo-bednr. "需求跟踪号
SELECTION-SCREEN END OF BLOCK b1.
DATA:gt_fcat TYPE lvc_t_fcat,
ga_fcat TYPE lvc_s_fcat,
gs_layout TYPE lvc_s_layo,
gc_grid TYPE REF TO cl_gui_alv_grid.
DEFINE alv_field.
CLEAR ga_fcat.
ga_fcat-fieldname = &1. "内表的字段名
ga_fcat-ref_table = &2. "输出数据的内表名
ga_fcat-ref_field = &3. "为key
ga_fcat-scrtext_l = &4. "字段描述
ga_fcat-colddictxt = 'L'.
ga_fcat-checkbox = &5. "字段描述
ga_fcat-edit = &6. "字段描述
APPEND ga_fcat TO gt_fcat.
END-OF-DEFINITION.
"初始化
INITIALIZATION.
START-OF-SELECTION.
PERFORM frm_get_data. "USING CHANGING TABLES
PERFORM frm_display_alv.
FORM frm_get_data.
CLEAR gt_itab[].
SELECT lips~werks lips~matnr lips~vbeln lips~posnr lips~lfimg lips~meins lips~lgort lips~lichn lips~wbsta
lips~vgbel lips~vgpos lips~ormng lips~arktx AS maktx
likp~lifnr likp~lfdat likp~bldat
* MAKT~MAKTX
* ekes~dabmg
* T001L~LGOBE
* EKKN~VBELN AS GVBELN EKKN~VBELP
ekko~submi
FROM lips
INNER JOIN likp ON lips~vbeln EQ likp~vbeln "唯一确认
* INNER JOIN MAKT ON ( LIPS~MATNR EQ MAKT~MATNR AND SPRAS = SY-LANGU ) "唯一确认
* INNER JOIN ekes ON ( lips~vbeln EQ ekes~vbeln_st AND lips~posnr EQ ekes~vbelp_st )
* INNER JOIN T001L ON ( LIPS~WERKS EQ T001L~WERKS AND LIPS~LGORT EQ T001L~LGORT ) "唯一确认
* INNER JOIN EKKN ON ( EKKN~EBELN EQ LIPS~VGBEL AND EKKN~EBELP EQ LIPS~VGPOS )
INNER JOIN ekko ON ( lips~vgbel EQ ekko~ebeln ) "唯一确认
* INNER JOIN EKPO ON ( LIPS~VGBEL EQ EKPO~EBELN AND LIPS~VGPOS EQ EKPO~EBELP ) "唯一确认
INTO CORRESPONDING FIELDS OF TABLE gt_itab
WHERE lips~werks IN s_werks "工厂
AND likp~lifnr IN s_lifnr "供应商
* AND ekko~ebeln IN s_ebeln "采购订单
AND lips~vgbel IN s_ebeln "采购订单
AND lips~vbeln IN s_vbeln "内向交货单
AND lips~matnr IN s_matnr "物料编码
AND ekko~ekgrp IN s_eknam."采购组
* AND EKPO~LOEKZ EQ P_LOEKZ "采购凭证删除标识
* AND EKPO~ELIKZ EQ P_ELIKZ."交货已完成标识
CHECK gt_itab IS NOT INITIAL.
DATA:lt_itab TYPE TABLE OF ty_itab.
*---从EKPO取数
* INNER JOIN EKPO ON ( LIPS~VGBEL EQ EKPO~EBELN AND LIPS~VGPOS EQ EKPO~EBELP ) "唯一确认
TYPES: BEGIN OF lty_itab06,
ebelp TYPE ekpo-ebelp,
ebeln TYPE ekpo-ebeln,
loekz TYPE ekpo-loekz,
elikz TYPE ekpo-elikz,
bednr TYPE ekpo-bednr,
END OF lty_itab06.
DATA:lt_ekpoitab TYPE TABLE OF lty_itab06,
ls_ekpoitab TYPE lty_itab06.
SELECT ebeln ebelp loekz elikz bednr
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE lt_ekpoitab
FOR ALL ENTRIES IN gt_itab
WHERE ebeln EQ gt_itab-vgbel.
* AND bednr IN ( s_bednr.
SORT lt_ekpoitab BY ebeln ebelp.
CHECK gt_itab IS NOT INITIAL.
*---从LFA1取NAME1
TYPES: BEGIN OF lty_itab04,
lifnr TYPE lfa1-lifnr,
name1 TYPE lfa1-name1,
END OF lty_itab04.
DATA:lt_lfa1itab TYPE TABLE OF lty_itab04,
ls_lfa1itab TYPE lty_itab04.
SELECT name1
lifnr
FROM lfa1
INTO CORRESPONDING FIELDS OF TABLE lt_lfa1itab
FOR ALL ENTRIES IN gt_itab
WHERE lifnr EQ gt_itab-lifnr.
SORT lt_lfa1itab BY lifnr.
*--从TWLAD取送货地址
TYPES: BEGIN OF lty_itab03,
werks TYPE twlad-werks,
lgort TYPE twlad-lgort,
adrnr TYPE twlad-adrnr,
END OF lty_itab03.
DATA:lt_twladitab TYPE TABLE OF lty_itab03,
ls_twladitab TYPE lty_itab03.
SELECT werks lgort adrnr
FROM twlad
INTO CORRESPONDING FIELDS OF TABLE lt_twladitab
FOR ALL ENTRIES IN gt_itab
WHERE werks = gt_itab-werks
AND lgort = gt_itab-lgort
AND lfdnr = '000'.
SORT lt_twladitab BY werks lgort.
IF lt_twladitab[] IS NOT INITIAL.
TYPES: BEGIN OF lty_adrc,
addrnumber TYPE adrc-addrnumber,
city1 TYPE adrc-city1,
street TYPE adrc-street,
house_num1 TYPE adrc-house_num1,
END OF lty_adrc.
DATA:lt_adrc TYPE TABLE OF lty_adrc,
ls_adrc TYPE lty_adrc.
SELECT addrnumber city1 street house_num1
FROM adrc
INTO CORRESPONDING FIELDS OF TABLE lt_adrc
FOR ALL ENTRIES IN lt_twladitab
WHERE addrnumber = lt_twladitab-adrnr.
SORT lt_adrc BY addrnumber.
ENDIF.
*---从MAKT取数
* MAKT~MAKTX
* INNER JOIN MAKT ON ( LIPS~MATNR EQ MAKT~MATNR AND SPRAS = SY-LANGU ) "唯一确认
* TYPES: BEGIN OF lty_itab02,
* matnr TYPE makt-matnr,
* maktx TYPE makt-maktx,
* END OF lty_itab02.
* DATA:lt_maktitab TYPE TABLE OF lty_itab02,
* ls_maktitab TYPE lty_itab02.
* SELECT maktx
* matnr
* FROM makt
* INTO CORRESPONDING FIELDS OF TABLE lt_maktitab
* FOR ALL ENTRIES IN gt_itab
* WHERE matnr EQ gt_itab-matnr
* AND spras = sy-langu.
* SORT lt_maktitab BY matnr.
*---从T001L取数
* T001L~LGOBE
* INNER JOIN T001L ON ( LIPS~WERKS EQ T001L~WERKS AND LIPS~LGORT EQ T001L~LGORT ) "唯一确认
TYPES: BEGIN OF lty_itab05,
werks TYPE t001l-werks,
lgort TYPE t001l-lgort,
lgobe TYPE t001l-lgobe,
END OF lty_itab05.
DATA:lt_t001litab TYPE TABLE OF lty_itab05,
ls_t001litab TYPE lty_itab05.
SELECT lgobe
werks
lgort
FROM t001l
INTO CORRESPONDING FIELDS OF TABLE lt_t001litab
FOR ALL ENTRIES IN gt_itab
WHERE werks EQ gt_itab-werks
AND lgort EQ gt_itab-lgort.
SORT lt_t001litab BY werks lgort.
*---从ekkn取数
* EKKN~VBELN AS GVBELN EKKN~VBELP
* INNER JOIN EKKN ON ( EKKN~EBELN EQ LIPS~VGBEL AND EKKN~EBELP EQ LIPS~VGPOS )
TYPES: BEGIN OF lty_itab01,
ebeln TYPE ekkn-ebeln,
ebelp TYPE lips-vgpos,
vbeln TYPE ekkn-vbeln,
vbelp TYPE ekkn-vbelp,
END OF lty_itab01.
DATA:lt_ekknitab TYPE TABLE OF lty_itab01,
ls_ekknitab TYPE lty_itab01.
SELECT ebeln
ebelp
vbeln
vbelp
FROM ekkn
INTO CORRESPONDING FIELDS OF TABLE lt_ekknitab
FOR ALL ENTRIES IN gt_itab
WHERE ebeln EQ gt_itab-vgbel
* AND ebelp = gt_itab-vgpos "因长度不同,不作为条件
AND zekkn = '01'.
SORT lt_ekknitab BY ebeln ebelp.
LOOP AT gt_itab INTO gs_itab.
READ TABLE lt_ekpoitab INTO ls_ekpoitab WITH KEY ebeln = gs_itab-vgbel ebelp = gs_itab-vgpos BINARY SEARCH.
IF sy-subrc IS INITIAL.
gs_itab-loekz = ls_ekpoitab-loekz.
gs_itab-elikz = ls_ekpoitab-elikz.
gs_itab-bednr = ls_ekpoitab-bednr.
IF ls_ekpoitab-bednr IS INITIAL.
gs_itab-bednr = gs_itab-submi.
ENDIF.
IF s_bednr IS NOT INITIAL.
IF gs_itab-bednr NOT IN s_bednr.
DELETE gt_itab WHERE vgbel = gs_itab-vgbel AND vgpos = gs_itab-vgpos.
CONTINUE.
ENDIF.
ENDIF.
* MODIFY gt_itab FROM gs_itab TRANSPORTING loekz elikz bednr.
ELSE.
DELETE gt_itab WHERE vgbel = gs_itab-vgbel AND vgpos = gs_itab-vgpos.
CONTINUE.
ENDIF.
READ TABLE lt_lfa1itab INTO ls_lfa1itab WITH KEY lifnr = gs_itab-lifnr BINARY SEARCH.
IF sy-subrc IS INITIAL.
gs_itab-name1 = ls_lfa1itab-name1.
* MODIFY gt_itab FROM gs_itab TRANSPORTING name1.
ENDIF.
* READ TABLE lt_maktitab INTO ls_maktitab WITH KEY matnr = gs_itab-matnr BINARY SEARCH.
* IF sy-subrc IS INITIAL.
* gs_itab-maktx = ls_maktitab-maktx.
* MODIFY gt_itab FROM gs_itab TRANSPORTING maktx.
* ENDIF.
READ TABLE lt_t001litab INTO ls_t001litab WITH KEY werks = gs_itab-werks lgort = gs_itab-lgort BINARY SEARCH.
IF sy-subrc IS INITIAL.
gs_itab-lgobe = ls_t001litab-lgobe.
* MODIFY gt_itab FROM gs_itab TRANSPORTING lgobe.
ENDIF.
"
READ TABLE lt_twladitab INTO ls_twladitab WITH KEY werks = gs_itab-werks lgort = gs_itab-lgort BINARY SEARCH.
IF sy-subrc IS INITIAL.
READ TABLE lt_adrc INTO ls_adrc WITH KEY addrnumber = ls_twladitab-adrnr BINARY SEARCH.
IF sy-subrc IS INITIAL.
CONCATENATE ls_adrc-city1 ls_adrc-street ls_adrc-house_num1 INTO gs_itab-adrnr.
ENDIF.
* MODIFY gt_itab FROM gs_itab TRANSPORTING adrnr.
ENDIF.
READ TABLE lt_ekknitab INTO ls_ekknitab WITH KEY ebeln = gs_itab-vgbel ebelp = gs_itab-vgpos BINARY SEARCH.
IF sy-subrc IS INITIAL.
gs_itab-gvbeln = ls_ekknitab-vbeln.
gs_itab-vbelp = ls_ekknitab-vbelp.
ENDIF.
"摘要长文本
PERFORM frm_read_text USING gs_itab-vgbel ls_ekpoitab-ebelp 'F01' 'EKPO' CHANGING gs_itab-ysum.
MODIFY gt_itab FROM gs_itab TRANSPORTING loekz elikz bednr name1 lgobe adrnr gvbeln vbelp ysum.
CLEAR:gs_itab,ls_lfa1itab,ls_t001litab,ls_ekpoitab,ls_ekknitab,ls_twladitab,ls_adrc.
ENDLOOP.
SORT gt_itab BY werks lifnr.
*---从EKES取DABMG
* ekes~dabmg
* INNER JOIN ekes ON ( lips~vbeln EQ ekes~vbeln_st AND lips~posnr EQ ekes~vbelp_st )
* TYPES: BEGIN OF lty_itab,
* vbeln_st TYPE ekes-vbeln_st,
* vbelp_st TYPE ekes-vbelp_st,
* dabmg TYPE ekes-dabmg,
* END OF lty_itab.
* DATA:lt_ekesitab TYPE TABLE OF lty_itab,
* ls_ekesitab TYPE lty_itab.
* SELECT dabmg
* vbelp_st
* vbeln_st
* FROM ekes
* INTO CORRESPONDING FIELDS OF TABLE lt_ekesitab
* FOR ALL ENTRIES IN gt_itab
* WHERE vbelp_st EQ gt_itab-posnr
* AND vbeln_st EQ gt_itab-vbeln.
ENDFORM.
FORM frm_display_alv.
CLEAR: gs_layout.
gs_layout-zebra = 'X'.
gs_layout-sel_mode = 'A'.
gs_layout-cwidth_opt = 'X'.
* GS_LAYOUT-BOX_FNAME = 'SEL'.
PERFORM frm_get_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
* i_grid_title = lv_grid_title
* I_BUFFER_ACTIVE = 'X'
i_default = 'X'
i_save = 'X'
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
it_fieldcat_lvc = gt_fcat[]
is_layout_lvc = gs_layout
* it_events = lt_event
TABLES
t_outtab = gt_itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.
FORM frm_get_fieldcat .
REFRESH gt_fcat.
alv_field: 'WERKS' 'LIPS' 'MATNR' '工厂' ' ' ''.
alv_field: 'LIFNR' 'LIKP' 'LIFNR' '供应商' ' ' ''.
alv_field: 'NAME1' 'LFA1' 'NAME1' '供应商描述' ' ' ''.
alv_field: 'MATNR' 'LIPS' 'MATNR' '物料编码' ' ' ''.
alv_field: 'MAKTX' 'MAKT' 'MAKTX' '物料描述' ' ' ''.
alv_field: 'VBELN' 'LIPS' 'VBELN' '内向交货单' ' ' ''.
alv_field: 'POSNR' 'LIPS' 'POSNR' '行项目' ' ' ''.
alv_field: 'LFIMG' 'LIPS' 'LFIMG' '数量' ' ' ''.
alv_field: 'MEINS' 'LIPS' 'MEINS' '基本计量单位' ' ' ''.
alv_field: 'LGORT' 'LIPS' 'LGORT' '库位' ' ' ''.
alv_field: 'LGOBE' 'T001L' 'LGOBE' '库位描述' ' ' ''.
alv_field: 'LFDAT' 'LIKP' 'LFDAT' '交货日期' ' ' ''.
alv_field: 'BLDAT' 'LIKP' 'BLDAT' '凭证日期' ' ' ''.
alv_field: 'LICHN' 'LIPS' 'LICHN' '供应商批次' ' ' ''.
alv_field: 'WBSTA' 'LIPS' 'WBSTA' '是否已入库' ' ' ''.
alv_field: 'ORMNG' 'LIPS' 'ORMNG' '已收货数量' ' ' ''.
alv_field: 'VGBEL' 'LIPS' 'VGBEL' '采购订单' ' ' ''.
alv_field: 'VGPOS' 'LIPS' 'VGPOS' '行项目' ' ' ''.
alv_field: 'GVBELN' 'EKKN' 'VBELN' '销售订单' ' ' ''.
alv_field: 'VBELP' 'EKKN' 'VBELP' '行项目' ' ' ''.
alv_field: 'YSUM' '' '' '摘要' ' ' ''.
alv_field: 'BEDNR' 'EKPO' 'BEDNR' '需求跟踪号' ' ' ''.
alv_field: 'LOEKZ' 'EKPO' 'LOEKZ' '采购凭证删除标识' ' ' ''.
alv_field: 'ELIKZ' 'EKPO' 'ELIKZ' '交货已完成标识' ' ' ''.
ENDFORM.
FORM set_pf_status USING rt_extab TYPE slis_t_extab."调用SAP标准功能的工具栏图标,例排序、筛选、小计等功能
SET PF-STATUS 'ZMM009'. "双击单引号里面的,新建一个同名的状态,也可以去在别的reportcopy一个标准的
" "再加上自己定义的按钮。比如program name : RM07MLBS
ENDFORM.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = gc_grid.
CALL METHOD gc_grid->check_changed_data.
rs_selfield-refresh = 'X'.
CASE r_ucomm.
WHEN 'PRINT'.
PERFORM frm_print.
ENDCASE.
ENDFORM.
FORM frm_print .
DATA: lt_row_index TYPE lvc_t_row,
lt_row_no TYPE lvc_t_roid,
ls_row_no TYPE lvc_s_roid,
lt_itab TYPE TABLE OF ty_itab,
ls_itab TYPE ty_itab,
lv_lines TYPE i.
DATA: lt_item TYPE TABLE OF zmms008,
ls_item TYPE zmms008,
ls_header TYPE zmms007.
DATA: lv_form TYPE tdsfname.
* smartform调用定义
DATA: lw_output_options TYPE ssfcompop,
lw_control_parameters TYPE ssfctrlop,
lv_fmname TYPE rs38l_fnam,
lw_output_options1 TYPE ssfcompop,
lw_control_parameters1 TYPE ssfctrlop,
lv_fmname1 TYPE rs38l_fnam,
lt_errortab TYPE tsferror,
outopt TYPE ssfcresop.
* 打印内表定义
TYPES: BEGIN OF typ_dn,
bldat TYPE likp-bldat, "制单日期
vbeln TYPE lips-vbeln, "单号
lifnr TYPE char100, "供应商:LFA1-LIFNR LFA1-NAME1
adrnr TYPE char50, "送货地址
END OF typ_dn.
DATA: lt_dn TYPE TABLE OF typ_dn,
ls_dn TYPE typ_dn.
DATA:l_lifnr TYPE char50. "供应商 LFA1-LIFNR + LFA1-NAME1
CALL METHOD gc_grid->get_selected_rows
IMPORTING
* ET_INDEX_ROWS = LT_ROW_INDEX
et_row_no = lt_row_no.
DESCRIBE TABLE lt_row_no LINES lv_lines.
IF lv_lines EQ 0.
MESSAGE '请选择要打印的条目' TYPE 'E'.
EXIT.
ENDIF.
REFRESH lt_itab.
lt_itab[] = gt_itab[].
SORT lt_itab BY vbeln lifnr adrnr.
CLEAR ls_row_no.
LOOP AT lt_row_no INTO ls_row_no. "记录行号
CLEAR:gs_itab,l_lifnr,ls_dn.
READ TABLE lt_itab INTO gs_itab INDEX ls_row_no-row_id.
ls_dn-bldat = gs_itab-bldat.
ls_dn-vbeln = gs_itab-vbeln.
CONCATENATE gs_itab-lifnr '/' gs_itab-name1 INTO l_lifnr.
ls_dn-lifnr = l_lifnr.
ls_dn-adrnr = gs_itab-adrnr.
READ TABLE lt_dn INTO ls_dn WITH KEY vbeln = gs_itab-vbeln
adrnr = gs_itab-adrnr.
IF sy-subrc NE 0.
APPEND ls_dn TO lt_dn.
ENDIF.
ENDLOOP.
lv_form = 'ZMMF009'.
PERFORM start_sf USING lv_form CHANGING lw_output_options
lw_control_parameters
lv_fmname.
CLEAR ls_dn.
LOOP AT lt_dn INTO ls_dn.
CLEAR:ls_item,gs_itab,lt_item[].
SORT gt_itab BY vbeln adrnr.
LOOP AT lt_itab INTO gs_itab WHERE vbeln = ls_dn-vbeln
AND adrnr = ls_dn-adrnr.
CLEAR:ls_itab,ls_header.
ls_header-bldat = ls_dn-bldat.
ls_header-vbeln = ls_dn-vbeln.
ls_header-lifnr = ls_dn-lifnr.
ls_header-adrnr = ls_dn-adrnr.
MOVE-CORRESPONDING gs_itab TO ls_item.
IF gs_itab-vgpos NE ''.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = gs_itab-vgpos
IMPORTING
output = gs_itab-vgpos.
ENDIF.
CONCATENATE gs_itab-vgbel '/' gs_itab-vgpos INTO ls_item-vgbel. "采购订单/行项目
ls_item-gvbeln = gs_itab-gvbeln. "销售订单
APPEND ls_item TO lt_item.
ENDLOOP.
SORT lt_item BY posnr matnr.
* 调用SF
CALL FUNCTION lv_fmname
EXPORTING
control_parameters = lw_control_parameters
output_options = lw_output_options
job_output_options = outopt "输出参数
is_head = ls_header "自定义输出抬头
TABLES
it_item = lt_item "自定义输出表体
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR ls_dn.
ENDLOOP.
PERFORM end_sf TABLES lt_errortab USING 'X'.
ENDFORM.
FORM start_sf USING p_gc_sfname TYPE tdsfname
CHANGING p_lw_output_options TYPE ssfcompop
p_lw_control_parameters TYPE ssfctrlop
p_lv_fmname TYPE rs38l_fnam.
CLEAR:p_lw_output_options,p_lw_control_parameters,p_lv_fmname.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_gc_sfname
IMPORTING
fm_name = p_lv_fmname.
p_lw_control_parameters-no_open = 'X'.
p_lw_control_parameters-no_close = 'X'.
* p_lw_control_parameters-no_dialog = 'X'.
* p_lw_control_parameters-getotf = 'X'.
* P_LW_OUTPUT_OPTIONS-TDDEST = 'LP01'.
* p_lw_output-tdprinter = 'Microsoft Office Document Image Writer'.
p_lw_output_options-rqposname = ''.
p_lw_output_options-tddataset = ''.
p_lw_output_options-tdsuffix1 = ''.
p_lw_output_options-tdsuffix2 = ''.
p_lw_output_options-tdimmed = 'X'.
p_lw_output_options-tddelete = 'X'.
* p_lw_output_options-tdnoprev = 'X'.
CALL FUNCTION 'SSF_OPEN'
EXPORTING
control_parameters = p_lw_control_parameters
output_options = p_lw_output_options
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
ENDFORM.
FORM end_sf TABLES p_lt_errortab TYPE tsferror
USING p_flag TYPE c.
DATA: otf TYPE tsfotf.
DATA: g_job_output_info TYPE ssfcrescl.
CALL FUNCTION 'SSF_CLOSE'
IMPORTING
job_output_info = g_job_output_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
OTHERS = 4.
IF g_job_output_info-outputdone = 'X'.
"只有打印 和合并打印的时候需更新
IF p_flag = 'X'.
ENDIF.
ENDIF.
CALL FUNCTION 'SSF_READ_ERRORS'
IMPORTING
errortab = p_lt_errortab[].
otf[] = g_job_output_info-otfdata[].
CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'
EXPORTING
i_otf = otf
EXCEPTIONS
convert_otf_to_pdf_error = 1
cntl_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
FORM frm_read_text USING p_vbeln
p_posnr
p_id
p_object
CHANGING p_beizu.
DATA: lt_tdline LIKE TABLE OF tline,
ls_tdline TYPE tline,
lv_tdname TYPE thead-tdname.
CLEAR:lt_tdline.
lv_tdname = p_vbeln && p_posnr.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = p_id
language = sy-langu
name = lv_tdname
object = p_object
TABLES
lines = lt_tdline
EXCEPTIONS
id = 01
language = 02
name = 03
not_found = 04
object = 05
reference_check = 06
wrong_access_to_archive = 07.
IF lt_tdline IS NOT INITIAL.
LOOP AT lt_tdline INTO ls_tdline.
CONCATENATE p_beizu ls_tdline-tdline INTO p_beizu.
ENDLOOP.
ENDIF.
ENDFORM.