YMMI001-采购单审批

***********************************************************************
* Report : YMMI1 *
* Application : MM   *
* Subject : PO list *
* Requested by : Rainy *
* Execution : Online when required *
* Ref no: : *
* Author : *
* Req Date : 20140711 *
***********************************************************************
*     采购单审批信息查询 *
***********************************************************************
*     设计主要逻辑与原理说明 *
***********************************************************************
*1.取数根据用户的输入单据编号、交货单类型、计划发货日期、实际发货日期 *
* *
***********************************************************************
* MODIFICATIONS *
* ------------------------------------------------------------------- *
* REL DATE NAME (COMPANY) DESCRIPTION TASK-NO *
* --- ---- ---- --------- ----------- ------- *
***********************************************************************
REPORT YMMI1 NO STANDARD PAGE HEADING MESSAGE-ID Z001.

*----------------------------------------------------------------------
* TYPE-POOLS
*----------------------------------------------------------------------
TYPE-POOLS: SLIS. "ALV

TABLES:EKKO,
EKPO,
LFA1,
MAKT.

*&------------------------------------------------------------------*
*& Internal Table Definition
*&------------------------------------------------------------------*
*&3000000004
DATA:BEGIN OF GT_ALL OCCURS 0,
EBELN LIKE EKKO-EBELN,"SAP-PO
LIFNR LIKE EKKO-LIFNR,"SAP廠商編號
WAERS LIKE EKKO-WAERS,"交易幣別
* TXJCD LIKE EKKO-TXJCD,"交易稅別
STCEG LIKE EKKO-STCEG,"交易税别
EBELP LIKE EKPO-EBELP, "项目号
MATNR LIKE EKPO-MATNR, "材料编号
MENGE LIKE EKPO-MENGE, "訂購數量
NETPR LIKE EKPO-NETPR, "单价
KZWI LIKE EKPO-KZWI5, "金额
* PLIFZ LIKE EKPO-PLIFZ, "預定交期
SLFDT LIKE EKET-SLFDT, "预定交期

NAME1 LIKE LFA1-NAME1,"廠商簡稱
TELF1 LIKE LFA1-TELF1,"公司電話
TELFX LIKE LFA1-TELFX,"公司傳真
NAME2 LIKE LFA1-NAME2,"聯絡人
SPERZ LIKE LFA1-SPERZ,"付款方式 (付款冻结)
ADRNR LIKE LFA1-ADRNR,"联系地址
YUNSW TYPE STRING, "运送方式
TEXT(100) TYPE C, "抬头備註

MAKTX LIKE MAKT-MAKTX, "材料规格
MEINS LIKE MARA-MEINS, "单位

TEXTL(100) TYPE C, "项目備註
SEL TYPE C,
LIN TYPE I,
END OF GT_ALL.

*PO list
DATA:BEGIN OF GT_PO OCCURS 0,
LIFNR LIKE EKKO-LIFNR,"SAP廠商編號
NAME1 LIKE LFA1-NAME1,"廠商簡稱
EBELN LIKE EKKO-EBELN,"SAP-PO
TELF1 LIKE LFA1-TELF1,"公司電話
TELFX LIKE LFA1-TELFX,"公司傳真
NAME2 LIKE LFA1-NAME2,"聯絡人
WAERS LIKE EKKO-WAERS,"交易幣別
SPERZ LIKE LFA1-SPERZ,"付款方式 (付款冻结)
* TXJCD LIKE EKPO-TXJCD,"交易稅別
STCEG LIKE EKKO-STCEG,"交易税别
YUNSW TYPE STRING, "运送方式
ADRNR LIKE LFA1-ADRNR,"联系地址
TEXT(100) TYPE C, "抬头備註
*&add
EBELP LIKE EKPO-EBELP, "项目号
MATNR LIKE EKPO-MATNR, "材料编号
MAKTX LIKE MAKT-MAKTX, "材料规格
MEINS LIKE MARA-MEINS, "单位
MENGE LIKE EKPO-MENGE, "訂購數量
NETPR LIKE EKPO-NETPR, "单价
KZWI LIKE EKPO-KZWI5, "金额
SLFDT LIKE EKET-SLFDT, "预定交期
TEXTL(100) TYPE C, "项目備註
SEL TYPE C,
LIN TYPE I,
END OF GT_PO.

TYPES:BEGIN OF TY_ITEM,
EBELP LIKE EKPO-EBELP, "项目号
MATNR LIKE EKPO-MATNR, "材料编号
MAKTX LIKE MAKT-MAKTX, "材料规格
MEINS LIKE MARA-MEINS, "单位
MENGE LIKE EKPO-MENGE, "訂購數量
NETPR LIKE EKPO-NETPR, "单价
KZWI LIKE EKPO-KZWI5, "金额
SLFDT LIKE EKET-SLFDT, "预定交期
TEXTL(100) TYPE C, "项目備註S
END OF TY_ITEM.
TYPES:IT_ITEM TYPE STANDARD TABLE OF TY_ITEM WITH DEFAULT KEY.
DATA: IT_LINE TYPE STANDARD TABLE OF TY_ITEM WITH HEADER LINE,
WA_LINE1 LIKE IT_LINE.

TYPES:BEGIN OF TY_PO,
LIFNR LIKE EKKO-LIFNR,"SAP廠商編號
NAME1 LIKE LFA1-NAME1,"廠商簡稱
EBELN LIKE EKKO-EBELN,"SAP-PO
TELF1 LIKE LFA1-TELF1,"公司電話
TELFX LIKE LFA1-TELFX,"公司傳真
NAME2 LIKE LFA1-NAME2,"聯絡人
WAERS LIKE EKKO-WAERS,"交易幣別
SPERZ LIKE LFA1-SPERZ,"付款方式 (付款冻结)
* TXJCD LIKE EKPO-TXJCD,"交易稅別
STCEG LIKE EKKO-STCEG,"交易税别
YUNSW TYPE STRING, "运送方式
ADRNR LIKE LFA1-ADRNR,"联系地址
TEXT(100) TYPE C, "抬头備註
ITEM TYPE IT_ITEM,
END OF TY_PO.
DATA:IT_PO TYPE STANDARD TABLE OF TY_PO WITH HEADER LINE,
WA_PO LIKE IT_PO.
DATA:TMP_EBELN LIKE EKKO-EBELN.

