SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Using BAPI for purchase requisition creation and deletion



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Fri Oct 05, 2007 9:41 am    Post subject: Using BAPI for purchase requisition creation and deletion Reply with quote

What is required to be done is to populate the values into the tables that is present in the BAPI before calling it. In the sample code passed values for tables Requisition items only. You may be required to populate other fields in the different tables in the BAPI as per your requirement.

Code:
report z_req_create.

DATA : T_REQUISITION_ITEMS LIKE BAPIEBANC OCCURS 0 WITH HEADER LINE,

T_RETURN LIKE BAPIRETURN OCCURS 0 WITH HEADER LINE .

DATA : E_NUMBER LIKE BAPIEBANC-PREQ_NO.

T_REQUISITION_ITEMS-DOC_TYPE = 'NB'.
T_REQUISITION_ITEMS-DEL_DATCAT = '1'.
T_REQUISITION_ITEMS-DELIV_DATE = '20020626'.
T_REQUISITION_ITEMS-PLANT = 'P1'.
T_REQUISITION_ITEMS-STORE_LOC = '01'.
T_REQUISITION_ITEMS-PUR_GROUP = 'P01'.
T_REQUISITION_ITEMS-MAT_GRP = '01'.
T_REQUISITION_ITEMS-PREQ_ITEM = 1.
T_REQUISITION_ITEMS-MATERIAL = '1MAT1'.
T_REQUISITION_ITEMS-QUANTITY = 10.
T_REQUISITION_ITEMS-PREQ_NAME = '123456'.
T_REQUISITION_ITEMS-PURCH_ORG = '1000'.
T_REQUISITION_ITEMS-ACCTASSCAT = 'U' .
T_REQUISITION_ITEMS-VEND_MAT = 'G'.
APPEND T_REQUISITION_ITEMS.

CALL FUNCTION 'BAPI_REQUISITION_CREATE'
* EXPORTING
* SKIP_ITEMS_WITH_ERROR =
IMPORTING
NUMBER = E_NUMBER
TABLES
REQUISITION_ITEMS = T_REQUISITION_ITEMS
REQUISITION_ACCOUNT_ASSIGNMENT = T_REQ_ACCOUNT_ASSIGNMENT
* REQUISITION_ITEM_TEXT =
* REQUISITION_LIMITS =
* REQUISITION_CONTRACT_LIMITS =
* REQUISITION_SERVICES =
* REQUISITION_SRV_ACCASS_VALUES =
RETURN = T_RETURN
* REQUISITION_SERVICES_TEXT =
* EXTENSIONIN =
* REQUISITION_ADDRDELIVERY =
.

IF NOT E_NUMBER IS INITIAL .
WRITE:/ 'REQ NO:' , E_NUMBER , 'CREATED'.
ELSE.
LOOP AT T_RETURN.
WRITE T_RETURN-MESSAGE.
ENDLOOP.
ENDIF.



Set deletion indicator.

Code:
report Z_REQUISITION_DELETE.

tables: eban.

data: gt_BAPIEBAND type BAPIEBAND occurs 0 with header line,
      gt_return type bapiret2 occurs 0 with header line,
      error_occured.


PARAMETERS: p_banfn  like eban-banfn.

start-of-selection.

  select * from eban where banfn eq p_banfn.

     move: eban-bnfpo to gt_BAPIEBAND-PREQ_ITEM,
           'X'        to gt_BAPIEBAND-DELETE_IND,
           'X'        to gt_BAPIEBAND-CLOSED.
     append gt_BAPIEBAND.

  endselect.

end-of-selection.

  CALL FUNCTION 'BAPI_REQUISITION_DELETE'
    EXPORTING
      NUMBER                            = p_banfn
    TABLES
      REQUISITION_ITEMS_TO_DELETE       = gt_BAPIEBAND
      RETURN                            = gt_return.

  if gt_return[] is not initial.
    loop at gt_return.
      MESSAGE
         ID      gt_return-id
         TYPE    gt_return-type
         NUMBER  gt_return-number
         WITH    gt_return-message_v1
                 gt_return-message_v2
                 gt_return-message_v3
                 gt_return-message_v4.

      case gt_return-type.
        when 'E' or 'A'.
          exit.
      endcase.

    endloop.
  endif.

  call function 'BAPI_TRANSACTION_COMMIT'.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.