Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI

Former Member
0 Kudos

hI,

I was using BAPI_PO_CHANGE..There are two tables in this BAPi.

One is showing header data and another one is of EIKP table oriented.

How to relate the EKKO and EIKP table..Can any one give me a sample code of BAPI_po_change

2 REPLIES 2

Former Member
0 Kudos

EKKO-EXNUM = EIKP-EXNUM.

You could of actually found this out for yourself, it was not difficult.

Edited by: Martin Shinks on Jun 10, 2008 12:59 PM

valter_oliveira
Active Contributor
0 Kudos

Cheers.

To relate table EKKO with table EIKP just make EIKP-EXNUM (it's primary key) equal to EKKO-EXNUM.

Code for BAPI:


* HEADER
  t_header-doc_date   = p_data2.   "data do documento
  t_header-doc_type   = p_tipo.    "tipo de documento
  t_header-doc_cat    = 'F'.       "categoria de doc - pedido
  t_header-co_code    = c_incm.    "empresa
  t_header-purch_org  = c_a001.    "organização de compras
  t_header-pur_group  = c_c06.     "grupo de compradores
  t_header-suppl_plnt = c_p001.    "centro fornecedor
  t_header-created_by = sy-uname.  "usuário que cria o documento

*ITEMS
LOOP AT t_table.

    CLEAR: t_items, t_lote, l_aux, l_item.

*   Calcula nº de item do pedido no formato NUMC 5
    ADD 10 TO l_linha.
    MOVE l_linha TO l_aux.
    CONDENSE l_aux.
    IF l_linha LT 100.
      CONCATENATE '000' l_aux(2) INTO l_item.
    ELSEIF l_linha LT 1000.
      CONCATENATE '00' l_aux(3) INTO l_item.
    ELSE.
      CONCATENATE '0' l_aux(4) INTO l_item.
    ENDIF.

*   Tabela dos items - EKPO
    CONDENSE t_table-destino.

    t_items-po_item    = l_item.
    t_items-material   = t_table-zmatnr.
    t_items-pur_mat    = t_table-zmatnr.
    t_items-disp_quan  = t_table-zquant.
    t_items-plant      = p_centro.
    t_items-store_loc  = t_table-destino(4).
    t_items-item_cat   = 7.
    APPEND t_items.

*   Tabela das divisões de remessa - EKET
    t_lote-po_item = l_item.
    t_lote-batch = t_table-charg.
    t_lote-quantity = t_table-zquant.
    t_lote-deliv_date = p_data2.
    APPEND t_lote.

  ENDLOOP.

* BAPI
   CALL FUNCTION 'BAPI_PO_CREATE'
         EXPORTING
              po_header         = t_header
         IMPORTING
              purchaseorder     = l_pedido2
         TABLES
              po_items          = t_items
              po_item_schedules = t_lote
              return            = t_return.

Regards.

Valter Oliveira.