Tuesday, August 23, 2016

Interview questions on BADI

Ways to Find a BADI

- Through Trace ST05 - V_EXT_IMP and V_EXT_ACT , these two views will hold the values of BADIs and its interfaces called during an execution of a Tcode / Program


2. Go to Se24 in CL_EXITHANDLER , place a breakpoint in its method GET_INSTANCE, everytime a BADI is called this class will be called .

3. Go to the program for which you need to find the BADI , search for the term CL_EXITHANDLER=>GET_INSTANCE and place a break-point

4. For NEW BADI search for the term CALL BADI

--- Difference between BADI and Customer Exit

BADI
Customer-exit
Business Add-Ins are a new SAP enhancement technique based on ABAP Objects.
CUSTOMER EXITS (enhancements) are FUNCTIONS so they are called using CALL FUNCTION (or more exactly CALL CUSTOMER FUNCTION
Badi’s allow for a multi-level system landscape (SAP, partner, and customer solutions, as well as country versions, industry solutions, and the like). Business Add-Ins can be created at each level within such a system infrastructure
Customer exits assumes a two-level infrastructure (SAP and customer solutions)
Some BADI can have multiple independent implementations, which is much better for software deployment as several developers can implement the same BADI independently.
Customer-exit implemented in one project cannot be implemented in other.

BADI - Adding a Tab in ME21N

Introduction:  
The requirement is to add below screen fields in the ME21N, ME22N, ME23N (Header Section) …New tab called “Other Data” using a BADI.  
 
Step by step procedure:  
First, add the new fields required in the extension structure for EKKO table (CI_EKKODB). These fields will reflect in the new tab which we are going create in the ME21N screen.  
Now, Implement the BADI (ME_GUI_PO_CUST).  
First method: SUBSCRIBE  
DATA: ls_subscriber LIKE LINE OF re_subscribers.
* we want to add a customer subscreen on the Header tab
    CHECK im_application = 'PO'.
    CHECK im_element     = 'HEADER'.
* each line in re_subscribers generates a subscreen. We add one subscreen in this example
    CLEAR re_subscribers[].
* the name is a unique identifier for the subscreen and defined in this class definition
    ls_subscriber-name = subscreen1.
* the dynpro number to use
    ls_subscriber-dynpro = '0001'.
* the program where the dynpro can be found
    ls_subscriber-program = 'SAPLZKMMM_KAU86037'.
* each subscreen needs his own DDIC-Structure
    ls_subscriber-struct_name = 'CI_EKKODB'.
* a label can be defined
    ls_subscriber-label = text-001.
* the position within the tabstrib can be defined
    ls_subscriber-position = 13.
* the height of the screen can be defined here. Currently we suport two screen sizes:
* value <= 7 a sevel line subscreen
* value > 7  a 16 line subscreen
    ls_subscriber-height = 7.
    APPEND ls_subscriber TO re_subscribers.
Here, parameter ‘im_element’ is defined as ‘HEADER’ as we are adding new tab in header section of PO.  
Define a function group and take the main program and define it in ls_subscriber-program.
Also define a sub screen with the required fields and assign it to the parameter ls_subscriber-dynpro.  
Then method MAP_DYNPRO_FIELDS  
FIELD-SYMBOLS: <mapping> LIKE LINE OF ch_mapping.
    LOOP AT ch_mapping ASSIGNING <mapping>.
    CASE <mapping>-fieldname.
      WHEN 'ZZPAYMENT_AGRE'.      <mapping>-metafield = mmmfd_cust_03.
      WHEN 'ZZPROJECT'.                     <mapping>-metafield = mmmfd_cust_04.
    ENDCASE.
  ENDLOOP.  
TRANSPORT_FROM_MODEL:
DATA:     l_header       TYPE REF TO if_purchase_order_mm,
              ls_mepoheader  TYPE mepoheader,
              ls_customer    TYPE CI_EKKODB.
*--------------------------------------------------------------------*
* system asks to transport data from the business logic into the view
*--------------------------------------------------------------------*
    CASE im_name.
      WHEN subscreen1.
* is it an Header? im_model can be header or item.
        mmpur_dynamic_cast l_header im_model.
        CHECK NOT l_header IS INITIAL.
* transport standard fields
        ls_mepoheader = l_header->get_data( ).
* store info for later use
        MOVE-CORRESPONDING ls_mepoheader TO dynp_data_pbo.
      WHEN OTHERS.
* ...
    ENDCASE.    
TRANSPORT_TO_DYNP:
Define a FM 'ZK_KAU86037_PUSH' to push the values.
CASE im_name.
      WHEN subscreen1.
        CALL FUNCTION 'ZK_KAU86037_PUSH'
          EXPORTING
            im_dynp_data = dynp_data_pbo.
      WHEN OTHERS.
    ENDCASE.    
TRANSPORT_FROM_DYNP:
  Define another FM 'ZK_KAU86037_POP'.
CASE im_name.
      WHEN subscreen1.
        CALL FUNCTION 'ZK_KAU86037_POP'
          IMPORTING
            ex_dynp_data = dynp_data_pai.
        IF dynp_data_pai NE dynp_data_pbo.
* something has changed therefore we have to notify the framework
* to transport data to the model
          re_changed = mmpur_yes.
        ENDIF.
      WHEN OTHERS.
    ENDCASE.  
TRANSPORT_TO_MODEL:     
        DATA: l_header             TYPE REF TO if_purchase_order_mm,
          ls_mepoheader        TYPE mepoheader,
          ls_customer          TYPE CI_EKKODB,
          l_po_header_handle   TYPE REF TO cl_po_header_handle_mm.
*--------------------------------------------------------------------*
* data have to be transported to business logic
*--------------------------------------------------------------------*
    CASE im_name.
      WHEN subscreen1.
* is it an item? im_model can be header or item.
        mmpur_dynamic_cast l_header im_model.
        CHECK NOT l_header IS INITIAL.
        ls_mepoheader = l_header->get_data( ).
* standard fields changed?
        IF dynp_data_pbo-zzpayment_agre   NE dynp_data_pai-zzpayment_agre
        OR dynp_data_pbo-zzproject        NE dynp_data_pai-zzproject.
* update standard fields
          ls_mepoheader-zzpayment_agre   = dynp_data_pai-zzpayment_agre.
          ls_mepoheader-zzproject  = dynp_data_pai-zzproject.
          CALL METHOD l_header->set_data
            EXPORTING
              im_data = ls_mepoheader.
        ENDIF.
      WHEN OTHERS.
    ENDCASE.  
Then we have to implement one more BADI to display the tab and update the values.
Implement the BADI ME_PROCESS_PO_CUST. This cannot be used multiple times.  
In this, we have methods (PROCESS_HEADER,PROCESS_ITEM).if we need to any validations for the fields we can write the logic here in this methods. In my case I need to check for the document type which I implemented in the method (PROCESS_HEADER).  
FIELDSELECTION_HEADER: I have implemented this method as my requirement is to show the fields for particular document types only.  
Final output:  

BADI _ Business Add-Ins Scenario - Custom Tab in VL01N Header

- Adding a custom tab in VL01N
1) Append structure in LIKP
2) Create a function group and create 2 FMs transferring data to screen and other from screen
3) Create Screen in the function group with required fields mapped to fields created in Append structure to LIKP
4) In Se18 provide the BADI name as LE_SHP_TAB_CUST_HEAD , it has 3 methods
- For activating the custom TAB
- For transfering data from screen
- For transfering data to Screen


 
  ef_caption = text-000. “ Screen Caption
  ef_program = 