TYPES:BEGIN OF TY_HEAD,
LIFNR LIKE EKKO-LIFNR,"SAP廠商編號
NAME1 LIKE LFA1-NAME1,"廠商簡稱
EBELN LIKE EKKO-EBELN,"SAP-PO
TELF1 LIKE LFA1-TELF1,"公司電話
TELFX LIKE LFA1-TELFX,"公司傳真
NAME2 LIKE LFA1-NAME2,"聯絡人
WAERS LIKE EKKO-WAERS,"交易幣別
SPERZ LIKE LFA1-SPERZ,"付款方式 (付款冻结)
* TXJCD LIKE EKPO-TXJCD,"交易稅別
STCEG LIKE EKKO-STCEG,"交易税别
YUNSW TYPE STRING, "运送方式
ADRNR LIKE LFA1-ADRNR,"联系地址
TEXT(100) TYPE C, "抬头備註
SEL TYPE C,
LIN TYPE I,

END OF TY_HEAD.
DATA:IT_HEAD TYPE STANDARD TABLE OF TY_HEAD WITH HEADER LINE.

DATA:BEGIN OF TT_HEAD,

LIFN1 TYPE STRING VALUE ‘field1‘,
LIFN2 TYPE STRING VALUE ‘LIFNR‘,
LIFN3 TYPE STRING VALUE ‘SAP廠商編號‘,
LIFNR LIKE EKKO-LIFNR,"SAP廠商編號
NAM1 TYPE STRING VALUE ‘field3‘,
NAM2 TYPE STRING VALUE ‘NAME1‘,
NAM3 TYPE STRING VALUE ‘廠商簡稱‘,
NAME1 LIKE LFA1-NAME1,"廠商簡稱
EBEL1 TYPE STRING VALUE ‘field6‘,
EBEL2 TYPE STRING VALUE ‘EBELN‘,
EBEL3 TYPE STRING VALUE ‘SAP-PO‘,
EBELN LIKE EKKO-EBELN,"SAP-PO
TEL1 TYPE STRING VALUE ‘field5‘,
TEL2 TYPE STRING VALUE ‘TELF1‘,
TEL3 TYPE STRING VALUE ‘公司電話‘,
TELF1 LIKE LFA1-TELF1,"公司電話
TEF1 TYPE STRING VALUE ‘field7‘,
TEF2 TYPE STRING VALUE ‘TELFX‘,
TEF3 TYPE STRING VALUE ‘公司傳真‘,
TELFX LIKE LFA1-TELFX,"公司傳真
NAM6 TYPE STRING VALUE ‘field8‘,
NAM7 TYPE STRING VALUE ‘NAME2‘,
NAM8 TYPE STRING VALUE ‘聯絡人‘,
NAME2 LIKE LFA1-NAME2,"聯絡人

WAER1 TYPE STRING VALUE ‘field9‘,
WAER2 TYPE STRING VALUE ‘WAERS‘,
WAER3 TYPE STRING VALUE ‘交易幣別‘,
WAERS LIKE EKKO-WAERS,"交易幣別

SPER1 TYPE STRING VALUE ‘field10‘,
SPER2 TYPE STRING VALUE ‘SPER3‘,
SPER3 TYPE STRING VALUE ‘付款方式‘,
SPERZ LIKE LFA1-SPERZ,"付款方式 (付款冻结)
* TXJCD LIKE EKPO-TXJCD,"交易稅別
STCE1 TYPE STRING VALUE ‘field11‘,
STCE2 TYPE STRING VALUE ‘STCEG‘,
STCE3 TYPE STRING VALUE ‘交易稅別‘,
STCEG LIKE EKKO-STCEG,"交易税别

YUNS1 TYPE STRING VALUE ‘field12‘,
YUNS2 TYPE STRING VALUE ‘YUNSW‘,
YUNS3 TYPE STRING VALUE ‘運送方式‘,
YUNSW TYPE STRING, "运送方式

ADRN1 TYPE STRING VALUE ‘field13‘,
ADRN2 TYPE STRING VALUE ‘ADRNR‘,
ADRN3 TYPE STRING VALUE ‘聯繫地址‘,
ADRNR LIKE LFA1-ADRNR,"联系地址

TEXT1 TYPE STRING VALUE ‘field14‘,
TEXT2 TYPE STRING VALUE ‘TEXT‘,
TEXT3 TYPE STRING VALUE ‘備註‘,
TEXT(100) TYPE C, "抬头備註

*&附件
FJIAN1 TYPE STRING,
FJIAN2 TYPE STRING,
FJIAN3 TYPE STRING,
FJIAN4 TYPE STRING,
*&BPM固定格式抬头部分信息
ID TYPE STRING,
APP TYPE STRING,
START TYPE STRING,
FINISH TYPE STRING,
DATE TYPE STRING,

END OF TT_HEAD.
DATA:ST_HEAD LIKE TABLE OF TT_HEAD,
WA_HEAD LIKE LINE OF ST_HEAD.

DATA:BEGIN OF TT_LINE,

EBEL1 TYPE STRING VALUE ‘field99‘,
EBEL2 TYPE STRING VALUE ‘EBELP‘,
EBEL3 TYPE STRING VALUE ‘项目‘,
EBELP LIKE EKPO-EBELP, "项目号

MATN1 TYPE STRING VALUE ‘field1‘,
MATN2 TYPE STRING VALUE ‘MATNR‘,
MATN3 TYPE STRING VALUE ‘材料編碼‘,
MATNR LIKE EKPO-MATNR, "材料编号

MAKT1 TYPE STRING VALUE ‘field2‘,
MAKT2 TYPE STRING VALUE ‘MAKTX‘,
MAKT3 TYPE STRING VALUE ‘材料規格‘,
MAKTX LIKE MAKT-MAKTX, "材料规格

MEIN1 TYPE STRING VALUE ‘field3‘,
MEIN2 TYPE STRING VALUE ‘MEINS‘,
MEIN3 TYPE STRING VALUE ‘單位‘,
MEINS LIKE MARA-MEINS, "单位

MENG1 TYPE STRING VALUE ‘field4‘,
MENG2 TYPE STRING VALUE ‘MENGE‘,
MENG3 TYPE STRING VALUE ‘訂購數量‘,
MENGE LIKE EKPO-MENGE, "訂購數量

NETP1 TYPE STRING VALUE ‘field5‘,
NETP2 TYPE STRING VALUE ‘NETPR‘,
NETP3 TYPE STRING VALUE ‘单价‘,
NETPR LIKE EKPO-NETPR, "单价

KZWI1 TYPE STRING VALUE ‘field6‘,
KZWI2 TYPE STRING VALUE ‘KZWI‘,
KZWI3 TYPE STRING VALUE ‘金额‘,
KZWI LIKE EKPO-KZWI5, "金额

