Wednesday 23 July 2014

Printing a window in SAPSCRIPT without even calling it in driver program

Friends, lately 2-3 times I came across the situations where one window of script was coming into picture in print preview and while debugging also I could see it getting triggered. Tried putting break -point for every call of WRITE_FORM in order to find out from where exactly these windows are being called but to no avail.

On my recent encounter to this strange issue, I decided to go up to the bottom of the issue. Did a close analysis of the windows which were explicitly being called in driver program and those which were not. One thing was common among the windows, which were not being called in driver program, which was that there were no element in those windows. I google for it and Yes it was right.

So conclusion is, “We don't have to use WRITE_FORM explicitly for the windows which are having no element in it. We can go without caring for the calling of such windows. SAP standard code handles it automatically”.

Here I have developed one demo script and driver program to demonstrate it.
  1. Create a new script.
  2. Create 2 windows in it named Header and Main window.


  3. In the Header window, go inside and right something without using an element.


  4. Go inside the main window and write something under an element.


  1. Save and activate it.
  2. Create a diver program for this script and do the coding like below.


  3. Save it and activate it. Run it and choose output device as LOCL. Do the print preview

    Result:


  4. We are getting the content of Header window, while we have not used the WRITE_FORM for it.


                                                                                                                 By: Reetika Patel

Friday 18 July 2014

Using checkbox in ALV Webdynpro with Messaging functionality

Requirement: Creation of ALV with Check box and messaging functionality

Prerequisite: Creation of simple Webdynpro ALV application.

Steps:

1. Create a webdynpro component.
2. In main screen in 'used component' tab create the component usage of the standard ALV component SALV_WD_TABLE.


3. Go to component controller and create the component usage here also by clicking on the button as below. It will show the component usage you have created earlier. Use this one and screen will look like the 2nd screen shot.






4. Go to context tab of component controller and create 3 nodes named Header, Item, select_option. Make their attribute as mentioned below.







As you can see in right hand side panel, there is the context of component SALV_WD_TABLE. If you check in that component, the context shown here in right hand side, are actually the interface nodes of SALV_WD_TABLE. This way interface node come to the custom component where they are used.

5. Create a structure named ZHEADER1 in SE11 like below. And create a table type Z_HEADER
where line type is ZHEADER1.


These structure and table type we are going to sue further in our coding.

6. Create 2 attributes in attribute tab of component controller like below.





7. Create the layout of main view like below.


8. Go into the window where main view is embed. Inside main window you will get to see the view container you have created in main view's layout. Right click on it and click on 'embed view'. There select the 'Table' view of the used component. The window tab will kook like this now.




9. Go to INTERFACECONTROLLER in component usage. There bind the HEADER node of component controller to  DATA node of interface controller




10. In MAIN view on display button, create an event on action named 'ONDISPLAY'. By doing this there would be one method created automatically in method tab of the view like below.



11. Our job now is to fill the internal table and then the HEADER context node in order to display it in ALV. For that, in ONACTIONDISPLAY method we will right the below code.











12. Now go to the method tab of main view. There create one event handler method named ONCLICK. In event column select ON_CELL_ACTION event of interface controller of component usage ALV_USAGE.




13. Going inside the code of ONCLICK method, you will find one parameter named R_PARAM. This parameter will have the required info to process the checked row. This parameter will have data ranging from index of checked table record, column name, column value and all.

14.  We are implementing the functionality of displaying information message on check /uncheck of
check box and displaying the information message containing the index of table row. Below code is used for that. That is very well using the R_PARAM parameter of the method.




Results:





                                                                                                             By: Reetika Patel


Thursday 10 July 2014

Display of traffic signal lights in ALV

Some times we get requirement to show the lights in ALV display. Those lights one can compare with the traffic lights. In ALV, those lights show the particular state of that record. It can be used for anything like showing the material in stock, showing the criticality etc.

How to achieve it:
  1.  Declare a variable of type icon_d  in internal structure type. Our final internal table which we will display would be of that structure type.
  2. There are some IDs which actually let us show those lights. The full information for those can be find in the below link.
    http://www.sapdesignguild.org/resources/icons_sap/status_icons.htm
  3. we will assign those Ids to out internal table's icon field.

Code:






Result:


                                                                                                             By: Reetika Patel