Tuesday, 5 December 2017

Transaction codes

Transaction codes are used in SAP for getting an easy access to custom applications or to call predefined processes. Transaction codes are a kind of shortcuts for different applications. Various categories of transaction codes are defined according to application area and modules. Some common and most widely used transaction codes are defined below.

ABAP / Tables / Data Dictionary

  • SE11 − Dictionary definitions
  • SE14 − Database utility
  • SE16 − Data Browser (display only)
  • SE16n − Modify: “&sap_edit” (uase16n)
  • SD11 − Data model
  • SM30/SM31 − SAP Table view maintenance
  • SE54 (SOBJ) − Table / View Cluster
  • SE37 − Function module editor
  • SE38 / SE39 - Program editor / split screen
  • SA38 − Program execution
  • SE80 − ABAP development workbench
  • SE84 − Object navigator
  • SE18 − BAdI definitions
  • SE19 − BAdI implementations
  • SE24 − Class builder
  • SWO1/2 − Business object builder / browser
  • SMARTFORMS − Smart forms administration
  • SE71 − SAP script (Form painter)
  • SE43 − Area menu maintenance
  • SE91 − Message maintenance
  • SE93 − Transaction maintenance

Runtime / Logs / Database

  • SM21 − System log sm13 Update requests
  • ST22 − ABAP Runtime Error (Dump)
  • SM12 − Table look entries
  • SM56 − Number range buffers
  • SNRO − Number ranges
  • SE30 − Runtime analysis
  • ST01 − System trace
  • ST05 − SQL Trace
  • DB02, ST04 − Database tools / performance
  • ST02, ST06 − Database tune summary
  • SCU3 − Table logging (see V_DDAT_54)

Jobs / Batches / Events

  • SM36 − Job definition
  • SM37 /SMX − Job overview
  • SM50 − Process overview
  • SM34 − View cluster maintenance
  • SM49/SM69 − External commands
  • SM66 − Process overview
  • SM62/SM64 − Event overview / administration
  • STVARV(C) − Selection fields variables

User Administration

  • SM04 − User overview
  • SU53 − Check authorization data for user
  • SUIM − User information / authorization
  • SU20 / SU21 − Authorization object and class / field
  • SU01 − User maintenance PFCG roles
  • SU03 − Authorization Archive Development Kit (ADK)

Batch Input

  • SM35 − Batch Input: session overview
  • SHDB − Batch input recorder

Paths & Connections

  • AL11 − SAP file directory
  • FILE − Logical file path
  • SM58 − Transactional RFC
  • SM59 − RFC connections

Spool (Print Output)

  • SP01 − Spool request selection
  • SP02 − List of own spool requests
  • SPAD − Spool administration

Monday, 4 December 2017

Reopen Closed Bank Accounts


Currently a bank account with the status Closed can no longer be reopened. However, in some exceptional cases, customers need to reopen bank accounts and set the status back to Active.

Solution


The bank account reopening scenario is not a standard scenario. And this only occurs in some exceptional case, therefore a workaround for this issue is provided.


  • In the system where the bank account needs to be reopened, create a local report in transaction SE38
  • Copy the following codes into your new report
  • Replace the report name 'ZFCLM_BAM_REOPENACCOUNTS' with your own report name
  • For SAP Simple Finance, on-premise edition 1503 (SP0), please comment out codes which is marked as '[TO BE COMMENTED in 1503 (SP0)]'
  • Save and activate your report
  • Run the report by specifying the bank account ID that you want to reopen

This report only processes bank accounts with the status Closed. And it requires that the executor has the authorization to modify bank accounts. Please ensure that executor has activity 02 assigned for authorization object F_CLM_BAM.


Source code for report:

