Skip to Content

For a few weeks we have installed Screen Personas on our system landscape. So I have played around with it a little bit and started to make my first experiences. But then we had an requirement where we really had to consider a real use.

Within a transation we had an ALV with many different layouts(and of course different columns). Besides this ALV there was the requirement for a sidepanel for additional data for a selected line.

Technical the ALV schould send a tag when a single line is selected. This tag is a value stored in a special column of this ALV. So there are two major problems. The first ist that this ALV doesn’t recognize the single click of a line so that you could send a value as tag to the Side Panel. It only recognizes a double click(jump to the next screen so it isn’t an option) or a right click(which isn’t confortable for the user). The next problem ist that there are many different layouts. So maybe the user has a layout where the specific column with the tagging relevant value istn’t displayed. So you could only send values to the sidepanel which are currently on the screen.

So I decided to try to find a soloution with our newest gimmick Screen Personas 🙂

I created a new Flavor and the first surprise was that you can catch a single click on a line and attach a script(it is now the SAP GUI for HTML).

I wrote the following script:

// select
var pscdbel;
var sRawRow = source.selectedRowsAbsolute;

	try{
    	pscdbel = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell[1]").getCellValue(Number(sRawRow), 'ZDZOPBEL');
		pscdbel_vorhanden = true;
	} catch(oError){
		pscdbel_vorhanden = false;
		session.findById("wnd[0]/tbar[1]/btn[32]").press();
		session.findById("wnd[1]/usr/tabsG_TS_ALV/tabpALV_M_R1/ssubSUB_DYN0510:SAPLSKBH:0620/cntlCONTAINER1_LAYO/shellcont/shell/tbar/btnFIND").press();
		session.findById("wnd[2]/usr/txtGS_SEARCH-VALUE").text = "PSCD-Belegnummer";
		session.findById("wnd[2]/usr/txtGS_SEARCH-VALUE").setFocus();
		session.findById("wnd[2]/tbar[0]/btn[0]").press();
		session.findById("wnd[2]/usr/cmbGS_SEARCH-SEARCH_ORDER").setFocus();
		session.findById("wnd[2]").close();
		session.findById("wnd[1]/usr/tabsG_TS_ALV/tabpALV_M_R1/ssubSUB_DYN0510:SAPLSKBH:0620/btnAPP_WL_SING").press();
		session.findById("wnd[1]/tbar[0]/btn[0]").press();
		sap.personas.scripting.scriptingEngine.scheduleTask(
			function(){
				pscdbel = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell[1]").getCellValue(Number(sRawRow), 'ZDZOPBEL');
				tags();
				session.findById("wnd[0]/tbar[1]/btn[32]").press();
				session.findById("wnd[1]/usr/tabsG_TS_ALV/tabpALV_M_R1/ssubSUB_DYN0510:SAPLSKBH:0620/cntlCONTAINER2_LAYO/shellcont/shell/tbar/btnFIND").press();
				session.findById("wnd[2]/usr/txtGS_SEARCH-VALUE").text = "PSCD-Belegnummer";
				session.findById("wnd[2]/usr/txtGS_SEARCH-VALUE").setFocus();
				session.findById("wnd[0]").sendVKey(0);
				session.findById("wnd[2]/usr/cmbGS_SEARCH-SEARCH_ORDER").setFocus();
				session.findById("wnd[2]").close();
				session.findById("wnd[1]/usr/tabsG_TS_ALV/tabpALV_M_R1/ssubSUB_DYN0510:SAPLSKBH:0620/btnAPP_FL_SING").press();
				session.findById("wnd[1]/tbar[0]/btn[0]").press();
			}
		);
	}

function tags() {
	var keys = new Array("OPBEL");   
	// template that will be used to update the data context 
	var prefix = "<asx:abap xmlns:asx='http://www.sap.com/abapxml' version='1.0'><asx:values><NAMESPACES><item><NAME>CANVAS_appData</NAME><ENTRIES>"; 
	var item = "<item><NAME>{name}</NAME><ARGS><item><ARG>0</ARG></item></ARGS><VALUE>{value}</VALUE></item>"; 
	var suffix = "</ENTRIES></item></NAMESPACES></asx:values></asx:abap>";   
	// create the xml message by looping through the keys 
	var payload = prefix;
	for (var i = 0; i < keys.length; i++) {     
		payload += item.replace("{name}", keys[i]).replace("{value}", pscdbel); 
	}   
	payload += suffix;   
	// raise the EPCM event
	if (window.external.epcm !== undefined) {     
		window.external.epcm.raiseEvent("com.sap.lsapi.dataContext", "loadFromXML", payload, ""); 
	} 
}

 

What I did in the first step, I checked if the column which is needed for the tagging is displayed or not. If the column is not displayed i add the column to the ALV (I used the script recorder to implement this). If I add an column automatically I also remove the column after the tag was sended to the Side Panel.

The second step was to implement the tagging. There I used EPCM(More Information).

The last thing I implemented was to schedule a new task if the coulmn was added dynamically to the screen, because when the coding block was run after the column was added the column wasn’t really aviable on the screen, so you couldn’t read the value of the selected lines column. So this event is triggered after the normal coding is finished.

So the result is that the tagging works fine and for every use case.

 

So I think it’s a special soloution but it works and was a nice start for some special possibilities i have with Screen Personas. I never thought starting like this into this nice technology. 🙂

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply