BAPI_PO_CREATE1 Prcicing Conditions

Hi,
     By using BAPI_PO_CREATE1 i can create Purchase orders successfully i am trying to update with pricing condtions by using this function module. Pricing details  are maintained in Purchase order.But the problem same pricing condition is appending while generating another PO. for example if  i created 10 purchase orders successively  in 10 th purchase order same pricing conditions appear 10 times in condition record.
        Can any one suggest the solution for this,
Thanks in Advance
Regards..........KIshore.

{  LOOP AT ITAB.
    MOVE-CORRESPONDING ITAB TO T_POSPLIT.
    APPEND T_POSPLIT.
  ENDLOOP.
  SORT T_POSPLIT BY SNO.
  DELETE ADJACENT DUPLICATES FROM T_POSPLIT COMPARING SNO.
  LOOP AT ITAB.
    MOVE-CORRESPONDING ITAB TO ITAB2.
    APPEND ITAB2.
  ENDLOOP.
  SORT ITAB2 BY SNO.
  DELETE ADJACENT DUPLICATES FROM ITAB2 COMPARING SNO.
  CLEAR : T_POSPLIT, ITAB ,T_POHEADER.
  LOOP AT T_POSPLIT.
    LOOP AT ITAB.
      IF ITAB-SNO = T_POSPLIT-SNO.
        IF ITAB-DOC_TYPE = T_POSPLIT-DOC_TYPE.
*SCHEDULE
*LOOP AT ITAB.
          T_POSCHEDULE-PO_ITEM        = ITAB-PO_ITEM.
          T_POSCHEDULE-DELIVERY_DATE  = ITAB-DELIVERY_DATE.
          APPEND T_POSCHEDULE.
*SCHEDULE X
          T_POSCHEDULEX-PO_ITEM        = ITAB-PO_ITEM.
          T_POSCHEDULEX-PO_ITEMX       = 'X'.
          T_POSCHEDULEX-DELIVERY_DATE  = 'X'.
          APPEND T_POSCHEDULEX.
*ITEM X
          T_POITEMX-PO_ITEM      = ITAB-PO_ITEM.
          T_POITEMX-PO_ITEMX     = 'X'.
          T_POITEMX-PLANT        = 'X'.
          T_POITEMX-STGE_LOC     = 'X'.
          T_POITEMX-TRACKINGNO   = 'X'.
          T_POITEMX-MATERIAL     = 'X'.
          T_POITEMX-QUANTITY      = 'X'.
          T_POITEMX-NET_PRICE    = 'X'.
          T_POITEMX-VAL_TYPE     = 'X'.
          T_POITEMX-TAX_CODE     = 'X'.
          APPEND T_POITEMX.
*Condition
          T_POCOND-ITM_NUMBER  = ITAB-PO_ITEM.
          T_POCOND-COND_TYPE   = ITAB-COND_TYPE.
          T_POCOND-COND_VALUE  = ITAB-COND_VALUE.
         T_POCOND-CURRENCY   = '%'.
          T_POCOND-CHANGE_ID   = 'I'.
          T_POCOND-COND_ST_NO  = '001'.
          T_POCOND-COND_COUNT  = '01'.
          APPEND T_POCOND.
          T_POCONDX-ITM_NUMBER  = ITAB-PO_ITEM.
          T_POCONDX-ITM_NUMBER  = 'X'.
          T_POCONDX-COND_TYPE   = 'X'.
          T_POCONDX-COND_VALUE  = 'X'.
         T_POCOND-CURRENCY    = 'X'.
          T_POCONDX-CHANGE_ID    = 'X'.
          T_POCONDX-COND_ST_NO   = 'X'.
          T_POCONDX-COND_COUNT   = 'X'.
          APPEND T_POCOND.
ITEM
*converting material into BAPI acceptbale format
          CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
            EXPORTING
              INPUT              = ITAB-MATERIAL
           IMPORTING
             OUTPUT             = ITAB-MATERIAL
EXCEPTIONS
  LENGTH_ERROR       = 1
  OTHERS             = 2
          IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          MOVE-CORRESPONDING ITAB TO T_POITEM.
          T_POITEM-EMATERIAL = ' '.
          APPEND T_POITEM.
*ITEM TEXT
          CLEAR W_LNGTXT.
          W_LNGTXT = ITAB-ITMTXT.
IF ITEM HAS LONG TEXT
          CALL FUNCTION 'G_SPLIT_LINE'
            EXPORTING
              INPUT_LINE   = W_LNGTXT
            TABLES
              EXPORT_LINES = T_SPLTITMTXT.
          LOOP AT T_SPLTITMTXT.
            T_POTEXTITEM-PO_ITEM = ITAB-PO_ITEM.
            T_POTEXTITEM-TEXT_FORM = 'ST'.
            T_POTEXTITEM-TEXT_ID = 'F01'.
            MOVE T_SPLTITMTXT-ITMLNGTXT TO T_POTEXTITEM-TEXT_LINE.
            APPEND T_POTEXTITEM.
            CLEAR ITAB.
          ENDLOOP .
        ENDIF.
      ENDIF.
      CLEAR ITAB.
    ENDLOOP.
         ENDLOOP.
         ENDIF.
       ENDIF.
     ENDLOOP.
    LOOP AT ITAB WHERE SNO = T_POSPLIT-SNO AND
      DOC_TYPE = T_POSPLIT-DOC_TYPE.
*IF ITAB-SNO = T_POSPLIT-SNO.
Add leading zeros to VENDOR
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = ITAB-VENDOR
        IMPORTING
          OUTPUT = ITAB-VENDOR.
Add leading zeros to MATERIAL
       CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
         EXPORTING
           INPUT  = ITAB-MATERIAL
         IMPORTING
           OUTPUT = ITAB-MATERIAL.
HEADER
      MOVE-CORRESPONDING ITAB TO T_POHEADER.
      T_POHEADER-PO_NUMBER = ITAB-PONO.
      T_POHEADER-DOC_TYPE = ITAB-DOC_TYPE.
      T_POHEADER-GR_MESSAGE = 'X'.
      APPEND T_POHEADER.
       ENDIF.
    ENDLOOP.
     CLEAR T_POHEADER.
     SORT T_POHEADER BY DOC_TYPE.
     DELETE ADJACENT DUPLICATES FROM T_POHEADER COMPARING DOC_TYPE.
    DESCRIBE TABLE T_POHEADER LINES LNS.
*HEADERX
    DO LNS TIMES.
      T_POHEADERX-PO_NUMBER  = 'X'.
      T_POHEADERX-VENDOR     = 'X'.
      T_POHEADERX-DOC_TYPE   = 'X'.
      T_POHEADERX-CREAT_DATE = 'X'.
      T_POHEADERX-PURCH_ORG  = 'X'.
      T_POHEADERX-PUR_GROUP  = 'X'.
      T_POHEADERX-COMP_CODE  = 'X'.
      T_POHEADERX-GR_MESSAGE = 'X'.
      T_POHEADERX-PMNTTRMS   = 'X'.
      T_POHEADERX-INCOTERMS1 = 'X'.
      T_POHEADERX-INCOTERMS2 = 'X'.
      T_POHEADERX-QUOT_DATE  = 'X'.
      T_POHEADERX-QUOTATION  = 'X'.
      T_POHEADERX-REF_1      = 'X'.
      T_POHEADERX-SALES_PERS = 'X'.
      T_POHEADERX-OUR_REF    = 'X'.
      T_POHEADERX-TELEPHONE  = 'X'.
      APPEND T_POHEADERX.
    ENDDO.
CALL BAPI
    CALL FUNCTION 'BAPI_PO_CREATE1'
      EXPORTING
        POHEADER         = T_POHEADER
        POHEADERX        = T_POHEADERX
      IMPORTING
        EXPPURCHASEORDER = PO_NUMBER
      TABLES
        RETURN           = T_RETURN
        POITEM           = T_POITEM
        POITEMX          = T_POITEMX
        POSCHEDULE       = T_POSCHEDULE
        POSCHEDULEX      = T_POSCHEDULEX
        POCOND           = T_POCOND
        POCONDX          = T_POCONDX
        POTEXTITEM       = T_POTEXTITEM. " ITEM TEXT
**commit WORK and WAIT.
CALL BAPI COMMIT vivek
     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
****EXPORTING
****WAIT =
     IMPORTING
     RETURN = T_RETURN
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        WAIT   = WAIT
      IMPORTING
        RETURN = T_RETURN.
HEADER TEXT UPLOADING
    LOOP AT ITAB2[] INTO ITAB2.
      IF CNTR = ITAB2-SNO.
        READ TABLE ITAB2[] INTO ITAB2 WITH KEY SNO = CNTR.
        T_LINE-TDFORMAT = 'ST'.
        T_LINE-TDLINE = ITAB2-HDRTXT.
        APPEND T_LINE.
INSERT PO HEADER TEXT.
        PERFORM UPLOAD_HDR_TXT USING PO_NUMBER P_HTXT.
      ENDIF.
    ENDLOOP.
    DELETE ITAB2 WHERE SNO = CNTR.
    CNTR = CNTR + 1.
COLLECT GENERATED POs.
    T_PONUMS-PO_NUMBER = PO_NUMBER.
    APPEND T_PONUMS.
    REFRESH T_POHEADER.
    CLEAR T_POHEADER.
    REFRESH T_POHEADERX.
    CLEAR T_POHEADERX.
    REFRESH T_POITEM.
    REFRESH T_POITEMX.
    REFRESH T_POSCHEDULE.
    REFRESH T_POSCHEDULEX.
    REFRESH T_POTEXTITEM.
    REFRESH T_POCOND.
    REFRESH T_POCONDX.
     refresh T_SPLTITMTXT.
***REFRESH T_POTEXTHEADER.
     REFRESH T_POTEXTITEM.
     REFRESH T_LINE.
   ENDAT.
  ENDLOOP.

Similar Messages

  • What values to pass in BAPI BAPI_PO_CREATE1 for conditions

    Hi,
    what necessary values to be passed to conditions tables in bapi BAPI_PO_CREATE1
    tables are :
    POCONDHEADER =
    POCONDHEADERX =
    POCOND =
    POCONDX =
    I am just paassing item number, condition type ,condition value they are reflecting in created PO.
    Helpfull answeres will be rewarded.

    Check this code u will get some idea of how to create a PO
    REPORT  zvk_bapi_po                                                 .
    DATA: s_poheader  LIKE bapimepoheader,
          f_pono      LIKE bapimepoheader-po_number,
          s_poheaderx LIKE bapimepoheaderx,
          s_versions  LIKE bapimedcm,
          t_poitem    LIKE bapimepoitem         OCCURS 0 WITH HEADER LINE,
          t_poitemx   LIKE bapimepoitemx        OCCURS 0 WITH HEADER LINE,
          t_addr      LIKE bapimepoaddrdelivery OCCURS 0 WITH HEADER LINE,
          t_schedule  LIKE bapimeposchedule     OCCURS 0 WITH HEADER LINE,
          t_schedulex LIKE bapimeposchedulx     OCCURS 0 WITH HEADER LINE,
          t_account   LIKE bapimepoaccount      OCCURS 0 WITH HEADER LINE,
          t_accountx  LIKE bapimepoaccountx     OCCURS 0 WITH HEADER LINE,
          t_return    like BAPIRET2             OCCURS 0 WITH HEADER LINE.
    Fill data
    *__ Header
    s_poheader-comp_code   = '1000'.
    s_poheader-doc_type    = 'ZIPS'.
    s_poheader-created_by  = 'XXX'.
    s_poheader-vendor      = '0001000441'.
    s_poheader-purch_org   = 'EC01'.
    s_poheader-pur_group   = '569'.
    s_poheader-currency    = 'USD'.
    s_poheaderx-comp_code   = 'X'.
    s_poheaderx-doc_type    = 'X'.
    s_poheaderx-created_by  = 'X'.
    s_poheaderx-vendor      = 'X'.
    s_poheaderx-purch_org   = 'X'.
    s_poheaderx-pur_group   = 'X'.
    s_poheaderx-currency    = 'X'.
    s_versions-post_date    = '06/05/2006'   .
    s_versions-completed    = 'X'     .
    s_versions-reason       = '0001'     .
    s_versions-description  = 'APPROVED BY KRISH' .
    s_versions-req_by       = 'HBE8328'.
    t_poitem-short_text     =  '0005-000721'.
    t_poitem-plant          =  '5002'.
    t_poitem-trackingno     =  '1000002151'.
    t_poitem-matl_group     =  'MG0001'.
    t_poitem-quantity       =  '8.000'.
    t_poitem-po_unit        =  'EA'.
    t_poitem-orderpr_un     =  'EA'.
    t_poitem-net_price      =  '109.880000000'.
    t_poitem-price_unit     =  '1'.
    t_poitem-acctasscat     =  'K'.
    t_poitem-preq_name      =  'ABC'.
    t_poitemx-po_itemx       =  'X'.
    t_poitemx-short_text     =  'X'.
    t_poitemx-plant          =  'X'.
    t_poitemx-trackingno     =  'X'.
    t_poitemx-matl_group     =  'X'.
    t_poitemx-quantity       =  'X'.
    t_poitemx-po_unit        =  'X'.
    t_poitemx-orderpr_un     =  'X'.
    t_poitemx-net_price      =  'X'.
    t_poitemx-price_unit     =  'X'.
    t_poitemx-acctasscat     =  'X'.
    t_poitemx-preq_name      =  'X'.
    t_addr-name               =  'CoCode 1000'.
    t_addr-name_2             =  'Company Code 1000'.
    t_addr-city               =  'Houston'.
    t_addr-postl_cod1         =  '77020-6237'.
    t_addr-street             =  '4100 Clinton Dr'.
    t_addr-country            =  'US'.
    t_addr-langu              =  'EN'.
    t_addr-region             =  'TX'.
    t_addr-sort1              =  'COCODE 1000'.
    t_addr-sort2              =  'COMPANY CODE 1000'.
    t_addr-time_zone          =  'CST'.
    t_addr-comm_type          =  'INT'.
    t_addr-tel1_numbr         =  '7137534000'.
    t_addr-e_mail             =  '[email protected]'.
    t_addr-countryiso         =  'US'.
    t_addr-langu_iso          =  'EN'.
    t_schedule-sched_line    = '0001'.
    t_schedule-delivery_date = '04/17/2006'.
    t_schedule-quantity      = '8.000'.
    t_schedule-preq_no       = '5000000050'.
    t_schedule-preq_item     = '00010'.
    t_schedulex-sched_line    = '0001'.
    t_schedulex-delivery_date = 'X'.
    t_schedulex-quantity      = 'X'.
    t_schedulex-preq_no       = 'X'.
    t_schedulex-preq_item     = 'X'.
    t_account-serial_no        = '01'.
    t_account-gl_account       = '0000500200'.
    t_account-costcenter       = '1000000297'.
    t_account-gr_rcpt          = '3227'.
    t_account-co_area          = 'CNTC'.
    t_account-profit_ctr       = '1000000297'.
    t_accountx-serial_no        = '01'.
    t_accountx-gl_account       = 'X'.
    t_accountx-costcenter       = 'X'.
    t_accountx-gr_rcpt          = 'X'.
    t_accountx-co_area          = 'X'.
    t_accountx-profit_ctr       = 'X'.
    t_poitem-po_item       = '00000'.
    t_poitemx-po_item      = '00000'.
    t_addr-po_item         = '00000'.
    t_schedule-po_item     = '00000'.
    t_account-po_item      = '00000'.
    t_accountx-po_item     = '00000'.
    DO 50 TIMES.
      t_poitem-po_item       = t_poitem-po_item + 1.
      APPEND t_poitem.
      t_poitemx-po_item      = t_poitemx-po_item + 1.
      APPEND t_poitemx.
    t_addr-po_item         = t_addr-po_item + 1.
    APPEND t_addr.
      t_schedule-po_item     = t_schedule-po_item + 1.
      APPEND t_schedule.
      t_schedulex-po_item    = t_schedulex-po_item + 1.
      APPEND t_schedulex.
      t_account-po_item      = t_account-po_item + 1.
      APPEND t_account.
      t_accountx-po_item     = t_accountx-po_item + 1.
      APPEND t_accountx.
    ENDDO.
    CALL FUNCTION 'BAPI_PO_CREATE1'
      EXPORTING
        poheader         = s_poheader
        poheaderx        = s_poheaderx
        versions         = s_versions
      IMPORTING
        exppurchaseorder = f_pono
    TABLES
       RETURN                       = t_return
       poitem                       = t_poitem
       poitemx                      = t_poitemx
       poaddrdelivery               = t_addr
       poschedule                   = t_schedule
       poschedulex                  = t_schedulex
       poaccount                    = t_account
       poaccountx                   = t_accountx   .
       WRITE: 'PO No:', f_pono.

  • BAPI_PO_CREATE1- pricing conditions

    Hi,
    In general if a info record exists, price will be determined based on that.
    But I need the price to be determined from condition records. Please help me to do that.
    BAPI_PO_CREATE1 consists of parameter POCOND. Can any body tell me in detail what this parameter does?
    Pls get me code if possible.
    regards,
    Ravi
    points will be awarded

    Hi
    <b>Conditions</b>
    Conditions are transferred in the table PoCond; header conditions in the table PoCondHeader. Price determination is reinitiated via the parameter CALCTYPE in the table PoItem.
    <b>Parameter: POCOND</b>
    ITM_NUMBER = 000001
    COND_ST_NO = 001
    COND_TYPE = PB00
    COND_VALUE = 79.900000000
    CURRENCY = EUR
    CURRENCY_ISO = EUR
    COND_UNIT = KG
    COND_P_UNT = 1
    CHANGE_ID = U
    <b>Parameter: POCONDX</b>
    ITM_NUMBER = 000001
    COND_ST_NO = 000
    ITM_NUMBERX = X
    COND_TYPE = X
    COND_VALUE = X
    CURRENCY = X
    CHANGE_ID = X
    Thanks
    Vijay
    <b>PLZ Reward points if helpful</b>

  • What mandatory values to pass in bapi_po_change

    Hi,
    I want to change the Condition value of a material i.e basic value of material in PO.
    what mandatory values required to pass to BAPI_PO_CHANGE.
    pl send along with the sample .example.
    Helpfull ans will be rewarded.
    Note : I am creating po using BAPI_PO_CREATE1. but condition values passing to POCOND are not getting reflected due to Info records that is the reason why i am going for po change.

    hi.
    check this examples.
    REPORT zpo_bapi_purchord_tej.
    DATA DECLARATIONS *
    TYPE-POOLS slis.
    TYPES: BEGIN OF ty_table,
    v_legacy(8),
    vendor TYPE bapimepoheader-vendor,
    purch_org TYPE bapimepoheader-purch_org,
    pur_group TYPE bapimepoheader-pur_group,
    material TYPE bapimepoitem-material,
    quantity(13),
    delivery_date TYPE bapimeposchedule-delivery_date,
    net_price(23),
    plant TYPE bapimepoitem-plant,
    END OF ty_table.
    TYPES: BEGIN OF ty_alv,
    v_legs(8),
    success(10),
    v_legf(8),
    END OF ty_alv.
    TYPES: BEGIN OF ty_alv1,
    v_legf1(8),
    v_msg(500),
    END OF ty_alv1.
    *-----Work area declarations.
    DATA: x_table TYPE ty_table,
    x_header TYPE bapimepoheader,
    x_headerx TYPE bapimepoheaderx,
    x_item TYPE bapimepoitem,
    x_itemx TYPE bapimepoitemx,
    x_sched TYPE bapimeposchedule,
    x_schedx TYPE bapimeposchedulx,
    x_commatable(255),
    x_alv TYPE ty_alv,
    x_alv1 TYPE ty_alv1,
    x_alv2 TYPE ty_alv1.
    *-----Internal table declarations.
    DATA: it_table TYPE TABLE OF ty_table,
    it_commatable LIKE TABLE OF x_commatable,
    it_item TYPE TABLE OF bapimepoitem,
    it_itemx TYPE TABLE OF bapimepoitemx,
    it_sched TYPE TABLE OF bapimeposchedule,
    it_schedx TYPE TABLE OF bapimeposchedulx,
    it_alv TYPE TABLE OF ty_alv,
    it_alv1 TYPE TABLE OF ty_alv1,
    it_alv2 TYPE TABLE OF ty_alv1.
    DATA: po_number TYPE bapimepoheader-po_number,
    x_return TYPE bapiret2,
    it_return TYPE TABLE OF bapiret2,
    v_file TYPE string,
    v_temp(8),
    v_succsount TYPE i VALUE 0,
    v_failcount TYPE i VALUE 0,
    v_total TYPE i.
    DATA: v_temp1(5) TYPE n VALUE 0.
    DATA: x_event TYPE slis_t_event,
    x_fieldcat TYPE slis_t_fieldcat_alv,
    x_list_header TYPE slis_t_listheader,
    x_event1 LIKE LINE OF x_event,
    x_layout1 TYPE slis_layout_alv,
    x_variant1 TYPE disvariant,
    x_repid2 LIKE sy-repid.
    DATA : it_fieldcat TYPE TABLE OF slis_t_fieldcat_alv.
    SELECTION-SCREEN *
    SELECTION-SCREEN BEGIN OF BLOCK v_b1 WITH FRAME.
    *-----To fetch the flat file.
    PARAMETERS: p_file TYPE rlgrap-filename.
    SELECTION-SCREEN END OF BLOCK v_b1.
    AT SELECTION-SCREEN *
    AT SELECTION-SCREEN.
    IF p_file IS INITIAL.
    MESSAGE text-001 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    *-----To use F4 help to find file path.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    IMPORTING
    file_name = p_file.
    v_file = p_file.
    START-OF-SELECTION *
    START-OF-SELECTION.
    PERFORM gui_upload.
    LOOP AT it_table INTO x_table.
    PERFORM header_details.
    v_temp = x_table-v_legacy.
    LOOP AT it_table INTO x_table WHERE v_legacy = v_temp.
    PERFORM lineitem.
    PERFORM schedule.
    ENDLOOP.
    DELETE it_table WHERE v_legacy = v_temp.
    PERFORM bapicall.
    MOVE po_number TO x_alv-success.
    APPEND x_alv TO it_alv.
    CLEAR x_alv.
    *-----To clear the item details in internal table after the operation for a header.
    REFRESH: it_item,
    it_itemx,
    it_sched,
    it_schedx.
    CLEAR: v_temp1.
    ENDLOOP.
    v_total = v_succsount + v_failcount.
    PERFORM display_alv.
    FORM GUI_UPLOAD *
    FORM gui_upload .
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = v_file
    filetype = 'ASC'
    TABLES
    data_tab = it_commatable
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17
    IF sy-subrc = 0.
    *-----To fetch the comma seperated flat file into an internal table.
    LOOP AT it_commatable INTO x_commatable.
    IF x_commatable IS NOT INITIAL.
    SPLIT x_commatable AT ',' INTO
    x_table-v_legacy
    x_table-vendor
    x_table-purch_org
    x_table-pur_group
    x_table-material
    x_table-quantity
    x_table-delivery_date
    x_table-net_price
    x_table-plant.
    APPEND x_table TO it_table.
    ENDIF.
    CLEAR x_table.
    ENDLOOP.
    ENDIF.
    ENDFORM. " gui_upload
    FORM HEADER_DETAILS *
    FORM header_details .
    MOVE 'NB' TO x_header-doc_type.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = x_table-vendor
    IMPORTING
    output = x_table-vendor
    MOVE x_table-vendor TO x_header-vendor.
    MOVE x_table-purch_org TO x_header-purch_org.
    MOVE x_table-pur_group TO x_header-pur_group.
    x_headerx-doc_type = 'X'.
    x_headerx-vendor = 'X'.
    x_headerx-purch_org = 'X'.
    x_headerx-pur_group = 'X'.
    ENDFORM. " header_details
    FORM LINEITEM *
    FORM lineitem .
    v_temp1 = v_temp1 + 10.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = v_temp1
    IMPORTING
    output = v_temp1.
    MOVE v_temp1 TO x_item-po_item.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = x_table-material
    IMPORTING
    output = x_table-material.
    MOVE x_table-material TO x_item-material.
    MOVE x_table-quantity TO x_item-quantity.
    MOVE x_table-net_price TO x_item-net_price.
    MOVE x_table-plant TO x_item-plant.
    x_itemx-po_item = v_temp1.
    x_itemx-material = 'X'.
    x_itemx-quantity = 'X'.
    x_itemx-net_price = 'X'.
    x_itemx-plant = 'X'.
    APPEND x_item TO it_item.
    APPEND x_itemx TO it_itemx.
    CLEAR: x_item, x_itemx.
    ENDFORM. " lineitem1
    FORM SCHEDULE *
    FORM schedule .
    MOVE x_table-delivery_date TO x_sched-delivery_date.
    MOVE v_temp1 TO x_sched-po_item.
    x_schedx-delivery_date = 'X'.
    x_schedx-po_item = v_temp1.
    APPEND x_sched TO it_sched.
    APPEND x_schedx TO it_schedx.
    CLEAR: x_sched, x_schedx.
    ENDFORM. " schedule
    FORM BAPICALL *
    FORM bapicall .
    CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
    poheader = x_header
    poheaderx = x_headerx
    IMPORTING
    exppurchaseorder = po_number
    TABLES
    return = it_return
    poitem = it_item
    poitemx = it_itemx
    poschedule = it_sched
    poschedulex = it_schedx.
    IF po_number IS NOT INITIAL.
    v_succsount = v_succsount + 1.
    MOVE x_table-v_legacy TO x_alv-v_legs.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ELSE.
    v_failcount = v_failcount + 1.
    MOVE x_table-v_legacy TO x_alv-v_legf.
    MOVE x_table-v_legacy TO x_alv1-v_legf1.
    LOOP AT it_return INTO x_return.
    IF x_alv1-v_msg IS INITIAL.
    MOVE x_return-message TO x_alv1-v_msg.
    ELSE.
    CONCATENATE x_alv1-v_msg x_return-message INTO x_alv1-v_msg SEPARATED BY space.
    ENDIF.
    ENDLOOP.
    APPEND x_alv1 TO it_alv1.
    CLEAR x_alv1.
    ENDIF.
    ENDFORM. " bapicall
    FORM DISPLAY_ALV *
    FORM display_alv .
    PERFORM x_list_header.
    PERFORM build_fieldcat CHANGING x_fieldcat.
    x_repid2 = sy-repid.
    x_event1-name = 'TOP_OF_PAGE'.
    x_event1-form = 'TOP_OF_PAGE'.
    APPEND x_event1 TO x_event.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = x_repid2
    is_layout = x_layout1
    it_fieldcat = x_fieldcat
    i_callback_user_command = 'USER_COMMAND'
    i_callback_top_of_page = 'TOP_OF_PAGE'
    i_save = 'A'
    is_variant = x_variant1
    it_events = x_event
    TABLES
    t_outtab = it_alv
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM. " display_master_data
    FORM USER_COMMAND *
    FORM user_command USING ucomm LIKE sy-ucomm selfield
    TYPE slis_selfield.
    READ TABLE it_alv INTO x_alv INDEX selfield-tabindex.
    CLEAR : x_alv2,it_alv2[].
    LOOP AT it_alv1 INTO x_alv1 WHERE v_legf1 = x_alv-v_legf.
    x_alv2 = x_alv1.
    APPEND x_alv2 TO it_alv2 .
    ENDLOOP.
    DATA : it_fieldcat TYPE slis_t_fieldcat_alv.
    DATA : x3_fieldcat LIKE LINE OF it_fieldcat.
    CLEAR : x3_fieldcat,it_fieldcat[].
    CLEAR x3_fieldcat.
    x3_fieldcat-col_pos = '1'.
    x3_fieldcat-fieldname = 'V_LEGF1'.
    x3_fieldcat-reptext_ddic = text-111.
    x3_fieldcat-ref_tabname = 'IT_ALV2'.
    APPEND x3_fieldcat TO it_fieldcat.
    CLEAR x3_fieldcat.
    CLEAR x3_fieldcat.
    x3_fieldcat-col_pos = '1'.
    x3_fieldcat-fieldname = 'V_MSG'.
    x3_fieldcat-reptext_ddic = text-112.
    x3_fieldcat-ref_tabname = 'IT_ALV2'.
    APPEND x3_fieldcat TO it_fieldcat.
    CLEAR x3_fieldcat.
    x_layout1-colwidth_optimize = 'X'.
    x_layout1-zebra = 'X'.
    IF it_alv2[] IS NOT INITIAL.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = x_repid2
    is_layout = x_layout1
    it_fieldcat = it_fieldcat
    i_save = 'A'
    i_callback_top_of_page = 'TOP'
    is_variant = x_variant1
    it_events = x_event
    TABLES
    t_outtab = it_alv2
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    ENDIF.
    ENDFORM.
    FORM USER_COMMAND *
    FORM top.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = 'Commentry'.
    ENDFORM.
    FORM BUILD_FIELDCAT *
    FORM build_fieldcat CHANGING et_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: x1_fieldcat TYPE slis_fieldcat_alv.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '1'.
    x1_fieldcat-fieldname = 'V_LEGS'.
    x1_fieldcat-reptext_ddic = text-108.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '2'.
    x1_fieldcat-fieldname = 'SUCCESS'.
    x1_fieldcat-key = 'X'.
    x1_fieldcat-reptext_ddic = text-109.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '3'.
    x1_fieldcat-fieldname = 'V_LEGF'.
    x1_fieldcat-key = 'X'.
    x1_fieldcat-reptext_ddic = text-110.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    ENDFORM. " build_fieldcat
    FORM BUILD_LIST_HEADER *
    FORM x_list_header.
    DATA: x_list_header1 TYPE slis_listheader.
    *-----List Header: type H
    CLEAR x_list_header1 .
    x_list_header1-typ = 'H'.
    x_list_header1-info = text-105.
    APPEND x_list_header1 TO x_list_header.
    *-----List Key: type S
    x_list_header1-typ = 'S'.
    x_list_header1-key = text-106.
    x_list_header1-info = v_total.
    APPEND x_list_header1 TO x_list_header.
    *-----List Key: Type S
    CLEAR x_list_header1 .
    x_list_header1-typ = 'S'.
    x_list_header1-key = text-107.
    x_list_header1-info = v_succsount.
    APPEND x_list_header1 TO x_list_header.
    ENDFORM. " build_list_header
    FORM TOP_OF_PAGE *
    FORM top_of_page.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = x_list_header.
    ENDFORM. " TOP_OF_PAGE
    REPORT Z_SALES_ORDER_CHANGE
    NO STANDARD PAGE HEADING
    LINE-SIZE 132
    LINE-COUNT 65(0)
    MESSAGE-ID ZZ.
    TABLES: VBAP.
    DATA:
    V_FILEIN(90) TYPE C,
    V_RECIN TYPE I,
    V_RECVBAP TYPE I,
    V_RECORDER TYPE I,
    V_VBELN LIKE VBAP-VBELN,
    ORDERHEADERINX LIKE BAPISDH1X.
    DATA: BEGIN OF I_ORDERS OCCURS 0,
    VBELN LIKE VBAK-VBELN,
    POSNR LIKE VBAP-POSNR,
    BRGEW(18) TYPE C,
    VOLUM(18) TYPE C,
    END OF I_ORDERS.
    DATA: BEGIN OF I_OUTPUT OCCURS 0,
    VBELN LIKE VBAK-VBELN,
    POSNR LIKE VBAP-POSNR,
    GEWEI LIKE VBAP-GEWEI,
    BRGEW LIKE VBAP-BRGEW,
    VOLUM LIKE VBAP-VOLUM,
    CKWGT TYPE C,
    CKVOL TYPE C,
    END OF I_OUTPUT.
    DATA: BEGIN OF ORDERITEMIN OCCURS 0.
    INCLUDE STRUCTURE BAPISDITM.
    DATA: END OF ORDERITEMIN.
    DATA: BEGIN OF ORDERITEMINX OCCURS 0.
    INCLUDE STRUCTURE BAPISDITMX.
    DATA: END OF ORDERITEMINX.
    DATA: BEGIN OF RETURN OCCURS 0.
    INCLUDE STRUCTURE BAPIRET2.
    DATA: END OF RETURN.
    DATA: BEGIN OF BAPIRETURN OCCURS 0.
    INCLUDE STRUCTURE BAPIRET2.
    DATA: END OF BAPIRETURN.
    PARAMETERS:
    P_PATH(45) TYPE C DEFAULT '/usr/users/ftpsapom/' LOWER CASE,
    P_FNAME(32) TYPE C DEFAULT '/sweetjo.txt' LOWER CASE.
    START-OF-SELECTION.
    CONCATENATE PATH AND FILE NAME INTO ONE VARIABLE
    CONCATENATE P_PATH P_FNAME INTO V_FILEIN.
    OPEN DATASET
    IF V_FILEIN IS INITIAL.
    MESSAGE E002 WITH 'FILE' V_FILEIN 'DOES NOT CONTAIN ANY DATA!'.
    ELSE.
    OPEN DATASET V_FILEIN
    FOR INPUT
    IN TEXT MODE.
    IF SY-SUBRC = 0.
    READ DATASET
    DO.
    READ DATASET V_FILEIN INTO I_ORDERS.
    IF SY-SUBRC = 0.
    APPEND I_ORDERS.
    ELSE.
    EXIT.
    ENDIF.
    ENDDO.
    CLOSE DATASET
    CLOSE DATASET V_FILEIN.
    IF SY-SUBRC <> 0.
    MESSAGE E002 WITH 'ERROR - CLOSING' V_FILEIN.
    ENDIF.
    ELSE.
    MESSAGE E002 WITH 'ERROR - COULD NOT OPEN' V_FILEIN.
    ENDIF.
    ENDIF.
    SORT AND REMOVE DUPLICATES FROM I_ORDERS
    SORT I_ORDERS BY VBELN POSNR.
    DELETE ADJACENT DUPLICATES FROM I_ORDERS.
    POPULATE I_OUTPUT
    LOOP AT I_ORDERS.
    SHIFT I_ORDERS-POSNR LEFT DELETING LEADING SPACE.
    CONCATENATE '0' I_ORDERS-POSNR INTO I_ORDERS-POSNR.
    SELECT SINGLE BRGEW VOLUM
    FROM VBAP
    INTO (VBAP-BRGEW, VBAP-VOLUM)
    WHERE VBELN = I_ORDERS-VBELN
    AND POSNR = I_ORDERS-POSNR.
    IF SY-SUBRC = 0.
    IF VBAP-BRGEW = 0.
    I_OUTPUT-CKWGT = 'X'.
    ENDIF.
    IF VBAP-VOLUM = 0.
    I_OUTPUT-CKVOL = 'X'.
    ENDIF.
    I_OUTPUT-VBELN = I_ORDERS-VBELN.
    I_OUTPUT-POSNR = I_ORDERS-POSNR.
    I_OUTPUT-GEWEI = 'ST'.
    I_OUTPUT-BRGEW = I_ORDERS-BRGEW.
    I_OUTPUT-VOLUM = I_ORDERS-VOLUM.
    APPEND I_OUTPUT.
    CLEAR: I_OUTPUT.
    ENDIF.
    V_RECIN = V_RECIN + 1.
    ENDLOOP.
    POPULATE BAPI DATA AND RUN BAPI
    CLEAR: ORDERHEADERINX, ORDERITEMIN, ORDERITEMINX,
    RETURN, BAPIRETURN.
    REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.
    ORDERHEADERINX-UPDATEFLAG = 'U'.
    LOOP AT I_OUTPUT WHERE CKWGT = 'X' OR CKVOL = 'X'.
    V_RECVBAP = V_RECVBAP + 1.
    IF I_OUTPUT-VBELN <> V_VBELN AND SY-TABIX <> 1.
    V_RECORDER = V_RECORDER + 1.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    SALESDOCUMENT = V_VBELN
    ORDER_HEADER_INX = ORDERHEADERINX
    TABLES
    RETURN = RETURN
    ORDER_ITEM_IN = ORDERITEMIN
    ORDER_ITEM_INX = ORDERITEMINX.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT = 'X'
    IMPORTING
    RETURN = BAPIRETURN.
    WRITE OUT RETURN
    LOOP AT RETURN.
    WRITE: / RETURN.
    ENDLOOP.
    WRITE: / BAPIRETURN.
    SKIP.
    CLEAR: ORDERITEMIN, ORDERITEMINX,
    RETURN, BAPIRETURN.
    REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.
    ENDIF.
    ORDERITEMIN-ITM_NUMBER = I_OUTPUT-POSNR.
    ORDERITEMIN-UNTOF_WGHT = I_OUTPUT-GEWEI.
    IF NOT I_OUTPUT-CKWGT IS INITIAL.
    ORDERITEMIN-GROSS_WGHT = I_OUTPUT-BRGEW.
    ORDERITEMINX-GROSS_WGHT = 'X'.
    ENDIF.
    IF NOT I_OUTPUT-CKVOL IS INITIAL.
    ORDERITEMIN-VOLUME = I_OUTPUT-VOLUM.
    ORDERITEMINX-VOLUME = 'X'.
    ENDIF.
    APPEND ORDERITEMIN.
    ORDERITEMINX-ITM_NUMBER = I_OUTPUT-POSNR.
    ORDERITEMINX-UNTOF_WGHT = 'X'.
    ORDERITEMINX-UPDATEFLAG = 'U'.
    APPEND ORDERITEMINX.
    V_VBELN = I_OUTPUT-VBELN.
    ENDLOOP.
    RUN BAPI ON LAST ORDER
    IF NOT ORDERITEMIN IS INITIAL.
    V_RECORDER = V_RECORDER + 1.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    SALESDOCUMENT = V_VBELN
    ORDER_HEADER_INX = ORDERHEADERINX
    TABLES
    RETURN = RETURN
    ORDER_ITEM_IN = ORDERITEMIN
    ORDER_ITEM_INX = ORDERITEMINX.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT = 'X'
    IMPORTING
    RETURN = BAPIRETURN.
    WRITE OUT RETURN
    LOOP AT RETURN.
    WRITE: / RETURN.
    ENDLOOP.
    WRITE: / BAPIRETURN.
    SKIP.
    ENDIF.
    WRITE OUT RECORD COUNT FROM FILE
    WRITE: / 'RECORD COUNT FROM FILE ', V_RECIN.
    SKIP.
    WRITE OUT RECORD COUNT FROM FILE
    WRITE: / 'RECORD COUNT OF LINES TO CHANGE ', V_RECVBAP.
    SKIP.
    WRITE OUT RECORD COUNT FROM FILE
    WRITE: / 'RECORD COUNT OF ORDERS TO CHANGE ', V_RECORDER.
    SKIP.
    TOP OF PAGE
    TOP-OF-PAGE.
    WRITE:/1(5) TEXT-H01, 6(8) SY-DATUM MM/DD/YY,
    100(8) TEXT-H02, 126(8) SY-PAGNO.
    WRITE:/1(5) TEXT-H03, 6(8) SY-UZEIT USING EDIT MASK '__:__:__',
    20(77) TEXT-H04,
    100(8) TEXT-H05, 108(25) SY-REPID.
    WRITE:/1(6) TEXT-H06, 8(12) SY-UNAME,
    20(4) TEXT-H07, 25(32) SY-HOST,
    100(13) TEXT-H08, 121(8) SY-SYSID,
    129 '/', 130(3) SY-MANDT.
    ULINE.
    SKIP.
    regards.
    sowjanya.b

  • PO updation after GR

    Dear Expert
    we want to update the conditions of PO ,  after the reversal of  GR  but System is not allowing any changes in the Condition of the PO .Is it a standard SAP behaviour then if so then must be some sap notes on the same , please provide the SAP note otherwise please provide the setting which i have do , so that condition can be updated after GR reversal .
    Regards

    hi,
    check few notes:
    439110
    622634 - BAPI_PO_CHANGE: New PD despite follow-on documents
    582252 - BAPI_PO_CREATE1/..._CHANGE: Header conditions are incorrect
    549843 - BAPI_PO_CREATE: Technical fields available
    539950 - BAPI_PO_CREATE1: n condition records for a condition type
    537221 - BAPI_PO_...: Conversion factors incorrect for conditions
    529531 - BAPI_PO_CHANGE: New pricing is no longer possible (V1227)
    529287 - BAPI_PO_CHANGE: Price merge is not possible
    428621 - EnjoySAP purchase order BAPIs - price det. & cond. change
    425996 - BAPI_PO_CREATE1: Termination msge 00151 w/ header conditions
    399791 - Enjoy-BAPI_PO...: Condition values are not transferred
    197958 - BAPIs for purchase orders - Missing functions

  • Problem in conditions pricing updation using BAPI_PO_CREATE1

    hi,
        I am creating PO using BAPI_PO_CREATE1 however when i am passing the data to the bapi for conditions at item level the price value is not changing and throwing error as ( NET PRICE FOR ITEM 00010 adopted from last document ) so for all the items its throwing the same information and when i am chekin the PO the value is not the changing. and while creating the PO manually also the net price is coming automatically and we need to backspace the value and re enter the new value. So wht should i do in order to input the data into the PO.
    Thanks in advance

    Thanks

  • BAPI_PO_CREATE1 Condition pricing problem

    Hi Experts,
    I  created the PO through BAPI_PO_CREAE1 according to the below code. In that PO which i created default  condition type "PBXX".But i want condition Type "PB00".so in my BAPI condtion table POCOND i gave  "U" [ POCOND-change_id = 'U' (update) ].But the default "PBXX" is again coming.
    when i give POCOND-change_id = 'I'  (insert)  two condition types are coming(PB00 & PBXX).
    I referred  our forum(sdn) throughly.I won't get solution.
      data: del_date type sy-datum.
    data: ORDER_HEADERS_OUT like BAPISDHD OCCURS 0 WITH HEADER LINE.
    data: ORDER_ITEMS_OUT like BAPISDIT OCCURS 0 WITH HEADER LINE.
    data: ORDER_SCHEDULES_OUT like BAPISDHEDU OCCURS 0 WITH HEADER LINE.
    data: ORDER_PARTNERS_OUT like BAPISDPART OCCURS 0 WITH HEADER LINE.
    data: ORDER_COND_HEAD like BAPICONDHD OCCURS 0 WITH HEADER LINE.
    data: ORDER_COND_ITEM like BAPICONDIT OCCURS 0 WITH HEADER LINE.
    data: ORDER_TEXTHEADERS_OUT like BAPISDTEHD OCCURS 0 WITH HEADER LINE.
    datA: ORDER_TEXTLINES_OUT like BAPITEXTLI OCCURS 0 WITH HEADER LINE.
    data: I_BAPI_VIEW like ORDER_VIEW OCCURS 0 WITH HEADER LINE.
      data: pohead  type bapimepoheader.
      data: poheadx type bapimepoheaderx.
      data: exp_head type bapimepoheader.
      data: return  type table of bapiret2 with header line.
      data: poitem  type table of bapimepoitem with header line.
      data: poitemx type table of bapimepoitemx with header line.
      data: posched  type table of bapimeposchedule with header line.
      data: poschedx type table of bapimeposchedulx with header line.
    data : POTEXTHEADER type table of BAPIMEPOTEXTHEADER with header line .
    data: POTEXTITEM type table of BAPIMEPOTEXT with header line.
    *data: POTEXTITEMx type table of BAPIMEPOTEXTx with header line.
    DATA: POCOND TYPE table of BAPIMEPOCOND with header line.
    DATA: POCONDX TYPE TABLE OF BAPIMEPOCONDX WITH HEADER LINE.
      data: ex_po_number type bapimepoheader-po_number.
    data: itno type i.
    i_bapi_view-HEADER = 'X'.
    i_bapi_view-ITEM = 'X'.
    i_bapi_view-SDSCHEDULE = 'X'.
    i_bapi_view-PARTNER = 'X'.
    i_bapi_view-SDCOND = 'X'.
    i_bapi_view-SDCOND_ADD = 'X'.
    i_bapi_view-TEXT = 'X'.
    *i_bapi_view- = 'X'.
    APPEND I_BAPI_VIEW.
    DATA: SONO LIKE SALES_KEY OCCURS 0 WITH HEADER LINE..
    SONO-VBELN = '0001014145'.
    APPEND SONO.
    CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'
      EXPORTING
        i_bapi_view                   = I_BAPI_VIEW
      I_MEMORY_READ                 =
      tables
        sales_documents               = SONO
       ORDER_HEADERS_OUT             =  ORDER_HEADERS_OUT
       ORDER_ITEMS_OUT               =   ORDER_ITEMS_OUT
       ORDER_SCHEDULES_OUT           =  ORDER_SCHEDULES_OUT
      ORDER_BUSINESS_OUT            =
       ORDER_PARTNERS_OUT            =   ORDER_PARTNERS_OUT
      ORDER_ADDRESS_OUT             =
      ORDER_STATUSHEADERS_OUT       =
      ORDER_STATUSITEMS_OUT         =
      ORDER_CONDITIONS_OUT          =
       ORDER_COND_HEAD               =  ORDER_COND_HEAD
       ORDER_COND_ITEM               = ORDER_COND_ITEM
      ORDER_COND_QTY_SCALE          =
      ORDER_COND_VAL_SCALE          =
      ORDER_CONTRACTS_OUT           =
       ORDER_TEXTHEADERS_OUT         = ORDER_TEXTHEADERS_OUT
       ORDER_TEXTLINES_OUT           = ORDER_TEXTLINES_OUT
    BREAK-POINT.
      pohead-comp_code = 'SG20'.
      pohead-doc_type   = 'NB'     .
      pohead-creat_date = sy-datum   .
      pohead-vendor = '0000100040'.
      pohead-purch_org = 'SG20'.
      pohead-pur_group = '001'.
      pohead-langu      = sy-langu   .
      pohead-doc_date   = sy-datum.
      poheadx-comp_code  = c_x.
      poheadx-doc_type   = c_x.
      poheadx-creat_date = c_x.
      poheadx-vendor     = c_x.
      poheadx-langu      = c_x.
      poheadx-purch_org  = c_x.
      poheadx-pur_group  = c_x.
      poheadx-doc_date   = c_x.
    *POTEXTITEM-PO_ITEM = itno.
    *POTEXTITEM-TEXT_ID =
    *POTEXTITEM-TEXT_FORM
    POTEXTHEADER-TEXT_LINE = SONO.
    append POTEXTHEADER.
    Item Level Data
    itno = 10.
    loop at   ORDER_ITEMS_OUT.
      poitem-po_item  = itno.
      poitem-material = ORDER_ITEMS_OUT-material.
      poitem-plant    = 'SG20'.
      poitem-stge_loc = 'SA01'.
      poitem-quantity = ORDER_ITEMS_OUT-REQ_QTY .
      POITEM-NET_PRICE = ORDER_ITEMS_OUT-NET_PRICE.
      append poitem.
      poitemx-po_item    = itno.
      poitemx-po_itemx   = c_x.
      poitemx-material   = c_x.
      poitemx-plant      = c_x .
      poitemx-stge_loc   = c_x .
      poitemx-quantity   = c_x .
      poitemx-tax_code   = c_x .
      poitemx-item_cat   = c_x .
      poitemx-acctasscat = c_x .
      POITEMX-NET_PRICE = C_X.
      append poitemx.
    POTEXTITEM-PO_NUMBER =
    POTEXTITEM-PO_ITEM = itno.
    POTEXTITEM-TEXT_ID = 'F01'.
    *POTEXTITEM-TEXT_FORM
    POTEXTITEM-TEXT_LINE = SONO.
    append POTEXTITEM.
    POCOND-itm_number = ITNO.
    POCOND-cond_st_no = '001'.
    POCOND-COND_COUNT = '01'.
    POCOND-cond_type = 'PB00'.
    POCOND-cond_value = ORDER_ITEMS_OUT-REQ_QTY.
    POCOND-currency = ORDER_ITEMS_OUT-CURRENCY.
    POCOND-CONDISACTI = ' '.
    POCOND-COND_UPDAT = 'X'.
    POCOND-change_id = 'U'.
    APPEND pocond.
    POCONDX-itm_number = ITNO.
    POCONDX-cond_st_no = '001'.
    POCONDX-cond_st_nox = 'X'.
    POCONDX-itm_numberx = 'X'.
    POCONDX-COND_COUNT = 'X'.
    POCONDX-cond_type = 'X'.
    POCONDX-cond_value = 'X'.
    POCONDX-currency = 'X'.
    POCONDX-CONDISACTI =  'X'.
    POCONDX-change_id = 'X'.
    POCONDX-COND_UPDAT = 'X'.
    APPEND POCONDX.
      itno = itno + 10.
    endloop.
      call function 'BAPI_PO_CREATE1'
           EXPORTING
                poheader         = pohead
                poheaderx        = poheadx
                testrun          = ' '
           IMPORTING
                exppurchaseorder = ex_po_number
                expheader        = exp_head
           TABLES
                return           = return
                poitem           = poitem
                poitemx          = poitemx
                poschedule       = posched
                poschedulex      = poschedx
       POTEXTHEADER                 = POTEXTHEADER
       POTEXTITEM   = POTEXTITEM
    POCOND                       = POCOND
        POCONDX                     = POCONDX .
      call function 'BAPI_TRANSACTION_COMMIT'
           EXPORTING
                wait = 'X'.
      if not ex_po_number is initial.
        call function 'DEQUEUE_ALL'.
      else.
        call function 'DEQUEUE_ALL'.
       message i036.
      endif.
      WRITE: / EX_PO_NUMBER.

    Hi Vioth,
          Did you got solution for thsi i am also facing the same problem.If you konw the solution kindly suggest the solution for this
    Thanks in Adavce,
    Regards...............Kishore

  • BAPI_PO_CREATE1 Service Positions and Conditions with reference to P. Req.

    Hello together,
    i have the following problem. I used the BAPI BAPI_PO_CREATE1 to create Purchase Orders with reference to a purchase requsition. I have 2 different types of purchase requsitions. One with normal items and one with services.
    So for both the creation of the purchase order works but if i add Conditions on Serivce Item Level to the purchase requsition they are not transfered to the purchase order.
    To eliminate misunderstandings in a purchase order there are 3 diffent typs of conditions possible. First on header Level of the purchase order which can easly be filled with BAPI. The second on item level of the purchase order with can also easily be filled with BAPI and the last on service level which i doesn't found in BAPI. May be someone has an idea how to fill these conditions.
    Here is my code:
      header-doc_date = wa_eban-erdat.
      value = 10.
    Set COMP_CODE
      select single bwkey from t001w into lv_bwkey
                    where werks = wa_eban-werks.
      select single bukrs from t001k into header-comp_code
                    where bwkey = lv_bwkey.
      header-doc_type = wa_eban-bsart.
      header-vendor = wa_eban-flief.
      header-created_by = sy-uname.
      header-purch_org = wa_eban-ekorg.
      header-pur_group = wa_eban-ekgrp.
      header-langu = sy-langu.
      header-status = 'B'.
      header-indx = header-indx + 1.
      append header.
      headerx-doc_type = 'X'.
      headerx-comp_code = 'X'.
      headerx-vendor = 'X'.
      headerx-purch_org = 'X'.
      headerx-created_by = 'X'.
      headerx-pur_group = 'X'.
      headerx-created_by = 'X'.
      headerx-langu = 'X'.
      headerx-status = 'X'.
      headerx-indx = header-indx.
      append headerx.
    *!-- Populating the BAPI for PO Item data
      poitems-po_item = value.
      poitems-material = wa_eban-matnr.
      poitems-stge_loc = wa_eban-lgort.
      poitems-plant = wa_eban-werks.
      poitems-item_cat = wa_eban-pstyp.
      poitems-po_unit = wa_eban-meins.
      poitems-quantity = wa_eban-menge - wa_eban-bsmng.
      poitems-preq_no = wa_eban-banfn.
      poitems-preq_item = wa_eban-bnfpo.
      poitems-tax_code = wa_eban-yy_mwskz.
      poitems-indx = header-indx.
      poitemsx-po_item = value.
      poitemsx-material = 'X'.
      poitemsx-stge_loc = 'X'.
      poitemsx-plant = 'X'.
      poitemsx-item_cat = 'X'.
      poitemsx-preq_no = 'X'.
      poitemsx-preq_item = 'X'.
      poitemsx-po_unit = 'X'.
      poitemsx-quantity = 'X'.
      poitemsx-tax_code = 'X'.
      poitemsx-indx = header-indx.
    Create Construction with Services
      if wa_eban-bsart eq 'ZXXXX.
        poitemsx-pckg_no = 'X'.
        poitems-pckg_no = wa_eban-packno.
      endif.
      append poitems.
      append poitemsx.
    *!-- Populating the BAPI for PO Item Schedule data
      scd-po_item = value.
      scd-sched_line = value1.
      scd-delivery_date = wa_eban-lfdat.
      scd-quantity = wa_eban-menge - wa_eban-bsmng.
      scd-indx = header-indx.
      append scd.
      scdx-po_item = value.
      scdx-sched_line = value1.
      scdx-delivery_date = 'X'.
      scdx-quantity = 'X'.
      scdx-indx = header-indx.
      append scdx.
    *!-- Populating the BAPI for PO Item data for Accounting
      account-po_item = value.
      account-quantity = wa_eban-menge - wa_eban-bsmng.
      account-indx = header-indx.
      accountx-po_item = value.
      accountx-quantity = 'X'.
      accountx-indx = header-indx.
    Create Construction with Services
      if wa_eban-bsart eq 'ZXXX.
        account-costcenter = wa_ebkn-kostl.
        account-gl_account = wa_ebkn-sakto.
        account-orderid = wa_ebkn-aufnr.
        select single posid from prps into account-wbs_element where pspnr = wa_ebkn-ps_psp_pnr .
        account-serial_no = wa_ebkn-zebkn.
        accountx-costcenter = 'X'.
        accountx-gl_account = 'X'.
        accountx-orderid = 'X'.
        accountx-wbs_element = 'X'.
        accountx-serial_no = 'X'.
      endif.
      append account.
      append accountx.

    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/rfc%2bpurchase%2border%2bcreation%2bfm%2bfrom%2bariba
    cheers
    Aveek

  • Problem in Conditions while using BAPI_PO_CREATE1

    Hi All
    I am using BAPI_PO_CREATE1 to create purchase Order. When I am changing calculation type for condition type's system not picking the correct amount through BAPI.
    For e.g. for condition type 'FRB1' (Freight Value) I have maintain the amount 10.00 in condition value for calculation type 'B' (fixed amount). But when I pass calculation type 'A' i.e. Percentage, BAPI overwrites the amount to 1.00%.
    I Want to pass the amount 10.00 as it is with calculation type '%'. Kindly suggest how to do it.
    Regards,
    Pradip

    Hi All
    I am using BAPI_PO_CREATE1 to create purchase Order. When I am changing calculation type for condition type's system not picking the correct amount through BAPI.
    For e.g. for condition type 'FRB1' (Freight Value) I have maintain the amount 10.00 in condition value for calculation type 'B' (fixed amount). But when I pass calculation type 'A' i.e. Percentage, BAPI overwrites the amount to 1.00%.
    I Want to pass the amount 10.00 as it is with calculation type '%'. Kindly suggest how to do it.
    Regards,
    Pradip

  • How to pass the condition vallues in bapi BAPI_PO_CREATE1 for items as well

    HI,
    where to pass the condition value table in bapi BAPI_PO_CREATE1 item level as well as header level
    Like Frieght charges,discounts, basic price ,VAT,CST etc.
    Is there any BAPI for GR tcode MIGO.
    Pl send along with simple examples .
    Your answeres will be rewarded.

    Pass the condition value to the following parameters.
      POCONDHEADER                 =
      POCONDHEADERX                =
      POCOND                       =
      POCONDX                      =
    For GR u case use the following BAPI.
    GMCODE Table T158G - 01 - MB01 - Goods Receipts for Purchase Order
                         02 - MB31 - Goods Receipts for Prod Order
                         03 - MB1A - Goods Issue
                         04 - MB1B - Transfer Posting
                         05 - MB1C - Enter Other Goods Receipt
                         06 - MB11
    Domain: KZBEW - Movement Indicator
         Goods movement w/o reference
    B - Goods movement for purchase order
    F - Goods movement for production order
    L - Goods movement for delivery note
    K - Goods movement for kanban requirement (WM - internal only)
    O - Subsequent adjustment of "material-provided" consumption
    W - Subsequent adjustment of proportion/product unit material
             call function 'BAPI_GOODSMVT_CREATE'
               exporting
                   goodsmvt_header             = gmhead
                   goodsmvt_code               = gmcode
                 *   TESTRUN                     = ' '
              IMPORTING
                  goodsmvt_headret            = mthead
             *   MATERIALDOCUMENT            =
      MATDOCUMENTYEAR             =
               tables
                 goodsmvt_item               = itab
      GOODSMVT_SERIALNUMBER       =
                return                      = errmsg.

  • BAPI_PO_CREATE1 condition type are creating duplicate records

    Hello Experts,
    Currently I am creating Purchase orders using BAPI_PO_CREATE1 . When I am passing Condition related records to the same BAPI , second line item onwards , it creates multiple records of same condition type .
    I have also looked into threads in SDN for the same , and they have suggested to create PO using BAPI_PO_CREATE and later use BAPI_PO_CHANGE to pass condition records. I have tried the same , but still second line item onwards it creates multiple records. Please tell me how do I resolve this issue.
    Thanks
    Trishna

    Hello All,
    This duplicate condition record creation may happen due to a setting in the MM configuration, where the system tries to pull in the history condition records ,based on the same set of condition record determination parameters.
    Please contact the MM functional consultant in your team for settings change in detrmination of condition records under " MM-Purchasing " section.
    Best Regards,
    Kumaar.S

  • Submit new Item Conditions via Function Module BAPI_PO_CREATE1

    Hi all,
    I have problems using FM BAPI_PO_CREATE1.
    I want to transfer Item conditions via FM, but I am not able to change the netprice via FM, my Conditions are not displayed within the Item (only netprice of Item is displayed).
    I create POs out of a SRM System via FM BBP_PO_INBOUND (which calls BAPI_PO_CREATE1).
    My question:
    Has anyone an example how to fill in data within table POCOND so that my PO item contains for example a gross price and a rebate.
    I am stucked, I can´t find the solution to create item conditions via FM BAPI_PO_CREATE1.
    Any examples?
    Thanks a lot
    Regards
    Andreas

    Problem resolved
    I used the FBGENDAT param in R/3 system to generate test data automatically, compare the data and finally I found my error.
    --> OSS note 539978
    Regards
    Andreas

  • CONDITIONS IN BAPI_PO_CREATE1

    Hi, dear experts.
    Does anybody know how to fill correctly conditions in BAPI interface? I`d successfully use a field named "Condition amount" (POCOND-COND_VALUE in TABLES interface), but I need to use "Condition value". How can I fill it? In ME21N ("Conditions" tab) we are able to fill both a left field ("Condition amount" POCOND-COND_VALUE in TABLES interface) and a right field ("Condition value"), but in  BAPI I can`t fill a right field.

    Hi
    If you see the Function module documentation of BAPI_PO_CREATE1, you can see a example
    Regards
    Madhan D

  • Validating vendors in PO item conditions of BAPI_PO_CREATE1

    Hai friends,
    BAPI_PO_CREATE1 is not validating the vendors of item level conditions(BAPIMEPOCOND-VENDOR_NO).
    But I have to validate those vendors existed in SAP or not. please help me.
    regards,
    Eswar.

    before passing the data to any screen using bdc(session method or call transaction) or bapi methods you need to validate the data from its check tables say you asked the vendors is not validating u should check the data from lfa1 table whether the vendors are available or not this is nothing but data clensing.
    and each record entered in the bapi function module should be fully data validated i.e the data should 99.99% save in the data base table of concerned tables like ekko,ekpo in this case ie. this is nothing but data prusing.
    write select statements to lfa1 table & delete the records if in flat file given there is no vendors matched to database tables before passing the vendors to bapi_po_create functionmodule

  • Problem with condition type in BAPI_PO_CREATE1

    Hi All,
    I am uploading the data for txn ME21N through BAPI_PO_CREATE1.
    Whenever i m testing this bapi it is giving PO no. but Codition types are not getting update neither on header level nor on item level.
    Header Condition type and Condition value ,I am giving in Structures POCONDHEADER, POCONDHEADERX and Item Condition type and Condition value , i  am giving in structures POCOND,POCONDX.
    Thanx in Advance.
    Regards,
    Shiv Kant

    Take a look in this example:
        ADD 10 TO v_item.
        e_poheader-comp_code   = t_cabec-bukrs.
        e_poheader-doc_type    = 'EC'.
        e_poheader-vendor      = t_cabec-lifnr.
        e_poheader-creat_date  = sy-datum.
        e_poheader-created_by  = sy-uname.
        e_poheader-item_intvl  = '0010'.
        e_poheader-langu       = sy-langu.
        e_poheader-langu_iso   = sy-langu.
        e_poheader-incoterms1 = t_cabec-inco1.
        e_poheader-incoterms2 = t_cabec-inco2.
        e_poheader-currency   = t_cabec-waers.
        e_poheader-purch_org  = v_ekorg.
        e_poheader-pur_group  = t_saida3-ekgrp.
        e_poheader-pmnttrms   = t_cabec-zterm.
        e_poheader-telephone  = t_cabec-telf1.
        e_poheader-sales_pers = t_cabec-verkf.
        e_poheaderx-comp_code   = 'X'.
        e_poheaderx-doc_type    = 'X'.
        e_poheaderx-vendor      = 'X'.
        e_poheaderx-creat_date  = 'X'.
        e_poheaderx-created_by  = 'X'.
        e_poheaderx-item_intvl  = 'X'.
        e_poheaderx-langu       = 'X'.
        e_poheaderx-langu_iso   = 'X'.
        e_poheaderx-incoterms1 =  'X'.
        e_poheaderx-incoterms2 =  'X'.
        e_poheaderx-currency   = 'X'.
        e_poheaderx-purch_org  = 'X'.
        e_poheaderx-pur_group  = 'X'.
        e_poheaderx-pmnttrms   = 'X'.
        e_poheaderx-telephone  = 'X'.
        e_poheaderx-sales_pers = 'X'.
        IF t_saida3-elem_pep IS NOT INITIAL.
          MOVE 'P' TO t_saida3-knttp.
        ELSEIF t_saida3-aufnr IS NOT INITIAL.
          MOVE 'F' TO t_saida3-knttp.
        ELSEIF t_saida3-kostl IS NOT INITIAL.
          MOVE 'K' TO t_saida3-knttp.
        ENDIF.
        t_poitem-po_item      = v_item.
        t_poitem-plant        = s_werks.
        t_poitem-short_text   = t_saida3-txz01.
        t_poitem-quantity     = t_saida3-menge.
        t_poitem-po_unit     = t_saida3-meins.
        t_poitem-acctasscat   = t_saida3-knttp.
        t_poitem-matl_group   = t_saida3-matkl.
        t_poitem-tax_code     = t_saida3-mwskz.
        t_poitem-order_reason = t_saida3-bsgru.
        t_poitem-indus3       = t_saida3-j_1bindus3.
        t_poitem-matl_usage   = t_saida3-j_1bmatuse.
        t_poitem-mat_origin   = t_saida-j_1bmatorg.
        t_poitem-item_cat     = t_saida-epstp.
        t_poitem-net_price    = t_saida3-netpr.
        t_poitem-price_unit   = t_saida3-peinh.
        t_poitem-bras_nbm     = t_saida3-j_1bnbmco1.
        t_poitem-PREQ_NAME    = t_saida3-requisitante.
         APPEND t_poitem.
        t_poitemx-po_item      = v_item.
        t_poitemx-plant        = 'X'.
        t_poitemx-short_text   = 'X'.
        t_poitemx-quantity     = 'X'.
        t_poitemx-po_unit      = 'X'.
        t_poitemx-acctasscat   = 'X'.
        t_poitemx-matl_group   = 'X'.
        t_poitemx-tax_code     = 'X'.
        t_poitemx-order_reason = 'X'.
        t_poitemx-indus3       = 'X'.
        t_poitemx-matl_usage   = 'X'.
        t_poitemx-mat_origin   = 'X'.
        t_poitemx-item_cat     = 'X'.
        t_poitemx-net_price    = 'X'.
        t_poitemx-price_unit   = 'X'.
        t_poitemx-bras_nbm     = 'X'.
        t_poitemx-preq_name    = 'X'.
        APPEND t_poitemx.
        t_schedule-po_item = v_item.
        t_schedule-del_datcat_ext = '1'.
        t_schedule-delivery_date = v_data.
        t_schedule-del_datcat_ext = 'D'.
        t_schedule-quantity = t_saida3-menge.
        APPEND t_schedule.
        t_schedulx-po_item = v_item.
        t_schedulx-del_datcat_ext = 'X'.
        t_schedulx-delivery_date = 'X'.
        t_schedulx-del_datcat_ext = 'X'.
        t_schedulx-quantity = 'X'.
        APPEND t_schedulx.
        t_account-po_item = v_item.
        t_account-gl_account = t_saida3-saknr.
        t_account-wbs_element = t_saida3-elem_pep.
        t_account-costcenter  = t_saida3-kostl.
        t_account-orderid     = t_saida3-aufnr.
        t_account-gr_rcpt     = t_saida3-recebedor.
        t_account-unload_pt   = t_saida3-pdescarga.
        APPEND t_account.
        t_accountx-po_item = v_item.
        t_accountx-gl_account  = 'X'.
        t_accountx-wbs_element = 'X'.
        t_accountx-costcenter  = 'X'.
        t_accountx-orderid     = 'X'.
        t_accountx-gr_rcpt     = 'X'.
        t_accountx-unload_pt    = 'X'.
        APPEND t_accountx.
      CALL FUNCTION 'BAPI_PO_CREATE1'
        EXPORTING
          poheader         = e_poheader
          poheaderx        = e_poheaderx
          testrun          = ' '
        IMPORTING
          exppurchaseorder = v_pedido
        TABLES
          return           = t_bapiret2
          poitem           = t_poitem
          poitemx          = t_poitemx
          poschedule       = t_schedule
          poschedulex      = t_schedulx
          poaccount        = t_account
          poaccountx       = t_accountx
          potextitem       = t_textitem
          potextheader     = t_textheader.

Maybe you are looking for

  • Slwo to Come Out of Stand By after OS2 Upgrade

    Ladies and Gentlemen: Ever since I upgraded my 16 GB PlayBook to OS2, it has been very slow - sometimes up to 17 seconds - to come out of stand by.  Has anyone else run into this?  Any ideas as to how to speed things up a bit?  It was pretty well ins

  • Working with offline resolution

    When you edit a project in an offline resolution, how do you create elements in Photoshop and other programs that you do not want to recreate? For example, I have a project that is being shot on HDCAM (1080i), and will finally end up on DigiBeta and

  • Scaling and Resizing

    Hi, I use a ProgressIndicator in MigLayout (JavaFX version, see http://www.miglayout.com/). Now, if I scale the ProgressIndicator, its size does not change. In other words, MigPane still uses the non-scaled size to layout the components. Is this a la

  • Deployment Unlicensed captivate 8

    Hello, I work for a big company. I'm a software packager/deployer. I am having big issues with this product. What i want to do is very simple : I want a completely silent installation for my users that they will license themselves. We use individual

  • Help in writing stored procedrue

    I have a table with records like below ccn item sub_item 1 101a 102a 2 102a 103a 3 103a 104a 4 100x 100y 5 100y 100z 6 101b 101c and need to load above data into other table like below p_id p_item p_sub_item p_old_item f_code f_seq_no 1 101a 102a (nu