*&---------------------------------------------------------------------
*& Report Zrpp0027 *
*&---------------------------------------------------------------------*
*& Company ASAT Company Limited *
*& Report Zrpp0027 *
*& *
*& Autor : robbin *
*& *
*& Date : 0806.2005 *
*&---------------------------------------------------------------------*
*& Description: *
*& *
*& compare production order released with mes MGORDER *
*& *
*& ADD NEW PLANT 3200
*& AUTHOR:
*& ROBBIN
*& DATE :
*& 2005.12.06
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
*& Modification LOG *
*& *
*& Log by date description *
*& 001 Watson yuan 11/07/2006 Task#772: add columns "DEVK921032 *
*&---------------------------------------------------------------------*
*& 874 Leo Lee 01/19/2007 DEVK921802 *
*&It is requested to add some information into the report ZRPP0027. *
*&They are the fab lot number, the wafer received date, the IQA Run *
*&Card received date and the IQA wafer released date. *
*&---------------------------------------------------------------------*
*& 003 Vista 2007-10-19 Add lot type in order compare report *
*& "DEVK923435 [1521] *
*& SD080208 Wei_Zhu Add Section per Strip, Unit per Section and Unit
*& per Strip to ZRPP027 Report Transport# DEVK924136
*& 005 vista 2008-05-27 add two fields:Total Wires,Total Strips
*& "DEVK924607 [DS080521]
*& 006 vista 2008-06-05 Add Wire information into report ZRPP0027
*& "DEVK924705 [DS080605]
*& 007 wei_zhu 2008-07-02 Add condition type[ASSM & TSTA]
* price[ZRPP0027]
*& Tast#DS080614 Request# DEVK924881
* Request# DEVK924894
*& 008 vista 2008-07-14 "DEVK924986 [BS080703]
* The PERIOD INDICATOR field is no correct value sometimes.
*& 009 vista 2008-08-21 Add some new logic for hyperion
*& "DEVK925354 [DS080802]
*& 010 vista 2008-09-02 fix a bug for get package name
*& "DEVK925460 [DS080802]
*& 011 vista 2008-11-03 add Orig.Start Date in this report
*& "DEVK925891 [DS081013]
*&---------------------------------------------------------------------*
REPORT ZRPP0027.
*----------------------------------------------------------------------*
* Tables *
*----------------------------------------------------------------------*
TYPE-POOLS: SLIS,KKBLO.
TABLES: AFKO, AUFK, JEST, JCDS,MAKT,USR21,ADCP,DBCON, KNA1,MCHB,
RESB,MCHA,VBAP,VBAK, MARA, MARM,MARC,KONV,DRAD_PORDER,DRAW.
*----------------------------------------------------------------------*
* Global Data Declaration *
*----------------------------------------------------------------------*
DATA:BEGIN OF IAFKO OCCURS 0.
INCLUDE STRUCTURE AFKO.
DATA: OBJNR LIKE AUFK-OBJNR,
WERKS LIKE AUFK-WERKS,
END OF IAFKO.
*DATA IAFKO LIKE AFKO OCCURS 0 WITH HEADER LINE.
DATA IJCDS LIKE JCDS OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF V_ITAB OCCURS 0,
WERKS LIKE AUFK-WERKS,
AUFNR LIKE AFPO-AUFNR, "Order Number
KDMAT LIKE VBAP-KDMAT,
MFG LIKE AFPO-AUFNR, "Order Number
LOT LIKE VBAP-KDMAT,
GSTRP LIKE AFKO-GSTRP,
UDATE LIKE JCDS-UDATE,
UTIME LIKE JCDS-UTIME,
USNAM LIKE JCDS-USNAM,
PDATE LIKE JCDS-UDATE,
PTIME LIKE JCDS-UTIME,
PSNAM LIKE JCDS-USNAM,
* start 001 "DEVK921032
KUNNR LIKE VBPA-KUNNR,
NAME1 LIKE KNA1-NAME1,
CDIM LIKE CLOBJDAT-AUSP1, "Dimension
* CPACK LIKE SCLASS-CLASS,
PACKAGE(30),
CLEAD LIKE CLOBJDAT-AUSP1, "lead count
MATNR LIKE VBAP-MATNR,
MAKTX LIKE MAKT-MAKTX,
KWMENG LIKE VBAP-KWMENG, "Order quantity
KDAUF LIKE AFPO-KDAUF, "Sales order number
KDPOS LIKE AFPO-KDPOS, "Sales order item
ERDAT LIKE VBAP-ERDAT,
FABLOT LIKE VBAP-KDMAT, "Fab lot number DEVK921802
LWEDT LIKE MCHA-LWEDT, "Last GR date DEVK921802
REC_D LIKE JCDS-UDATE, "IQA Runcard Received Date DEVK921802
REC_T LIKE JCDS-UTIME, "IQA Runcard Received time
WRL_D LIKE JCDS-UDATE, "IQA Release date DEVK921802
WRL_T LIKE JCDS-UTIME, "IQA Runcard Release time
* end 001 "DEVK921032
*Start Vista "DEVK923435 [1521]
LPRIO LIKE VBAP-LPRIO, "Delivery priority
AUART LIKE VBAK-AUART, "sales order type
LOT_TYPE(16) TYPE C, "Lot type
NUM_WIRES(10) TYPE C,
*End Vista "DEVK923435 [1521]
*DEVK924136 Begin
RM_SECT_ST(16) TYPE C, "Section Per Strip
RM_UNIT_SE(16) TYPE C, "Unit per Section
RM_UNIT_ST(16) TYPE C, "Unit per Strip
*DEVK924136 End
*Start vista "DEVK924607 [DS080521]
TOTAL_WIRES TYPE I,
TOTAL_STRIPS TYPE I,
*End vista "DEVK924607 [DS080521]
*Start vista "DEVK924705 [DS080605]
WIRE_SIZE(10) TYPE C,
WIRE_LENGTH TYPE P DECIMALS 3,
WIRE_ROLL TYPE P DECIMALS 2,
AUFLD LIKE AFKO-AUFLD,
WIRE_MAT LIKE MARM-MATNR,
PERIOD_INDICATOR(12) TYPE C,
KAUSF LIKE MARC-KAUSF,
*End vista "DEVK924705 [DS080605]
* DEVK924881-->
ASSM_AM TYPE P DECIMALS 5,
TSTA_AM TYPE P DECIMALS 5,
TOTAL_AM TYPE P DECIMALS 5,
* DEVK924881<--
*Start vista "DEVK925891 [DS081013]
ZZOBSDT LIKE AUFK-ZZOBSDT,
*End vista "DEVK925891 [DS081013]
*Start vista "DEVK925354 [DS080802]
DIM_DEVICE(60),
DIM_SO(60),
DIM_PO(65), "Product
DIM_SUBLOT(60),
DIM_CUST(60),
DIM_BATCH(60),
DIM_DN(60),
DIM_BILL(60),
DOCU_NO(60),
CHARG LIKE MCHA-CHARG,
LGORT LIKE MCHB-LGORT,
*End vista "DEVK925354 [DS080802]
* WERKS(4), "plant
END OF V_ITAB.
DATA: BEGIN OF PODATE OCCURS 0,
AUFNR LIKE AFPO-AUFNR, "Order Number
GSTRP LIKE AFKO-GSTRP,
STAT LIKE JCDS-STAT,
UDATE LIKE JCDS-UDATE,
UTIME LIKE JCDS-UTIME,
USNAM LIKE JCDS-USNAM,
END OF PODATE.
DATA: BEGIN OF ITAB OCCURS 0,
AUFNR LIKE AFPO-AUFNR, "Order Number
RSNUM LIKE AFKO-RSNUM, "Reversion number
KDAUF LIKE AFPO-KDAUF, "Sales order number
KDPOS LIKE AFPO-KDPOS, "Sales order item
WEMNG LIKE AFPO-WEMNG, "po Qty
MATNR LIKE VBAP-MATNR,
ARKTX LIKE VBAP-ARKTX,
WERKS LIKE VBAP-WERKS,
VBELN LIKE VBAP-VBELN,
ZZTRC_CD LIKE VBAP-ZZTRC_CD,
KDMAT LIKE VBAP-KDMAT,
KUNNR LIKE VBPA-KUNNR,
* CPACK LIKE SCLASS-CLASS,
PACKAGE(30),
CLEAD LIKE CLOBJDAT-AUSP1,
CDIM LIKE CLOBJDAT-AUSP1,
CFTP LIKE CLOBJDAT-AUSP1, "Foot print
CBST LIKE CLOBJDAT-AUSP1, "Build sheet
MOLD LIKE CLOBJDAT-AUSP1, "PACKAGE_THICKNESS
SUBQTY LIKE CLOBJDAT-AUSP1,
* start 001 "DEVK921032
ERDAT LIKE VBAP-ERDAT,
KWMENG LIKE VBAP-KWMENG,
MAKTX LIKE MAKT-MAKTX,
NAME1 LIKE KNA1-NAME1,
* end 001 "DEVK921032
*Start Vista "DEVK923435 [1521]
LPRIO LIKE VBAP-LPRIO, "Delivery priority
AUART LIKE VBAK-AUART, "sales order type
LOT_TYPE(16) TYPE C, "Lot type
NUM_WIRES(10) TYPE C,
*End Vista "DEVK923435 [1521]
*DEVK924136 Begin
RM_SECT_ST(16) TYPE C, "Section Per Strip
RM_UNIT_SE(16) TYPE C, "Unit per Section
RM_UNIT_ST(16) TYPE C, "Unit per Strip
*DEVK924136 End
* WERKS(4), "plant
*Start vista "DEVK925891 [DS081013]
ZZOBSDT LIKE AUFK-ZZOBSDT,
*End vista "DEVK925891 [DS081013]
END OF ITAB.
DATA: BEGIN OF V_MCHB OCCURS 0,
WERKS LIKE MCHB-WERKS,
MATNR LIKE MCHB-MATNR,
CHARG LIKE MCHB-CHARG,
LGORT LIKE MCHB-LGORT,
END OF V_MCHB.
* Urgent status
DATA: BEGIN OF GT_URGENT OCCURS 0,
ESTAT LIKE TJ30T-ESTAT, "User status
TXT04 LIKE TJ30T-TXT04, "Status
END OF GT_URGENT.
DATA : L_LINES TYPE I.
*----------------------------------------------------------------------*
* Global Data Declaration *
*----------------------------------------------------------------------*
*Start vista "DEVK924607 [DS080521]
DATA: G_SVFILE LIKE RLGRAP-FILENAME.
DATA: G_REPID LIKE SY-REPID, "Report Name
G_SAVE(1) TYPE C, "Save Variants
GX_VARIANT LIKE DISVARIANT, "Layout Variant
G_VARIANT LIKE DISVARIANT, "Layout Variant
GT_FIELDCAT TYPE LVC_T_FCAT, "Table Field Catalog
GT_FIELDCATA TYPE SLIS_T_FIELDCAT_ALV, "ALV Field Catalog
GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER, "ALV Top-of-page
GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
*End vista "DEVK924607 [DS080521]
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, "ALV Field Catalog
* FC_STR TYPE SLIS_FIELDCAT_ALV,
LAYOUT TYPE SLIS_LAYOUT_ALV,
TITLE TYPE LVC_TITLE,
REPID LIKE SY-REPID,
EVENT TYPE SLIS_T_EVENT,
VARIANT LIKE DISVARIANT, "Layout Variant
* SORT TYPE SLIS_T_SORTINFO_ALV,
* SORT_STR TYPE SLIS_SORTINFO_ALV,
TOP_OF_PAGE TYPE SLIS_T_LISTHEADER. "ALV Top-of-page
DATA: BEGIN OF GT_SQL_QUERY_001 OCCURS 0,
FIELD_001(16) TYPE C, " Mfg Order
FIELD_002(30) TYPE C, " ContainerName
PLANT(10), "Plant
END OF GT_SQL_QUERY_001.
DATA P_TYPE(10) TYPE C.
**************************************************************
*DATA: G_REPID LIKE SY-REPID, "Report Name
* G_SAVE(1) TYPE C, "Save Variants
* GX_VARIANT LIKE DISVARIANT, "Layout Variant
* G_VARIANT LIKE DISVARIANT, "Layout Variant
* GT_FIELDCAT TYPE LVC_T_FCAT, "Table Field Catalog
* GT_FIELDCATA TYPE SLIS_T_FIELDCAT_ALV, "ALV Field Catalog
* GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER. "ALV Top-of-page
DATA L_OBJECTID LIKE CDHDR-OBJECTID.
DATA:BEGIN OF I_CLASS OCCURS 5.
INCLUDE STRUCTURE SCLASS. "^_n_516772
DATA:END OF I_CLASS.
DATA:BEGIN OF I_CLOBJDAT OCCURS 50.
INCLUDE STRUCTURE CLOBJDAT.
DATA:END OF I_CLOBJDAT.
DATA:CH_OBJECT LIKE AUSP-OBJEK, "Object Key for Classification
CH_CLASSTYPE LIKE KLAH-KLART, "classtype batch
BEGIN OF MCHA_OBJECT OCCURS 0, "Object Key MCHA
MATNR LIKE MCHA-MATNR,
WERKS LIKE MCHA-WERKS,
CHARG LIKE MCHA-CHARG,
END OF MCHA_OBJECT,
BEGIN OF MCH1_OBJECT, "Object Key MCH1
MATNR LIKE MCH1-MATNR,
CHARG LIKE MCH1-CHARG,
END OF MCH1_OBJECT,
CH_TABLE LIKE TCLA-OBTAB. "object table batch
DATA:L_OBJNR LIKE AUFK-OBJNR.
DATA:BEGIN OF I_DATE OCCURS 0,
UDATE LIKE JCDS-UDATE,
UTIME LIKE JCDS-UTIME,
END OF I_DATE.
* ALV output data table
FIELD-SYMBOLS: <GT_OUT> TYPE STANDARD TABLE. "ALV Data Table
*----------------------------------------------------------------------*
* Declarations *
*----------------------------------------------------------------------*
CONSTANTS: C_WERKS_HK LIKE T001W-WERKS VALUE '3000'.
CONSTANTS: C_WERKS_DG LIKE T001W-WERKS VALUE '3100'.
CONSTANTS: C_DBCONNAME_DEV LIKE DBCON-CON_NAME
VALUE 'HKMDDB',
C_DBCONNAME_PRD LIKE DBCON-CON_NAME
VALUE 'SQLDB1'.
CONSTANTS: C_DBCONNAME_HKM LIKE DBCON-CON_NAME
VALUE 'HKMDDB',
C_DBCONNAME_DGM LIKE DBCON-CON_NAME
VALUE 'DGMDDB'.
CONSTANTS: C_DBCONNAME_TEST LIKE DBCON-CON_NAME
VALUE 'HKMDDB_TEST1'.
CONSTANTS: C_MATCLTYPE LIKE KLAH-KLART VALUE '001'. "Material Class
*Start vista "DEVK925354 [DS080802]
**ALV Display variant
DATA: G_DISP_VAR LIKE DISVARIANT,
GX_DISP_VAR LIKE DISVARIANT.
* Internal table to store saved display variant
DATA GT_FCAT_SAV TYPE KKBLO_FIELDCAT OCCURS 0 WITH HEADER LINE.
DATA GT_SORT_SAV TYPE KKBLO_SORTINFO OCCURS 0 WITH HEADER LINE.
DATA GT_FILTER_SAV TYPE KKBLO_FILTER OCCURS 0 WITH HEADER LINE.
DATA GS_LAYOUT_SAV TYPE KKBLO_LAYOUT.
DATA GS_LAYOUT_LVC TYPE LVC_S_LAYO.
*DATA: G_SVFILE LIKE RLGRAP-FILENAME.
FIELD-SYMBOLS: <ITAB> TYPE STANDARD TABLE.
FIELD-SYMBOLS: <LS_OUT>.
DATA:LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:LS_FCAT LIKE LINE OF GT_FIELDCATA.
DATA:L_FIELD(400) TYPE C.
DATA:L_STRING(4000) TYPE C,
L_INDEX TYPE I.
FIELD-SYMBOLS:<L_LINE> TYPE ANY,
<L_FIELD> TYPE ANY.
DATA:WA_LINE TYPE REF TO DATA.
FIELD-SYMBOLS: <FS> TYPE ANY,
<FS2> TYPE ANY,
<FS1> TYPE ANY.
DATA:BEGIN OF LT_OUT OCCURS 0,
TEXT(60),
QTY(20),
AMT(20),
END OF LT_OUT.
*End "DEVK925354 [DS080802]
*----------------------------------------------------------------------*
* Selection Screen *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-S10.
SELECT-OPTIONS:S_FTRMS FOR AFKO-FTRMS,
S_WERKS FOR AUFK-WERKS DEFAULT '3100'.
SELECTION-SCREEN END OF BLOCK A.
SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-001.
* DEVK924881-->
PARAMETER: P_CH_P AS CHECKBOX DEFAULT ''.
* DEVK924881<--
PARAMETER: L_CK AS CHECKBOX DEFAULT ''.
*Start vista "DEVK924607 [DS080521]
PARAMETER: L_WIRE AS CHECKBOX DEFAULT ''.
PARAMETER: P_HYPE AS CHECKBOX DEFAULT ''.
SELECTION-SCREEN END OF BLOCK B.
SELECTION-SCREEN BEGIN OF BLOCK C WITH FRAME TITLE TEXT-002.
PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.
SELECTION-SCREEN END OF BLOCK C.
SELECTION-SCREEN BEGIN OF BLOCK D WITH FRAME TITLE TEXT-003.
PARAMETERS: L_SAVE AS CHECKBOX DEFAULT ''.
PARAMETERS: P_SVPATH LIKE RLGRAP-FILENAME MODIF ID PTH MEMORY ID PAT.
PARAMETERS: P_SVFILE LIKE RLGRAP-FILENAME NO-DISPLAY.
*End vista "DEVK924607 [DS080521]
SELECTION-SCREEN END OF BLOCK D.
*----------------------------------------------------------------------*
* SELECTION SCREEN *
*----------------------------------------------------------------------*
*Start vista "DEVK924607 [DS080521]
*DEVK924894-->
AT SELECTION-SCREEN.
IF L_WIRE = 'X' AND L_CK <> 'X'.
MESSAGE E001(00) WITH
'You must choose the With Component Information'.
ENDIF.
*End vista "DEVK924607 [DS080521]
IF P_CH_P ='X'.
AUTHORITY-CHECK OBJECT 'Z_KONV_VIW'
ID 'ACTVT' FIELD '03'.
IF SY-SUBRC NE 0.
MESSAGE E001(00) WITH
'You do not have view price authorization in this report!'.
ENDIF.
ENDIF.
*DEVK924894<--
* Process on value request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
PERFORM F4_FOR_VARIANT.
* PAI
AT SELECTION-SCREEN ON P_VARI.
PERFORM VALIDATE_VARIANT.
*----------------------------------------------------------------------*
* Initialization *
*----------------------------------------------------------------------*
INITIALIZATION.
G_REPID = SY-REPID.
* Set Options: Save variants user-specific or general
G_SAVE = 'A'.
* Initialize variant
PERFORM VARIANT_INIT.
* Get default values
PERFORM GET_DEFAULT.
*----------------------------------------------------------------------*
* Top-Of-Page *
*----------------------------------------------------------------------*
TOP-OF-PAGE.
* PERFORM TOP_OF_PAGE.
*----------------------------------------------------------------------*
* Start of Selection *
*----------------------------------------------------------------------*
START-OF-SELECTION.
***Get data
* PERFORM GET_DATA.
*----------------------------------------------------------------------*
* End of Selection *
*----------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM GET_DATA.
PERFORM GET_DATA_MES.
LOOP AT ITAB.
CLEAR V_ITAB.
MOVE-CORRESPONDING ITAB TO V_ITAB.
* CONCATENATE '00000' gt_sql_query_001-field_001 into MSEG_LINES-AUFNR.
READ TABLE GT_SQL_QUERY_001 WITH KEY FIELD_001 = ITAB-AUFNR+5(7).
IF SY-SUBRC = 0 OR SY-SUBRC = 2.
V_ITAB-MFG = ITAB-AUFNR.
V_ITAB-LOT = GT_SQL_QUERY_001-FIELD_002.
DELETE GT_SQL_QUERY_001
WHERE FIELD_001 = ITAB-AUFNR+5(7).
ENDIF.
* Add begin of DEVK921802
REFRESH MCHA_OBJECT.
CLEAR MCHA_OBJECT.
CLEAR RESB.
SELECT CHARG MATNR
INTO (RESB-CHARG,RESB-MATNR)
FROM RESB
WHERE RSNUM = ITAB-RSNUM
AND AUFNR = ITAB-AUFNR
AND WERKS = ITAB-WERKS
AND MATKL = 'WAFER'.
IF RESB-CHARG NE SPACE.
* read classification depending on batch level
CLEAR CH_OBJECT.
CH_CLASSTYPE = '022'.
CH_TABLE = 'MCHA'.
MCHA_OBJECT-MATNR = RESB-MATNR. "Concatenate Object Key
MCHA_OBJECT-WERKS = ITAB-WERKS.
MCHA_OBJECT-CHARG = RESB-CHARG.
APPEND MCHA_OBJECT.
CLEAR MCHA_OBJECT.
ENDIF.
ENDSELECT.
SORT MCHA_OBJECT BY CHARG.
READ TABLE MCHA_OBJECT INDEX 1.
IF SY-SUBRC EQ 0.
MOVE MCHA_OBJECT TO CH_OBJECT.
* DELETE Release PO batch
REFRESH I_CLASS.
CLEAR I_CLASS.
REFRESH I_CLOBJDAT.
CLEAR I_CLOBJDAT.
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
CLASSTYPE = CH_CLASSTYPE
FEATURES = 'X'
OBJECT = CH_OBJECT
OBJECTTABLE = CH_TABLE
TABLES
T_CLASS = I_CLASS
T_OBJECTDATA = I_CLOBJDAT
EXCEPTIONS
NO_CLASSIFICATION = 1
NO_CLASSTYPES = 2.
CHECK SY-SUBRC = 0.
SORT I_CLOBJDAT BY ZAEHL.
READ TABLE I_CLOBJDAT WITH KEY ATNAM = 'DB_FL'.
IF SY-SUBRC = 0.
MOVE I_CLOBJDAT-AUSP1 TO V_ITAB-FABLOT.
ENDIF.
ENDIF.
CLEAR MCHA.
SELECT SINGLE LWEDT
INTO MCHA-LWEDT
FROM MCHA
WHERE MATNR = MCHA_OBJECT-MATNR
AND WERKS = MCHA_OBJECT-WERKS
AND CHARG = MCHA_OBJECT-CHARG.
IF SY-SUBRC EQ 0.
V_ITAB-LWEDT = MCHA-LWEDT.
ENDIF.
CLEAR L_OBJNR.
CONCATENATE 'OR' ITAB-AUFNR INTO L_OBJNR.
CLEAR JCDS.
REFRESH I_DATE.
CLEAR I_DATE.
SELECT UDATE UTIME
INTO (JCDS-UDATE, JCDS-UTIME)
FROM JCDS
WHERE OBJNR = L_OBJNR
AND STAT = 'E0125' "IQA receive date
AND INACT = SPACE.
I_DATE-UDATE = JCDS-UDATE.
I_DATE-UTIME = JCDS-UTIME.
APPEND I_DATE.
CLEAR I_DATE.
ENDSELECT.
SORT I_DATE BY UDATE DESCENDING UTIME DESCENDING.
READ TABLE I_DATE INDEX 1.
IF SY-SUBRC EQ 0.
V_ITAB-REC_D = I_DATE-UDATE.
V_ITAB-REC_T = I_DATE-UTIME.
ENDIF.
REFRESH I_DATE.
CLEAR I_DATE.
SELECT UDATE
INTO JCDS-UDATE
FROM JCDS
WHERE OBJNR = L_OBJNR
AND STAT = 'E0126' "IQA Wafer release date
AND INACT = SPACE.
I_DATE-UDATE = JCDS-UDATE.
I_DATE-UTIME = JCDS-UTIME.
APPEND I_DATE.
CLEAR I_DATE.
ENDSELECT.
SORT I_DATE BY UDATE DESCENDING UTIME DESCENDING.
READ TABLE I_DATE INDEX 1.
IF SY-SUBRC EQ 0.
V_ITAB-WRL_D = I_DATE-UDATE.
V_ITAB-WRL_T = I_DATE-UTIME.
ENDIF.
*Add end of DEVK921802
APPEND V_ITAB.
ENDLOOP.
LOOP AT GT_SQL_QUERY_001.
CLEAR V_ITAB.
CONCATENATE '00000' GT_SQL_QUERY_001-FIELD_001 INTO V_ITAB-MFG.
V_ITAB-LOT = GT_SQL_QUERY_001-FIELD_002.
APPEND V_ITAB.
ENDLOOP.
*********************************
LOOP AT V_ITAB.
READ TABLE PODATE WITH KEY AUFNR = V_ITAB-AUFNR
STAT = 'I0002'.
IF SY-SUBRC = 0.
V_ITAB-GSTRP = PODATE-GSTRP.
V_ITAB-UDATE = PODATE-UDATE.
V_ITAB-UTIME = PODATE-UTIME.
V_ITAB-USNAM = PODATE-USNAM.
MODIFY V_ITAB.
ENDIF.
READ TABLE PODATE WITH KEY AUFNR = V_ITAB-AUFNR
STAT = 'E0085'.
IF SY-SUBRC = 0.
V_ITAB-PDATE = PODATE-UDATE.
V_ITAB-PTIME = PODATE-UTIME.
V_ITAB-PSNAM = PODATE-USNAM.
MODIFY V_ITAB.
ENDIF.
ENDLOOP.
*********************************
*Start vista "DEVK924607 [DS080521]
*Calculate toatl wires qty
IF L_WIRE = 'X'.
PERFORM CAL_WIRES.
*Start vista "DEVK924667
PERFORM GET_WIRE_INFOMATION.
*End vista "DEVK924667
ENDIF.
*End vista "DEVK924607 [DS080521]
* DEVK924881-->
IF P_CH_P ='X'.
PERFORM FILL_UNIT_PRICE_DATA.
ENDIF.
* DEVK924881<--
*Start vista "DEVK925354 [DS080802]
IF P_HYPE = 'X'.
P_CH_P = 'X'.
PERFORM PROCESS_DATA.
ENDIF.
*End vista "DEVK925354 [DS080802]
PERFORM BUILD_FIELDCAT.
* Generate ALV data table
PERFORM GENERATE_OUT_TABLE.
* Fill ALV data table
PERFORM GET_LIST.
* Set top-of-page content
PERFORM SET_TOP_OF_PAGE.
* Display report
PERFORM ALV_OUTPUT.
*Start vista "DEVK924607 [DS080521]
IF L_SAVE = 'X'.
IF P_HYPE = 'X'.
PERFORM DOWNLOAD_FILE_TO_SERVER.
ELSE.
PERFORM DOWNLOAD_FILE USING P_SVPATH.
ENDIF.
ENDIF.
*End vista "DEVK924607 [DS080521]
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* Get data from database
*----------------------------------------------------------------------*
FORM GET_DATA .
PERFORM GET_PRODUCTION_ORDER.
***Get details
PERFORM GET_PO_ITEM. "Get Production Order Item
* Get urgent status
PERFORM GET_URGENT_STATUS.
PERFORM GET_SALES_ORDER.
IF L_CK ='X'.
PERFORM GET_CHECKBOX_DATA.
ENDIF.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form GET_PO_ITEM
*&---------------------------------------------------------------------*
* Get Production Order item
*----------------------------------------------------------------------*
FORM GET_PO_ITEM .
DESCRIBE TABLE IAFKO LINES L_LINES .
IF L_LINES > 0.
SELECT AFKO~AUFNR AFKO~RSNUM AFPO~KDAUF AFPO~KDPOS PSMNG AUFK~WERKS
*Start vista "DEVK925891 [DS081013]
AUFK~ZZOBSDT
*End vista "DEVK925891 [DS081013]
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM AFPO
JOIN AFKO
ON AFPO~AUFNR = AFKO~AUFNR
INNER JOIN AUFK
ON AUFK~AUFNR = AFPO~AUFNR
FOR ALL ENTRIES IN IAFKO
WHERE AFPO~AUFNR = IAFKO-AUFNR
AND AFPO~KDAUF <> ''.
ELSE.
MESSAGE E001(00) DISPLAY LIKE 'E' WITH 'NOT DATA BE SELECTED'.
ENDIF.
ENDFORM. " GET_PO_ITEM
*&---------------------------------------------------------------------*
*& Form GET_PRODUCTION_ORDER
*&---------------------------------------------------------------------*
* Get Production Order Item
*----------------------------------------------------------------------*
FORM GET_PRODUCTION_ORDER .
DATA NUM TYPE I.
SELECT * INTO CORRESPONDING FIELDS OF TABLE IAFKO
FROM AFKO
INNER JOIN AUFK
ON AFKO~AUFNR = AUFK~AUFNR
WHERE AFKO~FTRMI IN S_FTRMS " FTRMS
AND AUFK~WERKS IN S_WERKS.
SORT IAFKO BY AUFNR.
LOOP AT IAFKO.
* CLEAR AUFK.
CLEAR JEST.
* SELECT SINGLE * FROM AUFK
* WHERE AUFNR = IAFKO-AUFNR
* AND WERKS = V_WERKS.
IF NOT IAFKO-OBJNR IS INITIAL.
SELECT SINGLE * FROM JCDS
WHERE OBJNR = IAFKO-OBJNR
AND STAT = 'I0002'
AND INACT NE 'X'
AND CHIND = 'I'.
IF SY-SUBRC = 4.
DELETE IAFKO.
ELSE.
PODATE-AUFNR = IAFKO-AUFNR.
PODATE-GSTRP = IAFKO-GSTRP.
PODATE-UDATE = JCDS-UDATE.
PODATE-UTIME = JCDS-UTIME.
PODATE-USNAM = JCDS-USNAM.
PODATE-STAT = 'I0002'.
APPEND PODATE.
ENDIF.
**********************************
* GET PRINT RUNCAR DATE AND TIME
***********************************
SELECT SINGLE * FROM JCDS
WHERE OBJNR = IAFKO-OBJNR
AND STAT = 'E0085'
AND INACT NE 'X'
AND CHIND = 'I'.
IF SY-SUBRC = 0.
PODATE-AUFNR = IAFKO-AUFNR.
PODATE-UDATE = JCDS-UDATE.
PODATE-UTIME = JCDS-UTIME.
PODATE-USNAM = JCDS-USNAM.
PODATE-STAT = 'E0085'.
APPEND PODATE.
ENDIF.
ENDIF.
* *******************************
* FILTER PRODUCTION ORDER DELETED
* *******************************
IF NOT IAFKO-OBJNR IS INITIAL.
SELECT * INTO TABLE IJCDS FROM JCDS
WHERE OBJNR = IAFKO-OBJNR
AND STAT = 'I0076'
ORDER BY UDATE UTIME DESCENDING.
NUM = 1.
LOOP AT IJCDS.
IF NUM = 1 .
IF IJCDS-INACT NE 'X' AND IJCDS-CHIND = 'I'.
DELETE IAFKO.
ENDIF.
EXIT.
ENDIF.
ENDLOOP.
* SELECT SINGLE * FROM JCDS
* WHERE OBJNR = AUFK-OBJNR
* AND STAT = 'I0076'
* AND INACT NE 'X'
* AND CHIND = 'I'.
*
* IF SY-SUBRC = 0.
* DELETE IAFKO.
* ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. "GET_PRODUCTION_ORDER
*&---------------------------------------------------------------------*
*& Form GET_SALES_ORDER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_SALES_ORDER .
* start 001 "DEVK921032
DATA: LT_CLASS LIKE SCLASS OCCURS 0 WITH HEADER LINE,
LT_CLOBJDAT LIKE CLOBJDAT OCCURS 0 WITH HEADER LINE,
L_OBJEK LIKE AUSP-OBJEK,
*Start Vista "DEVK923435 [1521]
LT_STATUS LIKE JSTAT OCCURS 0 WITH HEADER LINE,
LT_ORDER_STATUS LIKE ZPP_ORDER_STATUS OCCURS 0 WITH HEADER LINE.
DATA: L_PACKAGE(30),
L_PKG_GRP(50),
L_RET(40) TYPE N,
L_PACKAGE_NAME LIKE KLAH-CLASS.
*End Vista "DEVK923435 [1521]
* end 001 "DEVK921032
LOOP AT ITAB.
SELECT MATNR ARKTX WERKS VBELN ZZTRC_CD KDMAT LPRIO
* start 001 "DEVK921032
ERDAT KWMENG
FROM VBAP INTO (ITAB-MATNR, ITAB-ARKTX, ITAB-WERKS,
ITAB-VBELN, ITAB-ZZTRC_CD, ITAB-KDMAT, ITAB-LPRIO,
ITAB-ERDAT, ITAB-KWMENG )
* end 001 "DEVK921032
WHERE VBELN = ITAB-KDAUF
AND POSNR = ITAB-KDPOS.
SELECT SINGLE AUART
* start 001 "DEVK921032
KUNNR
FROM VBAK INTO (ITAB-AUART, ITAB-KUNNR)
* end 001 "DEVK921032
WHERE VBELN = ITAB-KDAUF.
*Start Vista "DEVK923435 [1521]
IF ITAB-AUART = 'SAMP' OR ITAB-AUART = 'QUAL' OR ITAB-AUART =
'ENG'.
ITAB-LOT_TYPE = ITAB-AUART.
ELSE.
ITAB-LOT_TYPE = 'NORMAL'.
ENDIF.
IF ITAB-LPRIO(1) <> '0' AND ITAB-LPRIO(1) <> '9'.
CONCATENATE ITAB-LOT_TYPE '/' 'HOT' ITAB-LPRIO(1) INTO
ITAB-LOT_TYPE.
ENDIF.
CALL FUNCTION 'ZPP_GET_STATUS'
EXPORTING
AUFNR = ITAB-AUFNR
TABLES
STATUS = LT_STATUS
ORDER_STATUS = LT_ORDER_STATUS.
LOOP AT GT_URGENT.
READ TABLE LT_STATUS WITH KEY STAT = GT_URGENT-ESTAT
INACT = ''.
IF SY-SUBRC = 0.
CONCATENATE ITAB-LOT_TYPE GT_URGENT-TXT04
INTO ITAB-LOT_TYPE SEPARATED BY '/'.
ENDIF.
ENDLOOP.
IF ITAB-LOT_TYPE(1) = '/'.
ITAB-LOT_TYPE(1) = ''.
CONDENSE ITAB-LOT_TYPE.
ENDIF.
*End Vista "DEVK923435 [1521]
* start 001 "DEVK921032
* GET material description
SELECT SINGLE * FROM MAKT
WHERE MATNR = ITAB-MATNR
AND SPRAS = 'EN'.
IF SY-SUBRC = 0.
ITAB-MAKTX = MAKT-MAKTX.
ENDIF.
* Get customer name
SELECT SINGLE * FROM KNA1
WHERE KUNNR = ITAB-KUNNR
AND SPRAS = 'EN'.
IF SY-SUBRC = 0.
ITAB-NAME1 = KNA1-NAME1.
ENDIF.
*Get material characteristic
L_OBJEK = ITAB-MATNR.
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
CLASSTYPE = '001'
OBJECT = L_OBJEK
TABLES
T_CLASS = LT_CLASS
T_OBJECTDATA = LT_CLOBJDAT
EXCEPTIONS
OTHERS = 4.
IF SY-SUBRC = 0.
*get package name
* READ TABLE LT_CLASS INDEX 1.
* IF SY-SUBRC = 0.
* ITAB-CPACK = LT_CLASS-CLASS.
* ENDIF.
*get lead count
READ TABLE LT_CLOBJDAT WITH KEY ATNAM = 'LEAD'.
IF SY-SUBRC = 0.
ITAB-CLEAD = LT_CLOBJDAT-AUSP1.
ENDIF.
*get Package Dimension
READ TABLE LT_CLOBJDAT WITH KEY ATNAM = 'PACKAGE_DIMENSION'.
IF SY-SUBRC = 0.
ITAB-CDIM = LT_CLOBJDAT-AUSP1.
ENDIF.
*Start Vista "DEVK923435 [1521]
*get Number of wires
READ TABLE LT_CLOBJDAT WITH KEY ATNAM = 'NUMBER_OF_WIRES'.
IF SY-SUBRC = 0 AND LT_CLOBJDAT-AUSP1 <> '?'.
ITAB-NUM_WIRES = LT_CLOBJDAT-AUSP1.
ENDIF.
*End Vista "DEVK923435 [1521]
ENDIF.
* end 001 "DEVK921032
*get package name
CALL FUNCTION 'Z_GET_PACKAGE_NAME'
EXPORTING
MATERIAL_NO = ITAB-MATNR
IMPORTING
PACKAGE_NAME = L_PACKAGE.
IF SY-SUBRC = 0.
MOVE L_PACKAGE TO ITAB-PACKAGE.
ENDIF.
MODIFY ITAB.
ENDSELECT.
CLEAR ITAB.
ENDLOOP.
ENDFORM. "GET_SALES_ORDER
*----------------------------------------------------------------------*
* Macro Definition *
*----------------------------------------------------------------------*
* Get SQL Query result
DEFINE MES_FETCH_DATA.
TRY.
EXEC SQL.
FETCH NEXT &3 INTO :&1
ENDEXEC.
CATCH CX_SY_NATIVE_SQL_ERROR.
&2 = '99'.
ENDTRY.
IF &2 NE 99.
&2 = SY-SUBRC.
ENDIF.
END-OF-DEFINITION.
* Close SQL Cursor
DEFINE MES_CLOSE_CURSOR.
TRY.
EXEC SQL.
CLOSE &1
ENDEXEC.
CATCH CX_SY_NATIVE_SQL_ERROR.
&2 = '99'.
ENDTRY.
IF &2 NE 99.
&2 = SY-SUBRC.
ENDIF.
END-OF-DEFINITION.
*&---------------------------------------------------------------------*
*& Form GET_DATA_MES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA_MES.
DATA: L_DBCONNAME LIKE DBCON-CON_NAME.
DATA: L_WERKS LIKE T001W-WERKS.
DATA: L_SUBRC LIKE SY-SUBRC.
DATA: L_DBOPEN LIKE SY-SUBRC.
DATA: P_VAL01_FROM(30) TYPE C VALUE '1950-01-01 00:00:00'.
DATA: P_VAL01_TO(30) TYPE C VALUE '9999-12-31 23:59:59'.
IF S_FTRMS-OPTION = 'EQ'.
CONCATENATE S_FTRMS-LOW+0(4) '-' S_FTRMS-LOW+4(2) '-'
S_FTRMS-LOW+6(2) ' 00:00:00' INTO P_VAL01_FROM.
CONCATENATE S_FTRMS-LOW+0(4) '-' S_FTRMS-LOW+4(2) '-'
S_FTRMS-LOW+6(2) ' 23:59:59' INTO P_VAL01_TO.
ENDIF.
IF S_FTRMS-OPTION = 'BT'.
CONCATENATE S_FTRMS-LOW+0(4) '-' S_FTRMS-LOW+4(2) '-'
S_FTRMS-LOW+6(2) ' 00:00:00' INTO P_VAL01_FROM.
CONCATENATE S_FTRMS-HIGH+0(4) '-' S_FTRMS-HIGH+4(2) '-'
S_FTRMS-HIGH+6(2) ' 23:59:59' INTO P_VAL01_TO.
ENDIF.
L_DBCONNAME = C_DBCONNAME_DGM .
L_DBOPEN = 99.
IF L_DBOPEN NE 0.
PERFORM CHECK_DBCON USING L_WERKS
CHANGING L_DBCONNAME
L_SUBRC.
PERFORM CONNECT_DBCON USING L_DBCONNAME
CHANGING L_SUBRC.
L_DBOPEN = L_SUBRC.
ENDIF.
PERFORM MES_SELECT_DATA_001 USING
P_VAL01_FROM
P_VAL01_TO
CHANGING L_SUBRC.
DO.
CLEAR GT_SQL_QUERY_001.
MES_FETCH_DATA GT_SQL_QUERY_001 L_SUBRC C1.
IF L_SUBRC NE 0.
EXIT.
ELSE.
APPEND GT_SQL_QUERY_001.
ENDIF.
ENDDO.
MES_CLOSE_CURSOR C1 L_SUBRC.
PERFORM DISCONNECT_DBCON USING L_DBCONNAME
CHANGING L_SUBRC.
CHECK S_WERKS[] IS NOT INITIAL.
DELETE GT_SQL_QUERY_001 WHERE PLANT NOT IN S_WERKS[].
ENDFORM. "GET_DATA_MES
*&---------------------------------------------------------------------*
*& Form connect_dbcon
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CONNECT_DBCON USING P_DBCONNAME LIKE DBCON-CON_NAME
CHANGING P_SUBRC.
TRY.
EXEC SQL.
CONNECT TO :p_dbconname
ENDEXEC.
EXEC SQL.
SET CONNECTION :p_dbconname
ENDEXEC.
CATCH CX_SY_NATIVE_SQL_ERROR.
P_SUBRC = '99'.
ENDTRY.
ENDFORM. " connect_dbcon
*&---------------------------------------------------------------------*
*& Form disconnect_dbcon
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISCONNECT_DBCON USING P_DBCONNAME LIKE DBCON-CON_NAME
CHANGING P_SUBRC.
TRY.
EXEC SQL.
DISCONNECT :p_dbconname
ENDEXEC.
CATCH CX_SY_NATIVE_SQL_ERROR.
P_SUBRC = '99'.
ENDTRY.
ENDFORM. " connect_dbcon
*&---------------------------------------------------------------------*
*& Form check_dbcon
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_DBCON USING P_PLANT
CHANGING P_DBCONNAME
P_SUBRC.
IF P_DBCONNAME IS INITIAL.
CASE P_PLANT.
WHEN C_WERKS_HK.
P_DBCONNAME = C_DBCONNAME_HKM.
WHEN C_WERKS_DG.
P_DBCONNAME = C_DBCONNAME_DGM.
ENDCASE.
ENDIF.
CLEAR DBCON.
SELECT SINGLE * FROM DBCON
WHERE CON_NAME = P_DBCONNAME.
IF SY-SUBRC NE 0.
MESSAGE E398(00)
WITH 'DB Connection ' P_DBCONNAME
'has not been set up.'
'Please check table DBCON.'.
P_SUBRC = SY-SUBRC.
CLEAR P_DBCONNAME.
ELSE.
P_SUBRC = SY-SUBRC.
ENDIF.
ENDFORM. " check_dbcon
*&---------------------------------------------------------------------*
*& Form mes_select_data_001
*&---------------------------------------------------------------------*
* text (USED IN ZRMM0021)
* Extract MES workflow current status
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM MES_SELECT_DATA_001 USING
P_DATE_FROM
P_DATE_TO
CHANGING P_SUBRC.
CLEAR P_SUBRC.
TRY.
EXEC SQL.
OPEN C1 FOR
SELECT MfgOrder.MfgOrderName,
Container.ContainerName,
MfgOrder.PLANT
FROM MfgOrder LEFT JOIN Container
ON MfgOrder.MfgOrderId = Container.MfgOrderId
WHERE ( MfgOrder.ERPReleaseDate>= :p_date_from
And MfgOrder.ERPReleaseDate<= :p_date_to )
* AND MfgOrder.PLANT = :v_WERKS
ENDEXEC.
P_SUBRC = SY-SUBRC.
CATCH CX_SY_NATIVE_SQL_ERROR.
P_SUBRC = '99'.
ENDTRY.
ENDFORM. " mes_extract_data_001
*&---------------------------------------------------------------------*
*& Form GET_requisite LIST
*&---------------------------------------------------------------------*
* GET WAREHOUSE MATERIAL QUANTITY Qual. inspection
* storage location ..
*----------------------------------------------------------------------*
FORM GET_LIST.
FIELD-SYMBOLS: <LS_OUT>.
ASSIGN LOCAL COPY OF INITIAL LINE OF <GT_OUT> TO <LS_OUT>.
LOOP AT V_ITAB.
MOVE-CORRESPONDING V_ITAB TO <LS_OUT>.
APPEND <LS_OUT> TO <GT_OUT>.
ENDLOOP.
ENDFORM. "GET_LIST
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* Build ALV Field Catalog
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT.
DATA: LS_FIELDCAT TYPE LVC_S_FCAT, "ALV Data Field Catalog
LS_FIELDCATA TYPE SLIS_FIELDCAT_ALV. "ALV Display Field Catalog
* Macro: _APPEND_FIELDCAT
* &1 - Field Name
* &2 - Reference Table
* &3 - Reference Table Field (when Field Name is different)
* &4 - Short Field Label
* &5 - Medium Field Label
* &6 - Long Field Label
* &7 - Text Field Name
* &8 - Reference Field with Quantity Unit
* &9 - Hotspot
DEFINE _APPEND_FIELDCAT.
CLEAR: LS_FIELDCAT, LS_FIELDCATA.
LS_FIELDCAT-FIELDNAME = &1.
LS_FIELDCAT-REF_TABLE = &2.
LS_FIELDCAT-REF_FIELD = &3.
LS_FIELDCATA-FIELDNAME = &1.
LS_FIELDCATA-REF_TABNAME = &2.
LS_FIELDCATA-REF_FIELDNAME = &3.
LS_FIELDCATA-SELTEXT_S = &4.
LS_FIELDCATA-SELTEXT_M = &5.
LS_FIELDCATA-SELTEXT_L = &6.
LS_FIELDCATA-REPTEXT_DDIC = &6.
LS_FIELDCATA-TEXT_FIELDNAME = &7.
LS_FIELDCATA-QFIELDNAME = &8.
* start 001 "DEVK921032
* LS_FIELDCATA-HOTSPOT = &9.
LS_FIELDCAT-DD_OUTLEN = &9.
* end 001 "DEVK921032
*Start vista "DEVK924986 [BS080703]
IF LS_FIELDCAT-FIELDNAME = 'PERIOD_INDICATOR'.
LS_FIELDCAT-OUTPUTLEN = '12'.
ENDIF.
IF LS_FIELDCAT-FIELDNAME(3) = 'DIM'.
LS_FIELDCAT-OUTPUTLEN = '60'.
ENDIF.
*End vista "DEVK924986 [BS080703]
APPEND LS_FIELDCAT TO GT_FIELDCAT.
APPEND LS_FIELDCATA TO GT_FIELDCATA.
END-OF-DEFINITION.
_APPEND_FIELDCAT 'AUFNR' 'AFPO' '' '' '' 'Order' '' '' ''.
_APPEND_FIELDCAT 'KDMAT' 'VBAP' '' '' '' 'Customer.Material' '' '' ''.
_APPEND_FIELDCAT 'MFG' 'AFPO' 'AUFNR'
'MFGORDER' 'MFGORDER' 'MFGORDER' '' '' ''.
_APPEND_FIELDCAT 'LOT' 'VBAP' 'KDMAT'
'LOT NUMBER' 'LOT NUMBER' 'LOT NUMBER' '' '' ''.
_APPEND_FIELDCAT 'GSTRP' 'AFKO' '' '' '' 'Bas.start date' '' '' ''.
*Start vista "DEVK925891 [DS081013]
_APPEND_FIELDCAT 'ZZOBSDT' 'AUFK' 'ZZOBSDT' 'start_date' 'org.strdate'
'Orig.Start Date' '' '' ''.
*End vista "DEVK925891 [DS081013]
"MATERIAL
_APPEND_FIELDCAT 'UDATE' 'JCDS' '' '' '' 'Date' '' '' ''.
"MATERIAL
_APPEND_FIELDCAT 'UTIME' 'JCDS' '' '' '' 'Time' '' '' ''.
"MATERIAL
_APPEND_FIELDCAT 'PERIOD_INDICATOR' '' '' '' '' 'PERIOD INDICATOR'
'' '' ''.
_APPEND_FIELDCAT 'USNAM' 'JCDS' '' '' '' 'Name' '' '' ''.
"MATERIAL
_APPEND_FIELDCAT 'PDATE' 'JCDS' 'UDATE'
'RUNCAR PRINT DATE' 'RUNCAR PRINT DATE' 'RUNCAR PRINT DATE' '' '' ''.
_APPEND_FIELDCAT 'PTIME' 'JCDS' 'UTIME'
'RUNCAR PRINT TIME' 'RUNCAR PRINT TIME' 'RUNCAR PRINT TIME' '' '' ''.
_APPEND_FIELDCAT 'PSNAM' 'JCDS' 'USNAM'
'RUNCAR PRINT USERS' 'RUNCAR PRINT USERS' 'RUNCAR PRINT USERS' '' ''
''.
* start 001 "DEVK921032
_APPEND_FIELDCAT 'KUNNR' '' '' '' '' 'Customer number' '' '' '30'.
_APPEND_FIELDCAT 'NAME1' 'KNA1' 'NAME1' '' ''
'Customer name' '' '' '60'.
_APPEND_FIELDCAT 'CDIM' '' '' '' '' 'Package Dimension' '' '' '40'.
* _APPEND_FIELDCAT 'CPACK' '' '' '' '' 'Package Name' '' '' '40'.
_APPEND_FIELDCAT 'PACKAGE' '' '' '' '' 'Package Name' '' '' '40'.
_APPEND_FIELDCAT 'CLEAD' '' '' '' '' 'Lead Count' '' '' '20'.
_APPEND_FIELDCAT 'MATNR' '' '' '' '' 'Device number' '' '' '30'.
_APPEND_FIELDCAT 'MAKTX' '' '' '' '' 'Device name' '' '' '60'.
_APPEND_FIELDCAT 'KWMENG' 'VBAP' 'KWMENG' '' '' 'Order qty' '' '' ''.
_APPEND_FIELDCAT 'KDAUF' 'VBAP' 'VBELN' '' '' 'Sales.Doc' '' '' ''.
_APPEND_FIELDCAT 'KDPOS' 'VBAP' 'POSNR' '' '' 'Item' '' '' ''.
_APPEND_FIELDCAT 'ERDAT' 'VBAP' 'ERDAT' '' '' 'Create On' '' '' ''.
* Add begin of DEVK921802
_APPEND_FIELDCAT 'FABLOT' '' '' '' '' 'Fab lot number' '' '' ''.
_APPEND_FIELDCAT 'LWEDT' 'MCHA' 'LWEDT' '' '' 'Last goods rec' '' ''
''.
_APPEND_FIELDCAT 'REC_D' 'MCHA' 'LWEDT' 'IQA Runcard Rec. Date'
'IQA Runcard Received Date' 'IQA Runcard Received Date' '' '' ''.
_APPEND_FIELDCAT 'REC_T' 'JCDS' 'UTIME' 'IQA Runcard Received Time'
'IQA Runcard Received Time' 'IQA Runcard Received Time' '' '' ''.
_APPEND_FIELDCAT 'WRL_D' 'MCHA' 'LWEDT' 'IQA Wafer Rel. Date'
'IQA Wafer Release date' 'IQA Wafer Release Date' '' '' ''.
_APPEND_FIELDCAT 'WRL_T' 'JCDS' 'UTIME' 'IQA Wafer Release Time'
'IQA Wafer Release Time' 'IQA Wafer Release Time' '' '' ''.
*Start Vista "DEVK923435 [1521]
_APPEND_FIELDCAT 'LPRIO' 'VBAP' '' '' '' 'Delivery priorty' '' '' ''.
_APPEND_FIELDCAT 'LOT_TYPE' '' '' '' '' 'Lot type' '' '' ''.
_APPEND_FIELDCAT 'NUM_WIRES' '' '' '' '' 'Number of wires' '' ''
''.
*End Vista "DEVK923435 [1521]
* End of DEVK921802
IF L_CK = 'X'.
_APPEND_FIELDCAT 'RM_SECT_ST' '' '' '' '' 'Section Per Strip' '' ''
''.
_APPEND_FIELDCAT 'RM_UNIT_SE' '' '' '' '' 'Unit per Section' '' ''
''.
_APPEND_FIELDCAT 'RM_UNIT_ST' '' '' '' '' 'Unit per Strip' '' '' ''.
ENDIF.
*Start vista "DEVK924607 [DS080521]
IF L_WIRE = 'X'.
_APPEND_FIELDCAT 'TOTAL_WIRES' '' '' '' '' 'Total_Wires' '' '' ''.
_APPEND_FIELDCAT 'TOTAL_STRIPS' '' '' '' '' 'TOTAL_STRIPS' '' '' ''.
*End vista "DEVK924607 [DS080521]
*Start vista "DEVK924667
_APPEND_FIELDCAT 'KAUSF' '' '' '' '' 'Wire scrap factor%' '' '' ''.
_APPEND_FIELDCAT 'WIRE_SIZE' '' '' '' '' 'Wire Size' '' '' ''.
_APPEND_FIELDCAT 'WIRE_LENGTH' '' '' '' '' 'Wire Length' '' '' ''.
_APPEND_FIELDCAT 'WIRE_ROLL' '' '' '' '' 'Wire Roll' '' '' ''.
_APPEND_FIELDCAT 'WIRE_MAT' '' '' '' '' 'Wire Mat#' '' '' ''.
*End vista "DEVK924667
ENDIF.
IF P_CH_P ='X'.
_APPEND_FIELDCAT 'ASSM_AM' '' '' '' '' 'Assm unit price' '' '' ''.
_APPEND_FIELDCAT 'TSTA_AM' '' '' '' '' 'Test unit price' '' '' ''.
_APPEND_FIELDCAT 'TOTAL_AM' '' '' '' '' 'Total Amount' '' '' ''.
ENDIF.
* end 001 "DEVK921032
*Start vista "DEVK925354 [DS080802]
_APPEND_FIELDCAT 'DIM_DEVICE' '' ''
'DIM_DEVICE' 'DIM_DEVICE' 'DIM_DEVICE'
'' '' ''.
_APPEND_FIELDCAT 'DIM_SO' '' '' 'DIM_SALES_ORDER' 'DIM_SALES_ORDER'
'DIM_SALES_ORDER' '' '' ''.
_APPEND_FIELDCAT 'DIM_PO' '' '' 'DIM_PRODUCTION_ORDER'
'DIM_PRODUCTION_ORDER' 'DIM_PRODUCTION_ORDER'
'' '' ''.
_APPEND_FIELDCAT 'DIM_SUBLOT' '' ''
'DIM_SUBLOT' 'DIM_SUBLOT' 'DIM_SUBLOT'
'' '' ''.
_APPEND_FIELDCAT 'DIM_CUST' '' ''
'DIM_CUSTOMER' 'DIM_CUSTOMER' 'DIM_CUSTOMER'
'' '' ''.
_APPEND_FIELDCAT 'DIM_BATCH' '' ''
'DIM_BATCH' 'DIM_BATCH' 'DIM_BATCH'
'' '' ''.
_APPEND_FIELDCAT 'DIM_DN' '' '' 'DIM_DELIVERY_NOTE'
'DIM_DELIVERY_NOTE' 'DIM_DELIVERY_NOTE'
'' '' ''.
_APPEND_FIELDCAT 'DIM_BILL' '' '' 'DIM_BILLING_INVOICE'
'DIM_BILLING_INVOICE' 'DIM_BILLING_INVOICE'
'' '' ''.
*End vista "DEVK925354 [DS080802]
ENDFORM. " BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form GENERATE_OUT_TABLE
*&---------------------------------------------------------------------*
* Generate ALV data table
*----------------------------------------------------------------------*
FORM GENERATE_OUT_TABLE.
DATA: LX_TABLE TYPE REF TO DATA.
* Generate ALV data table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = GT_FIELDCAT
IMPORTING
EP_TABLE = LX_TABLE.
ASSIGN LX_TABLE->* TO <GT_OUT>.
ENDFORM. " GENERATE_OUT_TABLE
*&---------------------------------------------------------------------*
*& Form ALV_OUTPUT
*&---------------------------------------------------------------------*
* Generate ALV report
*----------------------------------------------------------------------*
FORM ALV_OUTPUT.
DATA: LS_LAYOUT TYPE SLIS_LAYOUT_ALV,
LT_SORT TYPE SLIS_T_SORTINFO_ALV,
LS_SORT TYPE SLIS_SORTINFO_ALV.
LS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
G_VARIANT-REPORT = SY-REPID.
** Sorting Options
* LS_SORT-SPOS = 1.
* LS_SORT-FIELDNAME = 'MATNR'.
* LS_SORT-UP = 'X'. " Ascending
* LS_SORT-SUBTOT = 'X'. " Calc subtotals
* APPEND LS_SORT TO LT_SORT.
* Display ALV
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT = GT_FIELDCATA[] "Field Catalog
IS_LAYOUT = LS_LAYOUT "Layout
I_SAVE = G_SAVE "'A'
IS_VARIANT = G_VARIANT "Variant
IT_SORT = LT_SORT[] "Sorting
I_CALLBACK_PROGRAM = G_REPID "Callback this program
I_CALLBACK_USER_COMMAND = 'USER_COMMAND' "User-command handling
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE' "Top-of-page display
TABLES
T_OUTTAB = <GT_OUT>
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. " ALV_OUTPUT
*&---------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&---------------------------------------------------------------------*
* ALV Top-of-page Callback Subroutine
*----------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = GT_TOP_OF_PAGE.
ENDFORM. " TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form SET_TOP_OF_PAGE
*&---------------------------------------------------------------------*
* Set Top-of-page Content
*----------------------------------------------------------------------*
FORM SET_TOP_OF_PAGE.
DATA: LS_LINE TYPE SLIS_LISTHEADER,
L_LINES TYPE I,
L_TEXT1(30) TYPE C,
L_TEXT2(30) TYPE C.
* Macro: _APPEND_SELECT_OPTIONS
* &1 - Selection Criteria Text
* &2 - Select-Option Variable
DEFINE _APPEND_SELECT_OPTIONS.
LS_LINE-KEY = &1.
READ TABLE &2 INDEX 1.
IF &2-HIGH IS INITIAL.
WRITE &2-LOW TO L_TEXT1.
LS_LINE-INFO = L_TEXT1.
ELSE.
WRITE: &2-LOW TO L_TEXT1,
&2-HIGH TO L_TEXT2.
CONCATENATE L_TEXT1 '-' L_TEXT2 INTO LS_LINE-INFO
SEPARATED BY SPACE.
ENDIF.
DESCRIBE TABLE &2 LINES L_LINES.
IF L_LINES > 1.
CONCATENATE LS_LINE-INFO ', ...'
INTO LS_LINE-INFO.
ENDIF.
APPEND LS_LINE TO GT_TOP_OF_PAGE.
END-OF-DEFINITION.
* Header
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = SY-TITLE.
APPEND LS_LINE TO GT_TOP_OF_PAGE.
* Selection Criteria List
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
* Material Number
* IF NOT ( V_MATNR IS INITIAL ).
* _APPEND_SELECT_OPTIONS TEXT-101 V_MATNR.
* ENDIF.
ENDFORM. " SET_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* ALV User-command Callback Subroutine
*----------------------------------------------------------------------*
FORM USER_COMMAND USING P_UCOMM LIKE SY-UCOMM
PS_SELFIELD TYPE SLIS_SELFIELD.
DATA: L_AUFNR LIKE AFPO-AUFNR. "Material#
IF P_UCOMM = '&IC1' "SAP standard code for double-clicking
AND NOT ( PS_SELFIELD-VALUE IS INITIAL ).
CASE PS_SELFIELD-FIELDNAME.
* Material# is selected
WHEN 'AUFNR'.
WRITE PS_SELFIELD-VALUE TO L_AUFNR LEFT-JUSTIFIED.
* OVERLAY L_MATNR WITH '00000000000000000'.
SET PARAMETER ID 'ANR' FIELD L_AUFNR.
* SET PARAMETER ID 'MXX' FIELD 'K'. "Basic View
* SET PARAMETER ID 'KAR' FIELD C_MATCLTYPE. "Material Class
CALL TRANSACTION 'CO03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDIF.
ENDFORM. " USER_COMMAND
*&---------------------------------------------------------------------*
*& Form GET_CHECKBOX_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_CHECKBOX_DATA .
DATA: MATNR LIKE RESB-MATNR,
L_OBJEK LIKE AUSP-OBJEK,
LT_CLASS LIKE SCLASS OCCURS 0 WITH HEADER LINE,
LT_CLOBJDAT LIKE CLOBJDAT OCCURS 0 WITH HEADER LINE.
LOOP AT ITAB.
CLEAR: MATNR.
IF ITAB-RSNUM <>''.
SELECT SINGLE RESB~MATNR INTO (MATNR)
FROM RESB INNER JOIN MARA
ON RESB~MATNR = MARA~MATNR
WHERE RESB~RSNUM = ITAB-RSNUM
AND MARA~MTART IN
('SUBS','LDFR').
L_OBJEK = MATNR.
* Get the features of characteristics of the material
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
* CLASSTEXT = '' "No class text
CLASSTYPE = '001' "Material classification
OBJECT = L_OBJEK "Material#
* INITIAL_CHARACT = '' "No initial characteristic
TABLES
T_CLASS = LT_CLASS
T_OBJECTDATA = LT_CLOBJDAT
EXCEPTIONS
OTHERS = 4.
IF SY-SUBRC = 0.
READ TABLE LT_CLOBJDAT WITH KEY ATNAM = 'RM_SECTION-STRIP'.
IF SY-SUBRC = 0 AND LT_CLOBJDAT-AUSP1 <> '?'.
MOVE LT_CLOBJDAT-AUSP1 TO ITAB-RM_SECT_ST.
ENDIF.
READ TABLE LT_CLOBJDAT WITH KEY ATNAM = 'RM_UNIT-SECTION'.
IF SY-SUBRC = 0 AND LT_CLOBJDAT-AUSP1 <> '?'.
MOVE LT_CLOBJDAT-AUSP1 TO ITAB-RM_UNIT_SE.
ENDIF.
READ TABLE LT_CLOBJDAT WITH KEY ATNAM = 'RM_UNIT-STRIP'.
IF SY-SUBRC = 0 AND LT_CLOBJDAT-AUSP1 <> '?'.
MOVE LT_CLOBJDAT-AUSP1 TO ITAB-RM_UNIT_ST.
ENDIF.
MODIFY ITAB.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " GET_CHECKBOX_DATA
*Start vista "DEVK924607 [DS080521]
*&---------------------------------------------------------------------*
*& FORM CAL_WIRES.
*&---------------------------------------------------------------------*
* Calculate total wires qty
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CAL_WIRES.
DATA: L_INT TYPE I,
L_STRIPS(4) TYPE C,
L_UNIT(2) TYPE C.
*Delete SAP order number is blank
DELETE V_ITAB WHERE AUFNR IS INITIAL.
*Delete those items not A(material type FER1) or A+T(material type FER2)
LOOP AT V_ITAB.
SELECT SINGLE * FROM MARA
WHERE MATNR = V_ITAB-MATNR
AND ( MTART = 'FER1' OR MTART = 'FER2' ).
IF SY-SUBRC <> 0.
DELETE V_ITAB INDEX SY-TABIX.
ENDIF.
ENDLOOP.
*Delete rework items(sales order type is 'RWRK').
DELETE V_ITAB WHERE AUART = 'RWRK'.
*Calculate total wires
LOOP AT V_ITAB.
V_ITAB-TOTAL_WIRES = V_ITAB-KWMENG * V_ITAB-NUM_WIRES.
CLEAR:L_STRIPS, L_UNIT.
SPLIT V_ITAB-RM_UNIT_ST AT SPACE INTO L_STRIPS L_UNIT.
IF L_STRIPS IS NOT INITIAL AND L_STRIPS > 0.
V_ITAB-TOTAL_STRIPS = V_ITAB-KWMENG DIV L_STRIPS.
L_INT = V_ITAB-KWMENG MOD L_STRIPS.
IF L_INT > 0. "
V_ITAB-TOTAL_STRIPS = V_ITAB-TOTAL_STRIPS + 1.
ENDIF.
ENDIF.
MODIFY V_ITAB TRANSPORTING TOTAL_WIRES TOTAL_STRIPS.
ENDLOOP.
ENDFORM. "CAL_WIRES
*&--------------------------------------------------------------------*
*& Form DOWNLOAD_FILE_TO_SERVER
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DOWNLOAD_FILE_TO_SERVER.
FIELD-SYMBOLS: <LS_OUT>.
DATA:LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:LS_FCAT LIKE LINE OF GT_FIELDCATA.
DATA:L_FIELD(400) TYPE C.
DATA:L_STRING(4000) TYPE C,
L_INDEX TYPE I.
FIELD-SYMBOLS:<L_LINE> TYPE ANY,
<L_FIELD> TYPE ANY.
DATA:WA_LINE TYPE REF TO DATA.
FIELD-SYMBOLS: <FS> TYPE ANY,
<FS2> TYPE ANY,
<FS1> TYPE ANY.
DATA:BEGIN OF LT_OUT OCCURS 0,
TEXT(60),
QTY(20),
AMT(20),
END OF LT_OUT.
IF P_VARI IS INITIAL. "No Variant is selected
LT_FIELDCAT[] = GT_FIELDCATA[].
ELSE.
PERFORM GET_ALV_VARIANT_DETAIL USING G_VARIANT
GT_FIELDCATA[]
GS_LAYOUT
CHANGING LT_FIELDCAT.
ENDIF.
TRY.
CONCATENATE 'asatSale_POREL_'
SY-DATUM SY-UZEIT '.csv' INTO P_SVFILE.
CONCATENATE P_SVPATH P_SVFILE INTO G_SVFILE.
OPEN DATASET G_SVFILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
LOOP AT LT_FIELDCAT INTO LS_FCAT WHERE NO_OUT = ''.
L_INDEX = L_INDEX + 1.
CONDENSE L_FIELD.
IF L_INDEX = 1.
L_STRING = LS_FCAT-SELTEXT_L.
ELSE.
CONCATENATE L_STRING LS_FCAT-SELTEXT_L
INTO L_STRING SEPARATED BY '|'.
ENDIF.
ENDLOOP.
TRANSFER L_STRING TO G_SVFILE.
CLEAR L_STRING.
LOOP AT <GT_OUT> ASSIGNING <LS_OUT>.
CLEAR L_INDEX.
LOOP AT LT_FIELDCAT INTO LS_FCAT WHERE NO_OUT = ''.
L_INDEX = L_INDEX + 1.
ASSIGN COMPONENT LS_FCAT-FIELDNAME OF
STRUCTURE <LS_OUT> TO <FS1>.
L_FIELD = <FS1>.
CONDENSE L_FIELD.
PERFORM PUT_SIGN_IN_FRONT CHANGING L_FIELD.
IF L_INDEX = 1.
L_STRING = L_FIELD.
ELSE.
CONCATENATE L_STRING L_FIELD INTO L_STRING
SEPARATED BY '|'.
ENDIF.
ENDLOOP.
TRANSFER L_STRING TO G_SVFILE.
CLEAR L_STRING.
ENDLOOP.
CLOSE DATASET G_SVFILE.
WRITE:/ 'Export is successful.'.
WRITE:/ 'Temporary file created on server:', G_SVFILE.
ELSE.
WRITE:/ 'Export is failed.'.
ENDIF.
CATCH CX_ROOT.
WRITE:/ 'Temporary file writing error on server.'.
ENDTRY.
ENDFORM. "DOWNLOAD_FILE_TO_SERVER
*End vista "DEVK924607 [DS080521]
*&--------------------------------------------------------------------*
*& Form DOWNLOAD_FILE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DOWNLOAD_FILE USING P_SVPATH TYPE C.
DATA: WA LIKE V_ITAB,
LEN TYPE I,
L_LINE(1500) TYPE C,
FLD(60) TYPE C,
L_DATE(14) TYPE C.
DATA: TMP_FC TYPE SLIS_FIELDCAT_ALV.
FIELD-SYMBOLS: <FS> TYPE ANY.
**replace the token <DATE> with system date &time of running
CONCATENATE SY-DATUM SY-UZEIT INTO L_DATE.
REPLACE '<DATE>' IN P_SVPATH WITH L_DATE.
OPEN DATASET P_SVPATH FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC <> 0.
MESSAGE E001(00) WITH 'Fail to open file on server' SPACE P_SVPATH.
ENDIF.
**build header line
CLEAR L_LINE.
LOOP AT GT_FIELDCATA INTO TMP_FC.
LEN = STRLEN( L_LINE ).
CONCATENATE '"' TMP_FC-REPTEXT_DDIC '"' ',' INTO L_LINE+LEN.
ENDLOOP.
TRANSFER L_LINE TO P_SVPATH.
**build csv content line
LOOP AT V_ITAB INTO WA.
CLEAR L_LINE.
LOOP AT GT_FIELDCATA INTO TMP_FC.
* writing out each field sequentially into a 'line'
ASSIGN COMPONENT TMP_FC-FIELDNAME OF STRUCTURE WA TO <FS>.
IF SY-SUBRC <> 0.
* remove extra comma at the end of line
LEN = STRLEN( L_LINE ) - 1.
WRITE '' TO L_LINE+LEN.
EXIT.
ENDIF.
LEN = STRLEN( L_LINE ).
WRITE <FS> TO FLD. CONDENSE FLD.
CONCATENATE '"' FLD '"' ',' INTO L_LINE+LEN.
ENDLOOP.
TRANSFER L_LINE TO P_SVPATH.
ENDLOOP.
CLOSE DATASET P_SVPATH.
ENDFORM. "DOWNLOAD_FILE
*&--------------------------------------------------------------------*
*& Form GET_WIRE_INFOMATION.
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
*Start vista "DEVK924705 [DS080605]
FORM GET_WIRE_INFOMATION.
*Start vista "DEVK924986 [BS080703]
DATA: TIME1 TYPE T VALUE '070000',
TIME2 TYPE T VALUE '110000',
TIME3 TYPE T VALUE '150000',
TIME4 TYPE T VALUE '190000',
TIME5 TYPE T VALUE '230000',
TIME6 TYPE T VALUE '030000'.
*End vista "DEVK924986 [BS080703]
DATA:L_TABIX LIKE SY-TABIX.
DATA : T_LINE TYPE I.
DATA : L_LINE TYPE I.
DATA : LT_CLASS LIKE SCLASS OCCURS 0 WITH HEADER LINE,
LT_CLOBJDAT LIKE CLOBJDAT OCCURS 0 WITH HEADER LINE,
L_OBJEK LIKE AUSP-OBJEK,
LT_CSTMAT LIKE CSTMAT OCCURS 0 WITH HEADER LINE,
LT_STB LIKE STPOX OCCURS 0 WITH HEADER LINE.
LOOP AT V_ITAB.
SELECT SINGLE AUFLD INTO V_ITAB-AUFLD FROM AFKO
WHERE AUFNR = V_ITAB-AUFNR.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
CAPID = SPACE
DATUV = V_ITAB-AUFLD
MKTLS = 'X'
MTNRV = V_ITAB-MATNR
STLAL = '01'
STLAN = '1'
WERKS = V_ITAB-WERKS
IMPORTING
TOPMAT = LT_CSTMAT
TABLES
STB = LT_STB
EXCEPTIONS
OTHERS = 9.
IF SY-SUBRC = 0.
READ TABLE LT_STB WITH KEY MTART = 'WIRE'.
IF SY-SUBRC = 0.
MOVE LT_STB-IDNRK TO V_ITAB-WIRE_MAT.
CLEAR: LT_CLASS,LT_CLOBJDAT.
L_OBJEK = LT_STB-IDNRK.
SELECT SINGLE KAUSF INTO V_ITAB-KAUSF FROM MARC
WHERE WERKS = V_ITAB-WERKS AND MATNR = LT_STB-IDNRK.
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
CLASSTYPE = '001'
OBJECT = L_OBJEK
TABLES
T_CLASS = LT_CLASS
T_OBJECTDATA = LT_CLOBJDAT
EXCEPTIONS
NO_CLASSIFICATION = 1
NO_CLASSTYPES = 2
INVALID_CLASS_TYPE = 3
OTHERS = 4.
IF SY-SUBRC = 0.
READ TABLE LT_CLOBJDAT WITH KEY ATNAM = 'RM_WDIAMETER'.
IF SY-SUBRC = 0 AND LT_CLOBJDAT-AUSP1 <> '?'.
V_ITAB-WIRE_SIZE = LT_CLOBJDAT-AUSP1.
ENDIF.
ENDIF.
IF LT_CSTMAT-BMENG IS NOT INITIAL.
V_ITAB-WIRE_LENGTH =
LT_STB-MENGE * V_ITAB-KWMENG / LT_CSTMAT-BMENG *
( 1 + V_ITAB-KAUSF / 100 ).
ENDIF.
SELECT SINGLE * FROM MARM
WHERE MATNR = LT_STB-IDNRK
AND MEINH = 'ROL'.
IF SY-SUBRC = 0.
V_ITAB-WIRE_ROLL =
V_ITAB-WIRE_LENGTH * MARM-UMREN / MARM-UMREZ.
ENDIF.
ENDIF.
ENDIF.
IF TIME1 <= V_ITAB-UTIME AND V_ITAB-UTIME < TIME2.
V_ITAB-PERIOD_INDICATOR = '07:00-11:00'.
ELSEIF TIME2 <= V_ITAB-UTIME AND V_ITAB-UTIME < TIME3.
V_ITAB-PERIOD_INDICATOR = '11:00-15:00'.
ELSEIF TIME3 <= V_ITAB-UTIME AND V_ITAB-UTIME < TIME4.
V_ITAB-PERIOD_INDICATOR = '15:00-19:00'.
ELSEIF TIME4 <= V_ITAB-UTIME AND V_ITAB-UTIME < TIME5.
V_ITAB-PERIOD_INDICATOR = '19:00-23:00'.
ELSEIF TIME5 <= V_ITAB-UTIME OR V_ITAB-UTIME < TIME6.
V_ITAB-PERIOD_INDICATOR = '23:00-03:00'.
ELSEIF TIME6 <= V_ITAB-UTIME AND V_ITAB-UTIME < TIME1.
V_ITAB-PERIOD_INDICATOR = '03:00-07:00'.
ENDIF.
MODIFY V_ITAB TRANSPORTING WIRE_SIZE
WIRE_LENGTH WIRE_ROLL WIRE_MAT PERIOD_INDICATOR KAUSF.
ENDLOOP.
ENDFORM. "get_wire_infomation
*End vista "DEVK924705 [DS080605]
*&---------------------------------------------------------------------*
*& Form FILL_UNIT_PRICE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FILL_UNIT_PRICE_DATA .
DATA L_KNUMV LIKE VBAK-KNUMV.
DATA: BEGIN OF LTAB_PRUT OCCURS 0,
UNIT_PRICE TYPE P DECIMALS 5,
KPEIN LIKE KONV-KPEIN, "PER
KSCHL LIKE KONV-KSCHL, "TYPE 'ASSM' OR 'TSTA'
END OF LTAB_PRUT.
LOOP AT V_ITAB.
CLEAR L_KNUMV.
SELECT SINGLE VBAK~KNUMV INTO L_KNUMV
FROM VBAK
WHERE VBAK~VBELN = V_ITAB-KDAUF.
IF SY-SUBRC = 0.
CLEAR: LTAB_PRUT,LTAB_PRUT[].
SELECT KBETR KPEIN KSCHL INTO (LTAB_PRUT-UNIT_PRICE,
LTAB_PRUT-KPEIN,LTAB_PRUT-KSCHL)
FROM KONV
WHERE KONV~KNUMV = L_KNUMV
AND KONV~KPOSN = V_ITAB-KDPOS
AND KONV~KSCHL IN ('ASSM','TSTA').
APPEND LTAB_PRUT.
ENDSELECT.
IF SY-SUBRC = 0.
LOOP AT LTAB_PRUT.
CASE LTAB_PRUT-KSCHL.
WHEN 'ASSM'.
V_ITAB-ASSM_AM = LTAB_PRUT-UNIT_PRICE / LTAB_PRUT-KPEIN.
WHEN 'TSTA'.
V_ITAB-TSTA_AM = LTAB_PRUT-UNIT_PRICE / LTAB_PRUT-KPEIN.
ENDCASE.
MODIFY V_ITAB.
ENDLOOP.
ENDIF.
ENDIF.
V_ITAB-TOTAL_AM = V_ITAB-KWMENG * ( V_ITAB-TSTA_AM +
V_ITAB-ASSM_AM ).
MODIFY V_ITAB.
ENDLOOP.
ENDFORM. " FILL_UNIT_PRICE_DATA
*Start vista "DEVK925354 [DS080802]
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PROCESS_DATA .
SELECT MCHB~CHARG MCHB~LGORT MCHB~WERKS MCHB~MATNR
INTO CORRESPONDING FIELDS OF TABLE V_MCHB
FROM MCHB
FOR ALL ENTRIES IN V_ITAB
WHERE MCHB~WERKS = V_ITAB-WERKS
AND MCHB~MATNR = V_ITAB-MATNR.
LOOP AT V_ITAB.
PERFORM GET_BSHEET_FROM_PO USING V_ITAB-AUFNR
CHANGING V_ITAB-DOCU_NO.
LOOP AT V_MCHB WHERE MATNR = V_ITAB-MATNR AND WERKS = V_ITAB-WERKS.
V_ITAB-CHARG = V_MCHB-CHARG.
V_ITAB-LGORT = V_MCHB-LGORT.
MODIFY V_ITAB.
ENDLOOP.
PERFORM CONVERSION_OUTPUT CHANGING V_ITAB-MATNR.
PERFORM CONVERSION_OUTPUT CHANGING V_ITAB-KDAUF.
PERFORM CONVERSION_OUTPUT CHANGING V_ITAB-KDPOS.
PERFORM CONVERSION_OUTPUT CHANGING V_ITAB-AUFNR.
PERFORM CONVERSION_OUTPUT CHANGING V_ITAB-KUNNR.
******DIM_DEVICE
IF V_ITAB-DOCU_NO IS NOT INITIAL.
IF V_ITAB-MATNR(1) = '1'.
CONCATENATE '[' V_ITAB-MATNR '].[' V_ITAB-DOCU_NO ']'
INTO V_ITAB-DIM_DEVICE.
ELSEIF V_ITAB-MATNR(1) = '2'.
CONCATENATE '[' V_ITAB-MATNR '].[' V_ITAB-DOCU_NO '_AT]'
INTO V_ITAB-DIM_DEVICE.
ELSE.
CONCATENATE '[' V_ITAB-MATNR '].[' V_ITAB-MATNR '_NBS]'
INTO V_ITAB-DIM_DEVICE.
ENDIF.
ELSEIF V_ITAB-MATNR IS NOT INITIAL AND V_ITAB-DOCU_NO IS INITIAL.
CONCATENATE '[' V_ITAB-MATNR '].[' V_ITAB-MATNR '_NBS]'
INTO V_ITAB-DIM_DEVICE.
ENDIF.
IF V_ITAB-DOCU_NO = '' AND V_ITAB-MATNR = ''.
CONCATENATE '[DEVICE_TOTAL]' '.' '[DEVICE_NA]'
INTO V_ITAB-DIM_DEVICE.
ENDIF.
IF V_ITAB-MATNR = ''.
CONCATENATE '[DEVICE_TOTAL]' '.' '[DEVICE_NA]'
INTO V_ITAB-DIM_DEVICE.
ENDIF.
******DIM_SALES_ORDER
IF V_ITAB-KDAUF IS NOT INITIAL.
CONCATENATE '[' V_ITAB-KDAUF '].[' V_ITAB-KDAUF '_' V_ITAB-KDPOS
']'
INTO V_ITAB-DIM_SO.
ELSE.
CONCATENATE '[SALES_ORDER_TOTAL]' '.' '[SALES_ORDER_NA]'
INTO V_ITAB-DIM_SO.
ENDIF.
******DIM_PRODUCTION_ORDER
IF V_ITAB-AUFNR IS NOT INITIAL.
CONCATENATE '[PRODUCTION_ORDER_TOTAL].[' V_ITAB-AUFNR ']'
INTO V_ITAB-DIM_PO.
ELSE.
CONCATENATE '[PRODUCTION_ORDER_TOTAL]' '.[PRODUCTION_ORDER_NA]'
INTO V_ITAB-DIM_PO.
ENDIF.
******DIM_SUBLOT
IF V_ITAB-AUFNR IS NOT INITIAL AND V_ITAB-LOT IS NOT INITIAL.
CONCATENATE '[' V_ITAB-AUFNR '].[' V_ITAB-LOT ']'
INTO V_ITAB-DIM_SUBLOT.
ELSE.
CONCATENATE '[SUBLOT_TOTAL]' '.' '[SUBLOT_NA]'
INTO V_ITAB-DIM_SUBLOT.
ENDIF.
******DIM_CUSTOMER
IF V_ITAB-KUNNR IS NOT INITIAL.
CONCATENATE '[CUSTOMER_TOTAL].[' V_ITAB-KUNNR ']'
INTO V_ITAB-DIM_CUST.
ELSE.
CONCATENATE '[CUSTOMER_TOTAL]' '.' '[CUSTOMER_NA]'
INTO V_ITAB-DIM_CUST.
ENDIF.
******DIM_BATCH
* IF V_ITAB-CHARG IS NOT INITIAL.
* CONCATENATE '[' V_ITAB-CHARG '].[' V_ITAB-MATNR '_'
* V_ITAB-CHARG '_' V_ITAB-WERKS '_' V_ITAB-LGORT ']'
* INTO V_ITAB-DIM_BATCH.
* ELSE.
CONCATENATE '[BATCH_TOTAL]' '.' '[BATCH_NA]'
INTO V_ITAB-DIM_BATCH.
* ENDIF.
******DIM_DELIVERY_NOTE
CONCATENATE '[DELIVERY_NOTE_TOTAL]' '.' '[DELIVERY_NOTE_NA]'
INTO V_ITAB-DIM_DN.
******DIM_BILLING_INVOICE
CONCATENATE '[BILLING_INVOICE_TOTAL]' '.' '[BILLING_INVOICE_NA]'
INTO V_ITAB-DIM_BILL.
MODIFY V_ITAB.
ENDLOOP.
ENDFORM. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form GET_BSHEET_FROM_PO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_V_ITAB_AUFNR text
* <--P_V_ITAB_DOCU_NO text
*----------------------------------------------------------------------*
FORM GET_BSHEET_FROM_PO USING T_AUFNR LIKE AFKO-AUFNR
CHANGING P_DOCU_NO.
DATA: LS_DOC_KEY LIKE DMS_DOC_KEY,
L_OBJEK LIKE AUSP-OBJEK,
L_MATNR LIKE MARA-MATNR,
TEMP(11) TYPE C,
P_OBJKY LIKE DRAD_PORDER-OBJKY.
DATA: LT_CLASS LIKE SCLASS OCCURS 0 WITH HEADER LINE,
LT_CLOBJDAT LIKE CLOBJDAT OCCURS 0 WITH HEADER LINE.
CONCATENATE T_AUFNR 'H0001%'
INTO P_OBJKY.
SELECT SINGLE * FROM DRAD_PORDER WHERE OBJKY LIKE P_OBJKY.
IF SY-SUBRC = 0.
SELECT SINGLE * FROM DRAW
WHERE DOKAR = DRAD_PORDER-DOKAR AND DOKNR = DRAD_PORDER-DOKNR
AND DOKVR = DRAD_PORDER-DOKVR AND DOKTL = DRAD_PORDER-DOKTL.
IF SY-SUBRC = 0.
MOVE-CORRESPONDING DRAW TO LS_DOC_KEY.
PERFORM CONVERSION_OUTPUT CHANGING LS_DOC_KEY-DOKNR.
CONCATENATE LS_DOC_KEY-DOKNR LS_DOC_KEY-DOKVR INTO P_DOCU_NO.
ENDIF.
ENDIF.
ENDFORM. " GET_BSHEET_FROM_PO
*&---------------------------------------------------------------------*
*& Form CONVERSION_OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LS_DOC_KEY_DOKNR text
*----------------------------------------------------------------------*
FORM CONVERSION_OUTPUT CHANGING P_VALUE.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = P_VALUE
IMPORTING
OUTPUT = P_VALUE.
ENDFORM. " CONVERSION_OUTPUT
*&---------------------------------------------------------------------*
*& Form F4_FOR_VARIANT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM F4_FOR_VARIANT .
DATA: L_EXIT(1) TYPE C. "Exit Code
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = G_VARIANT
I_SAVE = G_SAVE
IMPORTING
E_EXIT = L_EXIT
ES_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 2.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF L_EXIT = SPACE.
P_VARI = GX_VARIANT-VARIANT.
ENDIF.
ENDIF.
ENDFORM. " F4_FOR_VARIANT
*&---------------------------------------------------------------------*
*& Form VALIDATE_VARIANT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM VALIDATE_VARIANT .
IF NOT P_VARI IS INITIAL.
MOVE G_VARIANT TO GX_VARIANT.
MOVE P_VARI TO GX_VARIANT-VARIANT.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
I_SAVE = G_SAVE
CHANGING
CS_VARIANT = GX_VARIANT.
G_VARIANT = GX_VARIANT.
ELSE.
PERFORM VARIANT_INIT.
ENDIF.
ENDFORM. " VALIDATE_VARIANT
*&---------------------------------------------------------------------*
*& Form VARIANT_INIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM VARIANT_INIT .
CLEAR G_VARIANT.
G_VARIANT-REPORT = G_REPID.
ENDFORM. " VARIANT_INIT
*&---------------------------------------------------------------------*
*& Form GET_DEFAULT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DEFAULT .
* Get default variant
GX_VARIANT = G_VARIANT.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
I_SAVE = G_SAVE
CHANGING
CS_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 0.
P_VARI = GX_VARIANT-VARIANT.
ENDIF.
ENDFORM. " GET_DEFAULT
*&--------------------------------------------------------------------*
*& Form GET_ALV_VARIANT_DETAIL
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->P_VARIANT text
* -->P_FIELDCAT text
* -->PS_LAYOUT text
* -->PT_FIELDCATtext
*---------------------------------------------------------------------*
FORM GET_ALV_VARIANT_DETAIL
USING P_VARIANT
P_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV
PS_LAYOUT
CHANGING PT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: LT_FCAT_DEF TYPE KKBLO_FIELDCAT OCCURS 0 WITH HEADER LINE.
DATA: LT_FCAT_SAV TYPE KKBLO_FIELDCAT OCCURS 0 WITH HEADER LINE.
DATA: LT_SORT TYPE KKBLO_SORTINFO OCCURS 0 WITH HEADER LINE.
DATA: LT_FILTER TYPE KKBLO_FILTER OCCURS 0 WITH HEADER LINE.
DATA: LT_LAYOUT TYPE KKBLO_LAYOUT.
DATA: LT_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: WA_SAV LIKE GT_FCAT_SAV.
DATA: FIELDCAT_LN TYPE SLIS_FIELDCAT_ALV.
LOOP AT P_FIELDCAT INTO LT_FIELDCAT.
MOVE-CORRESPONDING LT_FIELDCAT TO LT_FCAT_DEF.
APPEND LT_FCAT_DEF.
ENDLOOP.
MOVE-CORRESPONDING PS_LAYOUT TO LT_LAYOUT.
CALL FUNCTION 'LT_FC_LOAD'
EXPORTING
* I_TOOL = 'LT'
IS_VARIANT = P_VARIANT
I_TABNAME = 'MASTER'
* I_TABNAME_SLAVE =
IMPORTING
ET_FIELDCAT = LT_FCAT_SAV[]
* ET_SORT = LT_SORT[]
* ET_FILTER = LT_FILTER[]
CHANGING
CS_LAYOUT = LT_LAYOUT
CT_DEFAULT_FIELDCAT = LT_FCAT_DEF[]
EXCEPTIONS
FC_NOT_COMPLETE = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
ELSE.
* PT_FCAT_SAV[] = LT_FCAT_SAV[].
* PT_SORT_SAV[] = LT_SORT[].
* PT_FILTER_SAV[] = LT_FILTER[].
* MOVE-CORRESPONDING LT_LAYOUT TO PS_LAYOUT_SAV.
ENDIF.
SORT LT_FCAT_SAV BY COL_POS.
LOOP AT LT_FCAT_SAV INTO WA_SAV WHERE NO_OUT <> 'X'.
MOVE-CORRESPONDING WA_SAV TO FIELDCAT_LN.
APPEND FIELDCAT_LN TO PT_FIELDCAT.
CLEAR FIELDCAT_LN.
ENDLOOP.
ENDFORM. " GET_ALV_VARIANT_DETAIL
*End vista "DEVK925354 [DS080802]
*&---------------------------------------------------------------------*
*& Form PUT_SIGN_IN_FRONT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_L_FIELD text
*----------------------------------------------------------------------*
FORM PUT_SIGN_IN_FRONT CHANGING P_VALUE.
DATA:L_LEN TYPE I,
L_STR1(40),
L_STR2(40).
L_LEN = STRLEN( P_VALUE ).
CHECK L_LEN > 0.
L_LEN = L_LEN - 1.
L_STR1 = P_VALUE+L_LEN(1).
IF L_STR1 = '-'.
CONCATENATE '-' P_VALUE(L_LEN) INTO L_STR2.
P_VALUE = L_STR2.
ENDIF.
ENDFORM. " PUT_SIGN_IN_FRONT
*&---------------------------------------------------------------------*
*& Form get_urgent_status
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_URGENT_STATUS .
* Get urgent status
SELECT ESTAT TXT04
INTO CORRESPONDING FIELDS OF TABLE GT_URGENT
FROM TJ49 AS A
INNER JOIN TJ30T AS B ON B~ESTAT = A~STATS
WHERE A~SELID = 'ZURGENT'
AND A~INCEX = 'I'
AND A~ACTIV = 'X'
AND B~STSMA = 'Z0000001'
AND B~SPRAS = 'E'.
ENDFORM. " get_urgent_status