cancel
Showing results for 
Search instead for 
Did you mean: 

Change document type on follow on document in Classic Scenario

Former Member
0 Kudos

Hi All,

We have the classic scenario of SRM.

We have a requirement that PR with specific document type should be created in the backend,based on some field values in the Shopping cart.

I created an implementation for the BADI, BBP_CREATE_BE_RQ_NEW for this requirement, but it doesnt seem to be working.

Is there any other BADI which lets you change the document type for the follow on document, PR in our case.

Please let me know.

Thanks in Advance,

Binu

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Deepti,

This is the code:

DATA: gs_sc_item TYPE bbp_pds_transfer_item," SC Item table

gs_rq_items TYPE bbps_badi_rq_item, " PR Items table

gv_tabix TYPE sytabix,

gv_item_no(5) TYPE n,

gv_sc_no TYPE crmt_object_id_db, " Shopping Cart No.

gs_sc_account TYPE bbps_pdext_acc, " SC Account table

gs_rq_accnt_assignm type BBPS_BADI_RQ_ACCOUNT.

CONSTANTS: c_doctype TYPE bbsrt VALUE 'GP', " Document Type

c_item_cat TYPE pstyp VALUE '2', " Item Category

c_vmi TYPE bbp_acc_cat VALUE 'FI'. " VMI Identifier

TYPES: BEGIN OF ty_sc_det,

cart_no TYPE crmt_object_id_db,

guid TYPE bbp_guid,

END OF ty_sc_det.

DATA: gt_sc_det TYPE STANDARD TABLE OF ty_sc_det,

gs_sc_det type ty_sc_det.

CLEAR: gs_sc_item.

LOOP AT is_sc_document-item INTO gs_sc_item.

gv_tabix = sy-tabix.

  • Read the account table for the SC Line Item

READ TABLE is_sc_document-account INTO gs_sc_account

WITH KEY p_guid = gs_sc_item-guid.

  • Check if the Account Assignment Category on SC line item

  • corresponds to VMI

IF sy-subrc = 0 AND gs_sc_account-acc_cat = c_vmi

AND NOT gs_sc_account IS INITIAL.

  • Get the PR line item corresponding to SC line item

READ TABLE cs_rq_document-it_requisition_items index gv_tabix INTO gs_rq_items.

IF sy-subrc = 0 AND NOT gs_rq_items IS INITIAL.

  • gv_tabix = sy-tabix.

    • Set the item category and document type on PR line item

gs_rq_items-item_cat = c_item_cat.

gs_rq_items-doc_type = c_doctype.

  • Get the SC Number using the GUID

SELECT SINGLE object_id FROM crmd_orderadm_h INTO gv_sc_no

WHERE guid = gs_sc_item-parent.

IF sy-subrc = 0 AND NOT gv_sc_no IS INITIAL.

  • Assign the SC number to the tracking number field on PR line item

gs_rq_items-trackingno = gv_sc_no.

ENDIF.

MODIFY cs_rq_document-it_requisition_items INDEX gv_tabix FROM gs_rq_items

TRANSPORTING doc_type trackingno item_cat.

ENDIF.

ENDIF.

CLEAR: gv_item_no, gs_sc_account,

gs_rq_items, gv_tabix, gv_sc_no.

ENDLOOP.

If I attempt to change the doc type or item category, PR no gets relected in transaction, bbp_pd. However the same is not available in r/3 system.

If i just change fields like tracking no or description and not document type, PR gets successfully created in backend.

Please let me know your inputs.

Thanks,

Binu

Former Member
0 Kudos

Yes, I could acheive this using the same BADI.

There were some config issues causing the problem

Thanks,

Binu

former_member315621
Discoverer
0 Kudos

How to solve this issue... How to change doc_type in the ERP ?

Former Member
0 Kudos

Hi Binu,

The BADI you have implemented is correct.Please paste the code here for further analysis.I dont think there is any other BADI available for your requirement.The badi BBP_CREATE_BE_RQ_NEW is BADi to be used.,but may be you have coded it incorrectly due to which you are not getting the correct o/p.

Another way would be to use the user exit function EXIT_SAPLMEWQ_001 in the BAPI BAPI_REQUISITION_CREATE for document type mapping as mentioned in below thread :

HTH.

BR,

Deepti.