*&---------------------------------------------------------------------*
*& Report ZFCLM_BAM_REOPENACCOUNTS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zfclm_bam_reopenaccounts.
TABLES: sscrfields.
* Output structure for ALV tree
TYPES: BEGIN OF ys_alv_outtab,
acc_id TYPE fclm_bam_acc_id,
acc_num TYPE fclm_bam_acc_num,
banks TYPE banks,
bankl TYPE bankl,
currencies TYPE fclm_bam_acc_curr,
status TYPE fclm_bam_acc_status,
status_ui TYPE fclm_bam_status_ui,
description TYPE fclm_bam_description,
END OF ys_alv_outtab.
* Bank account data
DATA: ls_bam_amd TYPE fclm_bam_amd.
DATA: gt_amd TYPE fclm_bam_t_db_amd,
gt_amd_sig TYPE fclm_bam_t_db_sig,
gt_amd_lim TYPE fclm_bam_t_db_amd_lim,
gt_amd_cur TYPE fclm_bam_t_db_amd_cur,
gt_amd_t TYPE fclm_bam_t_db_amd_t,
gt_amd_aclink2 TYPE fclm_bam_t_aclink2.
* ALV variables
DATA: gt_alv_outtab TYPE TABLE OF ys_alv_outtab,
gr_cont_docking TYPE REF TO cl_gui_docking_container,
gr_container TYPE REF TO cl_gui_custom_container,
gr_alv TYPE REF TO cl_gui_alv_grid,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo,
gt_exclude_button TYPE ui_functions,
gv_ok_code TYPE sy-ucomm.
"Selection screen
SELECTION-SCREEN BEGIN OF BLOCK 1.
SELECT-OPTIONS: so_accid FOR ls_bam_amd-acc_id MATCHCODE OBJECT
FCLM_BAM_SHLP_ACNTID.
SELECTION-SCREEN END OF BLOCK 1.
SELECTION-SCREEN BEGIN OF SCREEN 1010.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN END OF SCREEN 1010.
INITIALIZATION.
"Add custom button 'Reopen Accounts'
MOVE 'Reopen Accounts' TO sscrfields-functxt_01.
AT SELECTION-SCREEN OUTPUT.
DATA lt_exclude TYPE TABLE OF rsexfcode.
CASE sy-dynnr.
WHEN 1010.
"Exclude default execute button
APPEND INITIAL LINE TO lt_exclude ASSIGNING FIELD-SYMBOL(<ls_exclude>).
<ls_exclude>-fcode = 'ONLI'.
CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
EXPORTING
p_status = '%_00'
p_program = 'RSSYSTDB'
TABLES
p_exclude = lt_exclude.
"Create container for ALV display
IF gr_cont_docking IS INITIAL.
CREATE OBJECT gr_cont_docking
EXPORTING
repid = sy-repid
dynnr = '1010'
side = gr_cont_docking->dock_at_left
extension = 1700.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT gr_alv
EXPORTING
i_parent = gr_cont_docking
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
**** prepare ALV control setting
* CREATE OBJECT lr_event_receiver.
* SET HANDLER lr_event_receiver->handle_user_command FOR gr_alv.
* SET HANDLER lr_event_receiver->handle_toolbar FOR gr_alv.
*** build ALV table
PERFORM build_alv_data.
SORT gt_alv_outtab BY acc_id.
*** set layout
gs_layout-sel_mode = 'A'.
CALL METHOD gr_alv->set_table_for_first_display
EXPORTING
it_toolbar_excluding = gt_exclude_button
is_layout = gs_layout
CHANGING
* it_sort = gt_sort
it_outtab = gt_alv_outtab[]
it_fieldcatalog = gt_fieldcat[]
EXCEPTIONS
OTHERS = 1.
PERFORM init_selected_row .
WHEN OTHERS.
ENDCASE.
AT SELECTION-SCREEN ON EXIT-COMMAND.
PERFORM exit_program.
AT SELECTION-SCREEN.
CASE sy-dynnr.
WHEN 1010.
IF sscrfields-ucomm = 'FC01'.
PERFORM reopen_bankaccounts.
ENDIF.
WHEN 1000.
IF sy-ucomm EQ 'ONLI'.
PERFORM set_exclude_button.
PERFORM set_field_catalog.
PERFORM prepare_reopenaccounts.
CALL SELECTION-SCREEN 1010.
ENDIF.
WHEN OTHERS.
ENDCASE.