PLIF1 TYPE STRING VALUE ‘field7‘,
PLIF2 TYPE STRING VALUE ‘PLIFZ‘,
PLIF3 TYPE STRING VALUE ‘預定交期‘,
SLFDT LIKE EKET-SLFDT, "預定交期

TET1 TYPE STRING VALUE ‘field8‘,
TET2 TYPE STRING VALUE ‘TEXTL‘,
TET3 TYPE STRING VALUE ‘项目備註‘,
TEXTL(100) TYPE C, "项目備註S

END OF TT_LINE.
DATA:ST_LINE LIKE TABLE OF TT_LINE,
WA_LINE LIKE LINE OF ST_LINE.

DATA:BEGIN OF TY_SIGN,
OK TYPE STRING,
OWN TYPE STRING,
SIGN TYPE STRING,
MARK TYPE STRING,
FLOW TYPE STRING,
TIME TYPE STRING,

END OF TY_SIGN.
DATA:ST_SIGN LIKE TABLE OF TY_SIGN.

DATA:BEGIN OF TY_SIGN1,
OK_K TYPE STRING,
END OF TY_SIGN1.
DATA:ST_SIGN1 LIKE TABLE OF TY_SIGN1.
DATA WS_SIGN1 LIKE LINE OF ST_SIGN1.

*&item data
DATA:BEGIN OF GT_ITEM OCCURS 0,
EBELP LIKE EKPO-EBELP, "项目号
MATNR LIKE EKPO-MATNR, "材料编号
MAKTX LIKE MAKT-MAKTX, "材料规格
MEINS LIKE MARA-MEINS, "单位
MENGE LIKE EKPO-MENGE, "訂購數量
NETPR LIKE EKPO-NETPR, "单价
KZWI LIKE EKPO-KZWI5, "金额
SLFDT LIKE EKET-SLFDT, "預定交期
TEXTL(100) TYPE C, "项目備註
END OF GT_ITEM.

*&for XML
TYPES: BEGIN OF XML_LINE,
DATA(256) TYPE X,
END OF XML_LINE.
DATA: XML_TABLE TYPE TABLE OF XML_LINE,
IN_TABLE TYPE TABLE OF XML_LINE,
WA_TABLE LIKE LINE OF IN_TABLE,
XML_SIZE TYPE I.
DATA:BEGIN OF GT_FILES OCCURS 0,
HEAD TYPE STRING,
ITEM TYPE STRING,
END OF GT_FILES.

DATA: L_RVAL TYPE I.
DATA: STR TYPE STRING .
DATA: TMPEBELN LIKE EKKO-EBELN.
DATA: L_IXML TYPE REF TO IF_IXML,
L_ENCODING TYPE REF TO IF_IXML_ENCODING,
L_COMMENT TYPE REF TO IF_IXML_COMMENT,
L_DOC TYPE REF TO IF_IXML_DOCUMENT,
L_ROOT TYPE REF TO IF_IXML_ELEMENT,
L_PO TYPE REF TO IF_IXML_ELEMENT,
L_POHEAD TYPE REF TO IF_IXML_ELEMENT,
L_ITEM TYPE REF TO IF_IXML_ELEMENT,
L_ELEMENT TYPE REF TO IF_IXML_ELEMENT,
L_ATTRIBUTE TYPE REF TO IF_IXML_ATTRIBUTE,
L_OSTREAM TYPE REF TO IF_IXML_OSTREAM,
L_FACTORY TYPE REF TO IF_IXML_STREAM_FACTORY.

*&Variant
DATA:G_LEN TYPE I.
DATA:S_SFILE LIKE RLGRAP-FILENAME.

DATA: W_XML TYPE STRING,
G_XML TYPE STRING,
W_LEN TYPE I,
XML_STRING TYPE STRING.
DATA:BEGIN OF IT_XML OCCURS 0,
LINE(100) TYPE C,
END OF IT_XML.
DATA:RESULT_XML TYPE STANDARD TABLE OF SMUM_XMLTB,
RETURN TYPE STANDARD TABLE OF BAPIRET2,
WA_XML TYPE SMUM_XMLTB.

*&------------------------------------------------------------------*
*& Global Variants Definition
*&------------------------------------------------------------------*
*DATA:GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
* GS_FIELDCAT TYPE LINE OF SLIS_T_FIELDCAT_ALV.
*&------------------------------------------------------------------*
*& ALV
*&------------------------------------------------------------------*
DATA:LS_LAYOUT TYPE SLIS_LAYOUT_ALV,
LV_TITLE TYPE LVC_TITLE.
DATA:G_PROGRAM TYPE SY-REPID,
GW_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
GT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.

************************************************************************
* Select Screen *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME.

SELECT-OPTIONS:S_BSART FOR EKKO-BSART.
SELECT-OPTIONS:S_EBELN FOR EKKO-EBELN. " obligatory.
SELECT-OPTIONS:S_WERKS FOR EKPO-WERKS.
SELECT-OPTIONS:S_MATNR FOR EKPO-MATNR.
SELECT-OPTIONS:S_EKORG FOR EKKO-EKORG.
SELECT-OPTIONS:S_EKGRP FOR EKKO-EKGRP.

"selection-screen skip 1.
SELECTION-SCREEN END OF BLOCK BLK1.

SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME.

PARAMETERS:P_FILE TYPE STRING DEFAULT ‘D:\BPM_999.xml‘ NO-DISPLAY."RLGRAP-FILENAME.C:

\Users\ThinkPad\Desktop\生成文件\xml\BPM_999.xml
PARAMETERS:P_SFILE LIKE RLGRAP-FILENAME DEFAULT ‘/aspic/job/in/‘ MODIF ID PF,

"‘/tmp/job/in/‘, "
P_SFILE1 TYPE RLGRAP-FILENAME DEFAULT ‘/aspic/job/return/‘ MODIF ID

PF,"‘/tmp/job/return/‘.
P_SFILE2 TYPE RLGRAP-FILENAME DEFAULT ‘/aspic/job/return_history/‘ MODIF ID

PF."‘/tmp/job/return/‘.
SELECTION-SCREEN END OF BLOCK BLK2.

*AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
*& 选择文件F4
* PERFORM FRM_FILE_OPEN_DIALOG CHANGING P_FILE.

INITIALIZATION.

AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-GROUP1 EQ ‘PF‘.
"screen-active = 0.
SCREEN-INPUT = 0.
ENDIF.

MODIFY SCREEN.
ENDLOOP.

