Skip to Content
0
Feb 27, 2009 at 04:40 PM

Update and create a new version of a PO

203 Views

Hi all experts,

I'm doing a simple report to synch POs between an R3 and the SRM system. In order to do this, the report (who's running on the SRM) does as follows:

1) given a PO number, retrieves from the backend all the PO-related tables (and translate them into SRM-like structures, but this is a minor note);

2) retrieves details for the PO specified in SRM (BBP_PD_PO_GETDETAIL);

3) perform a mapping between SRM items and corrispective R3 ones.

4) update eventually some fields from the R3.

5) then, finally, tries to do an update. And here the mess begins... I can't manage the update phase to do what I want...

First of all; I retrieve all the data I need from the SRM system as follows:

CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
    EXPORTING
*     I_GUID                           =
      I_OBJECT_ID                      = p_ebeln
*     I_ATTACH_WITH_DOC                = ' '
      I_WITH_ITEMDATA                  = 'X'
*     I_READ_BE_DATA                   = ' '
*     I_ITEM_SORTED_BY_HIERARCHY       =
*     I_WITHOUT_HEADER_TOTALS          =
    IMPORTING
      E_HEADER                         = srm_header
*     ET_ATTACH                        =
    TABLES
      E_ITEM                           = srm_item
      E_ACCOUNT                        = srm_account
      E_PARTNER                        = srm_partner
      E_CONFIRM                        = srm_confirm
      E_LONGTEXT                       = srm_longtext
      E_LIMIT                          = srm_limit
      E_ORGDATA                        = srm_orgdata
      E_TAX                            = srm_tax
      E_PRIDOC                         = srm_pridoc
      E_MESSAGES                       = srm_messages
      E_ACTVAL                         = srm_actval
      E_ACC_ACTVAL                     = srm_acc_actval
      E_VERSION                        = srm_version
      E_HEADER_REL                     = srm_header_rel
      E_ITMLIM_REL                     = srm_itmlim_rel
      E_STATUS                         = srm_status.

Then, since the modifications required are just at item granularity, I work on the srm_item table (i.e., let's say that the X item has its description changed).

The problem is the UPDATE task: basically, I tried to use the BBP_PD_PO_UPDATE as follows:

CALL FUNCTION 'BBP_PD_PO_UPDATE'
    EXPORTING
     i_park                       = 'X'
     i_header                     = s_headeru
     I_SAVE                       = ''
*   IV_REJECT                    =
*   IT_ATTACH                    =
    IV_WITH_CHANGE_VERSION       = ''
* IMPORTING
*   E_CHANGED                    =
*   ES_HEADER                    =
   TABLES
     i_item                       = v_item
*   I_ACCOUNT                    =
*     i_partner                    = t_partner
*   I_CONFIRM                    =
*   I_LONGTEXT                   =
*   I_LIMIT                      =
*   I_ORGDATA                    =
*   I_TAX                        =
*   I_PRIDOC                     =
     e_messages                   = t_messages    .

CALL FUNCTION 'BBP_PD_PO_SAVE'
EXPORTING
*    IV_WORKITEM_ID               = srm_header-object_id
*     IV_USERTYPE                  =
     IV_HEADER_GUID               = srm_header-guid
     IV_CREATE_HIST_VERSION       = 'X'
  .
COMMIT WORK AND WAIT.

where s_headeru is simply an adeguate structure for the FM (MOVE-CORRESPONDING srm_item TO s_headeru), so nothing new.

Issues: this code actually updates the PO. I can see on the SRM web interface that the order's been updated (e.g. modified description)... BUT there's no trace of the previous version. Calling the UPDATE FM in this way pratically overwrites the order on SRM.

IV_WITH_CHANGE_VERSION field seems not working: if I flag this field ('X') the update fm seems not working.

Can anybody help me understanding how these FM calls and parameters works?

I'd like to manage 3 different cases:

- overwrite the version in update (OK, I got it),

- overwrite the version in update and try to distribute (OK, got it just flagging the 'iSave' param);

- don't overwrite, but create a new active version and don't distribute (that's still missing.. )

Thanks in advance and forgive this huge post 😊

EDIT: sorry, I forgot to specify that if I flag the IV_WITH_CHANGE_VERSION input parameter for the UPDATE FM, the update doesn't work. More precisely, it terminates without any error message but the effect is that nothing seems to be done.

Edited by: Matteo Montalto on Feb 27, 2009 5:55 PM