*&---------------------------------------------------------------------*
*& Form EXIT_PROGRAM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM exit_program .
IF gr_container IS BOUND.
CALL METHOD gr_container->free.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
"Unlock objects
LOOP AT gt_alv_outtab ASSIGNING FIELD-SYMBOL(<ls_alv_outtab>).
CALL FUNCTION 'DEQUEUE_EFCLM_BAM_AMD'
EXPORTING
acc_id = <ls_alv_outtab>-acc_id.
ENDLOOP.
SET SCREEN 0.
LEAVE SCREEN.
ENDFORM.

*&---------------------------------------------------------------------*
*& Form REOPEN_BANKACCOUNTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM reopen_bankaccounts .
DATA lt_index_row TYPE lvc_t_row.
DATA lt_amd LIKE gt_amd.
DATA lt_amd_cur LIKE gt_amd_cur.
DATA lt_amd_sig LIKE gt_amd_sig.
DATA lt_amd_lim LIKE gt_amd_lim.
DATA lt_amd_t LIKE gt_amd_t.
DATA lt_amd_aclink2 LIKE gt_amd_aclink2.
DATA lt_message TYPE bapiret2_t.
DATA lv_error TYPE boolean.
"Process for each bank accounts
CALL METHOD gr_alv->get_selected_rows
IMPORTING
et_index_rows = lt_index_row.
"Prepare data for selected accounts
LOOP AT lt_index_row ASSIGNING FIELD-SYMBOL(<ls_index_row>).
READ TABLE gt_alv_outtab ASSIGNING FIELD-SYMBOL(<ls_alv_out>) INDEX <ls_index_row>-index.
CHECK sy-subrc EQ 0.
READ TABLE gt_amd ASSIGNING FIELD-SYMBOL(<ls_amd>) WITH KEY acc_id = <ls_alv_out>-acc_id.
CHECK sy-subrc EQ 0.
"Change account attributes for reopen scenario
<ls_amd>-status = if_fclm_bam_constants=>cc_account_status-active.
<ls_amd>-changed_by = sy-uname.
<ls_amd>-changed_at_dat = sy-datum.
<ls_amd>-changed_at_tim = sy-uzeit.
<ls_amd>-valid_to = '99991231'.
CLEAR <ls_amd>-planned_closing_date.
CLEAR <ls_amd>-closed_by.
CLEAR <ls_amd>-closed_at_dat.
CLEAR <ls_amd>-closed_at_tim.
APPEND <ls_amd> TO lt_amd.
LOOP AT gt_amd_cur ASSIGNING FIELD-SYMBOL(<ls_amd_cur>)
WHERE acc_id = <ls_amd>-acc_id.
APPEND <ls_amd_cur> TO lt_amd_cur.
ENDLOOP.
LOOP AT gt_amd_sig ASSIGNING FIELD-SYMBOL(<ls_amd_sig>)
WHERE acc_id = <ls_amd>-acc_id.
APPEND <ls_amd_sig> TO lt_amd_sig.
ENDLOOP.
LOOP AT gt_amd_lim ASSIGNING FIELD-SYMBOL(<ls_amd_lim>)
WHERE acc_id = <ls_amd>-acc_id.
APPEND <ls_amd_lim> TO lt_amd_lim.
ENDLOOP.
LOOP AT gt_amd_t ASSIGNING FIELD-SYMBOL(<ls_amd_t>)
WHERE acc_id = <ls_amd>-acc_id.
APPEND <ls_amd_t> TO lt_amd_t.
ENDLOOP.
LOOP AT gt_amd_aclink2 ASSIGNING FIELD-SYMBOL(<ls_amd_aclink2>)
WHERE acc_id = <ls_amd>-acc_id.
APPEND <ls_amd_aclink2> TO lt_amd_aclink2.
ENDLOOP.
ENDLOOP.
CALL FUNCTION 'FCLM_BAM_AMD_MODIFY_MULTI_CD'
EXPORTING
it_db_amd = lt_amd
it_db_amd_t = lt_amd_t
it_db_amd_cur = lt_amd_cur
it_db_amd_lim = lt_amd_lim
it_db_amd_sig = lt_amd_sig
* IV_WRITE_WITH_INITIAL =
* IV_WRITE_CD = 'X'
iv_commit = 'X'
* IV_NEEDBUFFER =
* IV_CHGDOC_TYPE = 'R'
it_aclink2 = lt_amd_aclink2 "[TO BE COMMENTED in 1503 (SP0)]
IMPORTING
* ET_ACCOUNT_CD =
et_message = lt_message
EXCEPTIONS
error_data = 1
read_account_error = 2
change_document_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ROLLBACK WORK.
ELSE.
LOOP AT lt_message TRANSPORTING NO FIELDS WHERE type CA 'AEX'.
lv_error = abap_true.
ENDLOOP.
IF lv_error EQ abap_true.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
"Unlock bank accounts
LOOP AT lt_amd ASSIGNING <ls_amd>.
CALL FUNCTION 'DEQUEUE_EFCLM_BAM_AMD'
EXPORTING
acc_id = <ls_amd>-acc_id.
DELETE gt_amd WHERE acc_id = <ls_amd>-acc_id.
ENDLOOP.
ENDIF.
ENDIF.
"Report messages by popup window
IF lv_error EQ abap_false.
MESSAGE 'Bank accounts are reopened successfully' TYPE 'I'.
ELSE.
MESSAGE 'Error when reopening bank accounts; try again' TYPE 'E'.
ENDIF.
ENDFORM.

