Skip to Content
author's profile photo Former Member
Former Member

BAPI_PO_CHANGE

Hi friends i am changing the purchase order data using BAPI_PO_CHANGE ,but data is not updates ple help me

i want update fowling fields data

Purchasing Document Number(ebeln)

PO Item Details

Item Number of Purchasing Document(EBELP)

Delivery Date(EEIND)

Net Price(NETPR)

PO Item Details --> Delivery Schedule

Scheduled Quantity(MENGE)

PO Item Details --> Texts

Item Text

Info Record PO Text

Material PO text

Delivery text

Info record note

Customer freight acct # note

i want to upload the above fields data from flat file to ME22n using BAPI_PO_CHANGE but my is is nou uploades into DATA BASE

here i am pasting my code

if there is any errors ple help me it's urgent

*&---------------------------------------------------------------------*

*& Report ZBAPI_PO_ITEM1

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT zbapi_po_item1.

*//Types delaraion

TYPES : BEGIN OF ty_item,

po_number LIKE bapimepoheader-po_number,

po_item LIKE bapimepoitem-po_item,

delivery_date LIKE bapimeposchedule-delivery_date,

netpr LIKE bapimeposchedule-quantity,

menge LIKE bapimepoitem-net_price,

* ITEMTEXT LIKE BAPIMEPOTEXT,

*INFOPOTEXT LIKE BAPIMEPOTEXT,

*MaterialPOtext like BAPIMEPOTEXT,

*Deliverypotext like BAPIMEPOTEXT,

*PAYTERMS LIKE BAPIMEPOTEXT,

*FRIGHT like BAPIMEPOTEXT,

* text_line1 LIKE bapimepotext-text_line,

* text_line2 LIKE bapimepotext-text_line,

* text_line3 LIKE bapimepotext-text_line,

* text_line4 LIKE bapimepotext-text_line,

* text_line5 LIKE bapimepotext-text_line,

* text_line6 LIKE bapimepotext-text_line,

* ebeln TYPE ebeln,

* ebelp(5) TYPE n,

* eeind(10) TYPE c,

* netpr(13) TYPE p DECIMALS 2,

* menge(16) TYPE p decimals 3,

text_line1(132) TYPE c,

text_line2(132) TYPE c,

text_line3(132) TYPE c,

text_line4(132) TYPE c,

text_line5(132) TYPE c,

text_line6(132) TYPE c,

END OF ty_item.

*//Internal table and work area declaration

DATA : lt_item TYPE TABLE OF ty_item,

wa_item TYPE ty_item.

*//Varible declaration

DATA : lv_path TYPE string.

DATA : BEGIN OF wa_text.

INCLUDE STRUCTURE bapimepotext.

DATA : END OF wa_text.

DATA : lt_text LIKE TABLE OF wa_text.

*//Selection screen design

PARAMETERS: p_file LIKE rlgrap-filename,

e_file LIKE rlgrap-filename.

*//

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

IMPORTING

file_name = p_file.

lv_path = p_file.

*//Uploading the data into internal table

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = lv_path

filetype = 'ASC'

has_field_separator = '|'

* HEADER_LENGTH = 0

* READ_BY_LINE = 'X'

* DAT_MODE = ' '

* CODEPAGE = ' '

* IGNORE_CERR = ABAP_TRUE

* REPLACEMENT = '#'

* CHECK_BOM = ' '

* VIRUS_SCAN_PROFILE =

* NO_AUTH_CHECK = ' '

* IMPORTING

* FILELENGTH =

* HEADER =

TABLES

data_tab = lt_item

* 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.

* Implement suitable error handling here

ENDIF.

IF sy-subrc EQ 0.

WRITE : 'success'.

ENDIF.

DATA : BEGIN OF itab1 OCCURS 10,

itemtext LIKE bapimepotext,

infopotext LIKE bapimepotext,

materialpotext LIKE bapimepotext,

deliverypotext LIKE bapimepotext,

fright LIKE bapimepotext,

payterms LIKE bapimepotext,

END OF itab1.

DATA : itemtext LIKE bapimepotext,

