一个简单的内部调用BAPI实例

原创 2007年09月30日 13:58:00
REPORT  ztestusebapi.

*&---------------------------------------------------------------------*
*DATA DECLARATION.
*&---------------------------------------------------------------------*
TABLES bapimepoheader.

CONSTANTS : c_x VALUE 'X'.

DATA wa_poheader TYPE bapimepoheader.
DATA wa_poheaderx TYPE bapimepoheaderx.

DATA wa_poitem TYPE bapimepoitem.
DATA itab_poitem LIKE TABLE OF wa_poitem.
DATA wa_poitemx TYPE bapimepoitemx.
DATA itab_poitemx LIKE TABLE OF wa_poitemx.
DATA wa_return TYPE bapiret2.
DATA itab_return LIKE TABLE OF wa_return.


*&---------------------------------------------------------------------*
*parameters
*&---------------------------------------------------------------------*.
*head
PARAMETERS :p_poty LIKE bapimepoheader-doc_type DEFAULT 'ZPO1',
            p_ponm LIKE bapimepoheader-po_number,
            p_vendor LIKE bapimepoheader-vendor DEFAULT 'Y200707',
            p_poorg LIKE bapimepoheader-purch_org DEFAULT 'CN01',
            p_pogrp LIKE bapimepoheader-pur_group DEFAULT 'KXX',
            p_comcd LIKE bapimepoheader-comp_code DEFAULT 'CN01'.

*Item
PARAMETERS :p_poitem LIKE bapimepoitem-po_item DEFAULT 1,
p_matnr LIKE bapimepoitem-material DEFAULT 'FWA-3600',
p_plant LIKE bapimepoitem-plant DEFAULT 'CKB3',
p_lgort LIKE bapimepoitem-stge_loc DEFAULT '0021',
p_qty LIKE bapimepoitem-quantity DEFAULT 3.

*&---------------------------------------------------------------------*
*START-OF-SELECTION.
*&---------------------------------------------------------------------*
START-OF-SELECTION.


*&---------------------------------------------------------------------*
*PO HEADER DATA.
*&---------------------------------------------------------------------*

  wa_poheader-po_number = p_ponm.
  wa_poheader-comp_code = p_comcd.
  wa_poheader-doc_type = p_poty.
  wa_poheader-vendor = p_vendor.      "1 供应商,普通PO,和下面2二选一
*wa_poheader-SUPPL_PLNT = p_vendor. "2 供货工厂,STO
  wa_poheader-purch_org = p_poorg.
  wa_poheader-pur_group = p_pogrp.

*&---------------------------------------------------------------------*
*PO HEADER FLAG.
*&---------------------------------------------------------------------*

  wa_poheaderx-po_number = c_x.
  wa_poheaderx-comp_code = c_x.
  wa_poheaderx-doc_type = c_x.
  wa_poheaderx-vendor = c_x.        "1 供应商,普通PO,和下面2二选一
*wa_poheaderx-SUPPL_PLNT = c_X.   "2 供货工厂,STO
  wa_poheaderx-purch_org = c_x.
  wa_poheaderx-pur_group = c_x.

*&---------------------------------------------------------------------*
*PO ITEM DATA.
*&---------------------------------------------------------------------*
  wa_poitem-po_item = p_poitem.
  wa_poitem-material = p_matnr.
  wa_poitem-plant = p_plant.
  wa_poitem-stge_loc = p_lgort.
  wa_poitem-quantity = p_qty.
  wa_poitem-preq_name = 'xj'.
  APPEND wa_poitem TO itab_poitem.

*&---------------------------------------------------------------------*
*PO ITEM FLAG.
*&---------------------------------------------------------------------*
  wa_poitemx-po_item = p_poitem.
  wa_poitemx-material = c_x.
  wa_poitemx-plant = c_x.
  wa_poitemx-stge_loc = c_x.
  wa_poitemx-quantity = c_x.
  wa_poitemx-preq_name = c_x.
  APPEND wa_poitemx TO itab_poitemx.

*&---------------------------------------------------------------------*
*CALL BAPI
*&---------------------------------------------------------------------*

  CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
      poheader                     = wa_poheader
      poheaderx                    = wa_poheaderx
