Well, since my bread and butter is SAP, I have found some new tricks since I was last blogging, so might as well sprinkle those in along with all my new endeavors. ha ha ha.
I guess this blog post could also have been called implementing a Badi… but that doesn’t so as much fun 🙂 My goal was to add some additional links into the Warranty Claims document flow. Namely, I wanted to see purchase orders that might be generated during the flow of the claim. Out of the box, these are not part of document flow, so I began searching on how to do it.
Everything started with using this blog post to get me started on how to do the Badi. But of course, the real work came from figuring out how to get it all connected. So first let me tell you some of the basic data you will need to make this work:
BAdi Definition: WTY_DOCU_FLOW
Interface: IF_EX_WTY_DOCU_FLOW
I needed to update 2 methods in order to make it all work.
- ADD_DOCUMENT – this adds the link into document flow
-
DATA:
lt_gbinrel TYPE TABLE OF gbinrel,
gs_wdocs TYPE pwty_wdocs,
lt_trl_borid TYPE trl_borid,
ls_trl_borid TYPE borident.
**** via document relation
CALL FUNCTION ‘WTY03_RELATION_FIND’
EXPORTING
iv_claim = IV_CLMNO
TABLES
et_gbinrel = lt_gbinrel
et_object = lt_trl_borid.
LOOP AT lt_trl_borid INTO ls_trl_borid.
CASE ls_trl_borid–objtype.
WHEN ‘BUS2012’.
gs_wdocs–doctype = ‘EBELN’.
gs_wdocs–docttext = ‘Purchase Order’.
gs_wdocs–clmno = IV_CLMNO.
gs_wdocs–docno = ls_trl_borid–objkey.
APPEND gs_wdocs TO ct_wdocs.
ENDCASE.
ENDLOOP.
-
- DOCUMENT_DISPLAY – I enhanced this so that you could double click on the node in document and drill to the PO
- Data: ld_ebeln type eblen.
- case is_wdocs-doctype.
- when ‘EBELN’.
- ld_ebeln = IS_WDOCS-docno.
- set parameter ID ‘BES’ FIELD ld_ebeln.
- call transaction ‘ME23N’ and skip first screen
- when ‘EBELN’.
- endcase.
Now, of course there isn’t Purchase order action out of the box either… so I had to build that as well. to do that, I had to define an action (see TXN: OWTY –> Control Data –> Process Control –> Define Actions)
I created a new one, and then assigned a function module to it that called a BAPI to create the PO (and of course it pulled data from the claim to have it all happen in the background). If you would like more details on creating this function, let me know and I can walk you through that in a future post. The key piece of this is to create the document flow links using the function ‘BINARY_RELATION_CREATE’. this links the PO and claim.
Once you have the new action, you need to build it into the Action controls and of course, play with a bit to make sure 1) you are creating the PO, 2) you are linked to it and 3) that your BAdi above is firing to add the document flow.
All and all, it was a lot more moving pieces than I expected, but it was a fun exercise (once it was done. LOL).
Ping me if you have issues, and as always, thanks for reading,