cancel
Showing results for 
Search instead for 
Did you mean: 

Could you check our source? (To determine the PR type and number range)

Former Member
0 Kudos

Hello.

We use SRM Server5.5 with Classic Scenario.

We will use the BADI BBP_SC_TRANSFER_BE to determine the PR type and number range according to your recommend.

We have two PR type in R/3.

1) KGPR

2) KTR1

As you know that shopping cart has no type. So we add customer field to mapping to R/3 PR type and this field has two values.

1) PR01: mapping to KGPR

2) PR02: mapping to KTR1

We will use the method GROUP_RQ to determine the PR type.

If customer field is PR01, PR type is determined KGPR

If customer field is PR002, PR type is determined KTR1.

To determine the PR number range, we will use the method GET_NUMBER_OR_RANGE.

If PR type is KGPR, Choose the No key 12

If PR type is KTR1, Choose the No key 16.

Configuration step:

1. Maintain the PR number range in SRM.

No key: 12 (for KGPR) internal NR

No range: 2520000000 – 2529000000

No key: 16 (for KTR1) internal NR

No range: 2560000000 – 2569000000

2. Maintain the PR number range in R/3

No key: 12 (for KGPR) Ext NR

No range: 2520000000 – 2529000000

No key: 16 (for KTR1) Ext NR

No range: 2560000000 – 2569000000

3. Assign the PR number range to PR type in R/3

KGPR – 12 (EXT)

KTR1 – 16 (EXT)

4. Maintain the attribute in SRM

Document type in R/3

Add KGPR and KTR1

We developed this logic, but it’s not working.

LOOP AT ct_proc_item INTO ls_proc_item “ Where is no date in ct_proc_item:

We can not find out the reason.

Could you check our source?

METHOD if_ex_bbp_sc_transfer_be~group_rq.

DATA:

ls_proc_item TYPE bbps_procurement,

lv_number_int TYPE bbp_item_no,

ls_item TYPE bbp_pds_transfer_item,

lv_group_counter TYPE numc5,

CONSTANTS:

lc_on(1) VALUE 'X'.

SORT ct_proc_item BY obj_to_gen.

CLEAR: lv_group_counter.

LOOP AT ct_proc_item INTO ls_proc_item

where obj_to_gen eq iv_object_to_generate.

    • get item data which includes customer fields

MOVE ls_proc_item-preq_item TO lv_number_int. " convert

READ TABLE it_item INTO ls_item WITH KEY number_int = lv_number_int.

IF sy-subrc = 0.

IF ls_item-pr_type EQ 'PR01'.

ls_proc_item-doc_type = 'KGRP'.

ELSEIF ls_item-pr_type EQ 'PR02'.

ls_proc_item-doc_type = 'KTR1'.

ENDIF. " lv_cust_field

lv_group_counter = lv_group_counter + 1. " increase counter

ls_proc_item-group_1 = lv_group_counter.

*

MODIFY ct_proc_item FROM ls_proc_item

TRANSPORTING group_1.

ENDIF. " sy-subrc

*

ENDLOOP.

cv_method_active = lc_on.

ENDMETHOD.

-


method IF_EX_BBP_SC_TRANSFER_BE~GET_NUMBER_OR_RANGE.

if is_item-pr_type = 'PR01'.

CV_NUMBER_RANGE = '12'.

CV_NUMBER = '2520000000'.

elseif is_item-pr_type = 'PR02'.

CV_NUMBER_RANGE = '16'.

CV_NUMBER = '2560000000'.

endif. " is_proc_item / is_item

Thank you

Best Regard

SH

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

Any updates. Is your problem solved.

Do let me know.

If yes, please close the thread and award suitable points.

Regards

- Atul

Former Member
0 Kudos

Thank you for your reply.

But we have already know the sample program.

As you see our source, we used to sample program.

But We still have a problem, I think we should study more about this.

Thank you for your answer.

It's useful answer.

Ramki
Active Contributor
0 Kudos

Hi So Hee Lee

Can you pl use BBP_CREATE_BE_RQ_NEW for changing document type ?

Pl use BBP_BS_GROUP_BE for changing number ranges (this is similar to BBP_SC_TRANSFER_BE).

The sequence is like this:

First BBP_BS_GROUP_BE is called.

Then BBP_CREATE_BE_RQ_NEW is called.

Best regards

Ramki

Former Member
0 Kudos

Thank you for our reply.

Could you expain more detail?

Or Could you send me the sample source, if it's possible?

Best Regards

SH

Former Member
0 Kudos

Hi

Please find some suitable sample code, which might help you out.

----