*   POADDRVENDOR                 =
*   TESTRUN                      =
*   MEMORY_UNCOMPLETE            =
*   MEMORY_COMPLETE              =
*   POEXPIMPHEADER               =
*   POEXPIMPHEADERX              =
*   VERSIONS                     =
*   NO_MESSAGING                 =
*   NO_MESSAGE_REQ               =
*   NO_AUTHORITY                 =
*   NO_PRICE_FROM_PO             =
* IMPORTING
*   EXPPURCHASEORDER             =
*   EXPHEADER                    =
*   EXPPOEXPIMPHEADER            =
   TABLES
      return                       = itab_return
      poitem                       = itab_poitem
      poitemx                      = itab_poitemx
*   POADDRDELIVERY               =
*   POSCHEDULE                   =
*   POSCHEDULEX                  =
*   POACCOUNT                    =
*   POACCOUNTPROFITSEGMENT       =
*   POACCOUNTX                   =
*   POCONDHEADER                 =
*   POCONDHEADERX                =
*   POCOND                       =
*   POCONDX                      =
*   POLIMITS                     =
*   POCONTRACTLIMITS             =
*   POSERVICES                   =
*   POSRVACCESSVALUES            =
*   POSERVICESTEXT               =
*   EXTENSIONIN                  =
*   EXTENSIONOUT                 =
*   POEXPIMPITEM                 =
*   POEXPIMPITEMX                =
*   POTEXTHEADER                 =
*   POTEXTITEM                   =
*   ALLVERSIONS                  =
*   POPARTNER                    =
            .
  DATA error_log TYPE c.
  LOOP AT itab_return INTO wa_return.
    IF wa_return-type = 'E'.
      error_log = 'X'.
      EXIT.
    ENDIF.
    CLEAR wa_return.
  ENDLOOP.

  IF error_log = 'X'.

    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
* IMPORTING
*   RETURN        =
    .

    WRITE '有错误存在,不能生成PO'.
    LOOP AT itab_return INTO wa_return.
      WRITE: / wa_return-type,wa_return-message.
      CLEAR wa_return.
    ENDLOOP.

  ELSE.

*奇怪,未Commit已经提交了,似乎下面的是多余的.

*&---------------------------------------------------------------------*
*Confirm the document creation by calling database COMMIT
*&---------------------------------------------------------------------*

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
     EXPORTING
       wait          = 'X'
* IMPORTING
*   RETURN        =
              .

    LOOP AT itab_return INTO wa_return.
      WRITE: / wa_return-type,wa_return-message.
      CLEAR wa_return.
    ENDLOOP.


  ENDIF.

实用BAPI做内部调拨

  • 2014年03月02日 16:32
  • 15KB
  • 下载

VS内部可用的一个简单翻译软件

  • 2017年04月21日 17:52
  • 745KB
  • 下载

JS调用OC简单实例-传递一个或者多个参数给oc方法

// // ViewController.m // JSCallsOC // // Created by hq on 16/4/19. // Copyright © 2016年 hanqing...

生成内部订单BAPI

事务码KO01 BAPI_INTERNALORDER_CREATE 但是这个BAPI的参数很少,需要增强extensionin参数。1.增强BAPI结构BAPI_TE_AUFK 2.传入参数...

深入理解函数内部原理(2)——对一个函数实例进行深入的分析

在阅读本博客之前先阅读: 深入理解函数之函数定义、调用、解析、执行 解剖http://blog.csdn.net/wmaoshu/article/details/60469571 本博客是使用一...
  • wmaoshu
  • wmaoshu
  • 2017年03月07日 15:40
  • 260

ftp内部命令和简单实例

FTP命令是Internet用户使用最频繁的命令之一,不论是在DOS还是UNIX操作系统下使用FTP,都会遇到大量的FTP内部命令。熟悉并灵活应用FTP的内部命令,可以大大方便使用者,并收到事半功倍之...

Thinking in Java---内部类及一个迭代器实例

可以将一个类的定义放在另一个类的定义内部,这就是内部类. 内部类的定义是简单的,但是它的语法确实很是复杂,让人不是很好理解.下面就内部类做一个小结. 一.内部类的分类 总的来讲内部类分为普...
  • acm_lkl
  • acm_lkl
  • 2015年06月01日 17:03
  • 941

自定义接口内部类的一个简单的使用(跨类传值)

定义一个普通的Java类:package com.example.shiyan;public class haitao { private static haitao instance; ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:一个简单的内部调用BAPI实例
举报原因:
原因补充:

(最多只允许输入30个字)