***********************************************************************
* 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