infopotext LIKE bapimepotext,

materialpotext LIKE bapimepotext,

deliverypotext LIKE bapimepotext,

fright LIKE bapimepotext,

payterms LIKE bapimepotext.

DATA: header LIKE bapimepoheader, " Header

header_ind LIKE bapimepoheaderx, " Header index

po_items LIKE bapimepoitem OCCURS 0 WITH HEADER LINE, " Item table

items_ind LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE, " Item index table

headertext LIKE bapimepotext ,

priceingtype LIKE bapimepotext,

return LIKE bapiret2 OCCURS 0 WITH HEADER LINE . " Message Return table

DATA : itemschedule LIKE bapimeposchedule OCCURS 0 WITH HEADER LINE ,

itemschedulex LIKE bapimeposchedulx OCCURS 0 WITH HEADER LINE .

*Structures to hold PO services data

DATA : services LIKE bapiesllc OCCURS 0 WITH HEADER LINE .

DATA : ctr TYPE n .

*end-of-selection.

LOOP AT lt_item INTO wa_item.

header-po_number = wa_item-po_number.

header_ind-po_number = 'X'.

po_items-po_item = wa_item-po_item.

po_items-quantity = wa_item-menge.

po_items-net_price = wa_item-netpr.

APPEND po_items.

items_ind-po_item = wa_item-po_item.

items_ind-quantity = 'X'.

items_ind-net_price = wa_item-netpr.

APPEND items_ind.

itemschedule-delivery_date = wa_item-delivery_date.

APPEND itemschedule.

*ITEMTEXT = WA_ITEM-ITEMTEXT.

*INFOPOTEXT = WA_ITEM-INFOPOTEXT.

*MaterialPOtext = WA_ITEM-MaterialPOtext.

*Deliverypotext = WA_ITEM-Deliverypotext.

*FRIGHT = WA_ITEM-FRIGHT.

*PAYTERMS = WA_ITEM-PAYTERMS.

*APPEND ITAB1.

*ENDLOOP.

*

*LOOP AT ITAB1.

wa_text-po_number = wa_item-po_number.

wa_text-po_item = wa_item-po_item.

wa_text-text_id = 'F01'.

wa_text-text_line = wa_item-text_line1.

APPEND wa_text TO lt_text.

CLEAR wa_text.

wa_text-po_number = wa_item-po_number.

wa_text-po_item = wa_item-po_item.

wa_text-text_id = 'F02'.

wa_text-text_line = wa_item-text_line2.

APPEND wa_text TO lt_text.

CLEAR wa_text.

wa_text-po_number = wa_item-po_number.

wa_text-po_item = wa_item-po_item.

wa_text-text_id = 'F03'.

wa_text-text_line = wa_item-text_line3.

APPEND wa_text TO lt_text.

CLEAR wa_text.

wa_text-po_number = wa_item-po_number.

wa_text-po_item = wa_item-po_item.

wa_text-text_id = 'F04'.

wa_text-text_line = wa_item-text_line4.

APPEND wa_text TO lt_text.

CLEAR wa_text.

wa_text-po_number = wa_item-po_number.

wa_text-po_item = wa_item-po_item.

wa_text-text_id = 'F05'.

wa_text-text_line = wa_item-text_line5.

APPEND wa_text TO lt_text.

CLEAR wa_text.

wa_text-po_number = wa_item-po_number.

wa_text-po_item = wa_item-po_item.

wa_text-text_id = 'F06'.

wa_text-text_line = wa_item-text_line6.

APPEND wa_text TO lt_text.

CLEAR wa_text.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = header-po_number

poheader = header

poheaderx = header_ind

TABLES

return = return

poitem = po_items

poitemx = items_ind

* POSCHEDULE =

* POSCHEDULEX =

* POTEXTHEADER =

potextitem = lt_text.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

IF NOT return IS INITIAL.

WRITE:/ return-message.

ENDIF.

ENDLOOP.

IF sy-subrc EQ 0.

WRITE : 'SUCCESS'.

ELSE.

WRITE : 'Error'.

ENDIF.

plz help me it's urgent