method IF_EX_BBP_SC_TRANSFER_BE~GET_NUMBER_OR_RANGE .

* IV_OBJECT_TO_GENERATE
*   '1' Reservation
*   '2' Purchase Requsition (BANF)
*   '3' Purchase Order
*   '4' Customer Object


* 1. current item data are in structures
*    - IS_ITEM shopping cart item data including Customer Fields
*    - IS_PROC backend relevant item purchasing data


* 2. accounting data in tables
*    - IT_ACCOUNT all shopping cart account. data with Customer Fields
*    - IT_PROC_ACCOUNT backend relevant accounting data for current item

*  - key criteria between this tables are
*    - it_proc_account-preq_item
*                     -serial_no (numc 2)
*    - guid from is_item
*    - it_account-p_guid
*                -accno(numc 4)



*--------------------------------------------------------------------
* A) example to use current item data + item customer fields
*--------------------------------------------------------------------
*  if is_proc_item-DOC_TYPE = 'ABCD' AND
*     is_item-<field of CI_BBP_ITEM> = .
* set own number range
*  CV_NUMBER_RANGE = .


** set own number
** .. ==> if initial SAP Standard with no.range will be processed

*  CV_NUMBER = .

*  endif. " is_proc_item / is_item

*--------------------------------------------------------------------
* B) example to use only proc_account no accounting customer fields
*--------------------------------------------------------------------
*data:
*     ls_proc_account   type bbp_bapipogna.

*  loop at it_proc_account
*            into ls_proc_account.
*
*
*    if ls_proc_account-BUS_AREA = '9988'.

** set own number range
*  CV_NUMBER_RANGE = .


** set own number
** .. ==> if initial SAP Standard with no.range will be processed

*  CV_NUMBER = .

*     endif. " ls_proc_account
*
*  endloop.


*--------------------------------------------------------------------
* C) example to use only accounting customer fields, no other accounting
*--------------------------------------------------------------------
*data:
*     ls_account        type bbp_pds_acc.

*  loop at it_account
*            into ls_account
*            where p_guid = is_item-guid.

*    if ls_account-<field of CI_BBP_ACC> = .
** set own number range
*  CV_NUMBER_RANGE = .


** set own number
** .. ==> if initial SAP Standard with no.range will be processed

*  CV_NUMBER = .

*   endif. " ls_account

*  endloop.

*--------------------------------------------------------------------
* D) example to use proc_account + customer fields for accounting
*--------------------------------------------------------------------
*data:
*     lv_serial_no      type bbp_bapipogna-serial_no,  " sequence num 2
*     lv_acc_no         type bbp_pds_acc-acc_no,       " sequence num 4
*     ls_proc_account   type bbp_bapipogna,
*     ls_account        type bbp_pds_acc.

*  loop at it_proc_account
*            into ls_proc_account.
*
*    move ls_proc_account-serial_no to lv_acc_no.
*    read table it_account
*         into ls_account
*         with key p_guid = is_item-guid
*                  acc_no = lv_acc_no.
*
*    if sy-subrc = 0.
*
**     if ls_account-<field of CI_BBP_ACC> = .
*
** set own number range
**  CV_NUMBER_RANGE = .
*
*
** set own number
** .. ==> if initial SAP Standard with no.range will be processed
*
**  CV_NUMBER = .
*
**      endif. " ls_account
*
*    endif. " sy-subrc
*  endloop.
endmethod.

----


method IF_EX_BBP_SC_TRANSFER_BE~GROUP_RQ .

* 1. current item data are in structures
*
*    - IT_ITEM all shopping cart item data including Customer Fields
*    - IT_PROC_ITEM backend relevant item data of current log.system
*
*    key criteria between this tables are:
*    - IT_ITEM-NUMBER_INT (numc 10)
*    - IT_PROC_ITEM       (numc  5)

* 2. accounting data in tables
*
*    - IT_ACCOUNT all shopping cart account. data incl. Customer Fields
*    - IT_PROC_ACCOUNT backend relevant accounting data for current item
*
*  - key criteria between this tables are
*    - it_proc_account-preq_item (numc 5)
*                     -serial_no (numc 2)
*    - is_item-guid
*             -number_int (numc 10)
*    - it_account-p_guid
*                -accno(numc 4)

constants:
      lc_on(1)               VALUE 'X'.


*--------------------------------------------------------------------
* A) example to use only proc_item with NO customer fields
*         group requisitions by backend document type
*--------------------------------------------------------------------
*data: lv_doc_type            TYPE esart,
*      ls_proc_item           type BBPS_PROCUREMENT,
*      lv_group_counter       type numc5.
*
*
*    clear lv_group_counter.
*    clear lv_doc_type.
*    SORT ct_proc_item BY obj_to_gen doc_type.
*
*    LOOP AT ct_proc_item
*            into ls_proc_item
*            WHERE obj_to_gen EQ iv_object_to_generate.

