When creating sales order with BAPI_SALESORDER_CREATEFROMDAT2, we normally use the structure PARTNERADDRESSES to change the partner address data if needed. However, the "mobile phone" field is not contained in structure PARTNERADDRESSES. Means, in standard, the BAPI doesn't support maintaining the mobile phone number. It sometimes cause inconvenience in the project. :???:
With this blog post, I would like to share some information about how to enhance the structure PARTNERADDRESSES to make the maintaining of mobile phone possible.
1. Enhance structure BAPIADDR1.
Firstly, we need to check the enhancement category and change it if necessary. Follow the below path to check the Enhancement category of structure.
SE11 to change structure BAPIADDR1.
Then execute MENU >EXTRAS >ENHANCEMENT CATEGORY
Change it to: Can Be Enhanced (Deep).
Save and activate.
Secondly, create structure APPEND_BAPIADDR1_2 in the System and append this structure to structure BAPIADDR1.
For this purpose, proceed as follows:
Use Transaction SE11 to display structure BAPIADDR1. Via 'Goto' -> 'Append structure' the system issues a dialog box.
If you have no append structure, the dialog box will be like below. Enter 'APPEND_BAPIADDR1_2' into the input field.
If you have already an append structure for the structure BAPIADDR1, the pop-up will be like below. You can use the existing one, or click on the create button to create a new one like above.
After entering the Append Name and pressing enter, we come to the append structure creation screen as below. Enter the text and the field as below.
As a short text, enter 'APPEND for mobile phone number in structure BAPIADDR1'. You can enter any other text if you want.
For the "Component", I use "MOB_NUMBER" here. You can enter any value you want. It is the name of the field. You will see this name in the BAPI structure. And you need use the same field name when enhancing the interface. (I will show later.)
For the "Component type", please enter "AD_MBNMBR1".
Save and activate the append structure.
Now, you will be able to see the MOB_NUMBER already in structure PARTNERADDRESSES as below, when executing BAPI_SALESORDER_CREATEFROMDAT2 in SE37. But it will not work, because the interface program has not been enhanced.
2. Enhance interface program: FM ADDR_CONVERT_FROM_BAPIADDR1.
The sample code is:
* pass mobile phone number to sales order address.
Here, you can see that I am passing the ADDR1_COMPLETE_BAPI-MOB_NUMBER value to ADTEL_WA-ADTEL-TEL_NUMBER. If you use other field name than MOB_NUMBER, then you will need to adjust the coding part accordingly.
ADTEL_WA-ADTEL-R3_USER = '3' is to tell the system that this number is the mobile phone number.
As for the place where to put the code, it is actually not important, only if you don't interrupt the existing code. The easiest way is to insert the code at the end of the FM.
I would suggest putting the coding here as below. Because it is just after the code for Telephone field. It looks beautiful. :lol:
Activate the code.
Enhancement finished. :cool:
Now, you will be able to maintain the mobile phone number when creating sales order with BAPI_SALESORDER_CREATEFROMDAT2.
By the way, don't forget to link the address with ORDER_PARTNERS-ADDRESS = PARTNERADDRESSES-ADDR_NO. :wink: