ABAP 出库单打印 产品 A搭A A搭B显示方式
*&---------------------------------------------------------------------*
*& Report
*&
*&---------------------------------------------------------------------*
*&程序名称:
*&事物代码:
*&导入模板:无
*&作者:
*&时间:2016/5/18
*&--------------------------------------------------------------------
REPORT zsdr045.
INCLUDE zsdr045_inc.
*INCLUDE zsdr007_inc.
TYPE-POOLS: slis.
TABLES:likp, kna1, lips ,mkpf ,mseg ,vttp,vbak.
TYPES: BEGIN OF ty_all,
vbelv LIKE vbfa-vbelv , "销售订单号
tknum LIKE vttp-tknum, "装运单号
auart LIKE vbak-auart, "销售订单类型
auart_txt LIKE tvakt-bezei, "销售订单类型描述
vkorg LIKE vbak-vkorg, "销售组织
vtweg LIKE vbak-vtweg, "分销渠道
lfart LIKE likp-lfart, "交货类型
lfart_txt LIKE tvlkt-vtext, "交货类型描述
vbeln_im LIKE lips-vbeln , "交货单号
mblnr LIKE mseg-mblnr, "物料凭证
shkzg LIKE mseg-shkzg, "借贷标识
zeile LIKE mseg-zeile, "凭证项目
smbln LIKE mseg-smbln, "参考物料凭证
smblp LIKE mseg-smblp, "参考物料项目
bwart LIKE mseg-bwart, "移动类型
kunag LIKE likp-kunag , "客户
kunag_txt LIKE kna1-name1, "客户名称
kunnr LIKE likp-kunnr , "送达方
kunnr_txt LIKE kna1-name1, "送达方名称
stras LIKE kna1-stras , "客户地址
budat_mkpf LIKE mseg-budat_mkpf , "出库日期
cputm_mkpf LIKE mseg-cputm_mkpf , "输入时间
telf1 LIKE kna1-telf1 , "电话
usnam_mkpf LIKE mseg-usnam_mkpf , "经办人
name_last LIKE adrp-name_last, "创建者姓
name_first LIKE adrp-name_first, "创建者名
matnr LIKE lips-matnr , "物料编码
arktx LIKE lips-arktx , "物料描述
werks LIKE mseg-werks, "工厂
lgort LIKE mseg-lgort , "库存地点
menge LIKE mseg-menge , "数量
vrkme LIKE lips-vrkme , "单位
charg LIKE mseg-charg , "批次
vbelp_im LIKE mseg-vbelp_im , "物料项目
pstyv LIKE lips-pstyv, "行项目类别
uecha LIKE lips-uecha, "上层项目号
bolnr LIKE likp-bolnr , "物流单号
brgew LIKE lips-brgew, "单项目毛重
gewei LIKE lips-gewei, "单项目毛重单位
"printed TYPE c,"是否已打印
count_prt TYPE i, "记录此交货单打印次数
beizhu(20) TYPE c , "备注
END OF ty_all.
TYPES:BEGIN OF ty_header,
vbelv LIKE vbfa-vbelv , "销售订单号
"tknum LIKE vttp-tknum, "装运单号
auart LIKE vbak-auart, "销售订单类型
auart_txt LIKE tvakt-bezei, "销售订单类型描述
vkorg LIKE vbak-vkorg, "销售组织
vtweg LIKE vbak-vtweg, "分销渠道
lfart LIKE likp-lfart, "交货类型
lfart_txt LIKE tvlkt-vtext, "交货类型描述
vbeln_im LIKE mseg-vbeln_im , "交货单号
mblnr LIKE mseg-mblnr, "物料凭证
shkzg LIKE mseg-shkzg, "借贷标识
budat_mkpf LIKE mseg-budat_mkpf , "出库日期
cputm_mkpf LIKE mseg-cputm_mkpf , "输入时间
kunag LIKE likp-kunag , "客户
kunag_txt LIKE kna1-name1, "客户名称
kunnr LIKE likp-kunnr , "送达方
kunnr_txt LIKE kna1-name1, "送达方名称
lgort LIKE mseg-lgort , "库存地点
werks LIKE mseg-werks, "工厂
stras LIKE kna1-stras , "客户地址
telf1 LIKE kna1-telf1 , "电话
usnam_mkpf LIKE mseg-usnam_mkpf , "经办人
name_last LIKE adrp-name_last, "创建者姓
name_first LIKE adrp-name_first, "创建者名
total_brgew LIKE lips-brgew, "项目总毛重
bolnr LIKE likp-bolnr, "物流单号
count_prt TYPE i, "记录此交货单打印次数
beizhu(60) TYPE c , "备注
END OF ty_header.
TYPES:BEGIN OF ty_items,
vbelv LIKE vbfa-vbelv , "销售订单号
vbeln_im LIKE mseg-vbeln_im , "交货单号
lfart LIKE likp-lfart, "交货类型
shkzg LIKE mseg-shkzg, "借贷标识
budat_mkpf LIKE mseg-budat_mkpf , "出库日期
cputm_mkpf LIKE mseg-cputm_mkpf , "输入时间
mblnr LIKE mseg-mblnr, "物料凭证
matnr LIKE mseg-matnr , "物料编码
arktx LIKE lips-arktx , "物料描述
lgort LIKE mseg-lgort , "库存地点
menge LIKE mseg-menge , "数量
vrkme LIKE lips-vrkme , "单位
charg LIKE mseg-charg , "批次
vbelp_im LIKE mseg-vbelp_im , "项目
pstyv LIKE lips-pstyv, "行项目类别
uecha LIKE lips-uecha, "上层项目号
pstyv_txt LIKE tvapt-vtext, "类别描述
brgew LIKE lips-brgew, "单项目毛重
gewei LIKE lips-gewei, "单项目毛重单位
bolnr LIKE likp-bolnr , "物流单号
beizhu(45) TYPE c , "备注
END OF ty_items.
TYPES:BEGIN OF ty_items_n,
vbelv LIKE vbfa-vbelv , "销售订单号
vbeln_im LIKE mseg-vbeln_im , "交货单号
matnr LIKE mseg-matnr , "物料编码
arktx LIKE lips-arktx , "物料描述
menge1 LIKE mseg-menge , "本品数量
menge2 LIKE mseg-menge , "赠品数量
menge3 LIKE mseg-menge , "总计数量
vrkme LIKE lips-vrkme , "单位
"vbelp_im LIKE mseg-vbelp_im , "项目
"pstyv LIKE lips-pstyv, "行项目类别
"uecha LIKE lips-uecha, "上层项目号
"pstyv_txt LIKE tvapt-vtext, "类别描述
"brgew LIKE lips-brgew, "单项目毛重
"gewei LIKE lips-gewei, "单项目毛重单位
"bolnr LIKE likp-bolnr , "物流单号
beizhu(45) TYPE c , "备注
END OF ty_items_n.
*DATA:hs_items_n TYPE HASHED TABLE OF ty_items_n
* WITH UNIQUE KEY vbelv vbeln_im matnr arktx vrkme beizhu
* WITH HEADER LINE.
DATA:hs_items_n TYPE TABLE OF ty_items_n WITH HEADER LINE.
DATA:gt_items_n TYPE ty_items_n OCCURS 0.
DATA:gt_items_n_show TYPE ty_items_n OCCURS 0.
DATA:gt_items_n_temp TYPE ty_items_n OCCURS 0.
DATA:wa_items_n TYPE ty_items_n.
DATA:wa_all TYPE ty_all,
gt_all TYPE ty_all OCCURS 0.
DATA:wa_header TYPE ty_header,
gt_header
TYPE ty_header OCCURS 0.
DATA:wa_items TYPE ty_items,
gt_items
TYPE ty_items OCCURS 0.
DATA:gt_dc TYPE STANDARD TABLE OF ztbjdyzt.
DATA:wa_dc TYPE ztbjdyzt.
DATA:forms TYPE i."在FORM print里循环
*定义传入到smartforms的变量开始
DATA:fm_name TYPE rs38l_fnam.
DATA:itemsname(32) TYPE c.
DATA:headername(32) TYPE c.
*定义传入到smartforms的变量结束
DATA job_output_info TYPE ssfcrescl.
DATA job_output_options TYPE ssfcresop.
DATA BEGIN OF pdf OCCURS 10.
INCLUDE STRUCTURE tline.
DATA END OF pdf.
DATA len TYPE i. "PDF文件大小
*定义存储ALV向smartforms传入数据的内表开始
DATA:gt_header_temp TYPE ty_header OCCURS 0.
DATA:gt_items_temp TYPE ty_items OCCURS 0.
DATA:gt_all_temp TYPE ty_all OCCURS 0.
*定义存储ALV向smartforms传入数据的内表结束
*ALV显示头数据开始
DATA:gt_header_show TYPE ty_header OCCURS 0.
DATA:gt_items_show TYPE ty_items OCCURS 0.
*ALV显示头数据结束
"控制smartforms参数声明开始
DATA :control_parameters TYPE ssfctrlop,
lw_output_opt
TYPE ssfcompop. "Smart Forms: 智能写作器 (传输) 选项
DATA: lw_ssfcrescl TYPE ssfcrescl.
"控制smartforms参数声明结束
DATA: gs_fcat TYPE lvc_s_fcat,
gt_fcat
TYPE lvc_t_fcat,
gs_layo
TYPE lvc_s_layo,
gs_grid
TYPE lvc_s_glay.
DATA: gt_event TYPE slis_t_event WITH HEADER LINE,
gt_event_exit
TYPE slis_t_event_exit WITH HEADER LINE.
DATA: ref_grid TYPE REF TO cl_gui_alv_grid .
*PARAMETERS filename TYPE rlgrap-filename.
*
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
* PERFORM f4_file_save CHANGING filename.
START-OF-SELECTION.
SELECT-OPTIONS:
p_vbeln
FOR likp-vbeln , "交货单号
p_werks
FOR lips-werks , "工厂 ,
p_lgort
FOR lips-lgort ,"库存地点
p_budat
FOR mkpf-budat ,"过账日期
p_usnam
FOR vttp-ernam,"创建者
p_vkorg
FOR vbak-vkorg ,"销售组织
p_lfart
FOR likp-lfart,
p_tknum
FOR vttp-tknum NO INTERVALS NO-EXTENSION ."装运单号.
"P_TPLST FOR VTTK-TPLST ,
"P_ERNAM FOR VTTK-ERNAM ,
"P_ROUTE FOR VTTK-ROUTE .
PERFORM frm_get_data.
PERFORM display_data .
END-OF-SELECTION.
"当屏幕失去焦点时,自动刷新声明类开始
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS handle_modify
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified et_good_cells.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_modify.
* PERFORM refresh.
DATA stbl TYPE lvc_s_stbl.
stbl
-row = 'X'." 基于行的稳定刷新
stbl
-col = 'X'." 基于列稳定刷新
CALL METHOD ref_grid->refresh_table_display
EXPORTING
is_stable
= stbl.
ENDMETHOD. "HANDLE_MODIFY
ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION
DATA gt_event_receiver TYPE REF TO lcl_event_receiver .
"当屏幕失去焦点时,自动刷新声明类结束
FORM frm_get_data ."lp~kunag lp~kunnr
SELECT
vbfa
~vbelv ,lips~vbeln AS vbeln_im , likp~kunag ,likp~kunnr ,likp~lfart, kna1~stras, mseg~budat_mkpf, mseg~zeile, mseg~shkzg,
kna1
~telf1 , mseg~usnam_mkpf, lips~matnr , lips~arktx ,lips~lgort , lips~lfimg AS menge,lips~werks,lips~uecha,
lips
~vrkme , mseg~charg ,lips~posnr AS vbelp_im , likp~bolnr, lips~brgew ,lips~gewei, lips~pstyv , mseg~mblnr, mseg~bwart, mseg~cputm_mkpf ,adrp~name_last,
adrp
~name_first ,mseg~smbln, mseg~smblp, vbak~auart,vbak~vkorg, vbak~vtweg,
vttp
~tknum
INTO CORRESPONDING FIELDS OF TABLE @gt_all
* FROM mseg AS m
*
* INNER JOIN mkpf AS mf
* ON m~mblnr = mf~mblnr AND mf~mjahr = m~mjahr wAND mf~vgart = 'WL'
* INNER JOIN lips AS ls
* ON m~vbeln_im = ls~vbeln AND m~vbelp_im = ls~posnr
FROM likp
INNER
JOIN lips
ON likp~vbeln = lips~vbeln
INNER
JOIN mseg
ON mseg~vbeln_im = lips~vbeln AND mseg~vbelp_im = lips~posnr
LEFT JOIN mkpf
ON mseg~mblnr = mkpf~mblnr AND mkpf~mjahr = mseg~mjahr AND mkpf~vgart = 'WL'
INNER
JOIN kna1
ON kna1~kunnr = likp~kunnr
LEFT JOIN vbfa
ON vbfa~vbeln = lips~vbeln AND vbfa~posnn = lips~posnr
LEFT JOIN vbak
ON vbak~vbeln = vbfa~vbelv
INNER
JOIN usr21
ON usr21~bname = mkpf~usnam
LEFT JOIN adrp
ON adrp~persnumber = usr21~persnumber
LEFT JOIN vttp
ON vttp~vbeln = likp~vbeln
WHERE lips~vbeln IN @p_vbeln AND
lips
~werks IN @p_werks AND
lips
~lgort IN @p_lgort AND
mkpf
~budat IN @p_budat AND
mkpf
~usnam IN @p_usnam AND
vbak
~vkorg IN @p_vkorg AND
likp
~lfart IN @p_lfart AND " AND
vttp
~tknum IN @p_tknum .
SORT gt_all ASCENDING BY vbelv vbeln_im mblnr budat_mkpf cputm_mkpf vbelp_im."BUDAT_MKPF CPUTM_MKPF.
DELETE ADJACENT DUPLICATES FROM gt_all.
CLEAR wa_all.
LOOP AT gt_all INTO wa_all.
* AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
* ID 'VKORG' FIELD wa_all-vkorg
* ID 'VTWEG' DUMMY "wa_all-vtweg
* ID 'SPART' DUMMY "gwa_vbap-spart2 "行项目
* ID 'ACTVT' FIELD '03'.
* IF sy-subrc <> 0.
* DELETE TABLE gt_all FROM wa_all.
* CONTINUE.
* ENDIF.
SELECT SINGLE vtext INTO wa_all-lfart_txt
FROM tvlkt
WHERE lfart EQ wa_all-lfart.
SELECT SINGLE bezei INTO wa_all-auart_txt
FROM tvakt
WHERE auart EQ wa_all-auart.
SELECT SINGLE name1 INTO wa_all-kunnr_txt
FROM kna1 WHERE kunnr EQ wa_all-kunnr.
SELECT SINGLE name1 INTO wa_all-kunag_txt
FROM kna1 WHERE kunnr EQ wa_all-kunag.
CONCATENATE wa_all-name_last wa_all-name_first INTO wa_all-name_last.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_dc
FROM ztbjdyzt WHERE key1 EQ wa_all-vbeln_im AND type EQ '005'.
DESCRIBE TABLE gt_dc LINES wa_all-count_prt.
MODIFY gt_all FROM wa_all.
ENDLOOP.
LOOP AT gt_all INTO wa_all WHERE smbln IS NOT INITIAL AND smblp IS NOT INITIAL .
DELETE gt_all WHERE mblnr = wa_all-smbln AND zeile = wa_all-smblp.
DELETE TABLE gt_all FROM wa_all.
ENDLOOP.
LOOP AT gt_all INTO wa_all WHERE shkzg = 'S'.
IF wa_all-pstyv EQ 'REN' OR wa_all-pstyv EQ 'REN1' OR
wa_all
-pstyv EQ 'REN2' OR wa_all-pstyv EQ 'REN3' OR
wa_all
-pstyv EQ 'REQ' OR wa_all-pstyv EQ 'REHP'.
CONTINUE.
ELSE.
DELETE TABLE gt_all FROM wa_all.
ENDIF.
ENDLOOP.
MOVE-CORRESPONDING gt_all TO gt_header_show.
MOVE-CORRESPONDING gt_all TO gt_items_show.
DATA: luecha LIKE lips-uecha. "上层项目批
DATA: lpstyv LIKE lips-pstyv. "上层行项目类型
* DATA: lwa_items TYPE ty_items.
* DATA: l_items TYPE ty_items.
LOOP AT gt_items_show INTO wa_items WHERE lfart NE 'ZLF9' AND ( pstyv EQ 'TBN' OR pstyv EQ 'ZTNN'
OR pstyv EQ'ZMN' OR pstyv EQ 'TBN1' ).
IF wa_items-pstyv EQ 'ZMN' .
* SELECT SINGLE uecha INTO luecha
* FROM lips
* WHERE vbeln EQ wa_items-vbeln_im AND posnr EQ wa_items-vbelp_im.
SELECT SINGLE pstyv INTO lpstyv
FROM lips
WHERE vbeln EQ wa_items-vbeln_im AND posnr EQ wa_items-uecha.
IF lpstyv EQ 'TBN' .
wa_items
-pstyv_txt = '赠'.
ENDIF.
PERFORM frm_read_txt_po USING wa_items-vbeln_im luecha
CHANGING wa_items-beizhu.
ELSE.
wa_items
-pstyv_txt = '赠'.
PERFORM frm_read_txt_po USING wa_items-vbeln_im wa_items-vbelp_im
CHANGING wa_items-beizhu.
ENDIF.
* PERFORM frm_read_txt_po USING wa_items-vbeln_im wa_items-vbelp_im
* CHANGING wa_items-beizhu.
MODIFY gt_items_show FROM wa_items.
ENDLOOP.
DATA:lt_items_tmp TYPE ty_items OCCURS 0 .
DATA:wa_items_tmp TYPE ty_items .
DATA:ls_items TYPE ty_items.
LOOP AT gt_items_show INTO wa_items WHERE uecha IS NOT INITIAL.
ls_items
= wa_items.
ls_items
-vbelp_im = wa_items-uecha.
SELECT SINGLE pstyv INTO ls_items-pstyv
FROM lips
WHERE vbeln EQ ls_items-vbeln_im AND posnr EQ ls_items-vbelp_im.
CLEAR ls_items-uecha.
* LOOP AT lt_items_tmp INTO wa_items_tmp WHERE vbelv = ls_items-vbelv
* AND vbeln_im = ls_items-vbeln_im
* AND vbelp_im = ls_items-vbelp_im .
*
* ENDLOOP.
READ TABLE lt_items_tmp INTO wa_items_tmp WITH KEY vbelv = ls_items-vbelv
vbeln_im
= ls_items-vbeln_im
vbelp_im
= ls_items-vbelp_im.
IF sy-subrc EQ 0.
wa_items_tmp
-menge = wa_items_tmp-menge + ls_items-menge.
wa_items_tmp
-brgew = wa_items_tmp-brgew + ls_items-brgew.
MODIFY lt_items_tmp FROM wa_items_tmp INDEX sy-tabix.
ELSE.
APPEND ls_items TO lt_items_tmp.
ENDIF.
DELETE gt_items_show WHERE vbelv = wa_items-vbelv AND vbeln_im = wa_items-vbeln_im
AND vbelp_im = wa_items-vbelp_im .
ENDLOOP.
APPEND LINES OF lt_items_tmp TO gt_items_show.
CLEAR: lt_items_tmp,wa_items_tmp,ls_items.
SORT gt_items_show BY vbelv vbeln_im vbelp_im.
DELETE ADJACENT DUPLICATES FROM gt_header_show.
DATA count LIKE lips-brgew VALUE 0.
LOOP AT gt_header_show INTO wa_header.
LOOP AT gt_items_show INTO wa_items
WHERE vbeln_im EQ wa_header-vbeln_im
AND mblnr EQ wa_header-mblnr
AND vbelv EQ wa_header-vbelv
AND shkzg EQ wa_header-shkzg
AND budat_mkpf EQ wa_header-budat_mkpf
AND lgort EQ wa_header-lgort .
IF wa_items-gewei NE 'KG'.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
input = wa_items-brgew
round_sign
= 'X'
unit_in
= wa_items-gewei
unit_out
= 'KG'
IMPORTING
output = wa_items-brgew
EXCEPTIONS
conversion_not_found
= 01
division_by_zero
= 02
input_invalid
= 03.
ENDIF.
count = wa_items-brgew + count."放入到要往smartforms传入的内表行项目
" ENDIF.
ENDLOOP.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
input = count
round_sign
= 'X'
unit_in
= 'KG'
unit_out
= 'TO'
IMPORTING
output = count
EXCEPTIONS
conversion_not_found
= 01
division_by_zero
= 02
input_invalid
= 03.
wa_header
-total_brgew = count.
MODIFY TABLE gt_header_show FROM wa_header.
CLEAR wa_items.
CLEAR wa_header.
CLEAR count.
ENDLOOP.
SORT gt_items_show BY vbelv vbeln_im vbelp_im.
DATA:l_tabix TYPE sy-tabix.
DATA:lwa_items TYPE ty_items.
LOOP AT gt_items_show INTO wa_items.
l_tabix
= sy-tabix + 1.
MOVE-CORRESPONDING wa_items TO hs_items_n.
IF wa_items-pstyv EQ 'TBN'.
hs_items_n
-menge1 = 0.
hs_items_n
-menge2 = wa_items-menge.
hs_items_n
-menge3 = hs_items_n-menge1 + hs_items_n-menge2.
ELSE.
READ TABLE gt_items_show INTO lwa_items INDEX l_tabix.
IF lwa_items-pstyv EQ 'TBN' AND lwa_items-matnr EQ wa_items-matnr.
hs_items_n
-menge1 = wa_items-menge.
hs_items_n
-menge2 = lwa_items-menge.
hs_items_n
-menge3 = hs_items_n-menge1 + hs_items_n-menge2.
DELETE TABLE gt_items_show FROM lwa_items.
ELSEIF lwa_items-pstyv EQ 'TBN' AND lwa_items-matnr NE wa_items-matnr.
hs_items_n
-menge1 = wa_items-menge.
hs_items_n
-menge2 = 0.
hs_items_n
-menge3 = hs_items_n-menge1 + hs_items_n-menge2.
ELSE.
hs_items_n
-menge1 = wa_items-menge.
hs_items_n
-menge2 = 0.
hs_items_n
-menge3 = hs_items_n-menge1 + hs_items_n-menge2.
ENDIF.
ENDIF.
* IF wa_items-pstyv EQ 'TBN'."当行项目为标准类型赋值menge1
* hs_items_n-menge2 = wa_items-menge.
* hs_items_n-menge1 = 0.
* ELSE. "当行项目为赠品类型赋值menge2
* hs_items_n-menge1 = wa_items-menge.
* hs_items_n-menge2 = 0.
* ENDIF.
* hs_items_n-menge3 = wa_items-menge.
* COLLECT hs_items_n.
APPEND hs_items_n.
ENDLOOP.
gt_items_n_show[]
= hs_items_n[].
ENDFORM.
FORM display_data .
IF gt_header_show[] IS INITIAL.
MESSAGE '没有数据显示!' TYPE 'I'.
RETURN.
ENDIF.
PERFORM set_fcat.
PERFORM set_layout.
PERFORM show_alv TABLES gt_fcat gt_header_show[]
USING gs_layo.
ENDFORM. " DISPLAY_DATA
*&---------------------------------------------------------------------*
FORM set_fcat .
PERFORM csalv_set_fcat USING:
" 'Field' 'Text' 'Edit' 'Zero' 'Type' 'Qfieldname' 'Key' 'Hostspot' 'Emphasize' 'Checkbox'
"'TKNUM' '装运编号' '' 'X' '' '' '' '' '' '' '' '' '',
'VBELV' '销售订单号' '' 'X' '' '' '' '' '' '' '' '' '',
'AUART' '销售订单类型' '' 'X' '' '' '' '' '' '' '' '' '',
'AUART_TXT' '销售订单类型描述' '' 'X' '' '' '' '' '' '' '' '' '',
'VKORG' '销售组织' '' 'X' '' '' '' '' '' '' '' '' '',
'VBELN_IM' '交货单号' '' 'X' '' '' '' '' '' '' '' '' '',
'LFART' '交货类型' '' 'X' '' '' '' '' '' '' '' '' '',
'LFART_TXT' '交货类型描述' '' 'X' '' '' '' '' '' '' '' '' '',
'MBLNR' '物料凭证' '' '' '' '' '' '' '' '' '' '' '',
"'SHKZG' '借\贷标识' '' '' '' '' '' '' '' '' '' '' '',
'BUDAT_MKPF' '凭证日期' '' '' '' '' '' '' '' '' '' '' '',
'CPUTM_MKPF' '凭证时间' '' '' '' '' '' '' '' '' '' '' '',
"'ZEILE' '凭证项目' '' '' '' '' '' '' '' '' '' '' '',
"'BWART' '移动类型' '' '' '' '' '' '' '' '' '' '' '',
'KUNAG_TXT' '客户' '' '' '' '' '' '' '' '' '' '' '',
'KUNNR_TXT' '送达方' '' '' '' '' '' '' '' '' '' '' '',
"'MATNR' '产品编码' '' '' '' '' '' '' '' '' '' '' '' ,
"'ARKTX' '产品' '' '' '' '' '' '' '' '' '' '' '',
"'MENGE' '数量' '' '' '' '' '' '' '' '' '' '0' '',
"'VRKME' '单位' '' '' '' '' '' '' '' '' '' '' '',
"'BRGEW' '毛重' '' '' '' '' '' '' '' '' '' '0' '',
'WERKS' '工厂' '' '' '' '' '' '' '' '' '' '' '',
'LGORT' '库存地点' '' '' '' '' '' '' '' '' '' '' '',
'NAME_LAST' '经办人' '' '' '' '' '' '' '' '' '' '' '',
"'NAME_FIRST' '名' '' '' '' '' '' '' '' '' '' '' '',
'COUNT_PRT' '已打印次数' '' '' '' '' '' '' '' '' '' '' '',
'BEIZHU' '备注' 'X' '' '' '' '' '' '' '' '' '' 'X'.
"'zsel' '是否打印 ' '' '' '' '' '' '' '' 'X' ''.
ENDFORM. " SET_FCAT
*&---------------------------------------------------------------------*
FORM set_layout .
gs_layo
-zebra = 'X'.
* gs_layout-stylefname = 'FIELD_STYLE'.
gs_layo
-cwidth_opt = 'X'.
ENDFORM. " SET_LAYOUT
*&---------------------------------------------------------------------*
FORM csalv_set_fcat USING
p_name
p_text
p_edit
p_zero
p_type
p_qfieldname
p_key
p_hotspot
p_emphasize
p_checkbox
p_do_sum
p_decimals_out
p_no_out
.
gs_fcat
-fieldname = p_name.
* gs_fcat-reptext_l =
* gs_fcat-selddictxt =
gs_fcat
-reptext = p_text.
gs_fcat
-edit = p_edit.
gs_fcat
-no_zero = p_zero.
gs_fcat
-datatype = p_type.
gs_fcat
-qfieldname = p_qfieldname.
gs_fcat
-key = p_key.
gs_fcat
-hotspot = p_hotspot.
gs_fcat
-emphasize = p_emphasize.
gs_fcat
-checkbox = p_checkbox.
gs_fcat
-do_sum = p_do_sum.
gs_fcat
-decimals_o = p_decimals_out.
gs_fcat
-no_out = p_no_out.
APPEND gs_fcat TO gt_fcat.
ENDFORM. "csalv_set_fcat
*&---------------------------------------------------------------------*
FORM show_alv TABLES pt_fcat
pt_tab
USING ps_layout.
gs_grid
-edt_cll_cb = 'X'."当屏幕失去焦点时,自动刷新
gt_event
-name = 'CALLER_EXIT'. "slis_ev_caller_exit_at_start事件
gt_event
-form = 'FM_BUTTON'.
APPEND gt_event .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program
= sy-repid
i_callback_user_command
= 'USER_COMMAND'
i_grid_settings
= gs_grid
i_callback_pf_status_set
= 'SET_PF_STATUS'
is_layout_lvc
= gs_layo
it_fieldcat_lvc
= pt_fcat[]
it_events
= gt_event[]
i_save
= 'X'
* it_event_exit = gt_event_exit[]
TABLES
t_outtab
= pt_tab
EXCEPTIONS
program_error
= 1
OTHERS = 2.
ENDFORM. "csalv_set_fcat
FORM print.
DATA:ptr_count(10) TYPE c.
DATA: lines TYPE i."获取往smartforms传入的要打印的行数目
DATA: insertrows TYPE i."需要再插入多少空行
DATA: rows TYPE i VALUE 15."一页要打印的行数
CLEAR gt_all_temp.
CLEAR gt_header.
CLEAR gt_items_n.
CLEAR gt_header_temp.
CLEAR gt_items_n_temp.
DATA count LIKE lips-brgew VALUE 0.
DATA:ls_row TYPE lvc_s_row,
lt_rows
TYPE lvc_t_row.
"CLEAR GT_HEADER.
"CLEAR GT_ITEMS.
CALL METHOD ref_grid->get_selected_rows
IMPORTING
et_index_rows
= lt_rows
* et_row_no =
.
LOOP AT lt_rows INTO ls_row.
READ TABLE gt_header_show INTO wa_header INDEX ls_row-index.
APPEND wa_header TO gt_header.
LOOP AT gt_items_n_show INTO wa_items_n
WHERE vbeln_im EQ wa_header-vbeln_im
AND vbelv EQ wa_header-vbelv .
APPEND wa_items_n TO gt_items_n.
ENDLOOP.
ENDLOOP.
CLEAR: control_parameters.
control_parameters
-preview = 'X'.
control_parameters
-no_open = 'X'.
control_parameters
-no_close = 'X'.
* control_parameters-getotf = 'X'.
* control_parameters-no_dialog = 'X'.
lw_output_opt
-tdiexit = 'X'.
CALL FUNCTION 'SSF_OPEN'
EXPORTING
control_parameters
= control_parameters
output_options
= lw_output_opt
* IMPORTING
* job_output_info = job_output_info
EXCEPTIONS
formatting_error
= 1
internal_error
= 2
send_error
= 3
user_canceled
= 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
LOOP AT gt_header INTO wa_header.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_dc
FROM ztbjdyzt WHERE key1 EQ wa_header-vbeln_im AND type EQ '005'.
DESCRIBE TABLE gt_dc LINES wa_header-count_prt.
wa_header
-count_prt = wa_header-count_prt + 1.
PERFORM frm_read_txt USING wa_header-vbeln_im CHANGING wa_header-beizhu.
APPEND wa_header TO gt_header_temp."放入到要往smartforms传入的表头内表
LOOP AT gt_items_n INTO wa_items_n
WHERE vbeln_im EQ wa_header-vbeln_im
AND vbelv EQ wa_header-vbelv.
APPEND wa_items_n TO gt_items_n_temp.
ENDLOOP.
CLEAR wa_items_n.
CLEAR wa_header.
IF gt_items_n_temp IS INITIAL.
MESSAGE i000(0k) WITH '请选中要打印的内容!'.
EXIT .
ENDIF.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname
= 'ZSDSF007_2'
IMPORTING
fm_name
= fm_name
EXCEPTIONS
no_form
= 1
no_function_module
= 2
OTHERS = 3.
"SET HANDLER gt_event_receiver->handle_modify FOR ref_grid.
DESCRIBE TABLE gt_items_n_temp LINES lines.
insertrows
= lines MOD rows .
IF insertrows NE 0.
insertrows
= rows - insertrows.
ELSE.
insertrows
= 0.
ENDIF.
DO insertrows TIMES.
APPEND wa_items_n TO gt_items_n_temp."放入到要往smartforms传入的行项目内表
ENDDO.
PERFORM frm_print_data."每一个表头数据向smartforms传入数据
ENDLOOP.
CALL FUNCTION 'SSF_CLOSE'
IMPORTING
job_output_info
= job_output_info
EXCEPTIONS
formatting_error
= 1
internal_error
= 2
send_error
= 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF job_output_info-outputdone = 'X'.
CLEAR wa_dc.
LOOP AT gt_header INTO wa_header.
wa_dc
-mandt = sy-mandt.
wa_dc
-to_date = sy-datum.
wa_dc
-to_time = sy-uzeit.
wa_dc
-type = '005'.
wa_dc
-tab_no = sy-tabix.
wa_dc
-name = sy-uname.
wa_dc
-key1 = wa_header-vbeln_im.
wa_dc
-to_go = 'X'.
APPEND wa_dc TO gt_dc.
wa_header
-count_prt = wa_header-count_prt + 1.
MODIFY TABLE gt_header_show FROM wa_header.
ENDLOOP.
MODIFY ztbjdyzt FROM TABLE gt_dc.
COMMIT WORK.
DATA stbl TYPE lvc_s_stbl.
stbl
-row = 'X'." 基于行的稳定刷新
stbl
-col = 'X'." 基于列稳定刷新
CALL METHOD ref_grid->refresh_table_display
EXPORTING
is_stable
= stbl.
ENDIF.
CLEAR gt_dc[].
CLEAR job_output_info.
ENDFORM.
FORM frm_print_data.
forms
= forms + 1.
DATA: ls_compop TYPE ssfcompop.
DATA: ls_job_output_info TYPE ssfcrescl.
DATA :lt_itcoo TYPE itcoo OCCURS 0. "Smart Forms: OTF 结构
itemsname
= sy-uname && forms && '1' && sy-datum && sy-uzeit.
headername
= sy-uname && forms && '2' && sy-datum && sy-uzeit.
savebuffer gt_items_n_temp itemsname
.
savebuffer gt_header_temp headername
.
* PTR_COUNT = GV_COUNT .
*调用 smartForms
ls_compop
-tddest = 'DEFAULT'.
ls_compop
-tdnoprev = 'X'.
ls_compop
-tdiexit = 'X'.
CALL FUNCTION fm_name
EXPORTING
control_parameters
= control_parameters
output_options
= ls_compop
user_settings
= 'X'
ptr_items
= itemsname
ptr_header
= headername
* IMPORTING
* job_output_info = job_output_info
* PTR_TOTAL = GV_COUNT
EXCEPTIONS
formatting_error
= 1
internal_error
= 2
send_error
= 3
user_canceled
= 4.
"MOVE: job_output_info-otfdata[] TO lt_itcoo. "智能表: OTF表
"将OTF表转换成PDF格式
"PERFORM covert_pdf TABLES lt_itcoo.
clearbuffer itemsname
.
clearbuffer headername
.
CLEAR gt_header_temp.
CLEAR gt_items_n_temp.
"PERFORM frm_smartforms_to_pdf.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_UCOMM text
* -->PS_SELFIELD text
*----------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield
TYPE slis_selfield.
" rs_selfield-refresh = 'X'.
CASE r_ucomm.
WHEN '&DATA_SAVE'.
WHEN '&PRINT' OR '&PRT'.
PERFORM print.
WHEN '&BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form SET_PF_STATUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab..
SET PF-STATUS 'STANDARD'.
ENDFORM. "SET_PF_STATUS
*&---------------------------------------------------------------------*
*& Form fm_button
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->E_GRID text
*----------------------------------------------------------------------*
FORM fm_button USING e_grid TYPE slis_data_caller_exit.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
* EXPORTING
* IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
* ET_EXCLUDING =
* E_REPID =
* E_CALLBACK_PROGRAM =
* E_CALLBACK_ROUTINE =
e_grid
= ref_grid
* ET_FIELDCAT_LVC =
* ER_TRACE =
* E_FLG_NO_HTML =
* ES_LAYOUT_KKBLO =
* ES_SEL_HIDE =
* ET_EVENT_EXIT =
* ER_FORM_TOL =
* ER_FORM_EOL =
.
* CALL METHOD ref_grid->check_changed_data.
* 设置enter事件
CALL METHOD ref_grid->register_edit_event
EXPORTING
i_event_id
= cl_gui_alv_grid=>mc_evt_enter
EXCEPTIONS
error
= 1
OTHERS = 2.
CREATE OBJECT gt_event_receiver.
SET HANDLER gt_event_receiver->handle_modify FOR ref_grid.
ENDFORM. "FM_BUTTON
FORM covert_pdf TABLES otf_data STRUCTURE itcoo.
DATA: lt_lines TYPE STANDARD TABLE OF tline, "SAPscript: 文字行
lt_docs
TYPE STANDARD TABLE OF docs, "存储文档
l_bin_size
TYPE i. "
"将OTF转换PDF格式
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize
= l_bin_size
TABLES
otf
= otf_data "otf 表
doctab_archive
= lt_docs
lines = lt_lines "文本行
EXCEPTIONS
err_conv_not_possible
= 1
err_otf_mc_noendmarker
= 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.
* PERFORM send_mail TABLES gt_lines.
"保存到计算机本地PDF文件
PERFORM download_pdf TABLES lt_lines.
ENDFORM. "covert_pdf
*&---------------------------------------------------------------------*
*& Form download_pdf
*&---------------------------------------------------------------------*
* 保存到本地PDF文件
*----------------------------------------------------------------------*
* -->FU_TAB 文件内容
*----------------------------------------------------------------------*
FORM download_pdf TABLES fu_tab.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename
= 'C:\test.pdf' "文件路径
filetype
= 'BIN' "文件类型
codepage
= '8400' "代码页
TABLES
data_tab
= fu_tab "文件内容表
EXCEPTIONS
file_write_error
= 1
no_batch
= 2
gui_refuse_filetransfer
= 3
invalid_type
= 4
no_authority
= 5
unknown_error
= 6
header_not_allowed
= 7
separator_not_allowed
= 8
filesize_not_allowed
= 9
header_too_long
= 10
dp_error_create
= 11
dp_error_send
= 12
dp_error_write
= 13
unknown_dp_error
= 14
access_denied
= 15
dp_out_of_memory
= 16
disk_full
= 17
dp_timeout
= 18
file_not_found
= 19
dataprovider_exception
= 20
control_flush_error
= 21
OTHERS = 22.
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. "DOWNLOAD_PDF
FORM frm_read_txt USING vbeln LIKE likp-vbeln
CHANGING txt .
DATA :lc_name TYPE thead-tdname,
lit_lines
TYPE TABLE OF tline,
lwa_lines
TYPE tline.
CLEAR: lit_lines ,
lc_name
,
lwa_lines
.
lc_name
= vbeln .
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = '0001'
language = sy-langu
name
= lc_name
object
= 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = lit_lines
EXCEPTIONS
id = 1
language = 2
name
= 3
not_found
= 4
object
= 5
reference_check
= 6
wrong_access_to_archive
= 7
OTHERS = 8.
IF sy-subrc = 4.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = '0001'
language = sy-langu
name
= lc_name
object
= 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = lit_lines
EXCEPTIONS
id = 1
language = 2
name
= 3
not_found
= 4
object
= 5
reference_check
= 6
wrong_access_to_archive
= 7
OTHERS = 8.
ENDIF.
LOOP AT lit_lines INTO lwa_lines.
* GWA_OUTPUT-RISE_TEXT = LWA_LINES-TDLINE .
CONCATENATE txt lwa_lines-tdline INTO txt.
ENDLOOP.
ENDFORM.
FORM frm_read_txt_po USING vbeln LIKE likp-vbeln posnr LIKE lips-posnr
CHANGING txt .
DATA :lc_name TYPE thead-tdname,
lit_lines
TYPE TABLE OF tline,
lwa_lines
TYPE tline.
CLEAR: lit_lines ,
lc_name
,
lwa_lines
.
lc_name
= vbeln && posnr.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = '0001'
language = sy-langu
name
= lc_name
object
= 'VBBP'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = lit_lines
EXCEPTIONS
id = 1
language = 2
name
= 3
not_found
= 4
object
= 5
reference_check
= 6
wrong_access_to_archive
= 7
OTHERS = 8.
IF sy-subrc = 4.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = '0001'
language = sy-langu
name
= lc_name
object
= 'VBBP'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = lit_lines
EXCEPTIONS
id = 1
language = 2
name
= 3
not_found
= 4
object
= 5
reference_check
= 6
wrong_access_to_archive
= 7
OTHERS = 8.
ENDIF.
LOOP AT lit_lines INTO lwa_lines.
* GWA_OUTPUT-RISE_TEXT = LWA_LINES-TDLINE .
CONCATENATE txt lwa_lines-tdline INTO txt.
ENDLOOP.
ENDFORM.
ABAP 出库单打印 产品 A搭A A搭B显示方式的更多相关文章
- 使用Jasperreporter生成入库出库单打印等报表操作
项目需要打印报表:就是那种生成入库单,出库单等的操作.使用到的技术:使用iReport Designer5.1.0设计报表,使用struts2+jasperreporter生成最终填充数据的报表 首先 ...
- MySQL_产品昨日库存与历史入库历史出库成本_20161124
产品昨日库存与历史入库历史出库成本 SELECT d.ID,a.*,e.昨日订单额 ,b.昨天入库额,b.历史2天,b.历史3天,b.历史4天,b.历史5天,b.历史6天,b.历史7天,b.历史8天, ...
- ERP出库审核业务(四十四)
结束表单流程的代码: protected void btnSubmit_Click(object sender, EventArgs e) { if(this.txtreceiveDate.Text! ...
- SAP 出库单新版
*&---------------------------------------------------------------------* *& Report ZSDR045 ...
- SAP打印出库单 新需求
*&---------------------------------------------------------------------* *& Report Z_SD_CKD ...
- SAP打印出库单需求
*&---------------------------------------------------------------------* *& Report Z_SD_CKD ...
- 快递鸟电子面单打印功能基于java
之前的后天管理系统的电子面单打印使用的是灵通打单. 使用相对比较麻烦,需要到处Excel之后再导入,麻烦. 快递鸟有电子面单api,后台系统直接对接很是方便,不过也遇到了好些问题. 不难是不难,但是遇 ...
- SQL用先进先出存储过程求出库数量
create table t( id ,), name ),--商品名称 j int, --入库数量 c int, --出库数量 jdate datetime --入库时间 ) ,,'2007-12- ...
- [2015.08.13]万峰快递单打印软件 v2.2
<万峰快递单打印软件>是一款简单易用,且支持所有快递单的打印软件.1.支持文字打印位置的坐标精确定位和微调的打印工具.2.操作灵活,只需录入收件人和发件人信息即可打印:3.快递单打印尺寸和 ...
随机推荐
- java 导出word 并下载
记录一下导出操作 源码: /************ * 导出word 并下载 * @param id 房号记录编号 * ***********************/ @RequestMappin ...
- lua命令行编译
http://jingyan.baidu.com/article/359911f551917457fe0306e5.html 最后将生成的.exe解释器的根目录配置到系统环境变量 copy lua.c ...
- neo4j-jersey分嵌入式和服务式连接图形数据库
原文载自:http://blog.csdn.net/yidian815/article/details/12887259 嵌入式: 引入neo4j依赖 <dependency> <g ...
- asp.net mvc 权限过滤和单点登录(禁止重复登录)
1.权限控制使用controller和 action来实现,权限方式有很多种,最近开发项目使用控制控制器方式实现代码如下 /// <summary> /// 用户权限控制 /// < ...
- 定制sqlmap tamper脚本
前言 渗透测试过程中遇到注入点常常丢到sqlmap中进行测试,假如网站有waf,sqlmap便无法直接注入了. 测试 在测试某个项目的过程中,一个页面的aid参数,习惯性的提交 and 1=1发现直接 ...
- Javascript判断object还是list/array的类型(包含javascript的数据类型研究)
前提:先研究javascript中的变量有几种,参考: http://www.w3school.com.cn/js/js_datatypes.asp http://glzaction.iteye.co ...
- EntityFramework错误:Unable to update the EntitySet because it has a DefiningQuery
错误截图: 解决方法: 在所操作的数据库表中添加一个主键即可解决此问题
- MVC POST在ACTION上进行多个模型的数据绑定
首先声明,接下来的东西并不符合本人认同的严谨的MVC模式. 用MVC做项目的过程中,越来越多的用到不严谨的MVC编程. 比如,在"cshtml"文件中写: @Html.Raw(DB ...
- PHP获取上周、本周、上月、本月、本季度、上季度时间方法大全
<?php echo date("Ymd",strtotime("now")), "\n"; echo date(&q ...
- 如何使用跨平台工具创建 NuGet 包(转)
原文地址 https://docs.microsoft.com/zh-cn/dotnet/articles/core/deploying/creating-nuget-packages 内容 对于 . ...