Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

Dynamic Checkbox Labels

$
0
0

Requirement: Creating a label with a dynamic text, fetching from the database.

 

SAP has provided very easy way to create labels for Checkbox, Fields, Radio buttons and that is through following path

 

 

1.png

 

 

This is very easy way to maintain a Label for selection screen elements, assume a scenario, when you need to change the name of the label based on certain requirements, like you need to fetch Manager’s name from the database and display it in front of the checkbox.

 

In such cases static naming does not work and we need to have dynamic coding, which will fetch data during runtime and will populate the label of the checkbox or parameter or selection screen.

 

 

 

Following code can be used directly to change the labels dynamically.

 

DATA: l_cname LIKE pa0002-cname.


PARAMETERS: p_xcheck AS CHECKBOX.

 


AT SELECTION-SCREEN OUTPUT.

 


* Data Base Select Statement
 
SELECT SINGLE cname FROM pa0002 INTO l_cname WHERE pernr = '10000000'.

 


* Assigning fetched value to Dyanamic checkbox  
  %_p_xcheck_%_app_%
-text = l_cname.

 

 

 

 

 

 

 

Output:-

 

2.png

 

In the Program below, we have used programmatic way of fetching the label from the database and assigning it to the checkbox, we can use same technique for Parameter Radio Button or Section Options, Keep this simple one line code handy as anyone can come across a requirment of dyanamic labels.

 

 

 


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>