Thursday 12 November 2009

ABAP: Once in a blue moon..

Yup, once in a blue moon, you'll get a kind of weird requirement to work on. And today, I'm getting one too, adding a serial number to an order which originally created from CRM.

In the first place, this is all bespoke, so, standard middleware wouldn't work. The serial number is passed through CRM order in a customer field and left out when the middleware is called in. What I need is to move this serial number over to R/3 and update the batch number too, in the order!!! Easy does it? Nope!!! But there is a way!

1. In CRM, there is a BDOC exchange BADI which I could use to transfer the serial number over to R/3, the BADI is CRM_DATAEXCHANGE_BADI, use the CRM_DATAEXCH_AFTER_BAPI_FILL method to fill in missing information. I need to enhance the BAPISDITM structure to add this new serial number field.

2. On the R/3 receiving end, thing doesn't seem to be that simple. The BAPI_SALESDOCU_PROXY_UPLOAD doesn't have BADI that I could use to transfer these fields from CRM but, yes, there always be a but. There is BTE available which I could use. BTE/Process 00501020/00501021 could be use to transfer some missing information from CRM to R/3, batch number could be assigned here, no problem. I need to enhance the BAPISDITM here too and probably the VBAPKOM structure too so I could pass this to the final user exit which is, yes, to assign this serial number to the order.

3. Now, how the heck am I going to update this serial number into the order? I have never done this before, I've done updating serials into delivery document but not to an order document. This yet to be tested but this URL seems to be promising, will try this one out:

https://forums.sdn.sap.com:443/thread.jspa?threadID=1470413

Two function modules described at the end of the thread there: IWOL_WV_ADD_OBJECTS & IWOL_WV_POST_OBJECT_LIST.

Will try this and see if I could get it to work! Wish me luck!

Update 1: Success!! Got it to work in less than a day .. couldn't pass the vbapkom to the final stage so I need to use an ABAP memory to pass the final table into the final user exit before I could post it. But somehow, the serial isn't get copied to a delivery document, no idea why, someone needs to fix this for sure. Functional problem :)

Update 2: A small hitch, after they fixed the config, a short dump occurs when creating a delivery. Probably something has to do with the serial counter at VBAP. Need to take a look into this..

Update 3: Scrapped everything on the last part, doesn't seem to work!!! Yes, I could get the serial into the order but as update no 2, I have problem when creating delivery document. It wasn't the serial counter but the object type in OBJK. So, I've implemented this using a new function module SERNR_ADD_TO_AU. I added this in userexit_save_document_prepare instead. I've no problem copying the serial number into the delivery document now.

2 comments:

9W2BSR said...

It is all greek to me but good luck anyway... :-)
I'm sure, in between the drooling, you can find the inspiration to solve the problem... |||8-r

9M2TPT said...

Muhaa..haa.. its alright Basir .. aku pun x paham some of your works gak ..

Calling MS SQL Stored Procedure from ABAP

One of the few things sometime coming up in your ticket request. Calling stored procedure from ABAP to remote SQL server.  How do we send th...