Overview In this example we would like to create a simple application to release purchase requisitions can be released (SAP transaction ME54N).
|
Step 1: AAutomatic generation of an S10 application
based on the EBAN table
To do this, we start the generation tool (transaction /S10/UTIL) and specify the table EBAN. Then we select some fields to be displayed in the application and press "Save and generate": As a basis, we now have an up and running application in which purchase requisitions are listed. However, these are neither assigned to a specific user (we will use the cost center for this later), nor can they be released. Therefore, we will add this functionality in the next steps. |
Step 2: Extending the interface for reading the purchase requisitions The cost center can be saved as a user parameter. Therefore we read this parameter to use it later in the selection of the purchase requisitions: * select database values and fill table tabeban method build_tabeban. data: condition type string, join type string, search type string. data: para type tpara-paramid value 'KOS', ext_kostl(30) type c, user_kostl type ebkn-kostl. get parameter id para field ext_kostl. if ext_kostl is initial.. s10errormessage( s10localize( 'KOS_MISSING' ) ). endif. s10userinput( exporting uservalue = conv string( ext_kostl ) changing result = user_kostl ). We need the internal format for the SELECT statement later, so we convert the determined value of the cost center with the S10 method s10userinput. We then extend the conditions for the selection to include the query for the cost center: * Read only entries with assigned cost center (table EBKN) condition = condition && | and exists ( select * from ebkn | && | where banfn = eban~banfn and bnfpo = eban~bnfpo | && | and kostl = '| && user_kostl && |' ) |. To read the data, we use the S10 method s10databaseselect, which can be used to read data directly from the database into the ABAP object: * read data s10databaseselect( exporting condition = condition orderby = 'badat,banfn,statu,matnr,menge,meins,rlwrt,waers,lfdat,txz01,frgzu,frgst' changing folder = tabeban ). |
Step 3: Extending the HTML table with a "Release" column The generation tool has automatically generated the HTML page eban_manager.list.html, which displays the list of purchase requisitions. We add there another column " Release ", first the heading: <!-- column headers --> <!-- ... --> <!-- Release--> <div class='colhead' style="width: 120px; float: right;">Release </div> Then we define the corresponding column as HTML output field. That is, the HTML code for this element is generated directly in an ABAP method and later interpreted by the browser: <!-- list rows --> <form class='table' name='tabeban'> <!-- ... --> <!-- Release --> <div class='outputcellhtmldiv' style="width: 120px; float: right;" name="button_release_html"></div> The field is defined in the ABAP class "eban_short" and a build method there later creates the HTML code that displays a button: data: button_release_html type string. methods: build_button_release_html importing frgzu type eban-frgzu exporting button_release_html type string. The implementation of the method: class eban_short implementation. method build_button_release_html. if frgzu = 'X'. button_release_html = |<button style='background-color:orange;height:20px; width:100px;'| && | type='button' class='button' onclick='S10Apply("reset_release")'>| && s10localize( 'BANF_DO_RELEASE_RESET' ) && |</button>|. else. button_release_html = |<button style='background-color:greenyellow; height:20px; | && | width:100px;' type='button' class='button' onclick='S10Apply("release")'> | && s10localize( 'BANF_DO_RELEASE' ) && |</button>|. endif. endmethod. The method checks the release status FRGZU to decide whether a button should be displayed "Release" or " Withdraw". If the status changes, the build method is automatically called again and the display or button is updated. |
Step 4: Implementing the ABAP method for releasing a purchase requisition In step 2 it was defined in the HTML code that the ABAP method "release" resp. is called as soon as the user presses the button. In the method, the line in which this button is located is determined and then the number of the purchase requisition and the position are passed to the function module BAPI_REQUISITION_RELEASE.: method release. data: rownumber type i. rownumber = s10contextinfo( )->rownumber. read table tabeban index rownumber assigning field-symbol(<c>). call function 'BAPI_REQUISITION_RELEASE' exporting number = <c>->banfn rel_code = '01' item = <c>->bnfpo use_exceptions = 'X' exceptions others = 1. if sy-subrc <> 0. s10errormessage( msgid = sy-msgid msgno = sy-msgno par1 = sy-msgv1 par2 = sy-msgv2 ). endif. call function 'BAPI_TRANSACTION_COMMIT'. * update list display <c>->s10databaseread( ). s10infomessage( exporting text = s10localize( 'BANF_RELEASE_DONE' ) ). endmethod. |
Download You can download all project files here: s10_banf_example.zip The .ZIP archive contains the HTML views and a text file with the ABAP program "/s10/banf_main". To import the HTML views you can use the report "BSP_UPDATE_MIMEREPOS" as described in the documentation under the point "Development environment". Please adjust the number of the client in the file "user.logon.html" if necessary. You can find details about this in the documentation under the item S10Logon() |
Component: S10 Framework |