*&---------------------------------------------------------------------*
*& Form BUILD_ALV_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build_alv_data .
CLEAR gt_alv_outtab.
LOOP AT gt_amd ASSIGNING FIELD-SYMBOL(<ls_amd>).
APPEND INITIAL LINE TO gt_alv_outtab ASSIGNING FIELD-SYMBOL(<ls_alv_out>).
MOVE-CORRESPONDING <ls_amd> TO <ls_alv_out>.
"Get status text
<ls_alv_out>-status_ui = cl_fclm_bam_utility=>get_status_text( <ls_alv_out>-status ).
"Get description
READ TABLE gt_amd_t ASSIGNING FIELD-SYMBOL(<ls_amd_t>) WITH KEY acc_id = <ls_alv_out>-acc_id
langu = sy-langu.
IF sy-subrc EQ 0.
<ls_alv_out>-description = <ls_amd_t>-description.
ENDIF.
"Get currency
READ TABLE gt_amd_cur ASSIGNING FIELD-SYMBOL(<ls_amd_cur>) WITH KEY acc_id = <ls_alv_out>
-acc_id.
IF sy-subrc EQ 0.
<ls_alv_out>-currencies = <ls_amd_cur>-waers.
ENDIF.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form INIT_SELECTED_ROW
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM init_selected_row .
DATA: ls_index_row TYPE LINE OF lvc_t_row,
lt_index_row TYPE lvc_t_row.
CALL METHOD gr_alv->get_selected_rows
IMPORTING
et_index_rows = lt_index_row.
IF lt_index_row IS INITIAL.
LOOP AT gt_alv_outtab ASSIGNING FIELD-SYMBOL(<ls_alv_out>).
ls_index_row-index = sy-tabix.
APPEND ls_index_row TO lt_index_row.
ENDLOOP.
CALL METHOD gr_alv->set_selected_rows
EXPORTING
it_index_rows = lt_index_row.
ENDIF.
ENDFORM.

*&---------------------------------------------------------------------*
*& Form SET_EXCLUDE_BUTTON
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_exclude_button .
CHECK gt_exclude_button IS INITIAL.
"APPEND cl_gui_alv_grid=>mc_fc_graph TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_expcrtempl TO gt_exclude_button.
"APPEND cl_gui_alv_grid=>mc_fc_print_prev TO gt_exclude_button.
"APPEND cl_gui_alv_grid=>mc_fc_print_back TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_sum TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_info TO gt_exclude_button.
"APPEND cl_gui_alv_grid=>mc_fc_views TO gt_exclude_button.
"APPEND cl_gui_alv_grid=>mc_mb_export TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_mb_subtot TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_mb_sum TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_loc_copy_row TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_loc_delete_row TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_loc_append_row TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_loc_insert_row TO gt_exclude_button.
"APPEND cl_gui_alv_grid=>mc_fc_sort_asc TO gt_exclude_button.
"APPEND cl_gui_alv_grid=>mc_fc_sort_dsc TO gt_exclude_button.
"APPEND cl_gui_alv_grid=>mc_fc_detail TO gt_exclude_button.
"APPEND cl_gui_alv_grid=>mc_fc_find TO gt_exclude_button.
"APPEND cl_gui_alv_grid=>mc_fc_filter TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_graph TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_loc_move_row TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_loc_copy TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_loc_cut TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_loc_paste TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_loc_paste_new_row TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_loc_undo TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_check TO gt_exclude_button.
APPEND cl_gui_alv_grid=>mc_fc_refresh TO gt_exclude_button.
ENDFORM.

