码迷,mamicode.com
首页 > Windows程序 > 详细

QP01 BAPI、QP02 BDC

时间:2015-06-03 17:42:52      阅读:1035      评论:0      收藏:0      [点我收藏+]

标签:abap qp01 bapi   abap qp02 bdc   abap qp01   abap qp02   sap qp01 qp02   

最近在修改一个检验计划分配的一个程序,上网查了一些资料,分别对QP01检验计划创建、修改QP02、删除物料等操作,分享一下。

一、QP01 BAPI

BAPI_INSPECTIONPLAN_CREATE  



二、BDC for QP02

REPORT  ZQM_BDC_QP02.

************************************************************************
*TYPE-POOLS                                                            *
************************************************************************
TYPE-POOLS TRUXS.

************************************************************************
*TYPE DECLARATION                                                      *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
          PROGRAM  TYPE BDC_PROG,
          DYNPRO   TYPE BDC_DYNR,
          DYNBEGIN TYPE BDC_START,
          FNAM     TYPE FNAM_____4,
          FVAL     TYPE BDC_FVAL,
        END OF TYPE_BDCDATA,

        BEGIN OF TYPE_DATA,
          MATNR TYPE MATNR_BI,
          WERKS TYPE WERKS,
        END OF TYPE_DATA.

************************************************************************
*WORK AREA DECLARATION                                                 *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
       WA_DATA    TYPE TYPE_DATA,
       WA_MESSTAB TYPE BDCMSGCOLL,
       WA_RAW     TYPE TRUXS_T_TEXT_DATA.

************************************************************************
*INTERNAL TABLE DECLARATION                                            *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
       I_DATA    TYPE STANDARD TABLE OF TYPE_DATA,
       I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.

************************************************************************
*DATA DECLARATION                                                      *
************************************************************************
DATA   WF_MESSAGE(100).

************************************************************************
*SELECTION-SCREEN DECLARATION                                          *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
             P_MODE DEFAULT ‘A‘.
SELECTION-SCREEN END OF BLOCK A1.

************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION                      *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION ‘KD_GET_FILENAME_ON_F4‘
 EXPORTING
    FIELD_NAME          = ‘P_FILE‘
  CHANGING
    FILE_NAME           = P_FILE
          .
REFRESH I_DATA[].

CALL FUNCTION ‘TEXT_CONVERT_XLS_TO_SAP‘
  EXPORTING
    I_LINE_HEADER              = ‘X‘
    I_TAB_RAW_DATA             = WA_RAW
    I_FILENAME                 = P_FILE
  TABLES
    I_TAB_CONVERTED_DATA       = I_DATA
          .
************************************************************************
*START-OF-SELECTION                                                    *
************************************************************************
START-OF-SELECTION.

LOOP AT I_DATA INTO WA_DATA.

perform bdc_dynpro      using ‘SAPLCPDI‘ ‘8010‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_field       using ‘RC27M-MATNR‘
                               WA_DATA-MATNR.
perform bdc_field       using ‘RC27M-WERKS‘
                               WA_DATA-WERKS.

perform bdc_dynpro      using ‘SAPLCPDI‘ ‘1400‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘=ALD1‘.
perform bdc_field       using ‘RC27X-ENTRY_ACT‘
                              ‘1‘.

perform bdc_dynpro      using ‘SAPLCPDA‘ ‘1200‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘=MTUE‘.

perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘MAPL-PLNAL(02)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(03)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(04)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(05)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(06)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(07)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(08)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(09)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(10)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(11)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(12)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(13)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(14)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-MATNR(02)‘
                              ‘8514AA-MEG-0002-02‘.
perform bdc_field       using ‘MAPL-MATNR(03)‘
                              ‘8514AA-MEG-0002-03‘.
perform bdc_field       using ‘MAPL-MATNR(04)‘
                              ‘8514AA-MEG-0002-04‘.
