Application Development and Automation 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: 
Read only

bapi_po_change

Former Member
0 Likes
578

Hi,

I am updating the PO info based on the data from the flat file. that means I am uploading data from flat file and checking this data with the table data if there are any changed=s in the table data I am modifying it.

For that i am using BAPI_PO_CHANGE

the code is as below.

TYPES : BEGIN OF ty_ekko,

ebeln TYPE ebeln,

ekorg TYPE ekorg,

ekgrp TYPE bkgrp,

END OF ty_ekko.

DATA : it_flatfile TYPE TABLE OF ty_ekko ,

wa_flatfile TYPE ty_ekko,

it_ekko1 TYPE TABLE OF ty_ekko,

wa_ekko1 TYPE ty_ekko.

DATA : v_file TYPE string.

DATA : wa_header TYPE bapimepoheader,

wa_headerx TYPE bapimepoheaderx.

data: it_return type table of bapiret2.

PARAMETERS : p_file TYPE ibipparms-path.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

file_name = p_file.

START-OF-SELECTION.

MOVE p_file TO v_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_file

has_field_separator = 'X'

TABLES

data_tab = it_flatfile.

IF NOT it_flatfile IS INITIAL.

SELECT ebeln ekorg ekgrp

FROM ekko

INTO TABLE it_ekko1

FOR ALL ENTRIES IN it_flatfile

WHERE ebeln = it_flatfile-ebeln .

ENDIF.

LOOP AT it_flatfile INTO wa_flatfile.

READ TABLE it_ekko1 INTO wa_ekko1 WITH KEY ebeln = wa_flatfile-ebeln.

IF sy-subrc EQ 0.

IF wa_flatfile-ekorg NE wa_ekko1-ekorg OR

wa_flatfile-ekgrp NE wa_ekko1-ekgrp.

wa_header-po_number = wa_flatfile-ebeln.

wa_header-purch_org = wa_flatfile-ekorg.

wa_header-pur_group = wa_flatfile-ekgrp.

  • wa_headerx-po_number = wa_flatfile-ebeln.

wa_headerx-purch_org = 'X'.

wa_headerx-pur_group = 'X'.

ENDIF.

ENDIF.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = wa_ekko1-ebeln

poheader = wa_header

poheaderx = wa_headerx

TABLES

RETURN = it_return

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDLOOP.

but the data is not being updated. I am having some errors in the return table.

I am updating only the header data

kindly help me in this issue

Regards

Hi,

I am updating the PO info based on the data from the flat file. that means I am uploading data from flat file and checking this data with the table data if there are any changed=s in the table data I am modifying it.

For that i am using BAPI_PO_CHANGE

the code is as below.

TYPES : BEGIN OF ty_ekko,

ebeln TYPE ebeln,

ekorg TYPE ekorg,

ekgrp TYPE bkgrp,

END OF ty_ekko.

DATA : it_flatfile TYPE TABLE OF ty_ekko ,

wa_flatfile TYPE ty_ekko,

it_ekko1 TYPE TABLE OF ty_ekko,

wa_ekko1 TYPE ty_ekko.

DATA : v_file TYPE string.

DATA : wa_header TYPE bapimepoheader,

wa_headerx TYPE bapimepoheaderx.

data: it_return type table of bapiret2.

PARAMETERS : p_file TYPE ibipparms-path.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

file_name = p_file.

START-OF-SELECTION.

MOVE p_file TO v_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_file

has_field_separator = 'X'

TABLES

data_tab = it_flatfile.

IF NOT it_flatfile IS INITIAL.

SELECT ebeln ekorg ekgrp

FROM ekko

INTO TABLE it_ekko1

FOR ALL ENTRIES IN it_flatfile

WHERE ebeln = it_flatfile-ebeln .

ENDIF.

LOOP AT it_flatfile INTO wa_flatfile.

READ TABLE it_ekko1 INTO wa_ekko1 WITH KEY ebeln = wa_flatfile-ebeln.

IF sy-subrc EQ 0.

IF wa_flatfile-ekorg NE wa_ekko1-ekorg OR

wa_flatfile-ekgrp NE wa_ekko1-ekgrp.

wa_header-po_number = wa_flatfile-ebeln.

wa_header-purch_org = wa_flatfile-ekorg.

wa_header-pur_group = wa_flatfile-ekgrp.

  • wa_headerx-po_number = wa_flatfile-ebeln.

wa_headerx-purch_org = 'X'.

wa_headerx-pur_group = 'X'.

ENDIF.

ENDIF.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = wa_ekko1-ebeln

poheader = wa_header

poheaderx = wa_headerx

TABLES

RETURN = it_return

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDLOOP.

but the data is not being updated. I am having some errors in the return table.

I am updating only the header data

kindly help me in this issue

Regards

4 REPLIES 4
Read only

Former Member
0 Likes
539

Hi,

You might be sending only header data .

What i see from FM call that u hav sent only header data.

u didn't populate other tables .

say for ex POITEM and hav to populate POITEMX for which fields u wanna change.

Rhea

Read only

Former Member
0 Likes
539

Hi,

also populate the itemdetails table POITEM.

Regards,

Raju.

Read only

Former Member
0 Likes
539

there may be sevral reason behind this.from here hard to guess.first just check whether you have aurthorization to change PO ot not?than check Security (BC-SEC) which standas a firewall(A special server in computer networks that prevents unauthorized penetration (dialling in) of external people and/or the transfer of data that is not to be transferred.)

for more info carefully read Functionality in Detail from documentation.

Amit.

Read only

Former Member
0 Likes
539

Sorry guys its prob with the authorizations, and settings in my server