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_INCOMINGINVOICE_GETDETAIL



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Apr 12, 2008 6:25 pm    Post subject: BAPI_INCOMINGINVOICE_GETDETAIL Reply with quote

BAPI_INCOMINGINVOICE_GETDETAIL - Invoice Verification: Display Invoice

Code:
  select * into corresponding fields of table it_bkpf from bkpf
           where
           "gjahr in p_gjahr  and
           bukrs = p_bukrs
           and bstat = p_bstat
           and budat in p_dt_la.

  if sy-subrc = 0.
    loop at it_bkpf into wa_bkpf.

      if wa_bkpf-awtyp = 'RMRP' ."and dont is INITIAL.


*MM Invoices *************************
*
*
*---- Construcao da Chave de pesquisa    ---- *
*
*
        invoicedocnumber = wa_bkpf-awkey(10).
        fiscalyear = wa_bkpf-awkey+10(4).
*
*
*---- Ir buscar os dados para a criacao  ---- *
*
*
        call function 'BAPI_INCOMINGINVOICE_GETDETAIL'
          exporting
            invoicedocnumber = invoicedocnumber
            fiscalyear       = fiscalyear
          importing
            headerdata       = headdata_detail
          tables
            itemdata         = itemdata_detail
            return           = return.

        move-corresponding headdata_detail to headdata_create.
*
*
*Some Fields are not passed need to manual
        headdata_create-gross_amount =  headdata_detail-gross_amnt.
*
*
*Need to change To New Parameters
        headdata_create-pstng_date = p_budat.
        headdata_create-comp_code = p_b_dst .
        clear: headdata_create-inv_doc_no,
*
*
*To Clean for the creation
               headdata_create-dsct_days1,
               headdata_create-dsct_days2,
               headdata_create-dsct_pct1,
               headdata_create-dsct_pct2
               .
        clear return.
*
*
*---- Mudanca dos itens                  ---- *
*
*
*
*
*The PO number may be different for each item
        loop at itemdata_detail into wa_itemdetail.
*
*
*Get the number of the next PO
          clear: is_valid,ebeln_sel.
          select single ebeln from ekko into ebeln_sel
                 where unsez = wa_itemdetail-po_number
                 and bukrs = 'CST'.
          if sy-subrc = 0.
***Need To read the detail of the PO
            call function 'BAPI_PO_GETDETAIL1'
              exporting
                purchaseorder      = ebeln_sel
                account_assignment = 'X'
                version            = 'X'
                services           = 'X'
              tables
                return             = return
                pohistory          = pohistory
                poitem             = poitem.

            read table return with key type = 'E' transporting no fields.
            if sy-subrc  0.
*
*
*---- Passa os dados dos itens para a nova estrutura de criacao ---- *
*
*
              move-corresponding wa_itemdetail to wa_itemcreate.
*
*
*---- Verificacao se e um item com revisao de factura com base em entrada de mercadoria ---- *
*
*
              read table poitem into wa_item with key po_item = wa_itemdetail-po_item.
              if sy-subrc = 0.
                if wa_item-gr_ind = 'X' and wa_item-gr_basediv = 'X' and wa_item-ir_ind = 'X'."Case 1 - Tem revisao de facturas baseada em
                  " entrada de material
                  move-corresponding wa_itemdetail to wa_itemcreate.
                  read table pohistory into wa_hist with key po_item = wa_itemdetail-po_item.
                  if sy-subrc = 0.
                    wa_itemcreate-ref_doc = wa_hist-ref_doc.
                    wa_itemcreate-ref_doc_it = wa_hist-matdoc_itm.
                    wa_itemcreate-po_number = ebeln_sel.
                    wa_itemcreate-ref_doc_year = wa_hist-doc_year.
                    " Os restantes casos nao precisam do documento de material
                  else.
                    if not w_hist is initial.
                      write at /1 wa_itemdetail-po_number.
                      write at ebeln_sel 20 .
                    endif.
                  endif.
                endif.
              else.
*
*Msg de Erro
              endif.
              append wa_itemcreate to itemdata_create.
            endif.
          else.
*is_valid = 'X'.
          endif.
          clear: wa_itemdetail, wa_hist, wa_itemcreate, wa_item.
        endloop.
        describe table itemdata_create lines lines.
        if lines >= 1 and w_hist is initial.
          clear return[].
***Theres no errors on the document, process the document
          call function 'BAPI_INCOMINGINVOICE_PARK'
            exporting
              headerdata       = headdata_create
            importing
              invoicedocnumber = invoicedocnumber_c
              fiscalyear       = fiscalyear_c
            tables
              itemdata         = itemdata_create
              return           = return.

          read table return with key type = 'E' transporting no fields.
          if sy-subrc ne 0.

*it_out-old = .
*it_out-new = .

            call function 'BAPI_TRANSACTION_COMMIT'
              exporting
                wait = 'X'.
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 -> Interfaces | Интерфейсы -> BAPI 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 can 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.