'SAPLZSD537_HEAD'.“SAPL Followed by the Function group created ZSD537_HEAD
  ef_position = 
4. “ Tab Position
  ef_dynpro  = 
'9000'. “ Screen Number
  cs_v50agl_cust = 
'X'.


Go to method Transfer Data to Sub screen
Call the SET Function Module Go to method Transfer Data From Sub screen
Call the Function Module, Get data from screen
Activate BADI Implementation.
 Go to Header Details
 Go to the tab Additional Data.

Friday, August 12, 2016

LSMW Interview Questions

What is the LSM Workbench?
The LSM Workbench is an R/3-based tool that supports single or periodic data transfer from your non-SAP system to R/3
What are the core functions of the LSM Workbench?
Importing legacy data from PC spreadsheet tables or sequential files
Converting data from its original (legacy system) format to the target (R/3) format
Importing the data using the standard interfaces of R/3 (IDoc inbound processing, batch input, direct input)
Which data can be migrated using the LSM Workbench?
By means of standard transfer programs: a wide range of master data (e.g. G/L accounts, customer master, vendor master, material master, bills of material) and transaction data (e.g. financial documents, sales orders)
By means of recording of transactions: further data objects (if the transaction can be run in batch input mode)
Can I be certain that the imported data is consistent?
Yes. The data is loaded via the standard interfaces of the applications. This will include all checks that are run for online transactions. Invalid data will be rejected.
Can I be certain that conversions are carried out identically across the applications?
Yes. The LSM Workbench works on the principle of central (reusable) rules. This approach guarantees that, for example, the material number is converted in the same way wherever the reusable rule is used for conversion.
Do I need an extensive knowledge of ABAP to use the LSM Workbench?
No. The LSM workbench provides the main conversion techniques at the push of a button. For complex conversions, individual ABAP coding can be added.
Do I have to migrate table by table?
No. Business objects such as material master, customer master or FI document are migrated
Can I transfer data that is on my PC?
Yes. The LSM workbench can read the data directly from your PC. Only when using the periodic interface, the data has to be on a server accessible by R/3
Is the LSM Workbench part of the standard R/3 system?
No. The LSM Workbench can be downloaded for free from SAPNET: http://service.sap.com/LSMW
Is there an extra charge for the LSM Workbench?
No. The LSM Workbench is available free of charge to SAP’s customers and partners
Is there an LSM training course?
There is no specific training course for LSMW
LSMW is part of the 5-day standard training BC420
Workshops at customer site are done at customers charge
Examples in the media center can be used for self-study
Can I migrate from R/3 to R/3 via LSMW?
Yes, but:
Export has to be programmed
Source structures have to be defined
Fields of the source structures can be loaded from the dictionary
Mapping has to be done manually รจ a lot of fields!! Automatic fieldmapping might be used
Import of large data amounts can take a lot of time (most of the time data amount is higher than for Migration from legacy systems)
History data can not be build up most of the time
Can I build periodic interfaces using LSMW?
Yes. It is possible to build periodic interfaces using the frame program /SAPDMC/SAP_LSMW_INTERFACE