*&---------------------------------------------------------------------*
*& Form SET_FIELD_CATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_field_catalog .
DATA lt_fieldcat LIKE gt_fieldcat.
DATA: ls_fcat TYPE lvc_s_fcat.
FIELD-SYMBOLS: <fs_fcat> TYPE lvc_s_fcat.
CHECK gt_fieldcat IS INITIAL.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'FCLM_BAM_S_AMD_ATT'
CHANGING
ct_fieldcat = lt_fieldcat.
LOOP AT lt_fieldcat ASSIGNING FIELD-SYMBOL(<ls_fieldcat>).
CASE <ls_fieldcat>-fieldname.
WHEN 'ACC_ID'.
<ls_fieldcat>-col_pos = 1.
WHEN 'ACC_NUM'.
<ls_fieldcat>-col_pos = 2.
<ls_fieldcat>-outputlen = 20.
WHEN 'BANKS'.
<ls_fieldcat>-col_pos = 3.
<ls_fieldcat>-outputlen = 8.
WHEN 'BANKL'.
<ls_fieldcat>-col_pos = 4.
WHEN 'CURRENCIES'.
<ls_fieldcat>-col_pos = 5.
<ls_fieldcat>-outputlen = 10.
<ls_fieldcat>-reptext = 'Currency'.
CLEAR <ls_fieldcat>-no_out.
WHEN 'DESCRIPTION'.
<ls_fieldcat>-col_pos = 6.
<ls_fieldcat>-outputlen = 30.
CLEAR <ls_fieldcat>-no_out.
WHEN 'STATUS'.
<ls_fieldcat>-tech = abap_true.
WHEN 'STATUS_UI'.
<ls_fieldcat>-col_pos = 7.
<ls_fieldcat>-outputlen = 8.
WHEN OTHERS.
CONTINUE.
ENDCASE.
APPEND <ls_fieldcat> TO gt_fieldcat.
ENDLOOP.
ENDFORM.

*&---------------------------------------------------------------------*
*& Form PREPARE_REOPENACCOUNTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM prepare_reopenaccounts .
DATA lt_accid TYPE fclm_bam_t_acc_id.
DATA lt_amd TYPE fclm_bam_t_db_amd.
DATA lt_unauthor_records TYPE fclm_bam_t_unauth_records.
DATA lv_lockfailure TYPE boolean.
CLEAR lt_amd.
CLEAR gt_amd.
CLEAR gt_amd_t.
CLEAR gt_amd_cur.
CLEAR gt_amd_sig.
CLEAR gt_amd_lim.
CLEAR gt_amd_aclink2.
IF so_accid IS INITIAL.
MESSAGE 'Select account ranges; or all accounts with status Closed will be selected' TYPE 'W'.
ENDIF.
SELECT acc_id INTO TABLE @lt_accid FROM fclm_bam_amd
WHERE acc_id IN @so_accid.
CALL FUNCTION 'FCLM_BAM_AMD_READ'
EXPORTING
it_acc_id = lt_accid
iv_read_activity = '02'
IMPORTING
et_db_amd = lt_amd
et_db_amd_t = gt_amd_t
et_db_amd_cur = gt_amd_cur
et_db_amd_sig = gt_amd_sig
et_db_amd_lim = gt_amd_lim
* et_db_aclink = gt_amd_aclink
et_db_aclink2 = gt_amd_aclink2
et_unauthor_records = lt_unauthor_records
EXCEPTIONS
no_record_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE 'No bank accounts found' TYPE 'E'.
ENDIF.
IF lt_unauthor_records IS NOT INITIAL.
MESSAGE 'Some unauthorized bank accounts are skipped' TYPE 'W'.
ENDIF.
"Filter those bank account with status 'Closed'
LOOP AT lt_amd ASSIGNING FIELD-SYMBOL(<ls_amd>).
CHECK <ls_amd>-status EQ if_fclm_bam_constants=>cc_account_status-closed.
"Try to lock objects
CALL FUNCTION 'ENQUEUE_EFCLM_BAM_AMD'
EXPORTING
acc_id = <ls_amd>-acc_id
langu = sy-langu
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc EQ 0.
APPEND <ls_amd> TO gt_amd.
ELSE.
IF lv_lockfailure EQ abap_false.
lv_lockfailure = abap_true.
ENDIF.
ENDIF.
ENDLOOP.
IF lv_lockfailure EQ abap_true.
MESSAGE 'Some bank accounts cannot be locked for reopen' TYPE 'W'.
ENDIF.
IF gt_amd IS INITIAL.
MESSAGE 'No accounts with status Closed exist' TYPE 'E'.
ENDIF.
ENDFORM.


