WebDynpro Implementation Issues for Create, Change functionality using BAPI for SAP R/3 system

Hi this is my first weblog on SDN and for this I have chosen to write about some of the issues associated with creating and changing records in R/3 system using BAPIs that I faced and how I resolved them. If there are any other solutions in this regard, they are most welcome.

Initially I would like to provide a brief idea about the BAPIs that I used:

Iqs4_Get_Notification(Standard BAPI):

This BAPI requires a mandatory parameter-Notification Number to display the contents of that notification.

Z_Iqs4_Modify_Notification(Custom BAPI):

For the use of this BAPI, I first executed Iqs4_Get _Notification BAPI so that the desired attribute values are fetched and then after the user makes the changes, I used Z_Iqs4_Modify_Notification BAPI to reflect the changes in the database which could be verified by running the Iqs4_Get_Notification again.

Yz_Iqs4_Create_Notification_Input(Custom BAPI):

This BAPI is used to create a notification of a particular type.

Initially I made a simple WebDynpro project and created a WebDynpro component. Next I created models for each of the BAPIs and mapped the required nodes into the view and controller context. Further I created the layout for the project with the text fields to display the values and the buttons for Display, Create and Change functions. For detailed guidance on the subject of model creation and handling of structures please refer to Perumal Kanthans weblog on the same.

Now I shall begin by explaining my modules and the related issues:

1. Change

To implement this functionality,as mentioned above, I made models for the BAPIs – Iqs4_Get_notification (for Display) and Z_Iqs4_Modify_notification (for Change) and mapped the necessary nodes from the model into the context.

Initially I decided to just display the values of attributes of a certain structure Riqs5 in the screen .For this I set the value descriptor in the properties section for each of the text field to the corresponding mapped context value attribute of Iqs4_Get_Notification node.

For e.g the field Notification Description was set to Iqs4_Get_Notification_Input.Output.E_Inlines_T.Tdline

Then as the next step I had to display the values and then allow the user to change them,wherein I faced certain problems. I first tried to set the value descriptor as in the earlier case and then try and set the corresponding attributes through the Z_Iqs4_Modify_Notification BAPI using code implementation. But this failed.

So I decided to assign the values obtained through one BAPI to a distinct separate context node, say A and then try to change the attribute values in the node for another BAPI through this A. So I created another value node ChangeDetails in the view context and further created value attributes in that node to receive the values through the BAPI Iqs4_Get_Notification.

I assigned the value descriptor of the fields in the screen area to the value attributes of the ControlChange_Details node as in, say the field Notification Description is now set to “ChangeDetails.Qmtxt”.

To initialize each of the ChangeDetails value attributes I wrote the following code in the implementation for OnChangeDetails () function executed on the click of Change button on screen:

Now I created a mapped version ControlChange_Details node in the Custom controller and using this node set the values of the attributes to their respective modified versions through the second BAPI Z_Iqs4_Modify_Notification, the code written as under,

2. Create

For the create functionality I just needed to give the users blank text fields to create a new record. Thereby the first notification display BAPI is not run so the initial code is out of question. But the second piece of code given above is essential with the BAPI Yz_Iqs4_Create_Notification_Input being run to create a new record.

For the Create function I have used the second code as it is in the controller implementation part.

There was another issue I had to sort out in the Change functionality, which was to verify if the notification was changed or not. For this I used the return part of the Output node ,which if empty indicates that the notification has been effectively changed.

The code I implemented to check the contents of the return field is as under

Each of these pieces of code are a part of the complete implementations of the functions invoked on clicking the button for the respective functionality viz. Display, Create or Change. The above discussed were the two problems I faced and their respective solutions. There could be more ways of doing the same and I would appreciate if I receive any guidance in this regard.

Note: Here when I talk about the notification, notification number etc. I am referring to instances of maintenance jobs with particular characteristics such as date of initiation, date of completion, description etc.