Thursday, August 11, 2016

ALE IDOCS Interview Questions

Question1 : How to achieve serialization in ALE / IDOCS


 Serialization is the concept of sending IDOCS of different message types in particular sequence . This can be achieved by creating a serialization groups both in sending and receiving systems.







While creating the outbound partner profile add SERDAT and for all the message types below should be clicked




Enable Change pointers globally using BD61 and for the message types BD50

Partner Profile in the receiving system should appear as below all the message types from the serialization group should have "Trigger by Background program" and SERDAT alone should have "Trigger Immediately"







1. Creating of IDOCs : The report RBDSER01 creates the IDocs for a serialization group. The serialization group to be created is specified as a parameter in this report. The report selects all the master data change pointers assigned to this serialization group. The IDocs are then created from the change pointers.

2. Dispatch of the IDOCs : After the IDocs have been created the report RBDSER02 dispatches the IDocs belonging to a serialization group. The name of the serialization group to be sent is specified as a parameter in this report. You can also specify the receiving systems and in the time period that IDocs can be created/changed.

3. Report RBDSER02  schedules a report RBDSER03 that checks whether all the IDOCS from the serialization group have been sucessfully sent to the receiving system .If they have, a control message of message type SERDAT is sent to the receiving system and posts the serialization group there. To do this specify in the parameters of report RBDSER02 the time that should be scheduled after sending report RBDSER03.
You also have the option to always dispatch the control message. This means dispatch it even if all the IDocs have not been passed to the receiving system. This means that IDocs arriving in the receiving system can be processed even if some IDocs are still being transferred. However, serialization difficulties may occur.


The processing of inbound IDocs of a serialzation group can be directly started by the Report RBDSER04.


Question2 : What happens when one of the IDOCs in the serialization group fails ? 

 Scenario : MATMAS and CLFMAS are in the serialization group with sequence 1 and 2 respectively .
If the Material IDOC(MATMAS) fails it will not allow the classification IDOC(CLFMAS) to get processed as they are serialized.

If the Material IDOC(MATMAS) goes through and gets posted and  if the  classification IDOC(CLFMAS) fails later it doesent cause the material idoc posting to be rolled back .The material idoc remains posted as such and the material values will be updated successfully in the destination.

The idocs are serialized to send the idocs in a specific order. The failure of one idoc will not cause the other to rollback.Any gaps in the sequence will mean that IDocs are missing, either because the transfer did not work, or because earlier IDocs were not posted successfully. In this case the IDoc is assigned status 66 and must be posted again with the program RBDAPP01.


Question3 : How do you reprocess an IDOC

BD87 - It will process the same IDOC in error 
If you are using WE19 it will create a new IDOC . 

