Thursday 24 January 2013

Smartform Debugging in SAP

Smart form is an output format. It’s just like a ready to print document. We can design the form to be printed in different ways with the requisite information on it. Some examples are Invoices, Purchase Order, Sales Order…

As we all know, there are two entities involved in smart form.
1.       Smart form design.
2.       Driver program.
Sometimes it happens that the information which needs to get printed on the form is missing or customer wants to display some new information on the form or client wants a change in the design format (Roll-Out Projects) and so on… At that point in time it is important to know from where the data is being retrieved to make the necessary changes. We can find out how, what and from where the data is retrieved through Debugging.
To debug a smart form we must know the smart form name and the driver program associated with it. It’s the functional consultant who will provide us this information. But if we know the smart form name we can find its driver program by
1.       NACE Tcode à Output Types à Processing Routines.
2.       TNAPR Table à Contents à Form Name (Smart form name).
3.       SPRO Tcode. 
As for as i know, Smartform can be debugged in four ways.
  1. By setting breakpoints in the function module.
  2. By setting breakpoints in the driver program.
  3. By setting breakpoints in the smartform include program.

Setting breakpoints in the function module.

Debugging a smart form is just like debugging a function module. To debug a smart form we have to follow the below steps.
  • Tcode SMARTFORMS à Enter the smart form name à Goto Environment Menu àFunction Module Name à Copy the Function Module Name (Ex: 1BCDWB/SF00000142)
  • Tcode SE37 à Paste the Function Module Name à Put the breakpoints in the required places
  • Tcode SMARTFORMS à Enter the smart form name à Test button à Test/Execute à give the Output Device as LP01 à Click on Print preview à Now the debugger session will open at the place where you have put the breakpoints.

Setting breakpoints in the driver program.

In order to set the breakpoints in the driver program,
  • Tcode SE38 and provide the program name and display it.
  • Put the breakpoints in the relevant places of driver program.
  • Try to print the smart form by giving the default printer name. Then the moment you click on print preview button, the smart form will enter the debug mode.
Setting breakpoints in the smartform include program.

Every time when the smartform is activated a corresponding include program is generated. To find out the corresponding include program follow the below steps.
  • Tcode SMARTFORMS à Enter the smart form name à Goto Environment Menu àFunction Module Name à Copy the Function Module Name (Ex: 1BCDWB/SF00000142).

  • Goto Tcode SE38 and paste the function module name and before displaying it Just prefix "L" before SF and postfix "F01" after 142. Now the include program name is : 1BCDWB/LSF00000142F01.
  • Put the breakpoints in the required places.
  • Try to print the smart form by giving the default printer name. Then the moment you click on print preview button, the smart form will enter the debug mode.

We can also use popup window debugging method to debug a smartform and to do that follow the below steps. 
  • Try to print the smartform and when the popup appears drag the .BAT file and drop it on the popup. You will see "Debugger switched on" message in the status bar.
  • After dropping the .BAT file on the above popup just click on the print preview you will enter the debug mode.

Sunday 20 January 2013

Reprocessing and Function Module Testing of Idocs.


In an Idoc there are mainly three segments. Control record (EDIDC), Data record (EDIDD) and Status record (EDIDS). Idoc can have many data and status records but there can be only one Control record.

To reprocess an Idoc, first we have to know the status of it. For that we have to execute the Tcode WE02/WE05 which displays the entire Idoc list and from there you can find the Idoc which you have to reprocess.

Steps to fallow:

  1. We02/05 --> Display all Idocs --> Your Idoc --> Status Record (if the Idoc is successfully processed the status would be 03 for Outbound Idoc and 53 for Inbound Idoc).
  2. BD87 --> Idoc inbound process (Keep the cursor on it) --> Process.

You will encounter some scenario where you have to find the function modules used in Idoc to test why the Idoc is not getting triggered or not getting reprocessed. In those scenarios fallow the above steps to know the status. And to know the function modules we have to fallow the below steps.

Steps to fallow:

  1. WE20 --> Partner Type -->In inbound parameters select the message type (double click) --> Process Code (Double Click) --> You will find the function module (Identification).
  2. We19 --> Inbound function module -->Select call in debugging mode --> You will enter the debugger.