AT SELECTION-SCREEN.

START-OF-SELECTION.
*&查询
PERFORM FRM_GET_DATA.

PERFORM FRM_ALV_DISPLAY.

END-OF-SELECTION.

*&---------------------------------------------------------------------*
*& Form FRM_FILE_OPEN_DIALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_P_FILE text
*----------------------------------------------------------------------*
FORM FRM_FILE_OPEN_DIALOG CHANGING P_FILE TYPE STRING.

DATA: LT_FILE TYPE TABLE OF FILE_TABLE,
LS_FILE TYPE FILE_TABLE.
DATA: LV_RC TYPE I,
LV_TITLE TYPE STRING.

LV_TITLE = SY-TITLE.

*& 文件的F4
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = LV_TITLE
FILE_FILTER = CL_GUI_FRONTEND_SERVICES=>FILETYPE_EXCEL
CHANGING
FILE_TABLE = LT_FILE
RC = LV_RC
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
*--open file failed, show error message
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
*--open file successful, get file name
READ TABLE LT_FILE INTO LS_FILE INDEX 1.
IF SY-SUBRC = 0 .
P_FILE = LS_FILE-FILENAME.
ENDIF.
ENDIF.

ENDFORM. " FRM_FILE_OPEN_DIALOG

*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA .
DATA:LT_LINE LIKE STANDARD TABLE OF TLINE,
LWA_LINE LIKE LINE OF LT_LINE,
LV_NAME LIKE THEAD-TDNAME,
L_JHTXT TYPE STRING.
*C~YUNSW

*&取数据:
SELECT A~EBELN
A~LIFNR
A~WAERS
A~STCEG
B~EBELP
B~MATNR
B~MENGE
B~NETPR
B~BRTWR AS KZWI
C~NAME1
C~TELF1
C~TELFX
C~NAME2
C~SPERZ
C~ADRNR

INTO CORRESPONDING FIELDS OF TABLE GT_PO
FROM EKKO AS A
JOIN EKPO AS B
ON A~EBELN EQ B~EBELN
JOIN LFA1 AS C
ON A~LIFNR EQ C~LIFNR
WHERE A~EBELN IN S_EBELN
AND A~BSART IN S_BSART
AND A~EKORG IN S_EKORG
AND A~EKGRP IN S_EKGRP
AND B~WERKS IN S_WERKS
AND B~MATNR IN S_MATNR.

G_LEN = LINES( GT_PO[] ).
IF G_LEN EQ 0.
MESSAGE S001 WITH ‘找不到数据!‘.
ENDIF.

SORT GT_PO BY EBELN EBELP.
LOOP AT GT_PO.
GT_PO-LIN = SY-TABIX.
* GT_PO-TEXT = ‘PO head text‘.
* GT_PO-TEXTL = ‘PO_item text‘.

CLEAR LV_NAME.
MOVE GT_PO-EBELN TO LV_NAME.
CALL FUNCTION ‘READ_TEXT‘
EXPORTING
CLIENT = SY-MANDT
ID = ‘F01‘
LANGUAGE = SY-LANGU
NAME = LV_NAME "GT_PO-EBELN
OBJECT = ‘EKKO‘
TABLES
LINES = LT_LINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.

LOOP AT LT_LINE INTO LWA_LINE.
SHIFT LWA_LINE-TDLINE LEFT DELETING LEADING ‘‘.
CONCATENATE LWA_LINE-TDLINE L_JHTXT INTO GT_PO-TEXT."l_jhtxt.
ENDLOOP.
IF GT_PO-TEXT IS INITIAL.
GT_PO-TEXT = ‘抬头无备注‘.
ENDIF.

CLEAR LV_NAME.
CONCATENATE GT_PO-EBELN GT_PO-EBELP INTO LV_NAME.

CALL FUNCTION ‘READ_TEXT‘
EXPORTING
CLIENT = SY-MANDT
ID = ‘F02‘
LANGUAGE = SY-LANGU
NAME = LV_NAME
OBJECT = ‘EKPO‘
TABLES
LINES = LT_LINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.

LOOP AT LT_LINE INTO LWA_LINE.
SHIFT LWA_LINE-TDLINE LEFT DELETING LEADING ‘‘.
CONCATENATE LWA_LINE-TDLINE L_JHTXT INTO GT_PO-TEXTL.
ENDLOOP.
IF GT_PO-TEXTL IS INITIAL.
GT_PO-TEXTL = ‘项目无备注‘.
ENDIF.

GT_PO-YUNSW = ‘物流确认‘.

*&取物料描述
SELECT SINGLE MAKTX
INTO GT_PO-MAKTX
FROM MAKT
WHERE MATNR EQ GT_PO-MATNR.
*&取物料单位
SELECT SINGLE MEINS
INTO GT_PO-MEINS
FROM MARA
WHERE MATNR EQ GT_PO-MATNR.
*&取预定交期
SELECT SINGLE SLFDT
INTO GT_PO-SLFDT
FROM EKET
WHERE EBELN EQ GT_PO-EBELN
AND EBELP EQ GT_PO-EBELP.
MODIFY GT_PO.
CLEAR GT_PO.

* MOVE-CORRESPONDING GT_PO TO IT_HEAD.
* COLLECT IT_HEAD.
ENDLOOP.

* LOOP AT GT_PO.
* ENDLOOP.

ENDFORM. " FRM_GET_DATA
*&---------------------------------------------------------------------*
*& Form FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_ALV_DISPLAY .
* PERFORM FRM_BUILD_FIELDCAT.
DATA: L_NN TYPE I.

DEFINE ADD_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = &1.
WA_FIELDCAT-SELTEXT_L = &2.
WA_FIELDCAT-KEY = &3.
WA_FIELDCAT-COL_POS = L_NN + 1.
WA_FIELDCAT-JUST = &4.
WA_FIELDCAT-OUTPUTLEN = &5.
WA_FIELDCAT-FIX_COLUMN = &6.
WA_FIELDCAT-NO_ZERO = &7.
WA_FIELDCAT-EDIT = &8.
APPEND WA_FIELDCAT TO GT_FIELDCAT.
END-OF-DEFINITION.

CLEAR GT_FIELDCAT.
REFRESH GT_FIELDCAT.

* ADD_FIELDCAT ‘LIN‘ ‘序号‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.

ADD_FIELDCAT ‘EBELN‘ ‘采购订单‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘LIFNR‘ ‘廠商編號‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘WAERS‘ ‘交易幣別‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘STCEG‘ ‘交易税别‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.