perform bdc_field       using ‘MAPL-MATNR(05)‘
                              ‘8514AA-MEG-0002-05‘.
perform bdc_field       using ‘MAPL-MATNR(06)‘
                              ‘8514AA-MEG-0002-06‘.
perform bdc_field       using ‘MAPL-MATNR(07)‘
                              ‘8514AA-MEG-0002-07‘.
perform bdc_field       using ‘MAPL-MATNR(08)‘
                              ‘8514AA-MEG-0002-08‘.
perform bdc_field       using ‘MAPL-MATNR(09)‘
                              ‘8514AA-MEG-0002-09‘.
perform bdc_field       using ‘MAPL-MATNR(10)‘
                              ‘8514AA-MEG-0002-10‘.
perform bdc_field       using ‘MAPL-MATNR(11)‘
                              ‘8514AA-MEG-0002-11‘.
perform bdc_field       using ‘MAPL-MATNR(12)‘
                              ‘8514AA-MEG-0002-12‘.
perform bdc_field       using ‘MAPL-MATNR(13)‘
                              ‘8514AA-MEG-0002-13‘.
perform bdc_field       using ‘MAPL-MATNR(14)‘
                              ‘8514AA-MEG-0002-14‘.

perform bdc_field       using ‘MAPL-WERKS(02)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(03)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(04)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(05)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(06)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(07)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(08)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(09)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(10)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(11)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(12)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(13)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(14)‘
                              ‘2000‘.

perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_field       using ‘MAPL-PLNAL(02)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(03)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(04)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(05)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(06)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(07)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(08)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(09)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(10)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(11)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(12)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(13)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-PLNAL(14)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-MATNR(02)‘
                              ‘8514AA-MEG-0002-15‘.
perform bdc_field       using ‘MAPL-MATNR(03)‘
                              ‘8514AA-MEG-0002-16‘.
perform bdc_field       using ‘MAPL-MATNR(04)‘
                              ‘8514AA-MEG-0002-17‘.
perform bdc_field       using ‘MAPL-MATNR(05)‘
                              ‘8514AA-MEG-0002-18‘.
perform bdc_field       using ‘MAPL-MATNR(06)‘
                              ‘8514AA-MEG-0002-19‘.
perform bdc_field       using ‘MAPL-MATNR(07)‘
                              ‘8514AA-MEG-0002-20‘.
perform bdc_field       using ‘MAPL-MATNR(08)‘
                              ‘8514AA-MEG-0002-21‘.
perform bdc_field       using ‘MAPL-MATNR(09)‘
                              ‘8514AA-MEG-0002-22‘.
perform bdc_field       using ‘MAPL-MATNR(10)‘
                              ‘8514AA-MEG-0002-23‘.
perform bdc_field       using ‘MAPL-MATNR(11)‘
                              ‘8514AA-MEG-0002-24‘.
perform bdc_field       using ‘MAPL-MATNR(12)‘
                              ‘8514AA-MEG-0002-25‘.
perform bdc_field       using ‘MAPL-MATNR(13)‘
                              ‘8514AA-MEG-0002-26‘.
perform bdc_field       using ‘MAPL-MATNR(14)‘
                              ‘8514AA-MEG-0002-27‘.
perform bdc_field       using ‘MAPL-WERKS(02)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(03)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(04)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(05)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(06)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(07)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(08)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(09)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(10)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(11)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(12)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(13)‘
                              ‘2000‘.
perform bdc_field       using ‘MAPL-WERKS(14)‘
                              ‘2000‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RC271-PLNNR‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/00‘.
perform bdc_dynpro      using ‘SAPLCZDI‘ ‘4010‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘MAPL-WERKS(03)‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘=BACK‘.
perform bdc_field       using ‘MAPL-PLNAL(03)‘
                              ‘1‘.
perform bdc_field       using ‘MAPL-MATNR(03)‘
                              ‘8514AA-MEG-0002-28‘.
