ลิขิตฟ้า หรือ จะสู้มานะคน

chon_pro
Location :
สมุทรปราการ Thailand

[Profile ทั้งหมด]

ฝากข้อความหลังไมค์
Rss Feed
Smember
ผู้ติดตามบล็อก : 12 คน [?]




ผมแค่อยากเขียน บันทึกเกี่ยวกับข้อมูลการทำงานของผมต่างๆ เพื่อเก็บเอาไว้ใช้ดูเวลาที่ผมหลงลืม และเพื่อเป็นประโยชน์ กับน้องๆๆๆ ทั้งหลาย
loaocat

Stat Counter :
Group Blog
 
All Blogs
 
Friends' blogs
[Add chon_pro's blog to your web]
Links
 

 
ZPP272 Transfer BOM from SAP to SFC

***********************************************************************
* ABAP Name : ZPP272
* Created by : Suchon Poomcharoen.
* Created on : 28 July 2009
* Version : 1.0
* Transport :
* Task ID :
*----------------------------------------------------------------------
* Description: This program is used for BOM SAP to SFC
*----------------------------------------------------------------------
* Modification Log:
* 1) Changed by :
* Changed on :
* Transport :
* Correction-No :
* Description : 1)
*----------------------------------------------------------------------
report zpp272.
*********************************************
* Tables
*********************************************
TABLES:
MAST,CSAP_MBOM,ZSFCBOM.
*********************************************
* select screen
*********************************************
SELECT-OPTIONS:
S_MATNR FOR CSAP_MBOM-MATNR.
PARAMETER:
P_Case(1) TYPE C DEFAULT 'A'.
*********************************************
* Data Declaration
*********************************************
data:
t_stpo like stpo_api02 occurs 0 with header line, "BOM items
t_stko like stko_api02 occurs 0 with header line, "BOM headers
t_mara like MARA_MATNR occurs 0 with header line,
T_ZSFCBOM LIKE ZSFCBOM OCCURS 0 WITH HEADER LINE,
v_MATNR like CSAP_MBOM-MATNR,
v_maktx like makt-maktx.


**********************************************
*Main Routines
**********************************************
perform get_material_mast.

loop at t_mara.
clear v_matnr.
v_matnr = t_mara-matnr.
perform get_material_bom.
endloop.

**********************************************
**********************************************

*&---------------------------------------------------------------------*
*& Form get_material_bom
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_material_bom.

perform alternative_bom_01 using '01' .
perform alternative_bom_01 using '02' .

endform. " get_material_bom
*&---------------------------------------------------------------------*
*& Form get_material_mast
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_material_mast.

*delete from ZSFCBOM where MATNR <> 1. CLEAR T_mara.
clear t_mara.
REFRESH t_mara.

CASE P_Case.
WHEN 'A'.
* เลือก Bom ทีมีการเปลี่ยนค่าระดับ Item
SELECT mast~matnr
FROM mast
INNER JOIN MARA
ON MAST~MATNR = MARA~MATNR
INNER JOIN STKO
ON STKO~STLAL = MAST~STLAL
AND STKO~STLNR = MAST~STLNR
INNER JOIN STPO
ON STPO~DATUV = STKO~DATUV
AND STPO~STLNR = STKO~STLNR
AND STPO~STLTY = STKO~STLTY
INTO t_mara-matnr
WHERE MARA~MATNR in s_matnr
and LVORM <> 'X'
and MTART in ('ZFIN','ZSFI')
and ZZPRODU eq 'PLP'
and STPO~AEDAT = SY-DATUM.
* append t_mara.
*Collect ใช้สำหรับ นำค่าที่ duplicate ออกไป
collect t_mara.
ENDSELECT.

* เลือก Bom ทีมีการเปลี่ยนค่าระดับ Header
SELECT mast~matnr
FROM mast
INNER JOIN MARA
ON MAST~MATNR = MARA~MATNR
INNER JOIN STKO
ON STKO~STLAL = MAST~STLAL
AND STKO~STLNR = MAST~STLNR
INTO t_mara-matnr
WHERE MARA~MATNR in s_matnr
and LVORM <> 'X'
and MTART in ('ZFIN','ZSFI')
and ZZPRODU eq 'PLP'
and STKO~AEDAT = SY-DATUM.
append t_mara.
ENDSELECT.

* เลือก Bom ทีมีการสร้างใหม่
SELECT mast~matnr
FROM mast
INNER JOIN MARA
ON MAST~MATNR = MARA~MATNR
INNER JOIN STKO
ON STKO~STLAL = MAST~STLAL
AND STKO~STLNR = MAST~STLNR
INTO t_mara-matnr
WHERE MARA~MATNR in s_matnr
and LVORM <> 'X'
and MTART in ('ZFIN','ZSFI')
and ZZPRODU eq 'PLP'
and STKO~ANDAT = SY-DATUM.
append t_mara.
ENDSELECT.

WHEN 'S'.