ADD_FIELDCAT ‘EBELP‘ ‘项目号‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘MATNR‘ ‘材料编号‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘MENGE‘ ‘訂購數量‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘NETPR‘ ‘单价‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘KZWI ‘ ‘金额‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘SLFDT‘ ‘预定交期‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘NAME1‘ ‘廠商簡稱‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘TELF1‘ ‘公司電話‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘TELFX‘ ‘公司傳真‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘NAME2‘ ‘聯絡人‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘SPERZ‘ ‘付款方式‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘ADRNR‘ ‘联系地址‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘YUNSW‘ ‘运送方式‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘TEXT‘ ‘抬头備註‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘MAKTX‘ ‘材料规格‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘MEINS‘ ‘单位‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
ADD_FIELDCAT ‘TEXTL‘ ‘项目备注‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.

GW_LAYOUT-COLWIDTH_OPTIMIZE = ‘X‘.
GW_LAYOUT-BOX_FIELDNAME = ‘SEL‘.

*&ALV输出
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY‘
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_GRID_TITLE = LV_TITLE
I_CALLBACK_PF_STATUS_SET = ‘FRM_PF_STATUS‘
I_CALLBACK_USER_COMMAND = ‘FRM_USER_COMMAND‘
IS_LAYOUT = GW_LAYOUT
IT_FIELDCAT = GT_FIELDCAT
I_SAVE = ‘A‘
TABLES
T_OUTTAB = GT_PO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.

ENDFORM. " FRM_ALV_DISPLAY
*&--------------------------------------------------------------------*
*& 界面的功能按钮定义
*&--------------------------------------------------------------------*
FORM FRM_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.

SET PF-STATUS ‘STANDARD‘ EXCLUDING EXTAB.

ENDFORM. "SET_PF_STATUS
*&---------------------------------------------------------------------*
*& Form FRM_USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM FRM_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.

DATA: LT_SORT TYPE SLIS_T_SORTINFO_ALV,
LS_SORT TYPE LINE OF SLIS_T_SORTINFO_ALV.

BREAK RAINY.

CASE R_UCOMM.
WHEN ‘&XML_01‘.
PERFORM FRM_GET_XML.

WHEN ‘&XML_02‘.
PERFORM FRM_READ_XML.

WHEN OTHERS.
ENDCASE.
ENDFORM. "FRM_USER_COMMAND
*&---------------------------------------------------------------------*
*& Form FRM_GET_XML
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_XML .
LOOP AT GT_PO.
WA_HEAD-ID = ‘7592a0425357413ca5e12e896f1cb841‘.
WA_HEAD-APP = ‘admin‘.
WA_HEAD-START = ‘0‘.
WA_HEAD-FINISH = ‘72‘.
WA_HEAD-DATE = ‘1‘.

WA_HEAD-LIFN1 = ‘field1‘.
WA_HEAD-LIFN2 = ‘LIFNR‘.
WA_HEAD-LIFN3 = ‘SAP廠商編號‘.
WA_HEAD-NAM1 = ‘field3‘.
WA_HEAD-NAM2 = ‘NAME1‘.
WA_HEAD-NAM3 = ‘廠商簡稱‘.
WA_HEAD-EBEL1 = ‘field6‘.
WA_HEAD-EBEL2 = ‘EBELN‘.
WA_HEAD-EBEL3 = ‘SAP-PO‘.

WA_HEAD-TEL1 = ‘field5‘.
WA_HEAD-TEL2 = ‘TELF1‘.
WA_HEAD-TEL3 = ‘公司電話‘.
WA_HEAD-TEF1 = ‘field7‘.
WA_HEAD-TEF2 = ‘TELFX‘.
WA_HEAD-TEF3 = ‘公司傳真‘.
WA_HEAD-NAM6 = ‘field8‘.
WA_HEAD-NAM7 = ‘NAME2‘.
WA_HEAD-NAM8 = ‘聯絡人‘.

WA_HEAD-WAER1 = ‘field9‘.
WA_HEAD-WAER2 = ‘WAERS‘.
WA_HEAD-WAER3 = ‘交易幣別‘.
WA_HEAD-SPER1 = ‘field10‘.
WA_HEAD-SPER2 = ‘SPER3‘.
WA_HEAD-SPER3 = ‘付款方式‘.
WA_HEAD-STCE1 = ‘field11‘.
WA_HEAD-STCE2 = ‘STCEG‘.
WA_HEAD-STCE3 = ‘交易稅別‘.

WA_HEAD-YUNS1 = ‘field12‘.
WA_HEAD-YUNS2 = ‘YUNSW‘.
WA_HEAD-YUNS3 = ‘運送方式‘.
WA_HEAD-ADRN1 = ‘field13‘.
WA_HEAD-ADRN2 = ‘ADRNR‘.
WA_HEAD-ADRN3 = ‘聯繫地址‘.
WA_HEAD-TEXT1 = ‘field14‘.
WA_HEAD-TEXT2 = ‘TEXT‘.
WA_HEAD-TEXT3 = ‘備註‘.

WA_HEAD-FJIAN1 = ‘field16‘.
WA_HEAD-FJIAN2 = ‘string‘.
WA_HEAD-FJIAN3 = ‘附件‘.
WA_HEAD-FJIAN4 = ‘www.sap.com.‘.
MOVE-CORRESPONDING GT_PO TO WA_HEAD.
COLLECT WA_HEAD INTO ST_HEAD.

WA_LINE-EBEL1 = ‘field68‘.
WA_LINE-EBEL2 = ‘EBELP‘.
WA_LINE-EBEL3 = ‘项目‘.
WA_LINE-MATN1 = ‘field1‘.
WA_LINE-MATN2 = ‘MATNR‘.
WA_LINE-MATN3 = ‘材料編碼‘.
WA_LINE-MAKT1 = ‘field2‘.
WA_LINE-MAKT2 = ‘MAKTX‘.
WA_LINE-MAKT3 = ‘材料規格‘.

WA_LINE-MEIN1 = ‘field3‘.
WA_LINE-MEIN2 = ‘MEINS‘.
WA_LINE-MEIN3 = ‘單位‘.
WA_LINE-MENG1 = ‘field4‘.
WA_LINE-MENG2 = ‘MENGE‘.
WA_LINE-MENG3 = ‘訂購數量‘.
WA_LINE-NETP1 = ‘field5‘.
WA_LINE-NETP2 = ‘NETPR‘.
WA_LINE-NETP3 = ‘单价‘.