if u have any code plz send it to me.....

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 31, 2012 at 10:11 AM

    Hi friends it is working fine but it is updating first record only second record onword it is not working

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 31, 2012 at 06:39 AM

    Hi Vishnu,

    The Program source code is available, Please check the below link

    http://wiki.sdn.sap.com/wiki/display/HOME/Abap+code+on+BAPI+PO+Change

    With Regards,

    Sudhir S

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Pranav Mandelia

      friends i followed all ur suggestion but still it is not updating plz refer my code once

      *//Types delaraion

      TYPES : BEGIN OF ty_item,

      po_number LIKE bapimepoheader-po_number,

      po_item LIKE bapimepoitem-po_item,

      delivery_date LIKE bapimeposchedule-delivery_date,

      netpr LIKE bapimeposchedule-quantity,

      menge LIKE bapimepoitem-net_price,

      text_line1(130) TYPE c,

      text_line2(130) TYPE c,

      text_line3(130) TYPE c,

      text_line4(130) TYPE c,

      text_line5(130) TYPE c,

      text_line6(130) TYPE c,

      END OF ty_item.

      *//Internal table and work area declaration

      DATA : lt_item TYPE TABLE OF ty_item,

      wa_item TYPE ty_item.

      *//Varible declaration

      DATA : lv_path TYPE string.

      DATA : BEGIN OF wa_text.

      INCLUDE STRUCTURE bapimepotext.

      DATA : END OF wa_text.

      DATA : lt_text LIKE TABLE OF wa_text.

      *//Selection screen design

      PARAMETERS: p_file LIKE rlgrap-filename,

      e_file LIKE rlgrap-filename.

      *//

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

      CALL FUNCTION 'F4_FILENAME'

      EXPORTING

      program_name = syst-cprog

      dynpro_number = syst-dynnr

      IMPORTING

      file_name = p_file.

      lv_path = p_file.

      *//Uploading the data into internal table

      CALL FUNCTION 'GUI_UPLOAD'

      EXPORTING

      filename = lv_path

      filetype = 'ASC'

      has_field_separator = '|'

      * HEADER_LENGTH = 0

      * READ_BY_LINE = 'X'

      * DAT_MODE = ' '

      * CODEPAGE = ' '

      * IGNORE_CERR = ABAP_TRUE

      * REPLACEMENT = '#'

      * CHECK_BOM = ' '

      * VIRUS_SCAN_PROFILE =

      * NO_AUTH_CHECK = ' '

      * IMPORTING

      * FILELENGTH =

      * HEADER =

      TABLES

      data_tab = lt_item

      * 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.

      * Implement suitable error handling here

      ENDIF.

      IF sy-subrc EQ 0.

      WRITE : 'success'.

      ENDIF.

      DATA : BEGIN OF itab1 OCCURS 10,

      itemtext LIKE bapimepotext,

      infopotext LIKE bapimepotext,

      materialpotext LIKE bapimepotext,

      deliverypotext LIKE bapimepotext,

      fright LIKE bapimepotext,

      payterms LIKE bapimepotext,

      END OF itab1.

      DATA : itemtext LIKE bapimepotext,

      infopotext LIKE bapimepotext,

      materialpotext LIKE bapimepotext,

      deliverypotext LIKE bapimepotext,

      fright LIKE bapimepotext,

      payterms LIKE bapimepotext.

      DATA: header LIKE bapimepoheader, " Header

      header_ind LIKE bapimepoheaderx, " Header index

      po_items LIKE bapimepoitem OCCURS 0 WITH HEADER LINE, " Item table

      items_ind LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE, " Item index table

      headertext LIKE bapimepotext ,

      priceingtype LIKE bapimepotext,

      return LIKE bapiret2 OCCURS 0 WITH HEADER LINE . " Message Return table

      DATA : itemschedule LIKE bapimeposchedule OCCURS 0 WITH HEADER LINE ,

      itemschedulex LIKE bapimeposchedulx OCCURS 0 WITH HEADER LINE .

      *Structures to hold PO services data

      DATA : services LIKE bapiesllc OCCURS 0 WITH HEADER LINE .

      DATA : ctr TYPE n .

      *end-of-selection.

      LOOP AT lt_item INTO wa_item.

      header-po_number = wa_item-po_number.

      header_ind-po_number = 'X'.

      po_items-po_item = wa_item-po_item.

      po_items-quantity = wa_item-menge.

      po_items-net_price = wa_item-netpr.

      APPEND po_items.

      * items_ind-po_item = wa_item-po_item.

      * items_ind-quantity = 'X'.

      * items_ind-net_price = wa_item-netpr.

      * APPEND items_ind.

      items_ind-po_item = 'X'.

      items_ind-quantity = 'X'.

      items_ind-net_price = 'X'.

      APPEND items_ind.

      itemschedule-delivery_date = wa_item-delivery_date.

      APPEND itemschedule.

      itemschedulex-delivery_date = 'X'.

      append itemschedulex.

      wa_text-po_number = wa_item-po_number.

      wa_text-po_item = wa_item-po_item.

      wa_text-text_id = 'F01'.

      wa_text-text_form = '*'.

      wa_text-text_line = wa_item-text_line1.

      APPEND wa_text TO lt_text.

      CLEAR wa_text.

      wa_text-po_number = wa_item-po_number.

      wa_text-po_item = wa_item-po_item.

      wa_text-text_id = 'F02'.

      wa_text-text_form = '*'.

      wa_text-text_line = wa_item-text_line2.

      APPEND wa_text TO lt_text.

      CLEAR wa_text.

      wa_text-po_number = wa_item-po_number.

      wa_text-po_item = wa_item-po_item.

      wa_text-text_id = 'F03'.

      wa_text-text_form = '*'.

      wa_text-text_line = wa_item-text_line3.

      APPEND wa_text TO lt_text.

      CLEAR wa_text.

      wa_text-po_number = wa_item-po_number.

      wa_text-po_item = wa_item-po_item.

      wa_text-text_id = 'F04'.

      wa_text-text_form = '*'.

      wa_text-text_line = wa_item-text_line4.

      APPEND wa_text TO lt_text.

      CLEAR wa_text.

      wa_text-po_number = wa_item-po_number.

      wa_text-po_item = wa_item-po_item.

      wa_text-text_id = 'F05'.

      wa_text-text_form = '*'.

      wa_text-text_line = wa_item-text_line5.

      APPEND wa_text TO lt_text.

      CLEAR wa_text.

      wa_text-po_number = wa_item-po_number.

      wa_text-po_item = wa_item-po_item.

      wa_text-text_id = 'F06'.

      wa_text-text_form = '*'.

      wa_text-text_line = wa_item-text_line6.

      APPEND wa_text TO lt_text.

      CLEAR wa_text.

      endloop.

      SORT lt_text BY po_item text_id.

      CALL FUNCTION 'BAPI_PO_CHANGE'

      EXPORTING

      purchaseorder = header-po_number

      poheader = header

      poheaderx = header_ind

      TABLES

      return = return

      poitem = po_items

      poitemx = items_ind

      POSCHEDULE = ITEMSCHEDULE

      POSCHEDULEX = ITEMSCHEDULEX.

      * POTEXTHEADER =

      potextitem = lt_text.

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

      IF NOT return IS INITIAL.

      WRITE:/ return-message.

      ENDIF.

      * ENDLOOP.

      IF sy-subrc EQ 0.

      WRITE : 'SUCCESS'.

      ELSE.

      WRITE : 'Error'.

      ENDIF.

  • author's profile photo Former Member
    Former Member
    Posted on May 31, 2012 at 06:16 AM

    The items that you are changing should be passed in the Internal Table POITEMX as well

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 31, 2012 at 06:23 AM

    Here, POITEM table contains the values that will update and POITEMX contains same fields with POITEM but as a flag. (X or space).

    BAPI_PO_CHANGE will update only if POITEMX table fields are SET with ‘X’.


    In short,

    ITEM – Value for the fields

    ITEMX – Fields in ITEM table is need to update or not (X or space)

    Regards,

    NIM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 04, 2012 at 06:53 AM

    Finally i got the result

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.