Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 11577

Re: Classic scenario service PO replication

$
0
0

Can you please elaborate more on this .

from what I understand you want the SC item to not split into different PO  generally it spits based on different shipping address maintained . You can also check this in BADI ZBBP_GROUP_LOC_PO

 

Below is a sample code I found from one of the earlier threads as below :

 

http://scn.sap.com/message/2772557#2772557

http://scn.sap.com/message/3155145#3155145

http://scn.sap.com/message/2877448#2877448

http://scn.sap.com/message/2371974#2371974

https://scn.sap.com/thread/2026160

https://scn.sap.com/thread/54153

 

 

 

METHOD if_ex_bbp_group_loc_po~group_po.<BR>

*------------------------------------------------------------------------------*<BR>

* Exit Grouping of Items for Local Purchase Orders<BR>

** Parameters<BR>

*ITEM_DATA  TYPE BBP_INT_ITEM_GROUP Item Data for Shopping Basket Item<BR>

*It contains the most important item details of the shopping cart and<BR>

*additionally in the field REFNUMBER a reference number for further<BR>

*processing purposes<BR>

*------------------------------------------------------------------------------*<BR>

* Method used to group item before PO creation<BR>

* How it work ?<BR>

* 1/ Select extra colons from table ZPO_SPLIT_CRITER<BR>

* 2/ Getting Compoents from existing type BBP_INT_ITEM_GROUP<BR>

* 3/ For each line recalcul Refnumber<BR>

**********************************************************************<BR>

* Declarations<BR>

**********************************************************************<BR>

*--------------------------------------------------------------------*<BR>

* Variable<BR>

*--------------------------------------------------------------------*<BR>

  DATA: lt_zpo_split_criter TYPE TABLE OF zpo_split_criter<BR>

      , ls_zpo_split_criter TYPE zpo_split_criter<BR>

      , lo_struct           TYPE REF TO cl_abap_structdescr<BR>

      , lt_field_list       TYPE ddfields<BR>

      , ls_field_list       TYPE dfies<BR>

      .<BR>

<BR>

  DATA:<BR>

    lt_item_data     TYPE bbp_int_item_group<BR>

  , ls_item_data     TYPE bbp_int_item_groups<BR>

  , ls_back_data     TYPE bbp_int_item_groups<BR>

  , ls_modi_data     TYPE bbp_int_item_groups<BR>

  , l_fname          TYPE fieldname<BR>

  , l_refnumber      TYPE refnumber<BR>

  , l_tabix          TYPE sytabix<BR>

  , l_not_empty      TYPE c<BR>

  , l_act_not_empty  TYPE c<BR>

  .<BR>

*--------------------------------------------------------------------*<BR>

* Field symbols<BR>

*--------------------------------------------------------------------*<BR>

  FIELD-SYMBOLS: <lfs_refnumber>       TYPE bbp_int_item_groups-refnumber<BR>

               , <lfs_act_refnumber>   TYPE bbp_int_item_groups-refnumber<BR>

               , <lfs_field_value>     TYPE ANY<BR>

               , <lfs_act_field_value> TYPE ANY<BR>

               .<BR>

*--------------------------------------------------------------------*<BR>

* Constants<BR>

*--------------------------------------------------------------------*<BR>

*  CONSTANTS:<BR>

*  .<BR>

**********************************************************************<BR>

* Process<BR>

**********************************************************************<BR>

* 1/ Select extra colons from table ZPO_SPLIT_CRITER<BR>

  SELECT * FROM zpo_split_criter INTO TABLE lt_zpo_split_criter<BR>

    WHERE split EQ 'X'.<BR>

  CHECK NOT lt_zpo_split_criter[] IS INITIAL.<BR>

  DELETE lt_zpo_split_criter WHERE fieldname = 'REFNUMBER'.<BR>

<BR>

* 2/ Getting Compoents from existing type<BR>

  lo_struct ?= cl_abap_typedescr=>describe_by_name( 'bbp_int_item_groups' ).<BR>

  CALL METHOD lo_struct->get_ddic_field_list<BR>

    EXPORTING<BR>

      p_langu                  = sy-langu<BR>

      p_including_substructres = abap_true<BR>

    RECEIVING<BR>

      p_field_list             = lt_field_list<BR>

    EXCEPTIONS<BR>

      not_found                = 1<BR>

      no_ddic_type             = 2<BR>

      OTHERS                   = 3.<BR>

  IF sy-subrc <> 0.<BR>

*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO<BR>

*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.<BR>

  ENDIF.<BR>

