Friday, May 8, 2015

SAP ABAP : RFC and BAPI

http://www.erpgreat.com/abap/interview-question-on-bapi-rfc-abap-objects-tables.htm


  • BAPI are RFC enabled function modules. and BAPI are business object. you create a business object and then store this to your BOR (business object Repository).
  • BAPIs are provided to outside world so they can interact with SAP from non SAP system like JAVA etc.
  • in case of BAPI there is no direct system call from external system although in case of RFC it is a direct system call,
  • RFC cannot get or store data from/to SAP alone, to do this we must use BAPI,
  • RFC is a protocol used by SAP for remote communication.
========================================================================
Function module  
Difference between RFC and BAPI: 
=> BAPIs are RFC enabled function module. BAPI stands for business application programming interface. 
=> A BAPI is a function module which can be called remotely using RFC technology. 
=> BAPIs are function modules stored in a repository and released for public use. 
=> RFC is a methodology or protocol to used to call a function in R/3 system from a system external to R/3 and vice versa. 
=> RFC are the function modules which can be written by "programmers" for their particular requirement, these don't come as "package" as in case of BAPIs where they are already available readily. 
Types of RFC: 
=> Synchronous RFC: RFC call require both the systems to be available at time of the call. calling system wait for the called system to complete its execution before going further to the execution. 
=>Asynchronous RFC:  
The called function must be present during the call. 
Function control returns to the calling program directly after the call. 
The parameters of asynchronous RFCs are not logged to the database, but sent directly to the server. 
Asynchronous RFCs allow the user to carry on an interactive dialog with the remote system. 
When the caller starts an aRFC, the called server must be available to accept the request. 
The calling program can receive results from the asynchronous RFC. 

Using aRFC is always a good idea when real-time communication is established with a remote system, where processing in the calling program should not be interrupted until the results of the called function module have been obtained (the term asynchronous is used in this sense here). 

=> Transactional RFC:  
The remote system need not be available at the time when the RFC client program is executing a tRFC. The tRFC component stores the called RFC function, together with the corresponding data, in the SAP database under a unique transaction ID (TID ). 
If a call is sent, and the receiving system is down, the call remains in the local queue until a later time. The calling dialog program can proceed without waiting to see whether or not the remote call was successful. If the receiving system does not become active within a certain amount of time, the call is scheduled to run in batch. 

Disadvantage : tRFC uses LUW to process all the request if target system is not available. so we cannot guarantee that all the request should be executed in the same sequence as they are called from the calling system. Many LUW much heavy process. 
=> Queued RFC:  
To guarantee that multiple LUWs are processed in the order specified by the application, tRFC can be serialized using queues (inbound and outbound queues). This type of RFC is called queued RFC (qRFC). 
qRFC is therefore an extension of tRFC. It transfers an LUW (transaction) only if it has no predecessors (based on the sequence defined in different application programs) in the participating queues. 
Implementation of qRFC is recommended if you want to guarantee that several transactions are processed in a predefined order. 

=> Background RFC: 
bgRFC is the successor to tRFC and qRFC, with significant improvements in terms of performance and functionality. 


========================================================================

SAP ABAP : SMART FORMS

http://sap-interview-questions-and-answers.blogspot.in/2012/07/sap-webdynpro-abap-interview-questions.html


*An SAP R/3 system has 2 clients 800 & 810. You create an SAP Script Z_Script and a Smartform Z_Smartform in client 800. Will both Z_Script and Z_Smartform be available in client 810 as well?
Client 200 will have just the Smartform Z_Smartform and not the SAP Script Z_Script.

SAP-Script is client dependent whereas SMARTFORM is client independent. Many people don't understand what this is all about. The above answer should suffice. However, if you still do not understand this, find an SAP system where you have 2 clients. Create a dummy Smartform / script in one client and check whether they exist in the other client.

*You have created a Smartform in DEV environment. Then you migrated the Smartform to PROD environment. Will the name of the function module be same in DEV and PROD?
Once you transport the Smartform from DEV to PROD environment, a new function module name for the Smartform in generated in the PROD environment. For a particular Smartform , generated function module names are different in different systems.One can get the name of the function module for Smartform by passing the Smartform name to FM SSF_FUNCTION_MODULE_NAME.


===================================================================================
  • SMART FORMS TRANSACTIONS:
    • SMARTFORMS (SE71 for scripts)
      SMARTSTYLES (se72 for scripts)
  • We can copy smartforms directly while in scripts we have to use utilities->copy from client option for this.
  • Smart forms are client independent.
  • smart forms can be created without a main window.
  • utiliteis->migrate-> ... to change SAP Script to a Smart forms.
  • SSF_FUNCTION_MODULE_NAME to get the function module name for smart form.
  • take a thumb rule that always create print program first than the smart form because we know the structure we have to display.
  • we create a print program for a smart form because we want to improve the performance of our application.
  • If we write all logic and data fetch logic in the smart forms itself, it may hamper the performance.
  • in script we use command IT (Item line) to loop data of an internal table and display it.
  • RS_LXE_RECORD_TORDER to transport request with translation from SE63.
  • pdf!
  • background picture
  • bar code
  • graphic
  • alternative
  • Configure your Smartform name to output type using Tcode V/83


  • Finding Test data corresponding to the output type  

Go to transaction SE11 and enter the name of the table as NAST. Input condition type into KSCHL field.
B.    Execute and use value of OBJKEY.  
  
The value of the object key can then be used to look at the actual Purchase order / Sales Order etc. for which the Smartform was being developed.  
=====================================================================================
Windows in SMART FORM 
  • Main Window : 
  • Copy Window:
    • The variable SFSY-COPYCOUNT will give us the count of the copy.






