*&---------------------------------------------------------------------*
*& Report ZRPT_PP_SEQ_RELATE
*&
*&---------------------------------------------------------------------*
*& author gavin
*& date 20220321
*& from jiangsy
*&---------------------------------------------------------------------*
REPORT ZRPT_PP_SEQ_RELATE.
TABLES:caufv,afko,afpo,ZMESCODESN,LIPS,likp.
TYPES:BEGIN OF TYP_DATA,
VBELN LIKE LIKP-VBELN,
POSNR LIKE LIPS-POSNR,
MATNR LIKE LIPS-MATNR,
SERNR LIKE OBJK-SERNR,
MAKTX LIKE ZMESCODESN-MAKTX,
SDDAT TYPE ZMESCODESN-SDDAT, "发货日期
SOURSE TYPE ZMESCODESN-SOURSE, "源系统
KUNNR TYPE ZMESCODESN-KUNNR, "客户编号
BARCODE TYPE ZMESCODESN-BARCODE, "完整条码
END OF TYP_DATA.
SELECTION-SCREEN BEGIN OF BLOCK 001 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:S_VBELN FOR LIPS-VBELN.
SELECT-OPTIONS:S_LFART FOR LIKP-LFART DEFAULT 'ZLR' to 'ZRE'.
SELECT-OPTIONS:S_KUNNR FOR LIKP-KUNNR.
SELECT-OPTIONS:S_VTWIV FOR LIKP-VTWIV.
SELECT-OPTIONS:S_VKORG FOR LIKP-VKORG.
SELECT-OPTIONS:S_ERDAT FOR LIKP-ERDAT.
SELECTION-SCREEN END OF BLOCK 001.
DATA:
STDATUM LIKE SY-DATUM,
STUZEIT LIKE SY-UZEIT,
GT_DATA TYPE TABLE OF TYP_DATA,
GS_DATA TYPE TYP_DATA,
GT_FIELDCAT TYPE LVC_T_FCAT,
GS_FIELDCAT TYPE LVC_S_FCAT,
GS_LAYOUT TYPE LVC_S_LAYO.
INITIALIZATION.
START-OF-SELECTION.
STDATUM = SY-DATUM.
STUZEIT = SY-UZEIT.
PERFORM GET_DATA.
PERFORM PROCESS_DATA.
PERFORM WRITERPTRUNRECORD.
PERFORM DISPLAY_DATA.
*&---------------------------------------------------------------------*
*& FORM GET_DATA
*&---------------------------------------------------------------------*
* 获取数据
*----------------------------------------------------------------------*
FORM GET_DATA.
SELECT
LIPS~VBELN LIPS~POSNR LIPS~MATNR OBJK~SERNR
INTO TABLE GT_DATA
FROM LIPS
JOIN likp on lips~vbeln = likp~vbeln
JOIN SER01 ON SER01~LIEF_NR = LIPS~VBELN AND SER01~POSNR = LIPS~POSNR
JOIN OBJK ON OBJK~OBKNR = SER01~OBKNR
WHERE LIPS~VBELN IN S_VBELN AND LIKP~LFART IN S_LFART AND
( LIKP~KUNNR IN S_KUNNR or LIKP~KUNAG IN S_KUNNR ) and
LIKP~VTWIV IN S_VTWIV AND LIKP~VKORG IN S_VKORG
AND LIKP~ERDAT IN S_ERDAT .
LOOP AT GT_DATA INTO GS_DATA.
SHIFT GS_DATA-SERNR LEFT DELETING LEADING '0'.
SELECT SINGLE ZMESCODESN~MAKTX ZMESCODESN~SDDAT ZMESCODESN~SOURSE ZMESCODESN~KUNNR ZMESCODESN~BARCODE
INTO (GS_DATA-MAKTX,GS_DATA-SDDAT,GS_DATA-SOURSE,GS_DATA-KUNNR,GS_DATA-BARCODE)
FROM ZMESCODESN
WHERE ZMESCODESN~MATNR = GS_DATA-MATNR AND
ZMESCODESN~SERNO = GS_DATA-SERNR.
MODIFY GT_DATA FROM GS_DATA.
ENDLOOP.
ENDFORM. "GET_DATA
*&---------------------------------------------------------------------*
*& FORM WRITERPTRUNRECORD
*&---------------------------------------------------------------------*
* 获取数据
*----------------------------------------------------------------------*
FORM WRITERPTRUNRECORD.
GET TIME.
CALL FUNCTION 'ZSYS_RPT_RUNRECORD'
EXPORTING
TCODE = SY-TCODE
PROGRAMM = SY-CPROG
"werks = GS_BW-werks
DATUMRST = STDATUM
UZEITRST = STUZEIT
BATCH = SY-BATCH
DATUMREND = SY-datum
UZEITREND = sy-UZEIT
DATUMC = '20220321'
RUNNER = SY-UNAME
RPTSRC = 'SD JSY'.
ENDFORM. "WRITERPTRUNRECORD
*&---------------------------------------------------------------------*
*& FORM PROCESS_DATA
*&---------------------------------------------------------------------*
* 处理数据
*----------------------------------------------------------------------*
FORM PROCESS_DATA.
ENDFORM. "PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT USING P_FIELDNAME TYPE FIELDNAME
P_QFIELDNAME TYPE LVC_QFNAME
P_CFIELDNAME TYPE LVC_CFNAME
P_REF_TABLE TYPE LVC_RTNAME
P_REF_FIELD TYPE LVC_RFNAME
P_CONVEXIT TYPE CONVEXIT
P_EMPHASIZE TYPE LVC_EMPHSZ
P_SCRTEXT_L TYPE SCRTEXT_L
P_NO_ZERO TYPE XFLAG.
GS_FIELDCAT-FIELDNAME = P_FIELDNAME.
GS_FIELDCAT-QFIELDNAME = P_QFIELDNAME.
GS_FIELDCAT-CFIELDNAME = P_CFIELDNAME.
GS_FIELDCAT-REF_TABLE = P_REF_TABLE.
GS_FIELDCAT-REF_FIELD = P_REF_FIELD.
GS_FIELDCAT-CONVEXIT = P_CONVEXIT.
GS_FIELDCAT-EMPHASIZE = P_EMPHASIZE.
GS_FIELDCAT-SCRTEXT_L = P_SCRTEXT_L.
GS_FIELDCAT-NO_ZERO = P_NO_ZERO.
GS_FIELDCAT-COLDDICTXT = 'L'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR: GS_FIELDCAT.
ENDFORM. "BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& FORM DISPLAY_DATA
*&---------------------------------------------------------------------*
* 显示数据
*----------------------------------------------------------------------*
FORM DISPLAY_DATA.
PERFORM BUILD_FIELDCAT USING 'VBELN' '' '' '' '' '' '' '交货单号码' 'X'.
PERFORM BUILD_FIELDCAT USING 'POSNR' '' '' '' '' '' '' '行项目号' 'X'.
PERFORM BUILD_FIELDCAT USING 'MATNR' '' '' '' '' '' '' '物料代码' 'X'.
PERFORM BUILD_FIELDCAT USING 'SERNR' '' '' '' '' '' '' '序列号' 'X'.
PERFORM BUILD_FIELDCAT USING 'MAKTX' '' '' '' '' '' '' '物料描述' ''.
PERFORM BUILD_FIELDCAT USING 'SDDAT' '' '' '' '' '' '' '发货日期' ''.
PERFORM BUILD_FIELDCAT USING 'SOURSE' '' '' '' '' '' '' 'MES源' ''.
PERFORM BUILD_FIELDCAT USING 'KUNNR' '' '' '' '' '' '' '客户代码' 'X'.
PERFORM BUILD_FIELDCAT USING 'BARCODE' '' '' '' '' '' '' '完整条码' ''.
gs_layout-cwidth_opt = 'X'.
gs_layout-zebra = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
" I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_ALV'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND_ALV'
IT_FIELDCAT_LVC = GT_FIELDCAT
IS_LAYOUT_LVC = GS_LAYOUT
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = GT_DATA
EXCEPTIONS
OTHERS = 1.
CLEAR GT_DATA[].
ENDFORM. "DISPLAY_DATA
**&---------------------------------------------------------------------*
**& FORM PF_STATUS_ALV
**&---------------------------------------------------------------------*
** TEXT
**----------------------------------------------------------------------*
*FORM PF_STATUS_ALV USING RT_EXTAB TYPE SLIS_T_EXTAB .
* SET PF-STATUS 'STATUS_ALV' EXCLUDING RT_EXTAB.
*ENDFORM. "PF_STATUS_ALV
*&---------------------------------------------------------------------*
*& FORM USER_COMMAND_ALV
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
FORM USER_COMMAND_ALV USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
CASE RS_SELFIELD-FIELDNAME.
WHEN ''.
* CHECK RS_SELFIELD-VALUE IS NOT INITIAL.
* SET PARAMETER ID 'MBN' FIELD RS_SELFIELD-VALUE.
* CALL TRANSACTION 'MB03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDCASE.
ENDFORM. "USER_COMMAND_ALV