Quantcast
Channel: SCN: Message List - Supplier Relationship Management (SAP SRM)
Viewing all articles
Browse latest Browse all 6690

Re: Split PO in SRM

$
0
0

Hello all,

 

It depends of the scenario.

For the shopping cart transfer to external ([How to|http://wiki.sdn.sap.com/wiki/display/SRM/TransferprocessoftheShopping+Cart]) you can use BADI BBP_SC_TRANSFER_BE (Exit for Transferring Shopping Cart to the Backend).

For the shopping cart in classic scenario, you can use BADI BBP_GROUP_LOC_PO (Exit Grouping of Items for Local Purchase Orders).

 

If you want, I have an example for the local solution:

 

METHOD if_ex_bbp_group_loc_po~group_po.
*------------------------------------------------------------------------------*
* Exit Grouping of Items for Local Purchase Orders
** Parameters
*ITEM_DATA  TYPE BBP_INT_ITEM_GROUP Item Data for Shopping Basket Item
*It contains the most important item details of the shopping cart and
*additionally in the field REFNUMBER a reference number for further
*processing purposes
*------------------------------------------------------------------------------*
* Method used to group item before PO creation
* How it work ?
* 1/ Select extra colons from table ZPO_SPLIT_CRITER
* 2/ Getting Compoents from existing type BBP_INT_ITEM_GROUP
* 3/ For each line recalcul Refnumber
**********************************************************************
* Declarations
**********************************************************************
*--------------------------------------------------------------------*
* Variable
*--------------------------------------------------------------------*  DATA: lt_zpo_split_criter TYPE TABLE OF zpo_split_criter      , ls_zpo_split_criter TYPE zpo_split_criter      , lo_struct           TYPE REF TO cl_abap_structdescr      , lt_field_list       TYPE ddfields      , ls_field_list       TYPE dfies      .  DATA:    lt_item_data     TYPE bbp_int_item_group  , ls_item_data     TYPE bbp_int_item_groups  , ls_back_data     TYPE bbp_int_item_groups  , ls_modi_data     TYPE bbp_int_item_groups  , l_fname          TYPE fieldname  , l_refnumber      TYPE refnumber  , l_tabix          TYPE sytabix  , l_not_empty      TYPE c  , l_act_not_empty  TYPE c  .
*--------------------------------------------------------------------*
* Field symbols
*--------------------------------------------------------------------*  FIELD-SYMBOLS: <lfs_refnumber>       TYPE bbp_int_item_groups-refnumber               , <lfs_act_refnumber>   TYPE bbp_int_item_groups-refnumber               , <lfs_field_value>     TYPE ANY               , <lfs_act_field_value> TYPE AN               .
*--------------------------------------------------------------------*
* Constants
*--------------------------------------------------------------------*
*  CONSTANTS:
*  .
**********************************************************************
* Process
**********************************************************************
* 1/ Select extra colons from table ZPO_SPLIT_CRITER  SELECT * FROM zpo_split_criter INTO TABLE lt_zpo_split_criter    WHERE split EQ 'X'.  CHECK NOT lt_zpo_split_criter[] IS INITIAL.  DELETE lt_zpo_split_criter WHERE fieldname = 'REFNUMBER'.

* 2/ Getting Compoents from existing type
  lo_struct ?= cl_abap_typedescr=>describe_by_name( 'bbp_int_item_groups' ).  CALL METHOD lo_struct->get_ddic_field_list    EXPORTING      p_langu                  = sy-langu      p_including_substructres = abap_true    RECEIVING      p_field_list             = lt_field_list    EXCEPTIONS      not_found                = 1      no_ddic_type             = 2      OTHERS                   = 3.  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.  ENDIF.  LOOP AT lt_zpo_split_criter INTO ls_zpo_split_criter.
*   Verify if field exist in table    READ TABLE lt_field_list         TRANSPORTING NO FIELDS         WITH KEY fieldname = ls_zpo_split_criter-fieldname.    CHECK sy-subrc EQ 0.

*   Copy table in internal    lt_item_data[] = item_data[].

*   Sort table by REFNUMBER and fieldname    SORT lt_item_data      BY refnumber (ls_zpo_split_criter-fieldname)      ASCENDING.

*   Clear internal value.    CLEAR: l_refnumber         .    CONCATENATE 'LS_ITEM_DATA-' ls_zpo_split_criter-fieldname      INTO l_fname.    ASSIGN (l_fname) TO <lfs_act_field_value>.    CHECK sy-subrc = 0.    CONCATENATE 'LS_BACK_DATA-' ls_zpo_split_criter-fieldname      INTO l_fname.    ASSIGN (l_fname) TO <lfs_field_value>.    CHECK sy-subrc = 0.    CONCATENATE 'LS_ITEM_DATA-' 'REFNUMBER'      INTO l_fname.    ASSIGN (l_fname) TO <lfs_act_refnumber>.    CHECK sy-subrc = 0.    CONCATENATE 'LS_BACK_DATA-' 'REFNUMBER'      INTO l_fname.    ASSIGN (l_fname) TO <lfs_refnumber>.    CHECK sy-subrc = 0.    CLEAR: <lfs_refnumber>         , <lfs_field_value>         .

*   For each reccord in table, calculate new REFNUMBER    LOOP AT lt_item_data INTO ls_item_data.      MOVE sy-tabix TO l_tabix.      IF <lfs_act_field_value> IS INITIAL.        MOVE ' ' TO l_act_not_empty.      ENDIF.      IF ls_zpo_split_criter-as_not_blank IS INITIAL.
*       Case of each value on field create a new refnumber        IF <lfs_field_value> NE <lfs_act_field_value> OR           <lfs_refnumber> NE <lfs_act_refnumber> .          l_refnumber = l_refnumber + 1.          MOVE <lfs_act_field_value> TO <lfs_field_value>.          MOVE <lfs_act_refnumber> TO <lfs_refnumber>.        ENDIF.      ELSE.        IF l_not_empty NE l_act_not_empty OR           <lfs_refnumber> NE <lfs_act_refnumber> .          l_refnumber = l_refnumber + 1.          MOVE l_act_not_empty TO l_not_empty.          MOVE <lfs_act_refnumber> TO <lfs_refnumber>.        ENDIF.      ENDIF.      ls_modi_data = ls_item_data.      ls_modi_data-refnumber = l_refnumber.      MODIFY item_data FROM ls_modi_data INDEX l_tabix             TRANSPORTING refnumber.    ENDLOOP.  ENDLOOP.

ENDMETHOD.

 

 

 

It works with the table ZPO_SPLIT_CRITER as bellow:

CLIENT                 MANDT

FIELDNAME         FIELDNAME

SPLIT                 BOOLE_D

AS_NOT_BLANK BOOLE_D

 

If you need more information, contact me directly.

Regards,

 

David BOUTIER<BR>

Consultant technique Sap Netweaver - KALYDIA

www.kalydia.com Paris

 

Edited by: David BOUTIER on Jun 27, 2011 11:38 AM


Viewing all articles
Browse latest Browse all 6690

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>