perform bdc_field       using ‘MAPL-WERKS(03)‘
                              ‘2000‘.
perform bdc_dynpro      using ‘SAPLCPDA‘ ‘1200‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘=BU‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘PLKOD-KTEXT‘.
perform bdc_field       using ‘PLKOD-KTEXT‘
                              ‘8514AA-MEG-0002-01  -Package -04- RC C‘
                            & ‘oo‘.
perform bdc_field       using ‘PLKOD-WERKS‘
                              ‘2000‘.
perform bdc_field       using ‘PLKOD-VERWE‘
                              ‘Z1‘.
perform bdc_field       using ‘PLKOD-STATU‘
                              ‘4‘.
perform bdc_field       using ‘PLKOD-LOSBS‘
                              ‘99,999,999‘.
perform bdc_field       using ‘PLKOD-PLNME‘
                              ‘EA‘.
perform bdc_field       using ‘PLKOD-SLWBEZ‘
                              ‘Z01‘.

CALL TRANSACTION ‘QP02‘ USING I_BDCDATA MODE P_MODE UPDATE ‘A‘ MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].

ENDLOOP.

************************************************************************
*START-OF-SELECTION                                                    *
************************************************************************
END-OF-SELECTION.

LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION ‘FORMAT_MESSAGE‘
 EXPORTING
   ID              = WA_MESSTAB-MSGID
   LANG            = SY-LANGU
   NO              = WA_MESSTAB-MSGNR
   V1              = WA_MESSTAB-MSGV1
   V2              = WA_MESSTAB-MSGV2
   V3              = WA_MESSTAB-MSGV3
   V4              = WA_MESSTAB-MSGV4
 IMPORTING
   MSG             = WF_MESSAGE
 EXCEPTIONS
   NOT_FOUND       = 1
   OTHERS          = 2.

WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.

*&---------------------------------------------------------------------*
*&      Form  BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
                     FVAL TYPE ANY.
CLEAR WA_BDCDATA.
  WA_BDCDATA-FNAM = FNAM.
  WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM.                    " BDC_FIELD

*&---------------------------------------------------------------------*
*&      Form  BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
  WA_BDCDATA-PROGRAM  = PROGRAM.
  WA_BDCDATA-DYNPRO   = DYNPRO.
  WA_BDCDATA-DYNBEGIN = ‘X‘.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM.                    " BDC_DYNPRO




三、Deleting material assignments from inspection plans
ISSUE
Recently I had the issue that a material has been wrongly assigned to an inspection plan in a test system. If you remove the assignment in QP02 via the delete button, the system only sets a deletion indicator in table MAPL on this assignment. Hence the material assignment is still blocking actions like "change of unit of measure". After digging a bit in the internet I found an SAP report for this, which I like to share also here on SCN.
 
STANDARD SOLUTION
The correct way to get rid of the assignment is to archive the complete inspection plan (I have not found a way so far to just archive a material-task list assignment).
 
WORKAROUND
Beside using transaction QSR6 (which deletes the complete inspection plan from the database without archiving), there is an SAP report that just deletes material assignments from the database: RCPMAPL1
 
With entering the task list type (e.g. Q) and the group ID, the report displays all assignments. The ones that should be removed can be marked and deleted. It is advisable to first remove the assignment with QP02, as then the deletion indicator will be visible in the report. This ensures that you tick the right assignment...
 
WARNING
As always with these kind of actions: be aware that you bypass most SAP security concepts (like dependency/integrity checks,...) with this action! You will most likely need a special approval from (IT) Managment and you normally have to record these actions and document them so that an auditor will understand why this had to be done.


QP01 BAPI、QP02 BDC

标签:abap qp01 bapi   abap qp02 bdc   abap qp01   abap qp02   sap qp01 qp02   

原文地址:http://blog.csdn.net/champaignwolf/article/details/46348083

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!