Builds Details by Device for Engineering (DownLoad to PC,Field Type=CSV)
REPORT ZRPP0054 NO STANDARD PAGE HEADING
LINE-SIZE 255
MESSAGE-ID 00.
*-----------------------------------------------------------------------
* Company ASAT Company Limited
*
* Author: Wei_Zhu
*
* Date: 21/03/2007
*
* Description: The build details per device.
*
*-----------------------------------------------------------------------
* Last Modified Data: 2007-03-21
*
* Description:
* Task#1131 Request#DEVK922381
*-----------------------------------------------------------------------
TYPE-POOLS: SLIS. "ALV Type Pool
TABLES: MARA, A904, MAKT, MARC.
*----------------------------------------------------------------------*
* Global Data Declaration *
*----------------------------------------------------------------------*
DATA: BEGIN OF ITAB OCCURS 0,
*Basic data
MATNR LIKE A904-MATNR, "Material
MAKTX LIKE MAKT-MAKTX, "Material Name
WERKS LIKE T001W-WERKS, "Plant
*BOM Material and Classification and Routing infor
RIONO LIKE AUSP-ATWRT, "I/O Number -RM_I-O_NUM
BAPTH LIKE AUSP-ATWRT, "Ball/Pin Pitch -BALL_PIN_PITCH
BOPPH LIKE AUSP-ATWRT, "Bond Pad Pitch -DOC_BDS_DIE_BPP
DIAME LIKE AUSP-ATWRT, "Wire Diameter -RM_DIAMETER
NOWIR LIKE AUSP-ATWRT, "Wire Count -NUMBER_OF_WIRES
END OF ITAB.
*Download Path and file name
DATA:PF_NAME LIKE RLGRAP-FILENAME.
* Global variables for ALV use
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: I_FCOL TYPE SY-TITLE OCCURS 0 WITH HEADER LINE. "field name
data : begin of xtab1 occurs 0,
line(1000).
data : end of xtab1.
*----------------------------------------------------------------------*
* Selection Screen *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-T10.
PARAMETERS:P_WERKS LIKE T001W-WERKS OBLIGATORY.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
SELECTION-SCREEN END OF BLOCK A.
SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-T20.
PARAMETERS: P_DL AS CHECKBOX.
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B.
*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
INITIALIZATION.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
*Get device by selection criteria
PERFORM GET_DEVICE.
*Get Material information
PERFORM GET_MATERIAL_CHAR.
*Get BOM information
PERFORM GET_BOM_CHAR.
END-OF-SELECTION.
*----------------------------------------------------------------------*
* END-OF-SELECTION *
*----------------------------------------------------------------------*
* Build field category
PERFORM BUILD_FIELDCAT.
*Download to PC
IF P_DL EQ 'X'.
perform format_file.
perform download_pc.
ENDIF.
* Display report
PERFORM ALV_OUTPUT.
*&---------------------------------------------------------------------*
*& Form GET_DEVICE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DEVICE.
SELECT MARC~WERKS MAKT~MATNR MAKT~MAKTX
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM MARC INNER JOIN MAKT
ON MARC~MATNR = MAKT~MATNR
WHERE MARC~WERKS = P_WERKS
AND MARC~MATNR IN S_MATNR.
ENDFORM. "GET_DEVICE
*&---------------------------------------------------------------------*
*& FORM GET_Material_CHAR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_MATERIAL_CHAR.
DATA:LT_STB LIKE STPOX OCCURS 0 WITH HEADER LINE.
CONSTANTS: C_STLAN LIKE MAST-STLAN VALUE '1', "BOM Usage
C_STLAL LIKE MAST-STLAL VALUE '01'. "Alternative BOM
DATA:L_MATNR LIKE MARC-MATNR.
DATA: LS_DOC_KEY LIKE DMS_DOC_KEY,
LT_CLASS LIKE SCLASS OCCURS 0 WITH HEADER LINE,
LT_CLOBJDAT LIKE CLOBJDAT OCCURS 0 WITH HEADER LINE.
DATA: L_OBJEK LIKE AUSP-OBJEK.
LOOP AT ITAB.
L_OBJEK = ITAB-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 = 'NUMBER_OF_WIRES'.
IF SY-SUBRC = 0.
MOVE LT_CLOBJDAT-AUSP1 TO ITAB-NOWIR.
MODIFY ITAB.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. "GET_MATERIAL_CHAR
*&---------------------------------------------------------------------*
*& FORM GET_BOM_CHAR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_BOM_CHAR.
DATA:LT_STB LIKE STPOX OCCURS 0 WITH HEADER LINE.
CONSTANTS: C_STLAN LIKE MAST-STLAN VALUE '1', "BOM Usage
C_STLAL LIKE MAST-STLAL VALUE '01'. "Alternative BOM
DATA:L_MATNR LIKE MARC-MATNR.
DATA: LS_DOC_KEY LIKE DMS_DOC_KEY,
LT_CLASS LIKE SCLASS OCCURS 0 WITH HEADER LINE,
LT_CLOBJDAT LIKE CLOBJDAT OCCURS 0 WITH HEADER LINE.
DATA: L_OBJEK LIKE AUSP-OBJEK.
LOOP AT ITAB.
* Get BOM information
CLEAR LT_STB. REFRESH LT_STB.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
CAPID = SPACE
DATUV = SY-DATUM
MTNRV = ITAB-MATNR
STLAL = C_STLAL
STLAN = C_STLAN
WERKS = P_WERKS
TABLES
STB = LT_STB
EXCEPTIONS
OTHERS = 9.
IF SY-SUBRC = 0.
*Get substrate
CLEAR L_MATNR.
LOOP AT LT_STB WHERE MTART = 'SUBS'.
L_MATNR = LT_STB-IDNRK.
ENDLOOP.
** Get substrate classficatin
REFRESH LT_CLASS.
REFRESH LT_CLOBJDAT.
CLEAR L_OBJEK.
L_OBJEK = L_MATNR.
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_CLASS INDEX 1.
LOOP AT LT_CLOBJDAT.
CHECK LT_CLOBJDAT-AUSP1 NE '?'.
CASE LT_CLOBJDAT-ATNAM.
WHEN 'RM_I-O_NUM'.
ITAB-RIONO = LT_CLOBJDAT-AUSP1.
WHEN 'BALL_PIN_PITCH'.
ITAB-BAPTH = LT_CLOBJDAT-AUSP1.
ENDCASE.
ENDLOOP.
ENDIF.
*Get wire
CLEAR L_MATNR.
LOOP AT LT_STB WHERE MTART = 'WIRE'.
L_MATNR = LT_STB-IDNRK.
ENDLOOP.
* Get wire classficatin
REFRESH LT_CLASS.
REFRESH LT_CLOBJDAT.
CLEAR L_OBJEK.
L_OBJEK = L_MATNR.
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_CLASS INDEX 1.
LOOP AT LT_CLOBJDAT WHERE ATNAM = 'RM_DIAMETER'
AND AUSP1 NE '?'.
ITAB-DIAME = LT_CLOBJDAT-AUSP1.
ENDLOOP.
ENDIF.
* Get Bond Pad Pitch from DMS characteristics
READ TABLE LT_STB WITH KEY POSTP = 'D'
DOKAR = 'BDS'.
IF SY-SUBRC = 0.
MOVE-CORRESPONDING LT_STB TO LS_DOC_KEY.
L_OBJEK = LS_DOC_KEY.
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
CLASSTEXT = '' "No class text
CLASSTYPE = '017' "Document Classification
OBJECT = L_OBJEK "Document key
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 = 'DOC_BDS_DIE_BPP'.
IF SY-SUBRC = 0.
ITAB-BOPPH = LT_CLOBJDAT-AUSP1.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
MODIFY ITAB.
L_OBJEK = ITAB-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 = 'NUMBER_OF_WIRES'.
IF SY-SUBRC = 0.
MOVE LT_CLOBJDAT-AUSP1 TO ITAB-NOWIR.
MODIFY ITAB.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. "GET_BOM_CHAR
*&---------------------------------------------------------------------*
*& 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
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_l = &5.
ls_fieldcat-datatype = &6.
ls_fieldcat-inttype = &7.
ls_fieldcat-decimals = &8.
ls_fieldcata-hotspot = &9.
append ls_fieldcat to gt_fieldcat.
append ls_fieldcata to gt_fieldcata.
end-of-definition.
_append_fieldcat 'MATNR' 'MARA' 'MATNR' '' 'Material' '' '' '' ''.
_append_fieldcat 'MAKTX' 'MAKT' 'MAKTX' '' 'Description' '' '' '' ''.
_append_fieldcat 'WERKS' 'MARC' 'WERKS' '' 'Plant' '' '' '' ''.
_append_fieldcat 'RIONO' '' '' '' 'I/O Number' '' '' '' ''.
_append_fieldcat 'BAPTH' '' '' '' 'Ball/Pin Pitch' '' '' '' ''.
_append_fieldcat 'BOPPH' '' '' '' 'Bond Pad Pitch' '' '' '' ''.
_append_fieldcat 'DIAME' '' '' '' 'Wire Diameter' '' '' '' ''.
_append_fieldcat 'NOWIR' '' '' '' 'Wire Count' '' '' '' ''.
ENDFORM. "build_fieldcat
*&---------------------------------------------------------------------*
*& 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'.
* 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
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. " ALV_OUTPUT
*&---------------------------------------------------------------------*
*& Form format_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form format_file .
concatenate 'Material#' ' Material Description' 'Plant' 'I/O Number'
'Ball/Pin Pitch' 'Bond Pad Pitch' 'Wire Diameter'
'Wire Count' into xtab1 separated by ','.
append xtab1.
clear xtab1.
loop at ITAB.
concatenate '"' ITAB-MATNR '"' ','
'"' ITAB-MAKTX '"' ','
'"' ITAB-WERKS '"' ','
'"' ITAB-RIONO '"' ','
'"' ITAB-BAPTH '"' ','
'"' ITAB-BOPPH '"' ','
'"' ITAB-DIAME '"' ','
'"' ITAB-NOWIR '"' ','
into xtab1.
append xtab1.
clear: xtab1.
endloop.
endform. " format_file
*&---------------------------------------------------------------------*
*& Form download_pc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form download_pc .
data : l_fname type STRING.
if P_FILE ne space.
l_fname = P_FILE.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
FILENAME = l_fname
FILETYPE = 'ASC'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = xtab1[]
* 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.
WRITE:/ 'File is output to', l_fname.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.
endform. " download_pc