Question4 : How to improve the performance of Inbound IDOC processing 

This is how:
A) Switch from immediate IDoc processing to batch
Program that transfers the IDOCS is "RBDAPP01"

B) Use parallel processing option: Program Name : "RBDAPP01" 

C) Use IDoc packets rather than single IDoc posts


Question5 : IDOC filtration process , Tcodes and example 

The technique of filtering at the IDoc level enables to send a subset of data that is relevant for a receiving system

For IDOC Filtration we have to search for a suitable filtering object in transaction BD59.

In the distribution model select the Filter Object , provide the values. 

Like MRP view of one plant should be sent to other plant while the material master distribution through BD10.


Question 6 : What is an Idoc status?  What are the different types of Idoc statuses that you know ?

When an IDoc is sent from one system to another , it goes through variuos stages.The IDoc status indicates the stage that the Idoc in currently in.
There about 75 IDoc statuses.There is no way you can remember those all .
Don't even try to ! You will probably remember only those on which you have worked .

But here are a few that you should know:
0-49 indicates an Outbound IDoc and 50-75 as Inbound IDoc. 

01  IDoc generated
02  Error passing data to port
03  Data passed to port OK

51  Application document not posted
52  Application document not fully posted
53  Application document posted


Question 7 : Explain about Change pointers : 


Change Pointers are log entries to remember all modified records relevant for ALE. Change pointers are log entries to table BDCP, which are written every time a transaction modifies certain fields.

A) TCODE:   BD50 (Activate change pointer for message type)  
Below screen shows Activating change pointer for Message Type 'MATMAS'  

B) TCODE:   BD66 (Segment Field-Change Document field)  
Change Document field should exist in this TCODE align particular Segment type.  
The above screen shows the fields in change document.  
Message Type: MATMAS
Segment Type: E1MAKTM  

The below screen shows actual fields in segment.  
 
C) TCODE:   BD61 (Activate change pointers generally)  
The Below screen shows how to activate change Pointers generally.  

Creating IDOC with change pointers.

 TCODE:   BD21
Purpose: Create IDOC type from change pointers
Program: RBDMIDOC  
We can create IDOCS from change pointers with the report RBDMIDOC
The report tells how many master and communication IDocs have been created.    


Question 8 : What is the main difference between ALE/IDOCs and BAPI 



ALE/IDOCS are used for asynchronous information interchange and BAPI for synchronous .


Question 9 : I have to send same IDOC to multiple receiving systems , how to achieve the same .


There will be 1 sender and multiple receiver in SALE . For each combination BD64 ( distribution model has to be created with the message type added . 
There will be multiple IDOCS having the same data sent to different receivers . 

Some Theoretical Questions : 


Question 10:  What is ALE ?
ALE stands for Application Link Enabling. As it's name indicates , it links two systems.
ALE is a technology that can enable exchange of data between two different Systems ( Sap - Sap OR Sap - Non Sap). ALE technology enables distributed yet integrated installation of SAP systems.
ALE architecture comprises of 3 layers : 

Application layer refers to the application data ( SD , MM , FI or data for any SAP application ) . In this layer the data is collected to be distributed and then sent to the distribution layer.

Distribution layer determines to whom should the data generated by the application layer has to be distributed i.e. it is in the distribution layer that the recipient is determined , the data is formatted or filtered and then an actual is created.

Communication layer takes the responsibility of delivering the Idoc to the receiving system and communicates to the receiving system via tRFC , File ports , FTP or TCP/IP etc.

ALE uses IDoc as a vehicle to transfer data between two systems.

Question 11:  What are the types of records in SAP ALE Idocs and where is this information stored ?
There are three types of records in SAP ALE Idocs:
Control Records: Control record information for an IDoc is stored in standard table EDIDC.
Data Records:     Control record information for an IDoc is stored in standard table EDIDD.
Status Records:   Control record information for an IDoc is stored in standard table EDIDS.

Question 12 : Can you send IDOCs without maintaining BD64 ?

Yes you can send IDOCs but its best practices to utilize the capabilities of Distribution Model in order like filtering .



Question 13 : How can you send IDOCs through program : 

Using Master_IDOC_DISTRIBUTE 

Question 14 : IDOCS are in status 30 how can you send these IDOCS to receiving system : 

RSEOUT00 program can be called and one can provide the Message TYpe , receiving system details , packet size .

Question 15 : How can you send IDOCs through message control : 

Example : PO create ME10 /change ME11




I will try to add more questions and detailed explanation to answer to this thread .