see, ME31K is a online transaction, SAP can communicate with the user, can send warning messages to make the user think, can send pop-ups with yes/no decisions, the user is able to see what SAP did and can directly take corrective actions.
All this is not possible in a BAPI, hence you have to prepare your BAPI call with the wanted values. The determination of those values is made by the programmer in the calling program before the BAPI is called. And even the functionality of the BAPI may be limited compared to the online transaction, e.g. scales and volume rebates are not supported among many other restrictions as you can read in the docu to this BAPI.