problema BAPI_PO_CCREATE1

Colapsar
X
 
  • Tiempo
  • Mostrar
Limpiar Todo
nuevos mensajes
  • ivansap1
    Junior Member
    • jun
    • 16

    #1

    problema BAPI_PO_CCREATE1

    Buenos Dias foro,ante todo gracias por su respuesta ,
    quisiera saber que puede estar pasando pues estoy usando la bapi de creacion de pedido,: BAPI_PO_CREATE1 .
    estoy creandolos a partir de una solicitud de pedido ,me lanza el siguiente mensaje : "NO SE CREADO NINGUNA INSTANCIA DE TIPO OBJETO PURCHASEORDER" .
    otro inconvebiente es que Al DEBUGGEAR veo que antes de ingresar en la bapi ,existe precio para ello uso el campo net_price, del item de la bapi ,pero a la hora de que sale de la bapi ,no se encuentra valor del precio pues aparece con 0.
    el codio es el siguiente :

    FORM perform_creapedido .
    DATA: l_line(4) TYPE n,
    l_ebeln TYPE ekko-ebeln,
    l_ekorg TYPE ekko-ekorg,
    l_lifnr TYPE ekko-lifnr,
    l_lifnp TYPE ekko-lifnr.

    DATA: l_tab LIKE object_tab2.* SORT object_tab2 BY lifnp lifnr.
    SORT object_tab2 BY waers matnr banfn bnfpo.
    CLEAR: l_line.

    LOOP AT object_tab2 .
    CLEAR: ekko, ekpo.
    l_tab = object_tab2.
    if object_tab2-netpu is INITIAL.
    move: object_tab2-netpr to object_tab2-netpu,
    object_tab2-waers to object_tab2-waeru.
    modify object_tab2 TRANSPORTING netpu waeru.
    endif.

    AT NEW waers.
    REFRESH: item, itemx, itemschedule, itemschedulex, ipocond,
    ipocondx, ipopartner, returnerr, iaddrdelivery.

    CLEAR: item, itemx, itemschedule, itemschedulex, ipocond,
    ipocondx, ipopartner, header, returnerr, iaddrdelivery,
    headerx, "INSERT JCP20110927
    ekko, ekpo.
    SELECT SINGLE ekorg
    INTO l_ekorg
    FROM t024w
    WHERE werks = s_werks-low.

    IF ekko-bukrs IS INITIAL.
    SELECT SINGLE bukrs
    INTO ekko-bukrs
    FROM t001k
    WHERE bwkey = s_werks-low.
    ENDIF.


    header-comp_code = ekko-bukrs.
    header-doc_type = w_bsartp.
    header-creat_date = sy-datum.
    header-created_by = sy-uname.
    IF l_tab-lfdat LE sy-datum.
    header-vper_start = sy-datum + 4.
    header-vper_end = sy-datum + 4.
    ELSE.
    header-vper_start = l_tab-lfdat.
    header-vper_end = l_tab-lfdat.
    ENDIF.
    header-item_intvl = l_line.
    header-vendor = l_tab-lifnr.
    header-langu = sy-langu.
    header-purch_org = l_ekorg.
    header-pur_group = l_tab-ekgrp.
    header-currency = l_tab-waers.
    header-doc_date = sy-datum.

    header-collect_no = g_submi.
    headerx-collect_no = 'X'.

    SELECT SINGLE * FROM lfb1
    WHERE lifnr = l_tab-lifnr
    AND bukrs = ekko-bukrs.
    IF sy-subrc = 0.
    IF lfb1-zterm IS INITIAL.
    header-pmnttrms = 'Z007'.
    headerx-pmnttrms = 'X'.
    ENDIF.
    ENDIF.
    headerx-comp_code = 'X'.
    headerx-doc_type = 'X'.
    headerx-creat_date = 'X'.
    headerx-created_by = 'X'.
    headerx-vper_start = 'X'.
    headerx-vper_end = 'X'.
    headerx-item_intvl = 'X'.
    headerx-vendor = 'X'.
    headerx-langu = 'X'.
    headerx-purch_org = 'X'.
    headerx-pur_group = 'X'.
    headerx-currency = 'X'.
    headerx-doc_date = 'X'.
    ENDAT.
    item-po_item = l_line.
    item-short_text = object_tab2-txz01.
    item-material = object_tab2-matnr.
    item-plant = s_werks-low.
    item-matl_group = object_tab2-matkl.
    item-quantity = object_tab2-ktmng.


    item-po_unit = object_tab2-meins.
    item-net_price = object_tab2-netpr.
    item-item_cat = object_tab2-pstyp.
    item-acctasscat = object_tab2-knttp.
    item-gr_ind = 'X'.
    item-period_ind_expiration_date = 'D'.
    APPEND item.
    itemx-po_item = l_line.
    itemx-short_text = 'X'.
    itemx-material = 'X'.
    itemx-plant = 'X'.
    itemx-matl_group = 'X'.
    itemx-quantity = 'X'.
    itemx-po_unit = 'X'.
    itemx-net_price = 'X'.
    itemx-item_cat = 'X'.
    IF item-acctasscat IS NOT INITIAL.
    itemx-acctasscat = 'X'.
    ENDIF. "INSERT JCP20110913
    itemx-gr_ind = 'X'.


    itemx-period_ind_expiration_date = 'X'.
    APPEND itemx.
    IF object_tab2-lfdat LE sy-datum.
    object_tab2-lfdat = sy-datum + 4.
    ENDIF.
    itemschedule-po_item = l_line.
    itemschedule-del_datcat_ext = 'D'.
    itemschedule-delivery_date+0(2) = object_tab2-lfdat+6(2).
    itemschedule-delivery_date+2(2) = object_tab2-lfdat+4(2).
    itemschedule-delivery_date+4(4) = object_tab2-lfdat+0(4).
    itemschedule-stat_date = object_tab2-lfdat.
    IF object_tab2-ebeln IS NOT INITIAL.
    itemschedule-quantity = object_tab2-ktmng.
    ELSE.
    itemschedule-quantity = object_tab2-ktmng.
    ENDIF.
    itemschedule-preq_no = object_tab2-banf1.
    itemschedule-preq_item = object_tab2-bnfp1.
    APPEND itemschedule.

    itemschedulex-po_item = l_line.
    itemschedulex-po_itemx = 'X'.
    itemschedulex-del_datcat_ext = 'X'.
    itemschedulex-delivery_date = 'X'.
    itemschedulex-stat_date = 'X'.
    itemschedulex-quantity = 'X'.
    itemschedulex-preq_no = 'X'.
    itemschedulex-preq_item = 'X'.
    APPEND itemschedulex.
    *Si tiene Tipo de Imputacion, agrega condiciones.
    IF item-acctasscat IS NOT INITIAL.
    * Adiciona condiciones de pedido/posición.
    ipocond-itm_number = l_line.
    ipocond-cond_st_no = '001'.
    ipocond-cond_type = 'PBXX'.
    IF ekpo-netpr IS NOT INITIAL.
    ipocond-cond_value = ekpo-netpr.
    ELSE.
    ipocond-cond_value = object_tab2-netpr.
    ENDIF.
    IF ekko-waers IS NOT INITIAL.
    ipocond-currency = ekko-waers.
    ELSE.
    ipocond-currency = object_tab2-waers.
    ENDIF.

    * Condiciones de posición
    ipocond-cond_unit = ekpo-meins.
    ipocond-cond_p_unt = ekpo-peinh.
    ipocond-change_id = 'U'.
    APPEND ipocond.

    ipocondx-itm_number = l_line.
    ipocondx-cond_st_no = '001'.
    ipocondx-cond_type = 'X'.
    ipocondx-cond_value = 'X'.
    ipocondx-currency = 'X'.
    ipocondx-cond_unit = 'X'.
    ipocondx-cond_p_unt = 'X'.
    ipocondx-change_id = 'X'.
    APPEND ipocondx.
    ENDIF. "INSERT JCP20110913

    * Dirección de entrega
    iaddrdelivery-po_item = l_line.
    iaddrdelivery-addr_no = '0000022544'.
    APPEND iaddrdelivery.

    AT END OF waers.
    ipopartner-langu = sy-langu.
    ipopartner-buspartno = object_tab2-lifnr.
    APPEND ipopartner.

    PERFORM ejecutabapi.
    ENDAT.
    ENDLOOP.
    PERFORM muestra_mensajes.
    IF w_error IS INITIAL.
    SET SCREEN 0.
    LEAVE SCREEN.
    ENDIF.

    ENDFORM. " PERFORM_CREAPEDIDO
    *&---------------------------------------------------------------------*
    *& Form ejecutabapi
    *&---------------------------------------------------------------------*
    * text
    *----------------------------------------------------------------------*
    * --> p1 text
    * <-- p2 text
    *----------------------------------------------------------------------*
    FORM ejecutabapi .
    DATA: l_ebeln TYPE ekko-ebeln.
    * Se declara para parametro Tabla EXTENSIONIN de la BAPI
    DATA: it_bapi_extension TYPE TABLE OF bapiparex WITH HEADER LINE.

    * Crea Pedido de compra
    CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
    poheader = header
    poheaderx = headerx
    IMPORTING
    exppurchaseorder = l_ebeln
    TABLES
    return = returnerr
    poitem = item
    poitemx = itemx
    poaddrdelivery = iaddrdelivery
    poschedule = itemschedule
    poschedulex = itemschedulex
    pocond = ipocond
    pocondx = ipocondx
    popartner = ipopartner
    extensionin = it_bapi_extension. "INSERT JCP20110909

    ***** Bapi commit work**********
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    wait = 'X'.

    IF l_ebeln IS INITIAL.
    w_error = '1'.
    LOOP AT returnerr.
    t_errores-mov = 'ME21N'.
    t_errores-nrodoc = ' '.
    t_errores-msg = returnerr-message.
    APPEND t_errores.
    ENDLOOP.
    ELSE.
    t_errores-mov = 'ME21N'.
    t_errores-nrodoc = l_ebeln.
    t_errores-msg = 'Pedido de compra creado'.
    APPEND t_errores.
    LOOP AT itemschedule.
    DELETE object_tab WHERE banf1 = itemschedule-preq_no
    AND bnfp1 = itemschedule-preq_item.
    DELETE object_tab2 WHERE banfn = itemschedule-preq_no
    AND bnfpo = itemschedule-preq_item.

    ENDLOOP.
    ENDIF.

    ENDFORM. " ejecutabapi

    *&---------------------------------------------------------------------*
    *& Form MUESTRA_MENSAJES
    *&---------------------------------------------------------------------*
    * text
    *----------------------------------------------------------------------*
    * --> p1 text
    * <-- p2 text
    *----------------------------------------------------------------------*
    FORM muestra_mensajes .
    DATA: l_title(70) TYPE c.
    REFRESH: w_cols.
    * Títulos para reporte de errores
    w_cols-tabname = 'KBLE'.
    w_cols-fieldname = 'RCOBELNR'.
    w_cols-selectflag = 'X'.
    APPEND w_cols.

    w_cols-tabname = 'TSTC'.
    w_cols-fieldname = 'MENUE'.
    w_cols-selectflag = 'X'.
    APPEND w_cols.

    w_cols-tabname = 'BAPIRET2'.
    w_cols-fieldname = 'MESSAGE'.
    w_cols-selectflag = 'X'.
    APPEND w_cols.
    * Titulo de la ventana de errores
    l_title = text-e10.
    * Mostrar errores
    CALL FUNCTION 'MD_POPUP_SHOW_INTERNAL_TABLE'
    EXPORTING
    title = l_title
    TABLES
    values = t_errores
    columns = w_cols
    EXCEPTIONS
    leave = 1
    OTHERS = 2.

    ENDFORM. " MUESTRA_MENSAJES





    desde ya gracias por su respuesta .
  • ruizarreba
    Junior Member
    • sep
    • 23

    #2
    no se ha creado ninguna instancia para el tipo de objeto PurchaseOrder

    Tengo el siguiente error: no se ha creado ninguna instancia para el tipo de objeto PurchaseOrder

    alguien sabe cómo solucionarlo?

    Gracias.

    Comentario

    • ruizarreba
      Junior Member
      • sep
      • 23

      #3
      Finalmente error de autorizaciones...

      Comentario

      • Junior Member
        • feb
        • 1

        #4
        Re: problema BAPI_PO_CCREATE1

        Hola Buen dia, como solventaste este problema?

        Comentario

        Trabajando...