发货单打印程序(ZSD19)程序记录
*&---------------------------------------------------------------------*
*& Report ZBME_SD_FHPT
*&
*&---------------------------------------------------------------------*
*&
*&-------------------BME发货单打印程序--SF 2019.03.06-------------------*
*&
*&---------------------------------------------------------------------*
REPORT zbme_sd_fhpt.
TYPE-POOLS:slis.
TABLES:likp,lips.
DATA: gth_out TYPE zbme_sd_fhpt,
gtd_out LIKE TABLE OF gth_out.
DATA:gth_alv_sel TYPE zbme_sd_fhpt,
gtd_alv_sel LIKE TABLE OF gth_alv_sel.
DATA:gth_item LIKE zbme_sd_fhi,
gtd_item LIKE TABLE OF gth_item.
DATA:gth_likp TYPE likp,
gth_lips TYPE lips.
DATA:gtd_fieldcat_lvc TYPE lvc_t_fcat,
gth_fieldcat_lvc TYPE lvc_s_fcat,
gst_layout_lvc TYPE lvc_s_layo.
DATA:g_grid TYPE REF TO cl_gui_alv_grid.
SELECTION-SCREEN BEGIN OF BLOCK b_01 WITH FRAME TITLE text_001.
SELECT-OPTIONS:
s_vkorg FOR gth_likp-vkorg DEFAULT '1300',
s_vbeln FOR gth_likp-vbeln,
s_vgbel FOR gth_lips-vgbel,
s_kunnr FOR gth_likp-kunnr,
s_erdat FOR gth_likp-erdat,
s_ernam FOR gth_likp-ernam.
*PARAMETERS: p_prt AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK b_01.
INITIALIZATION.
text_001 = '筛选条件'.
s_erdat-sign = 'I'.
s_erdat-option = 'EQ'.
s_erdat-low = sy-datum - 10.
s_erdat-high = sy-datum + 2.
APPEND s_erdat.
START-OF-SELECTION.
PERFORM sub_getdata.
END-OF-SELECTION.
PERFORM sub_fieldcat_lvc.
PERFORM sub_layout_lvc.
* PERFORM add_field_lvc.
PERFORM call_alv_lvc.
*&---------------------------------------------------------------------*
*& Form sub_getdata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM sub_getdata.
SELECT a~vbeln
b~vgbel
a~vkorg
a~erdat
a~bldat
a~kunnr
b~ernam
b~posnr "项目编号
b~pstyv "项目类别
b~matnr
b~werks
b~lgort "库存地点
b~charg
b~lfimg "交货数量
b~vrkme "销售单位
INTO CORRESPONDING FIELDS OF TABLE gtd_out
FROM likp AS a INNER JOIN lips AS b ON a~vbeln = b~vbeln
WHERE a~vkorg IN s_vkorg AND a~vbeln IN s_vbeln AND b~vgbel IN s_vgbel
AND a~kunnr IN s_kunnr AND a~erdat IN s_erdat AND b~ernam IN s_ernam.
DELETE gtd_out WHERE lifsk IS NOT INITIAL."交货冻结.
SORT gtd_out BY vbeln DESCENDING.
LOOP AT gtd_out INTO gth_out.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' "补零函数
EXPORTING
input = gth_out-matnr
IMPORTING
output = gth_out-matnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = gth_out-kunnr
IMPORTING
output = gth_out-kunnr.
"物料描述
SELECT SINGLE maktx INTO gth_out-maktx FROM makt WHERE matnr = gth_out-matnr