** new group criteria?
*      if lv_doc_type ne ls_proc_item-doc_type.     " backend doc.type
*
*        lv_group_counter = lv_group_counter + 1.   " increase counter
*        lv_doc_type      = ls_proc_item-doc_type.       " save criteria
*
*      endif.
*
*      ls_proc_item-group_1 = lv_group_counter.
*
*      modify ct_proc_item from ls_proc_item
*             transporting group_1.
*
*    ENDLOOP.

*--------------------------------------------------------------------
* B) example to use item customer fields
*--------------------------------------------------------------------

* data:
*      ls_proc_item           type BBPS_PROCUREMENT,
*      lv_cust_field          type <field of ci_bbp_item>.
*      lv_number_int          type BBP_ITEM_NO,
*      ls_item                type BBP_PDS_TRANSFER_ITEM.

*    clear lv_group_counter.
*    clear lv_cust_field .
*    SORT ct_proc_item BY obj_to_gen.
*
*
*    LOOP AT ct_proc_item
*            into ls_proc_item
*            WHERE obj_to_gen EQ iv_object_to_generate.

** get item data which includes customer fields
*      move ls_proc_item-preq_item to lv_number_int. " convert
*      read table it_item
*           into ls_item
*           with key number_int = lv_number_int.
*
*      if sy-subrc = 0.
*
**       new group criteria?
*        if lv_cust_field ne 'XYZ'.
*
*         lv_group_counter = lv_group_counter + 1.   " increase counter
*         lv_cust_field = ls_item-<field of ci_bbp_item>."save criteria
*
*        endif. " lv_cust_field

*        ls_proc_item-group_1 = lv_group_counter.
*
*        modify ct_proc_item from ls_proc_item
*               transporting group_1.
*
*      endif.  " sy-subrc
*
*    ENDLOOP.

*--------------------------------------------------------------------
* C) example to use accounting data with customer fields
*            group requisitions by backend document type
*--------------------------------------------------------------------
*data: lv_doc_type            TYPE esart,
*      ls_proc_item           type BBPS_PROCUREMENT,
*      lt_account             type BBPT_PD_ACC,
*      ls_account             type bbp_pds_acc,
*      ls_item                type BBP_PDS_TRANSFER_ITEM,
*      lv_number_int          type BBP_ITEM_NO,
*      lv_account_flag        type c,
*      lv_group_counter       type numc5.
*
*
*    clear lv_group_counter.
*    clear lv_doc_type.
*    SORT ct_proc_item BY obj_to_gen doc_type.
*
*    lt_account[] = it_account[].
*    SORT lt_account BY p_guid acc_no.
*
*    LOOP AT ct_proc_item
*            into ls_proc_item
*            WHERE obj_to_gen EQ iv_object_to_generate.
*
** get accounting customer fields for this item
*    clear lv_account_flag.
*
** ..first get item guid
*    move ls_proc_item-preq_item to lv_number_int.
*    read table it_item
*         into ls_item
*         with key number_int = lv_number_int.
*
*    if sy-subrc = 0.
*
*      loop at lt_account
*           into ls_account
*           where p_guid = ls_item-guid.
*
*        if ls_account-<field of CI_BBP_ACC> = .
*           lv_account_flag = lc_on.
*        endif.
*
*      endloop.
*
*    endif. " sy-subrc it_item
*
*
** new group criteria?
*      if lv_doc_type ne ls_proc_item-doc_type OR     " backend doc.type
*         lv_account_flag = lc_on.                    " accounting
*
*        lv_group_counter = lv_group_counter + 1.   " increase counter
*        lv_doc_type      = ls_proc_item-doc_type.       " save criteria
*
*      endif.
*
*      ls_proc_item-group_1 = lv_group_counter.
*
*      modify ct_proc_item from ls_proc_item
*             transporting group_1.
*
*    ENDLOOP.


* !!!! set flag that BADI was processed
* .. ==> no SAP Standard grouping will be processed
    cv_method_active = lc_on.
endmethod.

----


Hope this will help.

Please reward suitable points, incase it suits your requirements.

Regards

- Atul

Ramki
Active Contributor
0 Kudos

Hi So Hee Lee

I do not have the codes other than the ones sent by Atul.

One tip:

Any BADI standard sample codes and documentation can be viewed from SE18 transaction.

Best regards

Ramki