*&---------------------------------------------------------------------*
*& Report ZOSD0022 *
*& *
*&---------------------------------------------------------------------*
*& Date: 2008-06-19
*& Author: vista
*& Description: Display report for Broadcom EDI
*& Request: DEVK924850 [DS080608]
*&
*& Date: 2008-07-17
*& Author: vista
*& Description: Change 'From Date & Time' and 'To Date & Time'
*& Request: DEVK925074
*&
*& Date: 2008-07-22
*& Author: vista
*& Description: Change Two Fileds Description
*& Request: DEVK925080
*
*-----------------------------------------------------------------------
* Change History:
* ===============
* Task# Date By Description
* DS080608 2008.11.14 wei_zhu 1.For lot number field remove all
* character that include and after “$” sign
* 2.Add logic to check if the lot number
* has been transacted before. If already
* remove from report.
* Transport Request :DEVK925259
*-----------------------------------------------------------------------
*-----------------------------------------------------------------------
* Change History:
* ===============
* Task # Request Date By
* DEVK925639 2008.09.26 vista
* Description: Download file base on daily by lot number
*-----------------------------------------------------------------------
*-----------------------------------------------------------------------
* Change History:
* ===============
* Task # Request Date By
* DEVK925661 2008/10/01 Stephen
* Description: Remove the hypen from ITAB-LASTUPDATE
*-----------------------------------------------------------------------
*-----------------------------------------------------------------------
* Change History:
* ===============
* Task # Request Date By
* DEVK925816 2008.10.24 vista
* Description: fix a bug: get lot.num in IMI database [DS080608]
*-----------------------------------------------------------------------
*-----------------------------------------------------------------------
* Change History:
* ===============
* Task # Request Date By
* DEVK925933 2008.11.05 vista
* Description: delete end of character by '$' or ':' [DS081013]
*-----------------------------------------------------------------------
REPORT ZOSD0022 .
TABLES: VBAK,VBAP,AUFK,SYST.
TYPE-POOLS: SLIS.
DATA: C_VENDOR_CODE(20) TYPE C.
DATA: BEGIN OF ITAB OCCURS 0,
FILE(6) TYPE C,
FILE1(6) TYPE C , "Trading partner's contact person
FILE2(23) TYPE C, "Trading partner's email (vendor code*********)
FILE3(12) TYPE C, "Trading partner's fax (Start run program time)
FILE4(13) TYPE C, "Trading partner's contact number
FILE5(13) TYPE C, "Information Sender
FILE6(33) TYPE C, "Trading partner's DUNS( LOT NUMBER*****)
FILE7(5) TYPE C, "NA
FILE8(5) TYPE C, "Contract Manufacturer
FILE9(5) TYPE C, "NA
FILE10(13) TYPE C, "create date of report (*****)
FILE11(23) TYPE C, "YYYYMMDDTHHMMSS_BOM (*****)
FILE12(13) TYPE C, "Broacom contact Person
FILE13(13) TYPE C, "Broadcom Contact Person email
FILE14(13) TYPE C, "Broadcom Contact Person fax
FILE15(13) TYPE C, "Broadcom Contact number
FILE16(13) TYPE C, "Information Receiver
FILE17(13) TYPE C, "Broadcom DUNS
FILE18(13) TYPE C, "Manufacturer
LASTUPDATE(10),
END OF ITAB.
DATA: BEGIN OF TIMI OCCURS 0,
PO_NUMBER(15) TYPE C,
LASTUPDATE(20),
LOT_NUMBER(30) TYPE C,
END OF TIMI.
*Start vista "DEVK925816
DATA: BEGIN OF T_LOT OCCURS 0,
LOT_NBER(30) TYPE C,
END OF T_LOT.
*End vista "DEVK925816
DATA: BEGIN OF T_CODE OCCURS 0,
MFGORDERNAME(30),
C_VENDOR_CODE(20) TYPE C,
END OF T_CODE.
DATA: BEGIN OF DTAB OCCURS 0,
DATE(10),
END OF DTAB.
DATA: G_SVFILE LIKE RLGRAP-FILENAME.
DATA:G_SUBRC LIKE SY-SUBRC.
DATA: FILENAME(33) TYPE C.
DATA: DATE1(25) TYPE C.
DATA: DATE2(30) TYPE C.
CONCATENATE '"' SY-DATUM 'T' SY-UZEIT '.000Z' '"' ',' INTO DATE1.
CONCATENATE '"' SY-DATUM 'T' SY-UZEIT '_BOM' '_ASAT' '"' ',' INTO DATE2
.
DATA: DATE_NUM TYPE I.
DATA: NUM TYPE I.
DATA: STR1(20).
*&---------------------------------------------------------------------*
*& S E L E C T I O N S C R E E N *
*&---------------------------------------------------------------------*
SELECT-OPTIONS: P_WERKS FOR VBAP-WERKS NO-DISPLAY DEFAULT '3100'.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.
PARAMETERS: P_BUDAT LIKE MKPF-BUDAT DEFAULT SY-DATUM,
P_TIME LIKE SY-UZEIT DEFAULT '001500'.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_BUDAT1 LIKE MKPF-BUDAT DEFAULT SY-DATUM,
P_TIME1 LIKE SY-UZEIT DEFAULT '001500'.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-002.
PARAMETERS: P_SVPATH LIKE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B3.
*----------------------------------------------------------------------*
* Macro Definition *
*----------------------------------------------------------------------*
* Get SQL Query result
DEFINE IMI_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 IMI_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.
*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
INITIALIZATION.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM GETDATA.
PERFORM CHECK_VENDOR_CODE.
END-OF-SELECTION.
DATE_NUM = P_BUDAT - P_BUDAT1.
LOOP AT DTAB.
PERFORM DOWNLOAD_FILE_HEAD USING P_SVPATH.
CHECK G_SUBRC = 0.
LOOP AT ITAB WHERE LASTUPDATE = DTAB-DATE.
FILENAME = ITAB-FILE6.
REPLACE '"' IN FILENAME WITH ''.
REPLACE ',' IN FILENAME WITH ''.
REPLACE '"' IN FILENAME WITH ''.
CONDENSE FILENAME.
PERFORM DOWNLOAD_FILE_ITEM_TO_SERVER1 USING P_SVPATH.
ENDLOOP.
* CLOSE FILE
CLOSE DATASET G_SVFILE.
WRITE:/ 'Export is successful.'.
WRITE:/ 'Temporary file created on server:', G_SVFILE.
ENDLOOP.
*----------------------------------------------------------------------*
* END-OF-SELECTION *
*----------------------------------------------------------------------*
*&--------------------------------------------------------------------*
*& Form Getdata
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM GETDATA.
PERFORM GET_IMI_INFO.
PERFORM GET_VENDOR_CODE.
ENDFORM. "GETDATA
*&--------------------------------------------------------------------*
*& Form GET_MES_WIP_INFO
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM GET_IMI_INFO.
DATA: L_LOT(30).
DATA: L_DBCONNAME LIKE DBCON-CON_NAME.
DATA: L_AUFNR LIKE AUFK-AUFNR.
DATA: L_SUBRC LIKE SY-SUBRC.
DATA: L_DBOPEN LIKE SY-SUBRC.
DATA: L_DBCON(10) VALUE 'HKIMI_DG'.
MOVE L_DBCON TO L_DBCONNAME.
PERFORM CHECK_DBCON USING P_WERKS-LOW
CHANGING L_DBCONNAME
L_SUBRC.
PERFORM CONNECT_DBCON USING L_DBCONNAME
CHANGING L_SUBRC.
L_DBOPEN = L_SUBRC.
IF L_DBOPEN = 0.
* Retrieve info for Po Number in IMI
CLEAR L_SUBRC.
L_AUFNR = TIMI-PO_NUMBER.
SHIFT L_AUFNR LEFT DELETING LEADING '0'.
PERFORM IMI_DATA USING L_AUFNR
CHANGING L_SUBRC.
DO.
CLEAR TIMI.
IMI_FETCH_DATA TIMI L_SUBRC C11A.
IF L_SUBRC = 0.
TIMI-LASTUPDATE = TIMI-LASTUPDATE(10).
COLLECT TIMI.
ELSE.
EXIT.
ENDIF.
ENDDO.
IMI_CLOSE_CURSOR C11A L_SUBRC.
*Start vista "DEVK925816
LOOP AT TIMI.
*Start vista "DEVK925933 [DS081013]
SEARCH TIMI-LOT_NUMBER FOR '$'.
IF SY-SUBRC = 0.
NUM = SY-FDPOS.
STR1 = TIMI-LOT_NUMBER(NUM).
CONCATENATE STR1 '",' INTO TIMI-LOT_NUMBER.
ELSE.
SEARCH TIMI-LOT_NUMBER FOR ':'.
IF SY-SUBRC = 0.
NUM = SY-FDPOS.
STR1 = TIMI-LOT_NUMBER(NUM).
CONCATENATE STR1 '",' INTO TIMI-LOT_NUMBER.
ENDIF.
ENDIF.
MODIFY TIMI.
*End vista "DEVK925933 [DS081013]
L_LOT = TIMI-LOT_NUMBER.
PERFORM IMI_DATA_FILTER USING L_LOT CHANGING L_SUBRC.
DO.
CLEAR T_LOT.
IMI_FETCH_DATA T_LOT L_SUBRC C11B.
IF L_SUBRC = 0.
APPEND T_LOT.
ELSE.
EXIT.
ENDIF.
ENDDO.
IMI_CLOSE_CURSOR C11B L_SUBRC.
ENDLOOP.
*End vista "DEVK925816
* Disconnect from IMI database
PERFORM DISCONNECT_DBCON USING L_DBCONNAME
CHANGING L_SUBRC.
ENDIF.
LOOP AT TIMI.
READ TABLE T_LOT WITH KEY LOT_NBER = TIMI-LOT_NUMBER.
IF SY-SUBRC <> 0.
DELETE TIMI.
ENDIF.
ENDLOOP.
ENDFORM. "GET_MES_WIP_INFO
*&--------------------------------------------------------------------*
*& Form CHECK_DBCON
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->P_PLANT text
* -->P_DBCONNAMEtext
* -->P_SUBRC text
*---------------------------------------------------------------------*
FORM CHECK_DBCON USING P_PLANT
CHANGING P_DBCONNAME
P_SUBRC.
TABLES:DBCON.
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 CONNECT_DBCON
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->P_DBCONNAMEtext
* -->P_SUBRC 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 IMI_DATA
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->L_AUFNR text
* -->L_SUBRC text
*---------------------------------------------------------------------*
FORM IMI_DATA USING L_AUFNR
CHANGING P_SUBRC.
*Start vista "DEVK925074
DATA: L_FROM_DATE(19),
L_END_DATE(19),
L_DATE1(10),
L_TIME1(8),
L_DATE2(10),
L_TIME2(8).
CONCATENATE P_BUDAT(4) '-' P_BUDAT+4(2) '-' P_BUDAT+6(2) INTO L_DATE1
.
CONCATENATE P_TIME(2) ':' P_TIME+2(2) ':' P_TIME+4(2) INTO L_TIME1.
CONCATENATE L_DATE1 L_TIME1 INTO L_FROM_DATE SEPARATED BY SPACE.
CONCATENATE P_BUDAT1(4) '-' P_BUDAT1+4(2) '-' P_BUDAT1+6(2) INTO
L_DATE2.
CONCATENATE P_TIME1(2) ':' P_TIME1+2(2) ':' P_TIME1+4(2) INTO L_TIME2.
CONCATENATE L_DATE2 L_TIME2 INTO L_END_DATE SEPARATED BY SPACE.
*End vista "DEVK925074
CLEAR P_SUBRC.
TRY.
EXEC SQL.
OPEN C11A FOR
*DEVK925816 -->
select distinct mfgorder, lastupdate,lot from SpecialInfo
where customer='10030'
and lastupdate between :L_FROM_DATE
and :L_END_DATE
*DEVK925816 <--
* select distinct mfgorder,lastupdate,Lot=Case charindex('$',lot)
* when 0 then
* lot
* else
* substring(lot,0,charindex('$',lot))
* end
* from SpecialInfo
* where customer='10030'
* and lastupdate between :L_FROM_DATE and :L_END_DATE
* and lot not in
* (select distinct lot=Case charindex('$',lot)
* when 0 then
* lot
* else
* substring(lot,0,charindex('$',lot))
* end
* from SpecialInfo
* where customer='10030'
* and lastupdate < :L_FROM_DATE
*
* and lot<>'')
ENDEXEC.
P_SUBRC = SY-SUBRC.
CATCH CX_SY_NATIVE_SQL_ERROR.
P_SUBRC = '99'.
ENDTRY.
ENDFORM. "CONNECT_DBCON
*&---------------------------------------------------------------------*
*& Form DISCONNECT_DBCON
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_L_DBCONNAME text
* <--P_L_SUBRC 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 GET_VENDOR_CODE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM GET_VENDOR_CODE.
DATA: L_DBCONNAME LIKE DBCON-CON_NAME.
DATA: L_AUFNR LIKE AUFK-AUFNR.
DATA: L_SUBRC LIKE SY-SUBRC.
DATA: L_DBOPEN LIKE SY-SUBRC.
DATA: L_DBCON(10) VALUE 'DGMDDB'.
MOVE L_DBCON TO L_DBCONNAME.
PERFORM CHECK_DBCON USING P_WERKS-LOW
CHANGING L_DBCONNAME
L_SUBRC.
PERFORM CONNECT_DBCON USING L_DBCONNAME
CHANGING L_SUBRC.
L_DBOPEN = L_SUBRC.
IF L_DBOPEN = 0.
* RETRIEVE INFO FOR Vendor Code IN MES
LOOP AT TIMI.
L_AUFNR = TIMI-PO_NUMBER.
SHIFT L_AUFNR LEFT DELETING LEADING '0'.
CLEAR L_SUBRC.
PERFORM MES_GET_VENDOR_CODE USING L_AUFNR
CHANGING L_SUBRC.
DO.
CLEAR T_CODE.
IMI_FETCH_DATA T_CODE L_SUBRC C11A.
IF L_SUBRC = 0.
APPEND T_CODE.
ELSE.
EXIT.
ENDIF.
ENDDO.
IMI_CLOSE_CURSOR C11A L_SUBRC.
ENDLOOP.
* Disconnect from IMI database
PERFORM DISCONNECT_DBCON USING L_DBCONNAME
CHANGING L_SUBRC.
ENDIF.
ENDFORM. "GET_VENDOR_CODE
*&--------------------------------------------------------------------*
*& Form MES_GET_VENDOR_CODE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->L_AUFNR text
* -->L_SUBRC text
*---------------------------------------------------------------------*
FORM MES_GET_VENDOR_CODE USING L_AUFNR
CHANGING P_SUBRC.
CLEAR P_SUBRC.
TRY.
EXEC SQL.
OPEN C11A FOR
SELECT distinct MfgOrder.mfgordername,
isnull(MaterialVendorCode.Description,'') as SubstrateVendorCode
FROM MfgOrderMaterialListItem with(nolock)
LEFT OUTER JOIN MfgOrder with(nolock) ON
MfgOrderMaterialListItem.mfgorderid = MfgOrder.mfgorderid
LEFT OUTER JOIN ProductBase with(nolock) ON
MfgOrderMaterialListItem.ProductBaseId = ProductBase.ProductBaseId
LEFT OUTER JOIN Product with(nolock) ON
MfgOrderMaterialListItem.ProductBaseId = Product.ProductBaseId
LEFT OUTER JOIN ProductType with(nolock) ON
Product.ProductTypeId = ProductType.ProductTypeId
LEFT OUTER JOIN MaterialVendorCode with(nolock) on
MfgOrderMaterialListItem.vendorname =
MaterialVendorCode.MaterialVendorCodeName
WHERE MfgOrder.MfgOrderName= :L_AUFNR
and ProductTypeName = 'SUBS'
ENDEXEC.
P_SUBRC = SY-SUBRC.
CATCH CX_SY_NATIVE_SQL_ERROR.
P_SUBRC = '99'.
ENDTRY.
ENDFORM. "MES_GET_VENDOR_CODE
*&--------------------------------------------------------------------*
*& Form check_vendor_code
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM CHECK_VENDOR_CODE.
DATA: DATE(12) TYPE C.
SORT TIMI BY PO_NUMBER LOT_NUMBER.
LOOP AT T_CODE.
* ITAB-FILE2 = T_CODE-C_VENDOR_CODE.
CONCATENATE '"' T_CODE-C_VENDOR_CODE '"' ',' INTO ITAB-FILE2.
READ TABLE TIMI WITH KEY PO_NUMBER = T_CODE-MFGORDERNAME.
IF SY-SUBRC = 0.
CONCATENATE '"' TIMI-LOT_NUMBER '"' ',' INTO ITAB-FILE6.
ITAB-LASTUPDATE = TIMI-LASTUPDATE.
ENDIF.
"DEVK925661
CONCATENATE ITAB-LASTUPDATE+0(4) ITAB-LASTUPDATE+5(2)
ITAB-LASTUPDATE+8(2) INTO ITAB-LASTUPDATE.
* LOOP AT ITAB.
CONCATENATE '"' ITAB-LASTUPDATE 'Z' '"' ',' INTO ITAB-FILE3.
* MODIFY ITAB.
* ENDLOOP.
ITAB-FILE = 'DET,'.
ITAB-FILE1 = '"Add",'.
* ITAB-FILE3 = DATE.
ITAB-FILE4 = '"Substrate",'.
ITAB-FILE5 = '"Add",'.
ITAB-FILE7 = '"NA"'.
DTAB-DATE = ITAB-LASTUPDATE.
COLLECT DTAB.
CLEAR DTAB.
APPEND ITAB.
CLEAR ITAB.
ENDLOOP.
ENDFORM. "check_vendor_code
*&--------------------------------------------------------------------*
*& Form DOWNLOAD_FILE_TO_SERVER
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DOWNLOAD_FILE_ITEM_TO_SERVER1 USING P_SVPATH.
DATA: BEGIN OF O_TAB OCCURS 0,
FILE(6) TYPE C,
FILE1(6) TYPE C , "Trading partner's contact person
FILE2(23) TYPE C,
"Trading partner's email (vendor code*********)
FILE3(12) TYPE C,
"Trading partner's fax (Start run program time)
FILE4(13) TYPE C, "Trading partner's contact number
FILE5(13) TYPE C, "Information Sender
FILE6(33) TYPE C, "Trading partner's DUNS( LOT NUMBER*****)
FILE7(5) TYPE C, "NA
FILE8(5) TYPE C, "Contract Manufacturer
FILE9(5) TYPE C, "NA
FILE10(13) TYPE C, "create date of report (*****)
FILE11(23) TYPE C, "YYYYMMDDTHHMMSS_BOM (*****)
FILE12(13) TYPE C, "Broacom contact Person
FILE13(13) TYPE C, "Broadcom Contact Person email
FILE14(13) TYPE C, "Broadcom Contact Person fax
FILE15(13) TYPE C, "Broadcom Contact number
FILE16(13) TYPE C, "Information Receiver
FILE17(13) TYPE C, "Broadcom DUNS
FILE18(13) TYPE C, "Manufacturer
END OF O_TAB.
FIELD-SYMBOLS: <FS>.
DATA: L_FIELD(200) TYPE C,
L_STRING(3000) TYPE C.
DATA:P_SUBRC LIKE SY-SUBRC.
P_SUBRC = 1.
MOVE-CORRESPONDING ITAB TO O_TAB.
CLEAR L_STRING.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE O_TAB TO <FS>.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
WRITE <FS> TO L_FIELD.
CONDENSE L_FIELD.
IF SY-INDEX = 1.
L_STRING = L_FIELD.
ELSE.
CONCATENATE L_STRING L_FIELD INTO L_STRING.
* SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
ENDIF.
ENDDO.
TRANSFER L_STRING TO G_SVFILE.
ENDFORM. "DOWNLOAD_FILE_TO_SERVER
*&--------------------------------------------------------------------*
*& Form DOWNLOAD_FILE_TO_SERVER2
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->P_SVPATH text
*---------------------------------------------------------------------*
FORM DOWNLOAD_FILE_TO_SERVER2 USING P_SVPATH.
FIELD-SYMBOLS: <FS>.
DATA: L_FIELD(200) TYPE C,
L_STRING(3000) TYPE C.
DATA:P_SUBRC LIKE SY-SUBRC.
P_SUBRC = 1.
TRY.
CONCATENATE P_SVPATH FILENAME '_' SY-DATUM SY-UZEIT '.CSV'
INTO G_SVFILE.
OPEN DATASET G_SVFILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
CONCATENATE 'HDR,'
'"Jenny Nip",'
'"jenny_nip@asathk.com",'
'"86-769-85642129",'
'"86-769-85647788",'
'"Information Sender",'
'"197051014",'
'"Semiconductor Manufacturing",'
'"Contract Manufacturer",'
'"NA",'
* 'create date of report(YYYYMMDDZ)'
* '(YYYYMMDDTHHMMSS_BOM)'
DATE1
DATE2
'"BC Lee",'
'"bclee@broadcom.com",'
'"65-6668-4715",'
'"65-6668-4877",'
'"Information Receiver",'
'"799870605",'
'"Manufacturer"'
INTO L_STRING.
* SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
*.
TRANSFER L_STRING TO G_SVFILE.
* LOOP AT ITAB WHERE FILE2 = ''.
CLEAR L_STRING.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE ITAB TO <FS>.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
WRITE <FS> TO L_FIELD.
CONDENSE L_FIELD.
IF SY-INDEX = 1.
L_STRING = L_FIELD.
ELSE.
CONCATENATE L_STRING L_FIELD INTO L_STRING.
* SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
ENDIF.
ENDDO.
TRANSFER L_STRING TO G_SVFILE.
* ENDLOOP.
CLOSE DATASET G_SVFILE.
WRITE:/ 'Export is successful.'.
WRITE:/ 'Temporary file created on server:', G_SVFILE.
P_SUBRC = 0.
ELSE.
WRITE:/ 'Export is failed.'.
ENDIF.
CATCH CX_ROOT.
WRITE:/ 'Temporary file writing error on server.'.
ENDTRY.
ENDFORM. "DOWNLOAD_FILE_TO_SERVER2
*&---------------------------------------------------------------------*
*& Form process_date
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PROCESS_DATE .
LOOP AT ITAB.
DTAB-DATE = ITAB-FILE3.
APPEND DTAB.
CLEAR DTAB.
ENDLOOP.
SORT DTAB BY DATE.
DELETE ADJACENT DUPLICATES FROM DTAB COMPARING DATE.
ENDFORM. " process_date
*&---------------------------------------------------------------------*
*& Form DOWNLOAD_FILE_HEAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_SVPATH text
*----------------------------------------------------------------------*
FORM DOWNLOAD_FILE_HEAD USING P_SVPATH.
FIELD-SYMBOLS: <FS>.
DATA: L_FIELD(200) TYPE C,
L_DATE(10),
L_STRING(3000) TYPE C.
G_SUBRC = 1.
CONCATENATE DTAB-DATE(4) DTAB-DATE+4(2) DTAB-DATE+6(2) INTO L_DATE.
TRY.
CONCATENATE P_SVPATH L_DATE SY-UZEIT '.CSV'
INTO G_SVFILE.
OPEN DATASET G_SVFILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
CONCATENATE 'HDR,'
'"Jenny Nip",'
'"jenny_nip@asathk.com",'
'"86-769-85642129",'
'"86-769-85647788",'
'"Information Sender",'
'"197051014",'
'"Semiconductor Manufacturing",'
'"Contract Manufacturer",'
'"NA",'
* 'create date of report(YYYYMMDDZ)'
* '(YYYYMMDDTHHMMSS_BOM)'
DATE1
DATE2
'"BC Lee",'
'"bclee@broadcom.com",'
'"65-6668-4715",'
'"65-6668-4877",'
'"Information Receiver",'
'"799870605",'
'"Manufacturer"'
INTO L_STRING.
* SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
TRANSFER L_STRING TO G_SVFILE.
G_SUBRC = 0.
ENDIF.
CATCH CX_ROOT.
WRITE:/ 'Temporary file writing error on server.'.
ENDTRY.
ENDFORM. " DOWNLOAD_FILE_HEAD
*&---------------------------------------------------------------------*
*& Form IMI_DATA_FILTER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_L_AUFNR text
* <--P_L_SUBRC text
*----------------------------------------------------------------------*
FORM IMI_DATA_FILTER USING L_LOT
CHANGING P_SUBRC.
DATA: LO_NBER(30) TYPE C.
CONCATENATE TIMI-LOT_NUMBER '%' INTO LO_NBER.
CLEAR P_SUBRC.
TRY.
EXEC SQL.
OPEN C11B FOR
select top 1 lot from dbo.SpecialInfo
where lot like :LO_NBER
and attributename = 'MKNUMBER'
and customer = '10030'
order by attributevalue
ENDEXEC.
ENDTRY.
ENDFORM. " IMI_DATA_FILTER