cancel
Showing results for 
Search instead for 
Did you mean: 

Update and create a new version of a PO

matteo_montalto
Contributor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member206968
Active Contributor
0 Kudos

Hi,

Did you check if the PO version management is active in the SRM system. The setting is defined in txn-SPRO-SRM server>cross-application basic settings>version management. Try changing the po manually in srm system and then check if change version is created.

Regards,

Sanjeev

matteo_montalto
Contributor
0 Kudos

Hi Sanjeev and thanks for your help,

the SRM system supports surely versioning, as I can easily see entering on SRM by the web gui and changing a PO. After the mod's done, I can easily see that there are two different version of that PO in the table (I don't have access to the sys right now, anyway I'm quite sure that the table is CRMD_ORDERADM_H).

matteo_montalto
Contributor
0 Kudos

Well, I'm now back on the system I was working on and can confirm that the version management is active in SRM.

Maybe I can formulate the question in a simpler way...

My task is quite simple: retrieve a Purchase Order in SRM (using the BBP_PD_PO_GETDETAIL function module), do some modifications on it (this step has been already tested) and then simply create a new version of the same purchase order (that obviously, will become the active version).

What I have in hand are the structures I got from the BBP_PD_PO_GETDETAIL, eventually modified.

Any hint? The solution posted above allows me to overwrite the PO active in SRM, I'd like to manage also the case in which the user wants to create a new version of the PO .

former_member206968
Active Contributor
0 Kudos

Hi,

In which srm version are you working. in srm5.0, there is a flag as iv_with_change_approval for bbp_pd_po_update. Set this as x and try updating the PO.

In case you do not have this parameter, then set iv_change_version as X. This time try without calling fm bbp_pd_po_save in your code. This fm is being called using active version guid and hence might be saving only active version.

Regards,

Sanjeev

matteo_montalto
Contributor
0 Kudos

Thanks, I solved... it was my mistake, I did not use the new guid of the header after the update process, that was the problem

Answers (0)