Friday, 1 December 2017

ABAP – Web Dynpro



     Web Dynpro (WD) for ABAP is the SAP standard user interface technology developed by SAP AG. It can be used in the development of web-based applications in the SAP ABAP environment that utilizes SAP development tools and concepts. It provides a front-end web user interface to connect directly to backend SAP R/3 systems to access data and functions for reporting.

Web Dynpro for ABAP consists of a run-time environment and a graphical development environment with specific development tools that are integrated in the ABAP Workbench (transaction: SE80).

Architecture of Web Dynpro


The following illustration shows the overall architecture of Web Dynpro:


Following are a few points to keep in mind regarding Web Dynpro:

 Web Dynpro is the SAP NetWeaver programming model for user interfaces.

 All Web Dynpro applications are structured as per the Model View Controller (MVC) programming model.

 The model defines an interface to the main system and the Web Dynpro application can have an access to system data.

 The view is responsible for showing the data in the web browser.

 The controller resides between the view and the model. The controller formats the model data to be displayed in the view. It processes the user entries made by the user and returns them to the model.


Advantages


Web Dynpro offers the following advantages for application developers:

 The use of graphical tools significantly reduces the implementation effort.

 Reuse and better maintainability by using components.

 The layout and navigation is easily changed using the Web Dynpro tools.

 User interface accessibility is supported.

 Full integration in the ABAP development environment.

Web Dynpro Component and Window


The component is the global unit of the Web Dynpro application project. Creating a Web Dynpro component is the initial step in developing a new Web Dynpro application. Once the component is created, it acts as a node in the Web Dynpro object list. You may create any number of component views in a component and assemble them in any number of the corresponding Web Dynpro windows.

At least one Web Dynpro window is contained in each Web Dynpro component. The Web Dynpro window embeds all the views that are displayed within the front-end web application. The window is processed in the window editors of the ABAP Workbench.

Note:

 The component view displays all the administrative details for the application including the description, the name of the person who created it, the creation date, and the assigned development package.

 The Web Dynpro application is the independent object in the object list of the ABAP Workbench. The interaction between the window and the application is created by the interface view of a given window.

ABAP – Business Add-Ins



   In some cases, special functions need to be predefined in a software application to enhance the functionality of various applications. There are many Microsoft Excel add-ins to improve the functionality of MS Excel. Similarly, SAP facilitates some predefined functions by providing Business Add-Ins known as BADIs.

A BADI is an enhancement technique that facilitates a SAP programmer, a user, or a specific industry to add some additional code to the existing program in SAP system. We can use standard or customized logic to improve the SAP system. A BADI must first be defined and then implemented to enhance SAP application. While defining a BADI, an interface is created. BADI is implemented by this interface, which in turn is implemented by one or more adaptor classes.

The BADI technique is different from other enhancement techniques in two ways:

 Enhancement technique can be implemented only once.

 This enhancement technique can be used by many customers simultaneously.



You can also create filter BADIs, which means BADIs are defined on the basis of filtered data that is not possible with enhancement techniques. The concept of BADIs has been redefined in SAP Release 7.0 with the following goals:

 Enhancing the standard applications in a SAP system by adding two new elements in the ABAP language, that is ‘GET BADI’ and ‘CALL BADI’.

 Offering more flexibility features such as contexts and filters for the enhancement of standard applications in a SAP system.