WA_LINE-KZWI1 = ‘field6‘.
WA_LINE-KZWI2 = ‘KZWI‘.
WA_LINE-KZWI3 = ‘金额‘.
WA_LINE-PLIF1 = ‘field7‘.
WA_LINE-PLIF2 = ‘SLFDT‘.
WA_LINE-PLIF3 = ‘預定交期‘.
WA_LINE-TET1 =‘field8‘.
WA_LINE-TET2 =‘TEXTL‘.
WA_LINE-TET3 =‘项目備註‘.

MOVE-CORRESPONDING GT_PO TO WA_LINE.
APPEND WA_LINE TO ST_LINE.
ENDLOOP.

BREAK RAINY.
*&call transformation to xml
CALL TRANSFORMATION ZMM3
SOURCE CPEL = ST_HEAD "ITAB_MATNR
ET-DATA-LIST = ST_LINE"ITAB_CLASS
RESULT XML W_XML.

* REPLACE FIRST OCCURRENCE OF ‘encoding=”utf-16″‘ IN G_XML WITH ‘encoding=”utf-8″

‘.
* APPEND IT_XML.
*REPLACE FIRST OCCURRENCE OF ‘encoding="utf-16"‘ IN W_XML WITH ‘encoding="utf-8"‘.

*&xml string to it_XML
CALL FUNCTION ‘SCMS_STRING_TO_FTEXT‘
EXPORTING
TEXT = W_XML
IMPORTING
LENGTH = W_LEN
TABLES
FTEXT_TAB = IT_XML.
*&1.DOWNloan local.
CALL FUNCTION ‘GUI_DOWNLOAD‘
EXPORTING
FILENAME = P_FILE
FILETYPE = ‘BIN‘
IMPORTING
FILELENGTH = W_LEN
TABLES
DATA_TAB = IT_XML.

*&2.上传服务器
* CONCATENATE P_SFILE SY-DATUM ‘corepress20140701.xml‘ INTO S_SFILE.
CONCATENATE P_SFILE ‘corepress20140701.xml‘ INTO S_SFILE.
OPEN DATASET S_SFILE FOR OUTPUT IN BINARY MODE.
IF SY-SUBRC EQ 0.
TRANSFER W_XML TO S_SFILE. " LENGTH W_SIZE."W_STRING
CLOSE DATASET S_SFILE.
IF SY-SUBRC EQ 0.

"revised by ronnie 2014-07-17
*&更新PO 审核标记
PERFORM FRM_UPDATE_SIGN_A1.
************************************

MESSAGE S001 WITH ‘文件处理成功!‘.
ENDIF.
ELSE.
MESSAGE ‘OPEN ERROR!‘ TYPE ‘E‘.
STOP.
ENDIF.

*&ADD1.for test
* CONCATENATE P_SFILE1 ‘corepress20140701.xml‘ INTO S_SFILE.
* OPEN DATASET S_SFILE FOR OUTPUT IN BINARY MODE.
* IF SY-SUBRC EQ 0.
* TRANSFER W_XML TO S_SFILE. " LENGTH W_SIZE."W_STRING
* CLOSE DATASET S_SFILE.
* IF SY-SUBRC EQ 0.
* MESSAGE S001 WITH ‘文件处理成功!‘.
* ENDIF.
* ELSE.
* MESSAGE ‘OPEN ERROR!‘ TYPE ‘E‘.
* STOP.
* ENDIF.

ENDFORM. " FRM_GET_XML
*&---------------------------------------------------------------------*
*& Form FRM_READ_XML
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_READ_XML .
DATA:DSET TYPE STRING,
SUBRC LIKE SY-SUBRC,
LENG TYPE I,
FSIZE TYPE I VALUE 0,
* BUF TYPE C LENGTH 3000,
BUF TYPE XSTRING,"C LENGTH 3000,
TBLOB LIKE TABLE OF BUF.

DATA:XMLDATA TYPE XSTRING,
RESULT_XML TYPE STANDARD TABLE OF SMUM_XMLTB,
RETURN TYPE STANDARD TABLE OF BAPIRET2,
WA_XML TYPE SMUM_XMLTB.
DATA:LV_COMMAND(200) TYPE C.
DATA:BEGIN OF TABL OCCURS 0,
LINE(200),
END OF TABL.
DATA:LV_ORG_FILE TYPE STRING,
LV_ERR_FILE TYPE STRING.

CLEAR:ST_HEAD,
ST_LINE,
GT_PO, GT_PO[].
REFRESH GT_PO.

*&从服务器读取文件
CONCATENATE P_SFILE1 ‘corepress20140701_return.xml‘ INTO DSET .

OPEN DATASET DSET FOR INPUT IN BINARY MODE.
IF SY-SUBRC <> 0.
MESSAGE ‘Error: open dataset.‘ TYPE ‘S‘.
EXIT.
ENDIF.
CONCATENATE P_SFILE1 ‘corepress20140701_return.xml‘ INTO LV_ORG_FILE.
CONCATENATE P_SFILE2 SY-DATUM SY-UZEIT‘corepress20140701.xml‘ INTO LV_ERR_FILE.

WHILE SUBRC = 0.
* LENG = 0.
READ DATASET DSET INTO BUF ACTUAL LENGTH LENG.
IF BUF IS NOT INITIAL.
XMLDATA = BUF.
ENDIF.
SUBRC = SY-SUBRC.
CHECK LENG > 0.
FSIZE = FSIZE + LENG.
APPEND BUF TO TBLOB.
ENDWHILE.

*&ADD2.
*&move the file to bak directory
CONCATENATE ‘mv‘
LV_ORG_FILE
LV_ERR_FILE
INTO LV_COMMAND
SEPARATED BY SPACE.

CALL ‘SYSTEM‘ ID ‘COMMAND‘ FIELD LV_COMMAND
ID ‘TAB‘ FIELD TABL-*SYS*."LT_TABL.
CLOSE DATASET DSET.

*&Change.
*将 XML->inner table(table->XML)
CALL TRANSFORMATION ZMM4
SOURCE XML XMLDATA "BUF
RESULT CPEL = ST_HEAD
ET-DATA-LIST = ST_LINE

SIGN-STATE = ST_SIGN1
SIGN-LIST = ST_SIGN.
*&Change to
* CALL TRANSFORMATION ZMM3_1
* SOURCE XML XMLDATA "BUF
* RESULT CPEL = ST_HEAD
* ET-DATA-LIST = ST_LINE
* RESULT_LIST = ST_SIGN.
BREAK TEST_13.

READ TABLE ST_SIGN1 INTO WS_SIGN1 INDEX 1.

