Skip to Content
0
Feb 06, 2019 at 05:21 PM

Checking data before next screen using Personas or BAPI is not working

92 Views

Hello Experts, I need to verify that the equipment typed in my IW21 flavor is present before going to the second screen where the data is entered. However, I have already tried to check the equipment in two ways and none of them work:

1. BAPI.

The BAPI is in the whitelist on the client, so much that it returns value in the table 'RETURN', but it is not the correct value. Here is the code:

var equ = session.findById("wnd[0]/usr/ctxtPersonas_154936602513861").text;	
var oRFC = session.createRFC("BAPI_EQUI_GETDETAIL");
	oRFC.setParameter("EQUIPMENT", equ);
	oRFC.requestResults(["DATA_SPECIFIC_EXP","RETURN"]);
	oRFC.send();
	var _DATA_SPECIFIC_EXP = oRFC.getResultObject("DATA_SPECIFIC_EXP");
	var _RETURN = oRFC.getResultObject("RETURN"); debugger
	if(!_DATA_SPECIFIC_EXP.EQUICATGRY){ 
	//LOGIC
	} 

To test it, I use the search help to fill the equipment, that is, if I am using a data that was previously selected in the system it means that the equipment exists. However:

When I use the same data and the same BAPI in ECC the data returns as expected - that is, the data is found.

2. Using Screen Navigation and Standard Check

In this option I tried to have the IW21 home screen data inserted into the second screen of the same transaction and let SAP verify that the Machine exists. This option works, however, when I try to identify the error and go back to the first screen with the error message the problem occurs. What happens is that my logic is not identifying the error msg.

//Check Equipment		
	if(session.findById("wnd[0]/sbar").messageNumber == "003"){debugger
		session.findById("wnd[0]/tbar[0]/btn[12]").press();	
		session.findById("wnd[1]/usr/btnSPOP-OPTION2").press();	
		session.utils.showOptionDialog("Equipment", "Equipment does not exist", 
							   session.utils.MESSAGE_TYPE_INFORMATION, session.utils.MESSAGE_OPTION_OK, onOptionDialogClose, "1");
	}

The debugger command soon after message identification is never reached. Important to mention that the message 003 is type E.

Does anyone know what I'm doing wrong in these two options or some other way of doing this error handling?

Thanks

Andrea

Attachments

equip-notfound.jpg (53.4 kB)