SAP ABAP : BDC

http://sap-interview-questions-and-answers.blogspot.in/2012/07/sap-webdynpro-abap-interview-questions.html

What is BDC and why do we use BDC ?
BDC ( Batch Data Communication ) also known as batch input is a technique by which large volumes of data can be transferred from Non Sap or Legacy systems to SAP systems.

The two methods for BDC are:
  • Session Method
  • Call TRANSACTION Method
hat is the difference between Call Transaction Method and the Session method ?

Session Method
Call Transaction
Session method id generally used when the data volume is huge.
Call transaction method is when the data volume is   low
Session method is slow as compared to Call transaction.
Call Transaction method is relatively faster than Session method.
SAP Database is updated when you process the sessions. You need to process the sessions separately via SM35.
SAP Database is updated during the execution of the batch input program.
Errors are automatically handled during the processing of the batch input session.
Errors should be handled in the batch input program.
Question 2: How do you do BDC for a table control?
With other things as usual, there is a special trick that you have to use while doing BDC for table control.
You need to use the BDC OKCODE '=P+'.
Its the BDC_OKCODE for Page down that can be used for scrolling down in table control.

Question 3: Is there any method apart from BDC for data upload to SAP?
Apart from BDC and LSMW, you can use BAPIs to upload data into SAP.
BAPIs should be preferred over BDCs, because they process data faster than BDC.
A BAPI is faster since it updates Database "directly". Whereas BDC calls transaction and goes through the whole screen sequence as any user would do.

BAPI
BDC
BAPI is faster than BDC.
BDC is relatively slower than BAPI.
BAPI directly updates database.
BDC goes through all the screens as a normal user would do and hence it is slower.
No such processing options are available in BAPI.
Background and Foreground processing options are available for BDC.
BAPI would generally used for small data uploads.
BDCs would be preferred for large volumes of data upload since background processing option is available.
For processing errors, the Return Parameters for BAPI should be used.This parameter returns exception messages or success messages to the calling program.
Errors can be processed in SM35 for session method and in the batch input program for Call Transaction method.

Question 4: How do you process errors in Call Transaction method ?

Let's have a look at the syntax for CALL TRANSACTION method.
Sample code:
DATA: BEGIN OF G_T_MESSTAB OCCURS 0.
        INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF G_T_MESSTAB.

CALL TRANSACTION 'MB11'
    USING G_T_BDCDATA
          MODE 'E'
          UPDATE 'S'
          MESSAGES INTO G_T_MESSTAB.

All the error messages will be trapped inside G_T_MESSTAB.

RSBDCSUB : to Schedule BDC.

Question 6: What is the structure of the BDC table?

The BDCDATA consists of the following fields:
§  PROGRAM [CHAR 40] - Online program name.
§  DYNPRO [NUMC 4] - Screen number.
§  DYNBEGIN [CHAR 1] - Flag to indicate the start of a new screen.
§  FNAM [CHAR 132] - Field name of a screen field to be filled with data.
§  FVAL [CHAR 132] - The actual value to be filled into the specified screen field.



Question 7: What is the difference between BDC_OKCODE and BDC_CURSOR?


BDC_OKCODE: is used for storing commands during the recording. like '/00' is the command for 'ENTER' Key.
BDC_CURSOR: contains the cursor position. it contains the field in which cursor will be.

EExample code:
pperform bdc_field       using 'BDC_CURSOR'
                                                'PROJ-PSPID'.
pperform bdc_field       using 'BDC_OKCODE'
                                                '=BU'.

Question 8: What are the 3 methods that we use in sequence in a Batch input session method ?

1) BDC_OPEN_GROUP for opening the Batch Input Session
2) BDC_INSERT for inserting the transactional data into SAP
3) BDC_CLOSE_GROUP for closing the Batch Input Session

General Information about a session is stored in table APQI.
Transaction data for a session is stored in table APQD.

Question 9: What is your approach for writing a BDC program?

Identify the Tcode and do the recording in SHDB to populate the BDCDATA.



Once the recording is done , one can Transfer it to the Batch input program.










In the batch Input program , The transactional data is read from the file to an internal table.

Then one can loop over the transactional data in the internal table and start uploading the data in SAP either by CALL TRANSACTION method or by creating sessions through the batch input program.

Question 10: How do you process errors in Session method ?
You can go to Transaction SM35 , Choose the session name and click on Process.

Question 12: What is the difference between Synchronous and Asynchronous Update ?

In Synchronous update , the database is updated before the next transaction is taken for processing in a batch input.

In Asynchronous update , the system doesn't wait for updating the database before the next transaction is taken for processing in a batch input.

uestion 14: How do you read files from the Application server ?

You can use the commands:
OPEN DATASET ---> opens the file(dataset) either in read /write mode.
READ DATASET ---> Read the file
CLOSE DATASET ---> Close the dataset once the date has been read .






Wednesday, April 22, 2015

SAP DMS : How to add filter button in originals of a DIR

SAP DMS : How to add filter button in originals of a DIR

Objective: user should be able to see originals having a particular original type by default. there should be a filter button in case we have to remove filter and display all originals of DIR. currently we have following display in CV03N:



SPRO Path for customization: Here we can define according to the user profile which originals user want to see and authorized to see.
now with this function we can define the application type for the user. and user by default only able to see these files:
Now we add the original type we want to see by default. here we can add multiple original types if we want.

Note : if no entry defined in this column this means user see all available originals to the DIR and there will be no filter button.

Now if we go to CV03N and we open the document we see only CMP file and there is a filter button to toggle between see all files or only filtered files :