IF SY-SUBRC = 0 AND WS_SIGN1-OK_K = ‘OK‘.
LOOP AT ST_HEAD INTO WA_HEAD.
MOVE-CORRESPONDING WA_HEAD TO GT_PO.
LOOP AT ST_LINE INTO WA_LINE.
MOVE-CORRESPONDING WA_LINE TO GT_PO.
APPEND GT_PO.
ENDLOOP.
ENDLOOP.

* PERFORM FRM_ALV_DISPLAY.
*&更新PO 审核标记
PERFORM FRM_UPDATE_SIGN.

ELSE.

BREAK SHUAI.
READ TABLE ST_HEAD INTO WA_HEAD INDEX 1.
"取消第一次的审核通过状态
PERFORM FRM_UPDATE_SIGN2.

ENDIF.
ENDFORM. " FRM_READ_XML
*&---------------------------------------------------------------------*
*& Form FRM_UPDATE_SIGN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_UPDATE_SIGN .
DATA:REL_CODE TYPE FRGCO,
GC_NEW_STATUS LIKE BAPIMMPARA-REL_STATUS,
GC_INDICATOR_NEW LIKE BAPIMMPARA-PO_REL_IND,
GT_LOG LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

LOOP AT GT_PO.
AT NEW EBELN.

CALL FUNCTION ‘BAPI_PO_RELEASE‘
EXPORTING
PURCHASEORDER = GT_PO-EBELN
PO_REL_CODE = ‘A2‘"REL_CODE
USE_EXCEPTIONS = ‘X‘
* no_commit =
IMPORTING
REL_STATUS_NEW = GC_NEW_STATUS
REL_INDICATOR_NEW = GC_INDICATOR_NEW
* ret_code =
TABLES
RETURN = GT_LOG.

IF SY-SUBRC EQ 0.
MESSAGE S003 WITH ‘采购订单‘ GT_PO-EBELN ‘审核成功!‘.
ENDIF.
* CALL FUNCTION ‘BAPI_PO_RELEASE‘
* EXPORTING
* PURCHASEORDER =
* PO_REL_CODE =
** USE_EXCEPTIONS = ‘X‘
** NO_COMMIT = ‘ ‘
** IMPORTING
** REL_STATUS_NEW =
** REL_INDICATOR_NEW =
** RET_CODE =
** TABLES
** RETURN =
** EXCEPTIONS
** AUTHORITY_CHECK_FAIL = 1
** DOCUMENT_NOT_FOUND = 2
** ENQUEUE_FAIL = 3
** PREREQUISITE_FAIL = 4
** RELEASE_ALREADY_POSTED = 5
** RESPONSIBILITY_FAIL = 6
** OTHERS = 7
* IF SY-SUBRC <> 0.
** Implement suitable error handling here
* ENDIF.

ENDAT.

ENDLOOP.

ENDFORM. " FRM_UPDATE_SIGN
*&---------------------------------------------------------------------*
*& Form FRM_UPDATE_SIGN_A1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_UPDATE_SIGN_A1 .
DATA:REL_CODE TYPE FRGCO,
GC_NEW_STATUS LIKE BAPIMMPARA-REL_STATUS,
GC_INDICATOR_NEW LIKE BAPIMMPARA-PO_REL_IND,
GT_LOG LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

LOOP AT GT_PO.
AT NEW EBELN.

CALL FUNCTION ‘BAPI_PO_RELEASE‘
EXPORTING
PURCHASEORDER = GT_PO-EBELN
PO_REL_CODE = ‘A1‘
USE_EXCEPTIONS = ‘X‘
* no_commit =
IMPORTING
REL_STATUS_NEW = GC_NEW_STATUS
REL_INDICATOR_NEW = GC_INDICATOR_NEW
* ret_code =
TABLES
RETURN = GT_LOG.

IF SY-SUBRC EQ 0.
MESSAGE S003 WITH ‘采购订单‘ GT_PO-EBELN ‘审核成功!‘.
**************************************************************************************
* "revised by ronnie 2014-07-17
* else.
"关于取消已经审核的订单
* CALL FUNCTION ‘BAPI_PO_RESET_RELEASE‘
* EXPORTING
* purchaseorder = GT_PO-EBELN
* po_rel_code = ‘A1‘
* USE_EXCEPTIONS = ‘X‘
** IMPORTING
** REL_STATUS_NEW =
** REL_INDICATOR_NEW =
** TABLES
** RETURN =
* EXCEPTIONS
* AUTHORITY_CHECK_FAIL = 1
* DOCUMENT_NOT_FOUND = 2
* ENQUEUE_FAIL = 3
* PREREQUISITE_FAIL = 4
* RELEASE_ALREADY_POSTED = 5
* RESPONSIBILITY_FAIL = 6
* NO_RELEASE_ALREADY = 7
* NO_NEW_RELEASE_INDICATOR = 8
* OTHERS = 9
* .
* IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ELSE.
* MESSAGE s006 with ‘采购订单‘ GT_PO-EBELN‘取消审批成功!‘.
* ENDIF.

*************************************************************************
ENDIF.

* CALL FUNCTION ‘BAPI_PO_RELEASE‘
* EXPORTING
* PURCHASEORDER =
* PO_REL_CODE =
** USE_EXCEPTIONS = ‘X‘
** NO_COMMIT = ‘ ‘
** IMPORTING
** REL_STATUS_NEW =
** REL_INDICATOR_NEW =
** RET_CODE =
** TABLES
** RETURN =
** EXCEPTIONS
** AUTHORITY_CHECK_FAIL = 1
** DOCUMENT_NOT_FOUND = 2
** ENQUEUE_FAIL = 3
** PREREQUISITE_FAIL = 4
** RELEASE_ALREADY_POSTED = 5
** RESPONSIBILITY_FAIL = 6
** OTHERS = 7
* IF SY-SUBRC <> 0.
** Implement suitable error handling here
* ENDIF.

ENDAT.

ENDLOOP.