When a BADI is created, it contains an interface and other additional components, such as function codes for menu enhancements and screen enhancements. A BADI creation allows customers to include their own enhancements in the standard SAP application. The enhancement, interface, and generated classes are located in an appropriate application development namespace.

Hence, a BADI can be considered as an enhancement technique that uses ABAP objects to create ‘predefined points’ in the SAP components. These predefined points are then implemented by individual industry solutions, country variants, partners and customers to suit their specific requirements. SAP actually introduced the BADI enhancement technique with the Release 4.6A, and the technique has been re-implemented again in the Release 7.0.

ABAP – User Exits



     User exits are used in an extraction if the standard SAP extractors do not provide the expected data or the required functionality, for instance in authorizations or time checks. User exits are commonly used in Sales and Distribution (SD) modules. There are many exits provided by SAP in the areas of sales, transportation, shipping and billing. A user exit is designed to make some changes when standard SAP is not capable of fulfilling all the requirements.

To be able to access what exits are available in each area of sales, go to IMG using this path:

IMG -> Sales and Distribution -> System Modifications -> User Exits.

The documentation for each exit in the areas of SD is explained thoroughly.
For instance, if you want to find user exits in Sales Document Processing (contract, quotation or sales order), follow the path mentioned above and continue to expand the node User Exits in
Sales -> User Exits. Click on icon documentation to see all user exits available in Sales Document Processing.


A User Exit serves the same purpose as Customer Exits but they are available only for the SD module. The exit is implemented as a call to a Function Module. User Exits are modifications to SAP standard programs.


REPORT ZUSEREXIT1.
TABLES: TSTC, TSTCT, TADIR, TRDIR, TFDIR, ENLFDIR, MODSAPT, MODACT.
DATA: JTAB LIKE TADIR OCCURS 0 WITH HEADER LINE,
field1(30),
v_devclass LIKE TADIR-devclass.
PARAMETERS: P_TCODE LIKE TSTC-tcode OBLIGATORY.
SELECT SINGLE * FROM TSTC WHERE tcode EQ P_TCODE.
IF SY-SUBRC EQ 0.
SELECT SINGLE * FROM TADIR WHERE pgmid = 'R3TR' AND object = 'PROG' AND obj_name = TSTC-pgmna.
MOVE TADIR-devclass TO v_devclass.
iF SY-SUBRC NE 0.
SELECT SINGLE * FROM TRDIR WHERE name = TSTC-pgmna.
IF TRDIR-subc EQ 'F'.
SELECT SINGLE * FROM TFDIR WHERE pname = TSTC-pgmna.
SELECT SINGLE * FROM ENLFDIR WHERE funcname = TFDIR-funcname.
SELECT SINGLE * FROM TADIR WHERE pgmid = 'R3TR' AND object = 'FUGR' AND obj_name EQ ENLFDIR-area.
MOVE TADIR-devclass TO v_devclass.
ENDIF.
ENDIF.
SELECT * FROM TADIR INTO TABLE JTAB WHERE pgmid = 'R3TR' AND object = 'SMOD' AND devclass = v_devclass.
sELECT SINGLE * FROM TSTCT WHERE sprsl EQ SY-LANGU AND tcode EQ P_TCODE. FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
WRITE:/(19) 'Transaction Code - ',20(20) P_TCODE, 45(50) TSTCT-ttext.
SKIP. IF NOT JTAB[] IS INITIAL.
WRITE:/(95) SY-ULINE.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/1 SY-VLINE, 2 'Exit Name', 21 SY-VLINE , 22 'Description', 95 SY-VLINE.
WRITE:/(95) SY-ULINE.
LOOP AT JTAB.
SELECT SINGLE * FROM MODSAPT WHERE sprsl = SY-LANGU AND
name = JTAB-zzj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WRITE:/1 SY-VLINE, 2 JTAB-obj_name HOTSPOT ON, 21 SY-VLINE , 22 MODSAPT-modtext, 95 SY-VLINE.
ENDLOOP.
WRITE:/(95) SY-ULINE.
DESCRIBE TABLE JTAB.
SKIP.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ 'No of Exits:' , SY-TFILL.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'User Exit doesn’t exist'.
ENDIF. ELSE. FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'Transaction Code Does Not Exist'.
ENDIF.
aT LINE-SELECTION.
GET CURSOR FIELD field1.
CHECK field1(4) EQ 'JTAB'.
SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.

