Wednesday, June 3, 2015

Purcahse order create using BAPI with the reference of purchase requisition



  "---DATA DECALRATION FOR AUTO PO CREATION
tablesbapimepoheader,
        bapimepoheaderx
.

datait_bapimepoitem type bapimepoitem occurs with header line,
      it_bapimepoitemx 
type bapimepoitemx occurs with header line,
      it_poaccount 
type bapimepoaccount occurs with header line,
      it_poaccountx 
type bapimepoaccountx occurs with header line.
datait_return2 like bapiret2 occurs with header line.
dataflines like tline occurs with header line,
      string
(132type cfobject like thead-tdobjectfname  like thead-tdname.

dataline_no type i.
datavendor_no type lifnr.

datantgew type ekpo-ntgew.
databrgew type ekpo-brgew.

datastr type string.
datastr1 type string.

datav_plant(4type c,
      v_whno
(3type c,
      v_sorg
(4type c,
      v_dplnt
(4type c,
      v_ccode
(4type c,
      v_curr
(3type c,
      v_shippt
(4type c,
      v_country
(2type c.

datatemp_char(200type c.

databanfn type vbep-banfn" for purchase requisition number.

  
select single banfn into banfn from vbep where vbeln zsalesdocument" fetching purchse requisition number

  
" for PO Header data fill

   bapimepoheader
-comp_code t001-bukrs.
   bapimepoheader
-doc_type 'ZCOM'.
   bapimepoheader
-item_intvl '00010'.

   bapimepoheader
-vendor VENDOR.
   bapimepoheader
-pmnttrms '0001'.
   bapimepoheader
-purch_org ‘ABC’.
   bapimepoheader
-pur_group 'E15'.
   bapimepoheader
-currency 'USD'.
   
"bapimepoheader-ref_1 = wa_asntab-asnnumber.
   bapimepoheader
-incoterms2 'inco2'.

   bapimepoheaderx
-comp_code 'X'.
   bapimepoheaderx
-doc_type 'X'.
   bapimepoheaderx
-item_intvl 'X'.
   bapimepoheaderx
-vendor 'X'.
   bapimepoheaderx
-pmnttrms 'X'.
   bapimepoheaderx
-purch_org 'X'.
   bapimepoheaderx
-pur_group 'X'.
   bapimepoheaderx
-currency 'X'.
   
"bapimepoheaderx-ref_1 = 'X'.
   bapimepoheaderx
-incoterms2 'X'.

  
" for PO Line item Data FIll

    line_no 
line_no + 10.
    it_bapimepoitem
-po_item '00010'.
    it_bapimepoitem
-material material.
    it_bapimepoitem
-plant PLANT.
    it_bapimepoitem
-quantity '1'.
    it_bapimepoitem
-free_item 'X'.
    it_bapimepoitem
-conf_ctrl '0004'.
    it_bapimepoitem
-incoterms2 'inco2'.

    it_bapimepoitem
-gross_wt brgew.  “ gross weight

    it_bapimepoitem
-preq_no banfn. “ purchase requisition number

    it_bapimepoitem
-net_weight ntgew. “ net weight

    
append it_bapimepoitem to it_bapimepoitem.
    
clear it_bapimepoitem.

    it_bapimepoitemx
-po_item '00010'.
    it_bapimepoitemx
-material 'X'.
    it_bapimepoitemx
-plant 'X'.
    it_bapimepoitemx
-quantity 'X'.
    it_bapimepoitemx
-free_item 'X'.
    it_bapimepoitemx
-conf_ctrl 'X'.
    it_bapimepoitemx
-incoterms2 'X'.
    it_bapimepoitemx
-gross_wt 'X'.
    it_bapimepoitemx
-preq_no  'X'.
    it_bapimepoitemx
-net_weight 'X'.
    
append it_bapimepoitemx to it_bapimepoitemx.
    
clear it_bapimepoitemx.
    
cleartemp_char.

    it_poaccount
-po_item '00010'.
    it_poaccount
-serial_no '01'.
    it_poaccount
-quantity '1'.

    it_poaccount
-costcenter cost_center.
    
append it_poaccount to it_poaccount.

    it_poaccountx
-po_item '00010'.
    it_poaccountx
-serial_no '01'.
    it_poaccountx
-quantity 'X'.
    it_poaccountx
-costcenter 'X'.
    
append it_poaccountx to it_poaccountx.


    
clear po_number.

    
call function 'BAPI_PO_CREATE1'
    
exporting
      poheader         
bapimepoheader
      poheaderx        
bapimepoheaderx
    
importing
      exppurchaseorder 
po_number
    
tables
      
return           it_return2
      poitem           
it_bapimepoitem
      poitemx          
it_bapimepoitemx
      poaccount        
it_poaccount
      poaccountx        
it_poaccountx.

   
call function 'BAPI_TRANSACTION_COMMIT'
    
exporting
      
wait   'X'
    
importing
      
return return.

13 comments:

  1. Your information is really interesting. Thanks for sharing more details about Sap. Also I want you to know the latest updates about Sap.
    SAP Help Portal | SAP Online Training Tutorials

    ReplyDelete
  2. Thanks for the proper explanation about SAP. It’s really helpful to me. I found one of the good resource related to SAP which I am sharing with you just go through this link: https://intellipaat.com/sap-bi-combo-pack/

    ReplyDelete
  3. We provide sap abap technical course, call us to know more about us and join with us.
    Call them at 8122241286 in chennai.
    www.thecreatingexperts.com

    ReplyDelete
  4. I have been a blogger too but you post much technical details. Thank you for sharing your knowledge. The creating experts was my first trainer in SAP ABAP got in depth learning from them

    http://thecreatingexperts.com/sap-abap-training-in-chennai/


    contact +91-08122241286

    ReplyDelete
  5. SAP ABAP training is provided in CHENNAI.

    THE CREATING EXPERTS is one of the leading trainer in SAP who provides real time training

    http://thecreatingexperts.com/sap-abap-training-in-chennai/

    contact 8122241286

    ReplyDelete
  6. Ken Academy is the premier institute for SAP courses London. Ken offer a practical industry-led approach. Ken has emerged as a destination of choice among the students. We have trained enormous students individual as well as corporates who are looking for excelling and building a career in SAP.

    ReplyDelete
  7. Maple Hill Outsourcing services is a specialist outsourcing provider working specifically for Uk businesses of all size. Our team is qualified and highly trained in almost every software used in the accounting world.

    ReplyDelete

  8. I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic. Here is one of the best tibco spotfire tutorial . hope more articles from you.

    ReplyDelete