ENDFORM. " FRM_UPDATE_SIGN_A1
*&---------------------------------------------------------------------*
*& Form FRM_UPDATE_SIGN2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_UPDATE_SIGN2 .
" 关于取消已经审核的订单
CALL FUNCTION ‘BAPI_PO_RESET_RELEASE‘
EXPORTING
PURCHASEORDER = WA_HEAD-EBELN
PO_REL_CODE = ‘A1‘
USE_EXCEPTIONS = ‘X‘
* IMPORTING
* REL_STATUS_NEW =
* REL_INDICATOR_NEW =
* TABLES
* RETURN =
EXCEPTIONS
AUTHORITY_CHECK_FAIL = 1
DOCUMENT_NOT_FOUND = 2
ENQUEUE_FAIL = 3
PREREQUISITE_FAIL = 4
RELEASE_ALREADY_POSTED = 5
RESPONSIBILITY_FAIL = 6
NO_RELEASE_ALREADY = 7
NO_NEW_RELEASE_INDICATOR = 8
OTHERS = 9
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
MESSAGE S006 WITH ‘采购订单‘ WA_HEAD-EBELN ‘最终审批未通过!‘.
ENDIF.
ENDFORM. " FRM_UPDATE_SIGN2

时间: 2024-10-11 04:32:43

YMMI001-采购单审批的相关文章

Java设计模式之责任链设计模式

职责链模式(Chain of Responsibility):使多个对象都有机会处理请求,从而避免请求的发送者和接收者之间的耦合关系,将所有处理对象连成一条链,并沿着这条链传递请求,直到有一个对象处理它为止. ? 请求传递方向:从低级到高级 ? 重点:如何形成这个责任链 ? 特点:发出处理请求的客户端并不知道是系统当中的哪一个对象最终处理这个请求,这样系统的更改可以在不影响客户端的情况下动态地重新组织和分配责任.1. 派生类中都具备的功能(1) 都要设置后继者(一样)(2) 都能实现自己职责范围

行为型模式之职责链模式

概述 很多情况下,在一个软件系统中可以处理某个请求的对象不止一个,例如SCM系统中的采购单审批,主任.副董事长.董事长和董事会都可以处理采购单,他们可以构成一条处理采购单的链式结构,采购单沿着这条链进行传递,这条链就称为职责链.职责链可以是一条直线.一个环或者一个树形结构,最常见的职责链是直线型,即沿着一条单向的链来传递请求.链上的每一个对象都是请求处理者,职责链模式可以将请求的处理者组织成一条链,并让请求沿着链传递,由链上的处理者对请求进行相应的处理,客户端无须关心请求的处理细节以及请求的传递

责任链模式综述(基础篇)

摘要: 本篇综述责任链模式的提出动机.原理结构.典型实现和应用场景,并结合具体实例展现了其灵活性.可插拔性和松耦合性.首先,结合我们日常生活中"打扑克"的例子引出了责任链模式产生动机,并揭示了其应用场景.紧接着,我们概述了责任链模式的内涵和结构,即通过建立一条责任链来组织请求的处理者,请求将沿着链进行传递,而请求发送者无须知道请求在何时.何处以及如何被处理,实现了请求发送者与处理者的解耦.此外,本文给出了责任链模式的典型实现和并结合具体实例介绍其使用方式,以便我们更好体会其优点. 版权

chain pattern

16.4 纯与不纯的职责链模式 职责链模式可分为纯的职责链模式和不纯的职责链模式两种:        (1) 纯的职责链模式 一个纯的职责链模式要求一个具体处理者对象只能在两个行为中选择一个:要么承担全部责任,要么将责任推给下家,不允许出现某一个具体处理者对象在承担了一部分或全部责任后又将责任向下传递的情况.而且在纯的职责链模式中,要求一个请求必须被某一个处理者对象所接收,不能出现某个请求未被任何一个处理者对象处理的情况.在前面的采购单审批实例中应用的是纯的职责链模式.        (2)不纯

java设计模式之职责链模式

[学习难度:★★★☆☆,使用频率:★★☆☆☆] "一对二","过","过"--这声音熟悉吗?你会想到什么?对!纸牌.在类似"斗地主"这样的纸牌游戏中,某人出牌给他的下家,下家看看手中的牌,如果要不起上家的牌则将出牌请求再转发给他的下家,其下家再进行判断.一个循环下来,如果其他人都要不起该牌,则最初的出牌者可以打出新的牌.在这个过程中,牌作为一个请求沿着一条链在传递,每一位纸牌的玩家都可以处理该请求.在设计模式中,我们也有一种专

责任链模式(chainOfResponsibility)

参考文章:http://wiki.jikexueyuan.com/project/design-pattern-behavior/chain-four.html 定义: 使多个对象都有机会处理请求,从而避免请求的发送者和接收者之间的耦合关系.将这些对象连成一条链,并沿着这条链传递该请求,直到有一个对象处理它为止. 分类: 纯的职责链模式 一个纯的职责链模式要求一个具体处理者对象只能在两个行为中选择一个:要么承担全部责任,要么将责任推给下家,不允许出现某一个具体处理者对象在承担了一部分或全部责任后

设计模式-行为型-职责链设计模式

一.简介 职责链设计模式是属于经典设计模式中行为型设计模式里的一种设计模式.其实这种模式 在现实生活中很多地方出现,比如说: 1.多人打牌: 上家出牌后,出牌请求到达下家,下家出牌后,下下家获得出牌机会, 在一轮后如果无人出牌,则可以从 新下一轮出牌,这样一个场景,其实就是职责链模式的原型. 2.审批流程: 再比如,一个公司的采购单审批流程,如果采购单总价在5万RMB,那么主任审核即可, 如果5-10万RMB 由副董事长审批,10-50万由董事长审批,>=50万则由董事会审批.每一个节点只负责职

AP_标准采购单付基本操作(流程)

2014-06-04 BaoXinjian 一.汇总 1. 建立请购单,并进行审批 2. 根据请购单建立采购单,并进行审批 采购1.接收2.入库3.发票4 (1). 2-way: 采购-->AP发票创建 (2). 3-way: 采购-->接收-->AP发票创建 (3). 4-way: 采购-->接收-->入库-->AP发票创建 3. 对采购单进行接收 4. 接收后做入库操作 5. 在应付模块中建立应付发票,绑定采购单 6. 验证发票后建立会计科目 7. 对发票进行付款

PO_PO系列 - 采购单管理分析(案例)

2014-07-01 BaoXinjian 一.摘要 PO采购单的类型 1. 标准采购业务 •业务背景: 标准采购业务的发生一般是,公司采购部门的采购员根据业务部门领导签字的请购单, 或者是已接受供应商报价的报价单,填写采购单,交部门领导审批,或更高层领导审批, 领导审批后,采购员即可通知供应商根据约定进行供货. 2. 一揽子采购业务 •业务背景: 一揽子采购业务的发生一般是,公司采购部门与供应商签订一个一揽子采购协议, 即在向该供应商进行采购时,由于采购量的变化,供应商可以根据实际的情况给与公