Sep 30, 2015

BTE - Business Transaction Event

BTE - Business Transaction Event

Enhancement type developed for FI (Financial Accounting).
 SAP Reference IMG -> Financial Accounting -> Financial Accounting Global Settings -> Business Transaction Events  .
Customizing can be done via transaction FIBF.
Main steps for activating a BTE:
  1. Check OSS note for documentation and explanation 
  2. Copy sample function module SAMPLE_INTERFACE_<event_number> to Customer namespace 
  3. Make sure the application is active for Business Transaction Events , else maintain table TBE11.
  4. Maintain table TBE34 and TBE01
  5. Enter code to the BTE function module
How to check/debug?
To check the functionality, you can put a break-point in your BTE function module. If it's not called, put a breakpoint at FM OPEN_FI_PERFORM_<BTE number>_E.
Related Transaction Code :
    BERE Business Event Repository
    BERP Business Processes
    BF31 Application modules per Event
    BF32 Partner Modules per Event
    BF34 Customer Modules per Event
    BF41 Application Modules per Process
    BF42 Partner Modules per Process
   BF44 Customer Modules per Process 
 BTE exits to add additional components to the SAP standard system, for example in the form of function modules. There are two types of interface:
-        Publish and Subscribe interfaces
-        These give information that specific events have occurred in the SAP standard application and provide the data generated to external software. However the external software does not return any data to the SAP standard system.
-        Process interfaces
These subject business processes to an external control function that is not part of the standard system; in other words the process interfaces interrupt the standard process and deliver data to the SAP application.
A BTE exit is called up in the process, meaning that process modules check the events in Customizing for calling up the BTE exits. In the BTE method, function modules are called up in specified events, to which they have been assigned in Customizing. The event interface is predefined. To activate the process modules, choose _Settings for Process Interfaces -> Assign Customer Function Modules to Process Interfaces.



Sep 26, 2015

Converting Material Quantities To Different Unit Of Measure In ABAP

Each material in SAP has its standard, base unit of measure (stored in MARA-MEINS). To allow using alternative units, those can be maintained per material in table MARM. A common requirement for ABAPer is to convert material quantity from one unit to another, most likely from an alternative unit to the base one, to be able to summarize the report results.
To do the conversion, SAP provides the function module MATERIAL_UNIT_CONVERSION. Its parameter names are not self-explaining, and for my own purposes I have a simple wrapper form that I use to convert quantities from alternative to base UoM. The form is using data caching technique that I described in one of my earlier posts.

form convert_to_base_uom 
  using    pf_matnr     type matnr 
           pf_menge_in  type gsmng 
           pf_meins_in  type meins 
  changing pf_menge_out type gsmng 
           pf_meins_out type meins. 

* define internal table to cache the base UOM 
  types: begin of lty_meins_rec, 
             matnr type matnr, 
             meins type meins, 
           end of lty_meins_rec. 

  types: 
    lty_meins_tab type hashed table of lty_meins_rec 
          with unique key matnr. 
  data: 
    ls_wa type lty_meins_rec. 

  statics: 
    lt_meins type lty_meins_tab. 

* first, find the base UOM 
  clear pf_meins_out. 
  read table lt_meins into ls_wa 
    with table key matnr = pf_matnr. 
  if sy-subrc = 0. 
    pf_meins_out = ls_wa-meins. 
  else. 
    select single meins 
      from mara 
      into ls_wa-meins 
      where matnr = pf_matnr. 
    if sy-subrc  0.  "doesn't exist. try PC 
      ls_wa-meins = 'ST'. 
    endif. 
    ls_wa-matnr = pf_matnr. 
    pf_meins_out = ls_wa-meins. 
    insert ls_wa into table lt_meins. 
  endif. 

* now convert the qty 
  if pf_meins_in = pf_meins_out. 
    pf_menge_out = pf_menge_in. 
  else. 
    call function 'MATERIAL_UNIT_CONVERSION' 
         exporting 
              input                = pf_menge_in 
              kzmeinh              = 'X' 
              matnr                = pf_matnr 
              meinh                = pf_meins_in 
              meins                = pf_meins_out 
              type_umr             = '3' 
         importing 
              output               = pf_menge_out 
         exceptions 
              conversion_not_found = 1 
              input_invalid        = 2 
              material_not_found   = 3 
              meinh_not_found      = 4 
              meins_missing        = 5 
              no_meinh             = 6 
              output_invalid       = 7 
              overflow             = 8 
              others               = 9. 

  endif. 

endform.


ref: https://abaplog.wordpress.com/2007/03/22/converting-material-quantities-to-different-unit-of-measure-in-abap/



Sep 3, 2015

Multiple ALV Grids on One Window

A sample program to create multiple ALV in one window

By Ramesh T

Codes:
REPORT ztest01.

DATA : splitter_1  TYPE REF TO cl_gui_splitter_container,
       splitter_2  
TYPE REF TO cl_gui_splitter_container,
       container   
TYPE REF TO cl_gui_custom_container,
       container_1 
TYPE REF TO cl_gui_container,
       container_2 
TYPE REF TO cl_gui_container,
       container_3 
TYPE REF TO cl_gui_container.
DATA : it_mara     TYPE TABLE OF mara,
       it_makt     
TYPE TABLE OF makt,
       it_mseg     
TYPE TABLE OF mseg,
       c_container 
TYPE scrfname VALUE 'ccontainer',
       grid1       
TYPE REF TO cl_gui_alv_grid,
       grid2       
TYPE REF TO cl_gui_alv_grid,
       grid3       
TYPE REF TO cl_gui_alv_grid.

**fetching the three tables
SELECT FROM  mara INTO TABLE it_mara UP TO 100 ROWS.
SELECT FROM  makt INTO TABLE it_makt UP TO ROWS.
SELECT FROM  mseg INTO TABLE it_mseg UP TO ROWS.

START-OF-SELECTION.
  
CALL SCREEN 9000.

*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_9000 OUTPUT.

  
SET PF-STATUS 'ZSTATUS'.
*  SET TITLEBAR 'xxx'.

  
PERFORM create_splitter_1.
  
PERFORM create_splitter_2.
  
PERFORM display_grid1.
  
PERFORM display_grid2.
  
PERFORM display_grid3.

ENDMODULE.                 " STATUS_9000  OUTPUT

*&---------------------------------------------------------------------*
*&      Form  CREATE_SPLITTER_1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_splitter_1 .

  
CREATE OBJECT container
    
EXPORTING
*     PARENT         =
      container_name 
'CCONTAINER'.

  
CREATE OBJECT splitter_1
    
EXPORTING
      parent  
container
      
rows    1
      columns 
2.

  
CALL METHOD splitter_1->get_container
    
EXPORTING
      row       
1
      column    
1
    RECEIVING
      container 
container_1.

  
CALL METHOD splitter_1->get_container
    
EXPORTING
      row       
1
      column    
2
    RECEIVING
      container 
container_2.

ENDFORM.                    " CREATE_SPLITTER_1
*&---------------------------------------------------------------------*
*&      Form  CREATE_SPLITTER_2
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_splitter_2 .

  
CREATE OBJECT splitter_2
    
EXPORTING
      parent  
container_2
      
rows    2
      columns 
1.

  
CALL METHOD splitter_2->get_container
    
EXPORTING
      row       
1
      column    
1
    RECEIVING
      container 
container_2.

  
CALL METHOD splitter_2->get_container
    
EXPORTING
      row       
2
      column    
1
    RECEIVING
      container 
container_3.

ENDFORM.                    " CREATE_SPLITTER_2
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_GRID1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_grid1 .


  
CREATE OBJECT container
    
EXPORTING
      container_name 
c_container.

  
CREATE OBJECT grid1
    
EXPORTING
      i_parent 
container_1.

  
CALL METHOD grid1->set_table_for_first_display
    
EXPORTING
      i_structure_name 
'MARA'
    
CHANGING
      it_outtab        
it_mara.

ENDFORM.                    " DISPLAY_GRID1
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_GRID2
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_grid2 .

  
CREATE OBJECT container
    
EXPORTING
      container_name 
c_container.

  
CREATE OBJECT grid2
    
EXPORTING
      i_parent 
container_2.

  
CALL METHOD grid2->set_table_for_first_display
    
EXPORTING
      i_structure_name 
'MAKT'
    
CHANGING
      it_outtab        
it_makt.

ENDFORM.                    " DISPLAY_GRID2
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_GRID3
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_grid3 .

  
CREATE OBJECT container
    
EXPORTING
      container_name 
c_container.

  
CREATE OBJECT grid3
    
EXPORTING
      i_parent 
container_3.

  
CALL METHOD grid3->set_table_for_first_display
    
EXPORTING
      i_structure_name 
'MSEG'
    
CHANGING
      it_outtab        
it_mseg.

ENDFORM.                    " DISPLAY_GRID3

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.

  
CASE sy-ucomm.
    
WHEN 'BACK'.
      
LEAVE TO SCREEN 0.
  
ENDCASE.

ENDMODULE.                 " USER_COMMAND_9000  INPUT


Result: