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

BAPI_PO_CHANGE



 
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: Thu Sep 20, 2007 11:01 am    Post subject: BAPI_PO_CHANGE Reply with quote

BAPI_PO_CHANGE - Change purchase order

Functionality
You can use this method to change Enjoy purchase orders.

Code:
PARAMETERS: p_ebeln LIKE ekko-ebeln OBLIGATORY.
PARAMETERS: p_ebelp LIKE ekpo-ebelp OBLIGATORY.

DATA: t_item LIKE bapimepoitem OCCURS 0 WITH HEADER LINE.
DATA: t_itemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE.
DATA: t_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.


t_item-po_item = p_ebelp.
t_item-no_more_gr = 'X'.
t_item-final_inv = 'X'.
APPEND t_item.


t_itemx-po_item = p_ebelp.
t_itemx-po_itemx = 'X'.
t_itemx-no_more_gr = 'X'.
t_itemx-final_inv = 'X'.
APPEND t_itemx.

CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = p_ebeln
TABLES
return = t_return
poitem = t_item
poitemx = t_itemx.

LOOP AT t_return WHERE type = 'A' OR type = 'E'.
EXIT.
ENDLOOP.

IF sy-subrc = 0.
WRITE: / 'FAILED'.
ELSE.
WRITE: / 'SUCCESS'.
COMMIT WORK.
ENDIF.

Code:
 DATA i_list LIKE i_listado OCCURS 0 WITH HEADER LINE.                     
                                                                           
  DATA : t_bapi_poheader LIKE bapimepoheader OCCURS 0 WITH HEADER LINE,     
         t_bapi_poheaderx LIKE bapimepoheaderx OCCURS 0                     
                                              WITH HEADER LINE,             
         t_bapi_poitem LIKE bapimepoitem OCCURS 0 WITH HEADER LINE,         
         t_bapi_poitemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE,       
         t_bapireturn LIKE bapiret2 OCCURS 0 WITH HEADER LINE.             
                                                                           
  LOOP AT i_listado INTO i_list WHERE check = 'X'.                         
    APPEND i_list.                                                         
  ENDLOOP.                                                                 
                                                                           
                                                                           
  SORT i_list.                                                             
  LOOP AT i_list INTO i_listado.                                           
    AT NEW ebeln.                                                           
*      REFRESH t_bapi_poheader.                                         
*      CLEAR t_bapi_poheader.                                           
*      t_bapi_poheader-po_number = i_listado-ebeln.                     
*      t_bapi_poheader-delete_ind = 'X'.                               
*      APPEND t_bapi_poheader.                                         
*                                                                       
*      REFRESH t_bapi_poheaderx.                                       
*      CLEAR t_bapi_poheaderx.                                         
*      t_bapi_poheaderx-delete_ind = 'X'.                               
*      APPEND t_bapi_poheaderx.                                         
                                                                           
      REFRESH: t_bapi_poitem,                                               
               t_bapi_poitemx.                                             
    ENDAT.                                                                 
                                                                           
    CLEAR t_bapi_poitem.                                                   
    t_bapi_poitem-po_item = i_listado-ebelp.                               
    t_bapi_poitem-delete_ind = 'X'.                                         
    APPEND t_bapi_poitem.                                                   
                                                                           
    CLEAR t_bapi_poitemx.                                                   
    t_bapi_poitemx-po_item = i_listado-ebelp.                               
    t_bapi_poitemx-delete_ind = 'X'.                                       
    APPEND t_bapi_poitemx.                                                 
                                                                           
    AT END OF ebeln.                                                       
      CALL FUNCTION 'BAPI_PO_CHANGE'                                   
           EXPORTING                                                       
                purchaseorder = i_listado-ebeln                             
*                poheader      = t_bapi_poheader                       
*                poheaderx     = t_bapi_poheaderx                       
           TABLES                                                           
                return        = t_bapireturn                               
                poitem        = t_bapi_poitem                               
                poitemx       = t_bapi_poitemx.                             
                                                                           
      READ TABLE t_bapireturn WITH KEY type = 'E'.                         
      IF sy-subrc NE 0.                                                     
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'                         
             EXPORTING                                                     
                  wait = 'X'.                                               
        READ TABLE t_bapireturn WITH KEY type = 'S'.                       
        LOOP AT i_listado WHERE check = 'X'                                 
           AND ebeln = i_list-ebeln.                                       
                         
          i_listado-message = t_bapireturn-message.                         
          MODIFY i_listado.                                                 
        ENDLOOP.                                                           
      ELSE.                                                                 
        LOOP AT i_listado WHERE check = 'X'                                 
                            AND ebeln = i_list-ebeln.                                                   
          i_listado-message = t_bapireturn-message.                         
          MODIFY i_listado.                                                 
        ENDLOOP.                                                           
      ENDIF.                                                               
    ENDAT.                                                                 
  ENDLOOP.
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.