How can you use a BADI which does not contain desire import or export data ?
Many time such condition occurs when you find a perfect BADI for your requirement but As the BADI does not contains proper import data you cant use it.
Lets take an example for BADI Delivery_publish.
This BADI gets trigger when you do the POST Goods issue.
Now this BADI does not contain any input parameter.So ideally it is of no use if you want to perform a particular task on that delivery,
So what can be done!!!!!!!!!!!!
SAP has given a unique solution for this kind of problem.
See the below code:::
DATA : V_MAT_DOCU TYPE EMKPF-MBLNR.
FIELD-SYMBOLS : <V_MAT> TYPE EMKPF-MBLNR.
DATA : V_VAL TYPE STRING VALUE ‘(SAPMV50A)emkpf-MBLNR’.
ASSIGN (V_VAL) TO <V_MAT>.
MOVE <V_MAT> TO V_MAT_DOCU.
I can able to find the material Document No. Here..
Here we have use field symbols for reading a global variable EMKPF. Which is there in main program SAPMV50A.
(Note : It is not mandatory that you can access this program’s global variable only.You can access all the program’s global variable which are initialized in the current call sequence.
Note : if you don’t know the main program name you can find it from system table SYST and field CPROG.Now go to this program and check the top include where u will find the EMKPF table .So here is the guess that this variable might have the data initialize by Standard SAP before calling this BADI.u can see this variable in debugging mode by (SAPMV50A)emkpf-MBLNR.
Note : Don’t ever change value As it may effect the standard SAP codes.