Author Topic: RFC CALL: BAPI_USER_EXISTENCE_CHECK  (Read 3825 times)

lakshmi.k

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 7
    • View Profile
RFC CALL: BAPI_USER_EXISTENCE_CHECK
« on: June 19, 2024, 02:23:34 AM »
Purpose:
Below example demonstrates to check the existence of username by calling BAPI_USER_EXISTENCE_CHECK function module on Easy Access Screen.

Note:
To make the function module call, it is required to provide the rfc parameters in the configuration file i.e., guixt.sjs

Liquid UI Code:
-----------------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs
-----------------------------------------------------------------------------------------------------------------------------------------------------
clearscreen();

//User Interface
inputfield([1,0],"User name",[1,10],{"name":"z_user_name","size":15});
pushbutton([3,1],"Check User Exist","?",{"size":[2,20],"process":z_fmCallGetData});



//Functions
// Function trim, to remove blank spaces from variable values
String.prototype.trim = function() {
   return this.replace(/^\s+|\s+$/g,"");
}

// Function to return trimmed string
function getString(strInput) {
   return(typeof(strInput) == 'undefined' || strInput == 'undefined')? "" : strInput.toString().trim();
}

// Function to check for blank string
function isBlank(strInput) {
   var strVal = getString(strInput);
   var blank = strVal == "";
   return blank;
}



//Function to call Bapi and display results
function z_fmCallGetData() {
   rfcresult = call('BAPI_USER_EXISTENCE_CHECK',{'in.USERNAME':'&V[z_user_name]','out.RETURN':'z_return'});
   if(rfcresult.rfc_rc != 0){
      // Cannot Call RFC for any reason
      // RFC call was *NOT* successful.
      // Display message to user, that rfc cannot be called (you can use the content of rfcresult.rfc_key)
      message('E:Error! RFC call failed to return data');
      enter("?");
      goto SCRIPT_END;
   }else {
      if(!isBlank(rfcresult.exception)){
         // RFC Call succeeded, but the ABAP code in the function module generated an exception
         // Display message to user, that rfc exception occured (you can use rfcresult.exception)
         message('E: Error!'+rfcresult.exception);
         enter('?');
         goto SCRIPT_END;
      }
   }
   
   // RFC Call was successful
   if(!isBlank(z_return)){
      set('V[z_user_exist]',z_return.substring(24,60));
   }
   
   message('S:'+ z_user_exist);
   set('V[z_user_name]','');
   enter("?");
   SCRIPT_END:;
   
}