<BR>

  LOOP AT lt_zpo_split_criter INTO ls_zpo_split_criter.<BR>

*   Verify if field exist in table<BR>

    READ TABLE lt_field_list<BR>

         TRANSPORTING NO FIELDS<BR>

         WITH KEY fieldname = ls_zpo_split_criter-fieldname.<BR>

    CHECK sy-subrc EQ 0.<BR>

<BR>

*   Copy table in internal<BR>

    lt_item_data[] = item_data[].<BR>

<BR>

*   Sort table by REFNUMBER and fieldname<BR>

    SORT lt_item_data<BR>

      BY refnumber (ls_zpo_split_criter-fieldname)<BR>

      ASCENDING.<BR>

<BR>

*   Clear internal value.<BR>

    CLEAR: l_refnumber<BR>

         .<BR>

<BR>

    CONCATENATE 'LS_ITEM_DATA-' ls_zpo_split_criter-fieldname<BR>

      INTO l_fname.<BR>

    ASSIGN (l_fname) TO <lfs_act_field_value>.<BR>

    CHECK sy-subrc = 0.<BR>

    CONCATENATE 'LS_BACK_DATA-' ls_zpo_split_criter-fieldname<BR>

      INTO l_fname.<BR>

    ASSIGN (l_fname) TO <lfs_field_value>.<BR>

    CHECK sy-subrc = 0.<BR>

    CONCATENATE 'LS_ITEM_DATA-' 'REFNUMBER'<BR>

      INTO l_fname.<BR>

    ASSIGN (l_fname) TO <lfs_act_refnumber>.<BR>

    CHECK sy-subrc = 0.<BR>

    CONCATENATE 'LS_BACK_DATA-' 'REFNUMBER'<BR>

      INTO l_fname.<BR>

    ASSIGN (l_fname) TO <lfs_refnumber>.<BR>

    CHECK sy-subrc = 0.<BR>

<BR>

    CLEAR: <lfs_refnumber><BR>

         , <lfs_field_value><BR>

         .<BR>

<BR>

*   For each reccord in table, calculate new REFNUMBER<BR>

    LOOP AT lt_item_data INTO ls_item_data.<BR>

      MOVE sy-tabix TO l_tabix.<BR>

      IF <lfs_act_field_value> IS INITIAL.<BR>

        MOVE ' ' TO l_act_not_empty.<BR>

      ENDIF.<BR>

<BR>

      IF ls_zpo_split_criter-as_not_blank IS INITIAL.<BR>

*       Case of each value on field create a new refnumber<BR>

        IF <lfs_field_value> NE <lfs_act_field_value> OR<BR>

           <lfs_refnumber> NE <lfs_act_refnumber> .<BR>

          l_refnumber = l_refnumber + 1.<BR>

          MOVE <lfs_act_field_value> TO <lfs_field_value>.<BR>

          MOVE <lfs_act_refnumber> TO <lfs_refnumber>.<BR>

        ENDIF.<BR>

      ELSE.<BR>

        IF l_not_empty NE l_act_not_empty OR<BR>

           <lfs_refnumber> NE <lfs_act_refnumber> .<BR>

          l_refnumber = l_refnumber + 1.<BR>

          MOVE l_act_not_empty TO l_not_empty.<BR>

          MOVE <lfs_act_refnumber> TO <lfs_refnumber>.<BR>

        ENDIF.<BR>

<BR>

      ENDIF.<BR>

      ls_modi_data = ls_item_data.<BR>

      ls_modi_data-refnumber = l_refnumber.<BR>

<BR>

      MODIFY item_data FROM ls_modi_data INDEX l_tabix<BR>

             TRANSPORTING refnumber.<BR>

    ENDLOOP.<BR>

  ENDLOOP.<BR>

<BR>

ENDMETHOD.

 

<BR>

 

<BR>

 

<BR>

 

It works with the table ZPO_SPLIT_CRITER as bellow:<BR>

 

CLIENT                     MANDT<BR>

 

FIELDNAME             FIELDNAME<BR>

 

SPLIT                     BOOLE_D<BR>

 

AS_NOT_BLANK     BOOLE_D<BR>

 

<BR>

 

If you need more information, contact me directly.<BR>

 

Regards, <BR>

 

<BR>

 

David BOUTIER<BR>

 

Consultant technique Sap Netweaver - KALYDIA<BR>

 

8, rue Pasquier - 75008 Paris<BR>


Viewing all articles
Browse latest Browse all 11577

Trending Articles



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