While processing, enter the transaction code ‘ME01’ and press F8 (Execute) button. The above code produces the following output:



ABAP – Customer Exits



       Customer exits could be considered as hooks to the SAP standard programs. We do not need an access key to write the code and there is no need to modify the SAP standard program. These exits don't have any functionality and they are empty. Business logic could be added in order to meet various client requirements. However, Customer Exits are not available for all programs.

Customer Exits for Standard Transactions


Following are the steps to find customer exits as far as standard transactions are concerned. Let’s identify customer exits available in MM01 (Material Master Creation).



Step 1: Go to transaction MM01 and identify the program name of MM01 by going to Menu bar  System  Status as shown in the above screenshot.

Step 2: Get the program name from the popup screen. The program name is 'SAPLMGMM'.

Step 3: Go to transaction SE38, enter the program name and click Display.

Step 4: Navigate to Go to  Properties and find out the package of this program name.




The package name is 'MGA'.

Step 5: Go to transaction code SMOD that is usually used to identify customer exits. Navigate to Utilities  Find (or) you may directly press Ctrl + F on the transaction code SMOD.

Step 6: After going to the ‘Find Exits’ screen, enter the package name we got earlier and press F8 (Execute) button.




The above steps produce the following output with the list of exits available in the Material Master Creation.

ABAP – SAPscripts



      The SAPscript tool of the SAP system can be used to build and manage business forms such as invoices and purchase orders. The SAPscript tool provides numerous templates that simplify the designing of a business form to a great extent.

    The SAP system comes with standard SAPscript forms that are delivered with the SAP standard client (generally as client 000). Following are a few examples of standard SAPscript forms delivered with client 000:





The structure of a SAPscript form consists of 2 main components:

Content: This can be either text (business data) or graphics (company logo).

Layout: This is defined by a set of windows in which the form content appears.


SAPscript – Form Painter Tool


The Form Painter tool provides the graphical layout of a SAPscript form and various functionalities to manipulate the form. In the following example, we are going to create an invoice form after copying its layout structure from a standard SAPscript form RVINVOICE01, and display its layout by accessing the Form Painter tool.

Step 1: Open the Form Painter. You may request the screen either by navigating the SAP menu or by using the SE71 transaction code.

Step 2: In the Form Painter, request screen, enter a name and language for a SAPscript form in the Form and Language fields, respectively. Let’s enter 'RVINVOICE01' and 'EN' respectively in these fields.

Step 3: Select the Page Layout radio button in the Sub objects group box.

Step 4: Select Utilities  Copy from Client to create a copy of the RVINVOICE01 form. The 'Copy Forms Between Clients' screen appears.

Step 5: In the 'Copy Forms Between Clients' screen, enter the original name of the form, 'RVINVOICE01', in the Form Name field, the number of the source client '000' in the Source Client field, and the name of the target form as 'ZINV_01' in the Target Form field. Make sure that other settings remain unchanged.

Step 6: Next, click the Execute icon in the 'Copy Forms Between Clients' screen. The 'Create Object Directory Entry' dialog box appears. Click the Save icon.

The ZINV_01 form is copied from the RVINVOICE01 form and displayed in the 'Copy Forms Between Clients screen' as depicted in the following snapshot:



Step 7: Click the back icon twice and navigate back to the Form Painter: Request screen, which contains the name of the copied form ZINV_01.

Step 8: After clicking the Display button, the 'Form ZINV_01: Layout of Page FIRST' window and the 'Form: Change Page Layout: ZINV_01' screen appears as shown in the following screenshot.



Step 9: The 'Form ZINV_01: Layout of Page FIRST' window shows the initial layout of the form. The layout of the form contains five windows: HEADER, ADDRESS, INFO, INFO1, and MAIN. The description of these windows can be accessed in PC Editor.

For instance, by just selecting the MAIN window and clicking the Text icon in the 'Form: Change Page Layout: ZINV_01' screen, you can view all the margin values as shown in the following screenshot: