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:





Aug 28, 2015

WebDynpro Tutorials in PDFs


Tutorial 1 - Create a Simple Web Dynpro Application
This step-by-step tutorial illustrates creating a  simple Web Dynpro component, which  consists of one view. Furthermore, it  demonstrates a Web Dynpro application for  this simple Web Dynpro component, which  can  then be run in the browser. 

This tutorial demonstrates the usage of BAPIs  and how to implement a view with input fields  and a result table using Web Dynpro for ABAP.

This tutorial demonstrates how easy it is to navigate between different views of the same Web Dynpro application.

In this tutorial, the BAPINAV component introduced in Tutorial 3 is further enhanced to display a list of bookings for a selected flight. The context that contains the flight information is enhanced with a subnode for the corresponding bookings. It also shows how the booking information is retrieved in a supply function and the context node is bound to a new table UI element in the Main View.


The fifth tutorial in the series describes component usage, personalization and configuration and offers an alternative solution to that presented in the Tutorial 3.

This tutorial demonstrates how to develop an example for component usage in Web Dynpro ABAP and further build on tutorial 4 to display customer data of a particular booking using his customer_id as a foreign key.

Tutorial 7 - How to Integrate WDA in Portal and Capture Logon User Name
This Article helps how to create iViews for Web Dynpro ABAP Application in SAP Netweaver Portal and helps how to capture portal Logon User Name in Our Web Dynpro Application.

In this tutorial, learn how to use Supply Function method in Web Dynpro Application with one simple application. Basically, Supply Function is used to fill context nodes at runtime,which can be defined by assigning a method name to the node property Supply Function in the controller at design time.


This tutorial demonstrates an efficient way to Apply Mandatory/Obligatory field Check on Input fields in a Webdynpro ABAP View.

This tutorial is written to support those ABAP consultants who want to develop their first ALV in Web Dynpro ABAP.

ref:http://webdynpro-tutorials.blogspot.com/p/web-dynpro-abap-tutorials-for-beginners.html

Aug 26, 2015

Difference between Internal and External Number Range in SAP

Each master record has a unique number in SAP.SAP needs it to display or change the
master record and to post to the vendor account.

Number ranges in SAP can be assigned with a internally or externally generated
number by the user. While defining the range in SAP this option can be selected to let
the system decide the number range to be selected while creating the master data;

Internal Number range in SAP
If you select this option then the document number will be generated by SAP
automatically in serial order within the range that you have selected while de￱ning
the
number range and will allot the next available progressive number to the next data
created. This option is selected to reduce the manual involvement of the user. The
number must be numerical.

External Number Range in SAP
While creating a master data you need to enter a number manually. With external
number range option in SAP, system will not automatically insert a number to the
document or master data. User can pick it randomly. It can be alphanumeric. Entering
the document number manually for each SAP ñnancial posting is time consuming and
risky to book transactions.
A number range can either be created as year dependent or year independent. For
year-dependent, a document number range has to be deñned for each new
accounting year as a year-end activity. You can deñne it as year independent by keying
9999 in the Year column.

Function Example: READ_TEXT ABAP Wrapper Function

by Vicky Bolster

The reason we cannot use the READ_TEXT function in an ABAP mapping is twofold:
It requires table parameters - which cannot be used in ABAP dataflows
It does raise exceptions if no data is found - a condition which would be okay for us
Therefore the solution could be to write a new SAP function module using the READ_TEXT function inside but doing exactly what we want it to do.
The code I came up with is:

FUNCTION Z_AW_READ_TEXT_ALL.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(ID) TYPE  THEAD-TDID
*"     REFERENCE(LANGUAGE) TYPE  THEAD-TDSPRAS
*"     REFERENCE(NAME) TYPE  THEAD-TDNAME
*"     REFERENCE(OBJECT) TYPE  THEAD-TDOBJECT
*"  EXPORTING
*"     REFERENCE(TEXT) TYPE  CHAR2000
*"----------------------------------------------------------------------
DATA BEGIN OF TEXTHEADER.
        INCLUDE STRUCTURE THEAD.
DATA END OF TEXTHEADER.
DATA BEGIN OF TEXTLINES OCCURS 10.
        INCLUDE STRUCTURE TLINE.
DATA END OF TEXTLINES.
CLEAR TEXTHEADER.
data: l_name type TDOBNAME."TR
l_name = name."TR
CALL FUNCTION 'READ_TEXT'
       EXPORTING
            OBJECT                  = OBJECT
            ID                      = ID
            LANGUAGE                = LANGUAGE
            NAME                    = l_NAME "TR
       IMPORTING
            HEADER                  = TEXTHEADER
       TABLES
            LINES                   = TEXTLINES
       EXCEPTIONS
            ID                      = 1
            LANGUAGE                = 2
            NAME                    = 3
            NOT_FOUND               = 4
            OBJECT                  = 5
            REFERENCE_CHECK         = 6
            WRONG_ACCESS_TO_ARCHIVE = 7
            OTHERS                  = 8.
LOOP AT TEXTLINES.
   CONCATENATE TEXT TEXTLINES into TEXT SEPARATED BY space.
ENDLOOP.
ENDFUNCTION.

This function does not have any exceptions by itself, so even if the READ_TEXT function does raise one, it will finish successfully and return an empty text.



ref: http://wiki.scn.sap.com/wiki/display/EIM/Function+Example+READ_TEXT+ABAP+wrapper+function