hi,
I am in SRM7. i want to change the 'No further confiramtions' flag in PO item level in 'related documents' tab using a report.
i am using the below code to do that
CALL FUNCTION 'BBP_PD_PO_GETDETAIL' EXPORTING * I_GUID = I_OBJECT_ID = po_no * I_ATTACH_WITH_DOC = ' ' I_WITH_ITEMDATA = 'X' IMPORTING E_HEADER = ls_hdr * ET_ATTACH = TABLES E_ITEM = lt_item . data: lt_item_upd type table of BBP_PDS_PO_ITEM_ICU, ls_item_upd type BBP_PDS_PO_ITEM_ICU. loop at lt_item assigning <ls_item> where number_int eq itemno. move-corresponding <ls_item> to ls_item_upd. ls_item_upd-final_entry = 'D'. append ls_item_upd to lt_item_upd. endloop. data: ls_hdr_upd type BBP_PDS_PO_HEADER_U. move-corresponding ls_hdr to ls_hdr_upd. CALL FUNCTION 'BBP_PD_PO_UPDATE' EXPORTING * I_PARK = i_header = ls_hdr_upd I_SAVE = 'X' IMPORTING E_CHANGED = lv_changed ES_HEADER = ls_hdr_new TABLES I_ITEM = lt_item_upd . CALL FUNCTION 'BBP_PD_PO_SAVE' EXPORTING * IV_USERTYPE = 'E' IV_HEADER_GUID = ls_hdr_new-guid * . CALL FUNCTION 'BBP_PROCDOC_RESET_BUFFER' * EXPORTING * I_NO_STATUS = ' ' * I_NO_WFL = C_ON . commit work and wait.
i am getting 'X' in e_changed parameter, but when i see the PO in webgui the indiactor still say 'Yes'.
what i am seeing in bbp_pd is i am seeing a new change version for the PO but in 'deleted' status. i saw even if i change this flag using a test user, the change version is in deleted status. so i think that is an issue.in the change version i am seeing the final entry flag deleted. but the changed are not reflecting in the active version.
am i missing something here? is this some authorization issue? where should i debug to see why the active version is not updating? surprisingly i am able to change the item quantities successfully.
thanks
Edited by: SRM7CON on Feb 27, 2012 2:16 PM
Edited by: SRM7CON on Feb 27, 2012 2:59 PM
Edited by: SRM7CON on Feb 27, 2012 3:46 PM
Edited by: SRM7CON on Feb 27, 2012 7:25 PM
hi guys,
I finally found the solution at 1:00 AM after debugging the whole SAP code for PO update. here is the logic sap following ( i did this in SRM7, not sure if it is same in SRM4)
loop at lt_item assigning <ls_item> where number_int eq itemno. move-corresponding <ls_item> to ls_item_upd. ls_item_upd-final_entry = 'D'. append ls_item_upd to lt_item_upd. endloop.
when we want update the final entry in PO item we should do the following
if you want to remove it pass ls_item_upd-final_entry as 'B' ( not space or D )
if you want the check the flag pass 'C' ( not X or S)
internally SAP converts the B to D and finally to blank
simillarly in the other case it converts from C to S to X and then updates the tables.
it really sounds crazy but i believe SAP might be having good reason for doing this. it is really hard to figure out this, without debugging. i wish SAp documnets this somewhere in SAP help. otherwise many more developers will waste hours to figure out this. i hope my answer will help other developers who are trying to achieve a similar result.
thanks
i found out the solution updated post with it