SELECT matnr FROM mara INTO t_mara-matnr
WHERE MATNR in s_matnr
and LVORM <> 'X'
and MTART in ('ZFIN','ZSFI')
and ZZPRODU eq 'PLP'.
append t_mara.
ENDSELECT.


WHEN OTHERS.
Exit.
ENDCASE.



ENDFORM. " get_material_mast
*&---------------------------------------------------------------------*
*& Form read_mat_desc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form read_mat_desc using p_matnr.
clear: v_maktx.
select single maktx into (v_maktx)
from makt
where matnr = p_matnr
and spras = 'E'.

ENDFORM. " read_mat_desc
*&---------------------------------------------------------------------*
*& Form alternative_bom_01
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alternative_bom_01 using p_alter.
CLEAR: T_STKO,
T_STPO.
REFRESH:
T_STKO,
T_STPO.

call function 'CSAP_MAT_BOM_READ'
exporting
material = v_matnr
plant = '0006'
bom_usage = '1'
ALTERNATIVE = p_alter
* VALID_FROM =
* VALID_TO =
* CHANGE_NO =
* REVISION_LEVEL =
* FL_DOC_LINKS = ' '
* FL_DMU_TMX = ' '
* IMPORTING
* FL_WARNING =
tables
t_stpo = t_stpo
T_STKO = t_stko
* T_DEP_DATA =
* T_DEP_DESCR =
* T_DEP_ORDER =
* T_DEP_SOURCE =
* T_DEP_DOC =
* T_DOC_LINK =
* T_DMU_TMX =
exceptions
error = 1
others = 2
.
* IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ENDIF.
IF SY-SUBRC = 0.
LOOP AT T_STPO.
clear: T_ZSFCBOM[],
T_ZSFCBOM.



call function 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = t_stpo-COMPONENT
IMPORTING
output = t_stpo-COMPONENT.

T_ZSFCBOM-MATNR = v_matnr.
t_zsfcbom-STLNR = t_stpo-bom_no.

case T_STPO-ITEM_NO.
when '0010'. "MOULD1
t_zsfcbom-mould1 = t_stpo-COMPONENT.
perform read_mat_desc using t_stpo-COMPONENT.
t_zsfcbom-mould1t = v_maktx.
when '0020'. "MOULD2
t_zsfcbom-mould2 = t_stpo-COMPONENT.
perform read_mat_desc using t_stpo-COMPONENT.
t_zsfcbom-mould2t = v_maktx.
when '0030'. "RING

t_zsfcbom-RING = t_stpo-COMPONENT.
perform read_mat_desc using t_stpo-COMPONENT.
t_zsfcbom-ringt = v_maktx.
IF t_zsfcbom-RING(1) = 'R'.
t_zsfcbom-class = '001'.
else.
t_zsfcbom-class = '022'.
ENDIF.

when '0040'. "RESIN
t_zsfcbom-Resin = t_stpo-COMPONENT.
t_zsfcbom-RESIN_WEIGHT = t_stpo-COMP_QTY.
perform read_mat_desc using t_stpo-COMPONENT.
t_zsfcbom-resint = v_maktx.
t_zsfcbom-resin_unit = t_stpo-COMP_UNIT.
when '0050'. "PACKING NO.
t_zsfcbom-PACKNO = t_stpo-COMPONENT.
perform read_mat_desc using t_stpo-COMPONENT.
t_zsfcbom-packnot = v_maktx.
when '0060'. "LABEL NO.
t_zsfcbom-labelno = t_stpo-COMPONENT.
perform read_mat_desc using t_stpo-COMPONENT.
t_zsfcbom-labelnot = v_maktx.
when '0070'. "PLASTIC INSERT.
t_zsfcbom-PINSERT = t_stpo-COMPONENT.
perform read_mat_desc using t_stpo-COMPONENT.
t_zsfcbom-pinsertt = v_maktx.
endcase.

* if t_stpo-changed_on <> ' '.

CONCATENATE t_stpo-CHANGED_ON+6(4) t_stpo-CHANGED_ON+3(2)
t_stpo-changed_on(2) into t_zsfcbom-AEDAT .
* endif.



ENDLOOP.
t_zsfcbom-status = 'X'.
* t_zsfcbom-status = 'E'.
* t_zsfcbom-AEDAT = t_stpo-CHANGED_ON.
t_zsfcbom-STLAL = p_alter.
APPEND T_ZSFCBOM.
MODIFY ZSFCBOM FROM TABLE T_ZSFCBOM.
* Commit work สั่งให้ DataBase ทำการ Save data ทันที
COMMIT WORK.
endif.




Create Date : 28 สิงหาคม 2552
Last Update : 28 สิงหาคม 2552 13:55:35 น. 0 comments
Counter : 711 Pageviews.

ชื่อ : * blog นี้ comment ได้เฉพาะสมาชิก
Comment :
  *ส่วน comment ไม่สามารถใช้ javascript และ style sheet
 
 Pantip.com | PantipMarket.com | Pantown.com | © 2004 BlogGang.com allrights reserved.