BAPI_PO_CHANGE Faxnumber
Hi folks,
does anyone know if it is possible to change the faxnumber on adress tabstrip via BAPI_PO_CHANGE.
I give you a small code example which dosen't work. Does anyone know why ?
There is no error from the BAPI. It only says nothing changed !
CALL FUNCTION 'BAPI_PO_GETDETAIL'
EXPORTING
purchaseorder = lv_ebeln
items = space
IMPORTING
po_address = lv_address.
lv_address_v-po_number = lv_ebeln.
lv_address_v-name = lv_address-name1.
lv_address_v-name_2 = lv_address-name2.
lv_address_v-name_3 = lv_address-name3.
lv_address_v-name_4 = lv_address-name4.
lv_address_v-c_o_name = lv_address-name_co.
lv_address_v-city = lv_address-city1.
lv_address_v-district = lv_address-city2.
lv_address_v-city_no = lv_address-city_code.
lv_address_v-postl_cod1 = lv_address-post_code1.
lv_address_v-postl_cod2 = lv_address-post_code2.
lv_address_v-postl_cod3 = lv_address-post_code3.
lv_address_v-po_box = lv_address-po_box.
lv_address_v-po_box_cit = lv_address-po_box_loc.
lv_address_v-deliv_dis = lv_address-postalarea.
lv_address_v-street = 'Hansstr. 8'.
lv_address_v-street_no = lv_address-streetcode.
lv_address_v-str_abbr = lv_address-streetabbr.
lv_address_v-house_no = lv_address-house_num1.
lv_address_v-str_suppl1 = lv_address-str_suppl1.
lv_address_v-str_suppl2 = lv_address-str_suppl2.
lv_address_v-location = lv_address-location.
lv_address_v-building = lv_address-building.
lv_address_v-floor = lv_address-floor.
lv_address_v-room_no = lv_address-roomnumber.
lv_address_v-country = lv_address-country.
lv_address_v-langu = lv_address-langu.
lv_address_v-region = lv_address-region.
lv_address_v-sort1 = lv_address-sort1.
lv_address_v-sort2 = lv_address-sort2.
lv_address_v-time_zone = lv_address-time_zone.
lv_address_v-taxjurcode = lv_address-taxjurcode.
lv_address_v-adr_notes = lv_address-remark.
lv_address_v-comm_type = lv_address-deflt_comm.
lv_address_v-tel1_numbr = lv_address-tel_number.
lv_address_v-tel1_ext = lv_address-tel_extens.
lv_address_v-fax_number = '00436526188'.
lv_address_v-street_lng = lv_address-street.
lv_address_v-distrct_no = lv_address-cityp_code.
lv_address_v-chckstatus = lv_address-chckstatus.
lv_address_v-pboxcit_no = lv_address-city_code2.
lv_address_v-transpzone = lv_address-transpzone.
lv_address_v-house_no2 = lv_address-house_num2.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = lv_ebeln
poaddrvendor = lv_address_v
no_messaging = 'X'
no_message_req = 'X'
TABLES
return = lt_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
Any help appreciated,
Hans
HI
Try with this sample one
REPORT ZMMR_DELETEPO NO STANDARD PAGE HEADING MESSAGE-ID zisb.
tables : zvtls_sap.
*C-- Types Declarations
TYPES : BEGIN OF tp_flatfile_vtls,
ebeln(10),
ebelp type ekpo-ebelp,
END OF tp_flatfile_vtls.
*=====================================================================
* INTERNAL TABLES DECLARATION
*=====================================================================
DATA: t_flatfile_vtls TYPE tp_flatfile_vtls OCCURS 0 WITH HEADER LINE.
data : begin of t_sapdata occurs 0,
po like zvtls_sap-posap,
item like zvtls_sap-itemsap,
end of t_sapdata.
data : begin of t_flatfile_vtls1 occurs 0,
po(10),
item like zvtls_sap-itemsap,
end of t_flatfile_vtls1.
data : begin of t_update occurs 0,
mandt like zvtls_sap-mandt,
povtls like zvtls_sap-povtls,
itemvtls like zvtls_sap-itemvtls,
posap like zvtls_sap-posap,
itemsap like zvtls_sap-itemsap,
aedat like zvtls_sap-aedat,
paedt like zvtls_sap-paedt,
loekz like zvtls_sap-loekz,
end of t_update.
data : begin of t_poheader occurs 0,
po like zvtls_sap-posap,
end of t_poheader.
data : begin of t_poitem occurs 0,
po like zvtls_sap-posap,
item like zvtls_sap-itemsap,
end of t_poitem.
DATA : BEGIN OF T_MESSAGE OCCURS 0,
MSGTY,
MSGID(2),
MSGNO(3),
MSGTX(100),
PO like zvtls_sap-povtls,
item like zvtls_sap-itemvtls,
END OF T_MESSAGE.
DATA : BEGIN OF t_bapi_poheader OCCURS 0.
INCLUDE STRUCTURE bapimepoheader.
DATA : END OF t_bapi_poheader.
DATA : BEGIN OF t_bapi_poheaderx OCCURS 0.
INCLUDE STRUCTURE bapimepoheaderx.
DATA : END OF t_bapi_poheaderx.
DATA : BEGIN OF t_bapi_poitem OCCURS 0.
INCLUDE STRUCTURE bapimepoitem.
DATA : END OF t_bapi_poitem.
DATA : BEGIN OF t_bapi_poitemx OCCURS 0.
INCLUDE STRUCTURE bapimepoitemx.
DATA : END OF t_bapi_poitemx.
DATA : BEGIN OF t_bapireturn OCCURS 0.
INCLUDE STRUCTURE bapiret2.
DATA : END OF t_bapireturn.
*=====================================================================
* V A R I A B L E S
*=====================================================================
DATA: w_success(6) TYPE n,
w_bklas like t023-bklas,
w_curryear(4),
w_begda like sy-datum,
w_endda like sy-datum,
w_begyr(4),
w_endyr(4),
w_currmon(2),
w_assetclass like ankt-anlkl,
w_price type p,
w_recordsap type i,
w_povtls(10),
w_count type i.
DATA: w_filepath TYPE rlgrap-filename,
w_rc TYPE sy-subrc,
w_sscrfields_ucomm1 TYPE sscrfields-ucomm,
w_file1 TYPE string,
w_file2 TYPE FILENAME-FILEINTERN.
*=====================================================================
* C O N S T A N T S
*=====================================================================
CONSTANTS: c_x TYPE c VALUE 'X',
c_hyp TYPE c VALUE '-',
c_err TYPE bdc_mart VALUE 'E'.
CONSTANTS: c_slash(1) TYPE c VALUE '/',
c_hash(1) TYPE c VALUE '#',
c_pipe TYPE c VALUE '|',
c_1 TYPE i VALUE 1,
c_zero TYPE n VALUE '0',
c_rg1(3) TYPE c VALUE 'rg1',
c_gr3(3) TYPE c VALUE 'GR3',
c_gr2(3) TYPE c VALUE 'GR2',
c_e(1) TYPE c VALUE 'E',
c_filepath(8) TYPE c VALUE '/interf/',
c_filetype(10) TYPE c VALUE 'ASC'.
CONSTANTS : c_bapimepoheaderx TYPE x030l-tabname
VALUE 'bapimepoheaderx',
c_bapimepoitem TYPE x030l-tabname
VALUE 'bapimepoitem',
c_bapimepoaccount TYPE x030l-tabname
VALUE 'bapimepoaccount',
c_t_bapi_poheader(15) TYPE c
VALUE 't_bapi_poheader',
c_t_bapi_poitem(13) TYPE c
VALUE 't_bapi_poitem',
c_t_bapi_poitemx(14) TYPE c
VALUE 't_bapi_poitemx',
c_t_bapi_poheaderx(16) TYPE c
VALUE 't_bapi_poheaderx'.
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS:con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
*======================================================================
* SELECTION SCREEN
*======================================================================
SELECTION-SCREEN BEGIN OF BLOCK inputpath WITH FRAME TITLE text-001.
SELECTION-SCREEN : BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
PARAMETERS : p_fore RADIOBUTTON GROUP rg1
USER-COMMAND pc,
p_back RADIOBUTTON GROUP rg1 DEFAULT 'X'.
SELECTION-SCREEN : END OF BLOCK blk2.
SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-003.
PARAMETERS : p_file1 LIKE rlgrap-filename OBLIGATORY MODIF ID gr2.
PARAMETERS : p_afile1 LIKE rlgrap-filename OBLIGATORY MODIF ID gr3.
SELECTION-SCREEN : END OF BLOCK blk1.
SELECTION-SCREEN END OF BLOCK inputpath.
*C-- Initialization Event
INITIALIZATION.
CLEAR w_filepath.
CONCATENATE c_filepath sy-sysid c_slash sy-mandt c_slash INTO
w_filepath.
CONDENSE w_filepath NO-GAPS.
p_file1 = text-008.
p_afile1 = text-009.
*======================================================================
* SELECTION SCREEN EVENTS
*======================================================================
*C-- Selection Screen Output
AT SELECTION-SCREEN OUTPUT.
IF p_fore = c_x.
w_sscrfields_ucomm1 = space.
ELSE.
w_sscrfields_ucomm1 = c_rg1.
ENDIF.
LOOP AT SCREEN.
*C--Modify selection screen if presentation
*C--or application server radio button is chosen
IF w_sscrfields_ucomm1 = space.
IF screen-group1 = c_gr3.
screen-active = c_zero.
ENDIF.
ELSE.
IF screen-group1 = c_gr2.
screen-active = c_zero.
ENDIF.
ENDIF.
if screen-name = 'P_AFILE1'.
screen-input = 0.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
*C-- Selection Screen VALUE-REQUEST FOR File path
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.
IF p_fore EQ c_x.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file1.
ENDIF.
*C-- At Start of the Selection Process
START-OF-SELECTION.
IF p_fore EQ c_x.
w_file1 = p_file1.
ELSE.
w_file2 = p_afile1.
ENDIF.
IF p_fore EQ c_x. " Presentaion Server
*C--Validations for the input files
PERFORM validate_pre_file USING p_file1.
*C-- Load the contents of the input file into the internal table
PERFORM upload_file TABLES t_flatfile_vtls
USING w_file1
CHANGING w_rc.
IF w_rc <> 0.
MESSAGE s006 DISPLAY LIKE c_e.
ENDIF.
ELSE. " Application Server
*C--Validations for the input files
PERFORM validate_app_file USING w_file2.
*C-- Load the contents of the input file into the internal table
PERFORM upload_file_app TABLES t_flatfile_vtls
USING w_file2
CHANGING w_rc.
ENDIF.
loop at t_flatfile_vtls.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = t_flatfile_vtls-ebeln
IMPORTING
output = t_flatfile_vtls1-po.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = t_flatfile_vtls-ebelp
IMPORTING
output = t_flatfile_vtls1-item.
append t_flatfile_vtls1.
clear t_flatfile_vtls1.
endloop.
perform get_podata.
loop at t_poheader.
perform move_to_bapi.
perform call_bapi.
endloop.
PERFORM STORE_MESSAGES TABLES T_MESSAGE.
*& Form validate_pre_file
* Routine to validate presentation server file path.
* -->fp_name text
FORM validate_pre_file USING fp_name TYPE rlgrap-filename.
DATA : l_result,
l_filename TYPE string.
l_filename = fp_name.
CLEAR l_result.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = l_filename
RECEIVING
result = l_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE s007 DISPLAY LIKE c_e.
LEAVE LIST-PROCESSING.
ELSEIF l_result IS INITIAL.
MESSAGE s008 DISPLAY LIKE c_e.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " validate_pre_file_hdr
*& Form validate_app_file
* text - Checks if the path entered and filename is correct
FORM validate_app_file USING fp_file TYPE FILENAME-FILEINTERN.
data : l_fname(60).
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = FP_FILE
OPERATING_SYSTEM = SY-OPSYS
IMPORTING
FILE_NAME = L_FNAME
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = '0'.
OPEN DATASET L_FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
MESSAGE s007 DISPLAY LIKE c_e.
ELSE.
CLOSE DATASET l_fname.
ENDIF.
ENDIF.
ENDFORM. " validate_app_file
*& Form upload_file
* Routine to upload data from file to tables.
* -->P_fp_flatfile
* -->P_fp_file
* <--P_fp_rc
FORM upload_file TABLES fp_flatfile
USING fp_file TYPE string
CHANGING fp_rc TYPE sy-subrc.
IF fp_flatfile[] IS INITIAL.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = fp_file
filetype = c_filetype
has_field_separator = c_x
TABLES
data_tab = fp_flatfile
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.
MOVE sy-subrc TO fp_rc.
ENDIF.
ENDFORM. " upload_file
*& Form upload_file_app
* text
* -->FP_FLATFILEtext
* -->FP_FILE text
* -->FP_RC text
FORM upload_file_app TABLES fp_flatfile
USING fp_file TYPE FILENAME-FILEINTERN
CHANGING fp_rc TYPE sy-subrc.
DATA: l_string TYPE tedata-data.
DATA: wa_data_file TYPE tp_flatfile_vtls,
l_wllength TYPE i,
FNAME(60).
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = FP_FILE
OPERATING_SYSTEM = SY-OPSYS
IMPORTING
FILE_NAME = FNAME
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = 0.
OPEN DATASET FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
* *C-- commented by Bikash
* MESSAGE s107(yaero_ps) DISPLAY LIKE c_e.
message e008.
ELSE.
DO.
CLEAR: l_string.
READ DATASET FNAME INTO l_string LENGTH l_wllength.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT l_string AT con_tab INTO wa_data_file-ebeln
wa_data_file-ebelp.
APPEND wa_data_file TO fp_flatfile.
ENDIF.
ENDDO.
CLOSE DATASET FNAME.
ENDIF.
ENDIF.
ENDFORM. " upload_file_app
*& Form get_podata
* text
form get_podata.
select *
into table t_update
from zvtls_sap
for all entries in t_flatfile_vtls1
where itemvtls = t_flatfile_vtls1-item
and povtls = t_flatfile_vtls1-po.
sort t_update by posap itemsap.
loop at t_update.
at new posap.
t_poheader-po = t_update-posap.
append t_poheader.
clear t_poheader.
endat.
t_poitem-po = t_update-posap.
t_poitem-item = t_update-itemsap.
append t_poitem.
clear t_poitem.
t_update-paedt = sy-datum.
t_update-loekz = 'X'.
modify t_update.
endloop.
modify zvtls_sap from table t_update.
endform. "get_podata
*& Form move_to_bapi
* text
form move_to_bapi.
t_bapi_poheader-po_number = t_poheader-po.
CLEAR t_bapi_poheaderx.
PERFORM fill_check_structure USING c_bapimepoheaderx
c_t_bapi_poheader
c_t_bapi_poheaderx
c_x.
refresh : t_bapi_poitem,t_bapi_poitemx.
loop at t_poitem where po = t_poheader-po.
clear t_bapi_poitem.
t_bapi_poitem-po_item = t_poitem-item.
t_bapi_poitem-delete_ind = 'X'.
CLEAR t_bapi_poitemx.
PERFORM fill_check_structure USING c_bapimepoitem
c_t_bapi_poitem
c_t_bapi_poitemx
c_x.
t_bapi_poitemx-po_item = t_poitem-item.
t_bapi_poitemx-po_itemx = c_x.
APPEND t_bapi_poitem.
APPEND t_bapi_poitemx.
clear t_bapi_poitem.
clear t_bapi_poitemx.
endloop.
endform. "move_to_bapi
*& Form call_bapi
* This form Routine is used to commit the data records
FORM call_bapi .
DATA : l_msgty TYPE c,
l_msgid(2) TYPE c,
l_msgno(3) TYPE c,
l_msgtx(100) TYPE c,
l_errflag TYPE c.
CLEAR: t_bapireturn.
REFRESH: t_bapireturn.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
PURCHASEORDER = T_POHEADER-PO
POHEADER = T_BAPI_POHEADER
POHEADERX = T_BAPI_POHEADERX
TABLES
RETURN = T_BAPIRETURN
POITEM = T_BAPI_POITEM
POITEMX = T_BAPI_POITEMX.
READ TABLE t_bapireturn WITH KEY type = c_err TRANSPORTING NO FIELDS.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_x.
ENDIF.
*C-- Write messages
WRITE: / 'PO Number', t_poheader-po.
clear : t_update,w_povtls.
read table t_update with key posap = t_poheader-po.
w_povtls = t_update-povtls.
CLEAR l_errflag.
LOOP AT t_bapireturn.
CLEAR: l_msgty, l_msgid, l_msgno, l_msgtx.
l_msgty = t_bapireturn-type.
l_msgid = t_bapireturn-id.
l_msgno = t_bapireturn-number.
l_msgtx = t_bapireturn-message.
WRITE: / l_msgty, l_msgid, l_msgno, l_msgtx.
if l_msgtx cs t_poheader-po.
w_count = w_count + 1.
loop at t_update.
if sy-tabix = w_count.
t_message-item = t_update-itemvtls.
endif.
endloop.
endif.
t_message-msgty = l_msgty.
t_message-msgid = l_msgid.
t_message-msgno = l_msgno.
t_message-msgtx = l_msgtx.
t_message-po = w_povtls.
append t_message.
clear t_message.
IF l_msgty EQ c_err.
l_errflag = c_x.
ENDIF. " l_msgty EQ 'E'
ENDLOOP.
ULINE.
IF l_errflag NE c_x.
w_success = w_success + 1.
ENDIF. " l_errflag NE C_X
endform. "call_bapi
*& Form fill_check_structure
* This form Routine will check whether the specified structure
* exist/active
FORM fill_check_structure USING fp_tabname TYPE any
fp_orgtabname TYPE any
fp_chktabname TYPE any
fp_check TYPE c.
FIELD-SYMBOLS : <fs_chk>, <fs_org>.
DATA: l_char1(61) TYPE c,
l_char2(61) TYPE c.
DATA: BEGIN OF tl_nametab OCCURS 60.
INCLUDE STRUCTURE x031l.
DATA: END OF tl_nametab.
REFRESH tl_nametab.
CALL FUNCTION 'RFC_GET_NAMETAB'
EXPORTING
tabname = fp_tabname
TABLES
nametab = tl_nametab
EXCEPTIONS
table_not_active = 1
OTHERS = 2.
IF sy-subrc <> 0.
CLEAR tl_nametab.
ENDIF.
LOOP AT tl_nametab.
CLEAR: l_char1, l_char2.
CONCATENATE fp_chktabname c_hyp tl_nametab-fieldname INTO l_char1.
ASSIGN (l_char1) TO <fs_chk>.
CONCATENATE fp_orgtabname c_hyp tl_nametab-fieldname INTO l_char2.
ASSIGN (l_char2) TO <fs_org>.
IF <fs_org> IS NOT INITIAL.
<fs_chk> = fp_check.
ENDIF.
ENDLOOP.
ENDFORM. " fill_check_structure
*& Form STORE_MESSAGES
* text
* -->FP_MESSAGEStext
FORM STORE_MESSAGES TABLES FP_MESSAGES STRUCTURE T_MESSAGE.
DATA: wl_output_data LIKE t_MESSAGE.
DATA: l_catstr TYPE string.
DATA: l_fieldvalue TYPE string.
DATA: l_index TYPE i VALUE 1.
DATA: L_FNAME(60).
FIELD-SYMBOLS <fs>.
CLEAR l_catstr.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = '/USR/SAP/VTLS/POCHANGE/LOG'
OPERATING_SYSTEM = SY-OPSYS
IMPORTING
FILE_NAME = L_FNAME
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = '0'.
IF fp_messages[] IS NOT INITIAL.
OPEN DATASET L_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
LEAVE LIST-PROCESSING.
ELSE.
LOOP AT fp_messages INTO wl_output_data.
DO.
ASSIGN COMPONENT l_index OF STRUCTURE wl_output_data TO <fs>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
MOVE <fs> TO l_fieldvalue.
IF l_catstr IS NOT INITIAL.
CONCATENATE l_catstr l_fieldvalue INTO l_catstr SEPARATED
BY con_tab.
ELSE.
MOVE l_fieldvalue TO l_catstr.
ENDIF.
l_index = l_index + c_1.
CLEAR l_fieldvalue.
CLEAR <fs>.
ENDDO.
l_index = c_1.
TRANSFER l_catstr TO L_FNAME .
CLEAR wl_output_data.
CLEAR l_catstr.
ENDLOOP.
CLOSE DATASET L_FNAME.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "STORE_MESSAGES
Regards
Pavan
Similar Messages
-
BAPI_PO_CHANGE, changing condition value in the purchase order
Hi Friends,
I have a requirement,
a flat file is present in the application server that contains the information about PO,PO-ITEM,Condition type, movement type , condition value, plant, storage location .
And i m calling the bapi "BAPI_PO_CHANGE" and passing the po number to it.
the bapi returns the following tables, i_return, i_header,i_cond, i_item,i_itemx.
But the purpose of calling the BAPI is, to check, if the condition value in the specified PO is '0', then it has to replace with the value of condition type present in the flat file.
But when we check the tablei_return, its shows error type.
And the PO is not updated with the new condition value.
Help me out in sorting this problem, by telling me
what value is to be passed to the respective BAPI and what should i do to solve the issue?
and after that i m using a BAPI " BAPI_GOODSMOVEMENT_CREATE".
and it is for the purpose of creating the GR(Goods Receipt),
when i go through the i_return table of the bapi, it si returning a message that "BAPI_201 Unable to create goods movement".
Help me in proving the input to those bapi's and how can i get the expected output?
And let me know, what the bapi's ,"BAPI_COMMIIT" and " BAPI_ROLLBACK" , will be doing?
Edited by: kumar t on Aug 9, 2008 1:02 PMHI
[Check the Link|http://abap.wikiprog.com/wiki/BAPI_PO_CHANGE]
[Commit|http://abap.wikiprog.com/wiki/BAPI_TRANSACTION_COMMIT]
[Roll Back|http://abap.wikiprog.com/wiki/BAPI_TRANSACTION_ROLLBACK]
Regards
Pavan -
I want to change payment terms for a purchase order. Is it possible to achieve the same by using BAPI_PO_CHANGE. I have tried the same by giving the po number and payment terms in POHEADER and POHEADERX. But failed to achieve the result. CAn anyone help me pl
BAPI RETURN Table is not having any record. Otherwise it gives message as po successfully changed.
-
How to change the open quantity of PO / STO using BAPI_PO_CHANGE
Hi Friends,
How can I change the open quantity in ME22 using the BAPI BAPI_PO_CHANGE...
I am getting some errors..The values I am passing to the BAPI are:-
*-- Purchase Order document
lv_purchaseorder = tbl_join-ebeln.
*-- Calculate Open quantity
lv_quantity = ( tbl_join-menge - tbl_join-wemng ).
*-- Fills Schedule quantity to be processed.
tbl_poschedule-po_item = tbl_join-ebelp.
tbl_poschedule-sched_line = tbl_join-etenr.
tbl_poschedule-quantity = lv_quantity.
APPEND tbl_poschedule.
*-- Marks the Schedule quantity to be processed.
tbl_poschedulex-po_item = tbl_join-ebelp.
tbl_poschedulex-sched_line = tbl_join-etenr.
tbl_poschedulex-po_itemx = c_true.
tbl_poschedulex-sched_linex = c_true.
tbl_poschedulex-quantity = c_true.
APPEND tbl_poschedulex.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
PURCHASEORDER = lv_purchaseorder
POHEADER =
POHEADERX =
POADDRVENDOR =
TESTRUN = 'X'
IMPORTING
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
RETURN = tbl_return
POSCHEDULE = tbl_poschedule
POSCHEDULEX = tbl_poschedulex.
Is there any other required fields needs to be passed to change the open quantity..
I am checking in ME22...
The scheduled quantity is 20.
Delivered quantity is 15.
Open quantity is 5 and ( this field is in non-editable display )
Delivery date is 10.10.2002 ( which is in past )
Now using this BAPI ..I want to post the remaining open quantity which is " 5 "
How can i do this ?? Please help.Hi Hari
Please check after making the following changes:
*-- Marks the Schedule quantity to be processed.
tbl_poschedulex-po_item = tbl_join-ebelp.
tbl_poschedulex-sched_line = tbl_join-etenr.
<b>tbl_poschedulex-po_itemx = 'U'. "c_true.
*tbl_poschedulex-sched_linex = c_true.</b>
tbl_poschedulex-quantity = c_true.
APPEND tbl_poschedulex.
If still you do not get the desired function working add the below code:
tbl_poitem-po_item = tbl_join-ebelp.
tbl_poitem-quantity = lv_quantity.
append tbl_poitem.
tbl_poitemx-po_item = tbl_join-ebelp.
tbl_poitemx-po_itemx = 'U'.
tbl_poitemx-quantity = c_true.
append tbl_poitemx.
Hope this helps.
Kind Regards
Eswar -
BAPI_PO_CHANGE not updating internal order no. in account assignment
Hi,
I am using 'BAPI_PO_CHANGE' to update the internal order no.
I am first fetching the existing account assignment line items using 'BAPI_PO_GETDETAIL1' and then modifying the internal order no. as below.
lt_poaccount-orderid = '310021000000'.
MODIFY lt_poaccount INDEX lv_poacc_tabix TRANSPORTING orderid.
lt_poaccountx-po_item = gt_po-ebelp.
lt_poaccountx-orderid = 'X'.
APPEND lt_poaccountx.
but while calling the BAPI, the original values are returned and the message is 'No Data Changed'.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = gt_distinct_po-ebeln
TABLES
return = lt_return
poaccount = lt_poaccount
poaccountx = lt_poaccountx.
(The internal order no. is different than the original)
Can somebody please assist me on this?
Thanks in advance.Hi Kumar,
I recommend you to try changing the internal order manually through transaction ME22N and see if that is possible in your system first.
After that if that isn't possible you should contact your MM Expert for advise.
Regards,
Gilberto Li -
Update Schedule line Delivery date using Bapi_po_Change
Hi all,
I am using Bapi_po_change to Update the Schedule line Delivery date(EKET-EINDT) for the PO based on the Item and the Schedule line.
I am passing the PO number, Po header, Item structure, Schedule line Structure.
But the Date is not getting updated in the Eket table.
Please suggest.Hi Sukriti,
Thanks for the Response, yes i have used the Bapi Transaction Commit Also .
The point is I am able to Update the Statistical Delivery Date in the Same EKET table using BAPI_PO_Change .I have Checked all the Ways to update the EKET-EINDT(Delivery Date)but no Unable to do it. -
Deletion of schedule line in PO using BAPI_PO_CHANGE
Hi ,
Can anyone give me the code to delete a schedule line in a po using the bapi bapi_po_change.
Useful answers will be rewarded.
Regards,
Sowmya.Hi,
Refer below code
*& Form sub_populate_data
text
FORM sub_populate_data .
*--Local Variables
DATA : l_ipdate TYPE rc65a-datefrom,
l_fdate TYPE sy-datum.
IF NOT it_succ_file[] IS INITIAL.
LOOP AT it_succ_file INTO st_succ_file.
st_ipfile = st_succ_file.
*--Sales Document
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = st_ipfile-vbeln
IMPORTING
output = st_salesdoc.
st_ord_headx-updateflag = c_u.
*--Sales Document Item
st_schedule_line-itm_number = st_ipfile-posnr.
st_schedule_linex-itm_number = st_ipfile-posnr.
st_schedule_linex-updateflag = c_i.
*--Schedule line date
l_ipdate = st_ipfile-edatu.
*--Call function module to convert the date format into current user format
CALL FUNCTION 'CY_CONVERT_DATE'
EXPORTING
date_string_imp = l_ipdate
IMPORTING
date_exp = l_fdate.
st_schedule_line-dlv_date = l_fdate.
st_schedule_linex-dlv_date = c_chk.
st_schedule_line-req_date = l_fdate.
st_schedule_linex-req_date = c_chk.
*--Order quantity in sales units
st_schedule_line-req_qty = st_ipfile-wmeng.
st_schedule_linex-req_qty = c_chk.
APPEND st_schedule_line TO it_schedule_line.
APPEND st_schedule_linex TO it_schedule_linex.
*--Clear
CLEAR : st_schedule_line,
st_schedule_linex.
AT END OF posnr.
*--Perform to delete the existing schedule line
PERFORM sub_delete_schedule_line.
ENDAT.
AT END OF vbeln.
*--Clear
CLEAR : st_erfile.
READ TABLE it_erfile INTO st_erfile WITH KEY vbeln = st_ipfile-vbeln
posnr = st_ipfile-posnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_error_records = g_error_records + 1.
g_total_records = g_total_records + 1.
ELSE.
*--Call the bapi to update sales order schedule line
PERFORM sub_call_bapi.
ENDIF.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM. " sub_populate_data
*& Form sub_call_bapi
text
FORM sub_call_bapi.
g_total_records = g_total_records + 1.
*--Call BAPI to update sales order schedule line for simulation mode
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = st_salesdoc
order_header_inx = st_ord_headx
simulation = c_chk
TABLES
return = it_return
schedule_lines = it_schedule_line
schedule_linesx = it_schedule_linex.
IF NOT it_return[] IS INITIAL.
READ TABLE it_return INTO st_return WITH KEY type = c_e.
IF sy-subrc EQ 0.
g_error_records = g_error_records + 1.
ELSE.
REFRESH : it_return.
*--Call BAPI to update sales order schedule line
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = st_salesdoc
order_header_inx = st_ord_headx
TABLES
return = it_return
schedule_lines = it_schedule_line
schedule_linesx = it_schedule_linex.
ENDIF.
LOOP AT it_return INTO st_return
WHERE type EQ c_e.
st_erfile = st_ipfile.
st_erfile-message = st_return-message.
APPEND st_erfile TO it_erfile.
APPEND st_erfile TO it_file.
CLEAR : st_return.
ENDLOOP.
ENDIF.
IF it_file[] IS INITIAL.
*--Call BAPI transaction commit to change the schedule line
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_chk.
ELSE.
ROLLBACK WORK.
*--Call BAPI transaction rollback to rollback the schedule line
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
*--Clear
CLEAR : st_salesdoc,
st_ord_headx.
*--Refresh
REFRESH : it_return,
it_schedule_line,
it_schedule_linex.
ENDFORM. " sub_call_bapi
Regards,
Prashant -
Unchecked final invoice and delivery completed indicator via BAPI_PO_CHANGE
Hi All,
Is it possible to reset the final invoice and delivery completed indicators of PO in ME23N using BAPI_PO_CHANGE? I need to unchecked the final invoice and delivery completed indicators for all POs in our system that were accidentally updated to delivery completed and final invoice by the user.
Points will be rewared.what i did now is to create a prototype program like the one below:
CONSTANTS c_po TYPE bapimepoheader-po_number VALUE '0040001816'.
DATA: t_poitem-po TYPE bapimepoheader-po_number,
t_return TYPE STANDARD TABLE OF bapiret2,
t_poitem TYPE STANDARD TABLE OF bapimepoitem,
t_poitemx TYPE STANDARD TABLE OF bapimepoitemx,
x_return TYPE bapiret2,
x_poitem TYPE bapimepoitem,
x_poitemx TYPE bapimepoitemx.
t_poitem-po = c_po.
x_poitem-no_more_gr = 'X'.
x_poitemx-no_more_gr = 'X'.
x_poitem-final_inv = 'X'.
x_poitemx-final_inv = 'X'.
x_poitem-po_item = c_po.
x_poitemx-po_item = c_po.
APPEND x_poitem TO t_poitem.
APPEND x_poitemx TO t_poitemx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = t_poitem-po
no_messaging = 'X'
no_message_req = 'X'
TABLES
return = t_return
poitem = t_poitem
poitemx = t_poitemx.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
The program is working if you will mark the PO as delivery completed and final invoice with suppressed output. The problem is i need to do the reverse which is to unmark. I replaced the value of no_more_gr and final_inv from 'X' to space but it is not working. -
BAPI_PO_CHANGE - error while locking PO iems
All,
We're getting error when trying to lock PO items using BAPI_PO_CHANGE.
The PO item has a closed order as the account assignment in the PO. We do not get the error if the order is open.
Has anybody encountered this problem before? Is there any way to suppress this and allow locking of the item? Any inputs will be highly appreciated.
Regards
Deepthi.More info on this,
I get the error -
'Material purchase order' not allowed - Order XXXXXX
When we try to lock the same PO item using ME22N it is successful.
Is there any relevant OSS note for this? -
BAPI_PO_CHANGE with scheduling
Hai frnds,
Im using BAPI_PO_CHANGE for changing the quantity of the existing item and need to create an new item also. For this im using scheduling table(poschedule),where one item has two scheduling line.
Existing details
Eg: POHEADER: 0210000001
POITEM:
10 -> 400(quantity)
POSCHEDULE:
10 -> 1(1st sched) -> 100(quantity)
10 -> 2(2nd sched) -> 300(quantity)
After modification
Eg: POHEADER: 0210000001
POITEM:
10 -> 60(quantity)
20 -> 340(quantity)
POSCHEDULE:
10 -> 1(1st sched) -> 60(quantity)
10 -> 2(2nd sched) -> 0(quantity)
20 -> 1(1st sched) -> 40(quantity)
20 -> 2(2nd sched) -> 300(quantity)
Can anyone help me to solve this problem??? wat are the fields to be considered in POITEM,POSCHEDULE?
Suganya Jayabalan.Hai Thomas,
this is the code:
REPORT zfi_upd_import_process NO STANDARD PAGE HEADING
MESSAGE-ID z6 .
TABLES: zmmpoamend,ekko, ekpo.
DATA:t_zmmpo_amend_tab LIKE zmmpoamend OCCURS 0 WITH HEADER LINE.
DATA:t_zmmpo_amend_tab1 LIKE zmmpoamend OCCURS 0 WITH HEADER LINE.
DATA:v_bstmg LIKE bapimepoitem-quantity,
v_ebelp LIKE bapimepoitem-po_item,
v_belnr1 LIKE bkpf-belnr,
v_awkey LIKE bkpf-awkey,
v_orderunit LIKE ekpo-meins,
v_currency LIKE tcurc-waers,
v_ebeln LIKE ekko-ebeln,
v_payterm LIKE ekko-zterm,
v_zfbdt LIKE bseg-zfbdt,
v_flag(1) TYPE c,
v_flgbdc(1) TYPE c.
DATA: wa_bapiquantity1 like eket-menge,
wa_bapiquanfin1 like eket-menge,
wa_bapiquantot like eket-menge,
wa_bapiquantity2 like eket-menge,
wa_bapiquanfin2 like eket-menge.
DATA: BEGIN OF t_belnr_tab OCCURS 0,
belnr LIKE bkpf-belnr,
gjahr LIKE bkpf-gjahr,
END OF t_belnr_tab.
DATA: BEGIN OF t_ret_tab OCCURS 0.
INCLUDE STRUCTURE bapiret2.
DATA: END OF t_ret_tab.
FOR PO AMENDMENT POSTING ****************
DATA:BEGIN OF t_bapimepocond_tab OCCURS 0.
INCLUDE STRUCTURE bapimepocond.
DATA:END OF t_bapimepocond_tab.
DATA:BEGIN OF t_bapimepoitem_tab OCCURS 0.
INCLUDE STRUCTURE bapimepoitem.
DATA:END OF t_bapimepoitem_tab.
DATA: t_bapimepoitem_tab1 LIKE t_bapimepoitem_tab OCCURS 0 WITH HEADER
LINE
DATA:BEGIN OF t_bapimepoitemdet_tab OCCURS 0.
INCLUDE STRUCTURE bapiekpo.
DATA:END OF t_bapimepoitemdet_tab.
DATA:BEGIN OF t_bapieket_tab OCCURS 0.
INCLUDE STRUCTURE bapieket.
DATA:END OF t_bapieket_tab.
DATA:BEGIN OF t_bapiposchedule OCCURS 0.
INCLUDE STRUCTURE BAPIMEPOSCHEDULE.
DATA:END OF t_bapiposchedule.
data: w_no type i,
w_no1 type i,
w_idx type i.
DATA: w_ebelp like ekpo-ebelp.
DATA:BEGIN OF t_bapimepoaccount_tab OCCURS 0.
INCLUDE STRUCTURE bapimepoaccount.
DATA:END OF t_bapimepoaccount_tab.
DATA:BEGIN OF t_bapimepoaccountx_tab OCCURS 0.
INCLUDE STRUCTURE bapimepoaccountx.
DATA:END OF t_bapimepoaccountx_tab.
DATA:BEGIN OF t_bapimepoaccountdet_tab OCCURS 0.
INCLUDE STRUCTURE bapiekkn.
DATA:END OF t_bapimepoaccountdet_tab.
DATA:BEGIN OF t_bapimepoitemx_tab OCCURS 0.
INCLUDE STRUCTURE bapimepoitemx.
DATA:END OF t_bapimepoitemx_tab.
DATA:wa_bapimepoitem LIKE LINE OF t_bapimepoitem_tab.
data: begin of t_bapiposchedulex occurs 0.
include structure BAPIMEPOSCHEDULX.
data: end of t_bapiposchedulex.
END OF FOR PO AMENDMENT POSTING **********
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_poamd RADIOBUTTON GROUP rad1,
p_mirofs RADIOBUTTON GROUP rad1,
p_mirocd RADIOBUTTON GROUP rad1,
p_mirofr RADIOBUTTON GROUP rad1,
p_j1iex RADIOBUTTON GROUP rad1.
SELECT-OPTIONS:s_zzboe FOR zmmpoamend-zzboe NO INTERVALS NO-EXTENSION
OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
IF p_poamd = 'X'.
begin of internal table processing for calling BAPI's*******
SELECT * FROM zmmpoamend INTO TABLE t_zmmpo_amend_tab
WHERE zzboe IN s_zzboe AND
zzpostat = ' '.
IF sy-subrc <> '0'.
MESSAGE 'No PO found which has to be updated.' TYPE 'E'.
ENDIF.
begin of PO Amendment****************
LOOP AT t_zmmpo_amend_tab .
t_zmmpo_amend_tab-waers = 'INR'.
t_zmmpo_amend_tab1 = t_zmmpo_amend_tab.
t_zmmpo_amend_tab1-zzpostat = 'X'.
APPEND t_zmmpo_amend_tab1.
IF t_zmmpo_amend_tab-zzwrbtrvcd NE '0'.
CLEAR t_bapimepocond_tab.
t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.
t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvcd.
t_bapimepocond_tab-cond_type = 'ZVCD'.
t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.
t_bapimepocond_tab-change_id = 'I'.
APPEND t_bapimepocond_tab.
ENDIF.
IF t_zmmpo_amend_tab-zzwrbtrvnv NE '0'.
CLEAR t_bapimepocond_tab.
t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.
t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvnv.
t_bapimepocond_tab-cond_type = 'ZVNV'.
t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.
t_bapimepocond_tab-change_id = 'I'.
APPEND t_bapimepocond_tab.
ENDIF.
IF t_zmmpo_amend_tab-zzwrbtrccd NE '0'.
CLEAR t_bapimepocond_tab.
t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.
t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrccd.
t_bapimepocond_tab-cond_type = 'ZCCD'.
t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.
t_bapimepocond_tab-change_id = 'I'.
APPEND t_bapimepocond_tab.
ENDIF.
IF t_zmmpo_amend_tab-zzwrbtrvcv NE '0'.
CLEAR t_bapimepocond_tab.
t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.
t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvcv.
t_bapimepocond_tab-cond_type = 'ZVCV'.
t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.
t_bapimepocond_tab-change_id = 'I'.
APPEND t_bapimepocond_tab.
ENDIF.
IF t_zmmpo_amend_tab-zzwrbtrvce NE '0'.
CLEAR t_bapimepocond_tab.
t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.
t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvce.
t_bapimepocond_tab-cond_type = 'ZVCE'.
t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.
t_bapimepocond_tab-change_id = 'I'.
APPEND t_bapimepocond_tab.
ENDIF.
IF t_zmmpo_amend_tab-zzwrbtrvfi NE '0'.
CLEAR t_bapimepocond_tab.
t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.
t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvfi.
t_bapimepocond_tab-cond_type = 'ZVFI'.
t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.
t_bapimepocond_tab-change_id = 'I'.
APPEND t_bapimepocond_tab.
ENDIF.
IF t_zmmpo_amend_tab-zzwrbtrvad NE '0'.
CLEAR t_bapimepocond_tab.
t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.
t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvad.
t_bapimepocond_tab-cond_type = 'ZVAD'.
t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.
t_bapimepocond_tab-change_id = 'I'.
APPEND t_bapimepocond_tab.
ENDIF.
IF t_zmmpo_amend_tab-zzwrbtrvac NE '0'.
ZVAC added..
CLEAR t_bapimepocond_tab.
t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.
t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvac.
t_bapimepocond_tab-cond_type = 'ZVAC'.
t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.
t_bapimepocond_tab-change_id = 'I'.
APPEND t_bapimepocond_tab.
ENDIF.
IF t_zmmpo_amend_tab-zzwrbtrvae NE '0'.
ZVAE added..
CLEAR t_bapimepocond_tab.
t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.
t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvae.
t_bapimepocond_tab-cond_type = 'ZVAE'.
t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.
t_bapimepocond_tab-change_id = 'I'.
APPEND t_bapimepocond_tab.
ENDIF.
IF t_zmmpo_amend_tab-zzwrbtrmis NE '0'.
ZMIS(Miscellaenous charges) added..
CLEAR t_bapimepocond_tab.
t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.
t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrmis.
t_bapimepocond_tab-cond_type = 'ZMIS'.
t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.
t_bapimepocond_tab-change_id = 'I'.
APPEND t_bapimepocond_tab.
ENDIF.
IF t_zmmpo_amend_tab-zzinsper NE '0'.
insurance
CLEAR t_bapimepocond_tab.
t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.
t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzinsper.
t_bapimepocond_tab-cond_type = 'ZPIN'.
t_bapimepocond_tab-currency = '%'. "zmmpo_amend_tab-waers.
t_bapimepocond_tab-change_id = 'I'.
APPEND t_bapimepocond_tab.
ENDIF.
IF t_zmmpo_amend_tab-zzclsper NE '0'.
*clearing charges.
CLEAR t_bapimepocond_tab.
t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.
t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzclsper.
t_bapimepocond_tab-cond_type = 'ZPCL'.
t_bapimepocond_tab-currency = '%'. "zmmpo_amend_tab-waers.
t_bapimepocond_tab-change_id = 'I'.
APPEND t_bapimepocond_tab.
ENDIF.
v_bstmg = t_zmmpo_amend_tab1-menge + v_bstmg.
AT END OF ebelp.
t_bapimepoitem_tab-po_number = t_zmmpo_amend_tab1-ebeln .
t_bapimepoitem_tab-po_item = t_zmmpo_amend_tab1-ebelp .
t_bapimepoitem_tab-quantity = v_bstmg.
APPEND t_bapimepoitem_tab.
CLEAR v_bstmg.
ENDAT.
AT END OF ebeln.
L_EBELN =
CALL FUNCTION 'BAPI_PO_GETDETAIL'
EXPORTING
purchaseorder = t_zmmpo_amend_tab-ebeln
items = 'X'
account_assignment = 'X'
SCHEDULES = 'X'
TABLES
po_items = t_bapimepoitemdet_tab
po_item_account_assignment = t_bapimepoaccountdet_tab
PO_ITEM_SCHEDULES = t_bapieket_tab.
CLEAR v_ebelp.
v_ebelp = t_bapimepoitemdet_tab-po_item.
LOOP AT t_bapimepoitem_tab.
v_bstmg = t_bapimepoitem_tab-quantity.
LOOP AT t_bapimepoitemdet_tab WHERE
po_number = t_zmmpo_amend_tab-ebeln AND
po_item = t_bapimepoitem_tab-po_item.
IF t_bapimepoitemdet_tab-quantity =
t_bapimepoitem_tab-quantity.
MOVE-CORRESPONDING t_bapimepoitemdet_tab TO wa_bapimepoitem.
wa_bapimepoitem-gr_basediv = ' '.
APPEND wa_bapimepoitem TO t_bapimepoitem_tab1.
t_bapimepoitemx_tab-po_item = wa_bapimepoitem-po_item.
t_bapimepoitemx_tab-gr_basediv = 'X'.
APPEND t_bapimepoitemx_tab.
ELSE.
v_ebelp = v_ebelp + '10'.
MOVE-CORRESPONDING t_bapimepoitemdet_tab TO wa_bapimepoitem.
wa_bapimepoitem-quantity = t_bapimepoitemdet_tab-quantity -
t_bapimepoitem_tab-quantity.
wa_bapimepoitem-po_item = v_ebelp .
APPEND wa_bapimepoitem TO t_bapimepoitem_tab1.
LOOP AT t_bapimepoaccountdet_tab
WHERE po_item = t_bapimepoitem_tab-po_item.
MOVE-CORRESPONDING t_bapimepoaccountdet_tab TO
t_bapimepoaccount_tab.
t_bapimepoaccount_tab-gl_account =
t_bapimepoaccountdet_tab-g_l_acct.
t_bapimepoaccount_tab-itm_number =
t_bapimepoaccountdet_tab-sdoc_item.
t_bapimepoaccount_tab-quantity = wa_bapimepoitem-quantity.
t_bapimepoaccount_tab-po_item = v_ebelp.
t_bapimepoaccountx_tab-po_item = v_ebelp.
t_bapimepoaccountx_tab-quantity = 'X'.
t_bapimepoaccountx_tab-creat_date = 'X'.
t_bapimepoaccountx_tab-quantity = 'X'.
t_bapimepoaccountx_tab-gl_account = 'X'.
t_bapimepoaccountx_tab-bus_area = 'X'.
t_bapimepoaccountx_tab-costcenter = 'X'.
t_bapimepoaccountx_tab-sd_doc = 'X'.
t_bapimepoaccountx_tab-itm_number = 'X'.
t_bapimepoaccountx_tab-co_area = 'X'.
t_bapimepoaccountx_tab-part_acct = 'X'.
APPEND t_bapimepoaccount_tab.
APPEND t_bapimepoaccountx_tab.
ENDLOOP.
t_bapimepoitemx_tab-po_item = wa_bapimepoitem-po_item.
t_bapimepoitemx_tab-quantity = 'X'.
t_bapimepoitemx_tab-stge_loc = 'X'.
t_bapimepoitemx_tab-preq_no = 'X'.
t_bapimepoitemx_tab-preq_item = 'X'.
t_bapimepoitemx_tab-material = 'X'.
t_bapimepoitemx_tab-po_unit = 'X'.
t_bapimepoitemx_tab-plant = 'X'.
APPEND t_bapimepoitemx_tab.
MOVE-CORRESPONDING t_bapimepoitemdet_tab TO wa_bapimepoitem.
wa_bapimepoitem-quantity = v_bstmg.
wa_bapimepoitem-gr_basediv = ' '.
APPEND wa_bapimepoitem TO t_bapimepoitem_tab1.
t_bapimepoitemx_tab-po_item = wa_bapimepoitem-po_item.
t_bapimepoitemx_tab-quantity = 'X'.
t_bapimepoitemx_tab-gr_basediv = 'X'.
APPEND t_bapimepoitemx_tab.
*********this is wer new coding starts*****************************
*inserted for delivery scheduling foe PO
loop at t_bapieket_tab
where po_item = t_bapimepoitemdet_tab-po_item.
w_idx = sy-tabix.
IF t_bapieket_tab-SERIAL_NO = '0001'.
IF t_bapimepoitem_tab-quantity > t_bapieket_tab-quantity or
t_bapimepoitem_tab-quantity = t_bapieket_tab-quantity.
wa_bapiquantity1 = t_bapieket_tab-quantity.
ELSEIF t_bapimepoitem_tab-quantity < t_bapieket_tab-quantity.
wa_bapiquantity1 = t_bapimepoitem_tab-quantity.
ENDIF.
wa_bapiquanfin1 = t_bapieket_tab-quantity - wa_bapiquantity1.
t_bapieket_tab-QUANTITY = wa_bapiquantity1.
modify t_bapieket_tab index w_idx transporting quantity.
t_bapieket_tab-po_item = v_ebelp.
t_bapieket_tab-quantity = wa_bapiquanfin1.
append t_bapieket_tab.
ELSE.
IF t_bapimepoitem_tab-quantity > t_bapieket_tab-quantity.
wa_bapiquantity2 = t_bapimepoitem_tab-quantity - wa_bapiquantity1.
ELSEIF t_bapimepoitem_tab-quantity < t_bapieket_tab-quantity or
t_bapimepoitem_tab-quantity = t_bapieket_tab-quantity.
wa_bapiquantity2 = 0.
ENDIF.
wa_bapiquanfin2 = t_bapieket_tab-quantity - abs( wa_bapiquantity2 ).
t_bapieket_tab-QUANTITY = abs( wa_bapiquantity2 ).
modify t_bapieket_tab index w_idx transporting quantity.
t_bapieket_tab-po_item = v_ebelp.
t_bapieket_tab-quantity = wa_bapiquanfin2.
append t_bapieket_tab.
ENDIF.
endloop.
Sort t_bapieket_tab by po_item.
sort t_bapimepoitem_tab1 by po_item.
sort t_bapimepoitemx_tab by po_item.
loop at t_bapieket_tab.
move: t_bapieket_tab-po_item to t_bapiposchedule-po_item,
t_bapieket_tab-serial_no to t_bapiposchedule-sched_line,
t_bapieket_tab-quantity to t_bapiposchedule-quantity,
t_bapieket_tab-preq_no to t_bapiposchedule-preq_no,
t_bapieket_tab-preq_item to t_bapiposchedule-preq_item.
if t_bapieket_tab-quantity = 0.
t_bapiposchedule-delete_ind = 'X'.
endif.
append t_bapiposchedule.
move: t_bapieket_tab-po_item to t_bapiposchedulex-po_item,
t_bapieket_tab-serial_no to t_bapiposchedulex-sched_line.
t_bapiposchedulex-po_itemx = 'X'.
t_bapiposchedulex-sched_linex = 'X'.
if t_bapieket_tab-quantity = 0.
t_bapiposchedulex-delete_ind = 'X'.
elseif t_bapieket_tab-quantity <> 0.
t_bapiposchedulex-quantity = 'X'.
endif.
clear: w_ebelp.
select single ebelp from ekpo
into w_ebelp
where ebeln = t_zmmpo_amend_tab-ebeln and
ebelp = t_bapieket_tab-po_item.
if w_ebelp is initial.
t_bapiposchedulex-preq_no = 'X'.
t_bapiposchedulex-preq_item = 'X'.
endif.
append t_bapiposchedulex.
clear: t_bapiposchedulex, t_bapiposchedule.
endloop.
ENDIF.
ENDLOOP.
***********end of new insertion**********************************************
CLEAR t_bapimepoitemdet_tab.
CLEAR v_bstmg.
ENDLOOP.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = t_zmmpo_amend_tab-ebeln
TABLES
return = t_ret_tab
poitem = t_bapimepoitem_tab1
poitemx = t_bapimepoitemx_tab
*****************inserted by suganya-2006/06/27*************************
POSCHEDULE = t_bapiposchedule
POSCHEDULEX = t_bapiposchedulex
*****************end of insertion-suganya-2006/06/27********************
poaccount = t_bapimepoaccount_tab
poaccountx = t_bapimepoaccountx_tab
pocond = t_bapimepocond_tab
CLEAR v_flag.
LOOP AT t_ret_tab.
IF t_ret_tab-type = 'E'.
v_flag = 'X'.
WRITE:/2 t_zmmpo_amend_tab-ebeln,
15 t_ret_tab-type,
25 t_ret_tab-message.
ENDIF.
AT LAST.
IF v_flag <> 'X'.
UPDATE zmmpoamend FROM TABLE t_zmmpo_amend_tab1.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
WRITE:/2 'PO ',5 t_zmmpo_amend_tab-ebeln,
16 ' changed succesfully'.
ENDIF.
ENDAT.
ENDLOOP.
CLEAR t_ret_tab.
REFRESH t_ret_tab.
CLEAR t_bapimepocond_tab.
REFRESH t_bapimepocond_tab.
CLEAR t_zmmpo_amend_tab1.
REFRESH t_zmmpo_amend_tab1.
CLEAR t_bapimepoitem_tab.
REFRESH t_bapimepoitem_tab.
CLEAR t_bapimepoitemdet_tab.
REFRESH t_bapimepoitemdet_tab.
CLEAR t_bapimepoitem_tab1.
REFRESH t_bapimepoitem_tab1.
CLEAR t_bapimepoitemx_tab.
REFRESH t_bapimepoitemx_tab.
CLEAR t_bapimepoaccount_tab.
REFRESH t_bapimepoaccount_tab.
CLEAR t_bapimepoaccountdet_tab.
REFRESH t_bapimepoaccountdet_tab.
CLEAR t_bapimepoaccountx_tab.
REFRESH t_bapimepoaccountx_tab.
ENDAT.
ENDLOOP.
ENDIF.
End of PO Amendment****************
Regrads,
Suganya Jayabalan -
BAPI_PO_CHANGE Add Services
Hi all,
I need to update a PURCHASE ORDER with new services but im getting the error msg "Enter Quantity in service line" but my service line is a information line what could be the problem (poservices-inform = 'X'. poservices-serv_type = 'HZ' ).
Im unable also to insert text information with POSERVICESTEXT.
What could be missing?
Test sequence
Se37
BAPI_PO_CHANGE
BAPI_TRANSACTION_COMMIT
TEST 1 (unable to insert POSERVICESTEXT information in PO, but the NZ lines are insert )
Return
T ID NUM MESSAGE
S 06 023 Standard PO 4500000284 changed
W ME 887 Error transferring ExtensionIn data for enhancement CI_EKKODB
I ME 664 Change Order Unit could not be effected
Parâmetros: PURCHASEORDER = 4500000284
Parâmetros: VERSIONS
POST_DATE = 00000000
Parâmetros: POITEM
PO_ITEM = 00010
SHORT_TEXT = CHANGE
MATERIAL = 000000000040000008
QUANTITY = 1.000
PO_UNIT = LE
PCKG_NO = 0000000001
Parâmetros: POITEMX
PO_ITEM = 00010
PO_ITEMX = X
SHORT_TEXT = X
MATERIAL = X
QUANTITY = X
PO_UNIT = X
PCKG_NO = X
Parâmetros: POSCHEDULE
PO_ITEM = 00010
SCHED_LINE = 0001
QUANTITY = 1.000
Parâmetros: POSCHEDULEX
PO_ITEM = 00010
SCHED_LINE = 0001
PO_ITEMX = X
SCHED_LINEX = X
QUANTITY = X
Parâmetros: POSERVICES
PCKG_NO = 0000000001
LINE_NO = 0000000001
OUTL_LEVEL = 0
OUTL_IND = X
SUBPCKG_NO = 0000000002
FROM_LINE = 1
PCKG_NO = 0000000002
LINE_NO = 0000000002
EXT_LINE = 0000000010
OUTL_LEVEL = 0
SERV_TYPE = NZ
QUANTITY = 5.000
BASE_UOM = UN
PRICE_UNIT = 1
GR_PRICE = 10.0000
SHORT_TEXT = SHORT 1
USERF1_TXT = LINHA NORMAL
PCKG_NO = 0000000002
LINE_NO = 0000000003
EXT_LINE = 0000000020
OUTL_LEVEL = 0
SERV_TYPE = NZ
QUANTITY = 5.000
BASE_UOM = UN
PRICE_UNIT = 1
GR_PRICE = 10.0000
SHORT_TEXT = SHORT 2
USERF1_TXT = LINHA NORMAL
PCKG_NO = 0000000002
LINE_NO = 0000000004
EXT_LINE = 0000000030
OUTL_LEVEL = 0
SERV_TYPE = NZ
QUANTITY = 5.000
BASE_UOM = UN
PRICE_UNIT = 1
GR_PRICE = 10.0000
SHORT_TEXT = SHORT 3
USERF1_TXT = LINHA NORMAL
Parâmetros: POSERVICESTEXT
PCKG_NO = 0000000002
LINE_NO = 0000000004
TEXT_ID = LLTX
FORMAT_COL = *
TEXT_LINE = LONGO
PCKG_NO = 0000000002
LINE_NO = 0000000004
TEXT_ID = LTXT
FORMAT_COL = *
TEXT_LINE = SUCINTO
Second test
Return
T ID NUM MESSAGE
E SE 319 Please enter a quantity
W ME 887 Error transferring ExtensionIn data for enhancement CI_EKKODB
E BAPI 003 Instance 4500000284 of object type PurchaseOrder could not be changed
Parameters: PURCHASEORDER = 4500000284
Parameters: VERSIONS
POST_DATE = 00000000
Parameters: POITEM
PO_ITEM = 00010
SHORT_TEXT = CHANGE
MATERIAL = 000000000040000008
QUANTITY = 1.000
PCKG_NO = 0000000001
Parameters: POITEMX
PO_ITEM = 00010
PO_ITEMX = X
SHORT_TEXT = X
MATERIAL = X
QUANTITY = X
PCKG_NO = X
Parameters: POSCHEDULE
PO_ITEM = 00010
SCHED_LINE = 0001
QUANTITY = 1.000
Parameters: POSCHEDULEX
PO_ITEM = 00010
SCHED_LINE = 0001
PO_ITEMX = X
SCHED_LINEX = X
QUANTITY = X
Parameters: POSERVICES
PCKG_NO = 0000000001
LINE_NO = 0000000001
OUTL_LEVEL = 0
OUTL_IND = X
SUBPCKG_NO = 0000000002
FROM_LINE = 1
PCKG_NO = 0000000002
LINE_NO = 0000000002
EXT_LINE = 0000000010
OUTL_LEVEL = 0
SERV_TYPE = NZ
QUANTITY = 5.000
BASE_UOM = UN
PRICE_UNIT = 1
GR_PRICE = 10.0000
SHORT_TEXT = SHORT 1
USERF1_TXT = LINHA NORMAL
PCKG_NO = 0000000002
LINE_NO = 0000000003
EXT_LINE = 0000000020
OUTL_LEVEL = 0
SERV_TYPE = HZ
GR_PRICE = 10.0000
SHORT_TEXT = SHORT 2
INFORM = X
USERF1_TXT = LINHA INFO
PCKG_NO = 0000000002
LINE_NO = 0000000004
EXT_LINE = 0000000030
OUTL_LEVEL = 0
SERV_TYPE = NZ
QUANTITY = 5.000
BASE_UOM = UN
PRICE_UNIT = 1
GR_PRICE = 10.0000
SHORT_TEXT = SHORT 3
USERF1_TXT = LINHA NORMAL
Parameters: POSERVICESTEXT
PCKG_NO = 0000000002
LINE_NO = 0000000004
TEXT_ID = LLTX
FORMAT_COL = *
TEXT_LINE = LONGO
PCKG_NO = 0000000002
LINE_NO = 0000000004
TEXT_ID = LTXT
FORMAT_COL = *
TEXT_LINE = SUCINTO
Thanks and Regards
null
Message was edited by:
Luis ConstantinoThank you for reply.
Yes, I read it, but I found a sap note that say:
You can also change services using BAPI_PO_CHANGE. Up to now, it was only possible to add complete service or limit items.
Using the new BAPI_PO_CHANGE, you can now make changes to services and with limits.
Because in the production mode the interfaces are filled entirely from available documents by report, SAP always assumes that the services or limits to be changed are sent in full to the BAPI interfaces with all the data belonging to them, even if not all the data is changed. If required entry fields are missing, the system displays an error message, other data not filled is possibly initialized. (It is not necessary to assign the complete item.)
- NOTE 561507 -
"What BAPI_PO_CHANGE can now do:
1. Changes to an already existing item:
For an existing item, you can
a) Add, change or delete services.
b) Add, change or delete limits (free limits and contract limits), provided that this does not cause the net value of the purchase order item to become "0".
1. Account assignment change for item category B and D: For an existing item, the account assignment can be changed.
a) Account assignment category U can be converted into another account assignment category allowed for the item categories, and vice versa.
b) An existing account assignment can be changed.
c) In case of services, a single account assignment can be converted into a multiple account assignment and vice versa - not with limits (with item category B), here multiple account assignment is not possible on-line either).
2. Making changes to more than one item.
3. Change outline layouts.
What the BAPI_PO_CHANGE cannot do:
Everything which is not possible on-line either." -
Using BAPI_PO_CHANGE to update PO with item actegory B
Hi Experts,
I have a requirement to update the PO with item category B which is created by referring PR having account assignment category N(.( So I have a PO with Acc assignment N now have to update the item category with B ). I am using BAPI_PO_CHANGE to update the item category with B .in me22n system will prompt the Limits ( overall limit , expected value) and Network details ( like GL acc and Network and activity code) so i am passing lt_poitem,lt_poitemx,lt_polimits,lt_poaccount,lt_poaccountx,lt_POSRVACCESSVALUES. System is issuing a message Buffer table is not up-to-date . Please let me know if any one updated the PO with item category B using BAPI_PO_CHANGE and please provide sample code for the same if possible. Thanks in advance.
Thanks
PraveeHi Experts,
I am passing the required structure as below .
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = v_po
TABLES
return = lt_return
poitem = lt_poitem
poitemx = lt_poitemx
polimits = lt_polimits
poaccount = lt_poaccount
poaccountx = lt_poaccountx
POSRVACCESSVALUES = lt_POSRVACCESSVALUES
POCONTRACTLIMITS = lt_POCONTRACTLIMITS
POSERVICES = lt_POSERVICES.
Now i am getting a message below messages from BAPI :
S 06 023 Indirect PO (ZSTA) 4506000481 changed
I ME 664 Change Item Category could not be effected
I ME 664 Change Item Category could not be effected
I can see that the PO is not got updated with any of values.Please help me to resolve this issue.
Thanks
PRavee. -
BAPI_PO_CHANGE for account assignment tab
Hi sdn,
I am trying to chnage the Account Assgnment tab details with the BAPI BAPI_PO_CHANGE and getting below error message.
E MEPO 000 Purchase order still contains faulty items
I 06 684 Releases already effected are liable to be reset
E 06 436 In case of account assignment, please enter acc. assignment data for item
I am trying to the chnage the line item details for Acount assignment type - Cost center. Item catagory - Limit.
Th evalue i am changing - Gl account and Cost center.
Below is the sample code.
APPEND wa_poitem TO it_poitem.
wa_poitemx-po_item = wa_poitem-po_item.
wa_poitemx-po_itemx = c_x.
APPEND wa_poitemx TO it_poitemx.
wa_poaccount-costcenter = wa_po_tmp_c-kostl.
wa_poaccountx-costcenter = c_x.
wa_poaccount-gl_account = wa_po_tmp_c-sakto.
wa_poaccountx-gl_account = c_x.
wa_poaccount-gr_rcpt = wa_po_tmp_c-wempf.
wa_poaccountx-gr_rcpt = c_x.
wa_poaccountx-po_item = wa_po_tmp_c-ebelp.
wa_poaccountx-serial_no = wa_poaccount-serial_no.
wa_poaccountx-po_itemx = c_x.
wa_poaccountx-serial_nox = c_x.
APPEND wa_poaccount TO it_poaccount.
APPEND wa_poaccountx TO it_poaccountx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = wa_po_c-ebeln
testrun = v_testrun
no_messaging = c_x
no_message_req = c_x
IMPORTING
expheader = wa_expheader
TABLES
return = it_return
poitem = it_poitem
poitemx = it_poitemx
poaccount = it_poaccount
poaccountx = it_poaccountxHi I had fixed this problem by creating Enhancement point in the Method .
IF_PURCHASE_ORDER_MM~SET_DATA
at the end of the method.
if sy-tcode = 'ZPO_ACCT_CHANGE'.
free my_recheck_queue[].
refresh my_recheck_queue[].
endif.
Edited by: Naresh Nelapatla on May 13, 2011 5:17 PM -
BAPI_PO_CHANGE - Account assignment serial number issue
Hi,
I am modifying Service PO with BAPI_PO_CHANGE.
I am passign A/c Assignment with WBS_Element value and serial number '01' for individual line.
PO has A/c Assignment catagory P(Project).
But the existing PO which i want to modify, had Serial number '02' for A/c assignemnt serial number.
So it is giving Short dump with raising exception for the class of Account assignnment handler.
What need to dofor such A/c assignment catagory in Service PO Case.?
Regards,
ManojHi,
Please try to change the serial number manually in mE22N and see.
Regards,
Nagaraj -
BAPI_PO_CHANGE "No account assignment for service 0000010" SE 518 Error
Hi Friends,
I am using BAPI_PO_CHANGE to add new line item with service data to purchase order.
For one scenario BAPI give me above error is "No account assignment for service 0000010" SE 518 .
basically when i pass outline aggrement and contract item to bapi i am getting this error.....according to my observation in outline agrement account assignment is maintain as 'U' but i want to pass outline agrement as 'K' or 'N' so i am passing this into BAPI parameters ,however i feel somewhere it is getting conflict so it giving above error...
Please guide,
Thanks & Regards,
BhaskarHi Seini,
Thanks for reply ..
I have pass contract number to BAPI ....and i also pass cost center and GL account to account assignment but still bapi giving same error.....I am totally stuck into this i tried a lot with different options..for other scenario BAPI works fine but when I pass contract number with account assignment 'U' and I want to change this 'U' to 'K' or 'N' for this I pass account assignment to PO line item but BAPI fails in this perticular scenario.
Maybe you are looking for
-
Keeps coming up as a error while trying to upload
I have been uploading files in the past to Acrobat.com but it appears the larger the files the more difficult it is on some occasions, 2 in particular last night. I think some, maybe 2 or 3 may have been too large for the page, out of lets say 149 do
-
Program ID in RFC destination of type T
can one please explain what exactly is program id in rfc destination of type T
-
What is WLAN connectivity, how to use it for inter...
hi all i have nokia n79, i have know about WLAN connectivity, i mean how to use it. i just check it in my office it shows WLAN network found, i opend it and select start web browsing, then it asked select WLAN network there it already shows hidden WL
-
Audit Vault Agent Installation issue
Hi All, I have installed the following things 1) Audit Vault Server (10.2.2.0.1) on a Windows 2003 Server 2) I completed the post-installation tasks 3) I am trying to install Audit Vault agent (10.2.2) on HPUX (11.11) machine. I start the AV Agent ru
-
Limit Connection resource in app - your opinion very welcome
Hi', I have an application where Connection object is used on different forms (classes). In order to limit numbers of creating a new ones I've created separate class mydb which holds a Connection obj. as a static member. The object (Connection) is be